]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/redboot/v2_0/src/winceinc.h
63d9c6752818217973b86ad971dc12be7f40dbe6
[karo-tx-redboot.git] / packages / redboot / v2_0 / src / winceinc.h
1 #ifndef __WINCEINC_H__
2 #define __WINCEINC_H__
3
4 #pragma pack(1)
5
6 // Edbg BOOTME packet structures
7
8 typedef struct
9 {
10     unsigned int        id;             // Protocol identifier ("EDBG" on the wire)
11     unsigned char       service;        // Service identifier
12     unsigned char       flags;          // Flags (see defs below)
13     unsigned char       seqNum;         // For detection of dropped packets
14     unsigned char       cmd;            // For administrative messages
15     unsigned char       data[1];        // Cmd specific data starts here (format is determined by
16                                         // Cmd, len is determined by UDP packet size)
17 } eth_dbg_hdr;
18
19 #define OFFSETOF(s,m)                   ((unsigned int)&(((s*)0)->m))
20 #define EDBG_DATA_OFFSET                (OFFSETOF(eth_dbg_hdr, data))
21
22 typedef struct
23 {
24         unsigned char   versionMajor;   // Bootloader version
25         unsigned char   versionMinor;   // Bootloader version
26         unsigned short  macAddr[3];             // Ether address of device (net byte order)
27         unsigned int    ipAddr;                 // IP address of device (net byte order)
28         char            platformId[17]; // Platform Id string (NULL terminated)
29         char            deviceName[17]; // Device name string (NULL terminated). Should include
30         // platform and number based on Ether address (e.g. Odo42, CEPCLS2346, etc)
31         unsigned char   cpuId;          // CPU identifier (upper nibble = type)
32         // The following fields were added in CE 3.0 Platform Builder release
33         unsigned char   bootmeVer;     // BOOTME Version.
34         // Must be in the range 2 -> EDBG_CURRENT_BOOTME_VERSION, or
35         // remaining fields will be ignored by Eshell and defaults will be used.
36         unsigned int    bootFlags;      // Boot Flags
37         unsigned short  downloadPort;   // Download Port (net byte order) (0 -> EDBG_DOWNLOAD_PORT)
38         unsigned short  svcPort;        // Service Port (net byte order) (0 -> EDBG_SVC_PORT)
39 } edbg_bootme_data;
40
41 // Packet size
42 #define BOOTME_PKT_SIZE                 (EDBG_DATA_OFFSET + sizeof(edbg_bootme_data))
43
44 // WinCE .BIN file format signature
45 #define CE_BIN_SIGN                     "B000FF\x0A"
46 #define CE_BIN_SIGN_LEN                 7
47
48 typedef struct
49 {
50         unsigned char sign[CE_BIN_SIGN_LEN];
51         unsigned int rtiPhysAddr;
52         unsigned int rtiPhysLen;
53 } ce_bin_hdr;
54
55 typedef struct
56 {
57         unsigned int physAddr;
58         unsigned int physLen;
59         unsigned int chkSum;
60         unsigned char data[1];
61 } ce_bin_entry;
62
63 // CE ROM image structures
64 #define ROM_SIGNATURE_OFFSET                    0x40    // Offset from the image's physfirst address to the ROM signature.
65 #define ROM_SIGNATURE                           0x43454345      // Signature
66 #define ROM_TOC_POINTER_OFFSET                  0x44    // Offset from the image's physfirst address to the TOC pointer.
67 #define ROM_TOC_OFFSET_OFFSET                   0x48    // Offset from the image's physfirst address to the TOC offset (from physfirst).
68
69 typedef struct
70 {
71         unsigned int    dllfirst;               // first DLL address
72         unsigned int    dlllast;                // last DLL address
73         unsigned int    physfirst;              // first physical address
74         unsigned int    physlast;               // highest physical address
75         unsigned int    nummods;                // number of TOCentry's
76         unsigned int    ramStart;               // start of RAM
77         unsigned int    ramFree;                // start of RAM free space
78         unsigned int    ramEnd;                 // end of RAM
79         unsigned int    copyEntries;            // number of copy section entries
80         unsigned int    copyOffset;             // offset to copy section
81         unsigned int    profileLen;             // length of PROFentries RAM
82         unsigned int    profileOffset;          // offset to PROFentries
83         unsigned int    numfiles;               // number of FILES
84         unsigned int    kernelFlags;            // optional kernel flags from ROMFLAGS .bib config option
85         unsigned int    fsRamPercent;           // Percentage of RAM used for filesystem
86         // from FSRAMPERCENT .bib config option
87         // byte 0 = #4K chunks/Mbyte of RAM for filesystem 0-2Mbytes 0-255
88         // byte 1 = #4K chunks/Mbyte of RAM for filesystem 2-4Mbytes 0-255
89         // byte 2 = #4K chunks/Mbyte of RAM for filesystem 4-6Mbytes 0-255
90         // byte 3 = #4K chunks/Mbyte of RAM for filesystem > 6Mbytes 0-255
91
92         unsigned int    drivglobStart;                  // device driver global starting address
93         unsigned int    drivglobLen;                    // device driver global length
94         unsigned short  cpuType;                                // CPU (machine) Type
95         unsigned short  miscFlags;                              // Miscellaneous flags
96         void*                   extensions;                             // pointer to ROM Header extensions
97         unsigned int    trackingStart;                  // tracking memory starting address
98         unsigned int    trackingLen;                    // tracking memory ending address
99 } ce_rom_hdr;
100
101 // Win32 FILETIME strcuture
102
103 typedef struct
104 {
105     unsigned int        loDateTime;
106     unsigned int        hiDateTime;
107 } ce_file_time;
108
109 // Table Of Contents entry structure
110
111 typedef struct
112 {
113     unsigned int        fileAttributes;
114     ce_file_time        fileTime;
115     unsigned int        fileSize;
116     char*                       fileName;
117     unsigned int        e32Offset;            // Offset to E32 structure
118     unsigned int        o32Offset;            // Offset to O32 structure
119     unsigned int        loadOffset;           // MODULE load buffer offset
120 } ce_toc_entry;
121
122 typedef struct
123 {                                                                       /* Extra information header block      */
124     unsigned int        rva;            /* Virtual relative address of info    */
125     unsigned int        size;           /* Size of information block           */
126 } e32_info;
127
128 #define ROM_EXTRA       9
129
130 typedef struct
131 {
132     unsigned short  e32_objcnt;     /* Number of memory objects            */
133     unsigned short  e32_imageflags; /* Image flags                         */
134     unsigned int        e32_entryrva;   /* Relative virt. addr. of entry point */
135     unsigned int        e32_vbase;      /* Virtual base address of module      */
136     unsigned short  e32_subsysmajor;/* The subsystem major version number  */
137     unsigned short  e32_subsysminor;/* The subsystem minor version number  */
138     unsigned int        e32_stackmax;   /* Maximum stack size                  */
139     unsigned int        e32_vsize;      /* Virtual size of the entire image    */
140     unsigned int        e32_sect14rva;  /* section 14 rva */
141     unsigned int        e32_sect14size; /* section 14 size */
142     unsigned int        e32_timestamp;  /* Time EXE/DLL was created/modified   */
143     e32_info            e32_unit[ ROM_EXTRA ]; /* Array of extra info units      */
144     unsigned short  e32_subsys;     /* The subsystem type                  */
145 } e32_rom;
146
147 #pragma pack(1)
148
149 // OS config msg
150 #define EDBG_FL_DBGMSG    0x01  // Debug messages
151 #define EDBG_FL_PPSH      0x02  // Text shell
152 #define EDBG_FL_KDBG      0x04  // Kernel debugger
153 #define EDBG_FL_CLEANBOOT 0x08  // Force a clean boot
154
155 typedef struct
156 {
157         unsigned char   flags;          // Flags that will be used to determine what features are
158                                         // enabled over ethernet (saved in driver globals by bootloader)
159         unsigned char   kitlTransport;  // Tells KITL which transport to start
160
161         // The following specify addressing info, only valid if the corresponding
162         // flag is set in the Flags field.
163
164         unsigned int    dbgMsgIPAddr;
165         unsigned short  dbgMsgPort;
166         unsigned int    ppshIPAddr;
167         unsigned short  ppshPort;
168         unsigned int    kdbgIPAddr;
169         unsigned short  kdbgPort;
170 } edbg_os_config_data;
171
172
173 // Driver globals structure
174 // Used to pass driver globals info from RedBoot to WinCE core
175
176 #define DRV_GLB_SIGNATURE                       0x424C4744 // "DGLB"
177 #define STD_DRV_GLB_SIGNATURE           0x53475241 // "ARGS"
178
179 typedef struct
180 {
181         unsigned int            signature;      // Signature
182         unsigned int            flags;          // Misc flags
183         unsigned int            ipAddr;         // IP address of device (net byte order)
184         unsigned int            ipGate;         // IP address of gateway (net byte order)
185         unsigned int            ipMask;         // Subnet mask
186         unsigned short          macAddr[3];     // Ether address of device (net byte order)
187         edbg_os_config_data edbgConfig;         // EDBG services info
188 } ce_driver_globals;
189
190 #pragma pack(4)
191
192 typedef struct {
193   unsigned long   signature;
194   unsigned short  oalVersion;
195   unsigned short  bspVersion;
196 } OAL_ARGS_HEADER;
197
198 typedef struct _DEVICE_LOCATION
199 {
200         unsigned long IfcType;
201         unsigned long BusNumber;
202         unsigned long LogicalLoc;
203         void *PhysicalLoc;
204         unsigned long Pin;
205 } DEVICE_LOCATION;
206
207 typedef struct
208 {
209         unsigned long flags;
210         DEVICE_LOCATION devLoc;
211         union {
212                 struct {
213                         unsigned long baudRate;
214                         unsigned long dataBits;
215                         unsigned long stopBits;
216                         unsigned long parity;
217                 };
218                 struct {
219                         unsigned short mac[3];
220                         unsigned long ipAddress;
221                         unsigned long ipMask;
222                         unsigned long ipRoute;
223                 };
224         };
225 } OAL_KITL_ARGS;
226
227 typedef struct
228 {
229         OAL_ARGS_HEADER header;
230         char            deviceId[16];   // Device identification
231         OAL_KITL_ARGS   kitl;
232 } ce_std_driver_globals;
233
234 externC ce_std_driver_globals   _KARO_CECFG_START;
235 externC char _KARO_MAGIC[8];
236 externC unsigned long _KARO_STRUCT_SIZE;
237
238 #pragma pack()
239
240 // Default UDP ports used for Ethernet download and EDBG messages.  May be overriden
241 // by device in BOOTME message.
242
243 #define  EDBG_DOWNLOAD_PORT             980   // For downloading images to bootloader via TFTP
244 #define  EDBG_SVC_PORT                  981   // Other types of transfers
245
246 // Byte string for Id field (note - must not conflict with valid TFTP
247 // opcodes (0-5), as we share the download port with TFTP)
248
249 #define EDBG_ID                         0x47424445 // "EDBG"
250
251 // Defs for reserved values of the Service field
252
253 #define EDBG_SVC_DBGMSG                 0   // Debug messages
254 #define EDBG_SVC_PPSH                   1   // Text shell and PPFS file system
255 #define EDBG_SVC_KDBG                   2   // Kernel debugger
256 #define EDBG_SVC_ADMIN                  0xFF  // Administrative messages
257
258 // Commands
259
260 #define EDBG_CMD_READ_REQ               1       // Read request
261 #define EDBG_CMD_WRITE_REQ              2       // Write request
262 #define EDBG_CMD_WRITE                  3       // Host ack
263 #define EDBG_CMD_WRITE_ACK              4       // Target ack
264 #define EDBG_CMD_ERROR                  5       // Error
265
266 // Service Ids from 3-FE are used for user apps
267
268 #define NUM_DFLT_EDBG_SERVICES          3
269
270 // Size of send and receive windows (except for stop and wait mode)
271
272 #define EDBG_WINDOW_SIZE                8
273
274 // The window size can be negotiated up to this amount if a client provides
275 // enough memory.
276 #define EDBG_MAX_WINDOW_SIZE            16
277
278 // Max size for an EDBG frame.  Based on ethernet MTU - protocol overhead.
279 // Limited to one MTU because we don't do IP fragmentation on device.
280
281 #define EDBG_MAX_DATA_SIZE                              1446
282
283 // Defs for Flags field.
284 #define EDBG_FL_FROM_DEV                                0x01   // Set if message is from the device
285 #define EDBG_FL_NACK                                    0x02   // Set if frame is a nack
286 #define EDBG_FL_ACK                                             0x04   // Set if frame is an ack
287 #define EDBG_FL_SYNC                                    0x08   // Can be used to reset sequence # to 0
288 #define EDBG_FL_ADMIN_RESP                              0x10    // For admin messages, indicate whether this is a response
289
290 // Definitions for Cmd field (used for administrative messages)
291 // Msgs from device
292
293 #define EDBG_CMD_BOOTME                 0 // Initial bootup message from device
294 // Msgs from PC
295 #define EDBG_CMD_SETDEBUG               1 // Used to set debug zones on device (TBD)
296 #define EDBG_CMD_JUMPIMG                2 // Command to tell bootloader to jump to existing
297                                           // flash or RAM image. Data is same as CMD_OS_CONFIG.
298 #define EDBG_CMD_OS_CONFIG              3 // Configure OS for debug ethernet services
299 #define EDBG_CMD_QUERYINFO              4 // "Ping" device, and return information (same fmt as bootme)
300 #define EDBG_CMD_RESET                  5 // Command to have platform perform SW reset (e.g. so it
301                                           // can be reprogrammed).  Support for this command is
302                                           // processor dependant, and may not be implemented
303                                           // on all platforms (requires HW mods for Odo).
304 // Msgs from device or PC
305 #define EDBG_CMD_SVC_CONFIG             6
306 #define EDBG_CMD_SVC_DATA               7
307 #define EDBG_CMD_DEBUGBREAK             8 // Break into debugger
308
309 // Structures for Data portion of EDBG packets
310 #define EDBG_MAX_DEV_NAMELEN            16
311
312 // BOOTME message - Devices broadcast this message when booted to request configuration
313 #define EDBG_CURRENT_BOOTME_VERSION     2
314
315 //
316 // Capability and boot Flags for dwBootFlags in EDBG_BOOTME_DATA
317 // LOWORD for boot flags, HIWORD for capability flags
318 //
319
320 // Always download image
321 #define EDBG_BOOTFLAG_FORCE_DOWNLOAD    0x00000001
322
323 // Support passive-kitl
324 #define EDBG_CAPS_PASSIVEKITL           0x00010000
325
326 // Defs for CPUId
327 #define EDBG_CPU_TYPE_SHX               0x10
328 #define EDBG_CPU_TYPE_MIPS              0x20
329 #define EDBG_CPU_TYPE_X86               0x30
330 #define EDBG_CPU_TYPE_ARM               0x40
331 #define EDBG_CPU_TYPE_PPC               0x50
332 #define EDBG_CPU_TYPE_THUMB             0x60
333
334 #define EDBG_CPU_SH3                    (EDBG_CPU_TYPE_SHX  | 0)
335 #define EDBG_CPU_SH4                    (EDBG_CPU_TYPE_SHX  | 1)
336 #define EDBG_CPU_R3000                  (EDBG_CPU_TYPE_MIPS | 0)
337 #define EDBG_CPU_R4101                  (EDBG_CPU_TYPE_MIPS | 1)
338 #define EDBG_CPU_R4102                  (EDBG_CPU_TYPE_MIPS | 2)
339 #define EDBG_CPU_R4111                  (EDBG_CPU_TYPE_MIPS | 3)
340 #define EDBG_CPU_R4200                  (EDBG_CPU_TYPE_MIPS | 4)
341 #define EDBG_CPU_R4300                  (EDBG_CPU_TYPE_MIPS | 5)
342 #define EDBG_CPU_R5230                  (EDBG_CPU_TYPE_MIPS | 6)
343 #define EDBG_CPU_R5432                  (EDBG_CPU_TYPE_MIPS | 7)
344 #define EDBG_CPU_i486                   (EDBG_CPU_TYPE_X86  | 0)
345 #define EDBG_CPU_SA1100                 (EDBG_CPU_TYPE_ARM | 0)
346 #define EDBG_CPU_ARM720                 (EDBG_CPU_TYPE_ARM | 1)
347 #define EDBG_CPU_PPC821                 (EDBG_CPU_TYPE_PPC | 0)
348 #define EDBG_CPU_PPC403                 (EDBG_CPU_TYPE_PPC | 1)
349 #define EDBG_CPU_THUMB720               (EDBG_CPU_TYPE_THUMB | 0)
350
351 #endif
352
353
354