1 //-----------------------------------------------------------------------------
2 // Jonathan Westhues, Mar 2006
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // Just vector to AppMain(). This is in its own file so that I can place it
9 // with the linker script.
10 //-----------------------------------------------------------------------------
15 #include "proxmark3_arm.h"
17 #ifndef WITH_NO_COMPRESSION
23 extern struct common_area common_area
;
24 extern uint32_t __data_src_start__
[], __data_start__
[], __data_end__
[], __bss_start__
[], __bss_end__
[];
26 #ifndef WITH_NO_COMPRESSION
27 static void uncompress_data_section(void) {
29 memcpy(&avail_in
, __data_src_start__
, sizeof(int));
30 int avail_out
= (uint32_t)__data_end__
- (uint32_t)__data_start__
; // uncompressed size. Correct.
31 // uncompress data segment to RAM
32 char *p
= (char *)__data_src_start__
;
33 int res
= LZ4_decompress_safe(p
+ 4, (char *)__data_start__
, avail_in
, avail_out
);
37 // save the size of the compressed data section
38 common_area
.arg1
= avail_in
;
42 void __attribute__((section(".startos"))) Vector(void);
44 /* Stack should have been set up by the bootloader */
46 if (common_area
.magic
!= COMMON_AREA_MAGIC
|| common_area
.version
!= 1) {
47 /* Initialize common area */
48 memset(&common_area
, 0, sizeof(common_area
));
49 common_area
.magic
= COMMON_AREA_MAGIC
;
50 common_area
.version
= 1;
52 common_area
.flags
.osimage_present
= 1;
54 /* Set up data segment: Copy from flash to ram */
55 #ifdef WITH_NO_COMPRESSION
56 uint32_t *data_src
= __data_src_start__
;
57 uint32_t *data_dst
= __data_start__
;
58 while (data_dst
< __data_end__
) *data_dst
++ = *data_src
++;
60 uncompress_data_section();
63 /* Set up (that is: clear) BSS. */
64 uint32_t *bss_dst
= __bss_start__
;
65 while (bss_dst
< __bss_end__
) *bss_dst
++ = 0;