NetBurner 3.5.6
PDF Version
startup.h
1#ifndef __STARTUP_H
2#define __STARTUP_H
3#include <stdint.h>
4
5// Flags define bits for the dwFlags in the MonExtraStruct
6// They are used for various image configurations on boot
7#define FLAG_DTCM_EN (0x1) // Data TCM should be enabled
8#define FLAG_ITCM_EN (0x2) // Instruction TCM should be enabled
9#define FLAG_DBG_WFE_EN (0x4)
10#define FLAG_RELOC (0x8) // image is relocatable in flash (assuming header updates)
11
12#define NBURN_CSUM_MAGIC (0x4255524E)
13
14typedef struct
15{
16 uint32_t u32Start;
17 uint32_t u32End;
18 uint8_t u8Region;
19 uint8_t u8pad;
20 uint16_t u16Attrs;
21} __attribute__((packed)) MPUConfig_t;
22
23typedef struct
24{
25 uint32_t dwFlags;
26 uint32_t count;
27 MPUConfig_t config[];
28 // uint32_t checksum will follow immediately
29} __attribute__((packed)) MonExtraStruct;
30
31typedef struct
32{
33 uint32_t dwImgAddr;
34 uint32_t dwExecutionAddr;
35 MonExtraStruct *pExtra;
36 uint32_t dwImgLen;
37 uint32_t dwImgSum;
38 uint32_t dwStructSum;
39} AppHeader_t;
40
41#define IMG_ID_XSUM_MAGIC 0x4E42 // 'N''B'
42
43// This is just an App Header with the image ID field, as it would be found at
44// the sector base
45typedef struct
46{
47 uint16_t wImgID;
48 uint16_t wImgIDXSum;
49 uint32_t dwImgAddr;
50 uint32_t dwExecutionAddr;
51 MonExtraStruct *pExtra;
52 uint32_t dwImgLen;
53 uint32_t dwImgSum;
54 uint32_t dwStructSum;
55} StartUpStruct;
56
57// allows for easy mapping of StartupStructs onto block boundaries
58typedef struct
59{
60 union
61 {
62 StartUpStruct startHdr;
63 struct
64 {
65 uint16_t wImgID;
66 uint16_t wImgIDXSum;
67 AppHeader_t appHdr;
68 };
69 };
70 uint8_t padd[0x2000 - sizeof(StartUpStruct)];
71} __attribute__((packed)) StartUpBlockStruct;
72
73extern StartUpBlockStruct *RunningAppImage;
74
75#endif /* ----- #ifndef __STARTUP_H ----- */