2010-02-21 05:57:20 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
2010-02-21 08:12:52 +08:00
|
|
|
// Jonathan Westhues, Mar 2006
|
|
|
|
//
|
|
|
|
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
|
|
|
// at your option, any later version. See the LICENSE.txt file for the text of
|
|
|
|
// the license.
|
|
|
|
//-----------------------------------------------------------------------------
|
2010-02-21 05:57:20 +08:00
|
|
|
// Just vector to AppMain(). This is in its own file so that I can place it
|
|
|
|
// with the linker script.
|
|
|
|
//-----------------------------------------------------------------------------
|
2010-02-21 08:12:52 +08:00
|
|
|
|
2017-01-25 07:33:03 +08:00
|
|
|
#ifndef __START_H
|
|
|
|
#define __START_H
|
|
|
|
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "proxmark3_arm.h"
|
|
|
|
#include "appmain.h"
|
2020-06-05 22:24:05 +08:00
|
|
|
#include "lz4.h"
|
2015-06-25 18:22:34 +08:00
|
|
|
#include "BigBuf.h"
|
2020-06-07 18:46:05 +08:00
|
|
|
#include "string.h"
|
2015-06-25 18:22:34 +08:00
|
|
|
|
|
|
|
static uint8_t *next_free_memory;
|
|
|
|
extern struct common_area common_area;
|
|
|
|
extern char __data_src_start__, __data_start__, __data_end__, __bss_start__, __bss_end__;
|
|
|
|
|
2019-03-10 18:20:22 +08:00
|
|
|
static void uncompress_data_section(void) {
|
2019-03-10 03:34:41 +08:00
|
|
|
next_free_memory = BigBuf_get_addr();
|
2020-06-07 18:46:05 +08:00
|
|
|
int avail_in;
|
|
|
|
memcpy(&avail_in, &__data_start__, sizeof(int));
|
2020-06-05 22:24:05 +08:00
|
|
|
int avail_out = &__data_end__ - &__data_start__; // uncompressed size. Correct.
|
|
|
|
// uncompress data segment to RAM
|
2020-06-07 21:59:06 +08:00
|
|
|
uintptr_t p = (uintptr_t)&__data_src_start__;
|
2020-06-08 09:15:10 +08:00
|
|
|
int res = LZ4_decompress_safe((char *)p + 4, &__data_start__, avail_in, avail_out);
|
2015-06-25 18:22:34 +08:00
|
|
|
|
2019-04-10 15:32:40 +08:00
|
|
|
if (res < 0)
|
2019-04-08 14:08:47 +08:00
|
|
|
return;
|
2019-03-10 03:34:41 +08:00
|
|
|
// save the size of the compressed data section
|
2020-06-05 22:24:05 +08:00
|
|
|
common_area.arg1 = res;
|
2015-06-25 18:22:34 +08:00
|
|
|
}
|
|
|
|
|
2020-05-10 22:59:38 +08:00
|
|
|
void __attribute__((section(".startos"))) Vector(void);
|
|
|
|
void Vector(void) {
|
2019-03-10 03:34:41 +08:00
|
|
|
/* Stack should have been set up by the bootloader */
|
2019-03-09 15:59:13 +08:00
|
|
|
|
2019-03-10 03:34:41 +08:00
|
|
|
uncompress_data_section();
|
2010-02-21 05:57:20 +08:00
|
|
|
|
2019-03-10 03:34:41 +08:00
|
|
|
/* Set up (that is: clear) BSS. */
|
2020-06-07 19:56:21 +08:00
|
|
|
char *dst = &__bss_start__;
|
|
|
|
char *end = &__bss_end__;
|
2019-03-10 07:00:59 +08:00
|
|
|
while (dst < end) *dst++ = 0;
|
2010-02-21 05:57:20 +08:00
|
|
|
|
2019-03-10 03:34:41 +08:00
|
|
|
AppMain();
|
2010-02-21 05:57:20 +08:00
|
|
|
}
|
2019-03-12 07:12:26 +08:00
|
|
|
#endif
|