diff options
Diffstat (limited to 'pdl/include')
-rw-r--r-- | pdl/include/cmd_defs.h | 77 | ||||
-rw-r--r-- | pdl/include/config.h | 11 | ||||
-rw-r--r-- | pdl/include/packet.h | 63 | ||||
-rw-r--r-- | pdl/include/pdl_channel.h | 28 | ||||
-rw-r--r-- | pdl/include/pdl_command.h | 15 | ||||
-rw-r--r-- | pdl/include/pdl_debug.h | 28 | ||||
-rw-r--r-- | pdl/include/pdl_engine.h | 12 |
7 files changed, 234 insertions, 0 deletions
diff --git a/pdl/include/cmd_defs.h b/pdl/include/cmd_defs.h new file mode 100644 index 0000000000..1ca9adcabc --- /dev/null +++ b/pdl/include/cmd_defs.h @@ -0,0 +1,77 @@ +#ifndef _CMD_DEFS_H_ +#define _CMD_DEFS_H_ +#include "packet.h" + +enum pdl_cmd_type{ + MIN_CMD = 0, + CONNECT = MIN_CMD, + ERASE_FLASH, + ERASE_PARTITION, + ERASE_ALL, + START_DATA, + MID_DATA, + END_DATA, + EXEC_DATA, + READ_FLASH, + READ_PARTITION, + NORMAL_RESET, + READ_CHIPID, + SET_BAUDRATE, + FORMAT_FLASH, + READ_PARTITION_TABLE, + READ_IMAGE_ATTR, + GET_VERSION, + SET_FACTMODE, + SET_CALIBMODE, + SET_PDL_DBG, + CHECK_PARTITION_TABLE, + POWER_OFF, + IMAGE_LIST, + GET_SWCFG_REG, + SET_SWCFG_REG, + GET_HWCFG_REG, + SET_HWCFG_REG, + EXIT_AND_RELOAD, + GET_SECURITY, + HW_TEST, + GET_PDL_LOG, + DOWNLOAD_FINISH, + MAX_CMD +}; + +enum pdl_rsp { + ACK = 0, + //from PC command + PACKET_ERROR, + INVALID_CMD, + UNKNOWN_CMD, + INVALID_ADDR, + INVALID_BAUDRATE, + INVALID_PARTITION, + INVALID_SIZE, + WAIT_TIMEOUT, + //from phone + VERIFY_ERROR, + CHECKSUM_ERROR, + OPERATION_FAILED, + //phone internal + DEVICE_ERROR, //DDR,NAND init errors + NO_MEMORY, + DEVICE_INCOMPATIBLE, + HW_TEST_ERROR, + MD5_ERROR, + ACK_AGAIN_ERASE, + ACK_AGAIN_FLASH, + MAX_RSP +}; + +#define PDL_DBG_PDL (0x1<<0) +#define PDL_DBG_USB_EP0 (0x1<<1) +#define PDL_DBG_USB_SERIAL (0x1<<2) +#define PDL_DBG_RW_CHECK (0x1<<3) +#define PDL_DBG_FACTORY_PART (0x1<<4) +#define PDL_DBG_PDL_VERBOSE (0x1<<5) +#define PDL_EXTENDED_STATUS (0x1<<7) + +#endif + diff --git a/pdl/include/config.h b/pdl/include/config.h new file mode 100644 index 0000000000..b2d37705ab --- /dev/null +++ b/pdl/include/config.h @@ -0,0 +1,11 @@ +#ifndef __PDL_CONFIG_H__ +#define __PDL_CONFIG_H__ + +#ifdef CONFIG_SPL_BUILD +# define CONFIG_RDA_PDL1 +#else +# define CONFIG_RDA_PDL2 +#endif + +#endif // __PDL_CONFIG_H__ + diff --git a/pdl/include/packet.h b/pdl/include/packet.h new file mode 100644 index 0000000000..c261eba161 --- /dev/null +++ b/pdl/include/packet.h @@ -0,0 +1,63 @@ +#ifndef _PACKET_H_ +#define _PACKET_H_ +#include "config.h" + +/* host define, for receiving packet */ +#define HOST_PACKET_TAG 0xAE +#define HOST_PACKET_FLOWID 0xFF + +/* client define, for sending packet */ +#define PACKET_TAG 0xAE +#define FLOWID_DATA 0xBB +#define FLOWID_ACK 0xFF +#define FLOWID_ERROR 0xEE + +/* + * for yaffs image, the packet length must be aligned to the (page_size+oob) + */ +#if defined(CONFIG_RDA_PDL2) +# define PDL_MAX_DATA_SIZE 270336 //(256*(1024 + 32)) == (64 * 4224) +#elif defined(CONFIG_RDA_PDL1) +# define PDL_MAX_DATA_SIZE (4*1024) +#else +#error "no valid pdl config" +#endif + + +struct packet_header { + u8 tag; + u32 pkt_size; + u8 flowid; +}__attribute__((packed)); + +struct command_header { + u32 cmd_type; + u32 data_addr; + u32 data_size; +}; + +#define PDL_MAX_PKT_SIZE (PDL_MAX_DATA_SIZE + \ + sizeof(struct command_header) + sizeof(struct packet_header)) + +struct pdl_packet { + struct command_header cmd_header; + u8 *data; +}; + + +struct packet{ + struct packet_header pkt_header; + struct pdl_packet *pdl_pkt; + int state; +}; + +int pdl_get_cmd_packet(struct pdl_packet *pkt); +void pdl_put_cmd_packet(struct pdl_packet *pkt); +int pdl_get_connect_packet(struct pdl_packet *pkt, u32 timeout); + +void pdl_send_rsp(int rsp); +int pdl_send_pkt(const u8 *data, u32 size); +int pdl_get_packet_error(void); +int pdl_init_packet_channel(void); +#endif + diff --git a/pdl/include/pdl_channel.h b/pdl/include/pdl_channel.h new file mode 100644 index 0000000000..731878d729 --- /dev/null +++ b/pdl/include/pdl_channel.h @@ -0,0 +1,28 @@ +#ifndef _PDL_CHANNEL_H_ +#define _PDL_CHANNEL_H_ + +struct pdl_channel { + int (*read) (unsigned char *buf, unsigned int len); + int (*getchar) (void); + int (*tstc) (void); + int (*write) (const unsigned char *buf, unsigned int len); + void (*putchar) (const char ch); + void *priv; +}; + +/* get the current pdl data channel */ +struct pdl_channel *pdl_get_channel(void); +/* register the pdl data channel */ +void pdl_channel_register(struct pdl_channel *channel); + +/* get the current pdl debug channel */ +struct pdl_channel *pdl_get_debug_channel(void); +/* register the pdl debug channel */ +void pdl_debug_channel_register(struct pdl_channel *channel); + +/* register the usb serial channel 0 as the pdl data channel. + if defined, register the usb serial channel 1 as the pdl debug channel. */ +void pdl_usb_channel_register(void); + +#endif + diff --git a/pdl/include/pdl_command.h b/pdl/include/pdl_command.h new file mode 100644 index 0000000000..08e8b66bed --- /dev/null +++ b/pdl/include/pdl_command.h @@ -0,0 +1,15 @@ +#ifndef _PDL_COMMAND_H_ +#define _PDL_COMMAND_H_ +#include "config.h" +#include "packet.h" + + +#if defined(CONFIG_RDA_PDL1) +#include "../pdl-1/pdl1_command.h" +#elif defined(CONFIG_RDA_PDL2) +#include "../pdl-2/pdl2_command.h" +#else +#error "no valid pdl" +#endif + +#endif diff --git a/pdl/include/pdl_debug.h b/pdl/include/pdl_debug.h new file mode 100644 index 0000000000..d908e7a28f --- /dev/null +++ b/pdl/include/pdl_debug.h @@ -0,0 +1,28 @@ +#ifndef _PDL_DEBUG_H_ +#define _PDL_DEBUG_H_ + +#include <serial.h> + +#define PDL_LOG_MAX_SIZE (512*1024) + +extern char *pdl_log_buff; +void pdl_init_serial(void); +void pdl_release_serial(void); + +#define pdl_error printf +#define pdl_info printf + +extern int pdl_dbg_pdl; +#define pdl_dbg(str...) \ + do { \ + if (pdl_dbg_pdl) \ + printf(str); \ + } while(0) + +extern int pdl_vdbg_pdl; +#define pdl_vdbg(str...) \ + do { \ + if (pdl_vdbg_pdl) \ + printf(str); \ + } while(0) +#endif diff --git a/pdl/include/pdl_engine.h b/pdl/include/pdl_engine.h new file mode 100644 index 0000000000..84f07797f6 --- /dev/null +++ b/pdl/include/pdl_engine.h @@ -0,0 +1,12 @@ +#ifndef _PDL_ENGINE_H_ +#define _PDL_ENGINE_H_ + +typedef int (*pdl_cmd_handler)(struct pdl_packet *pkt, void *arg); +struct pdl_cmd { + pdl_cmd_handler handler; +}; + +int pdl_cmd_register(int cmd_type, pdl_cmd_handler handler); +int pdl_handler(void *arg); +int pdl_handle_connect(u32 timeout); +#endif |