SFBBootBlock.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00029 #ifndef SFBBOOTBLOCK_H
00030 #define SFBBOOTBLOCK_H
00031
00032 #include "SFBChecksum.h"
00033 #include "SFBTypes.h"
00034 #include "SFBEeprom.h"
00035
00036 #define BOOTBLOCK_MIN_VERSION 0x01
00037 #define BOOTBLOCK_MAX_VERSION 0xfe
00043 #define BOOTBLOCK_VERSION 5
00044
00071 struct SFBBootBlock {
00072 u8 version;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 u8 writeTag;
00084
00085
00086 u16 flags;
00087 u32 bootCount;
00088 u32 burnCount;
00089 u32 ownerId;
00090 u32 boardId;
00091 u32 powerOnHours;
00092
00093
00094
00095
00096
00097
00098 u8 initialPower;
00099
00100 u8 watchdogResets;
00101 u8 reservedPadding[30];
00102 SFBChecksum cs;
00103 };
00104
00108 typedef char ensureSFBBootBlockSizeIsTheRightSize[sizeof(SFBBootBlock) == EEPROM_BYTES_PER_PAGE];
00109 typedef char ensureCorrectNumberOfPagesAreReserved[2 == EEPROM_RESERVED_PAGES];
00113 enum SFBBootBlockFlag {
00114 BOOTBLOCK_INVALID = 0x0001,
00115 BOOTBLOCK_BOOT_MODE = 0x0002,
00116 BOOTBLOCK_BLUE_NOT_RED = 0x0004,
00117 BOOTBLOCK_UNLOCKED = 0x0008,
00118
00119 BOOTBLOCK_NO_UPDATES = 0x0010,
00120 BOOTBLOCK_KILL_SKETCH = 0x0020,
00121 BOOTBLOCK_RSRVD06 = 0x0040,
00122 BOOTBLOCK_RSRVD07 = 0x0080,
00123
00124 BOOTBLOCK_RSRVD08 = 0x0100,
00125 BOOTBLOCK_RSRVD09 = 0x0200,
00126 BOOTBLOCK_RSRVD10 = 0x0400,
00127 BOOTBLOCK_RSRVD11 = 0x0800,
00128
00129 BOOTBLOCK_RSRVD12 = 0x1000,
00130 BOOTBLOCK_RSRVD13 = 0x2000,
00131 BOOTBLOCK_RSRVD14 = 0x4000,
00132 BOOTBLOCK_RSRVD15 = 0x8000,
00133
00134 BOOTBLOCK_DEFINED_FLAGS =
00135 BOOTBLOCK_INVALID | BOOTBLOCK_BOOT_MODE | BOOTBLOCK_BLUE_NOT_RED | BOOTBLOCK_UNLOCKED
00136 | BOOTBLOCK_NO_UPDATES | BOOTBLOCK_KILL_SKETCH
00137 };
00138
00139 extern u32 getBootBlockVersion() ;
00140
00141
00142 extern u8 getBootBlockWatchdogResets() ;
00143
00144 extern u32 getBootBlockOwnerId() ;
00145 extern u32 getBootBlockBoardId() ;
00146 extern u32 getBootBlockBootCount() ;
00147 extern u32 getBootBlockBurnCount() ;
00148 extern u32 getBootBlockPowerOnHours() ;
00149
00150
00151
00152
00153 extern u32 getBootBlockFlags() ;
00154 extern u32 getBootBlockBootMode() ;
00155
00156
00157
00158
00159 extern u32 getBootBlockMergedChecksum() ;
00160
00161
00162
00163 extern bool getBootBlockPowerIn(u8 face) ;
00164
00165
00166
00167
00168
00169
00170
00171
00172 extern bool getBootBlockPowerOut(u8 face) ;
00173
00174
00175
00176
00177
00178 extern void setBootBlockPowerIn(u8 face, bool accept) ;
00179
00180
00181
00182
00183 extern void setBootBlockPowerOut(u8 face, bool provide) ;
00184
00185
00186
00187
00188 extern const char * bootModeColorName(u32 bootMode) ;
00189
00190 extern u32 getBootBlockBootLoaderLength() ;
00191
00192
00193 extern u32 getBootBlockBootLoaderBurnCount() ;
00194
00195
00196
00197
00198
00199
00200
00201 extern void getBootBlockBootLoaderChecksum(SFBChecksum cs) ;
00202
00203
00204
00205
00206
00207
00208 extern void setBootBlockWatchdogResetFlag(bool bootedClean) ;
00209
00210
00211
00212 extern void setBootBlockOwnerId(u32 newOwnerId) ;
00213
00214
00215 extern void setBootBlockBoardId(u32 newBoardId) ;
00216
00217
00218 extern void incrementBootBlockBootCount() ;
00219 extern void incrementBootBlockBurnCount() ;
00220 extern void incrementBootBlockPowerOnHours() ;
00221 extern void setBootBlockFlags(u32 newFlags) ;
00222 extern void setBootBlockBootMode(u32 newBootMode) ;
00223
00224
00225
00226
00227 extern void bootblock_startup_initialization() ;
00228
00229
00230 extern void bootblock_bootcount_initialization() __attribute__ ((weak));
00231
00232 #endif
00233