1
0
Fork 0
forked from len0rd/rockbox

internals: VIRT_PTR needs to point at an *invalid* unmapped address

As an added bonus, don't allow it to be 0 as that could result in a
nullptr for ID2P(0).

Change-Id: I1d6eed774771790fae49f0e56a2f29351cab8d5c
This commit is contained in:
Solomon Peachy 2025-02-11 09:32:12 -05:00
parent 1ea5d57303
commit 801260dd79

View file

@ -215,18 +215,32 @@ enum { ALARM_START_WPS = 0,
/** virtual pointer stuff.. move to another .h maybe? **/
/* These define "virtual pointers", which could either be a literal string,
or a mean a string ID if the pointer is in a certain range.
This helps to save space for menus and options. */
This helps to save space for menus and options.
While using 0 as the base address is fastest/simplest,
it could result in a nullptr when ID==0 which C compilers try to
helpfully "optimize" away.
NOTE: VIRT_PTR must point at an *invalid* address in the target
memory map!
*/
#define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
#if defined(CPU_S5L87XX)
/* the S5L87XX has IRAM at 0, so we use 0xffff bytes right after that */
/* 256K IRAM at 0x0 */
#define VIRT_PTR ((unsigned char*)0x40000)
#elif CONFIG_CPU==DM320
/* the DM320 has IRAM at 0, so we use 0xffff bytes right after that */
#elif CONFIG_CPU==DM320 || CONFIG_CPU == RK27XX
/* 4K of IRAM at 0x0 */
#define VIRT_PTR ((unsigned char*)0x4000)
#elif defined(CPU_TCC780X)
/* 1K of IRAM at 0x0 */
#define VIRT_PTR ((unsigned char*)0x1000)
#elif CONFIG_CPU == S3C2440 || defined(CPU_PP) || CONFIG_CPU==IMX31L
/* up to 64MB of DRAM at 0x0 */
#define VIRT_PTR ((unsigned char*)0x40000000)
#else
/* a location where we won't store strings, 0 is the fastest */
#define VIRT_PTR ((unsigned char*)0)
/* offset from 0x0 slightly */
#define VIRT_PTR ((unsigned char*)sizeof(char*))
#endif
/* form a "virtual pointer" out of a language ID */