diff frbl/reconst/command.c @ 321:24d7d7875ee9

frbl/reconst/command.c: first function reconstructed
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Mar 2020 06:38:36 +0000
parents
children a4b6b4e389b9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/frbl/reconst/command.c	Thu Mar 05 06:38:36 2020 +0000
@@ -0,0 +1,82 @@
+#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)
+{
+
+
+}