FreeCalypso > hg > freecalypso-reveng
view frbl/reconst/command.c @ 354:f89a20e7adc7
fluid-mnf: helper files sought in proper install location
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 13 Mar 2020 19:56:56 +0000 |
parents | b5b8df53aa51 |
children |
line wrap: on
line source
#include "main/sys_types.h" #include "command.h" long com_analyze_request(SYS_UWORD8 *request_received, t_com_request *request) { SYS_WORD32 sp8; long sp12 = COM_SUCCESS; SYS_UWORD32 sp16, sp20; SYS_UWORD8 sp24; SYS_UWORD16 *sp28; SYS_UWORD16 sp32, sp34, sp36, sp38, sp40, sp42, sp44, sp46; sp20 = *request_received++; COM_COMMAND_WORD(request) = *request_received++; sp16 = 1; switch (COM_COMMAND_WORD(request)) { case COM_READ_PARAMETERS: /* 0x26 */ sp16 += 2; sp34 = *request_received++; sp32 = *request_received++; COM_READ_PARAMS_OFFSET(request) = (sp34 << 8) + sp32; sp16 += 1; sp24 = *request_received++; COM_NUMBER_OF_PARAMS_READ(request) = sp24; if (sp24 > COM_MAX_NUMBER_OF_16BITS_DATA) sp12 = COM_PARAMETER_ERROR; break; case COM_WRITE_PARAMETERS: /* 0x7a */ sp16 += 2; sp34 = *request_received++; sp32 = *request_received++; COM_WRITTEN_PARAMS_OFFSET(request) = (sp34 << 8) + sp32; sp16 += 1; sp24 = *request_received++; COM_NUMBER_OF_PARAMS_WRITTEN(request) = sp24; if (sp24 > COM_MAX_NUMBER_OF_16BITS_DATA) { sp12 = COM_PARAMETER_ERROR; break; } sp28 = COM_WRITTEN_PARAMS_LIST_ADDRESS(request); for (sp8 = 0; sp8 < sp24; sp8++) { sp38 = *request_received++; sp36 = *request_received++; *sp28++ = (sp38 << 8) + sp36; sp16 += 2; } break; case COM_SEND_RUN_ADDRESS: /* 0x11e */ sp16 += 2; sp40 = *request_received++; sp42 = *request_received++; COM_ADDRESS_MSB(request) = (sp40 << 8) + sp42; sp16 += 2; sp44 = *request_received++; sp46 = *request_received++; COM_ADDRESS_LSB(request) = (sp44 << 8) + sp46; break; case COM_GET_MONITOR_ID: case COM_GET_FLASH_ID: case COM_GET_CHIP_ID: case COM_GET_BOARD_ID: case COM_ERASE_FLASH: case COM_WRITE_DATA: case COM_START_APPLICATION: case COM_LOAD_APPLICATION: break; default: sp12 = COM_COMMAND_UNKNOWN; } if (sp20 != sp16) sp12 = COM_PARAMETER_ERROR; return sp12; } long com_build_confirmation(t_com_confirmation *confirmation, SYS_UWORD8 *confirmation_to_send) { SYS_WORD32 sp8; long sp12 = COM_SUCCESS; SYS_UWORD8 sp16; SYS_UWORD8 *sp20; SYS_UWORD8 sp24; SYS_UWORD16 *sp28; SYS_UWORD16 sp32; sp20 = confirmation_to_send++; *confirmation_to_send++ = COM_COMMAND_WORD(confirmation); sp16 = 1; *confirmation_to_send++ = COM_RESULT(confirmation); sp16++; switch (COM_COMMAND_WORD(confirmation)) { case COM_GET_MONITOR_ID: /* 0x202 */ if (COM_RESULT(confirmation)) break; *confirmation_to_send++ = COM_MONITOR_ID(confirmation); *confirmation_to_send++ = COM_MONITOR_VERSION_FIRST_NBR(confirmation); *confirmation_to_send++ = COM_MONITOR_VERSION_SECOND_NBR(confirmation); sp16 += 3; break; case COM_GET_FLASH_ID: /* 0x23c */ if (COM_RESULT(confirmation)) break; *confirmation_to_send++ = COM_FLASH_ID(confirmation); sp16++; break; case COM_GET_CHIP_ID: /* 0x25a */ if (COM_RESULT(confirmation)) break; *confirmation_to_send++ = COM_CHIP_ID(confirmation); sp16++; break; case COM_GET_BOARD_ID: /* 0x266 */ if (COM_RESULT(confirmation)) break; *confirmation_to_send++ = COM_BOARD_ID(confirmation); sp16++; break; case COM_ERASE_FLASH: break; case COM_WRITE_DATA: /* 0x272 */ if (COM_RESULT(confirmation)) break; sp32 = COM_FILE_CHECKSUM(confirmation); *confirmation_to_send++ = (sp32 & 0xFF00) >> 8; *confirmation_to_send++ = sp32 & 0xFF; sp32 = COM_FLASH_CHECKSUM(confirmation); *confirmation_to_send++ = (sp32 & 0xFF00) >> 8; *confirmation_to_send++ = sp32 & 0xFF; sp16 += 4; break; case COM_START_APPLICATION: /* 0x2dc */ if (COM_RESULT(confirmation)) break; *confirmation_to_send++ = COM_STARTING_STATE(confirmation); sp16++; break; case COM_READ_PARAMETERS: /* 0x2e8 */ if (COM_RESULT(confirmation)) break; sp16++; sp24 = COM_NUMBER_OF_PARAMS_READ(confirmation); *confirmation_to_send++ = sp24; if (sp24 > COM_MAX_NUMBER_OF_16BITS_DATA) { sp12 = COM_PARAMETER_ERROR; break; } sp28 = COM_READ_PARAMS_LIST_ADDRESS(confirmation); for (sp8 = 0; sp8 < sp24; sp8++) { *confirmation_to_send++ = (*sp28 & 0xFF00) >> 8; *confirmation_to_send++ = *sp28++ & 0xFF; sp16 += 2; } break; case COM_WRITE_PARAMETERS: break; case COM_LOAD_APPLICATION: /* 0x374 */ if (COM_RESULT(confirmation)) break; sp32 = COM_FILE_RAM_CHECKSUM(confirmation); *confirmation_to_send++ = (sp32 & 0xFF00) >> 8; *confirmation_to_send++ = sp32 & 0xFF; sp32 = COM_RAM_CHECKSUM(confirmation); *confirmation_to_send++ = (sp32 & 0xFF00) >> 8; *confirmation_to_send++ = sp32 & 0xFF; sp16 += 4; break; case COM_SEND_RUN_ADDRESS: break; default: sp12 = COM_COMMAND_UNKNOWN; } *sp20 = sp16; return sp12; }