hal_defs.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /****************************************************************
  2. ****************************************************************
  3. ** **
  4. ** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. ** **
  6. ** All Rights Reserved. **
  7. ** **
  8. ** 6145-F, Northbelt Parkway, Norcross, **
  9. ** **
  10. ** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. ** **
  12. ****************************************************************
  13. ****************************************************************/
  14. /*****************************************************************
  15. *
  16. * hal_defs.h
  17. * HAL Definitions
  18. *
  19. * Author: Vinoth kumar S <vinothkumars@ami.com>
  20. *
  21. *****************************************************************/
  22. #ifndef HAL_DEFS_H
  23. #define HAL_DEFS_H
  24. #include "Types.h"
  25. //#include "SensorMonitor.h"
  26. #define MAX_INT_HNDLR_NAME 25
  27. #define MAX_NM_HNDLR_NAME 25
  28. /**
  29. * @brief HAL Error code definitions
  30. **/
  31. typedef enum
  32. {
  33. /* HAL Error codes */
  34. HAL_ERR_NONE, /* No error */
  35. HAL_ERR_READ, /* Error in reading device */
  36. HAL_ERR_WRITE, /* Error in writing to device*/
  37. HAL_ERR_FUNC_NOT_SUPPORTED, /* Function called is not supported */
  38. } hal_status_codes_e;
  39. /**
  40. * @brief HAL Supported Hardware functions
  41. **/
  42. typedef enum
  43. {
  44. HAL_DEVICE_READ, /* General Read function */
  45. HAL_DEVICE_WRITE, /* General Write function */
  46. /* Special I2C functions */
  47. HAL_I2C_READ_REG, /* Read I2C register */
  48. HAL_I2C_READ_WRITE, /* Read/Write I2C */
  49. /* Special GPIO functions */
  50. HAL_SET_GPIO_DIR, /* GPIO Set direction */
  51. HAL_GET_GPIO_DIR, /* GPIO Get direction */
  52. HAL_SET_GPIO_POL, /* GPIO Set Polarity */
  53. HAL_GET_GPIO_POL, /* GPIO Get Polarity */
  54. HAL_SET_GPIO_OUTPUT_REG, /* GPIO Set output data register */
  55. } hal_func_codes_e;
  56. /**
  57. * @brief HAL Supported Device Types
  58. **/
  59. typedef enum
  60. {
  61. HAL_DEVICE_I2C, /* I2C Device */
  62. HAL_DEVICE_GPIO, /* GPIO Device */
  63. HAL_DEVICE_MMAP, /* Memory mapped device */
  64. HAL_DEVICE_FANPWM, /* FanPwm Device */
  65. } hal_dev_type_e;
  66. /**
  67. * @brief HAL Error code definitions
  68. **/
  69. typedef enum
  70. {
  71. HAL_SOURCE_PORT_UART, /* Source uart port */
  72. HAL_SOURCE_PORT_COM, /* Source com port */
  73. HAL_SOURCE_PORT_BOTH, /* Source both port */
  74. } hal_lpcuart_type_e;
  75. /**
  76. * @brief This structure holds device properties information
  77. **/
  78. typedef struct
  79. {
  80. int handle; /* Device handle */
  81. u8 sensor_num; /* sensor number if device is a sensor */
  82. int len; /* Device property length */
  83. u8 *pData; /* Device properties */
  84. } hal_dev_properties_t;
  85. /**
  86. * @brief This structure holds I2C device information
  87. **/
  88. typedef struct
  89. {
  90. u8 bus; /* Bus number in which the device resides */
  91. u8 slave_addr; /* Slave address of the device */
  92. u8 reg_num; /* Register to read/write */
  93. /* I2C read/write functionality uses the read/write buffer
  94. present in the HAL structure */
  95. } hal_i2c_t;
  96. /**
  97. * @brief This structure holds GPIO device information
  98. **/
  99. typedef struct
  100. {
  101. u8 pin; /* GPIO number */
  102. u8 dir; /* direction for this gpio */
  103. u8 pol; /* polarity for this gpio */
  104. } hal_gpio_t;
  105. /**
  106. * @brief This structure holds Memory mapped device information
  107. **/
  108. typedef struct
  109. {
  110. u32 addr; /* memory map to access */
  111. u8 mask; /* memory map mask to read or write data */
  112. } hal_mmap_t;
  113. /**
  114. * @brief This structure holds ADC device information
  115. **/
  116. typedef struct
  117. {
  118. int channel; /* adc channel to read */
  119. int raw; /* non-0 means driver returns raw data */
  120. } hal_adc_t;
  121. /**
  122. * @brief This structure necessary hardware information to access any device
  123. **/
  124. typedef struct
  125. {
  126. u8 fannum;
  127. unsigned int rpmvalue;
  128. unsigned int fanpwm;
  129. unsigned int fantach;
  130. }hal_fanpwm_t;
  131. /**
  132. * @brief This structure necessary hardware information to access any device
  133. **/
  134. typedef struct
  135. {
  136. unsigned char target;
  137. unsigned char dev_id;
  138. unsigned char write_len;
  139. unsigned char write_buffer[20];
  140. unsigned char read_len;
  141. unsigned char read_buffer[20];
  142. }hal_peci_t;
  143. /**
  144. * @brief This structure necessary hardware information to access any device
  145. **/
  146. typedef struct
  147. {
  148. unsigned char source_port_type;
  149. unsigned short source_port;
  150. unsigned short destination_port;
  151. }hal_lpcuart_t;
  152. typedef struct
  153. {
  154. unsigned char IsIntConfig;
  155. char IntrHndlrName[MAX_INT_HNDLR_NAME];
  156. unsigned char Int_num;
  157. unsigned char Intsource;
  158. unsigned char Intsensornum;
  159. unsigned char SensorType;
  160. unsigned char TriggerMethod;
  161. unsigned char TriggerType;
  162. unsigned char int_type;
  163. unsigned char int_input_data;
  164. }hal_intsensor_t;
  165. typedef struct
  166. {
  167. unsigned char IsNMconfig;
  168. unsigned char Sensor_Num;
  169. unsigned char SensorType;
  170. unsigned char NetFnLUN;
  171. unsigned char cmd;
  172. u16 NM_SensorID;
  173. unsigned char res_par;
  174. char FillHndlrName[MAX_NM_HNDLR_NAME];
  175. char ParseHndlrName[MAX_NM_HNDLR_NAME];
  176. }hal_nmsensor_t;
  177. /**
  178. * @brief This structure necessary hardware information to access any device
  179. **/
  180. typedef struct
  181. {
  182. hal_status_codes_e status_code; /* HAL api's status codes */
  183. hal_func_codes_e func; /* Hardware function */
  184. union {
  185. u8 *pbyte; /* All HAL apis return data
  186. in bytes using this pointer */
  187. u16 *pword; /* All HAL apis return data accesed
  188. in words using this pointer */
  189. u8 *pread_buf; /* All HAL apis return data
  190. in bytes using this pointer */
  191. };
  192. int read_len; /* bytes to read */
  193. u8 *pwrite_buf; /* All HAL apis write data
  194. from this buffer */
  195. int write_len; /* bytes to write */
  196. hal_dev_properties_t dev_prop; /* Device properties information */
  197. hal_dev_type_e dev_type; /* Type of the device */
  198. hal_i2c_t i2c; /* Hold I2C information */
  199. hal_gpio_t gpio; /* Hold GPIO information */
  200. hal_mmap_t mmap; /* Hold memory mapped information */
  201. hal_adc_t adc; /* Hold ADC information */
  202. hal_fanpwm_t fan; /* Hold FanPwm information Added by winston for fanpwm */
  203. hal_peci_t peci; /* Hold PECI information Added by winston for peci */
  204. hal_lpcuart_t lpcuart; /* Hold LPCUART information Added by jcchiu for lpcuart */
  205. hal_intsensor_t intsensor; /* Hold Interrupt Sensor information */
  206. hal_nmsensor_t nmsensor; /* Hold Interrupt Sensor information */
  207. } hal_t;
  208. /**
  209. * @brief HAL read/write/init function type definition
  210. **/
  211. typedef int (*phal_hndlr_t) (hal_t *phal);
  212. /**
  213. * @brief HAL Device Table
  214. **/
  215. typedef struct
  216. {
  217. // u16 device_enum;
  218. u16 device_instance;
  219. u16 sensor_number;
  220. u16 device_id;
  221. phal_hndlr_t device_read;
  222. phal_hndlr_t device_write;
  223. phal_hndlr_t device_init;
  224. void *device_properties;
  225. int properties_len;
  226. } device_tbl_t;
  227. /**
  228. * @brief HAL Sensor Properties Table
  229. **/
  230. typedef struct
  231. {
  232. u8 monitor_interval;
  233. u8 monitor_state;
  234. u16 normal_value;
  235. u8 poweron_delay; // Delay after chassis power on in seconds. 0 don’t delay
  236. u8 sysreset_delay; // Delay after chassis reset in seconds. 0 don’t delay
  237. } sensor_properties_t;
  238. typedef int (*preturn_total_t) (void);
  239. typedef device_tbl_t* (*preturn_tbl_t) (int);
  240. typedef struct
  241. {
  242. preturn_total_t pget_total_sensors;
  243. preturn_tbl_t pget_sen_tbl_entry;
  244. preturn_total_t pget_total_devices;
  245. preturn_tbl_t pget_dev_tbl_entry;
  246. } par_fn_t;
  247. #endif //#define HAL_DEFS_H