Files
proxmark3/armsrc/start.c
T
dxl e3511c5350 Used HAL layer
in appmain.c and cmd added.
in cmd.c and add some code for test CEP
in em4x50.c(Do not timeout--)
in em4x70.c
in emvsim.c
in epa.c
in felica.c
in felicasim.c
in felicasim.c
in hfops.c
in hfsnoop.c
in hitag2.c
in hitag_common.c(Cross-platform implementation is incomplete.)
in hitagS.c
in hitagu.c
in i2c.c(Incomplete, continue to abstract.)
in i2c_direct.c
in iclass.c
in iso14443a.c(Sniff no finish yet)
in iso14443b.c and fixed bug for st25
in iso15693.c
in legicrf.c
in legicrfsim.c
in lfadc.c(lf_count_edge_periods_ex() improved)
in lfops.c(TI tag no finish yet)
in lfsampling.c
in lfzx.c
in mifarecmd.c
in mifaredesfire.c
in mifaresim.c
in mifaresniff_disabled.c
in mifareutil.c
in pcf7931.c
in sam_xxx
in secc & seos
in start.c
in thinfilm.c
in utils
2026-08-19 15:32:39 +02:00

102 lines
3.7 KiB
C

//-----------------------------------------------------------------------------
// Copyright (C) Jonathan Westhues, Mar 2006
// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// See LICENSE.txt for the text of the license.
//-----------------------------------------------------------------------------
// Just vector to AppMain(). This is in its own file so that I can place it
// with the linker script.
//-----------------------------------------------------------------------------
#include "proxmark3_arm.h"
#include "appmain.h"
#ifdef WITH_COMPRESSION
#include "lz4.h"
#endif
#include "BigBuf.h"
#include "string.h"
#include "ticks_apis.h"
#include "gpio_apis.h"
#include "sys_apis.h"
extern common_area_t g_common_area;
// export by ldscript, is a fixed space in ram, the data from rom will copy and decompress(optional) to ram.
extern uint32_t __data_src_start__[], __data_start__[], __data_end__[], __bss_start__[], __bss_end__[];
// Define an empty unit test main program entry,
// and if the developer compiles the source file that implements the UnitTestMain function,
// this empty function will be automatically overwritten.
void __attribute__((weak)) UnitTestMain(void);
void UnitTestMain(void) {
// Nothing to do...
// In general, this function will be overridden.
}
#ifdef WITH_COMPRESSION
static void uncompress_data_section(void) {
int avail_in;
memcpy(&avail_in, __data_src_start__, sizeof(int));
// if compressed, the head 4byte of '.data' section will be uncompressed size.
int avail_out = (uint32_t) __data_end__ - (uint32_t) __data_start__; // uncompressed size. Correct.
// uncompress data segment to RAM
char *p = (char *) __data_src_start__;
int res = LZ4_decompress_safe(p + 4, (char *) __data_start__, avail_in, avail_out);
if (res < 0) {
while (true) {
LED_A_INV();
LED_B_INV();
LED_C_INV();
LED_D_INV();
SpinDelay(200);
}
}
// save the size of the compressed data section
g_common_area.arg1 = avail_in;
}
#endif
void __attribute__((section(".startos"))) Vector(void);
void Vector(void) {
/* Stack should have been set up by the bootloader */
if (g_common_area.magic != COMMON_AREA_MAGIC || g_common_area.version != 1) {
/* Initialize common area */
memset(&g_common_area, 0, sizeof(g_common_area));
g_common_area.magic = COMMON_AREA_MAGIC;
g_common_area.version = 1;
}
g_common_area.flags.osimage_present = 1;
/* Set up data segment: Copy from flash to ram */
#ifndef WITH_COMPRESSION
uint32_t *data_src = __data_src_start__;
uint32_t *data_dst = __data_start__;
while (data_dst < __data_end__) *data_dst++ = *data_src++;
#else
uncompress_data_section();
#endif
/* Set up (that is: clear) BSS. */
uint32_t *bss_dst = __bss_start__;
while (bss_dst < __bss_end__) *bss_dst++ = 0;
// For some platforms (such as AT32), it is best to init the system clock after jump to app,
// otherwise the USB may not work.
// Because after jumping from boot to app, some variables in RAM will be lost.
ConfigSystemClocks();
// Run the unit test(If enable)
UnitTestMain();
// Run App main loop
AppMain();
}