]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/redboot/v2_0/src/winceinc.h
446bb146ef9d5b8c5e31fee285a42d2d9932d4cd
[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 long rtiPhysAddr;
52         unsigned long rtiPhysLen;
53 } ce_bin_hdr;
54
55 typedef struct
56 {
57         unsigned long physAddr;
58         unsigned long physLen;
59         unsigned long 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 {
194         unsigned long   signature;
195         unsigned short  oalVersion;
196         unsigned short  bspVersion;
197 } OAL_ARGS_HEADER;
198
199 typedef struct _DEVICE_LOCATION
200 {
201         unsigned long IfcType;
202         unsigned long BusNumber;
203         unsigned long LogicalLoc;
204         void *PhysicalLoc;
205         unsigned long Pin;
206 } DEVICE_LOCATION;
207
208 typedef struct
209 {
210         unsigned long flags;
211         DEVICE_LOCATION devLoc;
212         union {
213                 struct {
214                         unsigned long baudRate;
215                         unsigned long dataBits;
216                         unsigned long stopBits;
217                         unsigned long parity;
218                 };
219                 struct {
220                         unsigned short mac[3];
221                         unsigned long ipAddress;
222                         unsigned long ipMask;
223                         unsigned long ipRoute;
224                 };
225         };
226 } OAL_KITL_ARGS;
227
228 typedef struct
229 {
230         OAL_ARGS_HEADER header;
231         char            deviceId[16];   // Device identification
232         OAL_KITL_ARGS   kitl;
233 } ce_std_driver_globals;
234
235 externC ce_std_driver_globals   _KARO_CECFG_START;
236 externC char _KARO_MAGIC[8];
237 externC unsigned long _KARO_STRUCT_SIZE;
238
239 #pragma pack()
240
241 // Default UDP ports used for Ethernet download and EDBG messages.  May be overriden
242 // by device in BOOTME message.
243
244 #define  EDBG_DOWNLOAD_PORT             980   // For downloading images to bootloader via TFTP
245 #define  EDBG_SVC_PORT                  981   // Other types of transfers
246
247 // Byte string for Id field (note - must not conflict with valid TFTP
248 // opcodes (0-5), as we share the download port with TFTP)
249
250 #define EDBG_ID                                 0x47424445 // "EDBG"
251
252 // Defs for reserved values of the Service field
253
254 #define EDBG_SVC_DBGMSG                 0   // Debug messages
255 #define EDBG_SVC_PPSH                   1   // Text shell and PPFS file system
256 #define EDBG_SVC_KDBG                   2   // Kernel debugger
257 #define EDBG_SVC_ADMIN                  0xFF  // Administrative messages
258
259 // Commands
260
261 #define EDBG_CMD_READ_REQ               1       // Read request
262 #define EDBG_CMD_WRITE_REQ              2       // Write request
263 #define EDBG_CMD_WRITE                  3       // Host ack
264 #define EDBG_CMD_WRITE_ACK              4       // Target ack
265 #define EDBG_CMD_ERROR                  5       // Error
266
267 // Service Ids from 3-FE are used for user apps
268
269 #define NUM_DFLT_EDBG_SERVICES  3
270
271 // Size of send and receive windows (except for stop and wait mode)
272
273 #define EDBG_WINDOW_SIZE                8
274
275 // The window size can be negotiated up to this amount if a client provides
276 // enough memory.
277 #define EDBG_MAX_WINDOW_SIZE    16
278
279 // Max size for an EDBG frame.  Based on ethernet MTU - protocol overhead.
280 // Limited to one MTU because we don't do IP fragmentation on device.
281
282 #define EDBG_MAX_DATA_SIZE              1446
283
284 // Defs for Flags field.
285 #define EDBG_FL_FROM_DEV                0x01   // Set if message is from the device
286 #define EDBG_FL_NACK                    0x02   // Set if frame is a nack
287 #define EDBG_FL_ACK                             0x04   // Set if frame is an ack
288 #define EDBG_FL_SYNC                    0x08   // Can be used to reset sequence # to 0
289 #define EDBG_FL_ADMIN_RESP              0x10    // For admin messages, indicate whether this is a response
290
291 // Definitions for Cmd field (used for administrative messages)
292 // Msgs from device
293
294 #define EDBG_CMD_BOOTME                 0 // Initial bootup message from device
295 // Msgs from PC
296 #define EDBG_CMD_SETDEBUG               1 // Used to set debug zones on device (TBD)
297 #define EDBG_CMD_JUMPIMG                2 // Command to tell bootloader to jump to existing
298                                                                   // flash or RAM image. Data is same as CMD_OS_CONFIG.
299 #define EDBG_CMD_OS_CONFIG              3 // Configure OS for debug ethernet services
300 #define EDBG_CMD_QUERYINFO              4 // "Ping" device, and return information (same fmt as bootme)
301 #define EDBG_CMD_RESET                  5 // Command to have platform perform SW reset (e.g. so it
302                                                                   // can be reprogrammed).  Support for this command is
303                                                                   // processor dependant, and may not be implemented
304                                                                   // on all platforms (requires HW mods for Odo).
305 // Msgs from device or PC
306 #define EDBG_CMD_SVC_CONFIG             6
307 #define EDBG_CMD_SVC_DATA               7
308 #define EDBG_CMD_DEBUGBREAK             8 // Break into debugger
309
310 // Structures for Data portion of EDBG packets
311 #define EDBG_MAX_DEV_NAMELEN    16
312
313 // BOOTME message - Devices broadcast this message when booted to request configuration
314 #define EDBG_CURRENT_BOOTME_VERSION     2
315
316 //
317 // Capability and boot Flags for dwBootFlags in EDBG_BOOTME_DATA
318 // LOWORD for boot flags, HIWORD for capability flags
319 //
320
321 // Always download image
322 #define EDBG_BOOTFLAG_FORCE_DOWNLOAD    0x00000001
323
324 // Support passive-kitl
325 #define EDBG_CAPS_PASSIVEKITL                   0x00010000
326
327 // Defs for CPUId
328 #define EDBG_CPU_TYPE_SHX               0x10
329 #define EDBG_CPU_TYPE_MIPS              0x20
330 #define EDBG_CPU_TYPE_X86               0x30
331 #define EDBG_CPU_TYPE_ARM               0x40
332 #define EDBG_CPU_TYPE_PPC               0x50
333 #define EDBG_CPU_TYPE_THUMB             0x60
334
335 #define EDBG_CPU_SH3                    (EDBG_CPU_TYPE_SHX  | 0)
336 #define EDBG_CPU_SH4                    (EDBG_CPU_TYPE_SHX  | 1)
337 #define EDBG_CPU_R3000                  (EDBG_CPU_TYPE_MIPS | 0)
338 #define EDBG_CPU_R4101                  (EDBG_CPU_TYPE_MIPS | 1)
339 #define EDBG_CPU_R4102                  (EDBG_CPU_TYPE_MIPS | 2)
340 #define EDBG_CPU_R4111                  (EDBG_CPU_TYPE_MIPS | 3)
341 #define EDBG_CPU_R4200                  (EDBG_CPU_TYPE_MIPS | 4)
342 #define EDBG_CPU_R4300                  (EDBG_CPU_TYPE_MIPS | 5)
343 #define EDBG_CPU_R5230                  (EDBG_CPU_TYPE_MIPS | 6)
344 #define EDBG_CPU_R5432                  (EDBG_CPU_TYPE_MIPS | 7)
345 #define EDBG_CPU_i486                   (EDBG_CPU_TYPE_X86  | 0)
346 #define EDBG_CPU_SA1100                 (EDBG_CPU_TYPE_ARM | 0)
347 #define EDBG_CPU_ARM720                 (EDBG_CPU_TYPE_ARM | 1)
348 #define EDBG_CPU_PPC821                 (EDBG_CPU_TYPE_PPC | 0)
349 #define EDBG_CPU_PPC403                 (EDBG_CPU_TYPE_PPC | 1)
350 #define EDBG_CPU_THUMB720               (EDBG_CPU_TYPE_THUMB | 0)
351
352 #endif
353
354
355