📄 parfpm.c
字号:
putstr(" ME="); tx_hex(me);
putstr(" P="); tx_hex(p);
putstr(" End="); tx_hex(e);
putstr(" Op="); tx_byte(op);
putstr(" PA="); tx_hex(pa >> 8); tx_hex(pa);
putstr(" Idx="); tx_hex(index);
putstr(" Val="); tx_hex(val); putcr();
tx_hex(me_done); tx_hex(pg_done); tx_hex(mn_done); putcr();
}
if (p==e) pg_done=1;
p+=inc;
}
if (mn==MarchNum) mn_done=1;
mn++;
}
return(result);
}
// System Util
// k select tests (any key to stop toggle tests)
//00:
//01: Secure
//02: Copy from src to dest CPU (input cpu)
//03: Verify from src to dest CPU (input cpu)
//04: Blank check
//05: FME
//07: Toggle ID
//08: Toggle AL
//09: Toggle AH
//0a: Toggle CMD ReqA ReqS
//0b: Continuous Address March for testing address lines
//0c: After-bake: Slave Retention Check only
//0d: After-bake: Slave Retention Check and March Test
//0e: Write i and chk
//0f: Pre-bake: Program Slave CPU with AA and check result
//10: LED/Beeper
//11: Key On-Off
//12: Key Voltage Level
//13: SRD/SWR Test???
unsigned char util (unsigned char cpu, unsigned char k)
{ unsigned int i;
unsigned int n,e,f, end;
unsigned char c, err=0, cpux,src_cpu, dest_cpu, pat, ps=0, done=0, trial=0, inc,a,s,j;
bit kk;
if (target.exist) n=target.kbyte*1024; else n=32*1024;
if (k==0x01){ // Secure Part
err=fpm(cpu|FWR,0x807f,fpm(cpu|FRD,0x807f,0) & 0x7F);
}
if (k==0x02){ // 'cpu' define dest CPU
if (cpu==CPUS) {src_cpu=CPUA; dest_cpu=CPUS;}
else if (cpu==CPUA) {src_cpu=CPUS; dest_cpu=CPUA;}
else err=9;
err |= fpm(dest_cpu|FME,0x0000,0xff);
err |= fpm(dest_cpu|FME,0x8000,0xff);
if (err!=0) err=1;
else {
i=0; done=0; f=0; err=0; led(RED,ON);
while(!done){
s=fpm(dest_cpu|FRD,i,0);
if (s!=0xff) {err=2; f=i; done=1;} //Blank0 check err
else {
a=fpm(src_cpu|FRD,i,0);
if (a!=0xff) {
fpm(dest_cpu|FWR,i,a);
s=fpm(dest_cpu|FRD,i,0);
if (s!=a) {err=3; f=i; done=1;} // Write0 Err
}
}
if ((i&0x01ff)==0x0100) {led(GREEN,OFF);}
if ((i&0x01ff)==0x0000) {led(GREEN,ON);}
i++; if (i==n) done=1;
}
i=0x8000; done=0;
while(!done && err==0){
if (!blackout(i)){
s=fpm(dest_cpu|FRD,i,0);
if (s!=0xff) {err=4; f=i; done=1;} //Blank1 check err
else {
a=fpm(src_cpu|FRD,i,0);
if (a!=0xff) {
fpm(dest_cpu|FWR,i,a);
s=fpm(dest_cpu|FRD,i,0);
if (s!=a) {err=5; f=i; done=1;} // Write1 Err
}
}
}
i++; if (i==0x8080) done=1;
}
}
if (err==1) putstr(" Mass Erase Error");
if (err==2 || err==4) putstr(" Blank Check Error:");
if (err==3 || err==5) putstr(" Write Error:");
if (err!=0) {led(RED,ON);led(GREEN,OFF);tx_hex(f>>8); tx_hex(f); } else {led(RED,OFF);led(GREEN,ON);}
}
if (k==0x03 || k==0x04){
src_cpu=cpu;
if (k==0x03 && cpu==CPUA) { dest_cpu=CPUS;}
if (k==0x03 && cpu==CPUS) { dest_cpu=CPUA;}
i=0; done=0; f=0; err=0; led(GREEN,OFF);
while(!done){
a=fpm(src_cpu|FRD,i,0);
if (k==0x03) s=fpm(dest_cpu|FRD,i,0); else s=0xff;
if (s!=a) {err=1; f=i; done=1;}
i++; if (i==n) done=1;
if ((i&0x01ff)==0x0100) {led(RED,OFF);}
if ((i&0x01ff)==0x0000) {led(RED,ON);}
}
i=0x8000; done=0;
while(!done && err==0){
if (!blackout(i)){
a=fpm(src_cpu|FRD,i,0);
if (k==0x03) s=fpm(dest_cpu|FRD,i,0); else s=0xff;
if (s!=a) {err=1; f=i; done=1;}
}
i++; if (i==0x8080) done=1;
}
if (err!=0) {
putstr(" Error:");
led(RED,ON);led(GREEN,OFF);tx_hex(f>>8); tx_hex(f);
} else {led(RED,OFF);led(GREEN,ON);}
}
if (k==5){ // mass erase
err |= fpm(cpu|FME,0x0000,0xff);
err |= fpm(cpu|FME,0x8000,0xff);
}
if (k==7) { P0DDR=P0OUT; while(RI==0) id= c++; P0DDR=P0IDLE;}
if (k==8) while(RI==0) al= c++;
if (k==9) while(RI==0){ ah= c++; CP=0; CP=1;}
if (k==0x0a) while(RI==0) {CMD0=(c&1)?0:1; CMD1=(c&2)?0:1; CMD2=(c&4)?0:1; REQA=(c&8)?0:1; REQS=(c&16)?0:1; c=((c&0x1f)==0x1f)?0:(c+1);}
if (k==0x0b) { // Address Decoder and connection check
putstr("March Up {R1,W0,R0} ");
fpm(cpu|FME,0,0xff);
i=0; inc=1; end=n; done=0; f=0; err=0;
while(!done){
c=fpm(cpu|FRD,i,0);
if (c!=0xff) {CMD2=1; err|=1; f=i; done=1;}
else {
CMD1=1; fpm(cpu|FWR,i,0); c=fpm(cpu|FRD,i,0);
if (c!=0) {CMD2=1; err|=1; f=i; done=1;}
}
if ((i&0x01ff)==0x01ff) {led(RED,ON); led(GREEN,OFF);}
if ((i&0x01ff)==0x00ff) {led(RED,OFF); led(GREEN,OFF);}
i+=inc; if (i==end) done=1;
}
if (err!=0) {tx_hex(f>>8); tx_hex(f);}
putstr("March Down {R1,W0,R0} ");
fpm(cpu|FME,0,0xff);
i=n-1; end=0xffff; done=0; f=0;
while(!done){
c=fpm(cpu|FRD,i,0);
if (c!=0xff) {CMD2=1; err|=1; f=i; done=1;}
else {
CMD1=1; fpm(cpu|FWR,i,0); c=fpm(cpu|FRD,i,0);
if (c!=0) {CMD2=1; err|=1; f=i; done=1;}
}
if ((i&0x01ff)==0x01ff) {led(RED,ON); led(GREEN,ON);}
if ((i&0x01ff)==0x00ff) {led(RED,ON); led(GREEN,OFF);}
i--; if (i==end) done=1;
}
if (err!=0) {
tx_hex(f>>8); tx_hex(f); led(RED,ON); led(GREEN,OFF);
} else {led(RED,OFF); led(GREEN,ON);}
}
if (k==0x0c){ //After Bake Retention test only
e=0; f=0;
i=0; for (i=0;i<n;i++){ // Retention check 0000~80000
c=fpm(cpu|FRD,i,0); if (c!=ONE) {CMD2=1; err=1; if (f==0) f=i;} else {CMD1=1;}
if ((i&0x01ff)==0x01ff) {led(RED,ON); led(GREEN,ON);}
if ((i&0x01ff)==0x00ff) {led(RED,OFF); led(GREEN,OFF);}
}
i=0; for (i=0x8000;i<0x8080;i++){ // Retention check 80000~807F
if (blackout(i)==0){
c=fpm(cpu|FRD,i,0); if (c!=ONE) {CMD2=1; err=1; if (e==0) e=i;} else {CMD1=1;}
}
}
if (err!=0) {tx_hex(f>>8); tx_hex(f);tx_hex(e>>8); tx_hex(e);}
}
if (k==0x0d){ //After-bake retention chk & March Test
e=0; f=0;
i=0; for (i=0;i<n;i++){ // Retention check 0000~80000
c=fpm(cpu|FRD,i,0); if (c!=ONE) {CMD2=1; err=1; if (f==0) {f=i;}} else {CMD1=1;}
if ((i&0x01ff)==0x01ff) led(RED,ON);
if ((i&0x01ff)==0x00ff) led(RED,OFF);
}
i=0; for (i=0x8000;i<0x8080;i++){ // Retention check 80000~807F
if (blackout(i)==0){
c=fpm(cpu|FRD,i,0); if (c!=ONE) {CMD2=1; err=1; if (e==0) {e=i;}} else {CMD1=1;}
}
}
if (err!=0) {tx_hex(f>>8); tx_hex(f);tx_hex(e>>8); tx_hex(e);}
else {resetpfpm(); err|=march(cpu);}
}
if (k==0x0e){ //Write i and chk
err |= fpm(cpu|FME,0x0000,0xff);
err |= fpm(cpu|FME,0x8000,0xff);
tx_hex(n>>8); tx_hex(n); e=0; f=0;
i=0; for (i=0;i<n;i++){fpm(cpu|FWR,i,i); c=fpm(cpu|FRD,i,0); if (c!=(unsigned char) i) {CMD2=1; err=1; if (e==0) {e=i;}} else {CMD1=1;} }
i=0; for (i=0;i<n;i++){c=fpm(cpu|FRD,i,0); if (c!=(unsigned char) i) {CMD2=1; if (f==0) {err=1; f=i;}} else {CMD1=1;} }
if (err!=0) {tx_hex(f>>8); tx_hex(f);tx_hex(e>>8); tx_hex(e);}
}
if (k==0x0f){
err |= fpm(cpu|FME,0x0000,0xff);
err |= fpm(cpu|FME,0x8000,0xff);
e=0; f=0; i=0; done=0;
led(RED,ON);
while (!done){
if (!blackout(i)) {fpm(cpu|FWR,i,ONE); c=fpm(cpu|FRD,i,0); }
else c=ONE;
if (c==ONE ) {
CMD1=1; trial=0; i++;
if (ps==1 && i>=0x8080) done=1;
if (ps==0 && i>=n) { ps=1; i=0x8000;}
} else if (trial <3) trial ++; else {CMD2=1; err=1; e=i; done=1;}
if ((i&0x01ff)==0x01ff) led(GREEN,ON);
if ((i&0x01ff)==0x00ff) led(GREEN,OFF);
}
err=resetpfpm();
i=0; e=0; f=0;
for (i=0;i<n;i++){ // Double chk all
c=fpm(cpu|FRD,i,0); if (c!=ONE) {CMD2=1; err=1; e=i;} else {CMD1=1;}
led(RED,ON);
if ((i&0x01ff)==0x01ff) led(GREEN,ON);
if ((i&0x01ff)==0x00ff) led(GREEN,OFF);
}
i=0; for (i=0x8000;i<0x8080;i++){ // Double chk all
if (blackout(i)==0){
c=fpm(cpu|FRD,i,0); if (c!=ONE) {CMD2=1; err=1; f=i;} else {CMD1=1;}
}
}
if (err!=0) {tx_hex(e>>8); tx_hex(e);tx_hex(f>>8); tx_hex(f);}
}
if (k==0x10) { while(RI==0){led(GREEN,ON); led(RED,OFF); beep(700,200); led(GREEN,OFF); led(RED,ON); beep(300,200);}}
if (k==0x11) { while(RI==0){tx_hex(high(k1)); putspace1(); tx_hex(high(k2));putspace1(); tx_hex(high(k3)); putcr(); beep(300,500);}}
if (k==0x12) { while(RI==0){tx_hex((k1)); putspace1(); tx_hex((k2));putspace1(); tx_hex((k3)); putcr();}}
RI=0; return (err);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -