diff options
author | (no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2006-09-09 01:08:38 +0000 |
---|---|---|
committer | (no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2006-09-09 01:08:38 +0000 |
commit | 520784c7ba6a8325e413a293ab11840d982ba87d (patch) | |
tree | 44ee93d44102d47014c6ff696ebc93e8de402e01 | |
parent | b0317c72667378333e1008c49559e974f3e7c15d (diff) |
- major reorganization, split source tree in
- os: core "operating system"
- pcd: PCD (reader) side
- picc: PICC (transponder) side
- rewrite linker script almost from scratch (for correct DFU operation)
git-svn-id: https://svn.openpcd.org:2342/trunk@142 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
-rw-r--r-- | openpcd/firmware/Makefile | 27 | ||||
-rw-r--r-- | openpcd/firmware/include/librfid/rfid.h | 2 | ||||
-rw-r--r-- | openpcd/firmware/link/AT91SAM7S256-ROM-dfu-fullimage.ld | 145 | ||||
-rw-r--r-- | openpcd/firmware/src/openpcd.h | 43 | ||||
-rw-r--r-- | openpcd/firmware/src/os/dbgu.c (renamed from openpcd/firmware/src/dbgu.c) | 11 | ||||
-rw-r--r-- | openpcd/firmware/src/os/dbgu.h (renamed from openpcd/firmware/src/dbgu.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/dfu.c (renamed from openpcd/firmware/src/dfu.c) | 9 | ||||
-rw-r--r-- | openpcd/firmware/src/os/dfu.h (renamed from openpcd/firmware/src/dfu.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/fifo.c (renamed from openpcd/firmware/src/fifo.c) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/fifo.h (renamed from openpcd/firmware/src/fifo.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/flash.c (renamed from openpcd/firmware/src/flash.c) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/led.c (renamed from openpcd/firmware/src/led.c) | 7 | ||||
-rw-r--r-- | openpcd/firmware/src/os/led.h (renamed from openpcd/firmware/src/led.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/main.c (renamed from openpcd/firmware/src/main.c) | 6 | ||||
-rw-r--r-- | openpcd/firmware/src/os/main.h (renamed from openpcd/firmware/src/main.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/pcd_enumerate.c (renamed from openpcd/firmware/src/pcd_enumerate.c) | 9 | ||||
-rw-r--r-- | openpcd/firmware/src/os/pcd_enumerate.h (renamed from openpcd/firmware/src/pcd_enumerate.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/pio_irq.c (renamed from openpcd/firmware/src/pio_irq.c) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/pio_irq.h (renamed from openpcd/firmware/src/pio_irq.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/req_ctx.c (renamed from openpcd/firmware/src/req_ctx.c) | 5 | ||||
-rw-r--r-- | openpcd/firmware/src/os/req_ctx.h | 47 | ||||
-rw-r--r-- | openpcd/firmware/src/os/syscalls.c (renamed from openpcd/firmware/src/syscalls.c) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/trigger.c (renamed from openpcd/firmware/src/trigger.c) | 4 | ||||
-rw-r--r-- | openpcd/firmware/src/os/trigger.h (renamed from openpcd/firmware/src/trigger.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/os/usb_benchmark.c (renamed from openpcd/firmware/src/usb_benchmark.c) | 9 | ||||
-rw-r--r-- | openpcd/firmware/src/os/usb_handler.c (renamed from openpcd/firmware/src/usb_handler.c) | 13 | ||||
-rw-r--r-- | openpcd/firmware/src/os/usb_handler.h (renamed from openpcd/firmware/src/usb_handler.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/main_analog.c (renamed from openpcd/firmware/src/main_analog.c) | 10 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/main_dumbreader.c (renamed from openpcd/firmware/src/main_dumbreader.c) | 12 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/main_pwm.c (renamed from openpcd/firmware/src/main_pwm.c) | 10 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/main_reqa.c (renamed from openpcd/firmware/src/main_reqa.c) | 19 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/pwm.c (renamed from openpcd/firmware/src/pwm.c) | 9 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/pwm.h (renamed from openpcd/firmware/src/pwm.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/rc632.c (renamed from openpcd/firmware/src/rc632.c) | 11 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/rc632.h (renamed from openpcd/firmware/src/rc632.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/rc632_highlevel.c (renamed from openpcd/firmware/src/rc632_highlevel.c) | 6 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd/rfid_layer2_iso14443a.c (renamed from openpcd/firmware/src/rfid_layer2_iso14443a.c) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/picc/load_modulation.c | 31 | ||||
-rw-r--r-- | openpcd/firmware/src/picc/load_modulation.h | 7 | ||||
-rw-r--r-- | openpcd/firmware/src/picc/piccsim.h | 2 | ||||
-rw-r--r-- | openpcd/firmware/src/picc/tc.c (renamed from openpcd/firmware/src/tc.c) | 5 | ||||
-rw-r--r-- | openpcd/firmware/src/picc/tc.h (renamed from openpcd/firmware/src/tc.h) | 0 | ||||
-rw-r--r-- | openpcd/firmware/src/start/Cstartup.S | 56 |
43 files changed, 319 insertions, 196 deletions
diff --git a/openpcd/firmware/Makefile b/openpcd/firmware/Makefile index 2999093..4d8f2a6 100644 --- a/openpcd/firmware/Makefile +++ b/openpcd/firmware/Makefile @@ -75,17 +75,32 @@ SRC = # List C source files here which must be compiled in ARM-Mode. # use file-extension c for "c-only"-files + +# First, build library ... SRCARM = lib/lib_AT91SAM7.c -SRCARM += src/pcd_enumerate.c src/fifo.c src/dbgu.c \ - src/led.c src/rc632.c src/rc632_highlevel.c src/req_ctx.c \ - src/trigger.c src/main.c src/syscalls.c src/pwm.c src/tc.c \ - src/usb_handler.c src/ssc.c src/usb_benchmark.c src/dfu.c \ - src/$(TARGET).c src/start/Cstartup_SAM7.c ifdef DEBUG SRCARM += lib/vsprintf.c lib/ctype.c lib/string.c endif -SRCARM += src/rfid_layer2_iso14443a.c +# then, OS ... +SRCARM += src/os/pcd_enumerate.c src/os/fifo.c src/os/dbgu.c \ + src/os/led.c src/os/req_ctx.c src/os/trigger.c \ + src/os/main.c src/os/syscalls.c src/os/usb_handler.c \ + src/os/usb_benchmark.c src/os/dfu.c src/start/Cstartup_SAM7.c + +ifdef PCD +# PCD support code +SRCARM += src/pcd/rc632.c src/pcd/rc632_highlevel.c \ + src/pcd/pwm.c src/pcd/rfid_layer2_iso14443a.c +# finally, the actual main application +SRCARM += src/pcd/$(TARGET).c +else +# PICC support code +SRCARM += src/picc/tc.c src/picc/ssc.c +# finally, the actual main application +SRCARM += src/picc/$(TARGET).c +endif + # List C++ source files here. # use file-extension cpp for C++-files (use extension .cpp) diff --git a/openpcd/firmware/include/librfid/rfid.h b/openpcd/firmware/include/librfid/rfid.h index eb96378..308f46e 100644 --- a/openpcd/firmware/include/librfid/rfid.h +++ b/openpcd/firmware/include/librfid/rfid.h @@ -1,7 +1,7 @@ #ifndef _RFID_H #define _RFID_H -#include "dbgu.h" +#include <os/dbgu.h> #define rfid_hexdump hexdump diff --git a/openpcd/firmware/link/AT91SAM7S256-ROM-dfu-fullimage.ld b/openpcd/firmware/link/AT91SAM7S256-ROM-dfu-fullimage.ld index 9bb5163..3932e64 100644 --- a/openpcd/firmware/link/AT91SAM7S256-ROM-dfu-fullimage.ld +++ b/openpcd/firmware/link/AT91SAM7S256-ROM-dfu-fullimage.ld @@ -41,82 +41,79 @@ MEMORY SECTIONS { - . = 0x00000000; - /* first section is .text which is used for code */ - .text : { - src/start/Cstartup*.o (.text) - *(.dfu.func) - *(.dfu.struct) - } >FLASH - _etext_dfu = . ; - - .data : AT (_etext_dfu) { - _data_dfu = . ; - KEEP(*(.vectram)) - src/dfu.o (.data) + . = 0x00000000; + /* first section is .text which is used for code */ + .dfu.text 0x00100000: AT ( 0x00000000 ) { + src/start/Cstartup*.o (.text) + *(.dfu.func) + *(.dfu.struct) + . = ALIGN(4); + } >FLASH + + _etext_dfu = . ; + + .dfu.data 0x00200000: AT ( ADDR(.dfu.text) + SIZEOF(.dfu.text) - ADDR(.dfu.text) ) { + _data_dfu = . ; + *(.vectram) + src/os/dfu.o (.data) + . = ALIGN(4); + } >DATA + _edata_dfu = . ; - } >DATA - .text : { - . = 0x00002000; - *(.dfu.functab) - - . = 0x00002100; - *(.text) /* remaining code */ - - *(.glue_7t) *(.glue_7) - - } >FLASH - - . = ALIGN(4); - - /* .rodata section which is used for read-only data (constants) */ - - .rodata : - { - *(.rodata) - } >FLASH - - . = ALIGN(4); - - _etext = . ; - PROVIDE (etext = .); - - /* .data section which is used for initialized data */ - - .data : AT (_etext) - { - _data = . ; - *(.data) - SORT(CONSTRUCTORS) - . = ALIGN(4); - *(.fastrun) - } >DATA - . = ALIGN(4); - - _edata = . ; - PROVIDE (edata = .); - - /* .bss section which is used for uninitialized data */ - - .bss : - { - __bss_start = . ; - __bss_start__ = . ; - *(.bss) - *(COMMON) - } - . = ALIGN(4); - __bss_end__ = . ; - __bss_end__ = . ; - _end = .; - . = ALIGN(4); - .int_data : - { - *(.internal_ram_top) - }> STACK - - PROVIDE (end = .); + .dfu.functab 0x00102100: AT ( ADDR(.dfu.functab) - ADDR(.dfu.text) ) { + *(.dfu.functab) + . = ALIGN(4); + } >FLASH + + .text 0x00102200: AT ( ADDR(.text) - ADDR(.dfu.text) ) { + *(.text) /* remaining code */ + *(.glue_7t) *(.glue_7) + . = ALIGN(4); + } >FLASH + + + /* .rodata section which is used for read-only data (constants) */ + .rodata : AT ( ADDR(.text) + SIZEOF(.text) - ADDR(.dfu.text) ) { + *(.rodata*) + . = ALIGN(4); + } >FLASH + + _etext = . ; + PROVIDE (etext = .); + + /* .data section which is used for initialized data */ + .data : AT ( ADDR(.rodata) + SIZEOF(.rodata) - ADDR(.dfu.text) ) { + _data = . ; + *(.data) + SORT(CONSTRUCTORS) + . = ALIGN(4); + *(.fastrun) + . = ALIGN(4); + } >DATA + + _edata = . ; + PROVIDE (edata = .); + + /* .bss section which is used for uninitialized data */ + .bss : { + __bss_start = . ; + __bss_start__ = . ; + *(.bss) + *(COMMON) + } >DATA + + . = ALIGN(4); + __bss_end__ = . ; + __bss_end__ = . ; + _end = . ; + + . = ALIGN(4); + .int_data : { + *(.internal_ram_top) + } >STACK + + PROVIDE (end = .); /* Stabs debugging sections. */ .stab 0 : { *(.stab) } diff --git a/openpcd/firmware/src/openpcd.h b/openpcd/firmware/src/openpcd.h index ec577d3..aa47fa4 100644 --- a/openpcd/firmware/src/openpcd.h +++ b/openpcd/firmware/src/openpcd.h @@ -49,49 +49,6 @@ #define OPENPCD_IRQ_PRIO_UDP (AT91C_AIC_PRIOR_LOWEST+1) #define OPENPCD_IRQ_PRIO_RC632 AT91C_AIC_PRIOR_LOWEST -#define MAX_HDRSIZE sizeof(struct openpcd_hdr) -#define MAX_REQSIZE (64-MAX_HDRSIZE) - -#define req_buf_payload(x) (x->data[x->hdr_len]) -#define req_buf_hdr(x) (x->data[0]) - -#include <sys/types.h> - -struct req_buf { - u_int16_t hdr_len; - u_int16_t tot_len; - u_int8_t data[64]; -}; - -struct req_ctx { - u_int16_t seq; /* request sequence number */ - u_int16_t flags; - volatile u_int32_t state; - struct req_buf rx; - struct req_buf tx; -}; - -#define RCTX_STATE_FREE 0x00 -#define RCTX_STATE_UDP_RCV_BUSY 0x01 -#define RCTX_STATE_UDP_RCV_DONE 0x02 -#define RCTX_STATE_MAIN_PROCESSING 0x03 -#define RCTX_STATE_RC632IRQ_BUSY 0x04 - -#define RCTX_STATE_UDP_EP2_PENDING 0x10 -#define RCTX_STATE_UDP_EP2_BUSY 0x11 - -#define RCTX_STATE_UDP_EP3_PENDING 0x12 -#define RCTX_STATE_UDP_EP3_BUSY 0x13 - -#define RCTX_STATE_SSC_RX_BUSY 0x20 - -#define NUM_REQ_CTX 8 -extern struct req_ctx *req_ctx_find_get(unsigned long old_state, unsigned long new_state); -extern struct req_ctx *req_ctx_find_busy(void); -extern void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state); -extern void req_ctx_put(struct req_ctx *ctx); -extern u_int8_t req_ctx_num(struct req_ctx *ctx); - extern void _init_func(void); extern void _main_func(void); diff --git a/openpcd/firmware/src/dbgu.c b/openpcd/firmware/src/os/dbgu.c index 2e8cb8b..e64d8eb 100644 --- a/openpcd/firmware/src/dbgu.c +++ b/openpcd/firmware/src/os/dbgu.c @@ -15,11 +15,10 @@ // Include Standard files #include <board.h> -#include "dbgu.h" -#include "rc632.h" -#include "openpcd.h" -#include "led.h" -#include "main.h" +#include <os/dbgu.h> +#include "../openpcd.h" +#include <os/led.h> +#include <os/main.h> #include <asm/system.h> #define USART_SYS_LEVEL 4 @@ -79,6 +78,7 @@ static void DBGU_irq_handler(void) AT91F_DBGU_Printk("Toggling LED 2\n\r"); led_toggle(2); break; +#if 0 case '4': AT91F_DBGU_Printk("Testing RC632 : "); if (rc632_test(RAH) == 0) @@ -99,6 +99,7 @@ static void DBGU_irq_handler(void) case '7': rc632_dump(); break; +#endif default: if (_main_dbgu(value) < 0) AT91F_DBGU_Printk("\n\r"); diff --git a/openpcd/firmware/src/dbgu.h b/openpcd/firmware/src/os/dbgu.h index 8dd34be..8dd34be 100644 --- a/openpcd/firmware/src/dbgu.h +++ b/openpcd/firmware/src/os/dbgu.h diff --git a/openpcd/firmware/src/dfu.c b/openpcd/firmware/src/os/dfu.c index a56e538..ec99cef 100644 --- a/openpcd/firmware/src/dfu.c +++ b/openpcd/firmware/src/os/dfu.c @@ -11,13 +11,14 @@ #include <usb_dfu.h> #include <lib_AT91SAM7.h> -#include "dfu.h" -#include "pcd_enumerate.h" -#include "openpcd.h" +#include <os/dfu.h> +#include <os/pcd_enumerate.h> +#include <os/req_ctx.h> +#include "../openpcd.h" /* If debug is enabled, we need to access debug functions from flash * and therefore have to omit flashing */ -#define DEBUG_DFU +//#define DEBUG_DFU #ifdef DEBUG_DFU #define DEBUGE DEBUGP diff --git a/openpcd/firmware/src/dfu.h b/openpcd/firmware/src/os/dfu.h index a663688..a663688 100644 --- a/openpcd/firmware/src/dfu.h +++ b/openpcd/firmware/src/os/dfu.h diff --git a/openpcd/firmware/src/fifo.c b/openpcd/firmware/src/os/fifo.c index b0ec152..b0ec152 100644 --- a/openpcd/firmware/src/fifo.c +++ b/openpcd/firmware/src/os/fifo.c diff --git a/openpcd/firmware/src/fifo.h b/openpcd/firmware/src/os/fifo.h index d91c6c2..d91c6c2 100644 --- a/openpcd/firmware/src/fifo.h +++ b/openpcd/firmware/src/os/fifo.h diff --git a/openpcd/firmware/src/flash.c b/openpcd/firmware/src/os/flash.c index 2aaf760..2aaf760 100644 --- a/openpcd/firmware/src/flash.c +++ b/openpcd/firmware/src/os/flash.c diff --git a/openpcd/firmware/src/led.c b/openpcd/firmware/src/os/led.c index 1620444..8c34c6c 100644 --- a/openpcd/firmware/src/led.c +++ b/openpcd/firmware/src/os/led.c @@ -3,9 +3,10 @@ #include <errno.h> #include <lib_AT91SAM7.h> #include <openpcd.h> -#include "openpcd.h" -#include "usb_handler.h" -#include "dbgu.h" +#include "../openpcd.h" +#include <os/usb_handler.h> +#include <os/req_ctx.h> +#include <os/dbgu.h> static int led2port(int led) { diff --git a/openpcd/firmware/src/led.h b/openpcd/firmware/src/os/led.h index 394107b..394107b 100644 --- a/openpcd/firmware/src/led.h +++ b/openpcd/firmware/src/os/led.h diff --git a/openpcd/firmware/src/main.c b/openpcd/firmware/src/os/main.c index def9e57..c40fd79 100644 --- a/openpcd/firmware/src/main.c +++ b/openpcd/firmware/src/os/main.c @@ -1,9 +1,9 @@ #include <errno.h> #include <string.h> #include <include/lib_AT91SAM7.h> -#include "dbgu.h" -#include "led.h" -#include "openpcd.h" +#include <os/dbgu.h> +#include <os/led.h> +#include "../openpcd.h" int main(void) { diff --git a/openpcd/firmware/src/main.h b/openpcd/firmware/src/os/main.h index 1adc8f6..1adc8f6 100644 --- a/openpcd/firmware/src/main.h +++ b/openpcd/firmware/src/os/main.h diff --git a/openpcd/firmware/src/pcd_enumerate.c b/openpcd/firmware/src/os/pcd_enumerate.c index 4d89e87..ed71a50 100644 --- a/openpcd/firmware/src/pcd_enumerate.c +++ b/openpcd/firmware/src/os/pcd_enumerate.c @@ -21,10 +21,11 @@ #include <lib_AT91SAM7.h> #include <openpcd.h> -#include "pcd_enumerate.h" -#include "dfu.h" -#include "openpcd.h" -#include "dbgu.h" +#include <os/pcd_enumerate.h> +#include <os/req_ctx.h> +#include <os/dfu.h> +#include "../openpcd.h" +#include <os/dbgu.h> #define DEBUG_UDP_IRQ #define DEBUG_UDP_EP0 diff --git a/openpcd/firmware/src/pcd_enumerate.h b/openpcd/firmware/src/os/pcd_enumerate.h index 57ff88c..57ff88c 100644 --- a/openpcd/firmware/src/pcd_enumerate.h +++ b/openpcd/firmware/src/os/pcd_enumerate.h diff --git a/openpcd/firmware/src/pio_irq.c b/openpcd/firmware/src/os/pio_irq.c index 3e65561..3e65561 100644 --- a/openpcd/firmware/src/pio_irq.c +++ b/openpcd/firmware/src/os/pio_irq.c diff --git a/openpcd/firmware/src/pio_irq.h b/openpcd/firmware/src/os/pio_irq.h index 86021df..86021df 100644 --- a/openpcd/firmware/src/pio_irq.h +++ b/openpcd/firmware/src/os/pio_irq.h diff --git a/openpcd/firmware/src/req_ctx.c b/openpcd/firmware/src/os/req_ctx.c index 984f6b9..831d48e 100644 --- a/openpcd/firmware/src/req_ctx.c +++ b/openpcd/firmware/src/os/req_ctx.c @@ -2,9 +2,10 @@ #include <stdlib.h> #include <sys/types.h> #include <asm/bitops.h> +#include <os/dbgu.h> +#include <os/req_ctx.h> -#include "openpcd.h" -#include "dbgu.h" +#include "../openpcd.h" /* FIXME: locking, FIFO order processing */ diff --git a/openpcd/firmware/src/os/req_ctx.h b/openpcd/firmware/src/os/req_ctx.h new file mode 100644 index 0000000..f57f02f --- /dev/null +++ b/openpcd/firmware/src/os/req_ctx.h @@ -0,0 +1,47 @@ +#ifndef _REQ_CTX_H +#define _REQ_CTX_H + +#define MAX_HDRSIZE sizeof(struct openpcd_hdr) +#define MAX_REQSIZE (64-MAX_HDRSIZE) + +#define req_buf_payload(x) (x->data[x->hdr_len]) +#define req_buf_hdr(x) (x->data[0]) + +#include <sys/types.h> + +struct req_buf { + u_int16_t hdr_len; + u_int16_t tot_len; + u_int8_t data[64]; +}; + +struct req_ctx { + u_int16_t seq; /* request sequence number */ + u_int16_t flags; + volatile u_int32_t state; + struct req_buf rx; + struct req_buf tx; +}; + +#define RCTX_STATE_FREE 0x00 +#define RCTX_STATE_UDP_RCV_BUSY 0x01 +#define RCTX_STATE_UDP_RCV_DONE 0x02 +#define RCTX_STATE_MAIN_PROCESSING 0x03 +#define RCTX_STATE_RC632IRQ_BUSY 0x04 + +#define RCTX_STATE_UDP_EP2_PENDING 0x10 +#define RCTX_STATE_UDP_EP2_BUSY 0x11 + +#define RCTX_STATE_UDP_EP3_PENDING 0x12 +#define RCTX_STATE_UDP_EP3_BUSY 0x13 + +#define RCTX_STATE_SSC_RX_BUSY 0x20 + +#define NUM_REQ_CTX 8 +extern struct req_ctx *req_ctx_find_get(unsigned long old_state, unsigned long new_state); +extern struct req_ctx *req_ctx_find_busy(void); +extern void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state); +extern void req_ctx_put(struct req_ctx *ctx); +extern u_int8_t req_ctx_num(struct req_ctx *ctx); + +#endif /* _REQ_CTX_H */ diff --git a/openpcd/firmware/src/syscalls.c b/openpcd/firmware/src/os/syscalls.c index ed989f1..ed989f1 100644 --- a/openpcd/firmware/src/syscalls.c +++ b/openpcd/firmware/src/os/syscalls.c diff --git a/openpcd/firmware/src/trigger.c b/openpcd/firmware/src/os/trigger.c index 7fc51d1..b8cedf3 100644 --- a/openpcd/firmware/src/trigger.c +++ b/openpcd/firmware/src/os/trigger.c @@ -1,6 +1,6 @@ #include <lib_AT91SAM7.h> -#include "openpcd.h" -#include "trigger.h" +#include <os/trigger.h> +#include "../openpcd.h" void trigger_init(void) { diff --git a/openpcd/firmware/src/trigger.h b/openpcd/firmware/src/os/trigger.h index 597704b..597704b 100644 --- a/openpcd/firmware/src/trigger.h +++ b/openpcd/firmware/src/os/trigger.h diff --git a/openpcd/firmware/src/usb_benchmark.c b/openpcd/firmware/src/os/usb_benchmark.c index 9f593f8..3637bc3 100644 --- a/openpcd/firmware/src/usb_benchmark.c +++ b/openpcd/firmware/src/os/usb_benchmark.c @@ -1,10 +1,11 @@ #include <errno.h> #include <string.h> #include <lib_AT91SAM7.h> -#include "openpcd.h" -#include "led.h" -#include "pcd_enumerate.h" -#include "usb_handler.h" +#include <os/led.h> +#include <os/pcd_enumerate.h> +#include <os/usb_handler.h> +#include <os/req_ctx.h> +#include "../openpcd.h" static struct req_ctx dummy_rctx; static struct req_ctx empty_rctx; diff --git a/openpcd/firmware/src/usb_handler.c b/openpcd/firmware/src/os/usb_handler.c index 7a736e8..82620be 100644 --- a/openpcd/firmware/src/usb_handler.c +++ b/openpcd/firmware/src/os/usb_handler.c @@ -8,12 +8,13 @@ #include <openpcd.h> -#include "pcd_enumerate.h" -#include "usb_handler.h" -#include "openpcd.h" -#include "rc632.h" -#include "led.h" -#include "dbgu.h" +#include <os/pcd_enumerate.h> +#include <os/usb_handler.h> +#include <os/req_ctx.h> +#include <os/led.h> +#include <os/dbgu.h> + +#include "../openpcd.h" static usb_cmd_fn *cmd_hdlrs[16]; diff --git a/openpcd/firmware/src/usb_handler.h b/openpcd/firmware/src/os/usb_handler.h index a281c66..a281c66 100644 --- a/openpcd/firmware/src/usb_handler.h +++ b/openpcd/firmware/src/os/usb_handler.h diff --git a/openpcd/firmware/src/main_analog.c b/openpcd/firmware/src/pcd/main_analog.c index 92de3a4..45869e1 100644 --- a/openpcd/firmware/src/main_analog.c +++ b/openpcd/firmware/src/pcd/main_analog.c @@ -11,11 +11,11 @@ #include <string.h> #include <librfid/rfid_layer2_iso14443a.h> #include "rc632.h" -#include "dbgu.h" -#include "led.h" -#include "trigger.h" -#include "pcd_enumerate.h" -#include "main.h" +#include <os/dbgu.h> +#include <os/led.h> +#include <os/trigger.h> +#include <os/pcd_enumerate.h> +#include <os/main.h> void _init_func(void) { diff --git a/openpcd/firmware/src/main_dumbreader.c b/openpcd/firmware/src/pcd/main_dumbreader.c index d9172ed..21c4135 100644 --- a/openpcd/firmware/src/main_dumbreader.c +++ b/openpcd/firmware/src/pcd/main_dumbreader.c @@ -1,13 +1,13 @@ #include <errno.h> #include <include/lib_AT91SAM7.h> #include <include/openpcd.h> -#include "dbgu.h" +#include <os/dbgu.h> #include "rc632.h" -#include "led.h" -#include "pcd_enumerate.h" -#include "usb_handler.h" -#include "openpcd.h" -#include "main.h" +#include <os/led.h> +#include <os/pcd_enumerate.h> +#include <os/usb_handler.h> +#include "../openpcd.h" +#include <os/main.h> void _init_func(void) { diff --git a/openpcd/firmware/src/main_pwm.c b/openpcd/firmware/src/pcd/main_pwm.c index 51ecf48..85d304a 100644 --- a/openpcd/firmware/src/main_pwm.c +++ b/openpcd/firmware/src/pcd/main_pwm.c @@ -7,15 +7,15 @@ #include <errno.h> #include <string.h> #include <lib_AT91SAM7.h> -#include "openpcd.h" +#include "../openpcd.h" #include "rc632.h" -#include "dbgu.h" -#include "led.h" +#include <os/dbgu.h> +#include <os/led.h> #include "pwm.h" #include "tc.h" #include "ssc.h" -#include "pcd_enumerate.h" -#include "usb_handler.h" +#include <os/pcd_enumerate.h> +#include <os/usb_handler.h> static u_int8_t force_100ask = 1; static u_int8_t mod_conductance = 0x3f; diff --git a/openpcd/firmware/src/main_reqa.c b/openpcd/firmware/src/pcd/main_reqa.c index 0e9acea..179b423 100644 --- a/openpcd/firmware/src/main_reqa.c +++ b/openpcd/firmware/src/pcd/main_reqa.c @@ -13,11 +13,16 @@ #include <lib_AT91SAM7.h> #include <librfid/rfid_layer2_iso14443a.h> #include "rc632.h" -#include "dbgu.h" -#include "led.h" -#include "pcd_enumerate.h" -#include "trigger.h" +#include <os/dbgu.h> +#include <os/led.h> +#include <os/pcd_enumerate.h> +#include <os/trigger.h> + +#include "../openpcd.h" + +#ifdef WITH_TC #include "tc.h" +#endif void _init_func(void) { @@ -25,8 +30,10 @@ void _init_func(void) trigger_init(); DEBUGPCRF("enabling RC632"); rc632_init(); +#ifdef WITH_TC DEBUGPCRF("enabling TC"); tc_cdiv_init(); +#endif DEBUGPCRF("turning on RF"); rc632_turn_on_rf(RAH); DEBUGPCRF("initializing 14443A operation"); @@ -149,6 +156,7 @@ int _main_dbgu(char key) case 'l': AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, OPENPCD_PIO_TRIGGER); break; +#ifdef WITH_TC case '<': tc_cdiv_phase_inc(); break; @@ -165,6 +173,7 @@ int _main_dbgu(char key) cdiv_idx++; tc_cdiv_set_divider(cdivs[cdiv_idx]); break; +#endif case '-': if (speed_idx > 0) speed_idx--; @@ -206,7 +215,9 @@ void _main_func(void) rc632_reg_write(RAH, RC632_REG_MFOUT_SELECT, mfout_sel); for (i = 0; i < 0x3ffff; i++) {} //rc632_dump(); +#ifdef WITH_TC tc_cdiv_print(); +#endif switch (mode) { case MODE_REQA: diff --git a/openpcd/firmware/src/pwm.c b/openpcd/firmware/src/pcd/pwm.c index 8247921..ef1ee3f 100644 --- a/openpcd/firmware/src/pwm.c +++ b/openpcd/firmware/src/pcd/pwm.c @@ -9,10 +9,11 @@ #include <sys/types.h> #include <errno.h> #include <openpcd.h> -#include "usb_handler.h" -#include "pcd_enumerate.h" -#include "dbgu.h" -#include "openpcd.h" +#include <os/usb_handler.h> +#include <os/pcd_enumerate.h> +#include <os/req_ctx.h> +#include <os/dbgu.h> +#include "../openpcd.h" #define Hz #define kHz *1000 Hz diff --git a/openpcd/firmware/src/pwm.h b/openpcd/firmware/src/pcd/pwm.h index 8836c32..8836c32 100644 --- a/openpcd/firmware/src/pwm.h +++ b/openpcd/firmware/src/pcd/pwm.h diff --git a/openpcd/firmware/src/rc632.c b/openpcd/firmware/src/pcd/rc632.c index 54ff58d..9fc7428 100644 --- a/openpcd/firmware/src/rc632.c +++ b/openpcd/firmware/src/pcd/rc632.c @@ -13,11 +13,12 @@ #include <lib_AT91SAM7.h> #include <cl_rc632.h> #include <openpcd.h> -#include "openpcd.h" -#include "fifo.h" -#include "dbgu.h" -#include "pcd_enumerate.h" -#include "usb_handler.h" +#include "../openpcd.h" +#include <os/fifo.h> +#include <os/dbgu.h> +#include <os/pcd_enumerate.h> +#include <os/usb_handler.h> +#include <os/req_ctx.h> #include "rc632.h" #define ALWAYS_RESPOND diff --git a/openpcd/firmware/src/rc632.h b/openpcd/firmware/src/pcd/rc632.h index 1a4dc22..1a4dc22 100644 --- a/openpcd/firmware/src/rc632.h +++ b/openpcd/firmware/src/pcd/rc632.h diff --git a/openpcd/firmware/src/rc632_highlevel.c b/openpcd/firmware/src/pcd/rc632_highlevel.c index 6fa0f70..8cb1b86 100644 --- a/openpcd/firmware/src/rc632_highlevel.c +++ b/openpcd/firmware/src/pcd/rc632_highlevel.c @@ -24,7 +24,7 @@ #include <errno.h> #include <cl_rc632.h> #include "rc632.h" -#include "dbgu.h" +#include <os/dbgu.h> #include <librfid/rfid_layer2_iso14443a.h> #include <librfid/rfid_protocol_mifare_classic.h> @@ -837,7 +837,7 @@ struct tx_config { u_int8_t mod_width; }; -static struct rx_config rx_configs[] = { +static const struct rx_config rx_configs[] = { { .subc_pulses = RC632_RXCTRL1_SUBCP_8, .rx_coding = RC632_DECCTRL_MANCHESTER, @@ -864,7 +864,7 @@ static struct rx_config rx_configs[] = { }, }; -static struct tx_config tx_configs[] = { +static const struct tx_config tx_configs[] = { { .rate = RC632_CDRCTRL_RATE_106K, .mod_width = 0x13, diff --git a/openpcd/firmware/src/rfid_layer2_iso14443a.c b/openpcd/firmware/src/pcd/rfid_layer2_iso14443a.c index 80d9d5f..80d9d5f 100644 --- a/openpcd/firmware/src/rfid_layer2_iso14443a.c +++ b/openpcd/firmware/src/pcd/rfid_layer2_iso14443a.c diff --git a/openpcd/firmware/src/picc/load_modulation.c b/openpcd/firmware/src/picc/load_modulation.c new file mode 100644 index 0000000..d2af070 --- /dev/null +++ b/openpcd/firmware/src/picc/load_modulation.c @@ -0,0 +1,31 @@ + +#ifdef CONFIG_PICCSIM + +#include <sys/types.h> +#include <lib_AT91SAM7.h> + +#include "../openpcd.h" + +void load_mod_level(u_int8_t level) +{ + if (level > 3) + level = 3; + + if (level & 0x1) + AT91F_PIO_SetOutput(AT91C_BASE_PIOA, OPENPCD_PIO_LOAD1); + else + AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, OPENPCD_PIO_LOAD1); + + if (level & 0x2) + AT91F_PIO_SetOutput(AT91C_BASE_PIOA, OPENPCD_PIO_LOAD2); + else + AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, OPENPCD_PIO_LOAD2); +} + +void load_mod_init(void) +{ + AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPCD_PIO_LOAD1); + AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPCD_PIO_LOAD2); +} + +#endif /* CONFIG_PICCSIM */ diff --git a/openpcd/firmware/src/picc/load_modulation.h b/openpcd/firmware/src/picc/load_modulation.h new file mode 100644 index 0000000..71f9d6f --- /dev/null +++ b/openpcd/firmware/src/picc/load_modulation.h @@ -0,0 +1,7 @@ +#ifndef _LOAD_MODULATION_H +#define _LOAD_MODULATION_H + +extern void load_mod_level(u_int8_t level); +extern void load_mod_init(void); + +#endif diff --git a/openpcd/firmware/src/picc/piccsim.h b/openpcd/firmware/src/picc/piccsim.h index 34c7bf0..3cf6514 100644 --- a/openpcd/firmware/src/picc/piccsim.h +++ b/openpcd/firmware/src/picc/piccsim.h @@ -1,5 +1,5 @@ -#include <librfdi/rfid_layer2_iso14443a.h> +#include <librfid/rfid_layer2_iso14443a.h> struct piccsim_state { enum rfid_layer2_id l2prot; diff --git a/openpcd/firmware/src/tc.c b/openpcd/firmware/src/picc/tc.c index 2f4628a..d23afa2 100644 --- a/openpcd/firmware/src/tc.c +++ b/openpcd/firmware/src/picc/tc.c @@ -17,8 +17,9 @@ */ #include <lib_AT91SAM7.h> -#include "openpcd.h" -#include "dbgu.h" +#include <os/dbgu.h> + +#include "../openpcd.h" #include "tc.h" static AT91PS_TCB tcb = AT91C_BASE_TCB; diff --git a/openpcd/firmware/src/tc.h b/openpcd/firmware/src/picc/tc.h index e7aa7e4..e7aa7e4 100644 --- a/openpcd/firmware/src/tc.h +++ b/openpcd/firmware/src/picc/tc.h diff --git a/openpcd/firmware/src/start/Cstartup.S b/openpcd/firmware/src/start/Cstartup.S index 68e1a07..731d4c3 100644 --- a/openpcd/firmware/src/start/Cstartup.S +++ b/openpcd/firmware/src/start/Cstartup.S @@ -16,6 +16,41 @@ //*- 1.1 01/Apr/05 JPP : save SPSR //*-----------------------------------------------------------------------------*/ +//#define DEBUG_LL + +#ifdef DEBUG_LL +#define PIOA_PER 0xFFFFF400 +#define PIOA_OER 0xFFFFF410 +#define PIOA_SODR 0xFFFFF430 +#define PIOA_CODR 0xFFFFF434 +#define LED1 25 + .macro led1on + ldr r2, =PIOA_CODR + mov r1, #(1 << LED1) + str r1, [r2] + .endm + .macro led1off + ldr r2, =PIOA_SODR + mov r1, #(1 << LED1) + str r1, [r2] + .endm + .macro ledinit + ldr r2, =PIOA_PER + mov r1, #(1 << LED1) + str r1, [r2] + ldr r2, =PIOA_OER + str r1, [r2] + led1off + .endm +#else + .macro ledinit + .endm + .macro led1on + .endm + .macro led1off + .endm +#endif + .equ IRQ_Stack_Size, 0x00000400 .equ AIC_IVR, (256) @@ -128,6 +163,7 @@ IRQ_Handler_EntryR: .global remap .func remap _remap: +# led1on # Remap RAM to 0x00000000 for DFU ldr r1, =AT91C_BASE_AIC mov r2, #0x01 @@ -236,11 +272,12 @@ InitReset: /*- minumum C initialization */ /*- call AT91F_LowLevelInit( void) */ - ldr r13,.RAM_TOP /* temporary stack in internal RAM */ + ldr r13,.RAM_TOP /* temporary stack in internal RAM */ /*--Call Low level init function in ABSOLUTE through the Interworking */ - ldr r0,=AT91F_LowLevelInit - mov lr, pc - bx r0 + ldr r0,=AT91F_LowLevelInit + mov lr, pc + bx r0 + ledinit /*------------------------------------------------------------------------------ //*- Stack Sizes Definition //*------------------------ @@ -287,6 +324,15 @@ InitReset: msr CPSR_c, #ARM_MODE_SVC mov r13, r0 /* Init stack Sup */ +/*- Relocate DFU .data section (Copy from ROM to RAM)*/ + ldr r1, =_etext_dfu + ldr r2, =_data_dfu + ldr r3, =_edata_dfu +LoopRelDFU: cmp r2, r3 + ldrlo r0, [r1], #4 + strlo r0, [r2], #4 + blo LoopRelDFU + # Relocate .data section (Copy from ROM to RAM) LDR R1, =_etext LDR R2, =_data @@ -304,6 +350,8 @@ LoopZI: CMP R1, R2 STRLO R0, [R1], #4 BLO LoopZI + led1on + ldr r0, =_remap bx r0 |