]>
git.zerfleddert.de Git - proxmark3-svn/blob - armsrc/BigBuf.c
987fee7d520b581a7909644fd62d37ee4c49d161
1 //-----------------------------------------------------------------------------
2 // Jonathan Westhues, Aug 2005
3 // Gerhard de Koning Gans, April 2008, May 2011
5 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
6 // at your option, any later version. See the LICENSE.txt file for the text of
8 //-----------------------------------------------------------------------------
9 // BigBuf and functions to allocate/free parts of it.
10 //-----------------------------------------------------------------------------
13 #include "proxmark3.h"
17 // The large multi-purpose buffer, typically used to hold A/D samples or traces,
18 // may be processed in some way. Also used to hold various smaller buffers.
19 static uint8_t BigBuf
[BIGBUF_SIZE
];
22 static uint16_t BigBuf_hi
= BIGBUF_SIZE
;
24 // trace related global variables. Change to function calls?
25 //uint8_t *trace = BigBuf;
29 // get the address of BigBuf
30 uint8_t *BigBuf_get_addr(void)
36 // clear ALL of BigBuf
37 void BigBuf_Clear(void)
39 memset(BigBuf
,0,BIGBUF_SIZE
);
40 Dbprintf("Buffer cleared (%i bytes)",BIGBUF_SIZE
);
44 // allocate a chunk of memory from BigBuf. We allocate high memory first. Low memory
45 // is always for traces/samples
46 uint8_t *BigBuf_malloc(uint16_t chunksize
)
48 if (BigBuf_hi
- chunksize
< 0) {
49 return NULL
; // no memory left
51 BigBuf_hi
-= chunksize
; // aligned to 4 Byte boundary
52 return BigBuf
+ BigBuf_hi
;
57 // free ALL allocated chunks. The whole BigBuf is available for traces again.
58 void BigBuf_free(void)
60 BigBuf_hi
= BIGBUF_SIZE
;
64 // return the maximum trace length (i.e. the unallocated size of BigBuf)
65 uint16_t BigBuf_max_trace_len(void)