mirror of
				https://github.com/Telecominfraproject/OpenCellular.git
				synced 2025-10-31 18:38:06 +00:00 
			
		
		
		
	Merge pull request #250 from Telecominfraproject/ocware_alert_fw
Alert code for FW
This commit is contained in:
		| @@ -150,6 +150,7 @@ typedef struct AlertData { | |||||||
| } AlertData; | } AlertData; | ||||||
|  |  | ||||||
| void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | ||||||
|                         const void *data); |                         const void *data, const void *lValue, | ||||||
|  |                         OCMPActionType actionType); | ||||||
|  |  | ||||||
| #endif /* _SYS_CFG_FRAMEWORK_H */ | #endif /* _SYS_CFG_FRAMEWORK_H */ | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ SCHEMA_IMPORT const Driver_fxnTable CAT24C04_gbc_sid_fxnTable; | |||||||
| SCHEMA_IMPORT const Driver_fxnTable CAT24C04_gbc_inv_fxnTable; | SCHEMA_IMPORT const Driver_fxnTable CAT24C04_gbc_inv_fxnTable; | ||||||
| SCHEMA_IMPORT const Driver_fxnTable CAT24C04_sdr_inv_fxnTable; | SCHEMA_IMPORT const Driver_fxnTable CAT24C04_sdr_inv_fxnTable; | ||||||
| SCHEMA_IMPORT const Driver_fxnTable CAT24C04_fe_inv_fxnTable; | SCHEMA_IMPORT const Driver_fxnTable CAT24C04_fe_inv_fxnTable; | ||||||
|  | SCHEMA_IMPORT const Driver_fxnTable AT45DB641E_fxnTable; | ||||||
|  |  | ||||||
| static const Driver CAT24C04_gbc_sid = { | static const Driver CAT24C04_gbc_sid = { | ||||||
|     .name = "EEPROM", |     .name = "EEPROM", | ||||||
|   | |||||||
| @@ -34,8 +34,7 @@ ReturnStatus spi_reg_read(SPI_Handle spiHandle, OcGpio_Pin *chip_select, | |||||||
|                           uint32_t byte, uint8_t numofBytes); |                           uint32_t byte, uint8_t numofBytes); | ||||||
|  |  | ||||||
| ReturnStatus spi_reg_write(SPI_Handle spiHandle, OcGpio_Pin *chip_select, | ReturnStatus spi_reg_write(SPI_Handle spiHandle, OcGpio_Pin *chip_select, | ||||||
|                            void *regAddress, const uint8_t *data, |                            void *regAddress, uint8_t *data, uint32_t data_size, | ||||||
|                            uint32_t data_size, uint32_t byte, |                            uint32_t byte, uint8_t numofBytes); | ||||||
|                            uint8_t numofBytes); |  | ||||||
|  |  | ||||||
| #endif /* INC_COMMON_SPIBUS_H_ */ | #endif /* INC_COMMON_SPIBUS_H_ */ | ||||||
|   | |||||||
| @@ -29,6 +29,8 @@ typedef void (*AT45DB_CallbackFn)(AT45DB_Event evt, uint16_t value, | |||||||
| typedef struct AT45DB_Cfg { | typedef struct AT45DB_Cfg { | ||||||
|     SPI_Dev dev; |     SPI_Dev dev; | ||||||
|     OcGpio_Pin *pin_alert; |     OcGpio_Pin *pin_alert; | ||||||
|  |     const char *fileName[5]; | ||||||
|  |     uint8_t noOfFiles; | ||||||
| } AT45DB_Cfg; | } AT45DB_Cfg; | ||||||
|  |  | ||||||
| typedef struct AT45DB_Obj { | typedef struct AT45DB_Obj { | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ | |||||||
|  *                               HEADER FILES |  *                               HEADER FILES | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| #include "common/inc/global/post_frame.h" | #include "common/inc/global/post_frame.h" | ||||||
|  | #include "common/inc/global/ocmp_frame.h" | ||||||
| #include "drivers/OcGpio.h" | #include "drivers/OcGpio.h" | ||||||
| #include "inc/common/i2cbus.h" | #include "inc/common/i2cbus.h" | ||||||
|  |  | ||||||
| @@ -76,7 +77,8 @@ typedef enum INA226_Event { | |||||||
|     INA226_EVT_CUL, /* Current under limit - based on SUL */ |     INA226_EVT_CUL, /* Current under limit - based on SUL */ | ||||||
| } INA226_Event; | } INA226_Event; | ||||||
|  |  | ||||||
| typedef void (*INA226_CallbackFn)(INA226_Event evt, uint16_t value, | typedef void (*INA226_CallbackFn)(INA226_Event evt, OCMPActionType alertAction, | ||||||
|  |                                   uint16_t value, uint16_t lValue, | ||||||
|                                   void *context); |                                   void *context); | ||||||
|  |  | ||||||
| typedef struct INA226_Cfg { | typedef struct INA226_Cfg { | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ | |||||||
|  *                               HEADER FILES |  *                               HEADER FILES | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| #include "common/inc/global/post_frame.h" | #include "common/inc/global/post_frame.h" | ||||||
|  | #include "common/inc/global/ocmp_frame.h" | ||||||
| #include "common/inc/global/Framework.h" | #include "common/inc/global/Framework.h" | ||||||
| #include "drivers/OcGpio.h" | #include "drivers/OcGpio.h" | ||||||
| #include "inc/common/i2cbus.h" | #include "inc/common/i2cbus.h" | ||||||
| @@ -50,7 +51,8 @@ typedef enum Se98aAlert { | |||||||
|     SE98A_ALERT_CRITICAL |     SE98A_ALERT_CRITICAL | ||||||
| } Se98aAlert; | } Se98aAlert; | ||||||
|  |  | ||||||
| typedef void (*SE98A_CallbackFn)(SE98A_Event evt, int8_t temperature, | typedef void (*SE98A_CallbackFn)(SE98A_Event evt, OCMPActionType alertAction, | ||||||
|  |                                  int8_t temperature, int8_t lValue, | ||||||
|                                  void *context); |                                  void *context); | ||||||
|  |  | ||||||
| typedef struct SE98A_Cfg { | typedef struct SE98A_Cfg { | ||||||
|   | |||||||
| @@ -75,6 +75,8 @@ AT45DB_Dev gbc_spi_flash_memory = { | |||||||
|                     .chip_select = &(OcGpio_Pin){ &ec_io, OC_EC_FLASH_nCS }, |                     .chip_select = &(OcGpio_Pin){ &ec_io, OC_EC_FLASH_nCS }, | ||||||
|                 }, |                 }, | ||||||
|             .pin_alert = NULL, |             .pin_alert = NULL, | ||||||
|  |             .fileName = { "alertLog", "configLog", "bootLog" }, | ||||||
|  |             .noOfFiles = 3, | ||||||
|         }, |         }, | ||||||
|     .obj = {}, |     .obj = {}, | ||||||
| }; | }; | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -19,7 +19,7 @@ | |||||||
|  *                              MACRO DEFINITIONS |  *                              MACRO DEFINITIONS | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| #define GOSSIPER_TASK_PRIORITY 6 | #define GOSSIPER_TASK_PRIORITY 6 | ||||||
| #define GOSSIPER_TASK_STACK_SIZE 2048 | #define GOSSIPER_TASK_STACK_SIZE 4096 | ||||||
|  |  | ||||||
| #define SET_DEBEUG_MODE(debugMode) ((debugMode | 0x00)) | #define SET_DEBEUG_MODE(debugMode) ((debugMode | 0x00)) | ||||||
| #define UNSET_DEBUG_MODE(debugMode) ((debugMode & 0x0f)) | #define UNSET_DEBUG_MODE(debugMode) ((debugMode & 0x0f)) | ||||||
|   | |||||||
| @@ -17,6 +17,8 @@ | |||||||
| #include "inc/common/spibus.h" | #include "inc/common/spibus.h" | ||||||
| #include "inc/common/global_header.h" | #include "inc/common/global_header.h" | ||||||
| #include "inc/global/OC_CONNECT1.h" | #include "inc/global/OC_CONNECT1.h" | ||||||
|  | #include <ti/sysbios/BIOS.h> | ||||||
|  | #include "src/filesystem/fs_wrapper.h" | ||||||
|  |  | ||||||
| #define AT45DB_DATA_WR_OPCODE_WR_COUNT 4 | #define AT45DB_DATA_WR_OPCODE_WR_COUNT 4 | ||||||
| #define AT45DB_DATA_RD_OPCODE_WR_COUNT 8 | #define AT45DB_DATA_RD_OPCODE_WR_COUNT 8 | ||||||
| @@ -81,6 +83,8 @@ static ReturnStatus AT45DB_read_reg(AT45DB_Dev *dev, | |||||||
|  **    RETURN TYPE     : Success or failure |  **    RETURN TYPE     : Success or failure | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
|  | #pragma GCC diagnostic push | ||||||
|  | #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" | ||||||
| static ReturnStatus AT45DB_write_reg(AT45DB_Dev *dev, | static ReturnStatus AT45DB_write_reg(AT45DB_Dev *dev, | ||||||
|                                      void *cmdbuffer, /* cmd or opcode buffer */ |                                      void *cmdbuffer, /* cmd or opcode buffer */ | ||||||
|                                      const uint8_t *regValue, |                                      const uint8_t *regValue, | ||||||
| @@ -94,6 +98,7 @@ static ReturnStatus AT45DB_write_reg(AT45DB_Dev *dev, | |||||||
|             "AT45DBFLASHMEMORY:ERROR:: Failed to get SPI Bus for at45db flash memory " |             "AT45DBFLASHMEMORY:ERROR:: Failed to get SPI Bus for at45db flash memory " | ||||||
|             "0x%x on bus 0x%x.\n", |             "0x%x on bus 0x%x.\n", | ||||||
|             dev->cfg.dev.chip_select, dev->cfg.dev.bus); |             dev->cfg.dev.chip_select, dev->cfg.dev.bus); | ||||||
|  |         Semaphore_pend(semFilesysMsg, BIOS_WAIT_FOREVER); | ||||||
|     } else { |     } else { | ||||||
|         status = |         status = | ||||||
|             spi_reg_write(at45dbHandle, dev->cfg.dev.chip_select, cmdbuffer, |             spi_reg_write(at45dbHandle, dev->cfg.dev.chip_select, cmdbuffer, | ||||||
| @@ -101,7 +106,7 @@ static ReturnStatus AT45DB_write_reg(AT45DB_Dev *dev, | |||||||
|     } |     } | ||||||
|     return status; |     return status; | ||||||
| } | } | ||||||
|  | #pragma GCC diagnostic pop | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : at45db_readStatusRegister |  **    FUNCTION NAME   : at45db_readStatusRegister | ||||||
|  ** |  ** | ||||||
| @@ -246,14 +251,16 @@ ReturnStatus at45db_data_write(AT45DB_Dev *dev, const uint8_t *data, | |||||||
|  **    RETURN TYPE     : Success or failure |  **    RETURN TYPE     : Success or failure | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| static ReturnStatus at45db_getDevID(AT45DB_Dev *dev, uint8_t *devID) | #pragma GCC diagnostic push | ||||||
|  | #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" | ||||||
|  | static ReturnStatus at45db_getDevID(AT45DB_Dev *dev, uint32_t *devID) | ||||||
| { | { | ||||||
|     uint8_t txBuffer = AT45DB_DEVID_RD_OPCODE; /* opcode to get device id */ |     uint8_t txBuffer = AT45DB_DEVID_RD_OPCODE; /* opcode to get device id */ | ||||||
|  |  | ||||||
|     return AT45DB_read_reg(dev, &txBuffer, devID, NULL, AT45DB_DEVID_RD_BYTES, |     return AT45DB_read_reg(dev, &txBuffer, devID, NULL, AT45DB_DEVID_RD_BYTES, | ||||||
|                            AT45DB_DEVID_OPCODE_WR_COUNT); |                            AT45DB_DEVID_OPCODE_WR_COUNT); | ||||||
| } | } | ||||||
|  | #pragma GCC diagnostic pop | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : at45db_probe |  **    FUNCTION NAME   : at45db_probe | ||||||
|  ** |  ** | ||||||
| @@ -266,7 +273,7 @@ static ReturnStatus at45db_getDevID(AT45DB_Dev *dev, uint8_t *devID) | |||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| ePostCode at45db_probe(AT45DB_Dev *dev, POSTData *postData) | ePostCode at45db_probe(AT45DB_Dev *dev, POSTData *postData) | ||||||
| { | { | ||||||
|     uint8_t value = 0; |     uint32_t value = 0; | ||||||
|     uint16_t devId = 0; |     uint16_t devId = 0; | ||||||
|     uint8_t manfId = 0; |     uint8_t manfId = 0; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -93,12 +93,14 @@ static void call_state_cb(const GsmClccInfo *info, void *context) | |||||||
|     switch (info->call_state) { |     switch (info->call_state) { | ||||||
|         case GSM_CALL_STATE_INCOMING: { |         case GSM_CALL_STATE_INCOMING: { | ||||||
|             eTEST_MODE_CallEvent callState = TWOG_CALL_EVT_RING; |             eTEST_MODE_CallEvent callState = TWOG_CALL_EVT_RING; | ||||||
|             OCMP_GenerateAlert(context, TWOG_SIM_CALLSTATE_CHANGE, &callState); |             OCMP_GenerateAlert(context, TWOG_SIM_CALLSTATE_CHANGE, &callState, | ||||||
|  |                                NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         case GSM_CALL_STATE_RELEASED: { |         case GSM_CALL_STATE_RELEASED: { | ||||||
|             eTEST_MODE_CallEvent callState = TWOG_CALL_EVT_CALL_END; |             eTEST_MODE_CallEvent callState = TWOG_CALL_EVT_CALL_END; | ||||||
|             OCMP_GenerateAlert(context, TWOG_SIM_CALLSTATE_CHANGE, &callState); |             OCMP_GenerateAlert(context, TWOG_SIM_CALLSTATE_CHANGE, &callState, | ||||||
|  |                                NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         default: |         default: | ||||||
| @@ -269,7 +271,8 @@ static void testModule_task(UArg a0, UArg a1) | |||||||
|             if (GSM_cmgr(s_hGsm, sms_idx, sms, NULL)) { |             if (GSM_cmgr(s_hGsm, sms_idx, sms, NULL)) { | ||||||
|                 LOGGER("SMS: %.*s\n", 50, |                 LOGGER("SMS: %.*s\n", 50, | ||||||
|                        sms); // System_printf has a limited buffer |                        sms); // System_printf has a limited buffer | ||||||
|                 OCMP_GenerateAlert(alert_token, TWOG_SIM_INCOMING_MSG, sms); |                 OCMP_GenerateAlert(alert_token, TWOG_SIM_INCOMING_MSG, sms, | ||||||
|  |                                    NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|             } else { |             } else { | ||||||
|                 LOGGER_ERROR("TESTMOD:Failed to read SMS\n"); |                 LOGGER_ERROR("TESTMOD:Failed to read SMS\n"); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -469,7 +469,17 @@ static void _ina226_isr(void *context) | |||||||
|             _enable_alert(dev, new_mask); |             _enable_alert(dev, new_mask); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         dev->obj.alert_cb(evt, value, dev->obj.cb_context); |         OCMPActionType alertAction = OCMP_AXN_TYPE_ACTIVE; | ||||||
|  |         if (evt != INA226_EVT_COL) { | ||||||
|  |             if ((alert_mask & INA_MSK_AFF)) { | ||||||
|  |                 alertAction = OCMP_AXN_TYPE_CLEAR; | ||||||
|  |             } else { | ||||||
|  |                 LOGGER_WARNING("IN226::Unsupported INA event 0x%x\n", evt); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         dev->obj.alert_cb(evt, alertAction, value, alert_lim, | ||||||
|  |                           dev->obj.cb_context); | ||||||
|     } |     } | ||||||
|     /* TODO: Conversion ready not handled */ |     /* TODO: Conversion ready not handled */ | ||||||
| } | } | ||||||
|   | |||||||
| @@ -17,20 +17,22 @@ | |||||||
| /* TI-RTOS driver files */ | /* TI-RTOS driver files */ | ||||||
| #include <ti/drivers/I2C.h> | #include <ti/drivers/I2C.h> | ||||||
|  |  | ||||||
| bool i2c_read(void *i2c_cfg, void *oci2c) | bool i2c_read(void *i2c_cfg, void *pMsgFrame) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame *pMsg = (OCMPMessageFrame *)pMsgFrame; | ||||||
|     S_I2C_Cfg *s_oc_i2c_cfg = (S_I2C_Cfg *)i2c_cfg; |     S_I2C_Cfg *s_oc_i2c_cfg = (S_I2C_Cfg *)i2c_cfg; | ||||||
|     S_OCI2C *s_oci2c = (S_OCI2C *)oci2c; |     S_OCI2C *s_oci2c = (S_OCI2C *)pMsg->message.ocmp_data; | ||||||
|     I2C_Handle i2cHandle = i2c_open_bus(s_oc_i2c_cfg->bus); |     I2C_Handle i2cHandle = i2c_open_bus(s_oc_i2c_cfg->bus); | ||||||
|     return (i2c_reg_read(i2cHandle, s_oci2c->slaveAddress, s_oci2c->reg_address, |     return (i2c_reg_read(i2cHandle, s_oci2c->slaveAddress, s_oci2c->reg_address, | ||||||
|                          &s_oci2c->reg_value, |                          &s_oci2c->reg_value, | ||||||
|                          s_oci2c->number_of_bytes) == RETURN_OK); |                          s_oci2c->number_of_bytes) == RETURN_OK); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool i2c_write(void *i2c_cfg, void *oci2c) | bool i2c_write(void *i2c_cfg, void *pMsgFrame) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame *pMsg = (OCMPMessageFrame *)pMsgFrame; | ||||||
|     S_I2C_Cfg *s_oc_i2c_cfg = (S_I2C_Cfg *)i2c_cfg; |     S_I2C_Cfg *s_oc_i2c_cfg = (S_I2C_Cfg *)i2c_cfg; | ||||||
|     S_OCI2C *s_oci2c = (S_OCI2C *)oci2c; |     S_OCI2C *s_oci2c = (S_OCI2C *)pMsg->message.ocmp_data; | ||||||
|     I2C_Handle i2cHandle = i2c_open_bus(s_oc_i2c_cfg->bus); |     I2C_Handle i2cHandle = i2c_open_bus(s_oc_i2c_cfg->bus); | ||||||
|     return (i2c_reg_write(i2cHandle, s_oci2c->slaveAddress, |     return (i2c_reg_write(i2cHandle, s_oci2c->slaveAddress, | ||||||
|                           s_oci2c->reg_address, s_oci2c->reg_value, |                           s_oci2c->reg_address, s_oci2c->reg_value, | ||||||
|   | |||||||
| @@ -36,10 +36,11 @@ bool check_clause_22(uint8_t port) | |||||||
|     return status; |     return status; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool mdio_read(void *mdio_cfg, void *ocmdio) | bool mdio_read(void *mdio_cfg, void *pMsgFrame) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame *pMsg = (OCMPMessageFrame *)pMsgFrame; | ||||||
|     S_MDIO_Cfg *s_oc_mdio_cfg = (S_MDIO_Cfg *)mdio_cfg; |     S_MDIO_Cfg *s_oc_mdio_cfg = (S_MDIO_Cfg *)mdio_cfg; | ||||||
|     S_OCMDIO *s_ocmdio = (S_OCMDIO *)ocmdio; |     S_OCMDIO *s_ocmdio = (S_OCMDIO *)pMsg->message.ocmp_data; | ||||||
|     s_ocmdio->reg_value = 0xf00f; |     s_ocmdio->reg_value = 0xf00f; | ||||||
|  |  | ||||||
|     if (CLAUSE_45_REQUEST(reg_address)) |     if (CLAUSE_45_REQUEST(reg_address)) | ||||||
| @@ -59,10 +60,11 @@ bool mdio_read(void *mdio_cfg, void *ocmdio) | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool mdio_write(void *mdio_cfg, void *ocmdio) | bool mdio_write(void *mdio_cfg, void *pMsgFrame) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame *pMsg = (OCMPMessageFrame *)pMsgFrame; | ||||||
|     S_MDIO_Cfg *s_oc_mdio_cfg = (S_MDIO_Cfg *)mdio_cfg; |     S_MDIO_Cfg *s_oc_mdio_cfg = (S_MDIO_Cfg *)mdio_cfg; | ||||||
|     S_OCMDIO *s_ocmdio = (S_OCMDIO *)ocmdio; |     S_OCMDIO *s_ocmdio = (S_OCMDIO *)pMsg->message.ocmp_data; | ||||||
|  |  | ||||||
|     if (CLAUSE_45_REQUEST(reg_address)) { |     if (CLAUSE_45_REQUEST(reg_address)) { | ||||||
|         /*PHY registers use Reg 13 and Reg 14 as paging mechanism to access |         /*PHY registers use Reg 13 and Reg 14 as paging mechanism to access | ||||||
|   | |||||||
| @@ -18,10 +18,11 @@ | |||||||
| #define NO_GPIO_PINS_IN_GROUP 8 | #define NO_GPIO_PINS_IN_GROUP 8 | ||||||
| extern GPIO_PinConfig gpioPinConfigs[]; | extern GPIO_PinConfig gpioPinConfigs[]; | ||||||
|  |  | ||||||
| bool ocgpio_set(void *gpio_cfg, void *oc_gpio) | bool ocgpio_set(void *gpio_cfg, void *pMsgFrame) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame *pMsg = (OCMPMessageFrame *)pMsgFrame; | ||||||
|     S_OCGPIO_Cfg *oc_gpio_cfg = (S_OCGPIO_Cfg *)gpio_cfg; |     S_OCGPIO_Cfg *oc_gpio_cfg = (S_OCGPIO_Cfg *)gpio_cfg; | ||||||
|     S_OCGPIO *s_oc_gpio = (S_OCGPIO *)oc_gpio; |     S_OCGPIO *s_oc_gpio = (S_OCGPIO *)pMsg->message.ocmp_data; | ||||||
|     int ret = 0; |     int ret = 0; | ||||||
|     uint8_t idx = ((oc_gpio_cfg->group != 0) ? |     uint8_t idx = ((oc_gpio_cfg->group != 0) ? | ||||||
|                        (((oc_gpio_cfg->group - 1) * NO_GPIO_PINS_IN_GROUP) + |                        (((oc_gpio_cfg->group - 1) * NO_GPIO_PINS_IN_GROUP) + | ||||||
| @@ -36,10 +37,11 @@ bool ocgpio_set(void *gpio_cfg, void *oc_gpio) | |||||||
|     return (ret == 0); |     return (ret == 0); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool ocgpio_get(void *gpio_cfg, void *oc_gpio) | bool ocgpio_get(void *gpio_cfg, void *pMsgFrame) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame *pMsg = (OCMPMessageFrame *)pMsgFrame; | ||||||
|     S_OCGPIO_Cfg *oc_gpio_cfg = (S_OCGPIO_Cfg *)gpio_cfg; |     S_OCGPIO_Cfg *oc_gpio_cfg = (S_OCGPIO_Cfg *)gpio_cfg; | ||||||
|     S_OCGPIO *s_oc_gpio = (S_OCGPIO *)oc_gpio; |     S_OCGPIO *s_oc_gpio = (S_OCGPIO *)pMsg->message.ocmp_data; | ||||||
|     int ret = 0; |     int ret = 0; | ||||||
|     uint8_t idx = ((oc_gpio_cfg->group != 0) ? |     uint8_t idx = ((oc_gpio_cfg->group != 0) ? | ||||||
|                        (((oc_gpio_cfg->group - 1) * NO_GPIO_PINS_IN_GROUP) + |                        (((oc_gpio_cfg->group - 1) * NO_GPIO_PINS_IN_GROUP) + | ||||||
|   | |||||||
| @@ -186,11 +186,8 @@ static ePostCode _probe(void *driver, POSTData *postData) | |||||||
|     eth_sw_configure(driver); |     eth_sw_configure(driver); | ||||||
|     return eth_sw_probe(postData); |     return eth_sw_probe(postData); | ||||||
| } | } | ||||||
|  | #pragma GCC diagnostic push | ||||||
| #if 0 | #pragma GCC diagnostic ignored "-Wunused-function" | ||||||
| /* NOTE: Commented out because unused, triggers -Wunused-function warning. |  | ||||||
|  *       The function might be useful in the future. |  | ||||||
|  */ |  | ||||||
| static void _alert_handler(Eth_Sw_Events evt, int16_t value, void *alert_data) | static void _alert_handler(Eth_Sw_Events evt, int16_t value, void *alert_data) | ||||||
| { | { | ||||||
|     unsigned int alert; |     unsigned int alert; | ||||||
| @@ -222,10 +219,10 @@ static void _alert_handler(Eth_Sw_Events evt, int16_t value, void *alert_data) | |||||||
|             return; |             return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     OCMP_GenerateAlert(alert_data, alert, &value); |     OCMP_GenerateAlert(alert_data, alert, &value, NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|     LOGGER_DEBUG("ETH_SW:: Event: %d Value: %d\n", evt, value); |     LOGGER_DEBUG("ETH_SW:: Event: %d Value: %d\n", evt, value); | ||||||
| } | } | ||||||
| #endif | #pragma GCC diagnostic pop | ||||||
|  |  | ||||||
| static ePostCode _init(void *driver, const void *config, | static ePostCode _init(void *driver, const void *config, | ||||||
|                        const void *alert_token) |                        const void *alert_token) | ||||||
|   | |||||||
| @@ -67,14 +67,18 @@ static ePostCode _probe(void *driver, POSTData *postData) | |||||||
|     return ina226_probe(driver, postData); |     return ina226_probe(driver, postData); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void _alert_handler(INA226_Event evt, uint16_t value, void *alert_data) | static void _alert_handler(INA226_Event evt, OCMPActionType alertAction, | ||||||
|  |                            uint16_t value, uint16_t lValue, void *alert_data) | ||||||
| { | { | ||||||
|     if (evt != INA226_EVT_COL) { |     if (evt != INA226_EVT_COL) { | ||||||
|         LOGGER_WARNING("IN226::Unsupported INA event 0x%x\n", evt); |         if (evt != INA226_EVT_CUL) { | ||||||
|         return; |             LOGGER_WARNING("IN226::Unsupported INA event 0x%x\n", evt); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     OCMP_GenerateAlert(alert_data, INA226_ALERT_OVERCURRENT, &value); |     OCMP_GenerateAlert(alert_data, INA226_ALERT_OVERCURRENT, &value, &lValue, | ||||||
|  |                        alertAction); | ||||||
|     LOGGER_DEBUG("INA226 Event: 0x%x Current: %u\n", evt, value); |     LOGGER_DEBUG("INA226 Event: 0x%x Current: %u\n", evt, value); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -204,7 +204,7 @@ static void _alert_handler(LTC4015_Event evt, int16_t value, void *alert_data) | |||||||
|             return; |             return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     OCMP_GenerateAlert(alert_data, alert, &value); |     OCMP_GenerateAlert(alert_data, alert, &value, NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|     LOGGER_DEBUG("LTC4015 Event: %d Value: %d\n", evt, value); |     LOGGER_DEBUG("LTC4015 Event: %d Value: %d\n", evt, value); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -226,7 +226,7 @@ static void _alert_handler(LTC4274_Event evt, void *context) | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     uint8_t alert_data = 0x00; |     uint8_t alert_data = 0x00; | ||||||
|     OCMP_GenerateAlert(context, alert, &alert_data); |     OCMP_GenerateAlert(context, alert, &alert_data, NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|     LOGGER_DEBUG("LTC7274 Event: %d \n", evt); |     LOGGER_DEBUG("LTC7274 Event: %d \n", evt); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -64,7 +64,7 @@ static void _alert_handler(LTC4275_Event evt, void *context) | |||||||
|             LOGGER_ERROR("Unknown LTC4275evt: %d\n", evt); |             LOGGER_ERROR("Unknown LTC4275evt: %d\n", evt); | ||||||
|             return; |             return; | ||||||
|     } |     } | ||||||
|     OCMP_GenerateAlert(context, alert, &evt); |     OCMP_GenerateAlert(context, alert, &evt, NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|     LOGGER_DEBUG("LTC4275A alert: %d generated.\n", alert); |     LOGGER_DEBUG("LTC4275A alert: %d generated.\n", alert); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,14 +14,15 @@ void _rffe_watchdog_handler(void *context) | |||||||
| { | { | ||||||
|     RfWatchdog_Cfg *cfg = context; |     RfWatchdog_Cfg *cfg = context; | ||||||
|     if (OcGpio_read(cfg->pin_alert_lb) > 0) { |     if (OcGpio_read(cfg->pin_alert_lb) > 0) { | ||||||
|         OCMP_GenerateAlert(context, 0, NULL); |         OCMP_GenerateAlert(context, 0, NULL, NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|     } |     } | ||||||
|     if (OcGpio_read(cfg->pin_alert_hb) > 0) { |     if (OcGpio_read(cfg->pin_alert_hb) > 0) { | ||||||
|         OCMP_GenerateAlert(context, 1, NULL); |         OCMP_GenerateAlert(context, 1, NULL, NULL, OCMP_AXN_TYPE_ACTIVE); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
|  |  | ||||||
| static ePostCode _rffe_watchdog_init(void *driver, const void *config, | static ePostCode _rffe_watchdog_init(void *driver, const void *config, | ||||||
|                                      const void *alert_token) |                                      const void *alert_token) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -72,7 +72,8 @@ static ePostCode _probe(void *driver, POSTData *postData) | |||||||
|     return se98a_probe(driver, postData); |     return se98a_probe(driver, postData); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void _alert_handler(SE98A_Event evt, int8_t temperature, void *context) | static void _alert_handler(SE98A_Event evt, OCMPActionType alertAction, | ||||||
|  |                            int8_t temperature, int8_t lValue, void *context) | ||||||
| { | { | ||||||
|     unsigned int alert; |     unsigned int alert; | ||||||
|     switch (evt) { |     switch (evt) { | ||||||
| @@ -91,7 +92,7 @@ static void _alert_handler(SE98A_Event evt, int8_t temperature, void *context) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     uint8_t alert_data = (uint8_t)MAX((int8_t)0, temperature); |     uint8_t alert_data = (uint8_t)MAX((int8_t)0, temperature); | ||||||
|     OCMP_GenerateAlert(context, alert, &alert_data); |     OCMP_GenerateAlert(context, alert, &alert_data, &lValue, alertAction); | ||||||
|     LOGGER_DEBUG("SE98A Event: %d Temperature: %d\n", evt, temperature); |     LOGGER_DEBUG("SE98A Event: %d Temperature: %d\n", evt, temperature); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -56,6 +56,8 @@ | |||||||
| /* Default CFG plus interrupt mode (we don't support comparator mode) */ | /* Default CFG plus interrupt mode (we don't support comparator mode) */ | ||||||
| #define SE98A_CONFIG_DEFAULT (0x0000 | SE98A_CFG_EMD | SE98A_CFG_HYS_1P5) | #define SE98A_CONFIG_DEFAULT (0x0000 | SE98A_CFG_EMD | SE98A_CFG_HYS_1P5) | ||||||
|  |  | ||||||
|  | static uint8_t alertStatus = 0x00; | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  * Helper to read from a SE98A register |  * Helper to read from a SE98A register | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| @@ -306,14 +308,41 @@ static void se98a_handle_irq(void *context) | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if (trip_stat) { | ||||||
|  |         alertStatus = trip_stat; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /* Since > CRIT implies above window, we only handle the highest priority |     /* Since > CRIT implies above window, we only handle the highest priority | ||||||
|      * event to avoid duplicate events being sent */ |      * event to avoid duplicate events being sent */ | ||||||
|     if (trip_stat & SE98A_EVT_ACT) { |     OCMPActionType alertAction = OCMP_AXN_TYPE_ACTIVE; | ||||||
|         dev->obj.alert_cb(SE98A_EVT_ACT, temperature, dev->obj.cb_context); |     int8_t regLim = 0; | ||||||
|     } else if (trip_stat & SE98A_EVT_AAW) { |     if (alertStatus & SE98A_EVT_ACT) { | ||||||
|         dev->obj.alert_cb(SE98A_EVT_AAW, temperature, dev->obj.cb_context); |         if (se98a_get_limit(dev, CONF_TEMP_SE98A_CRITICAL_LIMIT_REG, ®Lim) == | ||||||
|     } else if (trip_stat & SE98A_EVT_BAW) { |             RETURN_OK) { | ||||||
|         dev->obj.alert_cb(SE98A_EVT_BAW, temperature, dev->obj.cb_context); |             if (regLim > temperature) { | ||||||
|  |                 alertAction = OCMP_AXN_TYPE_CLEAR; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         dev->obj.alert_cb(SE98A_EVT_ACT, alertAction, temperature, regLim, | ||||||
|  |                           dev->obj.cb_context); | ||||||
|  |     } else if (alertStatus & SE98A_EVT_AAW) { | ||||||
|  |         if (se98a_get_limit(dev, CONF_TEMP_SE98A_HIGH_LIMIT_REG, ®Lim) == | ||||||
|  |             RETURN_OK) { | ||||||
|  |             if (regLim > temperature) { | ||||||
|  |                 alertAction = OCMP_AXN_TYPE_CLEAR; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         dev->obj.alert_cb(SE98A_EVT_AAW, alertAction, temperature, regLim, | ||||||
|  |                           dev->obj.cb_context); | ||||||
|  |     } else if (alertStatus & SE98A_EVT_BAW) { | ||||||
|  |         if (se98a_get_limit(dev, CONF_TEMP_SE98A_LOW_LIMIT_REG, ®Lim) == | ||||||
|  |             RETURN_OK) { | ||||||
|  |             if (regLim < temperature) { | ||||||
|  |                 alertAction = OCMP_AXN_TYPE_CLEAR; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         dev->obj.alert_cb(SE98A_EVT_BAW, alertAction, temperature, regLim, | ||||||
|  |                           dev->obj.cb_context); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -121,9 +121,8 @@ ReturnStatus spi_reg_read(SPI_Handle spiHandle, OcGpio_Pin *chip_select, | |||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| ReturnStatus spi_reg_write(SPI_Handle spiHandle, OcGpio_Pin *chip_select, | ReturnStatus spi_reg_write(SPI_Handle spiHandle, OcGpio_Pin *chip_select, | ||||||
|                            void *regAddress, const uint8_t *data, |                            void *regAddress, uint8_t *data, uint32_t data_size, | ||||||
|                            uint32_t data_size, uint32_t byte, |                            uint32_t byte, uint8_t numofBytes) | ||||||
|                            uint8_t numofBytes) |  | ||||||
| { | { | ||||||
|     ReturnStatus status = RETURN_OK; |     ReturnStatus status = RETURN_OK; | ||||||
|     SPI_Transaction spiTransaction; |     SPI_Transaction spiTransaction; | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /** | /** | ||||||
|  * Copyright (c) 2017-present, Facebook, Inc. |  * Copyright (c) 2017-present, Facebook, Inc | ||||||
|  * All rights reserved. |  * All rights reserved. | ||||||
|  * |  * | ||||||
|  * This source code is licensed under the BSD-style license found in the |  * This source code is licensed under the BSD-style license found in the | ||||||
| @@ -8,8 +8,9 @@ | |||||||
|  * |  * | ||||||
|  * This file acts as wrapper for little filesystem, contains filesystem |  * This file acts as wrapper for little filesystem, contains filesystem | ||||||
|  * initialization, block read, block write, block erase as a main functions |  * initialization, block read, block write, block erase as a main functions | ||||||
|  * moreover provides API's like fileRead, fileWrite for external application to |  * moreover provides API's like fileRead, fs_wrapper_data_write for external | ||||||
|  * read and write data to at45db flash memory by using SPI interface. |  * application to read and write data to at45db flash memory by using SPI | ||||||
|  |  * interface. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "Board.h" | #include "Board.h" | ||||||
| @@ -18,46 +19,62 @@ | |||||||
| #include "inc/common/bigbrother.h" | #include "inc/common/bigbrother.h" | ||||||
| #include "inc/common/global_header.h" | #include "inc/common/global_header.h" | ||||||
| #include "inc/devices/at45db.h" | #include "inc/devices/at45db.h" | ||||||
| #include "inc/global/OC_CONNECT1.h" | #include <inc/global/OC_CONNECT1.h> | ||||||
|  | #include "inc/utils/ocmp_util.h" | ||||||
| #include "inc/utils/util.h" | #include "inc/utils/util.h" | ||||||
| #include "src/filesystem/fs_wrapper.h" | #include "platform/oc-sdr/schema/schema.h" | ||||||
| #include "src/filesystem/lfs.h" |  | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <ti/drivers/GPIO.h> | #include "src/filesystem/lfs.h" | ||||||
| #include <ti/drivers/SPI.h> | #include "src/filesystem/fs_wrapper.h" | ||||||
|  | #include "src/registry/SSRegistry.h" | ||||||
| #include <ti/sysbios/BIOS.h> | #include <ti/sysbios/BIOS.h> | ||||||
|  | #include <ti/drivers/GPIO.h> | ||||||
| #include <ti/sysbios/knl/Semaphore.h> | #include <ti/sysbios/knl/Semaphore.h> | ||||||
| #include <ti/sysbios/knl/Queue.h> | #include <ti/sysbios/knl/Queue.h> | ||||||
| #include <ti/sysbios/knl/Task.h> | #include <ti/sysbios/knl/Task.h> | ||||||
|  | #include <ti/drivers/SPI.h> | ||||||
|  |  | ||||||
|  | #define AT45DB_STATUS_READY 0xBC | ||||||
| #define BLOCK_SIZE 256 | #define BLOCK_SIZE 256 | ||||||
| #define BLOCK_COUNT 32768 | #define BLOCK_COUNT 32768 | ||||||
| #define FRAME_SIZE 64 | #define FILE_SIZE_LIMIT 8192 | ||||||
| #define LOOK_AHEAD 256 | #define LOOK_AHEAD 256 | ||||||
|  | #define NEXT_MSG_FLAG 1 | ||||||
| #define PAGE_SIZE 256 | #define PAGE_SIZE 256 | ||||||
|  | #define PAYLOAD_SIZE 47 | ||||||
| #define READ_SIZE 256 | #define READ_SIZE 256 | ||||||
| #define WRITE_SIZE 256 | #define WRITE_SIZE 256 | ||||||
|  |  | ||||||
|  | extern OCSubsystem *ss_reg[SUBSYSTEM_COUNT]; | ||||||
|  | #pragma GCC diagnostic push | ||||||
|  | #pragma GCC diagnostic ignored "-Wunused-variable" | ||||||
|  | static Queue_Struct fsRxMsg; | ||||||
|  | static Queue_Struct fsTxMsg; | ||||||
|  | #pragma GCC diagnostic pop | ||||||
|  |  | ||||||
| lfs_t lfs; | lfs_t lfs; | ||||||
| lfs_file_t file; | lfs_file_t file; | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : block_device_read |  **    FUNCTION NAME   : fs_wrapper_block_device_read | ||||||
|  ** |  ** | ||||||
|  **    DESCRIPTION     : It is called by filesystem to read block device |  **    DESCRIPTION     : This function called by filesystem to read block device | ||||||
|  ** |  ** | ||||||
|  **    ARGUMENTS       : context for device configuration, block or page number, |  **    ARGUMENTS       : context for device configuration, block or page number, | ||||||
|  ** |  ** | ||||||
|  **                      block or page offset, data buffer, size of data to read |  **                      block or page offset, data buffer, size of data to be | ||||||
|  |  *read | ||||||
|  ** |  ** | ||||||
|  **    RETURN TYPE     : Success or failure |  **    RETURN TYPE     : Success or failure | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| int block_device_read(const struct lfs_config *cfg, lfs_block_t block, | int fs_wrapper_block_device_read(const struct lfs_config *cfg, | ||||||
|                       lfs_off_t off, void *buffer, lfs_size_t size) |                                  lfs_block_t block, lfs_offset_t offset, | ||||||
|  |                                  void *buffer, lfs_size_t size) | ||||||
| { | { | ||||||
|     if (at45db_data_read(cfg->context, buffer, size, off, block) != RETURN_OK) { |     if (at45db_data_read(cfg->context, buffer, size, offset, block) != | ||||||
|  |         RETURN_OK) { | ||||||
|         return LFS_ERR_IO; |         return LFS_ERR_IO; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -65,20 +82,22 @@ int block_device_read(const struct lfs_config *cfg, lfs_block_t block, | |||||||
| } | } | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : block_device_write |  **    FUNCTION NAME   : fs_wrapper_block_device_write | ||||||
|  ** |  ** | ||||||
|  **    DESCRIPTION     : it is called by filesystem to write block device |  **    DESCRIPTION     : This function called by filesystem to write block | ||||||
|  |  *device | ||||||
|  ** |  ** | ||||||
|  **    ARGUMENTS       : context for device configuration, block or page number, |  **    ARGUMENTS       : context for device configuration, block or page number, | ||||||
|  ** |  ** | ||||||
|  **                      block or page offset, data buffer, size of data to |  **                      block or page offset, data buffer, size of data to be | ||||||
|  *write |  *written | ||||||
|  ** |  ** | ||||||
|  **    RETURN TYPE     : Success or failure |  **    RETURN TYPE     : Success or failure | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| int block_device_write(const struct lfs_config *cfg, lfs_block_t block, | int fs_wrapper_block_device_write(const struct lfs_config *cfg, | ||||||
|                        lfs_off_t off, const void *buffer, lfs_size_t size) |                                   lfs_block_t block, lfs_offset_t off, | ||||||
|  |                                   void *buffer, lfs_size_t size) | ||||||
| { | { | ||||||
|     if (at45db_data_write(cfg->context, buffer, size, off, block) != |     if (at45db_data_write(cfg->context, buffer, size, off, block) != | ||||||
|         RETURN_OK) { |         RETURN_OK) { | ||||||
| @@ -89,16 +108,18 @@ int block_device_write(const struct lfs_config *cfg, lfs_block_t block, | |||||||
| } | } | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : block_device_erase |  **    FUNCTION NAME   : fs_wrapper_block_device_erase | ||||||
|  ** |  ** | ||||||
|  **    DESCRIPTION     : It is called by filesystem to erase block device |  **    DESCRIPTION     : This function called by filesystem to erase block | ||||||
|  |  *device | ||||||
|  ** |  ** | ||||||
|  **    ARGUMENTS       : context for device configuration, block or page number, |  **    ARGUMENTS       : context for device configuration, block or page number, | ||||||
|  ** |  ** | ||||||
|  **    RETURN TYPE     : Success or failure |  **    RETURN TYPE     : Success or failure | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| int block_device_erase(const struct lfs_config *cfg, lfs_block_t block) | int fs_wrapper_block_device_erase(const struct lfs_config *cfg, | ||||||
|  |                                   lfs_block_t block) | ||||||
| { | { | ||||||
|     if (at45db_erasePage(cfg->context, block) != RETURN_OK) { |     if (at45db_erasePage(cfg->context, block) != RETURN_OK) { | ||||||
|         return LFS_ERR_IO; |         return LFS_ERR_IO; | ||||||
| @@ -108,26 +129,26 @@ int block_device_erase(const struct lfs_config *cfg, lfs_block_t block) | |||||||
| } | } | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : block_device_sync |  **    FUNCTION NAME   : fs_wrapper_block_device_sync | ||||||
|  ** |  ** | ||||||
|  **    DESCRIPTION     : It is  called by filesystem to sync with block device |  **    DESCRIPTION     : This function called by filesystem to sync with block | ||||||
|  |  *device | ||||||
|  ** |  ** | ||||||
|  **    ARGUMENTS       : context for device configuration |  **    ARGUMENTS       : context for device configuration | ||||||
|  ** |  ** | ||||||
|  **    RETURN TYPE     : Success or failure |  **    RETURN TYPE     : Success or failure | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| int block_device_sync(const struct lfs_config *cfg) | int fs_wrapper_block_device_sync(const struct lfs_config *cfg) | ||||||
| { | { | ||||||
|     if (at45db_readStatusRegister(cfg->context) != RETURN_OK) { |     while (!(AT45DB_STATUS_READY & at45db_readStatusRegister(cfg->context))) | ||||||
|         return LFS_ERR_IO; |         ; | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return LFS_ERR_OK; |     return LFS_ERR_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : fileSize |  **    FUNCTION NAME   : fs_wrapper_get_fileSize | ||||||
|  ** |  ** | ||||||
|  **    DESCRIPTION     : Returns size of saved file |  **    DESCRIPTION     : Returns size of saved file | ||||||
|  ** |  ** | ||||||
| @@ -136,21 +157,108 @@ int block_device_sync(const struct lfs_config *cfg) | |||||||
|  **    RETURN TYPE     : file size |  **    RETURN TYPE     : file size | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| int fileSize(const char *path) | int fs_wrapper_get_fileSize(const char *path) | ||||||
| { | { | ||||||
|     uint32_t fileSize = 0; |     uint32_t fileSize = 0; | ||||||
|  |  | ||||||
|     if (lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) == LFS_ERR_OK) { |     if (lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) == LFS_ERR_OK) { | ||||||
|         LOGGER_DEBUG("FS:: File open successfully \n"); |         LOGGER_DEBUG("FS:: File open successfully \n"); | ||||||
|  |         fileSize = lfs_file_size(&lfs, &file); | ||||||
|  |         lfs_file_close(&lfs, &file); | ||||||
|     } |     } | ||||||
|     fileSize = lfs_file_size(&lfs, &file); |  | ||||||
|     lfs_file_close(&lfs, &file); |  | ||||||
|  |  | ||||||
|     return fileSize; |     return fileSize; | ||||||
| } | } | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : fileWrite |  **    FUNCTION NAME   : fs_wrapper_flashMemory_read | ||||||
|  |  ** | ||||||
|  |  **    DESCRIPTION     : Reads saved logs from at45db flash memeory and enqueue | ||||||
|  |  ** | ||||||
|  |  **    ARGUMENTS       : Subsystem number, filename, file size | ||||||
|  |  ** | ||||||
|  |  **    RETURN TYPE     : Success or failure | ||||||
|  |  ** | ||||||
|  |  *****************************************************************************/ | ||||||
|  | void fs_wrapper_flashMemory_read(OCMPSubsystem subsystem, const char *fileName, | ||||||
|  |                                  uint32_t file_size, uint8_t fileIndex) | ||||||
|  | { | ||||||
|  |     uint32_t numOfMsg = 0; | ||||||
|  |     uint8_t *logFile; | ||||||
|  |     uint8_t *logFilePtr; | ||||||
|  |     OCMPMessageFrame *tMsg; | ||||||
|  |     OCSubsystem *ss = ss_reg[subsystem]; | ||||||
|  |  | ||||||
|  |     if (file_size > 0) { | ||||||
|  |         tMsg = (OCMPMessageFrame *)OCMP_mallocFrame(PAYLOAD_SIZE); | ||||||
|  |         logFile = (uint8_t *)calloc(file_size, sizeof(uint8_t)); | ||||||
|  |         if ((tMsg != NULL) && (logFile != NULL)) { | ||||||
|  |             logFilePtr = logFile; | ||||||
|  |             numOfMsg = file_size / FRAME_SIZE; | ||||||
|  |             LOGGER_DEBUG("FS:: numOfMsg = %d\n", numOfMsg); | ||||||
|  |             fs_wrapper_file_read(fileName, logFile, file_size); | ||||||
|  |             while (numOfMsg) { | ||||||
|  |                 logFile[NEXT_MSG_FLAG_POS] = NEXT_MSG_FLAG; | ||||||
|  |                 if (subsystem == OC_SS_SYS) { | ||||||
|  |                     logFile[FS_OCMP_MSGTYPE_POS] = OCMP_MSG_TYPE_COMMAND; | ||||||
|  |                     memcpy(tMsg, logFile, FRAME_SIZE); | ||||||
|  |  | ||||||
|  |                     Util_enqueueMsg(ss->msgRxQueue, ss->sem, (uint8_t *)tMsg); | ||||||
|  |                 } else { | ||||||
|  |                     if (logFile[FS_OCMP_SUBSYSTEM_POS] == subsystem) { | ||||||
|  |                         logFile[FS_OCMP_MSGTYPE_POS] = OCMP_MSG_TYPE_COMMAND; | ||||||
|  |                         memcpy(tMsg, logFile, FRAME_SIZE); | ||||||
|  |                         Util_enqueueMsg(ss->msgRxQueue, ss->sem, | ||||||
|  |                                         (uint8_t *)tMsg); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 logFile += FRAME_SIZE; | ||||||
|  |                 numOfMsg--; | ||||||
|  |             } | ||||||
|  |             if (fileIndex == 0) { | ||||||
|  |                 logFile[NEXT_MSG_FLAG_POS] = LAST_MSG_FLAG; | ||||||
|  |                 memcpy(tMsg, logFile, FRAME_SIZE); | ||||||
|  |                 Util_enqueueMsg(ss->msgRxQueue, ss->sem, (uint8_t *)tMsg); | ||||||
|  |                 LOGGER_DEBUG("FS:: Set last flag\n"); | ||||||
|  |             } | ||||||
|  |             free(tMsg); | ||||||
|  |             logFile = logFilePtr; | ||||||
|  |             free(logFile); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /***************************************************************************** | ||||||
|  |  **    FUNCTION NAME   : fs_wrapper_data_read | ||||||
|  |  ** | ||||||
|  |  **    DESCRIPTION     : Called by subsystems and passes filename to alert_msg | ||||||
|  |  ** | ||||||
|  |  **    ARGUMENTS       : Subsystem number | ||||||
|  |  ** | ||||||
|  |  **    RETURN TYPE     : Success or failure | ||||||
|  |  ** | ||||||
|  |  *****************************************************************************/ | ||||||
|  | bool fs_wrapper_data_read(FILESystemStruct *fileSysStruct) | ||||||
|  | { | ||||||
|  |     uint8_t index = fileSysStruct->noOfFiles - 1; | ||||||
|  |     OCMPMessageFrame *tempMsg = (OCMPMessageFrame *)fileSysStruct->pMsg; | ||||||
|  |     OCMPSubsystem subsys = tempMsg->message.subsystem; | ||||||
|  |     char fileName[FS_STR_SIZE] = { 0 }; | ||||||
|  |     file.cache.buffer = | ||||||
|  |         0; /* make buffer zero to avoid fail, might be a bug with filesystem */ | ||||||
|  |     while (index > 0) { | ||||||
|  |         sprintf(fileName, "%s_%d", fileSysStruct->fileName, index); | ||||||
|  |         fs_wrapper_flashMemory_read(subsys, fileName, | ||||||
|  |                                     fs_wrapper_get_fileSize(fileName), index); | ||||||
|  |         index--; | ||||||
|  |     } | ||||||
|  |     fs_wrapper_flashMemory_read( | ||||||
|  |         subsys, fileSysStruct->fileName, | ||||||
|  |         fs_wrapper_get_fileSize(fileSysStruct->fileName), index); | ||||||
|  |     return true; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /***************************************************************************** | ||||||
|  |  **    FUNCTION NAME   : fs_wrapper_data_write | ||||||
|  ** |  ** | ||||||
|  **    DESCRIPTION     : It write data to specified file |  **    DESCRIPTION     : It write data to specified file | ||||||
|  ** |  ** | ||||||
| @@ -159,24 +267,74 @@ int fileSize(const char *path) | |||||||
|  **    RETURN TYPE     : true or flase |  **    RETURN TYPE     : true or flase | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| bool fileWrite(const char *path, uint8_t *pMsg, uint32_t size) | bool fs_wrapper_data_write(FILESystemStruct *fileSysStruct) | ||||||
| { | { | ||||||
|     if (lfs_file_open(&lfs, &file, path, |     int8_t index = fileSysStruct->noOfFiles - 2; | ||||||
|                       LFS_O_RDWR | LFS_O_CREAT | LFS_O_APPEND) == LFS_ERR_OK) { |     char oldfilename[50] = { 0 }; | ||||||
|         LOGGER_DEBUG("FS:: File open successfully \n"); |     char newfilename[50] = { 0 }; | ||||||
|     } |  | ||||||
|     if (lfs_file_write(&lfs, &file, pMsg, size) == size) { |  | ||||||
|         LOGGER_DEBUG("FS:: File written successfully \n"); |  | ||||||
|     } |  | ||||||
|     if (lfs_file_close(&lfs, &file) == LFS_ERR_OK) { |  | ||||||
|         LOGGER_DEBUG("FS:: File closed successfully \n"); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |     if (fs_wrapper_get_fileSize(fileSysStruct->fileName) > | ||||||
|  |         fileSysStruct->maxFileSize) { | ||||||
|  |         /* Create new file */ | ||||||
|  |         if (lfs_file_open(&lfs, &file, "newfile", LFS_O_RDWR | LFS_O_CREAT) == | ||||||
|  |             LFS_ERR_OK) { | ||||||
|  |             LOGGER_DEBUG("FS:: File open successfully \n"); | ||||||
|  |             if (lfs_file_write(&lfs, &file, fileSysStruct->pMsg, | ||||||
|  |                                fileSysStruct->frameSize) == | ||||||
|  |                 fileSysStruct->frameSize) { | ||||||
|  |                 LOGGER_DEBUG("FS:: File written successfully \n"); | ||||||
|  |                 if (lfs_file_close(&lfs, &file) == LFS_ERR_OK) { | ||||||
|  |                     LOGGER_DEBUG("FS:: File closed successfully \n"); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         /* Find the last existing file */ | ||||||
|  |         while (index > 0) { | ||||||
|  |             sprintf(newfilename, "%s_%d", fileSysStruct->fileName, index); | ||||||
|  |             if (lfs_file_open(&lfs, &file, newfilename, | ||||||
|  |                               LFS_O_RDWR | LFS_O_APPEND) == LFS_ERR_OK) { | ||||||
|  |                 if (lfs_file_close(&lfs, &file) == LFS_ERR_OK) { | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             index--; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /* Move the existing files by +1 */ | ||||||
|  |         for (int i = index; i > 0; i--) { | ||||||
|  |             sprintf(oldfilename, "%s_%d", fileSysStruct->fileName, i); | ||||||
|  |             sprintf(newfilename, "%s_%d", fileSysStruct->fileName, i + 1); | ||||||
|  |             lfs_rename(&lfs, oldfilename, newfilename); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         sprintf(oldfilename, "%s", fileSysStruct->fileName); | ||||||
|  |         sprintf(newfilename, "%s_%d", fileSysStruct->fileName, 1); | ||||||
|  |         lfs_rename(&lfs, oldfilename, newfilename); | ||||||
|  |  | ||||||
|  |         sprintf(newfilename, "%s", fileSysStruct->fileName); | ||||||
|  |         lfs_rename(&lfs, "newfile", newfilename); | ||||||
|  |  | ||||||
|  |     } else { | ||||||
|  |         if (lfs_file_open(&lfs, &file, fileSysStruct->fileName, | ||||||
|  |                           LFS_O_RDWR | LFS_O_APPEND) == LFS_ERR_OK) { | ||||||
|  |             LOGGER_DEBUG("FS:: File open successfully \n"); | ||||||
|  |             if (lfs_file_write(&lfs, &file, fileSysStruct->pMsg, | ||||||
|  |                                fileSysStruct->frameSize) == | ||||||
|  |                 fileSysStruct->frameSize) { | ||||||
|  |                 LOGGER_DEBUG("FS:: File written successfully \n"); | ||||||
|  |                 if (lfs_file_close(&lfs, &file) == LFS_ERR_OK) { | ||||||
|  |                     LOGGER_DEBUG("FS:: File closed successfully \n"); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|  |             LOGGER_DEBUG("FS:: File open failed \n"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : fileRead |  **    FUNCTION NAME   : fs_wrapper_file_read | ||||||
|  ** |  ** | ||||||
|  **    DESCRIPTION     : It reads data from specified file |  **    DESCRIPTION     : It reads data from specified file | ||||||
|  ** |  ** | ||||||
| @@ -185,37 +343,50 @@ bool fileWrite(const char *path, uint8_t *pMsg, uint32_t size) | |||||||
|  **    RETURN TYPE     : true or flase |  **    RETURN TYPE     : true or flase | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| bool fileRead(const char *path, UChar *buf, uint32_t size) | bool fs_wrapper_file_read(const char *fileName, uint8_t *buf, uint32_t size) | ||||||
| { | { | ||||||
|     if (lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) == LFS_ERR_OK) { |     if (lfs_file_open(&lfs, &file, fileName, LFS_O_RDWR) == LFS_ERR_OK) { | ||||||
|         LOGGER_DEBUG("FS:: File open successfully \n"); |         LOGGER_DEBUG("FS:: File open successfully \n"); | ||||||
|  |         if (lfs_file_read(&lfs, &file, buf, size) == size) { | ||||||
|  |             LOGGER_DEBUG("FS:: File read successfully \n"); | ||||||
|  |             if (lfs_file_close(&lfs, &file) == LFS_ERR_OK) { | ||||||
|  |                 LOGGER_DEBUG("FS:: File closed successfully \n"); | ||||||
|  |             } else { | ||||||
|  |                 LOGGER_DEBUG("FS:: File closed failed \n"); | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|  |             LOGGER_DEBUG("FS:: File read failed \n"); | ||||||
|  |         } | ||||||
|  |     } else { | ||||||
|  |         LOGGER_DEBUG("FS:: File open failed \n"); | ||||||
|     } |     } | ||||||
|     if (lfs_file_read(&lfs, &file, buf, size) == size) { |  | ||||||
|         LOGGER_DEBUG("FS:: File read successfully \n"); |  | ||||||
|     } |  | ||||||
|     if (lfs_file_close(&lfs, &file) == LFS_ERR_OK) { |  | ||||||
|         LOGGER_DEBUG("FS:: File closed successfully \n"); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| /***************************************************************************** | /***************************************************************************** | ||||||
|  **    FUNCTION NAME   : fsMsgHandler |  **    FUNCTION NAME   : fs_wrapper_msgHandler | ||||||
|  ** |  ** | ||||||
|  **    DESCRIPTION     : It is called when data to be written |  **    DESCRIPTION     : It calls fs_wrapper_data_write function to write data | ||||||
|  |  *by passing file name | ||||||
|  ** |  ** | ||||||
|  **    ARGUMENTS       : data pointer |  **    ARGUMENTS       : data pointer | ||||||
|  ** |  ** | ||||||
|  **    RETURN TYPE     : true or flase |  **    RETURN TYPE     : true or flase | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| static bool fsMsgHandler(OCMPMessageFrame *pMsg) | static bool fs_wrapper_msgHandler(FILESystemStruct *fileSysStruct) | ||||||
| { | { | ||||||
|     char fileName[] = "logs"; |     switch (fileSysStruct->operation) { | ||||||
|  |         case WRITE_FLAG: | ||||||
|     fileWrite(fileName, (uint8_t *)pMsg, FRAME_SIZE); |             fs_wrapper_data_write(fileSysStruct); | ||||||
|  |             Semaphore_post(semFSwriteMsg); | ||||||
|  |             break; | ||||||
|  |         case READ_FLAG: | ||||||
|  |             fs_wrapper_data_read(fileSysStruct); | ||||||
|  |             break; | ||||||
|  |         default: | ||||||
|  |             break; | ||||||
|  |     } | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -225,45 +396,70 @@ static bool fsMsgHandler(OCMPMessageFrame *pMsg) | |||||||
|  **    DESCRIPTION     : It initializes filesystem by mounting device |  **    DESCRIPTION     : It initializes filesystem by mounting device | ||||||
|  ** |  ** | ||||||
|  **    ARGUMENTS       : arg0 for SPI device configuration, arg1 for return |  **    ARGUMENTS       : arg0 for SPI device configuration, arg1 for return | ||||||
|  |  *argument | ||||||
|  ** |  ** | ||||||
|  **    RETURN TYPE     : true or flase |  **    RETURN TYPE     : true or flase | ||||||
|  ** |  ** | ||||||
|  *****************************************************************************/ |  *****************************************************************************/ | ||||||
| void fs_init(UArg arg0, UArg arg1) | void fs_wrapper_fileSystem_init(UArg arg0, UArg arg1) | ||||||
| { | { | ||||||
|  |     uint8_t index = 0; | ||||||
|  |     FILESystemStruct *fileSysStruct; | ||||||
|  |     memset(&lfs, 0, sizeof(lfs)); | ||||||
|  |     memset(&file, 0, sizeof(file)); | ||||||
|  |  | ||||||
|  | #pragma GCC diagnostic push | ||||||
|  | #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" | ||||||
|     /*configuration of the filesystem is provided by this struct */ |     /*configuration of the filesystem is provided by this struct */ | ||||||
|     const struct lfs_config cfg = { |     const struct lfs_config cfg = { | ||||||
|         .context = (void *)arg0, |         .context = (void *)arg0, | ||||||
|         .read = block_device_read, |         .read = fs_wrapper_block_device_read, | ||||||
|         .prog = block_device_write, |         .prog = fs_wrapper_block_device_write, | ||||||
|         .erase = block_device_erase, |         .erase = fs_wrapper_block_device_erase, | ||||||
|         .sync = block_device_sync, |         .sync = fs_wrapper_block_device_sync, | ||||||
|         .read_size = READ_SIZE, |         .read_size = READ_SIZE, | ||||||
|         .prog_size = WRITE_SIZE, |         .prog_size = WRITE_SIZE, | ||||||
|         .block_size = BLOCK_SIZE, |         .block_size = BLOCK_SIZE, | ||||||
|         .block_count = BLOCK_COUNT, |         .block_count = BLOCK_COUNT, | ||||||
|         .lookahead = LOOK_AHEAD, |         .lookahead = LOOK_AHEAD, | ||||||
|     }; |     }; | ||||||
|  | #pragma GCC diagnostic pop | ||||||
|     int err = lfs_mount(&lfs, &cfg); |     int err = lfs_mount(&lfs, &cfg); | ||||||
|  |  | ||||||
|     if (err) { |     if (err) { | ||||||
|         lfs_format(&lfs, &cfg); |         lfs_format(&lfs, &cfg); | ||||||
|         lfs_mount(&lfs, &cfg); |         err = lfs_mount(&lfs, &cfg); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!err) { |     if (!err) { | ||||||
|         LOGGER_DEBUG("FS:: Filesystem mounted successfully \n"); |         LOGGER_DEBUG("FS:: Filesystem mounted successfully \n"); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     while (true) { |         while (index < ((AT45DB_Dev *)arg0)->cfg.noOfFiles) { | ||||||
|         if (Semaphore_pend(semFilesysMsg, BIOS_WAIT_FOREVER)) { |             if (lfs_file_open(&lfs, &file, | ||||||
|             while (!Queue_empty(fsTxMsgQueue)) { |                               ((AT45DB_Dev *)arg0)->cfg.fileName[index], | ||||||
|                 OCMPMessageFrame *pMsg = |                               LFS_O_CREAT | LFS_O_EXCL) == LFS_ERR_OK) { | ||||||
|                     (OCMPMessageFrame *)Util_dequeueMsg(fsTxMsgQueue); |                 LOGGER_DEBUG( | ||||||
|                 if (pMsg != NULL) { |                     "FS:: File created successfully in flash(at45db) memory \n"); | ||||||
|                     if (!fsMsgHandler(pMsg)) { |                 if (lfs_file_close(&lfs, &file) == LFS_ERR_OK) { | ||||||
|                         LOGGER_ERROR("ERROR:: Unable to route message \n"); |                     LOGGER_DEBUG("FS:: File closed successfully \n"); | ||||||
|                         free(pMsg); |                 } | ||||||
|  |             } else { | ||||||
|  |                 LOGGER_DEBUG( | ||||||
|  |                     "FS:: File already exist in flash(at45db) memory \n"); | ||||||
|  |             } | ||||||
|  |             index++; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         while (true) { | ||||||
|  |             if (Semaphore_pend(semFilesysMsg, BIOS_WAIT_FOREVER)) { | ||||||
|  |                 while (!Queue_empty(fsRxMsgQueue)) { | ||||||
|  |                     fileSysStruct = | ||||||
|  |                         (FILESystemStruct *)Util_dequeueMsg(fsRxMsgQueue); | ||||||
|  |                     if (fileSysStruct != NULL) { | ||||||
|  |                         if (!fs_wrapper_msgHandler(fileSysStruct)) { | ||||||
|  |                             LOGGER_ERROR("ERROR:: Unable to route message \n"); | ||||||
|  |                             free(fileSysStruct); | ||||||
|  |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -8,18 +8,60 @@ | |||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #ifndef SRC_FILESYSTEM_FS_H_ | #ifndef SRC_FILESYSTEM_FS_WRAPPER_H_ | ||||||
| #define SRC_FILESYSTEM_FS_H_ | #define SRC_FILESYSTEM_FS_WRAPPER_H_ | ||||||
|  |  | ||||||
| #include "common/inc/global/post_frame.h" | #include "common/inc/global/post_frame.h" | ||||||
|  | #include "common/inc/global/ocmp_frame.h" | ||||||
|  | #include <ti/sysbios/BIOS.h> | ||||||
|  | #include <ti/sysbios/knl/Queue.h> | ||||||
|  | #include <ti/sysbios/knl/Semaphore.h> | ||||||
|  | #include <ti/sysbios/knl/Task.h> | ||||||
|  |  | ||||||
| extern Queue_Handle fsRxMsgQueue; | #define FRAME_SIZE 64 | ||||||
| extern Queue_Handle fsTxMsgQueue; | #define FS_OCMP_MSGTYPE_POS 13 | ||||||
| extern Semaphore_Handle semFilesysMsg; | #define FS_OCMP_SUBSYSTEM_POS 11 | ||||||
|  | #define FS_STR_SIZE 50 | ||||||
|  | #define LAST_MSG 1 | ||||||
|  | #define LAST_MSG_FLAG 0 | ||||||
|  | #define MAX_ALERT_FILE_SIZE 512 | ||||||
|  | #define NEXT_MSG_FLAG_POS 17 | ||||||
|  | #define NO_OF_ALERT_FILES 8 | ||||||
|  | #define READ_FLAG 0 | ||||||
|  | #define WRITE_FLAG 1 | ||||||
|  |  | ||||||
| int fileSize(const char *path); | Semaphore_Handle semFilesysMsg; | ||||||
| void fs_init(UArg arg0, UArg arg1); | Semaphore_Struct semFSstruct; | ||||||
| bool fileRead(const char *path, UChar *buf, uint32_t size); |  | ||||||
| bool fileWrite(const char *path, uint8_t *pMsg, uint32_t size); |  | ||||||
|  |  | ||||||
| #endif /* SRC_FILESYSTEM_FS_H_ */ | Semaphore_Handle semFSreadMsg; | ||||||
|  | Semaphore_Struct semFSreadStruct; | ||||||
|  |  | ||||||
|  | Semaphore_Handle semFSwriteMsg; | ||||||
|  | Semaphore_Struct semFSwriteStruct; | ||||||
|  |  | ||||||
|  | #pragma GCC diagnostic push | ||||||
|  | #pragma GCC diagnostic ignored "-Wunused-variable" | ||||||
|  | static Queue_Struct fsRxMsg; | ||||||
|  | static Queue_Struct fsTxMsg; | ||||||
|  | #pragma GCC diagnostic pop | ||||||
|  |  | ||||||
|  | Queue_Handle fsRxMsgQueue; | ||||||
|  | Queue_Handle fsTxMsgQueue; | ||||||
|  |  | ||||||
|  | typedef struct FILESystemStruct { | ||||||
|  |     char *fileName; | ||||||
|  |     uint8_t frameSize; | ||||||
|  |     uint8_t noOfFiles; | ||||||
|  |     void *pMsg; | ||||||
|  |     uint16_t maxFileSize; | ||||||
|  |     uint8_t operation; | ||||||
|  | } FILESystemStruct; | ||||||
|  |  | ||||||
|  | int fs_wrapper_get_fileSize(const char *path); | ||||||
|  | bool fs_wrapper_data_read(FILESystemStruct *fileSysStruct); | ||||||
|  | void fs_wrapper_flashMemory_read(OCMPSubsystem subsystem, const char *path, | ||||||
|  |                                  uint32_t file_size, uint8_t fileIndex); | ||||||
|  | void fs_wrapper_fileSystem_init(UArg arg0, UArg arg1); | ||||||
|  | bool fs_wrapper_file_read(const char *fileName, uint8_t *buf, uint32_t size); | ||||||
|  |  | ||||||
|  | #endif /* SRC_FILESYSTEM_FS_WRAPPER_H_ */ | ||||||
|   | |||||||
| @@ -5,17 +5,16 @@ | |||||||
|  * SPDX-License-Identifier: BSD-3-Clause |  * SPDX-License-Identifier: BSD-3-Clause | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  | #include <assert.h> | ||||||
| #include "lfs.h" | #include "lfs.h" | ||||||
| #include "lfs_util.h" | #include "lfs_util.h" | ||||||
|  |  | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <assert.h> |  | ||||||
|  |  | ||||||
| /* Caching block device operations */ | /* Caching block device operations */ | ||||||
| static int lfs_cache_read(lfs_t *lfs, lfs_cache_t *rcache, | static int lfs_cache_read(lfs_t *lfs, lfs_cache_t *rcache, | ||||||
|                           const lfs_cache_t *pcache, lfs_block_t block, |                           const lfs_cache_t *pcache, lfs_block_t block, | ||||||
|                           lfs_off_t off, void *buffer, lfs_size_t size) |                           lfs_offset_t off, void *buffer, lfs_size_t size) | ||||||
| { | { | ||||||
|     uint8_t *data = buffer; |     uint8_t *data = buffer; | ||||||
|     assert(block < lfs->cfg->block_count); |     assert(block < lfs->cfg->block_count); | ||||||
| @@ -75,11 +74,11 @@ static int lfs_cache_read(lfs_t *lfs, lfs_cache_t *rcache, | |||||||
|  |  | ||||||
| static int lfs_cache_cmp(lfs_t *lfs, lfs_cache_t *rcache, | static int lfs_cache_cmp(lfs_t *lfs, lfs_cache_t *rcache, | ||||||
|                          const lfs_cache_t *pcache, lfs_block_t block, |                          const lfs_cache_t *pcache, lfs_block_t block, | ||||||
|                          lfs_off_t off, const void *buffer, lfs_size_t size) |                          lfs_offset_t off, const void *buffer, lfs_size_t size) | ||||||
| { | { | ||||||
|     const uint8_t *data = buffer; |     const uint8_t *data = buffer; | ||||||
|  |  | ||||||
|     for (lfs_off_t i = 0; i < size; i++) { |     for (lfs_offset_t i = 0; i < size; i++) { | ||||||
|         uint8_t c; |         uint8_t c; | ||||||
|         int err = lfs_cache_read(lfs, rcache, pcache, block, off + i, &c, 1); |         int err = lfs_cache_read(lfs, rcache, pcache, block, off + i, &c, 1); | ||||||
|         if (err) { |         if (err) { | ||||||
| @@ -95,9 +94,9 @@ static int lfs_cache_cmp(lfs_t *lfs, lfs_cache_t *rcache, | |||||||
|  |  | ||||||
| static int lfs_cache_crc(lfs_t *lfs, lfs_cache_t *rcache, | static int lfs_cache_crc(lfs_t *lfs, lfs_cache_t *rcache, | ||||||
|                          const lfs_cache_t *pcache, lfs_block_t block, |                          const lfs_cache_t *pcache, lfs_block_t block, | ||||||
|                          lfs_off_t off, lfs_size_t size, uint32_t *crc) |                          lfs_offset_t off, lfs_size_t size, uint32_t *crc) | ||||||
| { | { | ||||||
|     for (lfs_off_t i = 0; i < size; i++) { |     for (lfs_offset_t i = 0; i < size; i++) { | ||||||
|         uint8_t c; |         uint8_t c; | ||||||
|         int err = lfs_cache_read(lfs, rcache, pcache, block, off + i, &c, 1); |         int err = lfs_cache_read(lfs, rcache, pcache, block, off + i, &c, 1); | ||||||
|         if (err) { |         if (err) { | ||||||
| @@ -137,8 +136,8 @@ static int lfs_cache_flush(lfs_t *lfs, lfs_cache_t *pcache, lfs_cache_t *rcache) | |||||||
| } | } | ||||||
|  |  | ||||||
| static int lfs_cache_prog(lfs_t *lfs, lfs_cache_t *pcache, lfs_cache_t *rcache, | static int lfs_cache_prog(lfs_t *lfs, lfs_cache_t *pcache, lfs_cache_t *rcache, | ||||||
|                           lfs_block_t block, lfs_off_t off, const void *buffer, |                           lfs_block_t block, lfs_offset_t off, | ||||||
|                           lfs_size_t size) |                           const void *buffer, lfs_size_t size) | ||||||
| { | { | ||||||
|     const uint8_t *data = buffer; |     const uint8_t *data = buffer; | ||||||
|     assert(block < lfs->cfg->block_count); |     assert(block < lfs->cfg->block_count); | ||||||
| @@ -205,7 +204,7 @@ static int lfs_cache_prog(lfs_t *lfs, lfs_cache_t *pcache, lfs_cache_t *rcache, | |||||||
| } | } | ||||||
|  |  | ||||||
| /* General lfs block device operations */ | /* General lfs block device operations */ | ||||||
| static int lfs_bd_read(lfs_t *lfs, lfs_block_t block, lfs_off_t off, | static int lfs_bd_read(lfs_t *lfs, lfs_block_t block, lfs_offset_t off, | ||||||
|                        void *buffer, lfs_size_t size) |                        void *buffer, lfs_size_t size) | ||||||
| { | { | ||||||
|     /* if we ever do more than writes to alternating pairs, |     /* if we ever do more than writes to alternating pairs, | ||||||
| @@ -214,19 +213,19 @@ static int lfs_bd_read(lfs_t *lfs, lfs_block_t block, lfs_off_t off, | |||||||
|     return lfs_cache_read(lfs, &lfs->rcache, NULL, block, off, buffer, size); |     return lfs_cache_read(lfs, &lfs->rcache, NULL, block, off, buffer, size); | ||||||
| } | } | ||||||
|  |  | ||||||
| static int lfs_bd_prog(lfs_t *lfs, lfs_block_t block, lfs_off_t off, | static int lfs_bd_prog(lfs_t *lfs, lfs_block_t block, lfs_offset_t off, | ||||||
|                        const void *buffer, lfs_size_t size) |                        const void *buffer, lfs_size_t size) | ||||||
| { | { | ||||||
|     return lfs_cache_prog(lfs, &lfs->pcache, NULL, block, off, buffer, size); |     return lfs_cache_prog(lfs, &lfs->pcache, NULL, block, off, buffer, size); | ||||||
| } | } | ||||||
|  |  | ||||||
| static int lfs_bd_cmp(lfs_t *lfs, lfs_block_t block, lfs_off_t off, | static int lfs_bd_cmp(lfs_t *lfs, lfs_block_t block, lfs_offset_t off, | ||||||
|                       const void *buffer, lfs_size_t size) |                       const void *buffer, lfs_size_t size) | ||||||
| { | { | ||||||
|     return lfs_cache_cmp(lfs, &lfs->rcache, NULL, block, off, buffer, size); |     return lfs_cache_cmp(lfs, &lfs->rcache, NULL, block, off, buffer, size); | ||||||
| } | } | ||||||
|  |  | ||||||
| static int lfs_bd_crc(lfs_t *lfs, lfs_block_t block, lfs_off_t off, | static int lfs_bd_crc(lfs_t *lfs, lfs_block_t block, lfs_offset_t off, | ||||||
|                       lfs_size_t size, uint32_t *crc) |                       lfs_size_t size, uint32_t *crc) | ||||||
| { | { | ||||||
|     return lfs_cache_crc(lfs, &lfs->rcache, NULL, block, off, size, crc); |     return lfs_cache_crc(lfs, &lfs->rcache, NULL, block, off, size, crc); | ||||||
| @@ -430,7 +429,7 @@ static int lfs_dir_fetch(lfs_t *lfs, lfs_dir_t *dir, const lfs_block_t pair[2]) | |||||||
| } | } | ||||||
|  |  | ||||||
| struct lfs_region { | struct lfs_region { | ||||||
|     lfs_off_t oldoff; |     lfs_offset_t oldoff; | ||||||
|     lfs_size_t oldlen; |     lfs_size_t oldlen; | ||||||
|     const void *newdata; |     const void *newdata; | ||||||
|     lfs_size_t newlen; |     lfs_size_t newlen; | ||||||
| @@ -472,8 +471,8 @@ static int lfs_dir_commit(lfs_t *lfs, lfs_dir_t *dir, | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             int i = 0; |             int i = 0; | ||||||
|             lfs_off_t oldoff = sizeof(dir->d); |             lfs_offset_t oldoff = sizeof(dir->d); | ||||||
|             lfs_off_t newoff = sizeof(dir->d); |             lfs_offset_t newoff = sizeof(dir->d); | ||||||
|             while (newoff < (0x7fffffff & dir->d.size) - 4) { |             while (newoff < (0x7fffffff & dir->d.size) - 4) { | ||||||
|                 if (i < count && regions[i].oldoff == oldoff) { |                 if (i < count && regions[i].oldoff == oldoff) { | ||||||
|                     lfs_crc(&crc, regions[i].newdata, regions[i].newlen); |                     lfs_crc(&crc, regions[i].newdata, regions[i].newlen); | ||||||
| @@ -1002,7 +1001,7 @@ int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) | |||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) | int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_offset_t off) | ||||||
| { | { | ||||||
|     /* simply walk from head dir */ |     /* simply walk from head dir */ | ||||||
|     int err = lfs_dir_rewind(lfs, dir); |     int err = lfs_dir_rewind(lfs, dir); | ||||||
| @@ -1048,11 +1047,11 @@ int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* File index list operations */ | /* File index list operations */ | ||||||
| static int lfs_ctz_index(lfs_t *lfs, lfs_off_t *off) | static int lfs_ctz_index(lfs_t *lfs, lfs_offset_t *off) | ||||||
| { | { | ||||||
|     lfs_off_t size = *off; |     lfs_offset_t size = *off; | ||||||
|     lfs_off_t b = lfs->cfg->block_size - 2 * 4; |     lfs_offset_t b = lfs->cfg->block_size - 2 * 4; | ||||||
|     lfs_off_t i = size / b; |     lfs_offset_t i = size / b; | ||||||
|     if (i == 0) { |     if (i == 0) { | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
| @@ -1065,7 +1064,7 @@ static int lfs_ctz_index(lfs_t *lfs, lfs_off_t *off) | |||||||
| static int lfs_ctz_find(lfs_t *lfs, lfs_cache_t *rcache, | static int lfs_ctz_find(lfs_t *lfs, lfs_cache_t *rcache, | ||||||
|                         const lfs_cache_t *pcache, lfs_block_t head, |                         const lfs_cache_t *pcache, lfs_block_t head, | ||||||
|                         lfs_size_t size, lfs_size_t pos, lfs_block_t *block, |                         lfs_size_t size, lfs_size_t pos, lfs_block_t *block, | ||||||
|                         lfs_off_t *off) |                         lfs_offset_t *off) | ||||||
| { | { | ||||||
|     if (size == 0) { |     if (size == 0) { | ||||||
|         *block = 0xffffffff; |         *block = 0xffffffff; | ||||||
| @@ -1073,8 +1072,8 @@ static int lfs_ctz_find(lfs_t *lfs, lfs_cache_t *rcache, | |||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs_off_t current = lfs_ctz_index(lfs, &(lfs_off_t){ size - 1 }); |     lfs_offset_t current = lfs_ctz_index(lfs, &(lfs_offset_t){ size - 1 }); | ||||||
|     lfs_off_t target = lfs_ctz_index(lfs, &pos); |     lfs_offset_t target = lfs_ctz_index(lfs, &pos); | ||||||
|  |  | ||||||
|     while (current > target) { |     while (current > target) { | ||||||
|         lfs_size_t skip = |         lfs_size_t skip = | ||||||
| @@ -1096,7 +1095,7 @@ static int lfs_ctz_find(lfs_t *lfs, lfs_cache_t *rcache, | |||||||
|  |  | ||||||
| static int lfs_ctz_extend(lfs_t *lfs, lfs_cache_t *rcache, lfs_cache_t *pcache, | static int lfs_ctz_extend(lfs_t *lfs, lfs_cache_t *rcache, lfs_cache_t *pcache, | ||||||
|                           lfs_block_t head, lfs_size_t size, lfs_block_t *block, |                           lfs_block_t head, lfs_size_t size, lfs_block_t *block, | ||||||
|                           lfs_off_t *off) |                           lfs_offset_t *off) | ||||||
| { | { | ||||||
|     while (true) { |     while (true) { | ||||||
|         /* go ahead and grab a block */ |         /* go ahead and grab a block */ | ||||||
| @@ -1123,12 +1122,12 @@ static int lfs_ctz_extend(lfs_t *lfs, lfs_cache_t *rcache, lfs_cache_t *pcache, | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             size -= 1; |             size -= 1; | ||||||
|             lfs_off_t index = lfs_ctz_index(lfs, &size); |             lfs_offset_t index = lfs_ctz_index(lfs, &size); | ||||||
|             size += 1; |             size += 1; | ||||||
|  |  | ||||||
|             /* just copy out the last block if it is incomplete */ |             /* just copy out the last block if it is incomplete */ | ||||||
|             if (size != lfs->cfg->block_size) { |             if (size != lfs->cfg->block_size) { | ||||||
|                 for (lfs_off_t i = 0; i < size; i++) { |                 for (lfs_offset_t i = 0; i < size; i++) { | ||||||
|                     uint8_t data; |                     uint8_t data; | ||||||
|                     int err = |                     int err = | ||||||
|                         lfs_cache_read(lfs, rcache, NULL, head, i, &data, 1); |                         lfs_cache_read(lfs, rcache, NULL, head, i, &data, 1); | ||||||
| @@ -1155,7 +1154,7 @@ static int lfs_ctz_extend(lfs_t *lfs, lfs_cache_t *rcache, lfs_cache_t *pcache, | |||||||
|             index += 1; |             index += 1; | ||||||
|             lfs_size_t skips = lfs_ctz(index) + 1; |             lfs_size_t skips = lfs_ctz(index) + 1; | ||||||
|  |  | ||||||
|             for (lfs_off_t i = 0; i < skips; i++) { |             for (lfs_offset_t i = 0; i < skips; i++) { | ||||||
|                 int err = lfs_cache_prog(lfs, pcache, rcache, nblock, 4 * i, |                 int err = lfs_cache_prog(lfs, pcache, rcache, nblock, 4 * i, | ||||||
|                                          &head, 4); |                                          &head, 4); | ||||||
|                 if (err) { |                 if (err) { | ||||||
| @@ -1198,7 +1197,7 @@ static int lfs_ctz_traverse(lfs_t *lfs, lfs_cache_t *rcache, | |||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs_off_t index = lfs_ctz_index(lfs, &(lfs_off_t){ size - 1 }); |     lfs_offset_t index = lfs_ctz_index(lfs, &(lfs_offset_t){ size - 1 }); | ||||||
|  |  | ||||||
|     while (true) { |     while (true) { | ||||||
|         int err = cb(data, head); |         int err = cb(data, head); | ||||||
| @@ -1306,7 +1305,7 @@ int lfs_file_close(lfs_t *lfs, lfs_file_t *file) | |||||||
| { | { | ||||||
|     int err = lfs_file_sync(lfs, file); |     int err = lfs_file_sync(lfs, file); | ||||||
|  |  | ||||||
|     /* remove from list of files */ |     // remove from list of files | ||||||
|     for (lfs_file_t **p = &lfs->files; *p; p = &(*p)->next) { |     for (lfs_file_t **p = &lfs->files; *p; p = &(*p)->next) { | ||||||
|         if (*p == file) { |         if (*p == file) { | ||||||
|             *p = file->next; |             *p = file->next; | ||||||
| @@ -1342,7 +1341,7 @@ relocate: | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* either read from dirty cache or disk */ |     /* either read from dirty cache or disk */ | ||||||
|     for (lfs_off_t i = 0; i < file->off; i++) { |     for (lfs_offset_t i = 0; i < file->off; i++) { | ||||||
|         uint8_t data; |         uint8_t data; | ||||||
|         err = lfs_cache_read(lfs, &lfs->rcache, &file->cache, file->block, i, |         err = lfs_cache_read(lfs, &lfs->rcache, &file->cache, file->block, i, | ||||||
|                              &data, 1); |                              &data, 1); | ||||||
| @@ -1379,7 +1378,7 @@ static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (file->flags & LFS_F_WRITING) { |     if (file->flags & LFS_F_WRITING) { | ||||||
|         lfs_off_t pos = file->pos; |         lfs_offset_t pos = file->pos; | ||||||
|  |  | ||||||
|         /* copy over anything after current branch */ |         /* copy over anything after current branch */ | ||||||
|         lfs_file_t orig = { |         lfs_file_t orig = { | ||||||
| @@ -1565,7 +1564,7 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, const void *buffer, | |||||||
|  |  | ||||||
|     if (!(file->flags & LFS_F_WRITING) && file->pos > file->size) { |     if (!(file->flags & LFS_F_WRITING) && file->pos > file->size) { | ||||||
|         /* fill with zeros */ |         /* fill with zeros */ | ||||||
|         lfs_off_t pos = file->pos; |         lfs_offset_t pos = file->pos; | ||||||
|         file->pos = file->size; |         file->pos = file->size; | ||||||
|  |  | ||||||
|         while (file->pos < pos) { |         while (file->pos < pos) { | ||||||
| @@ -1654,13 +1653,13 @@ lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, | |||||||
|     if (whence == LFS_SEEK_SET) { |     if (whence == LFS_SEEK_SET) { | ||||||
|         file->pos = off; |         file->pos = off; | ||||||
|     } else if (whence == LFS_SEEK_CUR) { |     } else if (whence == LFS_SEEK_CUR) { | ||||||
|         if ((lfs_off_t)-off > file->pos) { |         if ((lfs_offset_t)-off > file->pos) { | ||||||
|             return LFS_ERR_INVAL; |             return LFS_ERR_INVAL; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         file->pos = file->pos + off; |         file->pos = file->pos + off; | ||||||
|     } else if (whence == LFS_SEEK_END) { |     } else if (whence == LFS_SEEK_END) { | ||||||
|         if ((lfs_off_t)-off > file->size) { |         if ((lfs_offset_t)-off > file->size) { | ||||||
|             return LFS_ERR_INVAL; |             return LFS_ERR_INVAL; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -1669,6 +1668,58 @@ lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, | |||||||
|     return file->pos; |     return file->pos; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_offset_t size) | ||||||
|  | { | ||||||
|  |     if ((file->flags & 3) == LFS_O_RDONLY) { | ||||||
|  |         return LFS_ERR_INVAL; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     lfs_offset_t oldsize = lfs_file_size(lfs, file); | ||||||
|  |     if (size < oldsize) { | ||||||
|  |         /* need to flush since directly changing metadata */ | ||||||
|  |         int err = lfs_file_flush(lfs, file); | ||||||
|  |         if (err) { | ||||||
|  |             return err; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /* lookup new head in ctz skip list */ | ||||||
|  |         err = lfs_ctz_find(lfs, &file->cache, NULL, file->head, file->size, | ||||||
|  |                            size, &file->head, &(lfs_offset_t){ 0 }); | ||||||
|  |         if (err) { | ||||||
|  |             return err; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         file->size = size; | ||||||
|  |         file->flags |= LFS_F_DIRTY; | ||||||
|  |     } else if (size > oldsize) { | ||||||
|  |         lfs_offset_t pos = file->pos; | ||||||
|  |  | ||||||
|  |         /* flush+seek if not already at end */ | ||||||
|  |         if (file->pos != oldsize) { | ||||||
|  |             int err = lfs_file_seek(lfs, file, 0, LFS_SEEK_END); | ||||||
|  |             if (err < 0) { | ||||||
|  |                 return err; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /* fill with zeros */ | ||||||
|  |         while (file->pos < size) { | ||||||
|  |             lfs_ssize_t res = lfs_file_write(lfs, file, &(uint8_t){ 0 }, 1); | ||||||
|  |             if (res < 0) { | ||||||
|  |                 return res; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /* restore pos */ | ||||||
|  |         int err = lfs_file_seek(lfs, file, pos, LFS_SEEK_SET); | ||||||
|  |         if (err < 0) { | ||||||
|  |             return err; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
| lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file) | lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file) | ||||||
| { | { | ||||||
|     return file->pos; |     return file->pos; | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ | |||||||
|  |  | ||||||
| /* Type definitions */ | /* Type definitions */ | ||||||
| typedef uint32_t lfs_size_t; | typedef uint32_t lfs_size_t; | ||||||
| typedef uint32_t lfs_off_t; | typedef uint32_t lfs_offset_t; | ||||||
|  |  | ||||||
| typedef int32_t lfs_ssize_t; | typedef int32_t lfs_ssize_t; | ||||||
| typedef int32_t lfs_soff_t; | typedef int32_t lfs_soff_t; | ||||||
| @@ -78,13 +78,13 @@ struct lfs_config { | |||||||
|     void *context; |     void *context; | ||||||
|  |  | ||||||
|     /* Read a region in a block */ |     /* Read a region in a block */ | ||||||
|     int (*read)(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, |     int (*read)(const struct lfs_config *c, lfs_block_t block, lfs_offset_t off, | ||||||
|                 void *buffer, lfs_size_t size); |                 void *buffer, lfs_size_t size); | ||||||
|  |  | ||||||
|     /* Program a region in a block, function must return LFS_ERR_CORRUPT |     /* Program a region in a block, function must return LFS_ERR_CORRUPT | ||||||
|      * if the block should be considered bad |      * if the block should be considered bad | ||||||
|      */ |      */ | ||||||
|     int (*prog)(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, |     int (*prog)(const struct lfs_config *c, lfs_block_t block, lfs_offset_t off, | ||||||
|                 const void *buffer, lfs_size_t size); |                 const void *buffer, lfs_size_t size); | ||||||
|  |  | ||||||
|     /* Erase a block, A block must be erased before being programmed */ |     /* Erase a block, A block must be erased before being programmed */ | ||||||
| @@ -152,7 +152,7 @@ struct lfs_info { | |||||||
|  |  | ||||||
| /* filesystem data structures */ | /* filesystem data structures */ | ||||||
| typedef struct lfs_entry { | typedef struct lfs_entry { | ||||||
|     lfs_off_t off; |     lfs_offset_t off; | ||||||
|  |  | ||||||
|     struct lfs_disk_entry { |     struct lfs_disk_entry { | ||||||
|         uint8_t type; |         uint8_t type; | ||||||
| @@ -171,32 +171,35 @@ typedef struct lfs_entry { | |||||||
|  |  | ||||||
| typedef struct lfs_cache { | typedef struct lfs_cache { | ||||||
|     lfs_block_t block; |     lfs_block_t block; | ||||||
|     lfs_off_t off; |     lfs_offset_t off; | ||||||
|     uint8_t *buffer; |     uint8_t *buffer; | ||||||
| } lfs_cache_t; | } lfs_cache_t; | ||||||
|  |  | ||||||
| typedef struct lfs_file { | typedef struct lfs_file { | ||||||
|     struct lfs_file *next; |     struct lfs_file *next; | ||||||
|     lfs_block_t pair[2]; |     lfs_block_t pair[2]; | ||||||
|     lfs_off_t poff; |     lfs_offset_t poff; | ||||||
|  |  | ||||||
|     lfs_block_t head; |     lfs_block_t head; | ||||||
|     lfs_size_t size; |     lfs_size_t size; | ||||||
|  |  | ||||||
|  |     const struct lfs_file_config *cfg; | ||||||
|  |  | ||||||
|     uint32_t flags; |     uint32_t flags; | ||||||
|     lfs_off_t pos; |     lfs_offset_t pos; | ||||||
|     lfs_block_t block; |     lfs_block_t block; | ||||||
|     lfs_off_t off; |     lfs_offset_t off; | ||||||
|     lfs_cache_t cache; |     lfs_cache_t cache; | ||||||
| } lfs_file_t; | } lfs_file_t; | ||||||
|  |  | ||||||
| typedef struct lfs_dir { | typedef struct lfs_dir { | ||||||
|     struct lfs_dir *next; |     struct lfs_dir *next; | ||||||
|  |  | ||||||
|     lfs_block_t pair[2]; |     lfs_block_t pair[2]; | ||||||
|     lfs_off_t off; |     lfs_offset_t off; | ||||||
|  |  | ||||||
|     lfs_block_t head[2]; |     lfs_block_t head[2]; | ||||||
|     lfs_off_t pos; |     lfs_offset_t pos; | ||||||
|  |  | ||||||
|     struct lfs_disk_dir { |     struct lfs_disk_dir { | ||||||
|         uint32_t rev; |         uint32_t rev; | ||||||
| @@ -206,7 +209,7 @@ typedef struct lfs_dir { | |||||||
| } lfs_dir_t; | } lfs_dir_t; | ||||||
|  |  | ||||||
| typedef struct lfs_superblock { | typedef struct lfs_superblock { | ||||||
|     lfs_off_t off; |     lfs_offset_t off; | ||||||
|  |  | ||||||
|     struct lfs_disk_superblock { |     struct lfs_disk_superblock { | ||||||
|         uint8_t type; |         uint8_t type; | ||||||
| @@ -305,7 +308,7 @@ int lfs_dir_close(lfs_t *lfs, lfs_dir_t *dir); | |||||||
| int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info); | int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info); | ||||||
|  |  | ||||||
| /* Change the position of the directory */ | /* Change the position of the directory */ | ||||||
| int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off); | int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_offset_t off); | ||||||
|  |  | ||||||
| /* Return the position of the directory */ | /* Return the position of the directory */ | ||||||
| lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir); | lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir); | ||||||
| @@ -316,6 +319,9 @@ int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir); | |||||||
| /* Traverse through all blocks in use by the filesystem */ | /* Traverse through all blocks in use by the filesystem */ | ||||||
| int lfs_traverse(lfs_t *lfs, int (*cb)(void *, lfs_block_t), void *data); | int lfs_traverse(lfs_t *lfs, int (*cb)(void *, lfs_block_t), void *data); | ||||||
|  |  | ||||||
|  | /* Truncates the size of the file to the specified size */ | ||||||
|  | int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_offset_t size); | ||||||
|  |  | ||||||
| /* Prunes any recoverable errors that may have occured in the filesystem | /* Prunes any recoverable errors that may have occured in the filesystem | ||||||
|  * Not needed to be called by user unless an operation is interrupted |  * Not needed to be called by user unless an operation is interrupted | ||||||
|  * but the filesystem is still mounted. This is already called on first |  * but the filesystem is still mounted. This is already called on first | ||||||
|   | |||||||
| @@ -1,12 +1,15 @@ | |||||||
| /* | /* | ||||||
|  * The little filesystem |  * lfs util functions | ||||||
|  * |  * | ||||||
|  * Copyright (c) 2017, Arm Limited. All rights reserved. |  * Copyright (c) 2017, Arm Limited. All rights reserved. | ||||||
|  * SPDX-License-Identifier: BSD-3-Clause |  * SPDX-License-Identifier: BSD-3-Clause | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "lfs_util.h" | #include "lfs_util.h" | ||||||
|  |  | ||||||
|  | // Only compile if user does not provide custom config | ||||||
|  | #ifndef LFS_CONFIG | ||||||
|  |  | ||||||
|  | // Software CRC implementation with small lookup table | ||||||
| void lfs_crc(uint32_t *restrict crc, const void *buffer, size_t size) | void lfs_crc(uint32_t *restrict crc, const void *buffer, size_t size) | ||||||
| { | { | ||||||
|     static const uint32_t rtable[16] = { |     static const uint32_t rtable[16] = { | ||||||
| @@ -22,3 +25,5 @@ void lfs_crc(uint32_t *restrict crc, const void *buffer, size_t size) | |||||||
|         *crc = (*crc >> 4) ^ rtable[(*crc ^ (data[i] >> 4)) & 0xf]; |         *crc = (*crc >> 4) ^ rtable[(*crc ^ (data[i] >> 4)) & 0xf]; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #endif | ||||||
|   | |||||||
| @@ -68,9 +68,9 @@ int main(void) | |||||||
|     openCellular_init(); |     openCellular_init(); | ||||||
|     /* Call board init functions */ |     /* Call board init functions */ | ||||||
|     Board_initGeneral(); |     Board_initGeneral(); | ||||||
|  |     Board_initSPI(); | ||||||
|     Board_initGPIO(); |     Board_initGPIO(); | ||||||
|     Board_initI2C(); |     Board_initI2C(); | ||||||
|     Board_initSPI(); |  | ||||||
|     Board_initUSB(Board_USBDEVICE); |     Board_initUSB(Board_USBDEVICE); | ||||||
|     Board_initUART(); |     Board_initUART(); | ||||||
|     ethernet_start(); |     ethernet_start(); | ||||||
|   | |||||||
| @@ -16,18 +16,21 @@ | |||||||
| #include "inc/common/global_header.h" | #include "inc/common/global_header.h" | ||||||
| #include "inc/utils/ocmp_util.h" | #include "inc/utils/ocmp_util.h" | ||||||
| #include "inc/utils/util.h" | #include "inc/utils/util.h" | ||||||
|  | #include "src/filesystem/fs_wrapper.h" | ||||||
|  |  | ||||||
| #define OCMP_ACTION_TYPE_GET 1 | #define AVAL_POS 9 | ||||||
| #define OCMP_ACTION_TYPE_SET 2 | #define LVAL_POS 7 | ||||||
| #define OCMP_ACTION_TYPE_REPLY 3 |  | ||||||
| #define OCMP_ACTION_TYPE_ACTIVE 4 | #define OCMP_ACTION_TYPE_ACTIVE 4 | ||||||
|  | #define OCMP_ACTION_TYPE_GET 1 | ||||||
|  | #define OCMP_ACTION_TYPE_REPLY 3 | ||||||
|  | #define OCMP_ACTION_TYPE_SET 2 | ||||||
|  |  | ||||||
| /* TODO: configurable directory (allow us to target different platforms) */ | /* TODO: configurable directory (allow us to target different platforms) */ | ||||||
| #include "platform/oc-sdr/schema/schema.h" | #include "platform/oc-sdr/schema/schema.h" | ||||||
|  |  | ||||||
| #include <ti/sysbios/BIOS.h> | #include <ti/sysbios/BIOS.h> | ||||||
|  |  | ||||||
| #define OC_TASK_STACK_SIZE 2048 | #define OC_TASK_STACK_SIZE 4096 | ||||||
| #define OC_TASK_PRIORITY 2 | #define OC_TASK_PRIORITY 2 | ||||||
|  |  | ||||||
| static char OC_task_stack[SUBSYSTEM_COUNT][OC_TASK_STACK_SIZE]; | static char OC_task_stack[SUBSYSTEM_COUNT][OC_TASK_STACK_SIZE]; | ||||||
| @@ -86,7 +89,8 @@ static bool _paramIsValid(const Parameter *param) | |||||||
| } | } | ||||||
|  |  | ||||||
| void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | ||||||
|                         const void *data) |                         const void *data, const void *lValue, | ||||||
|  |                         OCMPActionType actionType) | ||||||
| { | { | ||||||
|     if (!alert_data) { |     if (!alert_data) { | ||||||
|         return; |         return; | ||||||
| @@ -113,16 +117,24 @@ void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | |||||||
|     size_t param_size = (_paramSize(param) + 3) & ~0x03; |     size_t param_size = (_paramSize(param) + 3) & ~0x03; | ||||||
|  |  | ||||||
|     OCMPMessageFrame *pMsg = create_ocmp_msg_frame( |     OCMPMessageFrame *pMsg = create_ocmp_msg_frame( | ||||||
|         alert_data->subsystem, OCMP_MSG_TYPE_ALERT, OCMP_AXN_TYPE_ACTIVE, |         alert_data->subsystem, OCMP_MSG_TYPE_ALERT, actionType, | ||||||
|         alert_data->componentId + 1, /* TODO: inconsistency indexing in host */ |         alert_data->componentId + 1, /* TODO: inconsistency indexing in host */ | ||||||
|         parameters, param_size); |         parameters, param_size); | ||||||
|     if (pMsg) { |     if (pMsg) { | ||||||
|         memcpy(pMsg->message.ocmp_data, data, _paramSize(param)); |         memcpy(pMsg->message.ocmp_data + LVAL_POS, lValue, _paramSize(param)); | ||||||
|  |         memcpy(pMsg->message.ocmp_data + AVAL_POS, data, _paramSize(param)); | ||||||
|         Util_enqueueMsg(bigBrotherTxMsgQueue, semBigBrotherMsg, |         Util_enqueueMsg(bigBrotherTxMsgQueue, semBigBrotherMsg, | ||||||
|                         (uint8_t *)pMsg); |                         (uint8_t *)pMsg); | ||||||
|     } else { |     } else { | ||||||
|         LOGGER_ERROR("ERROR::Unable to allocate alert packet\n"); |         LOGGER_ERROR("ERROR::Unable to allocate alert packet\n"); | ||||||
|     } |     } | ||||||
|  |     FILESystemStruct fileSysStruct = { | ||||||
|  |         "alertLog",          FRAME_SIZE, | ||||||
|  |         NO_OF_ALERT_FILES,   (OCMPMessageFrame *)pMsg, | ||||||
|  |         MAX_ALERT_FILE_SIZE, WRITE_FLAG | ||||||
|  |     }; | ||||||
|  |     Util_enqueueMsg(fsRxMsgQueue, semFilesysMsg, (uint8_t *)&fileSysStruct); | ||||||
|  |     Semaphore_pend(semFSwriteMsg, BIOS_WAIT_FOREVER); | ||||||
| } | } | ||||||
|  |  | ||||||
| static bool _handleMsgTypeCmd(OCMPMessageFrame *pMsg, const Component *comp) | static bool _handleMsgTypeCmd(OCMPMessageFrame *pMsg, const Component *comp) | ||||||
| @@ -141,7 +153,7 @@ static bool _handleMsgTypeCmd(OCMPMessageFrame *pMsg, const Component *comp) | |||||||
|             cmd = &dev->commands[pMsg->message.action]; |             cmd = &dev->commands[pMsg->message.action]; | ||||||
|         } |         } | ||||||
|         if (cmd && cmd->cb_cmd) { |         if (cmd && cmd->cb_cmd) { | ||||||
|             cmd->cb_cmd(dev->driver_cfg, pMsg->message.ocmp_data); |             cmd->cb_cmd(dev->driver_cfg, pMsg); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -233,7 +245,8 @@ static bool _handleDevStatCfg(OCMPMessageFrame *pMsg, const Component *dev, | |||||||
|     } |     } | ||||||
|     return dev_handled; |     return dev_handled; | ||||||
| } | } | ||||||
|  | #pragma GCC diagnostic push | ||||||
|  | #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" | ||||||
| static bool _handle_post_enable(const Component *comp, OCMPMessageFrame *pMsg) | static bool _handle_post_enable(const Component *comp, OCMPMessageFrame *pMsg) | ||||||
| { | { | ||||||
|     bool ret = false; |     bool ret = false; | ||||||
| @@ -248,7 +261,7 @@ static bool _handle_post_enable(const Component *comp, OCMPMessageFrame *pMsg) | |||||||
|     pMsg->message.ocmp_data[0] = !(ret); // RETURN_OK =0; |     pMsg->message.ocmp_data[0] = !(ret); // RETURN_OK =0; | ||||||
|     return ret; |     return ret; | ||||||
| } | } | ||||||
|  | #pragma GCC diagnostic pop | ||||||
| static bool _handle_post_active(OCMPMessageFrame *pMsg, | static bool _handle_post_active(OCMPMessageFrame *pMsg, | ||||||
|                                 unsigned int subsystem_id) |                                 unsigned int subsystem_id) | ||||||
| { | { | ||||||
| @@ -415,9 +428,17 @@ static void subsystem_init(OCMPSubsystem ss_id) | |||||||
|                      ss_id); |                      ss_id); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Create Message Queue for RX Messages */ |     /* Create Message Queue for TX Messages */ | ||||||
|     ss->msgQueue = Util_constructQueue(&ss->queueStruct); |     ss->msgQueue = Util_constructQueue(&ss->queueStruct); | ||||||
|     if (!ss->msgQueue) { |     if (!ss->msgQueue) { | ||||||
|  |         LOGGER_ERROR("SS REG:ERROR:: Failed in Constructing Message Queue for " | ||||||
|  |                      "TX Message for subsystem %d\n", | ||||||
|  |                      ss_id); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /* Create Message Queue for RX Messages */ | ||||||
|  |     ss->msgRxQueue = Util_constructQueue(&ss->queueRxStruct); | ||||||
|  |     if (!ss->msgRxQueue) { | ||||||
|         LOGGER_ERROR("SS REG:ERROR:: Failed in Constructing Message Queue for " |         LOGGER_ERROR("SS REG:ERROR:: Failed in Constructing Message Queue for " | ||||||
|                      "RX Message for subsystem %d\n", |                      "RX Message for subsystem %d\n", | ||||||
|                      ss_id); |                      ss_id); | ||||||
| @@ -460,3 +481,38 @@ bool SSRegistry_sendMessage(OCMPSubsystem ss_id, void *pMsg) | |||||||
|  |  | ||||||
|     return Util_enqueueMsg(ss->msgQueue, ss->sem, (uint8_t *)pMsg); |     return Util_enqueueMsg(ss->msgQueue, ss->sem, (uint8_t *)pMsg); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | bool alert_log(void *driver, void *mSgPtr) | ||||||
|  | { | ||||||
|  |     // OCSubsystem *ss = (OCSubsystem*)malloc(sizeof(OCSubsystem)); | ||||||
|  |     OCMPMessageFrame *pMsg = mSgPtr; | ||||||
|  |     OC_SS subSysId = pMsg->message.subsystem; | ||||||
|  |     OCSubsystem *ss = ss_reg[subSysId]; | ||||||
|  |     bool count = false; | ||||||
|  |     FILESystemStruct fileSysStruct = { "alertLog",          FRAME_SIZE, | ||||||
|  |                                        NO_OF_ALERT_FILES,   pMsg, | ||||||
|  |                                        MAX_ALERT_FILE_SIZE, READ_FLAG }; | ||||||
|  |     Util_enqueueMsg(fsRxMsgQueue, semFilesysMsg, (uint8_t *)&fileSysStruct); | ||||||
|  |     while (1) { | ||||||
|  |         if (Semaphore_pend(ss->sem, BIOS_WAIT_FOREVER)) { | ||||||
|  |             while (!Queue_empty(ss->msgRxQueue)) { | ||||||
|  |                 pMsg = (OCMPMessageFrame *)Util_dequeueMsg(ss->msgRxQueue); | ||||||
|  |                 if (pMsg->message.ocmp_data[0] == LAST_MSG_FLAG) { | ||||||
|  |                     count = true; | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 if (pMsg) { | ||||||
|  |                     Util_enqueueMsg(bigBrotherTxMsgQueue, semBigBrotherMsg, | ||||||
|  |                                     (uint8_t *)pMsg); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             if (count == true) { | ||||||
|  |                 LOGGER_DEBUG("FS:: LAST msg \n"); | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return true; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -26,10 +26,12 @@ typedef void (*SS_ProcessMsg_Cb)(OCMPMessageFrame *pBmsMsg); | |||||||
| typedef struct OCSubsystem { | typedef struct OCSubsystem { | ||||||
|     /* Message queue handles */ |     /* Message queue handles */ | ||||||
|     Queue_Handle msgQueue; |     Queue_Handle msgQueue; | ||||||
|  |     Queue_Handle msgRxQueue; | ||||||
|     Semaphore_Handle sem; |     Semaphore_Handle sem; | ||||||
|  |  | ||||||
|     /* Private variables (reduce dynamic allocation needs) */ |     /* Private variables (reduce dynamic allocation needs) */ | ||||||
|     Queue_Struct queueStruct; |     Queue_Struct queueStruct; | ||||||
|  |     Queue_Struct queueRxStruct; | ||||||
|     Semaphore_Struct semStruct; |     Semaphore_Struct semStruct; | ||||||
|     Task_Struct taskStruct; |     Task_Struct taskStruct; | ||||||
|     eSubSystemStates state; |     eSubSystemStates state; | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "common/inc/global/Framework.h" | #include "common/inc/global/Framework.h" | ||||||
|  | #include <driverlib/sysctl.h> | ||||||
| #include "helpers/memory.h" | #include "helpers/memory.h" | ||||||
| #include "inc/common/bigbrother.h" | #include "inc/common/bigbrother.h" | ||||||
| #include "inc/common/global_header.h" | #include "inc/common/global_header.h" | ||||||
| @@ -26,23 +27,14 @@ | |||||||
| #include <xdc/std.h> | #include <xdc/std.h> | ||||||
| #include <xdc/cfg/global.h> | #include <xdc/cfg/global.h> | ||||||
| #include <xdc/runtime/System.h> | #include <xdc/runtime/System.h> | ||||||
|  | #include <xdc/std.h> | ||||||
|  |  | ||||||
| #define FRAME_SIZE 64 | #define OCFS_TASK_PRIORITY 1 | ||||||
| #define OCFS_TASK_PRIORITY 5 |  | ||||||
| #define OCFS_TASK_STACK_SIZE 4096 | #define OCFS_TASK_STACK_SIZE 4096 | ||||||
|  |  | ||||||
| Task_Struct ocFSTask; | Task_Struct ocFSTask; | ||||||
| Char ocFSTaskStack[OCFS_TASK_STACK_SIZE]; | Char ocFSTaskStack[OCFS_TASK_STACK_SIZE]; | ||||||
|  |  | ||||||
| Semaphore_Handle semFilesysMsg; |  | ||||||
|  |  | ||||||
| Semaphore_Struct semFSstruct; |  | ||||||
|  |  | ||||||
| static Queue_Struct fsTxMsg; |  | ||||||
|  |  | ||||||
| Queue_Handle fsRxMsgQueue; |  | ||||||
| Queue_Handle fsTxMsgQueue; |  | ||||||
|  |  | ||||||
| extern POSTData PostResult[POST_RECORDS]; | extern POSTData PostResult[POST_RECORDS]; | ||||||
|  |  | ||||||
| typedef enum { OC_SYS_CONF_MAC_ADDRESS = 0 } eOCConfigParamId; | typedef enum { OC_SYS_CONF_MAC_ADDRESS = 0 } eOCConfigParamId; | ||||||
| @@ -156,6 +148,16 @@ bool SYS_post_get_results(void **getpostResult) | |||||||
|     return status; |     return status; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /***************************************************************************** | ||||||
|  |  **    FUNCTION NAME   : sys_post_init | ||||||
|  |  ** | ||||||
|  |  **    DESCRIPTION     : Create the task for file system | ||||||
|  |  ** | ||||||
|  |  **    ARGUMENTS       : SPI driver configuration, return value | ||||||
|  |  ** | ||||||
|  |  **    RETURN TYPE     : bool | ||||||
|  |  ** | ||||||
|  |  *****************************************************************************/ | ||||||
| bool sys_post_init(void *driver, void *returnValue) | bool sys_post_init(void *driver, void *returnValue) | ||||||
| { | { | ||||||
|     Semaphore_construct(&semFSstruct, 0, NULL); |     Semaphore_construct(&semFSstruct, 0, NULL); | ||||||
| @@ -164,12 +166,32 @@ bool sys_post_init(void *driver, void *returnValue) | |||||||
|         LOGGER_DEBUG("FS:ERROR:: Failed in Creating Semaphore"); |         LOGGER_DEBUG("FS:ERROR:: Failed in Creating Semaphore"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |     Semaphore_construct(&semFSreadStruct, 0, NULL); | ||||||
|  |     semFSreadMsg = Semaphore_handle(&semFSreadStruct); | ||||||
|  |     if (!semFSreadMsg) { | ||||||
|  |         LOGGER_DEBUG("FS:ERROR:: Failed in Creating Semaphore"); | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     Semaphore_construct(&semFSwriteStruct, 0, NULL); | ||||||
|  |     semFSwriteMsg = Semaphore_handle(&semFSwriteStruct); | ||||||
|  |     if (!semFSwriteMsg) { | ||||||
|  |         LOGGER_DEBUG("FS:ERROR:: Failed in Creating Semaphore"); | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /* Create Message Queue for RX Messages */ |     /* Create Message Queue for RX Messages */ | ||||||
|     fsTxMsgQueue = Util_constructQueue(&fsTxMsg); |     fsTxMsgQueue = Util_constructQueue(&fsTxMsg); | ||||||
|     if (!fsTxMsgQueue) { |     if (!fsTxMsgQueue) { | ||||||
|         LOGGER_ERROR("FS:ERROR:: Failed in Constructing Message Queue for"); |         LOGGER_ERROR("FS:ERROR:: Failed in Constructing Message Queue for"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |     fsRxMsgQueue = Util_constructQueue(&fsRxMsg); | ||||||
|  |     if (!fsRxMsgQueue) { | ||||||
|  |         LOGGER_ERROR("FS:ERROR:: Failed in Constructing Message Queue for"); | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     Task_Params taskParams; |     Task_Params taskParams; | ||||||
|     Task_Params_init(&taskParams); |     Task_Params_init(&taskParams); | ||||||
|     taskParams.stackSize = OCFS_TASK_STACK_SIZE; |     taskParams.stackSize = OCFS_TASK_STACK_SIZE; | ||||||
| @@ -178,7 +200,7 @@ bool sys_post_init(void *driver, void *returnValue) | |||||||
|     taskParams.priority = OCFS_TASK_PRIORITY; |     taskParams.priority = OCFS_TASK_PRIORITY; | ||||||
|     taskParams.arg0 = (UArg)driver; |     taskParams.arg0 = (UArg)driver; | ||||||
|     taskParams.arg1 = (UArg)returnValue; |     taskParams.arg1 = (UArg)returnValue; | ||||||
|     Task_construct(&ocFSTask, fs_init, &taskParams, NULL); |     Task_construct(&ocFSTask, fs_wrapper_fileSystem_init, &taskParams, NULL); | ||||||
|     LOGGER_DEBUG("FS:INFO:: Creating filesystem task function.\n"); |     LOGGER_DEBUG("FS:INFO:: Creating filesystem task function.\n"); | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -20,6 +20,8 @@ | |||||||
| /* ======================== Constants & variables =========================== */ | /* ======================== Constants & variables =========================== */ | ||||||
| #define INA226_ALERT_MASK 0x8000 | #define INA226_ALERT_MASK 0x8000 | ||||||
| #define INA226_CAL_VALUE 0 | #define INA226_CAL_VALUE 0 | ||||||
|  | #define INA226_DEFAULT_ACTION 4 | ||||||
|  | #define INA226_DEFAULT_TEMP 600 | ||||||
| #define INA226_DEVICE_ID 0x2260 | #define INA226_DEVICE_ID 0x2260 | ||||||
| #define INA226_INVALID_CONFIG_PARAMID 1 | #define INA226_INVALID_CONFIG_PARAMID 1 | ||||||
| #define INA226_INVALID_DEVICE_ID 0xC802 | #define INA226_INVALID_DEVICE_ID 0xC802 | ||||||
|   | |||||||
| @@ -28,8 +28,10 @@ | |||||||
| #define GPP_TEMP_SENS_DEVICE_ID 0 | #define GPP_TEMP_SENS_DEVICE_ID 0 | ||||||
| #define POST_DATA_NULL 0x0000 | #define POST_DATA_NULL 0x0000 | ||||||
| #define SE98A_CFG_EOCTL 8 | #define SE98A_CFG_EOCTL 8 | ||||||
| #define SE98A_DEVICE_ID 0xA102 | #define SE98A_DEFAULT_ACTION 4 | ||||||
| #define SE98A_DEFAULT_INIT_VALUE 0 | #define SE98A_DEFAULT_INIT_VALUE 0 | ||||||
|  | #define SE98A_DEFAULT_TEMP 23 | ||||||
|  | #define SE98A_DEVICE_ID 0xA102 | ||||||
| #define SE98A_EVT_DEFAULT 1 << 3 | #define SE98A_EVT_DEFAULT 1 << 3 | ||||||
| #define SE98A_INVALID_DEVICE_ID 0xFACE | #define SE98A_INVALID_DEVICE_ID 0xFACE | ||||||
| #define SE98A_INVALID_MFG_ID 0xABCD | #define SE98A_INVALID_MFG_ID 0xABCD | ||||||
|   | |||||||
| @@ -126,8 +126,10 @@ static struct Test_AlertData { | |||||||
|     uint16_t val; |     uint16_t val; | ||||||
|     void *ctx; |     void *ctx; | ||||||
| } s_alert_data; | } s_alert_data; | ||||||
|  | #pragma GCC diagnostic push | ||||||
| static void _ina226_alert_handler(INA226_Event evt, uint16_t value, | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
|  | static void _ina226_alert_handler(INA226_Event evt, OCMPActionType alertAction, | ||||||
|  |                                   uint16_t value, uint16_t lValue, | ||||||
|                                   void *context) |                                   void *context) | ||||||
| { | { | ||||||
|     s_alert_data = (struct Test_AlertData){ |     s_alert_data = (struct Test_AlertData){ | ||||||
| @@ -137,7 +139,7 @@ static void _ina226_alert_handler(INA226_Event evt, uint16_t value, | |||||||
|         .ctx = context, |         .ctx = context, | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
|  | #pragma GCC diagnostic pop | ||||||
| static void _test_alert(INA226_Dev *dev, INA226_Event evt, uint16_t alert_mask, | static void _test_alert(INA226_Dev *dev, INA226_Event evt, uint16_t alert_mask, | ||||||
|                         uint16_t val, uint16_t new_mask) |                         uint16_t val, uint16_t new_mask) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -46,24 +46,33 @@ void suite_tearDown(void) | |||||||
| /* ================================ Tests =================================== */ | /* ================================ Tests =================================== */ | ||||||
| void test_i2c_read(void) | void test_i2c_read(void) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame Msg; | ||||||
|  |     OCMPMessageFrame *pMsg = &Msg; | ||||||
|  |     memcpy(pMsg->message.ocmp_data, &s_oci2c, sizeof(S_OCI2C)); | ||||||
|     DEBUG_I2C_regs[DEBUG_I2C_INTERRUPT_MASK] = DEBUG_I2C_READ_WRITE_VALUE; |     DEBUG_I2C_regs[DEBUG_I2C_INTERRUPT_MASK] = DEBUG_I2C_READ_WRITE_VALUE; | ||||||
|     TEST_ASSERT_EQUAL(true, i2c_read(&debug_I2C1, &s_oci2c)); |     TEST_ASSERT_EQUAL(true, i2c_read(&debug_I2C1, pMsg)); | ||||||
|  |     memcpy(&s_oci2c, pMsg->message.ocmp_data, sizeof(S_OCI2C)); | ||||||
|     TEST_ASSERT_EQUAL_HEX8(DEBUG_I2C_READ_WRITE_VALUE, s_oci2c.reg_value); |     TEST_ASSERT_EQUAL_HEX8(DEBUG_I2C_READ_WRITE_VALUE, s_oci2c.reg_value); | ||||||
|  |  | ||||||
|     /* Invalid bus */ |     /* Invalid bus */ | ||||||
|     TEST_ASSERT_EQUAL(false, i2c_read(&I2C_INVALID_DEV, &s_oci2c)); |     TEST_ASSERT_EQUAL(false, i2c_read(&I2C_INVALID_DEV, pMsg)); | ||||||
|     TEST_ASSERT_EQUAL(false, i2c_read(&debug_I2C1, &s_oci2c_invalid)); |     memcpy(pMsg->message.ocmp_data, &s_oci2c_invalid, sizeof(S_OCI2C)); | ||||||
|  |     TEST_ASSERT_EQUAL(false, i2c_read(&debug_I2C1, pMsg)); | ||||||
| } | } | ||||||
|  |  | ||||||
| void test_i2c_write(void) | void test_i2c_write(void) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame Msg; | ||||||
|  |     OCMPMessageFrame *pMsg = &Msg; | ||||||
|     DEBUG_I2C_regs[DEBUG_I2C_INTERRUPT_MASK] = DEBUG_I2C_DEFAULT_VALUE; |     DEBUG_I2C_regs[DEBUG_I2C_INTERRUPT_MASK] = DEBUG_I2C_DEFAULT_VALUE; | ||||||
|     s_oci2c.reg_value = DEBUG_I2C_READ_WRITE_VALUE; |     s_oci2c.reg_value = DEBUG_I2C_READ_WRITE_VALUE; | ||||||
|     TEST_ASSERT_EQUAL(true, i2c_write(&debug_I2C1, &s_oci2c)); |     memcpy(pMsg->message.ocmp_data, &s_oci2c, sizeof(S_OCI2C)); | ||||||
|  |     TEST_ASSERT_EQUAL(true, i2c_write(&debug_I2C1, pMsg)); | ||||||
|     TEST_ASSERT_EQUAL_HEX8(DEBUG_I2C_READ_WRITE_VALUE, |     TEST_ASSERT_EQUAL_HEX8(DEBUG_I2C_READ_WRITE_VALUE, | ||||||
|                            DEBUG_I2C_regs[DEBUG_I2C_INTERRUPT_MASK]); |                            DEBUG_I2C_regs[DEBUG_I2C_INTERRUPT_MASK]); | ||||||
|  |  | ||||||
|     /* Invalid bus */ |     /* Invalid bus */ | ||||||
|     TEST_ASSERT_EQUAL(false, i2c_write(&I2C_INVALID_DEV, &s_oci2c)); |     TEST_ASSERT_EQUAL(false, i2c_write(&I2C_INVALID_DEV, pMsg)); | ||||||
|     TEST_ASSERT_EQUAL(false, i2c_write(&debug_I2C1, &s_oci2c_invalid)); |     memcpy(pMsg->message.ocmp_data, &s_oci2c_invalid, sizeof(S_OCI2C)); | ||||||
|  |     TEST_ASSERT_EQUAL(false, i2c_write(&debug_I2C1, pMsg)); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -62,56 +62,63 @@ void suite_tearDown(void) | |||||||
| /* ================================ Tests =================================== */ | /* ================================ Tests =================================== */ | ||||||
| void test_ocgpio_get(void) | void test_ocgpio_get(void) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame Msg; | ||||||
|  |     OCMPMessageFrame *pMsg = &Msg; | ||||||
|     S_OCGPIO *s_oc_gpio = (S_OCGPIO *)&s_fake_pin; |     S_OCGPIO *s_oc_gpio = (S_OCGPIO *)&s_fake_pin; | ||||||
|     s_oc_gpio->pin = DEBUG_GPIO_PIN_VALUE; |     s_oc_gpio->pin = DEBUG_GPIO_PIN_VALUE; | ||||||
|     s_oc_gpio->value = DEBUG_GPIO_DEFAULT_VALUE; |     s_oc_gpio->value = DEBUG_GPIO_DEFAULT_VALUE; | ||||||
|  |  | ||||||
|  |     memcpy(pMsg->message.ocmp_data, &s_fake_pin, sizeof(S_OCGPIO)); | ||||||
|     PCA9557_regs[PCA9557_REGS_INPUT_VALUE] = DEBUG_GPIO_PIN_2; |     PCA9557_regs[PCA9557_REGS_INPUT_VALUE] = DEBUG_GPIO_PIN_2; | ||||||
|     SX1509_regs[SX1509_REG_DATA_B] = DEBUG_GPIO_SX1509_DATA_B_VALUE; |     SX1509_regs[SX1509_REG_DATA_B] = DEBUG_GPIO_SX1509_DATA_B_VALUE; | ||||||
|     SX1509_regs[SX1509_REG_DATA_A] = DEBUG_GPIO_SX1509_DATA_A_VALUE; |     SX1509_regs[SX1509_REG_DATA_A] = DEBUG_GPIO_SX1509_DATA_A_VALUE; | ||||||
|     DEBUG_GpioPins[DEBUG_GPIO_PIN_2] = OCGPIO_CFG_OUTPUT; |     DEBUG_GpioPins[DEBUG_GPIO_PIN_2] = OCGPIO_CFG_OUTPUT; | ||||||
|     /* Native Pin */ |     /* Native Pin */ | ||||||
|     TEST_ASSERT_EQUAL(true, ocgpio_get(&debug_ec_gpio_pa, &s_fake_pin)); |     TEST_ASSERT_EQUAL(true, ocgpio_get(&debug_ec_gpio_pa, pMsg)); | ||||||
|  |     memcpy(&s_fake_pin, pMsg->message.ocmp_data, sizeof(S_OCGPIO)); | ||||||
|     TEST_ASSERT_EQUAL(DEBUG_GPIO_PIN_VALUE, s_oc_gpio->value); |     TEST_ASSERT_EQUAL(DEBUG_GPIO_PIN_VALUE, s_oc_gpio->value); | ||||||
|  |  | ||||||
|     /* connected via SX1509 */ |     /* connected via SX1509 */ | ||||||
|     TEST_ASSERT_EQUAL(true, ocgpio_get(&debug_gbc_ioexpanderx70, &s_fake_pin)); |     TEST_ASSERT_EQUAL(true, ocgpio_get(&debug_gbc_ioexpanderx70, pMsg)); | ||||||
|     TEST_ASSERT_EQUAL(DEBUG_GPIO_PIN_VALUE, s_oc_gpio->value); |     TEST_ASSERT_EQUAL(DEBUG_GPIO_PIN_VALUE, s_oc_gpio->value); | ||||||
|  |  | ||||||
|     /* connected via PCA9557 */ |     /* connected via PCA9557 */ | ||||||
|     TEST_ASSERT_EQUAL(true, ocgpio_get(&debug_sdr_ioexpanderx1E, &s_fake_pin)); |     TEST_ASSERT_EQUAL(true, ocgpio_get(&debug_sdr_ioexpanderx1E, pMsg)); | ||||||
|     TEST_ASSERT_EQUAL(DEBUG_GPIO_PIN_VALUE, s_oc_gpio->value); |     TEST_ASSERT_EQUAL(DEBUG_GPIO_PIN_VALUE, s_oc_gpio->value); | ||||||
|  |  | ||||||
|     /* Invlaid Slave address */ |     /* Invlaid Slave address */ | ||||||
|     TEST_ASSERT_EQUAL( |     TEST_ASSERT_EQUAL(false, | ||||||
|         false, ocgpio_get(&debug_sdr_ioexpanderx1E_invalid, &s_fake_pin)); |                       ocgpio_get(&debug_sdr_ioexpanderx1E_invalid, pMsg)); | ||||||
| } | } | ||||||
| void test_ocgpio_set(void) | void test_ocgpio_set(void) | ||||||
| { | { | ||||||
|  |     OCMPMessageFrame Msg; | ||||||
|  |     OCMPMessageFrame *pMsg = &Msg; | ||||||
|     S_OCGPIO *s_oc_gpio = (S_OCGPIO *)&s_fake_pin; |     S_OCGPIO *s_oc_gpio = (S_OCGPIO *)&s_fake_pin; | ||||||
|     s_oc_gpio->pin = DEBUG_GPIO_PIN_2; |     s_oc_gpio->pin = DEBUG_GPIO_PIN_2; | ||||||
|     s_oc_gpio->value = DEBUG_GPIO_DEFAULT_VALUE; |     s_oc_gpio->value = DEBUG_GPIO_DEFAULT_VALUE; | ||||||
|  |     memcpy(pMsg->message.ocmp_data, &s_fake_pin, sizeof(S_OCGPIO)); | ||||||
|  |  | ||||||
|     PCA9557_regs[PCA9557_REGS_OUTPUT_VALUE] = DEBUG_GPIO_DEFAULT_VALUE; |     PCA9557_regs[PCA9557_REGS_OUTPUT_VALUE] = DEBUG_GPIO_DEFAULT_VALUE; | ||||||
|     SX1509_regs[SX1509_REG_DATA_B] = DEBUG_GPIO_DEFAULT_VALUE; |     SX1509_regs[SX1509_REG_DATA_B] = DEBUG_GPIO_DEFAULT_VALUE; | ||||||
|     SX1509_regs[SX1509_REG_DATA_A] = DEBUG_GPIO_DEFAULT_VALUE; |     SX1509_regs[SX1509_REG_DATA_A] = DEBUG_GPIO_DEFAULT_VALUE; | ||||||
|     DEBUG_GpioPins[DEBUG_GPIO_PIN_2] = OCGPIO_CFG_INPUT; |     DEBUG_GpioPins[DEBUG_GPIO_PIN_2] = OCGPIO_CFG_INPUT; | ||||||
|     /* Native Pin */ |     /* Native Pin */ | ||||||
|     TEST_ASSERT_EQUAL(true, ocgpio_set(&debug_ec_gpio_pa, &s_fake_pin)); |     TEST_ASSERT_EQUAL(true, ocgpio_set(&debug_ec_gpio_pa, pMsg)); | ||||||
|     TEST_ASSERT_EQUAL(OCGPIO_CFG_OUTPUT, DEBUG_GpioPins[DEBUG_GPIO_PIN_2]); |     TEST_ASSERT_EQUAL(OCGPIO_CFG_OUTPUT, DEBUG_GpioPins[DEBUG_GPIO_PIN_2]); | ||||||
|  |  | ||||||
|     /* connected via SX1509 */ |     /* connected via SX1509 */ | ||||||
|     TEST_ASSERT_EQUAL(true, ocgpio_set(&debug_gbc_ioexpanderx70, &s_fake_pin)); |     TEST_ASSERT_EQUAL(true, ocgpio_set(&debug_gbc_ioexpanderx70, pMsg)); | ||||||
|     TEST_ASSERT_EQUAL(DEBUG_GPIO_DEFAULT_VALUE, SX1509_regs[SX1509_REG_DATA_A]); |     TEST_ASSERT_EQUAL(DEBUG_GPIO_DEFAULT_VALUE, SX1509_regs[SX1509_REG_DATA_A]); | ||||||
|  |  | ||||||
|     /* connected via PCA9557 */ |     /* connected via PCA9557 */ | ||||||
|     TEST_ASSERT_EQUAL(true, ocgpio_set(&debug_sdr_ioexpanderx1E, &s_fake_pin)); |     TEST_ASSERT_EQUAL(true, ocgpio_set(&debug_sdr_ioexpanderx1E, pMsg)); | ||||||
|     TEST_ASSERT_EQUAL(DEBUG_GPIO_DEFAULT_VALUE, |     TEST_ASSERT_EQUAL(DEBUG_GPIO_DEFAULT_VALUE, | ||||||
|                       PCA9557_regs[PCA9557_REGS_OUTPUT_VALUE]); |                       PCA9557_regs[PCA9557_REGS_OUTPUT_VALUE]); | ||||||
|  |  | ||||||
|     /* Invlaid Slave address */ |     /* Invlaid Slave address */ | ||||||
|     TEST_ASSERT_EQUAL( |     TEST_ASSERT_EQUAL(false, | ||||||
|         false, ocgpio_set(&debug_sdr_ioexpanderx1E_invalid, &s_fake_pin)); |                       ocgpio_set(&debug_sdr_ioexpanderx1E_invalid, pMsg)); | ||||||
| } | } | ||||||
| void test_ocgpio_probe(void) | void test_ocgpio_probe(void) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -47,7 +47,8 @@ void suite_tearDown(void) | |||||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
| void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | ||||||
|                         const void *data) |                         const void *data, const void *lValue, | ||||||
|  |                         OCMPActionType actionType) | ||||||
| { | { | ||||||
| } | } | ||||||
| #pragma GCC diagnostic pop | #pragma GCC diagnostic pop | ||||||
| @@ -307,14 +308,22 @@ void test_ocmp_ina226_alert_handler(void) | |||||||
|                       INA226_fxnTable.cb_init(&sdr_fpga_ps, &fact_sdr_3v_ps_cfg, |                       INA226_fxnTable.cb_init(&sdr_fpga_ps, &fact_sdr_3v_ps_cfg, | ||||||
|                                               alert_data_cp)); |                                               alert_data_cp)); | ||||||
|  |  | ||||||
|     sdr_fpga_ps.obj.alert_cb(INA226_EVT_SOL, value, alert_data_cp); |     sdr_fpga_ps.obj.alert_cb(INA226_EVT_SOL, INA226_DEFAULT_ACTION, | ||||||
|     sdr_fpga_ps.obj.alert_cb(INA226_EVT_SUL, value, alert_data_cp); |                              INA226_DEFAULT_TEMP, value, alert_data_cp); | ||||||
|     sdr_fpga_ps.obj.alert_cb(INA226_EVT_BOL, value, alert_data_cp); |     sdr_fpga_ps.obj.alert_cb(INA226_EVT_SUL, INA226_DEFAULT_ACTION, | ||||||
|     sdr_fpga_ps.obj.alert_cb(INA226_EVT_BUL, value, alert_data_cp); |                              INA226_DEFAULT_TEMP, value, alert_data_cp); | ||||||
|     sdr_fpga_ps.obj.alert_cb(INA226_EVT_POL, value, alert_data_cp); |     sdr_fpga_ps.obj.alert_cb(INA226_EVT_BOL, INA226_DEFAULT_ACTION, | ||||||
|     sdr_fpga_ps.obj.alert_cb(INA226_EVT_COL, value, alert_data_cp); |                              INA226_DEFAULT_TEMP, value, alert_data_cp); | ||||||
|     sdr_fpga_ps.obj.alert_cb(INA226_EVT_CUL, value, alert_data_cp); |     sdr_fpga_ps.obj.alert_cb(INA226_EVT_BUL, INA226_DEFAULT_ACTION, | ||||||
|  |                              INA226_DEFAULT_TEMP, value, alert_data_cp); | ||||||
|  |     sdr_fpga_ps.obj.alert_cb(INA226_EVT_POL, INA226_DEFAULT_ACTION, | ||||||
|  |                              INA226_DEFAULT_TEMP, value, alert_data_cp); | ||||||
|  |     sdr_fpga_ps.obj.alert_cb(INA226_EVT_COL, INA226_DEFAULT_ACTION, | ||||||
|  |                              INA226_DEFAULT_TEMP, value, alert_data_cp); | ||||||
|  |     sdr_fpga_ps.obj.alert_cb(INA226_EVT_CUL, INA226_DEFAULT_ACTION, | ||||||
|  |                              INA226_DEFAULT_TEMP, value, alert_data_cp); | ||||||
|  |  | ||||||
|     /* Test for memory check */ |     /* Test for memory check */ | ||||||
|     sdr_fpga_ps.obj.alert_cb(INA226_EVT_COL, value, NULL); |     sdr_fpga_ps.obj.alert_cb(INA226_EVT_COL, INA226_DEFAULT_ACTION, | ||||||
|  |                              INA226_DEFAULT_TEMP, value, NULL); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -63,7 +63,8 @@ void suite_tearDown(void) | |||||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
| void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | ||||||
|                         const void *data) |                         const void *data, const void *lValue, | ||||||
|  |                         OCMPActionType actionType) | ||||||
| { | { | ||||||
| } | } | ||||||
| #pragma GCC diagnostic pop | #pragma GCC diagnostic pop | ||||||
|   | |||||||
| @@ -180,9 +180,9 @@ void suite_tearDown(void) | |||||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
| void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | ||||||
|                         const void *data) |                         const void *data, const void *lValue, | ||||||
|  |                         OCMPActionType actionType) | ||||||
| { | { | ||||||
|     return; |  | ||||||
| } | } | ||||||
| #pragma GCC diagnostic pop | #pragma GCC diagnostic pop | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,7 +31,8 @@ void test_alert(void) | |||||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
| void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | ||||||
|                         const void *data) |                         const void *data, const void *lValue, | ||||||
|  |                         OCMPActionType actionType) | ||||||
| { | { | ||||||
| } | } | ||||||
| #pragma GCC diagnostic pop | #pragma GCC diagnostic pop | ||||||
|   | |||||||
| @@ -42,7 +42,8 @@ void test_alert(void) | |||||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
| void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | ||||||
|                         const void *data) |                         const void *data, const void *lValue, | ||||||
|  |                         OCMPActionType actionType) | ||||||
| { | { | ||||||
| } | } | ||||||
| #pragma GCC diagnostic pop | #pragma GCC diagnostic pop | ||||||
|   | |||||||
| @@ -62,7 +62,8 @@ void suite_tearDown(void) | |||||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
| void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | void OCMP_GenerateAlert(const AlertData *alert_data, unsigned int alert_id, | ||||||
|                         const void *data) |                         const void *data, const void *lValue, | ||||||
|  |                         OCMPActionType actionType) | ||||||
| { | { | ||||||
| } | } | ||||||
| #pragma GCC diagnostic pop | #pragma GCC diagnostic pop | ||||||
| @@ -502,13 +503,18 @@ void test_ocmp_se98a_alert_handler(void) | |||||||
|                                             &fact_ap_se98a_ts1_cfg, |                                             &fact_ap_se98a_ts1_cfg, | ||||||
|                                             &alert_data)); |                                             &alert_data)); | ||||||
|  |  | ||||||
|     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_ACT, value, &alert_data); |     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_ACT, SE98A_DEFAULT_ACTION, | ||||||
|     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_AAW, value, &alert_data); |                                 SE98A_DEFAULT_TEMP, value, &alert_data); | ||||||
|     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_BAW, value, &alert_data); |     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_AAW, SE98A_DEFAULT_ACTION, | ||||||
|  |                                 SE98A_DEFAULT_TEMP, value, &alert_data); | ||||||
|  |     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_BAW, SE98A_DEFAULT_ACTION, | ||||||
|  |                                 SE98A_DEFAULT_TEMP, value, &alert_data); | ||||||
|  |  | ||||||
|     /* Test for memory check */ |     /* Test for memory check */ | ||||||
|     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_ACT, value, NULL); |     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_ACT, SE98A_DEFAULT_ACTION, | ||||||
|  |                                 SE98A_DEFAULT_TEMP, value, NULL); | ||||||
|  |  | ||||||
|     /* Default case test */ |     /* Default case test */ | ||||||
|     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_DEFAULT, value, &alert_data); |     gbc_gpp_ap_ts1.obj.alert_cb(SE98A_EVT_DEFAULT, SE98A_DEFAULT_ACTION, | ||||||
|  |                                 SE98A_DEFAULT_TEMP, value, &alert_data); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -133,8 +133,10 @@ static struct Test_AlertData { | |||||||
|     int8_t temp; |     int8_t temp; | ||||||
|     void *ctx; |     void *ctx; | ||||||
| } s_alert_data; | } s_alert_data; | ||||||
|  | #pragma GCC diagnostic push | ||||||
| static void alert_handler(SE98A_Event evt, int8_t temperature, void *context) | #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
|  | static void alert_handler(SE98A_Event evt, OCMPActionType alertAction, | ||||||
|  |                           int8_t temperature, int8_t lValue, void *context) | ||||||
| { | { | ||||||
|     s_alert_data = (struct Test_AlertData){ |     s_alert_data = (struct Test_AlertData){ | ||||||
|         .triggered = true, |         .triggered = true, | ||||||
| @@ -143,7 +145,7 @@ static void alert_handler(SE98A_Event evt, int8_t temperature, void *context) | |||||||
|         .ctx = context, |         .ctx = context, | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
|  | #pragma GCC diagnostic pop | ||||||
| /* Helper for testing the various alerts this device can create */ | /* Helper for testing the various alerts this device can create */ | ||||||
| static void _test_alert(SE98A_Dev *dev, uint16_t temp_reg, SE98A_Event exp_evt, | static void _test_alert(SE98A_Dev *dev, uint16_t temp_reg, SE98A_Event exp_evt, | ||||||
|                         int8_t exp_temp) |                         int8_t exp_temp) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 swateeshrivastava
					swateeshrivastava