11#include "bootver.h"
22
3- static const boot_ver_t asic_min_ver [] = {
4- { 5 , 0 , 0 , 0 }, /* Rev A */
5- { 5 , 0 , 0 , 0 }, /* Rev I */
6- { 5 , 3 , 6 , 0 }, /* Rev M */
7- };
8-
9- static const boot_ver_t asic_max_ver [] = {
10- { 5 , 3 , 5 , 65535 }, /* Rev A */
11- { 5 , 3 , 5 , 65535 }, /* Rev I */
12- { 255 , 255 , 255 , 65535 }, /* Rev M */
13- };
3+ static const boot_ver_t minRevA_CE = { 5 , 0 , 0 , 0 }; /* Rev A */
4+ static const boot_ver_t minRevI_CE = { 5 , 0 , 0 , 0 }; /* Rev I */
5+ static const boot_ver_t minRevM_CE = { 5 , 3 , 6 , 0 }; /* Rev M */
6+ static const boot_ver_t minRevM_82 = { 5 , 6 , 3 , 0 }; /* Rev pre-A of 82AEP, but otherwise the same JB-007 ASIC as M on CE */
7+ static const boot_ver_t maxRevA_CE = { 5 , 3 , 5 , 65535 }; /* Rev A */
8+ static const boot_ver_t maxRevI_CE = { 5 , 3 , 5 , 65535 }; /* Rev I */
9+ static const boot_ver_t maxRev = { 255 , 255 , 255 , 65535 }; /* Rev M */
10+
11+ /* NULL means unsupported */
12+ static const boot_ver_t * asic_min_ver_8384CE [] = { & minRevA_CE , & minRevI_CE , & minRevM_CE };
13+ static const boot_ver_t * asic_max_ver_8384CE [] = { & maxRevA_CE , & maxRevI_CE , & maxRev };
14+ static const boot_ver_t * asic_min_ver_82AEP [] = { NULL , NULL , & minRevM_82 };
15+ static const boot_ver_t * asic_max_ver_82AEP [] = { NULL , NULL , & maxRev };
1416
1517static bool parse_entry (const uint8_t * data , uint32_t entry , uint32_t * addr ) {
1618 if (entry + 4 >= SIZE_BOOTCODE ) {
@@ -98,6 +100,9 @@ bool bootver_parse(const uint8_t* data, boot_ver_t* boot_ver) {
98100}
99101
100102bool bootver_check_ver (const boot_ver_t * ver , const boot_ver_t * check ) {
103+ if (!ver || !check ) {
104+ return false;
105+ }
101106 if (ver -> major != check -> major ) {
102107 return ver -> major > check -> major ;
103108 }
@@ -110,16 +115,19 @@ bool bootver_check_ver(const boot_ver_t* ver, const boot_ver_t* check) {
110115 return ver -> build >= check -> build ;
111116}
112117
113- bool bootver_check_rev (const boot_ver_t * ver , asic_rev_t rev ) {
118+ bool bootver_check_rev (const boot_ver_t * ver , asic_rev_t rev , emu_device_t device ) {
114119 unsigned int index = (unsigned int )rev - 1 ;
115- if (index >= sizeof (asic_min_ver ) / sizeof (boot_ver_t )) {
120+ if (((device == TI83PCE || device == TI84PCE ) && index >= sizeof (asic_min_ver_8384CE ) / sizeof (boot_ver_t * )) ||
121+ ((device == TI82AEP ) && index >= sizeof (asic_min_ver_82AEP ) / sizeof (boot_ver_t * ))) {
116122 return false;
117123 }
118124
119125 if (!ver ) {
120126 return true;
121127 }
122128
123- return bootver_check_ver (ver , asic_min_ver + index )
124- && bootver_check_ver (asic_max_ver + index , ver );
129+ const boot_ver_t * * asic_min_ver = (device == TI83PCE || device == TI84PCE ) ? asic_min_ver_8384CE : asic_min_ver_82AEP ;
130+ const boot_ver_t * * asic_max_ver = (device == TI83PCE || device == TI84PCE ) ? asic_max_ver_8384CE : asic_max_ver_82AEP ;
131+ return bootver_check_ver (ver , asic_min_ver [index ])
132+ && bootver_check_ver (asic_max_ver [index ], ver );
125133}
0 commit comments