]>
Commit | Line | Data |
---|---|---|
1 | //-----------------------------------------------------------------------------\r | |
2 | // Definitions of interest to most of the software for this project.\r | |
3 | // Jonathan Westhues, Mar 2006\r | |
4 | //-----------------------------------------------------------------------------\r | |
5 | \r | |
6 | #ifndef __PROXMARK3_H\r | |
7 | #define __PROXMARK3_H\r | |
8 | \r | |
9 | // Might as well have the hardware-specific defines everywhere.\r | |
10 | #include <at91sam7s512.h>\r | |
11 | #include <config_gpio.h>\r | |
12 | \r | |
13 | #define WDT_HIT() AT91C_BASE_WDTC->WDTC_WDCR = 0xa5000001\r | |
14 | \r | |
15 | #define PWM_CH_MODE_PRESCALER(x) ((x)<<0)\r | |
16 | #define PWM_CHANNEL(x) (1<<(x))\r | |
17 | \r | |
18 | #define TC_CMR_TCCLKS_TIMER_CLOCK1 (0<<0)\r | |
19 | #define TC_CMR_TCCLKS_TIMER_CLOCK2 (1<<0)\r | |
20 | #define TC_CMR_TCCLKS_TIMER_CLOCK3 (2<<0)\r | |
21 | #define TC_CMR_TCCLKS_TIMER_CLOCK4 (3<<0)\r | |
22 | #define TC_CMR_TCCLKS_TIMER_CLOCK5 (4<<0)\r | |
23 | \r | |
24 | #define ADC_CHAN_LF 4\r | |
25 | #define ADC_CHAN_HF 5\r | |
26 | #define ADC_MODE_PRESCALE(x) ((x)<<8)\r | |
27 | #define ADC_MODE_STARTUP_TIME(x) ((x)<<16)\r | |
28 | #define ADC_MODE_SAMPLE_HOLD_TIME(x) ((x)<<24)\r | |
29 | #define ADC_CHANNEL(x) (1<<(x))\r | |
30 | #define ADC_END_OF_CONVERSION(x) (1<<(x))\r | |
31 | \r | |
32 | #define SSC_CLOCK_MODE_START(x) ((x)<<8)\r | |
33 | #define SSC_FRAME_MODE_WORDS_PER_TRANSFER(x) ((x)<<8)\r | |
34 | #define SSC_CLOCK_MODE_SELECT(x) ((x)<<0)\r | |
35 | #define SSC_FRAME_MODE_BITS_IN_WORD(x) (((x)-1)<<0)\r | |
36 | \r | |
37 | #define MC_FLASH_COMMAND_KEY ((0x5a)<<24)\r | |
38 | #define MC_FLASH_STATUS_READY (1<<0)\r | |
39 | #define MC_FLASH_MODE_FLASH_WAIT_STATES(x) ((x)<<8)\r | |
40 | #define MC_FLASH_MODE_MASTER_CLK_IN_MHZ(x) ((x)<<16)\r | |
41 | #define MC_FLASH_COMMAND_PAGEN(x) ((x)<<8)\r | |
42 | \r | |
43 | #define RST_CONTROL_KEY (0xa5<<24)\r | |
44 | \r | |
45 | #define PMC_MAIN_OSC_ENABLE (1<<0)\r | |
46 | #define PMC_MAIN_OSC_STABILIZED (1<<0)\r | |
47 | #define PMC_MAIN_OSC_PLL_LOCK (1<<2)\r | |
48 | #define PMC_MAIN_OSC_MCK_READY (1<<3)\r | |
49 | \r | |
50 | #define PMC_MAIN_OSC_STARTUP_DELAY(x) ((x)<<8)\r | |
51 | #define PMC_PLL_DIVISOR(x) (x)\r | |
52 | #define PMC_CLK_PRESCALE_DIV_2 (1<<2)\r | |
53 | #define PMC_PLL_MULTIPLIER(x) (((x)-1)<<16)\r | |
54 | #define PMC_PLL_COUNT_BEFORE_LOCK(x) ((x)<<8)\r | |
55 | #define PMC_PLL_FREQUENCY_RANGE(x) ((x)<<14)\r | |
56 | #define PMC_PLL_USB_DIVISOR(x) ((x)<<28)\r | |
57 | \r | |
58 | #define UDP_INTERRUPT_ENDPOINT(x) (1<<(x))\r | |
59 | #define UDP_CSR_BYTES_RECEIVED(x) (((x) >> 16) & 0x7ff)\r | |
60 | //**************************************************************\r | |
61 | \r | |
62 | #define LOW(x) AT91C_BASE_PIOA->PIO_CODR = (x)\r | |
63 | #define HIGH(x) AT91C_BASE_PIOA->PIO_SODR = (x)\r | |
64 | \r | |
65 | #define SPI_FPGA_MODE 0\r | |
66 | #define SPI_LCD_MODE 1\r | |
67 | \r | |
68 | typedef unsigned long DWORD;\r | |
69 | typedef signed long SDWORD;\r | |
70 | typedef unsigned long long QWORD;\r | |
71 | typedef int BOOL;\r | |
72 | typedef unsigned char BYTE;\r | |
73 | typedef signed char SBYTE;\r | |
74 | typedef unsigned short WORD;\r | |
75 | typedef signed short SWORD;\r | |
76 | #define TRUE 1\r | |
77 | #define FALSE 0\r | |
78 | \r | |
79 | #include <usb_cmd.h>\r | |
80 | \r | |
81 | #define PACKED __attribute__((__packed__))\r | |
82 | \r | |
83 | #define USB_D_PLUS_PULLUP_ON() { \\r | |
84 | HIGH(GPIO_USB_PU); \\r | |
85 | AT91C_BASE_PIOA->PIO_OER = GPIO_USB_PU; \\r | |
86 | }\r | |
87 | #define USB_D_PLUS_PULLUP_OFF() AT91C_BASE_PIOA->PIO_ODR = GPIO_USB_PU\r | |
88 | \r | |
89 | #define LED_A_ON() HIGH(GPIO_LED_A)\r | |
90 | #define LED_A_OFF() LOW(GPIO_LED_A)\r | |
91 | #define LED_B_ON() HIGH(GPIO_LED_B)\r | |
92 | #define LED_B_OFF() LOW(GPIO_LED_B)\r | |
93 | #define LED_C_ON() HIGH(GPIO_LED_C)\r | |
94 | #define LED_C_OFF() LOW(GPIO_LED_C)\r | |
95 | #define LED_D_ON() HIGH(GPIO_LED_D)\r | |
96 | #define LED_D_OFF() LOW(GPIO_LED_D)\r | |
97 | #define RELAY_ON() HIGH(GPIO_RELAY)\r | |
98 | #define RELAY_OFF() LOW(GPIO_RELAY)\r | |
99 | #define BUTTON_PRESS() !(AT91C_BASE_PIOA->PIO_PDSR & GPIO_BUTTON)\r | |
100 | //--------------------------------\r | |
101 | // USB declarations\r | |
102 | \r | |
103 | void UsbSendPacket(BYTE *packet, int len);\r | |
104 | BOOL UsbConnected();\r | |
105 | BOOL UsbPoll(BOOL blinkLeds);\r | |
106 | void UsbStart(void);\r | |
107 | \r | |
108 | // This function is provided by the apps/bootrom, and called from UsbPoll\r | |
109 | // if data are available.\r | |
110 | void UsbPacketReceived(BYTE *packet, int len);\r | |
111 | \r | |
112 | #define VERSION_INFORMATION_MAGIC 0x56334d50\r | |
113 | struct version_information {\r | |
114 | int magic; /* Magic sequence to identify this as a correct version information structure. Must be VERSION_INFORMATION_MAGIC */\r | |
115 | char versionversion; /* Must be 1 */\r | |
116 | char present; /* 1 if the version information could be created at compile time, otherwise 0 and the remaining fields (except for magic) are empty */\r | |
117 | char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */\r | |
118 | char svnversion[9]; /* String with the SVN revision */\r | |
119 | char buildtime[30]; /* string with the build time */\r | |
120 | } __attribute__((packed));\r | |
121 | \r | |
122 | #define COMMON_AREA_MAGIC 0x43334d50\r | |
123 | #define COMMON_AREA_COMMAND_NONE 0\r | |
124 | #define COMMON_AREA_COMMAND_ENTER_FLASH_MODE 1\r | |
125 | struct common_area {\r | |
126 | int magic; /* Magic sequence, to distinguish against random uninitialized memory */\r | |
127 | char version; /* Must be 1 */\r | |
128 | char command;\r | |
129 | struct {\r | |
130 | unsigned int bootrom_present:1; /* Set when a bootrom that is capable of parsing the common area is present */\r | |
131 | unsigned int osimage_present:1; /* Set when a osimage that is capable of parsing the common area is present */\r | |
132 | } __attribute__((packed)) flags;\r | |
133 | int arg1, arg2;\r | |
134 | } __attribute__((packed));\r | |
135 | \r | |
136 | #endif\r |