FreeCalypso > hg > freecalypso-reveng
changeset 312:6cba849e3332
frbl/reconst/inc: import from TCS211 surviving source
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 04 Mar 2020 23:06:07 +0000 |
parents | 9cecc930d78f |
children | 9b5079989681 |
files | frbl/reconst/inc/cmdboot.h frbl/reconst/inc/command.h frbl/reconst/inc/convert.h frbl/reconst/inc/optboot.h frbl/reconst/inc/protocol.h frbl/reconst/inc/reference.h frbl/reconst/inc/serial.h frbl/reconst/inc/target.h |
diffstat | 8 files changed, 697 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frbl/reconst/inc/cmdboot.h Wed Mar 04 23:06:07 2020 +0000 @@ -0,0 +1,21 @@ +/******************************************************************************* + * + * CMDBOOT.H + * + * (C) Texas Instruments 1999 + * + ******************************************************************************/ + +#ifndef __CMDBOOT_H__ +#define __CMDBOOT_H__ + +#include "main/sys_types.h" + + +extern long +cmd_load_application(SYS_UWORD16 *file_checksum, SYS_UWORD16 *RAM_checksum, SYS_UWORD8 device_id); + +extern long +cmd_check_application_in_flash (void); + +#endif /* __CMDBOOT_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frbl/reconst/inc/command.h Wed Mar 04 23:06:07 2020 +0000 @@ -0,0 +1,346 @@ +/******************************************************************************* + * + * COMMAND.H + * + * This module contains commands structures and functions to analyze a command + * received and to build a command to send (request and confirmation). + * + * (C) Texas Instruments 1998 + * + ******************************************************************************/ + +#ifndef __COMMAND_H__ +#define __COMMAND_H__ + +#include "main/sys_types.h" + +#define COM_SERIAL_COMMAND_LENGTH (256) /* In bytes. */ +#define COM_MAX_NUMBER_OF_16BITS_DATA ( 64) + +/* + * Constants used in the confirmation of the COM_GET_MONITOR_ID command. + */ + +enum { + COM_MONITOR_STAND_ALONE, + COM_MONITOR_LIBRARY, + COM_BOOTLOADER +}; + +/* + * Constants used in the confirmation of the COM_GET_CHIP_ID command. + */ + +enum { + COM_POLE112LA00, + COM_GEMINI_EFH, + COM_CHIP_NOT_SUPPORTED +}; + +/* + * Constants used in the confirmation of the COM_GET_BOARD_ID command. + */ + +enum { + COM_A_SAMPLE_1_0, + COM_A_SAMPLE_1_5, + COM_EVA4, + COM_GAIA_BOARD21 +}; + +/* + * Constants used in the confirmation of the COM_START_APPLICATION command. + */ + +enum { + COM_APPLICATION_IS_RUNNING, + COM_MONITOR_IS_RUNNING +}; + +/* + * List of commands. + */ + +enum { + COM_GET_MONITOR_ID, + COM_GET_FLASH_ID, + COM_GET_CHIP_ID, + COM_GET_BOARD_ID, + COM_ERASE_FLASH, + COM_WRITE_DATA, + COM_START_APPLICATION, + COM_READ_PARAMETERS, + COM_WRITE_PARAMETERS, + COM_LOAD_APPLICATION, + COM_SEND_RUN_ADDRESS +}; + +/* + * Functions results. + */ + +enum { + COM_SUCCESS, + COM_NO_EXECUTION, + COM_ERASE_ERROR, + COM_WRITE_ERROR, + COM_PARAMETER_ERROR, + COM_ADDRESS_ERROR, + COM_FILE_ERROR, + COM_NOT_SUPPORTED, + COM_COMMAND_UNKNOWN +}; + + +/* + * Constants used in the bootloader. + */ + +enum { + CMD_RAM_SUCCESS, + CMD_RAM_NO_EXECUTION, + CMD_RAM_WRITE_ERROR, + CMD_RAM_ADDRESS_ERROR, + CMD_RAM_FILE_ERROR +}; + +/* + * These macros allow to access to fields of each structure. + */ + +#define COM_COMMAND_WORD(COMMAND) ((COMMAND)->command_word) + +#define COM_RESULT(COMMAND) ((COMMAND)->result) + +#define COM_MONITOR_ID(COMMAND) ((COMMAND)->param.monitor_id.identifier) + +#define COM_MONITOR_VERSION_FIRST_NBR(COMMAND) ((COMMAND)->param.monitor_id.version_first_nbr) + +#define COM_MONITOR_VERSION_SECOND_NBR(COMMAND) ((COMMAND)->param.monitor_id.version_second_nbr) + +#define COM_FLASH_ID(COMMAND) ((COMMAND)->param.flash_id.identifier) + +#define COM_BOARD_ID(COMMAND) ((COMMAND)->param.board_id.identifier) + +#define COM_FILE_CHECKSUM(COMMAND) ((COMMAND)->param.checksum.file_checksum) + +#define COM_FLASH_CHECKSUM(COMMAND) ((COMMAND)->param.checksum.flash_checksum) + +#define COM_CHIP_ID(COMMAND) ((COMMAND)->param.chip_id.identifier) + +#define COM_STARTING_STATE(COMMAND) ((COMMAND)->param.starting.state) + +#define COM_READ_PARAMS_OFFSET(COMMAND) \ + ((COMMAND)->param.params_read.param_offset) + +#define COM_NUMBER_OF_PARAMS_READ(COMMAND) \ + ((COMMAND)->param.params_read.number_of_params) + +#define COM_READ_PARAMS_LIST_ADDRESS(COMMAND) \ + (&((COMMAND)->param.params_read.param[0])) + +#define COM_WRITTEN_PARAMS_OFFSET(COMMAND) \ + ((COMMAND)->param.params_written.param_offset) + +#define COM_NUMBER_OF_PARAMS_WRITTEN(COMMAND) \ + ((COMMAND)->param.params_written.number_of_params) + +#define COM_WRITTEN_PARAMS_LIST_ADDRESS(COMMAND) \ + (&((COMMAND)->param.params_written.param[0])) + +#define COM_FILE_RAM_CHECKSUM(COMMAND) ((COMMAND)->param.checksum_RAM.file_checksum) + +#define COM_RAM_CHECKSUM(COMMAND) ((COMMAND)->param.checksum_RAM.RAM_checksum) + +#define COM_ADDRESS_MSB(COMMAND) \ + ((COMMAND)->param.address.address_msb) + +#define COM_ADDRESS_LSB(COMMAND) \ + ((COMMAND)->param.address.address_lsb) + + + +/* + * Parameters for each command. + * Get software id : no parameter. + * Get flash id : no parameter. + * Get chip id : no parameter. + * Get board id : no parameter. + * Erase flash : no parameter. + * Write data : no parameter. + * Start application : no parameter. + */ + +/* + * Read parameters: + * - parameter offset (even), + * - number of parameters to read + */ + +typedef struct s_com_read_params_req { + SYS_UWORD16 param_offset; + SYS_UWORD8 number_of_params; +} t_com_read_params_req; + +/* + * Write parameters: + * - parameter offset (even), + * - number of parameters (16 bits) to write, + * - list of parameters to write. + */ + +typedef struct s_com_write_params_req { + SYS_UWORD16 param_offset; + SYS_UWORD8 number_of_params; + SYS_UWORD16 param[COM_MAX_NUMBER_OF_16BITS_DATA]; +} t_com_write_params_req; + + +/* + * Start application in RAM + * - file checksum, + * - flash checksum + */ + +typedef struct s_com_send_run_address_req { + SYS_UWORD16 address_msb; + SYS_UWORD16 address_lsb; +} t_com_send_run_address_req; + + +/* + * General request structure. + */ + +typedef struct s_com_request { + SYS_UWORD8 command_word; + union u_req_param { + t_com_read_params_req params_read; + t_com_write_params_req params_written; + t_com_send_run_address_req address; + } param; +} t_com_request; + +/* + * Parameters for each confirmation. + * Erase flash : no parameter. + * Write parameters : no parameter. + */ + +/* + * Get monitor id: + * - identifier, + * - version. + */ + +typedef struct s_com_get_monitor_id_cnf { + SYS_UWORD8 identifier; + SYS_UWORD8 version_first_nbr; + SYS_UWORD8 version_second_nbr; +} t_com_get_monitor_id_cnf; + +/* + * Get flash id: + * - identifier. + */ + +typedef struct s_com_get_flash_id_cnf { + SYS_UWORD8 identifier; +} t_com_get_flash_id_cnf; + +/* + * Get chip id: + * - identifier. + */ + +typedef struct s_com_get_chip_id_cnf { + SYS_UWORD8 identifier; +} t_com_get_chip_id_cnf; + +/* + * Get board id: + * - identifier. + */ + +typedef struct s_com_get_board_id_cnf { + SYS_UWORD8 identifier; +} t_com_get_board_id_cnf; + +/* + * Write data: + * - file checksum, + * - flash checksum + */ + +typedef struct s_com_write_data_cnf { + SYS_UWORD16 file_checksum; + SYS_UWORD16 flash_checksum; +} t_com_write_data_cnf; + +/* + * Start application: + * - state (application is running or not) + */ + +typedef struct s_com_start_application_cnf { + SYS_UWORD8 state; +} t_com_start_application_cnf; + +/* + * Read parameters: + * - number of words (16 bits) read, + * - list of words read. + */ + +typedef struct s_com_read_params_cnf { + SYS_UWORD8 number_of_params; + SYS_UWORD16 param[COM_MAX_NUMBER_OF_16BITS_DATA]; +} t_com_read_params_cnf; + + +/* + * Load application + * - file checksum, + * - flash checksum + */ + +typedef struct s_com_load_appli_cnf { + SYS_UWORD16 file_checksum; + SYS_UWORD16 RAM_checksum; +} t_com_load_appli_cnf; + + + + +/* + * General confirmation structure. + */ + +typedef struct s_com_confirmation { + SYS_UWORD8 command_word; + SYS_UWORD8 result; + union u_cnf_param { + t_com_get_monitor_id_cnf monitor_id; + t_com_get_flash_id_cnf flash_id; + t_com_get_chip_id_cnf chip_id; + t_com_get_board_id_cnf board_id; + t_com_write_data_cnf checksum; + t_com_start_application_cnf starting; + t_com_read_params_cnf params_read; + t_com_load_appli_cnf checksum_RAM; + } param; +} t_com_confirmation; + +extern long com_analyze_request (SYS_UWORD8 *request_received, + t_com_request *request); + +extern long com_analyze_confirmation (SYS_UWORD8 *confirmation_received, + t_com_confirmation *confirmation); + +extern long com_build_request (t_com_request *request, + SYS_UWORD8 *request_to_send); + +extern long com_build_confirmation (t_com_confirmation *confirmation, + SYS_UWORD8 *confirmation_to_send); + +#endif /* __COMMAND_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frbl/reconst/inc/convert.h Wed Mar 04 23:06:07 2020 +0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * + * CONVERT.H + * + * This module contains functions to convert a command into a string to send on + * the serial link and to get a command from a string received on the serial + * link. + * + * (C) Texas Instruments 1998 + * + ******************************************************************************/ + +#ifndef __CONVERT_H__ +#define __CONVERT_H__ + +#include "main/sys_types.h" + +extern long con_get_command_from_string (SYS_UWORD8 byte_to_analyze, SYS_UWORD8 *command); + +extern void con_build_string_from_command (SYS_UWORD8 *command, + SYS_UWORD8 *string, + SYS_UWORD16 *string_length); + +extern void con_initialize_conversion (void); + +#endif /* __CONVERT_H__ */ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frbl/reconst/inc/optboot.h Wed Mar 04 23:06:07 2020 +0000 @@ -0,0 +1,30 @@ +/******************************************************************************* + * + * OPTBOOT.H + * + * This module contains functions which build a confirmation for each option: + * - get the chip id, + * - get the monitor id, + * - get the board_id. + * + * (C) Texas Instruments 1999 + * + ******************************************************************************/ + +#ifndef __OPTBOOT_H__ +#define __OPTBOOT_H__ + +#include "command.h" + + +extern void opt_get_monitor_id (t_com_request *request, + t_com_confirmation *confirmation); + +extern void +opt_load_application (t_com_request *request, t_com_confirmation *confirmation, SYS_UWORD8 device_id); + +extern unsigned long +opt_get_running_address (t_com_request *request, t_com_confirmation *confirmation); + + +#endif /* __OPTBOOT_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frbl/reconst/inc/protocol.h Wed Mar 04 23:06:07 2020 +0000 @@ -0,0 +1,60 @@ +/****************************************************************************** + * FLUID (Flash Loader Utility Independent of Device) + * + * (C) Delta Technologies 2001. + * Cleanup, modifications and extensions by Mads Meisner-Jensen, mmj@ti.com. + * + * Target/PC protocol definition + * + * $Id: protocol.h 1.9 Wed, 31 Oct 2001 11:47:00 +0100 mmj $ + * + ******************************************************************************/ + + +enum ProtocolChars { + PROTO_HELLO = 'H', + PROTO_BAUDRATE = 'B', + PROTO_HARDWARE = 'H', + PROTO_QUERY = 'Q', + PROTO_QUERY_CHIP = 'C', + PROTO_READY = 'R', + PROTO_ISEMPTY = 'I', + PROTO_DOWNLOAD = 'L', + PROTO_DETECT = 'D', + PROTO_ERASE = 'E', + PROTO_COMPRESS = 'Z', + PROTO_PROGRAM = 'P', + PROTO_CKSUM = 'C', + PROTO_READ = 'R', + PROTO_RESET = '0', + PROTO_ERROR_CKSUM = 'X', + PROTO_ERROR_MEMORY = 'M', + PROTO_ERROR_FLASH_TIMEOUT = 'T', + PROTO_ERROR_FLASH_COMMAND = 'C', + PROTO_ERROR_FLASH_VPP = 'P', + PROTO_ERROR_FLASH_LOCKED = 'L', + PROTO_ERROR_VERIFY = 'V', + PROTO_CHECKSUM = 'C', + PROTO_VERSION = 'V', + PROTO_ERROR = '?', + + PROTO_TRACE = '$' +}; + + + +// Not really part of the protocol but as this header file is included by +// both PC side and target side source code, this is an easy place to put +// these difinitions. +enum ChipIdCodes { + // Ulysses and Hercules + CHIP_ID_ULYSSES_0 = 0xB2B5, + CHIP_ID_ULYSSES_A = 0xB335, + CHIP_ID_HERCULES_A = 0xB334, // Correct revision designation? + CHIP_ID_HERCULES_B = 0xB32C, // Correct revision designation? + + // Samson and Calypso + CHIP_ID_CALYPSO_A = 0xB2AC, + CHIP_ID_CALYPSO_B = 0xB396 +}; +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frbl/reconst/inc/reference.h Wed Mar 04 23:06:07 2020 +0000 @@ -0,0 +1,20 @@ +/******************************************************************************* + * + * REFERENCE.H + * + * This module contains a dummy function which must be called to link the + * modules of several libraries. A local function calls one function per module + * to be sure that all modules of each library are linked. This function is + * never called. + * + * (C) Texas Instruments 1999 + * + ******************************************************************************/ + +#ifndef __REFERENCE_H__ +#define __REFERENCE_H__ + +extern void ref_reference_all_functions (void); + +#endif /* __REFERENCE_H__ */ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frbl/reconst/inc/serial.h Wed Mar 04 23:06:07 2020 +0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * + * SERIAL.H + * + * This module contains functions to send or receive commands on the USART 8251. + * Only polled mode is used. + * + * (C) Texas Instruments 1998 + * + ******************************************************************************/ + +#ifndef __SERIAL_H__ +#define __SERIAL_H__ + +#include "main/sys_types.h" + +/* + * ser_receive_command and ser_receive_char have 2 modes: + * SER_INFINITE : Waits until a command is received. + * SER_IMMEDIATE: Returns imediately even if no character is received. + */ + +enum { + SER_INFINITE, + SER_IMMEDIATE +}; + +/* + * Return values of ser_receive_data_for_flash. + */ + +enum { + SER_DATA_READY, + SER_DATA_ERROR, + SER_END_OF_FILE +}; + +extern void ser_wait_no_activity (SYS_UWORD8 device_id); +extern long ser_send_command (SYS_UWORD8 *command, SYS_UWORD8 device_id); +extern SYS_UWORD8 ser_receive_command (SYS_UWORD8 *command, int mode); +extern long ser_receive_data_for_flash (SYS_UWORD32 *address, SYS_UWORD16 *data, SYS_UWORD8 device_id); +extern void ser_initialize_flash_data_detection (void); +extern void ser_initialize_serial_link (void); +extern void ser_wait_last_character_sent (SYS_UWORD8 device_id); + +#endif /* __SERIAL_H__ */ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frbl/reconst/inc/target.h Wed Mar 04 23:06:07 2020 +0000 @@ -0,0 +1,148 @@ +/****************************************************************************** + * FLUID (Flash Loader Utility Independent of Device) + * + * (C) Delta Technologies 2001. + * Cleanup, modifications and extensions by Mads Meisner-Jensen, mmj@ti.com. + * + * Target common definitions + * + * $Id: target.h,v 1.3 2003/07/10 17:50:21 rlendenmann Exp $ + * + ******************************************************************************/ +#ifndef __TARGET_H__ +#define __TARGET_H__ +#include "protocol.h" + + +/****************************************************************************** + * Typedefs and Prototypes + ******************************************************************************/ + +#ifndef RIVIERA_INCLUDED +typedef unsigned char UBYTE; +typedef unsigned short UINT16; +typedef unsigned long UINT32; +typedef signed char INT8; +typedef signed short INT16; +typedef signed long INT32; +#endif + +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef unsigned long uint32; +typedef signed char int8; +typedef signed short int16; +typedef signed long int32; + +typedef union { + UINT32 i; // integer value + UBYTE b[4]; // byte array +} union32_t; + +typedef union { + UINT16 i; // integer value + UBYTE b[2]; // byte array +} union16_t; + +typedef struct { + char (*init)(uint32 addr); + char (*erase)(uint32 *addr, int size); + char (*program)(uint32 addr, uint16 *buf, int size); + uint8 (*getchar)(void); + void (*putchar)(uint8 ch); + void (*debug_putstr)(uint32 uart, char *string); + void (*debug_putnum)(uint32 uart, unsigned int number); + uint32 uart_base; +} method_table_t; + +// Prototypes for functions in debug.c +void debug_putstr(uint32 uart, char *string); +void debug_putnum(uint32 uart, unsigned int number); + + +/****************************************************************************** + * Macros + ******************************************************************************/ + +#define REGISTER_8_READ(addr) (*((volatile uint8 *) (addr))) +#define REGISTER_8_WRITE(addr, data) (*((volatile uint8 *) (addr)) = data) +#define REGISTER_16_READ(addr) (*((volatile uint16 *) (addr))) +#define REGISTER_16_WRITE(addr, data) (*((volatile uint16 *) (addr)) = data) + +#define BIT_SET(reg, bit) (*((volatile UINT16 *) (reg)) |= (1 << (bit))) +#define BIT_CLR(reg, bit) (*((volatile UINT16 *) (reg)) &= ~(1 << (bit))) + +#define FLASH_READ(addr) (*(volatile uint16 *) (addr)) +#define FLASH_WRITE(addr, data) (*(volatile uint16 *) (addr)) = data + +#define PUTCHAR_FUNCTION_CODE(uart) \ + while (!(REGISTER_8_READ(uart + UART_LSR) & STAT_TXRDY)) ; \ + REGISTER_8_WRITE(uart + UART_THR, ch); + +#define GETCHAR_FUNCTION_CODE(uart) \ + while (!(REGISTER_8_READ(uart + UART_LSR) & STAT_RXRDY)) ; \ + return (uint8) REGISTER_8_READ(uart + UART_RHR); + + +/****************************************************************************** + * Debug Macros + ******************************************************************************/ + +#define DEBUG_PUTSTR(uart, text) ((method_table_t *)(my_addr))->debug_putstr(uart, text); +#define DEBUG_PUTNUM(uart, num) ((method_table_t *)(my_addr))->debug_putnum(uart, num); + + +/****************************************************************************** + * Hardware Definitions + ******************************************************************************/ + +#define UART_BASE_MODEM (0xFFFF5800) +#define UART_BASE_IRDA (0xFFFF5000) + +// ROM/Flash Config register +#define WS_REG_ROM 0x400000 + +// UART register definitions. +#define UART_RHR (0x00) /* Receive Holding Register */ +#define UART_THR (0x00) /* Transmit Holding Register */ +#define UART_FCR (0x02) /* FIFO Control Register */ +#define UART_LCR (0x03) /* Line Control Register */ +#define UART_LSR (0x05) /* Line Status Register */ +#define UART_MDR1 (0x08) /* Mode Definition Register 1 */ +#define UART_EFR (0x02) /* Enhanced Feature Register */ +#define UART_DLL (0x00) /* Divisor Latches */ +#define UART_DLH (0x01) /* Divisor Latches */ +#define UART_UIR (0xFFFF6000) /* UART Interface Register */ + +// UART status bit definitions. +#define STAT_RXRDY (0x01) +#define STAT_TXRDY (0x20) +#define STAT_TX_E (0x40) + +// UART_UIR bit definitions. +#define UART_ACCESS (0) +#define UART_MASK_IT (1) + +// UART_EFR bit definitions. +#define ENHANCED_EN (4) + +// UART command bit definitions. +#define CMD_UART_RESET (0x07) +#define CMD_EFR_EN (0xBF) +#define CMD_FCR_MCR_EN (0x80) +#define CMD_FIFO_EN (0x07) +#define CMD_UART_MODE (0x00) +#define CMD_CHAR8_STOP1_NOPAR (0x03) + +// UART ??? +#define BAUD_38400 (0x15) +#define BAUD_115200 (0x07) +#define BAUD_406250 (0x02) +#define BAUD_812500 (0x01) + + +// Enable/Disable ROM/Flash write strobe +#define ROM_WRITE_ENABLE() *((volatile uint16*) WS_REG_ROM) |= 0x80; +#define ROM_WRITE_DISABLE() *((volatile uint16*) WS_REG_ROM) &= ~0x80; + +#endif /* __TARGET_H__ */