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