]>
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 <at91sam7s128.h>\r | |
11 | \r | |
12 | #include <config_gpio.h>\r | |
13 | #define LOW(x) PIO_OUTPUT_DATA_CLEAR = (1 << (x))\r | |
14 | #define HIGH(x) PIO_OUTPUT_DATA_SET = (1 << (x))\r | |
15 | \r | |
16 | #define SPI_FPGA_MODE 0\r | |
17 | #define SPI_LCD_MODE 1\r | |
18 | \r | |
19 | typedef unsigned long DWORD;\r | |
20 | typedef signed long SDWORD;\r | |
21 | typedef unsigned long long QWORD;\r | |
22 | typedef int BOOL;\r | |
23 | typedef unsigned char BYTE;\r | |
24 | typedef signed char SBYTE;\r | |
25 | typedef unsigned short WORD;\r | |
26 | typedef signed short SWORD;\r | |
27 | #define TRUE 1\r | |
28 | #define FALSE 0\r | |
29 | \r | |
30 | #include <usb_cmd.h>\r | |
31 | \r | |
32 | #define PACKED __attribute__((__packed__))\r | |
33 | \r | |
34 | #define USB_D_PLUS_PULLUP_ON() { \\r | |
35 | PIO_OUTPUT_DATA_SET = (1<<GPIO_USB_PU); \\r | |
36 | PIO_OUTPUT_ENABLE = (1<<GPIO_USB_PU); \\r | |
37 | }\r | |
38 | #define USB_D_PLUS_PULLUP_OFF() PIO_OUTPUT_DISABLE = (1<<GPIO_USB_PU)\r | |
39 | \r | |
40 | #define LED_A_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_LED_A)\r | |
41 | #define LED_A_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_LED_A)\r | |
42 | #define LED_B_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_LED_B)\r | |
43 | #define LED_B_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_LED_B)\r | |
44 | #define LED_C_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_LED_C)\r | |
45 | #define LED_C_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_LED_C)\r | |
46 | #define LED_D_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_LED_D)\r | |
47 | #define LED_D_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_LED_D)\r | |
48 | #define RELAY_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_RELAY)\r | |
49 | #define RELAY_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_RELAY)\r | |
50 | #define BUTTON_PRESS() !(PIO_PIN_DATA_STATUS & (1<<GPIO_BUTTON))\r | |
51 | //--------------------------------\r | |
52 | // USB declarations\r | |
53 | \r | |
54 | void UsbSendPacket(BYTE *packet, int len);\r | |
55 | BOOL UsbConnected();\r | |
56 | BOOL UsbPoll(BOOL blinkLeds);\r | |
57 | void UsbStart(void);\r | |
58 | \r | |
59 | // This function is provided by the apps/bootrom, and called from UsbPoll\r | |
60 | // if data are available.\r | |
61 | void UsbPacketReceived(BYTE *packet, int len);\r | |
62 | \r | |
63 | #define VERSION_INFORMATION_MAGIC 0x56334d50\r | |
64 | struct version_information {\r | |
65 | int magic; /* Magic sequence to identify this as a correct version information structure. Must be VERSION_INFORMATION_MAGIC */ \r | |
66 | char versionversion; /* Must be 1 */\r | |
67 | 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 | |
68 | char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */\r | |
69 | char svnversion[9]; /* String with the SVN revision */\r | |
70 | char buildtime[30]; /* string with the build time */\r | |
71 | } __attribute__((packed));\r | |
72 | \r | |
73 | #define COMMON_AREA_MAGIC 0x43334d50\r | |
74 | #define COMMON_AREA_COMMAND_NONE 0\r | |
75 | #define COMMON_AREA_COMMAND_ENTER_FLASH_MODE 1\r | |
76 | struct common_area {\r | |
77 | int magic; /* Magic sequence, to distinguish against random uninitialized memory */\r | |
78 | char version; /* Must be 1 */\r | |
79 | char command;\r | |
80 | struct {\r | |
81 | unsigned int bootrom_present:1; /* Set when a bootrom that is capable of parsing the common area is present */\r | |
82 | unsigned int osimage_present:1; /* Set when a osimage that is capable of parsing the common area is present */\r | |
83 | } __attribute__((packed)) flags;\r | |
84 | int arg1, arg2;\r | |
85 | } __attribute__((packed));\r | |
86 | \r | |
87 | #endif\r |