Home | History | Annotate | Download | only in hardware
      1 #ifndef __HARDWARE_HARDWARE_H
      2 #define __HARDWARE_HARDWARE_H
      3 
      4 #include <stdint.h>
      5 
      6 #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
      7 
      8 #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T')
      9 #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T')
     10 
     11 #define HARDWARE_HAL_API_VERSION 0
     12 
     13 struct hw_module_t;
     14 struct hw_module_methods_t;
     15 struct hw_device_t;
     16 
     17 typedef struct hw_module_t {
     18     uint32_t tag;
     19     uint16_t module_api_version;
     20     uint16_t hal_api_version;
     21     const char *id;
     22     const char *name;
     23     const char *author;
     24     struct hw_module_methods_t* methods;
     25     void* dso;
     26 } hw_module_t;
     27 
     28 typedef struct hw_module_methods_t {
     29     int (*open)(const struct hw_module_t* module, const char* id,
     30                 struct hw_device_t** device);
     31 } hw_module_methods_t;
     32 
     33 typedef struct hw_device_t {
     34     uint32_t tag;
     35     uint32_t version;
     36     struct hw_module_t* module;
     37     int (*close)(struct hw_device_t* device);
     38 } hw_device_t;
     39 
     40 #endif
     41