diff options
Diffstat (limited to 'firmware/system.c')
-rw-r--r-- | firmware/system.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/firmware/system.c b/firmware/system.c index 4ab47fac1f..c9ce086f0a 100644 --- a/firmware/system.c +++ b/firmware/system.c | |||
@@ -82,31 +82,44 @@ void cpu_idle_mode(bool on_off) | |||
82 | #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ | 82 | #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ |
83 | 83 | ||
84 | 84 | ||
85 | bool detect_flashed_rockbox(void) | ||
86 | { | ||
87 | #ifdef HAVE_FLASHED_ROCKBOX | 85 | #ifdef HAVE_FLASHED_ROCKBOX |
88 | struct flash_header hdr; | 86 | static bool detect_flash_header(uint8_t *addr) |
89 | uint8_t *src = (uint8_t *)FLASH_ENTRYPOINT; | 87 | { |
90 | |||
91 | #ifndef BOOTLOADER | 88 | #ifndef BOOTLOADER |
92 | int oldmode = system_memory_guard(MEMGUARD_NONE); | 89 | int oldmode = system_memory_guard(MEMGUARD_NONE); |
93 | #endif | 90 | #endif |
94 | 91 | struct flash_header hdr; | |
95 | memcpy(&hdr, src, sizeof(struct flash_header)); | 92 | memcpy(&hdr, addr, sizeof(struct flash_header)); |
96 | |||
97 | #ifndef BOOTLOADER | 93 | #ifndef BOOTLOADER |
98 | system_memory_guard(oldmode); | 94 | system_memory_guard(oldmode); |
99 | #endif | 95 | #endif |
96 | return hdr.magic == FLASH_MAGIC; | ||
97 | } | ||
98 | #endif | ||
100 | 99 | ||
101 | if (hdr.magic != FLASH_MAGIC) | 100 | bool detect_flashed_romimage(void) |
102 | return false; | 101 | { |
102 | #ifdef HAVE_FLASHED_ROCKBOX | ||
103 | return detect_flash_header((uint8_t *)FLASH_ROMIMAGE_ENTRY); | ||
104 | #else | ||
105 | return false; | ||
106 | #endif /* HAVE_FLASHED_ROCKBOX */ | ||
107 | } | ||
103 | 108 | ||
104 | return true; | 109 | bool detect_flashed_ramimage(void) |
110 | { | ||
111 | #ifdef HAVE_FLASHED_ROCKBOX | ||
112 | return detect_flash_header((uint8_t *)FLASH_RAMIMAGE_ENTRY); | ||
105 | #else | 113 | #else |
106 | return false; | 114 | return false; |
107 | #endif /* HAVE_FLASHED_ROCKBOX */ | 115 | #endif /* HAVE_FLASHED_ROCKBOX */ |
108 | } | 116 | } |
109 | 117 | ||
118 | bool detect_original_firmware(void) | ||
119 | { | ||
120 | return !(detect_flashed_ramimage() || detect_flashed_romimage()); | ||
121 | } | ||
122 | |||
110 | #if CONFIG_CPU == SH7034 | 123 | #if CONFIG_CPU == SH7034 |
111 | #include "led.h" | 124 | #include "led.h" |
112 | #include "system.h" | 125 | #include "system.h" |