From 740a50687f67f3684e4b5698f8f30e3adebb8f6e Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 17 Jul 2021 19:35:09 +0100 Subject: jztool: add support for Shanling Q1 and Eros Q Change-Id: I8e93162d1a9d82e9d132219f2803b1856d24ae6c --- rbutil/jztool/src/device_info.c | 72 +++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 17 deletions(-) (limited to 'rbutil/jztool/src/device_info.c') diff --git a/rbutil/jztool/src/device_info.c b/rbutil/jztool/src/device_info.c index 5ce3899262..cc431959ca 100644 --- a/rbutil/jztool/src/device_info.c +++ b/rbutil/jztool/src/device_info.c @@ -22,39 +22,58 @@ #include "jztool.h" #include -static const jz_device_info infotable[] = { - { +static const jz_device_info infotable[JZ_NUM_DEVICES] = { + [JZ_DEVICE_FIIOM3K] = { .name = "fiiom3k", + .file_ext = "m3k", .description = "FiiO M3K", .device_type = JZ_DEVICE_FIIOM3K, .cpu_type = JZ_CPU_X1000, + .vendor_id = 0x2972, + .product_id = 0x0003, + }, + [JZ_DEVICE_SHANLINGQ1] = { + .name = "shanlingq1", + .file_ext = "q1", + .description = "Shanling Q1", + .device_type = JZ_DEVICE_SHANLINGQ1, + .cpu_type = JZ_CPU_X1000, + .vendor_id = 0x0525, + .product_id = 0xa4a5, + }, + [JZ_DEVICE_EROSQ] = { + .name = "erosq", + .file_ext = "erosq", + .description = "AIGO Eros Q", + .device_type = JZ_DEVICE_EROSQ, + .cpu_type = JZ_CPU_X1000, + .vendor_id = 0xc502, + .product_id = 0x0023, + }, +}; + +static const jz_cpu_info cputable[JZ_NUM_CPUS] = { + [JZ_CPU_X1000] = { + .info_str = "X1000_v1", .vendor_id = 0xa108, .product_id = 0x1000, + .stage1_load_addr = 0xf4001000, + .stage1_exec_addr = 0xf4001800, + .stage2_load_addr = 0x80004000, + .stage2_exec_addr = 0x80004000, }, }; -static const int infotable_size = sizeof(infotable)/sizeof(struct jz_device_info); - -/** \brief Get the number of entries in the device info list */ -int jz_get_num_device_info(void) -{ - return infotable_size; -} - /** \brief Lookup info for a device by type, returns NULL if not found. */ const jz_device_info* jz_get_device_info(jz_device_type type) { - for(int i = 0; i < infotable_size; ++i) - if(infotable[i].device_type == type) - return &infotable[i]; - - return NULL; + return jz_get_device_info_indexed(type); } /** \brief Lookup info for a device by name, returns NULL if not found. */ const jz_device_info* jz_get_device_info_named(const char* name) { - for(int i = 0; i < infotable_size; ++i) + for(int i = 0; i < JZ_NUM_DEVICES; ++i) if(!strcmp(infotable[i].name, name)) return &infotable[i]; @@ -64,8 +83,27 @@ const jz_device_info* jz_get_device_info_named(const char* name) /** \brief Get a device info entry by index, returns NULL if out of range. */ const jz_device_info* jz_get_device_info_indexed(int index) { - if(index < infotable_size) + if(index < JZ_NUM_DEVICES) return &infotable[index]; else return NULL; } + +/** \brief Lookup info for a CPU, returns NULL if not found. */ +const jz_cpu_info* jz_get_cpu_info(jz_cpu_type type) +{ + if(type < JZ_NUM_CPUS) + return &cputable[type]; + else + return NULL; +} + +/** \brief Lookup info for a CPU by info string, returns NULL if not found. */ +const jz_cpu_info* jz_get_cpu_info_named(const char* info_str) +{ + for(int i = 0; i < JZ_NUM_CPUS; ++i) + if(!strcmp(cputable[i].info_str, info_str)) + return &cputable[i]; + + return NULL; +} -- cgit v1.2.3