/** * @brief Disables all the active endpoints except the endpoint zero. * * @param[in] usbp pointer to the @p USBDriver object * * @notapi */ void usb_lld_disable_endpoints(USBDriver *usbp) { unsigned i; /* Resets the packet memory allocator.*/ pm_reset(usbp); /* Disabling all endpoints.*/ for (i = 1; i <= USB_ENDOPOINTS_NUMBER; i++) { EPR_TOGGLE(i, 0); EPR_SET(i, 0); } }
/** Open a power meter probe by a given serial number \param pm a pointer to a pm_context \param serial the serial number \retval 0 - all fine \retval -1 - open failed (wrong serial number?) \retval -2 - setting baudrate failed \retval -3 - setting data characteristics failed \retval -4 - setting flow control failed \retval -5 - setting timeouts failed \retval -6 - purging buffers failed \retval -7 - resetting device failed */ PM600X_EXPORT int pm_open(struct pm_context *pm, unsigned long serial) { FT_STATUS ftstat; // convert the serial into a 8 digit string with leading zeroes char serial_string[12]; snprintf(serial_string, 12, "%06lu", serial); // open the device by a given serial number ftstat = FT_OpenEx((void *)serial_string, FT_OPEN_BY_SERIAL_NUMBER, &pm->handle); if (ftstat != FT_OK) pm_error_return(-1, "open failed (wrong serial number?)"); // get the device info to obtain the power meter type unsigned long id; ftstat = FT_GetDeviceInfo(pm->handle, NULL, &id, NULL, NULL, NULL); if (ftstat != FT_OK) pm_error_return(-8, "can not retrieve device info!"); pm->type = id; // set baud rate to 115200 ftstat = FT_SetBaudRate(pm->handle, FT_BAUD_115200); if (ftstat != FT_OK) pm_error_return(-2, "setting baudrate failed"); // set data characteristics to 8n1 ftstat = FT_SetDataCharacteristics(pm->handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE); if (ftstat != FT_OK) pm_error_return(-3, "setting data characteristics failed"); // set flow control to NONE ftstat = FT_SetFlowControl(pm->handle, FT_FLOW_NONE, 0, 0); if (ftstat != FT_OK) pm_error_return(-4, "setting flow control failed"); // set timeouts to 1 second for writes and 3.5 seconds for reads. This should be enough when measuring with averaging == 10000 ftstat = FT_SetTimeouts(pm->handle, 3500, 1000); if (ftstat != FT_OK) pm_error_return(-5, "setting timeouts failed"); // purge bufffers just in case ftstat = FT_Purge(pm->handle, FT_PURGE_RX | FT_PURGE_TX); if (ftstat != FT_OK) pm_error_return(-6, "purging buffers failed"); // reset the device via *RST return pm_reset(pm); }
int am335_init(void) { int i; /* * Each interrupt has a priority register associated with it * 8 bits... only 7:6:5:4 are available for SA * out of the 16 levels here... using a priority grouping * these 4 bits can be further split into preempt priority * and subpriority fields */ scr_enable_sleepdeep(); scr_enable_sleeponexit(); /* Disable all the external interrupts */ for (i=0; i < CM3_NUM_EXT_INTERRUPTS; i++) nvic_disable_irq(i); /* Disable Tamper swakeup, a new addition for AM43XX SOCs */ if (soc_id == AM43XX_SOC_ID) nvic_disable_irq(CM3_IRQ_TPM_WAKE); /* Clean the IPC registers */ m3_param_reset(); trace_init(); pm_reset(); setup_soc(); /* Enable only the MBX IRQ */ nvic_enable_irq(CM3_IRQ_MBINT0); nvic_enable_irq(53); m3_firmware_version(); /* TODO: Enable PRCM_INT2 with a dummy handler */ /* Notify A8 of init completion */ a8_notify(CMD_STAT_PASS); /* Ok we are done here */ return 0; }
/** * @brief USB low level reset routine. * * @param[in] usbp pointer to the @p USBDriver object * * @notapi */ void usb_lld_reset(USBDriver *usbp) { uint32_t cntr; /* Post reset initialization.*/ STM32_USB->BTABLE = 0; STM32_USB->ISTR = 0; STM32_USB->DADDR = DADDR_EF; cntr = /*CNTR_ESOFM | */ CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM | /*CNTR_ERRM | CNTR_PMAOVRM |*/ CNTR_CTRM; /* The SOF interrupt is only enabled if a callback is defined for this service because it is an high rate source.*/ if (usbp->config->sof_cb != NULL) cntr |= CNTR_SOFM; STM32_USB->CNTR = cntr; /* Resets the packet memory allocator.*/ pm_reset(usbp); /* EP0 initialization.*/ usbp->epc[0] = &ep0config; usb_lld_init_endpoint(usbp, 0); }
/** * \brief The main function. * * It sets up the USART module on EXAMPLE_USART. The terminal settings are 57600 * 8N1. * Then it sets up the interrupt handler and waits for a USART interrupt to * trigger. */ int main(void) { static const gpio_map_t USART_GPIO_MAP = { {EXAMPLE_USART_RX_PIN, EXAMPLE_USART_RX_FUNCTION}, {EXAMPLE_USART_TX_PIN, EXAMPLE_USART_TX_FUNCTION} }; // USART options. static const usart_options_t USART_OPTIONS = { .baudrate = EXAMPLE_USART_BAUDRATE, .charlength = 8, .paritytype = USART_NO_PARITY, .stopbits = USART_1_STOPBIT, .channelmode = USART_NORMAL_CHMODE }; #if BOARD == EVK1100 || BOARD == EVK1101 || BOARD == UC3C_EK \ || BOARD == EVK1104 || BOARD == EVK1105 || BOARD == STK600_RCUC3L0 \ || BOARD == STK600_RCUC3D /* * Configure Osc0 in crystal mode (i.e. use of an external crystal * source, with frequency FOSC0) with an appropriate startup time then * switch the main clock source to Osc0. */ pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP); #elif BOARD == STK1000 pm_reset(); #elif BOARD == UC3L_EK /* * Note: on the AT32UC3L-EK board, there is no crystal/external clock * connected to the OSC0 pinout XIN0/XOUT0. We shall then program the * DFLL and switch the main clock source to the DFLL. */ pcl_configure_clocks(&pcl_dfll_freq_param); /* * Note: since it is dynamically computing the appropriate field values * of the configuration registers from the parameters structure, this * function is not optimal in terms of code size. For a code size * optimal solution, it is better to create a new function from * pcl_configure_clocks_dfll0() and modify it to use preprocessor * computation from pre-defined target frequencies. */ #endif // Assign GPIO to USART. gpio_enable_module(USART_GPIO_MAP, sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0])); // Initialize USART in RS232 mode. usart_init_rs232(EXAMPLE_USART, &USART_OPTIONS, EXAMPLE_TARGET_PBACLK_FREQ_HZ); print(EXAMPLE_USART, ".: Using interrupts with the USART :.\r\n\r\n"); // Disable all interrupts. Disable_global_interrupt(); // Initialize interrupt vectors. INTC_init_interrupts(); /* * Register the USART interrupt handler to the interrupt controller. * usart_int_handler is the interrupt handler to register. * EXAMPLE_USART_IRQ is the IRQ of the interrupt handler to register. * AVR32_INTC_INT0 is the interrupt priority level to assign to the * group of this IRQ. */ INTC_register_interrupt(&usart_int_handler, EXAMPLE_USART_IRQ, AVR32_INTC_INT0); // Enable USART Rx interrupt. EXAMPLE_USART->ier = AVR32_USART_IER_RXRDY_MASK; print(EXAMPLE_USART, "Type a character to use the interrupt handler." "\r\nIt will show up on your screen.\r\n\r\n"); // Enable all interrupts. Enable_global_interrupt(); /** * We have nothing left to do in the main, so we may switch to a device * sleep mode: we just need to be sure that the USART module will be * still be active in the chosen sleep mode. The sleep mode to use is * the FROZEN sleep mode: in this mode the PB clocks are still active * (so the USART module which is on the Peripheral Bus will still be * active while the CPU and HSB will be stopped). * -- * Modules communicating with external circuits should normally be * disabled before entering a sleep mode that will stop the module * operation: this is not the case for the FROZEN sleep mode. * -- * When the USART interrupt occurs, this will wake the CPU up which will * then execute the interrupt handler code then come back to the * while(1) loop below to execute the sleep instruction again. */ while(1) { /* * If there is a chance that any PB write operations are * incomplete, the CPU should perform a read operation from any * register on the PB bus before executing the sleep * instruction. */ AVR32_INTC.ipr[0]; // Dummy read // Go to FROZEN sleep mode. SLEEP(AVR32_PM_SMODE_FROZEN); /* * When the device wakes up due to an interrupt, once the * interrupt has been serviced, go back into FROZEN sleep mode. */ } }
/** * respond to an request message from Carrier Manager/BMC. * * \param request message which has to be responded * \param response response message */ int bmc_respond(ipmbMSG_t *request, ipmbMSG_t *response) { int ret = E_OK; /* Initialize general response message parameters */ response->rsSA = request->rqSA; response->netFN = (request->netFN | 0x01); /* response */ response->rsLUN = request->rqLUN; response->rqSA = global_data.bmc_ipmb_addr; /* BMC's IPMB address */ response->rqSeq = request->rqSeq; response->rqLUN = request->rsLUN; response->cmd = request->cmd; response->orig_channel = request->dest_channel; /* swap destination and origin channel */ response->dest_channel = request->orig_channel; response->data_len = 0; /* first evaluate net function */ switch (request->netFN) { /* NetFN = 0x04 (Sensor/Event) */ case NETFN_SENSOR_EVENT_RQ: switch (request->cmd) { case CMD_SET_EVENT_RECEIVER: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_EVENT_RECEIVER'\n"); bmc_set_event_receiver(request, response); break; case CMD_GET_EVENT_RECEIVER: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_EVENT_RECEIVER'\n"); bmc_get_event_receiver(request, response); break; case CMD_PLATFORM_EVENT: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_PLATFORM_EVENT'\n"); bmc_platform_event(request, response); break; #ifdef CFG_PEF_ENABLE case CMD_GET_PEF_CAPABILITIES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_PEF_CAPABILITIES'\n"); bmc_get_pef_capabilities(request, response); break; case CMD_ARM_PEF_POSTPONE_TIMER: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_ARM_PEF_POSTPONE_TIMER'\n"); bmc_arm_pef_postpone_timer(request, response); break; case CMD_SET_PEF_CONFIGURATION: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_PEF_CONFIG'\n"); bmc_set_pef_config(request, response); /* see event.c */ break; case CMD_GET_PEF_CONFIGURATION: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_PEF_CONFIG'\n"); bmc_get_pef_config(request, response); /* see event.c */ break; case CMD_SET_LAST_PROCESSED_EVENT_ID: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_LAST_PROCESSED_EVENT_ID'\n"); bmc_set_last_processed_eventid(request, response); /* see event.c */ break; case CMD_GET_LAST_PROCESSED_EVENT_ID: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_LAST_PROCESSED_EVENT_ID'\n"); bmc_get_last_processed_eventid(request, response); /* see event.c */ break; #endif /* CFG_PEF_ENABLE */ case CMD_GET_DEVICE_SDR_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_DEVICE_SDR_INFO'\n"); bmc_get_device_sdr_info(request, response); break; case CMD_GET_DEVICE_SDR: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_DEVICE_SDR'\n"); bmc_get_sdr_entry(request, response); break; case CMD_RES_DEVICE_SDR_REPO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_RES_DEVICE_SDR_REPO'\n"); bmc_sdr_reserve_id(request, response); break; #if 0 case CMD_GET_SENSOR_READING_FACTORS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SENSOR_READING_FACTORS'\n"); bmc_unknown_command(request, response); break; #endif case CMD_SET_SENSOR_HYSTERESIS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_SENSOR_HYSTERESIS'\n"); bmc_set_sensor_hysteresis(request, response); break; case CMD_GET_SENSOR_HYSTERESIS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SENSOR_HYSTERESIS'\n"); bmc_get_sensor_hysteresis(request, response); break; case CMD_SET_SENSOR_TRESHOLD: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_SENSOR_TRESHOLD'\n"); bmc_set_sensor_threshold(request, response); break; case CMD_GET_SENSOR_TRESHOLD: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SENSOR_TRESHOLD'\n"); bmc_get_sensor_threshold(request, response); break; case CMD_SET_SENSOR_EVENT_ENABLE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_SENSOR_EVENT_ENABLE'\n"); bmc_set_sensor_event_en(request, response); break; case CMD_GET_SENSOR_EVENT_ENABLE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SENSOR_EVENT_ENABLE'\n"); bmc_get_sensor_event_en(request, response); break; case CMD_REARM_SENSOR_EVENTS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_REARM_SENSOR_EVENTS'\n"); bmc_rearm_sensor_events(request, response); break; case CMD_GET_SENSOR_EVENT_STATUS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SENSOR_EVENT_STATUS'\n"); bmc_get_sensor_event_status(request, response); break; case CMD_GET_SENSOR_READING: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SENSOR_READING'\n"); bmc_get_sensor_reading(request, response); break; #if 0 case CMD_SET_SENSOR_TYPE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_SENSOR_TYPE'\n"); bmc_set_sensor_type(request, response); break; case CMD_GET_SENSOR_TYPE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SENSOR_TYPE'\n"); bmc_get_sensor_type(request, response); break; #endif /* Unknown command, respond with "invalid command" */ default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown cmd 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); bmc_unknown_command(request, response); break; } break; /* NetFN = 0x05 (Sensor/Event) */ #ifdef CFG_ATCA case NETFN_SENSOR_EVENT_RS: switch (request->cmd) { case CMD_PLATFORM_EVENT: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_handle_response: 'CMD_PLATFORM_EVENT'\n"); bmc_platform_event_response(request); break; /* Unknown command, respond with "invalid command" */ default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown rsp 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); break; } break; #endif /* NetFN = 0x06 (Application) */ case NETFN_APP_RQ: switch (request->cmd) { case CMD_GET_DEVICE_ID: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_DEVICE_ID'\n"); bmc_get_device_id(request, response); break; case CMD_COLD_RESET: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_COLD_RESET'\n"); bmc_cold_reset(request, response); break; #ifndef CFG_MCMC case CMD_WARM_RESET: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_WARM_RESET'\n"); bmc_warm_reset(request, response); break; #endif case CMD_GET_SELF_TEST_RESULT: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SELF_TEST_RESULT'\n"); bmc_get_selftest_results(request, response); break; case CMD_GET_DEVICE_GUID: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_DEVICE_GUID'\n"); bmc_get_device_guid(request, response); break; case CMD_RESET_WD_TIMER: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_RESET_WD_TIMER'\n"); bmc_reset_watchdog(request, response); break; case CMD_SET_WD_TIMER: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_WD_TIMER' timer use:%d\n", (request->data[0] & 0x7)); bmc_set_wd_timer(request, response); break; case CMD_GET_WD_TIMER: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_WD_TIMER'\n"); bmc_get_wd_timer(request, response); break; case CMD_SET_BMC_GLOBAL_ENABLES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_BMC_GLOBAL_ENABLES'\n"); bmc_set_global_enables(request, response); break; case CMD_GET_BMC_GLOBAL_ENABLES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_BMC_GLOBAL_ENABLES'\n"); bmc_get_global_enables(request, response); break; case CMD_CLR_MSG_FLAG: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_CLR_MSG_FLAG' %02x\n", request->data[0]); bmc_clr_msg_flags(request, response); break; case CMD_GET_MSG_FLAG: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_MSG_FLAG'\n"); bmc_get_msg_flags(request, response); break; case CMD_GET_MSG: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_MSG'\n"); bmc_get_recv_msg(request, response); break; case CMD_READ_EVENT_MSG_BUFFER: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_READ_EVENT_MSG_BUFFER'\n"); bmc_read_event_msg_buffer(request, response); break; case CMD_GET_SYSTEM_GUID: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SYSTEM_GUID'\n"); bmc_get_device_guid(request, response); break; #ifndef CFG_MCMC case CMD_GET_CHAN_AUTH_CAP: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_CHAN_AUTH_CAP'\n"); bmc_get_chan_auth_cap(request, response); break; case CMD_SET_CHANNEL_ACCESS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_CHANNEL_ACCESS' %02x\n", request->data[0]); bmc_set_channel_access(request, response); break; case CMD_GET_CHANNEL_ACCESS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_CHANNEL_ACCESS' %02x\n", request->data[0]); bmc_get_channel_access(request, response); break; #endif case CMD_GET_CH_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_CH_INFO' ch 0x%02x\n", request->data[0]); bmc_get_ch_info(request, response); break; #ifndef CFG_MCMC case CMD_SET_USER_ACCESS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_USER_ACCESS' ch 0x%02x\n", (request->data[0] & 0x0F)); bmc_set_user_access(request, response); break; case CMD_GET_USER_ACCESS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_USER_ACCESS' ch 0x%02x\n", (request->data[0] & 0x0F)); bmc_get_user_access(request, response); break; case CMD_SET_USER_NAME: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_USER_NAME'\n"); bmc_set_user_name(request, response); break; case CMD_GET_USER_NAME: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_USER_NAME'\n"); bmc_get_user_name(request, response); break; case CMD_SET_USER_PASSWORD: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_USER_PASSWORD'\n"); bmc_set_user_password(request, response); break; #endif case CMD_MASTER_WRITE_READ: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_MASTER_WRITE_READ'\n"); bmc_master_write_read(request, response); break; /* NOTE: Removed because command is optional and we do not support * a valid System Interface as defined by IPMI2.0 table 22-12. */ #if 0 case CMD_GET_SYS_INT_CAP: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SYS_INT_CAP' %02x\n", request->data[0]); bmc_get_sys_cap(request, response); break; #endif default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown cmd 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); bmc_unknown_command(request, response); break; } break; /* NetFN = 0x0A (Storage) */ case NETFN_STORAGE_RQ: switch (request->cmd) { case CMD_GET_FRU_INVENTORY_AREA_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_FRU_INVENTORY_AREA_INFO'\n"); bmc_fru_invent_area(request, response); break; case CMD_READ_FRU_DATA: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_READ_FRU_DATA'\n"); bmc_read_fru_data(request, response); break; case CMD_WRITE_FRU_DATA: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_WRITE_FRU_DATA'\n"); bmc_write_fru_data(request, response); break; case CMD_GET_SDR_REPO_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SDR_REPO_INFO'\n"); bmc_get_sdr_repo_info(request, response); break; case CMD_RES_SDR_REPO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_RES_SDR_REPO'\n"); bmc_sdr_reserve_id(request, response); break; case CMD_GET_SDR: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SDR' ID:%02x%02x\n", request->data[3], request->data[2]); bmc_get_sdr_entry(request, response); break; case CMD_ADD_SDR: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_ADD_SDR'\n"); bmc_add_sdr(request, response); break; case CMD_PART_ADD_SDR: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_PART_ADD_SDR'\n"); bmc_part_add_sdr(request, response); break; #if 0 case CMD_DEL_SDR: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_DEL_SDR' ID:%02x%02x\n", request->data[3], request->data[2]); bmc_del_sdr(request, response); break; #endif case CMD_CLR_SDR_REPO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_CLR_SDR_REPO'\n"); bmc_clr_sdr_repo(request, response); break; #ifndef CFG_MCMC case CMD_GET_SDR_REPO_TIME: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SDR_REPO_TIME'\n"); bmc_sel_time_get(request, response); break; case CMD_SET_SDR_REPO_TIME: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_SDR_REPO_TIME'\n"); bmc_sel_time_set(request, response); break; #endif // END CFG_MCMC #ifdef CFG_SEL_ENABLE case CMD_GET_SEL_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SEL_INFO'\n"); bmc_get_sel_info(request, response); break; #ifndef CFG_MCMC case CMD_GET_SEL_ALLOC_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SEL_ALLOC_INFO'\n"); bmc_get_sel_alloc_info(request, response); break; #endif // END CFG_MCMC case CMD_RESERVE_SEL: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_RESERVE_SEL'\n"); bmc_sel_reserve_id(request, response); break; case CMD_GET_SEL_ENTRY: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SEL_ENTRY' ID:%02x%02x\n", request->data[3], request->data[2]); bmc_get_sel_entry(request, response); break; case CMD_ADD_SEL_ENTRY: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_ADD_SEL_ENTRY'\n"); if (xSemaphoreTake(sel_in_use, QUEUE_BLOCK_SEM) == pdTRUE) /* wait until sel access is free */ { bmc_add_sel_entry(request, response); xSemaphoreGive(sel_in_use); } else { /* print error message and retry... */ debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Could not obtain semaphore for SEL.\n", __func__); } break; case CMD_CLR_SEL: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_CLR_SEL'\n"); bmc_clr_sel(request, response); break; case CMD_GET_SEL_TIME: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_SEL_TIME'\n"); bmc_sel_time_get(request, response); break; case CMD_SET_SEL_TIME: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_SEL_TIME'\n"); bmc_sel_time_set(request, response); break; #endif /* CFG_SEL_ENABLE */ /* Unknown command, respond with "invalid command" */ default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown cmd 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); bmc_unknown_command(request, response); break; } break; #ifndef CFG_MCMC /* NetFN = 0x0B (Storage) */ case NETFN_STORAGE_RS: switch (request->cmd) { case CMD_READ_FRU_DATA: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_response_handle : 'CMD_READ_FRU_DATA'\n"); bmc_read_fru_data_response(request); break; case CMD_WRITE_FRU_DATA: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_response_handle : 'CMD_WRITE_FRU_DATA'\n"); bmc_write_fru_data_response(request); break; #ifdef ADV_OEM_RTC_SYNC case CMD_GET_SEL_TIME: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_response_handle: 'CMD_GET_SEL_TIME'\n"); bmc_get_sel_time_response(request); break; #endif /* Unknown command, respond with "invalid command" */ default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown rsp 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); break; } break; #endif // END CFG_MCMC /* NetFN = 0x0C (Transport) */ case NETFN_TRANSPORT_RQ: switch (request->cmd) { #ifdef CFG_LAN case CMD_SET_LAN_CONFIG_PARAM: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_LAN_CONFIG_PARAM'\n"); bmc_set_lan_config(request, response); break; case CMD_GET_LAN_CONFIG_PARAM: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_LAN_CONFIG_PARAM'\n"); bmc_get_lan_config(request, response); break; #endif /* Unknown command, respond with "invalid command" */ default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown cmd 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); bmc_unknown_command(request, response); break; } break; /* NetFN = 0x2C (Group Extension -> PICMG) */ case NETFN_PICMG_RQ: /* check for PICMG identifier */ if ((request->data_len < 1) || (request->data[0] != PICMG_IDENTIFIER)) { debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown identifier in NetFN Group Extension\n", __func__); bmc_unknown_command(request, response); break; } /* PICMG identifier is valid, process command */ switch (request->cmd) { case CMD_GET_PICMG_PROPERTIES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_PICMG_PROPERTIES'\n"); bmc_get_picmg_prop(request, response); break; #if defined(CFG_ATCA) || defined(CFG_MCMC) case CMD_GET_ADDRESS_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_ADDRESS_INFO'\n"); bmc_get_address_info(request, response); break; #endif #ifdef CFG_CHECKPOINT case CMD_GET_SHELF_ADDRESS_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_response : 'CMD_GET_SHELF_ADDRESS_INFO'\n"); bmc_get_shelf_address(request, response); break; #endif #ifndef CFG_MCMC case CMD_FRU_CONTROL_CAPABILITIES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_FRU_CONTROL_CAPABILITIES'\n"); bmc_fru_control_cap(request, response); break; case CMD_FRU_CONTROL: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_FRU_CONTROL'\n"); bmc_fru_control(request, response); break; case CMD_GET_FRU_LED_PROPERTIES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'GET_FRU_LED_PROP'\n"); bmc_get_fru_led_properties(request, response); break; case CMD_GET_LED_COLOR_CAPABILITIES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'GET_LED_COLOR_CAP'\n"); bmc_get_led_color_capabilities(request, response); break; #endif case CMD_SET_FRU_LED_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'SET_FRU_LED'\n"); bmc_set_fru_led_state(request, response); break; case CMD_GET_FRU_LED_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'GET_FRU_LED'\n"); bmc_get_fru_led_state(request, response); break; #ifdef CFG_ATCA case CMD_SET_IPMB_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_IPMB_STATE'\n"); bmc_set_ipmb_state(request, response); break; case CMD_SET_FRU_ACTIVATION_POLICY: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_FRU_ACTIVATION_POLICY'\n"); bmc_set_fru_activation_policy(request, response); break; case CMD_GET_FRU_ACTIVATION_POLICY: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_FRU_ACTIVATION_POLICY'\n"); bmc_get_fru_activation_policy(request, response); break; case CMD_SET_FRU_ACTIVATION: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_FRU_ACTIVATION'\n"); bmc_set_fru_activation(request, response); break; #endif case CMD_GET_DEVICE_LOCATOR_RECORD_ID: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_DEVICE_LOCATOR_RECORD_ID'\n"); bmc_get_device_locator_record(request, response); break; #ifdef CFG_ATCA case CMD_SET_PORT_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'SET_PORT_STATE'\n"); bmc_set_port_state(request, response); break; case CMD_GET_PORT_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'GET_PORT_STATE'\n"); bmc_get_port_state(request, response); break; case CMD_COMPUTE_POWER_PROPERTIES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_COMPUTE_POWER_PROPERTIES'\n"); bmc_compute_power_properties(request, response); break; case CMD_SET_POWER_LEVEL: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'SET_POWER_LEVEL'\n"); bmc_set_power_level(request, response); break; case CMD_GET_POWER_LEVEL: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'GET_POWER_LEVEL'\n"); bmc_get_power_level(request, response); break; case CMD_GET_IPMB_LINK_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_IPMB_LINK_INFO'\n"); bmc_get_ipmb_link_info(request, response); break; #endif #ifdef CFG_NCP3110 case CMD_GET_FAN_SPEED_PROP: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_FAN_SPEED_PROP'\n"); bmc_get_fan_speed_prop(request, response); break; case CMD_SET_FAN_LEVEL: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_FAN_LEVEL'\n"); bmc_set_fan_level(request, response); break; case CMD_GET_FAN_LEVEL: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_FAN_LEVEL'\n"); bmc_get_fan_level(request, response); break; #endif #if defined(CFG_MMC) || defined(CFG_IRTM) case CMD_SET_AMC_PORT_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_AMC_PORT_STATE'\n"); bmc_set_amc_port_state(request, response); break; case CMD_GET_AMC_PORT_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_AMC_PORT_STATE'\n"); bmc_get_amc_port_state(request, response); break; case CMD_SET_CLOCK_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_SET_CLOCK_STATE'\n"); bmc_set_amc_clock_state(request, response); break; case CMD_GET_CLOCK_STATE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_CLOCK_STATE'\n"); bmc_get_amc_clock_state(request, response); break; #endif /* CFG_MMC || CFG_IRTM */ #ifdef CFG_EMMCPM case CMD_POWER_CHANNEL_CONTROL: debug_uart_printf(DBG_GRP_BMC, 3, "pm_respond: 'CMD_POWER_CHANNEL_CONTROL'\n"); pm_power_chan_control(request, response); break; case CMD_GET_POWER_CHANNEL_STATUS: debug_uart_printf(DBG_GRP_BMC, 3, "pm_respond: 'CMD_GET_POWER_CHANNEL_STATUS'\n"); pm_get_power_chan_status(request, response); break; case CMD_PM_RESET: debug_uart_printf(DBG_GRP_BMC, 3, "pm_respond: 'CMD_PM_RESET'\n"); pm_reset(request, response); break; case CMD_GET_PM_STATUS: debug_uart_printf(DBG_GRP_BMC, 3, "pm_respond: 'CMD_GET_PM_STATUS'\n"); pm_get_status(request, response); break; case CMD_PM_HEARTBEAT: debug_uart_printf(DBG_GRP_BMC, 3, "pm_respond: 'CMD_PM_HEARTBEAT'\n"); pm_heartbeat(request, response); break; #endif case CMD_GET_UPGRADE_CAPABILITIES: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_UPGRADE_CAPABILITIES'\n"); bmc_get_upgrade_cap(request, response); break; case CMD_GET_COMPONENT_PROP: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_COMPONENT_PROP'\n"); bmc_get_component_prop(request, response); break; case CMD_ABORT_FIRMWARE_UPGRADE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_ABORT_FIRMWARE_UPGRADE'\n"); bmc_abort_firmware_upgrade(request, response); break; case CMD_INITIATE_UPGRADE_ACTION: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_INITIATE_UPGRADE_ACTION'\n"); bmc_init_upgrade_action(request, response); break; case CMD_UPLOAD_FIRMWARE_BLOCK: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_UPLOAD_FIRMWARE_BLOCK'\n"); bmc_upload_firmware_block(request, response); break; case CMD_FINISH_FIRMWARE_UPLOAD: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_FINISH_FIRMWARE_UPLOAD'\n"); bmc_finish_firmware_upload(request, response); break; case CMD_GET_UPGRADE_STATUS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_GET_UPGRADE_STATUS'\n"); bmc_get_upgrade_status(request, response); break; case CMD_ACTIVATE_FIRMWARE: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_ACTIVATE_FIRMWARE'\n"); bmc_activate_firmware(request, response); break; case CMD_QUERY_SELFTEST_RESULTS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_QUERY_SELFTEST_RESULTS'\n"); bmc_query_selftest_results(request, response); break; case CMD_QUERY_ROLLBACK_STATUS: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_QUERY_ROLLBACK_STATUS'\n"); bmc_query_rollback_status(request, response); break; case CMD_INIT_MANUAL_ROLLBACK: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_INIT_MANUAL_ROLLBACK'\n"); bmc_init_manual_rollback(request, response); break; default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown cmd 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); bmc_unknown_command(request, response); break; } break; #ifndef CFG_MCMC /* NetFN = 0x2D (Group Extension -> PICMG) */ case NETFN_PICMG_RS: switch (request->cmd) { case CMD_GET_SHELF_ADDRESS_INFO: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_response_handle : 'CMD_GET_SHELF_ADDRESS_INFO'\n"); bmc_get_shelf_address_response(request); break; /* Unknown command, respond with "invalid command" */ default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown rsp 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); break; } break; #endif /* NetFN = 0x2E (OEM / Group) */ case NETFN_OEM_RQ: switch (request->cmd) { case ADV_OEM_GET_HW_REVISION: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_OEM_GET_HW_REVISION'\n"); bmc_oem_get_hw_revision(request, response); break; case ADV_OEM_WRITE_CONF: debug_uart_printf(DBG_GRP_BMC, 3, "bmc_respond: 'CMD_OEM_WRITE_CONFIGURATION'\n"); bmc_oem_write_config_setting(request, response); break; default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown cmd 0x%02x netFN 0x%02x\n", __func__, request->cmd, request->netFN); bmc_unknown_command(request, response); break; } break; /* Unknown netFN, respond with "invalid command" */ default: debug_uart_printf(DBG_GRP_BMC, 3, "ERR: %s: Unknown NetFn 0x%02x cmd %02x dest chan %02x\n", __func__, request->netFN, request->cmd, request->dest_channel); bmc_unknown_command(request, response); break; } return ret; }