]> cvs.zerfleddert.de Git - proxmark3-svn/blame_incremental - armsrc/start.c
Add Viking demod,
[proxmark3-svn] / armsrc / start.c
... / ...
CommitLineData
1//-----------------------------------------------------------------------------
2// Jonathan Westhues, Mar 2006
3//
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
6// the license.
7//-----------------------------------------------------------------------------
8// Just vector to AppMain(). This is in its own file so that I can place it
9// with the linker script.
10//-----------------------------------------------------------------------------
11
12#include "proxmark3.h"
13#include "apps.h"
14#include "zlib.h"
15#include "BigBuf.h"
16
17static uint8_t *next_free_memory;
18extern struct common_area common_area;
19extern char __data_src_start__, __data_start__, __data_end__, __bss_start__, __bss_end__;
20
21
22static voidpf inflate_malloc(voidpf opaque, uInt items, uInt size)
23{
24 uint8_t *allocated_memory;
25
26 allocated_memory = next_free_memory;
27 next_free_memory += items*size;
28 return allocated_memory;
29}
30
31
32static void inflate_free(voidpf opaque, voidpf address)
33{
34 // nothing to do
35
36}
37
38static void uncompress_data_section(void)
39{
40 z_stream data_section;
41
42 next_free_memory = BigBuf_get_addr();
43
44 // initialize zstream structure
45 data_section.next_in = (uint8_t *) &__data_src_start__;
46 data_section.avail_in = &__data_end__ - &__data_start__; // uncompressed size. Wrong but doesn't matter.
47 data_section.next_out = (uint8_t *) &__data_start__;
48 data_section.avail_out = &__data_end__ - &__data_start__; // uncompressed size. Correct.
49 data_section.zalloc = &inflate_malloc;
50 data_section.zfree = &inflate_free;
51 data_section.opaque = NULL;
52
53 // initialize zlib for inflate
54 inflateInit2(&data_section, 15);
55
56 // uncompress data segment to RAM
57 inflate(&data_section, Z_FINISH);
58
59 // save the size of the compressed data section
60 common_area.arg1 = data_section.total_in;
61}
62
63
64void __attribute__((section(".startos"))) Vector(void)
65{
66 /* Stack should have been set up by the bootloader */
67 // char *src;
68 char *dst, *end;
69
70 uncompress_data_section();
71
72 /* Set up (that is: clear) BSS. */
73 dst = &__bss_start__;
74 end = &__bss_end__;
75 while(dst < end) *dst++ = 0;
76
77 // Set up data segment: Copy from flash to ram
78 // src = &__data_src_start__;
79 // dst = &__data_start__;
80 // end = &__data_end__;
81 // while(dst < end) *dst++ = *src++;
82
83
84 AppMain();
85}
Impressum, Datenschutz