diff options
Diffstat (limited to 'rbutil/jztool/src/device_info.c')
-rw-r--r-- | rbutil/jztool/src/device_info.c | 72 |
1 files changed, 55 insertions, 17 deletions
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 @@ | |||
22 | #include "jztool.h" | 22 | #include "jztool.h" |
23 | #include <string.h> | 23 | #include <string.h> |
24 | 24 | ||
25 | static const jz_device_info infotable[] = { | 25 | static const jz_device_info infotable[JZ_NUM_DEVICES] = { |
26 | { | 26 | [JZ_DEVICE_FIIOM3K] = { |
27 | .name = "fiiom3k", | 27 | .name = "fiiom3k", |
28 | .file_ext = "m3k", | ||
28 | .description = "FiiO M3K", | 29 | .description = "FiiO M3K", |
29 | .device_type = JZ_DEVICE_FIIOM3K, | 30 | .device_type = JZ_DEVICE_FIIOM3K, |
30 | .cpu_type = JZ_CPU_X1000, | 31 | .cpu_type = JZ_CPU_X1000, |
32 | .vendor_id = 0x2972, | ||
33 | .product_id = 0x0003, | ||
34 | }, | ||
35 | [JZ_DEVICE_SHANLINGQ1] = { | ||
36 | .name = "shanlingq1", | ||
37 | .file_ext = "q1", | ||
38 | .description = "Shanling Q1", | ||
39 | .device_type = JZ_DEVICE_SHANLINGQ1, | ||
40 | .cpu_type = JZ_CPU_X1000, | ||
41 | .vendor_id = 0x0525, | ||
42 | .product_id = 0xa4a5, | ||
43 | }, | ||
44 | [JZ_DEVICE_EROSQ] = { | ||
45 | .name = "erosq", | ||
46 | .file_ext = "erosq", | ||
47 | .description = "AIGO Eros Q", | ||
48 | .device_type = JZ_DEVICE_EROSQ, | ||
49 | .cpu_type = JZ_CPU_X1000, | ||
50 | .vendor_id = 0xc502, | ||
51 | .product_id = 0x0023, | ||
52 | }, | ||
53 | }; | ||
54 | |||
55 | static const jz_cpu_info cputable[JZ_NUM_CPUS] = { | ||
56 | [JZ_CPU_X1000] = { | ||
57 | .info_str = "X1000_v1", | ||
31 | .vendor_id = 0xa108, | 58 | .vendor_id = 0xa108, |
32 | .product_id = 0x1000, | 59 | .product_id = 0x1000, |
60 | .stage1_load_addr = 0xf4001000, | ||
61 | .stage1_exec_addr = 0xf4001800, | ||
62 | .stage2_load_addr = 0x80004000, | ||
63 | .stage2_exec_addr = 0x80004000, | ||
33 | }, | 64 | }, |
34 | }; | 65 | }; |
35 | 66 | ||
36 | static const int infotable_size = sizeof(infotable)/sizeof(struct jz_device_info); | ||
37 | |||
38 | /** \brief Get the number of entries in the device info list */ | ||
39 | int jz_get_num_device_info(void) | ||
40 | { | ||
41 | return infotable_size; | ||
42 | } | ||
43 | |||
44 | /** \brief Lookup info for a device by type, returns NULL if not found. */ | 67 | /** \brief Lookup info for a device by type, returns NULL if not found. */ |
45 | const jz_device_info* jz_get_device_info(jz_device_type type) | 68 | const jz_device_info* jz_get_device_info(jz_device_type type) |
46 | { | 69 | { |
47 | for(int i = 0; i < infotable_size; ++i) | 70 | return jz_get_device_info_indexed(type); |
48 | if(infotable[i].device_type == type) | ||
49 | return &infotable[i]; | ||
50 | |||
51 | return NULL; | ||
52 | } | 71 | } |
53 | 72 | ||
54 | /** \brief Lookup info for a device by name, returns NULL if not found. */ | 73 | /** \brief Lookup info for a device by name, returns NULL if not found. */ |
55 | const jz_device_info* jz_get_device_info_named(const char* name) | 74 | const jz_device_info* jz_get_device_info_named(const char* name) |
56 | { | 75 | { |
57 | for(int i = 0; i < infotable_size; ++i) | 76 | for(int i = 0; i < JZ_NUM_DEVICES; ++i) |
58 | if(!strcmp(infotable[i].name, name)) | 77 | if(!strcmp(infotable[i].name, name)) |
59 | return &infotable[i]; | 78 | return &infotable[i]; |
60 | 79 | ||
@@ -64,8 +83,27 @@ const jz_device_info* jz_get_device_info_named(const char* name) | |||
64 | /** \brief Get a device info entry by index, returns NULL if out of range. */ | 83 | /** \brief Get a device info entry by index, returns NULL if out of range. */ |
65 | const jz_device_info* jz_get_device_info_indexed(int index) | 84 | const jz_device_info* jz_get_device_info_indexed(int index) |
66 | { | 85 | { |
67 | if(index < infotable_size) | 86 | if(index < JZ_NUM_DEVICES) |
68 | return &infotable[index]; | 87 | return &infotable[index]; |
69 | else | 88 | else |
70 | return NULL; | 89 | return NULL; |
71 | } | 90 | } |
91 | |||
92 | /** \brief Lookup info for a CPU, returns NULL if not found. */ | ||
93 | const jz_cpu_info* jz_get_cpu_info(jz_cpu_type type) | ||
94 | { | ||
95 | if(type < JZ_NUM_CPUS) | ||
96 | return &cputable[type]; | ||
97 | else | ||
98 | return NULL; | ||
99 | } | ||
100 | |||
101 | /** \brief Lookup info for a CPU by info string, returns NULL if not found. */ | ||
102 | const jz_cpu_info* jz_get_cpu_info_named(const char* info_str) | ||
103 | { | ||
104 | for(int i = 0; i < JZ_NUM_CPUS; ++i) | ||
105 | if(!strcmp(cputable[i].info_str, info_str)) | ||
106 | return &cputable[i]; | ||
107 | |||
108 | return NULL; | ||
109 | } | ||