SFBBootBlock.h

Go to the documentation of this file.
00001 /*                                              -*- mode:C++; fill-column:100 -*-
00002   SFBBootBlock.h - Persistent boot-time information support
00003   Copyright (C) 2009 The Regents of the University of New Mexico.  All rights reserved.
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this library; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
00018   USA
00019 
00020   $Id$
00021 */
00022 
00029 #ifndef SFBBOOTBLOCK_H
00030 #define SFBBOOTBLOCK_H
00031 
00032 #include "SFBChecksum.h"    /* For SFBChecksum */ 
00033 #include "SFBTypes.h"       /* For u32 etc */
00034 #include "SFBEeprom.h"      /* For EEPROM_RESERVED_BYTES */
00035 #include "SFBPower.h"       /* For VOLTAGE_CALIBRATION_SIZE_BYTES */ 
00036 
00037 #define BOOTBLOCK_MIN_VERSION 0x01  
00038 #define BOOTBLOCK_MAX_VERSION 0xfe  
00044 #define BOOTBLOCK_VERSION 6
00045 
00072 struct SFBBootBlock {
00073   u8 version;             
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084   u8 writeTag;            
00085 
00086 
00087   u16 flags;              
00088   u32 bootCount;          
00089   u32 burnCount;          
00090   u32 ownerId;            
00091   u32 boardId;            
00092   u32 powerOnHours;       
00093 
00094 
00095 
00096 
00097 
00098 
00099   u8 initialPower;        
00100 
00101   u8 watchdogResets;      
00102   u8 voltageCalib[15];    
00103   u8 reservedPadding[15]; 
00104   SFBChecksum cs;         
00105 };
00106 
00110 typedef char ensureSFBBootBlockSizeIsTheRightSize[sizeof(SFBBootBlock) == EEPROM_BYTES_PER_PAGE];
00111 typedef char ensureCorrectNumberOfPagesAreReserved[2 == EEPROM_RESERVED_PAGES];
00115 enum SFBBootBlockFlag {
00116   BOOTBLOCK_INVALID =      0x0001, 
00117   BOOTBLOCK_BOOT_MODE =    0x0002, 
00118   BOOTBLOCK_BLUE_NOT_RED = 0x0004, 
00119   BOOTBLOCK_UNLOCKED =     0x0008, 
00120 
00121   BOOTBLOCK_NO_UPDATES =   0x0010, 
00122   BOOTBLOCK_KILL_SKETCH =  0x0020, 
00123   BOOTBLOCK_RSRVD06 =      0x0040, 
00124   BOOTBLOCK_RSRVD07 =      0x0080, 
00125 
00126   BOOTBLOCK_RSRVD08 =      0x0100, 
00127   BOOTBLOCK_RSRVD09 =      0x0200, 
00128   BOOTBLOCK_RSRVD10 =      0x0400, 
00129   BOOTBLOCK_RSRVD11 =      0x0800, 
00130 
00131   BOOTBLOCK_RSRVD12 =      0x1000, 
00132   BOOTBLOCK_RSRVD13 =      0x2000, 
00133   BOOTBLOCK_RSRVD14 =      0x4000, 
00134   BOOTBLOCK_RSRVD15 =      0x8000, 
00135 
00136   BOOTBLOCK_DEFINED_FLAGS =   
00137     BOOTBLOCK_INVALID | BOOTBLOCK_BOOT_MODE | BOOTBLOCK_BLUE_NOT_RED | BOOTBLOCK_UNLOCKED
00138   | BOOTBLOCK_NO_UPDATES | BOOTBLOCK_KILL_SKETCH
00139 };
00140 
00141 extern u32 getBootBlockVersion() ;  
00142 
00143 
00144 extern u8 getBootBlockWatchdogResets() ;  
00145 
00146 extern u32 getBootBlockOwnerId() ;  
00147 extern u32 getBootBlockBoardId() ;  
00148 extern u32 getBootBlockBootCount() ;  
00149 extern u32 getBootBlockBurnCount() ;  
00150 extern u32 getBootBlockPowerOnHours() ;  
00151 
00152 
00153 
00154 
00155 extern u32 getBootBlockFlags() ;         
00156 extern u32 getBootBlockBootMode() ;      
00157 
00158 
00159 
00160 
00161 extern u32 getBootBlockMergedChecksum() ; 
00162 
00163 
00164 
00165 extern bool getBootBlockPowerIn(u8 face) ; 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 extern bool getBootBlockPowerOut(u8 face) ; 
00175 
00176 
00177 
00178 
00179 
00180 extern void setBootBlockPowerIn(u8 face, bool accept) ; 
00181 
00182 
00183 
00184 
00185 extern void setBootBlockPowerOut(u8 face, bool provide) ; 
00186 
00187 
00188 
00189 
00190 extern const char * bootModeColorName(u32 bootMode) ;
00191 
00192 extern u32 getBootBlockBootLoaderLength() ; 
00193 
00194 
00195 extern u32 getBootBlockBootLoaderBurnCount() ; 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 extern void getBootBlockBootLoaderChecksum(SFBChecksum cs) ; 
00204 
00205 
00206 
00207 
00208 
00209 
00210 extern void setBootBlockWatchdogResetFlag(bool bootedClean) ; 
00211 
00212 
00213 
00214 extern void setBootBlockOwnerId(u32 newOwnerId) ;             
00215 
00216 
00217 extern void setBootBlockBoardId(u32 newBoardId) ;             
00218 
00219 
00220 extern void incrementBootBlockBootCount() ;         
00221 extern void incrementBootBlockBurnCount() ;         
00222 extern void incrementBootBlockPowerOnHours() ;      
00223 extern void setBootBlockFlags(u32 newFlags) ;       
00224 extern void setBootBlockBootMode(u32 newBootMode) ; 
00225 
00229 extern void getBootBlockVoltageCalibrationData(u8 data[VOLTAGE_CALIBRATION_SIZE_BYTES]) ;
00230 
00236 extern void setBootBlockVoltageCalibrationData(u8 data[VOLTAGE_CALIBRATION_SIZE_BYTES]) ;
00237 
00239 /* The one-time serial startup code */
00240 extern void bootblock_startup_initialization() ;
00241 
00242 /* Increment the bootcount at startup (unless overridden) */
00243 extern void bootblock_bootcount_initialization() __attribute__ ((weak));  /* Allow overriding this initialization step */
00246 #endif  /* SFBBOOTBLOCK_H */
00247 

Generated on Fri Apr 22 06:54:11 2011 for SFB by doxygen 1.5.9