diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2021-12-15 21:04:28 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2021-12-24 18:05:53 +0100 |
commit | c876d3bbefe0dc00c27ca0c12d29da5874946962 (patch) | |
tree | 69f468a185a369b01998314bc3ecc19b70f4fcaa /utils/jztool/src/device_info.c | |
parent | 6c6f0757d7a902feb293be165d1490c42bc8e7ad (diff) | |
download | rockbox-c876d3bbefe0dc00c27ca0c12d29da5874946962.tar.gz rockbox-c876d3bbefe0dc00c27ca0c12d29da5874946962.zip |
rbutil: Merge rbutil with utils folder.
rbutil uses several components from the utils folder, and can be
considered part of utils too. Having it in a separate folder is an
arbitrary split that doesn't help anymore these days, so merge them.
This also allows other utils to easily use libtools.make without the
need to navigate to a different folder.
Change-Id: I3fc2f4de19e3e776553efb5dea5f779dfec0dc21
Diffstat (limited to 'utils/jztool/src/device_info.c')
-rw-r--r-- | utils/jztool/src/device_info.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/utils/jztool/src/device_info.c b/utils/jztool/src/device_info.c new file mode 100644 index 0000000000..cc431959ca --- /dev/null +++ b/utils/jztool/src/device_info.c | |||
@@ -0,0 +1,109 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2021 Aidan MacDonald | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "jztool.h" | ||
23 | #include <string.h> | ||
24 | |||
25 | static const jz_device_info infotable[JZ_NUM_DEVICES] = { | ||
26 | [JZ_DEVICE_FIIOM3K] = { | ||
27 | .name = "fiiom3k", | ||
28 | .file_ext = "m3k", | ||
29 | .description = "FiiO M3K", | ||
30 | .device_type = JZ_DEVICE_FIIOM3K, | ||
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", | ||
58 | .vendor_id = 0xa108, | ||
59 | .product_id = 0x1000, | ||
60 | .stage1_load_addr = 0xf4001000, | ||
61 | .stage1_exec_addr = 0xf4001800, | ||
62 | .stage2_load_addr = 0x80004000, | ||
63 | .stage2_exec_addr = 0x80004000, | ||
64 | }, | ||
65 | }; | ||
66 | |||
67 | /** \brief Lookup info for a device by type, returns NULL if not found. */ | ||
68 | const jz_device_info* jz_get_device_info(jz_device_type type) | ||
69 | { | ||
70 | return jz_get_device_info_indexed(type); | ||
71 | } | ||
72 | |||
73 | /** \brief Lookup info for a device by name, returns NULL if not found. */ | ||
74 | const jz_device_info* jz_get_device_info_named(const char* name) | ||
75 | { | ||
76 | for(int i = 0; i < JZ_NUM_DEVICES; ++i) | ||
77 | if(!strcmp(infotable[i].name, name)) | ||
78 | return &infotable[i]; | ||
79 | |||
80 | return NULL; | ||
81 | } | ||
82 | |||
83 | /** \brief Get a device info entry by index, returns NULL if out of range. */ | ||
84 | const jz_device_info* jz_get_device_info_indexed(int index) | ||
85 | { | ||
86 | if(index < JZ_NUM_DEVICES) | ||
87 | return &infotable[index]; | ||
88 | else | ||
89 | return NULL; | ||
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 | } | ||