Commit 1381e8c5 authored by Lucas Russo's avatar Lucas Russo

hal/dev_mngr/*: add new structure to monitor DEVIOs intances

This is the first step into making the dev_mngr a real
monitoring process.

This is the first patch towards the solution of
github issue #1
parent 7fb0abe5
......@@ -5,7 +5,8 @@ dev_mngr_DIR = hal/dev_mngr
# makefile
dev_mngr_core_OBJS = $(dev_mngr_DIR)/dev_mngr.o \
$(dev_mngr_DIR)/dev_mngr_core.o \
$(dev_mngr_DIR)/dev_mngr_err.o
$(dev_mngr_DIR)/dev_mngr_err.o \
$(dev_mngr_DIR)/dev_mngr_dev_info.o
dev_mngr_INCLUDE_DIRS = $(dev_mngr_DIR)
dev_mngr_OUT = dev_mngr
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#include <string.h>
#include "dev_mngr_dev_info.h"
#include "hal_assert.h"
#include "debug_print.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
#ifdef ASSERT_TEST
#undef ASSERT_TEST
#endif
#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \
ASSERT_HAL_TEST(test_boolean, DEV_MNGR, "dev_mngr_dev_info",\
err_str, err_goto_label, /* err_core */ __VA_ARGS__)
#ifdef ASSERT_ALLOC
#undef ASSERT_ALLOC
#endif
#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \
ASSERT_HAL_ALLOC(ptr, DEV_MNGR, "dev_mngr_dev_info", \
dmngr_err_str(DMNGR_ERR_ALLOC), \
err_goto_label, /* err_core */ __VA_ARGS__)
#ifdef CHECK_ERR
#undef CHECK_ERR
#endif
#define CHECK_ERR(err, err_type) \
CHECK_HAL_ERR(err, DEV_MNGR, "dev_mngr_dev_info", \
dmngr_err_str (err_type))
/* Creates a new instance of the Device Manager */
devio_info_t * devio_info_new (char *dev_pathname, uint32_t id, llio_type_e type,
devio_state_e state)
{
assert (dev_pathname);
devio_info_t *self = zmalloc (sizeof *self);
ASSERT_ALLOC (self, err_devio_info_alloc);
self->dev_pathname = strdup (dev_pathname);
ASSERT_ALLOC (self->dev_pathname, err_pathname_alloc);
self->id = id;
self->type = type;
self->state = state;
return self;
err_pathname_alloc:
free (self);
err_devio_info_alloc:
return NULL;
}
/* Destroy an instance of the Device Manager */
dmngr_err_e devio_info_destroy (devio_info_t **self_p)
{
assert (self_p);
if (*self_p) {
devio_info_t *self = *self_p;
free (self->dev_pathname);
free (self);
*self_p = NULL;
}
return DMNGR_SUCCESS;
}
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _DEV_MNGR_DEV_INFO_H_
#define _DEV_MNGR_DEV_INFO_H_
#include "czmq.h"
#include "dev_mngr_err.h"
#include "ll_io_utils.h" /* LLIO types */
enum _devio_state_e {
INACTIVE = 0, /* Nothing found yet */
READY_TO_RUN, /* Device found but not yet initialized */
RUNNING, /* Device is running */
STOPPED, /* Device is stopped momentarily */
KILLED /* Device is dead. Clean it and restart, if needed */
};
struct _devio_info_t {
uint32_t id; /* Device IO ID */
llio_type_e type; /* Device type */
char *dev_pathname; /* /dev pathname */
enum _devio_state_e state; /* Device IO state */
};
typedef struct _devio_info_t devio_info_t;
typedef enum _devio_state_e devio_state_e;
devio_info_t * devio_info_new (char *dev_pathname, uint32_t id, llio_type_e type,
devio_state_e state);
dmngr_err_e devio_info_destroy (devio_info_t **self_p);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment