mirror of https://github.com/dzavalishin/openpod
dev, prop hdr, uint test suit
This commit is contained in:
parent
21b6afd147
commit
8b30732a89
|
@ -0,0 +1,12 @@
|
|||
// Just include all main specification headres
|
||||
|
||||
#include "pod_types.h"
|
||||
|
||||
#include "pod_dev_class.h"
|
||||
#include ""
|
||||
#include ""
|
||||
#include ""
|
||||
#include ""
|
||||
#include ""
|
||||
#include ""
|
||||
#include ""
|
|
@ -0,0 +1,121 @@
|
|||
#ifndef POD_DRIVER_H
|
||||
#define POD_DRIVER_H
|
||||
|
||||
#include "pod_properties.h"
|
||||
|
||||
//*******************************************************************
|
||||
//
|
||||
// OpenPOD
|
||||
//
|
||||
// Driver level definitions
|
||||
//
|
||||
//*******************************************************************
|
||||
|
||||
struct pod_driver;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// Driver methods, required
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
|
||||
errno_t (*pod_construct)( struct pod_driver *drv );
|
||||
errno_t (*pod_destruct)( struct pod_driver *drv );
|
||||
|
||||
|
||||
errno_t (*pod_activate)( struct pod_driver *drv );
|
||||
errno_t (*pod_deactivate)( struct pod_driver *drv );
|
||||
|
||||
|
||||
errno_t (*pod_sense)( struct pod_driver *drv );
|
||||
//errno_t (*pod_probe)( struct pod_driver *drv, pod_bus *bus, pod_bus_dev *bdev );
|
||||
|
||||
} pod_dev_required_f;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// Driver methods, optional
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
pod_sleep_undefined, // Do the best you can
|
||||
pod_sleep_fast, // Must take uSeconds to wake
|
||||
pod_sleep_norm, // Must take mSeconds to wake
|
||||
pod_sleep_slow, // Must take seconds to wake
|
||||
pod_sleep_undefined, // Can take forever (disk spin) to wake
|
||||
} pod_sleep_level;
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
errno_t (*pod_get_property)( pod_properties *p, const char *pName, char *pValue, int vlen );
|
||||
errno_t (*pod_set_property)( pod_properties *p, const char *pName, const char *pValue );
|
||||
errno_t (*pod_list_properties)( pod_properties *p, int nProperty, char *pName, int vlen );
|
||||
|
||||
|
||||
errno_t (*pod_save_state)( struct pod_driver *drv, char **state_xml );
|
||||
errno_t (*pod_load_state)( struct pod_driver *drv, const char *state_xml );
|
||||
|
||||
errno_t (*pod_sleep)( struct pod_driver *drv, pod_sleep_level l );
|
||||
errno_t (*pod_awake)( struct pod_driver *drv );
|
||||
|
||||
} pod_dev_optional_f;
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// Driver descriptor
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
|
||||
typedef struct pod_driver
|
||||
{
|
||||
char magic[4]; // magic number
|
||||
|
||||
// Minor change means API is extended, but compatible
|
||||
uint8_t API_version_major;
|
||||
uint8_t API_version_minor;
|
||||
|
||||
// i32, i64, arm32, arm64, mips32, mips64, ...
|
||||
uint8_t arch_major;
|
||||
uint8_t arch_minor; // undefined, must be 0
|
||||
|
||||
uint8_t class_id;
|
||||
uint8_t pad0;
|
||||
uint8_t pad1;
|
||||
uint8_t pad2;
|
||||
|
||||
//uint32_t capabilities; // tbd.
|
||||
|
||||
char *name;
|
||||
|
||||
// lifecycle entry points function pointers
|
||||
pod_dev_required_f calls;
|
||||
pod_dev_optional_f *optional;
|
||||
|
||||
pod_properties *prop;
|
||||
|
||||
/**
|
||||
* òàáëèöà ôóíêöèé ÿäðà äëÿ äðàéâåðà - èñïîëüçóåòñÿ åñëè íåëüçÿ ïðîëèíêîâàòü
|
||||
* íàïðÿìóþ (ôóíêöèè çàìåíÿþòñÿ ìàòðîñàìè, êîòîðûå ÷åðåç ýòó òàáëèöó èäóò â
|
||||
* ÿäðî - ñì. pod_kernel_api.h)
|
||||
**/
|
||||
kernel_f *kernel_driver_api;
|
||||
|
||||
// private driver’s data structure
|
||||
void *private_data;
|
||||
|
||||
} pod_driver;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // POD_DRIVER_H
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
|
||||
#include "pod_types.h"
|
||||
#include "pod_driver.h"
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
|
@ -55,11 +56,12 @@ errno_t pod_kernel_signal_cond( pod_cond_t *cond );
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Logging
|
||||
// Logging and panic
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
errno_t pod_log_print( int loglevel, const char **format, ... );
|
||||
void pod_panic(const char *fmt, ...)
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
|
||||
//*******************************************************************
|
||||
//
|
||||
// OpenPOD
|
||||
//
|
||||
// Driver level definitions
|
||||
//
|
||||
//*******************************************************************
|
||||
|
||||
typedef enum
|
||||
{
|
||||
pt_int32,
|
||||
pt_mstring, // malloced string
|
||||
pt_enum32, // enum int32 - unimpl!
|
||||
} pod_property_type_t;
|
||||
|
||||
|
||||
struct pod_property;
|
||||
|
||||
typedef struct pod_properties
|
||||
//u_int32_t prefix; // 4-byte char prefix of this group, like 'dev.', 'gen.' or 'fsp.'
|
||||
//const char * prefix; // 4-byte char prefix of this group, like 'dev.', 'gen.' or 'fsp.'
|
||||
|
||||
struct pod_property *list;
|
||||
size_t lsize;
|
||||
|
||||
//! Get pointer to property value
|
||||
void * (*valp)(struct pod_properties *ps, void *context, size_t offset );
|
||||
|
||||
|
||||
|
||||
} pod_properties;
|
||||
|
||||
|
||||
|
||||
typedef struct pod_property {
|
||||
pod_property_type_t type;
|
||||
const char *name;
|
||||
size_t offset;
|
||||
void *valp;
|
||||
|
||||
char **val_list; // for enums
|
||||
|
||||
void (*activate)(struct pod_properties *ps, void *context, size_t offset, void *vp );
|
||||
errno_t (*setf)(struct pod_properties *ps, void *context, size_t offset, void *vp, const char *val);
|
||||
// unused yet
|
||||
errno_t (*getf)(struct pod_properties *ps, void *context, size_t offset, void *vp, char *val, size_t len);
|
||||
} pod_property;
|
||||
|
||||
|
||||
|
||||
#define PROP_COUNT(__plist) (sizeof(__plist)/sizeof(__plist[0]))
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// Generic property manipulation code
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
|
||||
errno_t pod_gen_setproperty( pod_properties *ps, void *context, const char *pName, const char *pValue );
|
||||
errno_t pod_gen_getproperty( pod_properties *ps, void *context, const char *pName, char *pValue, int vlen );
|
||||
errno_t pod_gen_listproperties( pod_properties *ps, int nProperty, char *pValue, int vlen );
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// Generic property manipulation code for a driver.
|
||||
//
|
||||
// Can be filled into the driver optional methods table.
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
|
||||
struct pod_driver;
|
||||
|
||||
errno_t gen_dev_listproperties( struct pod_driver *drv, int nProperty, char *pValue, int vlen );
|
||||
errno_t gen_dev_getproperty( struct pod_driver *drv, const char *pName, char *pValue, int vlen );
|
||||
errno_t gen_dev_setproperty( structpod_driver *drv, const char *pName, const char *pValue );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// Generic property manipulation code for a device.
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
|
||||
struct pod_device;
|
||||
|
||||
errno_t gen_dev_listproperties( struct pod_device *dev, int nProperty, char *pValue, int vlen );
|
||||
errno_t gen_dev_getproperty( struct pod_device *dev, const char *pName, char *pValue, int vlen );
|
||||
errno_t gen_dev_setproperty( struct pod_device *dev, const char *pName, const char *pValue );
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue