SFBProvenanceData.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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef SFBPROVENANCEDATA_H
00046 #define SFBPROVENANCEDATA_H
00047
00048 #include "SFBProvenance.h"
00049
00050 #ifndef HOST_MODE
00051 #define IN_HEADER __attribute__((section (".header")))
00052 #define IN_FOOTER __attribute__((section (".footer")))
00053 #else
00054 #define IN_HEADER
00055 #define IN_FOOTER
00056 #endif
00057
00058 #ifndef SFB_SKETCH_CREATOR_ID
00059 #define SFB_SKETCH_CREATOR_ID (0)
00060 #endif
00061
00062 #ifndef SFB_SKETCH_PROGRAM_ID
00063 #define SFB_SKETCH_PROGRAM_ID (0)
00064 #endif
00065
00066 #ifndef SFB_SKETCH_COPYRIGHT_NOTICE
00067 #define SFB_SKETCH_COPYRIGHT_NOTICE (0)
00068 #endif
00069
00070 u32 theFooter IN_FOOTER = SFB_PROVENANCE_NZTRX;
00071
00072 extern char __rom_length;
00073
00074 volatile const SFBProvenance theProvenance IN_HEADER = {
00075 0xEA000000+sizeof(SFBProvenance)/4-2,
00076 0,
00077 0,
00078 0,
00079 0,
00080 SFB_PROVENANCE_MAGIC,
00081 0,
00082 0,
00083 SKETCH_ARCH_CODE,
00084 SFB_SKETCH_CREATOR_ID,
00085 SFB_SKETCH_PROGRAM_ID,
00086 SKETCH_BUILD_DATE,
00087 SKETCH_BUILD_TIME,
00088 (int) &__rom_length,
00089 (u32) SFB_SKETCH_COPYRIGHT_NOTICE,
00090 SFB_PROVENANCE_CIGAM
00091 };
00092
00093 extern void initProgramServerSketch() {
00094 programServerSetSketch(&theProvenance,(uptr) &theProvenance, 0);
00095 }
00096
00102 int wantPhPacketCodeUpdate(u8 * packet) {
00103 if (!packet)
00104 return -1;
00105
00106 u8 arch;
00107 int cid, pid, bdt, btm;
00108 u32 matches =
00109 packetScanf(packet,"Ph%c%l%l%l%l%\n", &arch, &cid, &pid, &bdt, &btm);
00110 if (matches < 8) return -(matches+2);
00111 if (cid == -1 || pid == -1) return -10;
00112 if (bdt < 0 || btm < 0) return -11;
00113 if (arch != SKETCH_ARCH_CODE) return -(400+10*arch+SKETCH_ARCH_CODE);
00114
00115 u8 bootMode = getBootBlockBootMode();
00116
00117 if (bootMode==RED_BOOT_MODE) return 6;
00118 if (bootMode==BLUE_BOOT_MODE && cid != theProvenance.creatorId) return 1;
00119 if (bootMode==BLUE_BOOT_MODE && pid != theProvenance.programId) return 2;
00120 if (bdt < theProvenance.buildDate) return 3;
00121 if (bdt == theProvenance.buildDate && btm < theProvenance.buildTime) return 4;
00122 if (bdt == theProvenance.buildDate && btm == theProvenance.buildTime) return 5;
00123
00124 return 0;
00125 }
00126
00127
00128
00129 #endif
00130