123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #define SEGLOW 0xC800 /* lower range for EPROM segment */
- #define SEGHIGH 0xE800 /* upper range for EPROM segment */
- #define AMD_ID 0x2001 /* flash EPROM ID, only support AMD */
- #define ERASE1_CMD 0x80 /* first cmd for erasing full chip */
- #define ERASE2_CMD 0x10 /* second cmd for erasing full chip */
- #define READID_CMD 0x90 /* cmd to read chip ID */
- #define PROG_CMD 0xA0 /* cmd to program a byte */
- #define RESET_CMD 0xF0 /* cmd to reset chip state machine */
-
-
-
-
- .text
- .org 0
-
-
- _main: mov ax,#0x0FE0
- mov ds,ax
- mov ax,magic
- cmp ax,#0xE4E4
- jnz lderr
- jmpi 0x200,0x0FE0
- lderr: mov si,#loaderr
- cld
- lderrlp:seg cs
- lodsb
- or al,al
- jnz lderrnx
- xor ah,ah
- int 0x16
- jmpi 0x0000,0xFFFF
- lderrnx:mov ah,#0x0E
- mov bl,#0x07
- xor bh,bh
- int 0x10
- jmp lderrlp
-
- loaderr:.ascii "The flash EPROM utility has to be loaded from a BOOT-Prom"
- .byte 0xa,0xd
- .ascii "that knows about the 'nbi' file format!"
- .byte 0xa,0xd
- .ascii "Reboot to proceed..."
- .byte 0
-
- .org 510
- .byte 0x55,0xAA
-
- !----------------------------------------------------------------------------
-
- start: mov ax,cs
- mov ds,ax
- mov ax,romdata
- cmp ax,#0xAA55
- jnz resmag
- mov al,romdata+2
- or al,al
- jnz magicok
- resmag: mov si,#badmagic
- reset: call prnstr
- xor ah,ah
- int 0x16
- jmpi 0x0000,0xFFFF
- magicok:mov di,#clrline1
- mov si,#welcome
- inpnew: call prnstr
- inprest:xor bx,bx
- mov cl,#0xC
- inploop:xor ah,ah
- int 0x16
- cmp al,#0x8
- jnz inpnobs
- or bx,bx
- jz inperr
- mov si,#delchar
- call prnstr
- add cl,#4
- mov ch,cl
- mov cl,#0xC
- sub cl,ch
- mov ax,#0xFFFF
- shr ax,cl
- not ax
- and bx,ax
- mov cl,ch
- inploop1:jmp inploop
- inpnobs:cmp al,#0x0D
- jnz inpnocr
- or bx,bx
- jz inpdone
- cmp cl,#-4
- jz inpdone
- inperr: mov al,#7
- jmp inpecho
- inpnocr:cmp al,#0x15
- jnz inpnokl
- mov si,di
- call prnstr
- jmp inprest
- inpnokl:cmp cl,#-4
- jz inperr
- cmp al,#0x30
- jb inperr
- ja inpdig
- or bx,bx
- jz inperr
- inpdig: cmp al,#0x39
- ja inpnodg
- mov ch,al
- sub al,#0x30
- inpnum: xor ah,ah
- shl ax,cl
- add ax,bx
- test ax,#0x1FF
- jnz inperr
- cmp ax,#SEGHIGH
- jae inperr
- cmp ax,#SEGLOW
- jae inpok
- cmp cl,#0xC
- jnz inperr
- cmp ax,#0xC000
- jb inperr
- inpok: mov bx,ax
- sub cl,#4
- mov al,ch
- inpecho:call prnchr
- jmp inploop1
- inpnodg:and al,#0xDF
- cmp al,#0x41
- jb inperr
- cmp al,#0x46
- ja inperr
- mov ch,al
- sub al,#0x37
- jmp inpnum
- inpdone:or bx,bx
- jnz probe
- mov si,#automsg
- call prnstr
- mov cx,#0x10
- mov bx,#SEGHIGH
- autoprb:sub bx,#0x0200
- mov di,bx
- call readid
- cmp ax,#AMD_ID
- jz prbfnd
- loop autoprb
- mov si,#failmsg
- nofnd: mov di,#clrline2
- jmp near inpnew
- probe: mov di,bx
- test bx,#0x07FF
- jz noalign
- call readid
- cmp ax,#AMD_ID
- jz prbfnd
- mov si,#alignmsg
- call prnstr
- and bx,#0xF800
- noalign:call readid
- cmp ax,#AMD_ID
- jz prbfnd
- mov si,#nofndmsg
- call prnstr
- mov si,#basemsg
- jmp nofnd
- prbfnd: mov si,#fndmsg
- call prnstr
- mov ax,bx
- call prnwrd
- mov si,#ersmsg
- call prnstr
- call erase
- jnc ersdone
- mov si,#failresmsg
- jmp near reset
- ersdone:mov si,#prg1msg
- call prnstr
- mov ax,di
- call prnwrd
- mov si,#prg2msg
- call prnstr
- xor dh,dh
- mov dl,romdata+2
- shl dx,#1
- mov ah,dh
- mov cl,#4
- shl ah,cl
- xor al,al
- add ax,di
- call prnwrd
- mov al,#0x3A
- call prnchr
- mov ah,dl
- xor al,al
- dec ax
- call prnwrd
- mov al,#0x20
- call prnchr
- mov dh,romdata+2
- push ds
- mov ax,ds
- add ax,#romdata>>4
- mov ds,ax
- prgloop:mov cx,#0x200
- xor si,si
- xor bp,bp
- call program
- jc prgerr
- mov ax,ds
- add ax,#0x20
- mov ds,ax
- add di,#0x20
- dec dh
- jnz prgloop
- pop ds
- mov si,#donemsg
- prgdone:call prnstr
- mov si,#resetmsg
- jmp near reset
- prgerr: pop ds
- mov si,#failresmsg
- jmp prgdone
-
-
-
-
-
-
-
-
-
- readid: mov dl,#RESET_CMD
- call sendop
- mov dl,#READID_CMD
- call sendop
- mov es,bx
- seg es
- mov ax,0x00
- mov dl,#RESET_CMD
- jmp sendop
-
-
-
-
-
-
-
-
-
- erase: mov dl,#ERASE1_CMD
- call sendop
- mov dl,#ERASE2_CMD
- call sendop
- xor bp,bp
- mov al,#0xFF
- push di
- mov di,bx
- call waitop
- pop di
- jnc erfail
- mov dl,#RESET_CMD
- call sendop
- stc
- erfail: ret
-
-
-
-
-
-
-
-
-
- program:mov dl,#PROG_CMD
- call sendop
- lodsb
- mov es,di
- seg es
- mov byte ptr [bp],al
- call waitop
- jc progdn
- inc bp
- loop program
- clc
- progdn: ret
-
-
-
-
-
-
-
-
-
- sendop: mov es,bx
- seg es
- mov byte ptr 0x5555,#0xAA
- jcxz so1
- so1: jcxz so2
- so2: seg es
- mov byte ptr 0x2AAA,#0x55
- jcxz so3
- so3: jcxz so4
- so4: seg es
- mov byte ptr 0x5555,dl
- ret
-
-
-
-
-
-
-
-
-
-
-
- waitop: and al,#0x80
- mov es,di
- wait1: seg es
- mov ah,byte ptr [bp]
- mov dl,ah
- and ah,#0x80
- cmp al,ah
- je waitok
- test dl,#0x20
- jz wait1
- seg es
- mov ah,byte ptr [bp]
- and ah,#0x80
- cmp al,ah
- je waitok
- stc
- ret
- waitok: clc
- ret
-
-
-
-
-
-
-
-
- prnstr: push si
- cld
- prns1: lodsb
- or al,al
- jz prns2
- call prnchr
- jmp prns1
- prns2: pop si
- ret
-
-
-
-
-
-
-
-
-
- prnwrd: push ax
- mov al,ah
- call prnbyt
- pop ax
- prnbyt: push ax
- shr al,1
- shr al,1
- shr al,1
- shr al,1
- call prnnib
- pop ax
- prnnib: and al,#0x0F
- add al,#0x30
- cmp al,#0x39
- jle prnchr
- add al,#7
- prnchr: push bx
- mov ah,#0x0E
- mov bl,#0x07
- xor bh,bh
- int 0x10
- pop bx
- ret
-
-
-
-
- magic: .byte 0xE4,0xE4
-
- badmagic:.byte 0xa,0xd
- .ascii "There does not appear to be a ROM image attached to the"
- .ascii "flash EPROM utility;"
- .byte 0xa,0xd
- resetmsg:.ascii "Reboot to proceed..."
- .byte 0
-
- welcome:.byte 0xa,0xd
- .ascii "Flash EPROM programming utility V1.0"
- .byte 0xa,0xd
- .ascii "Copyright (c) 1997 by M. Gutschke <gutschk@uni-muenster.de>"
- .byte 0xa,0xd
- .ascii "==========================================================="
- .byte 0xa,0xd
- prompt: .byte 0xa,0xd
- .ascii "Enter base address for AMD29F010 flash EPROM on FlashCard or"
- .byte 0xa,0xd
- .ascii "press <RETURN> to start autoprobing; the base address has"
- .byte 0xa
- clrline1:.byte 0xd
- .ascii "to be in the range C800..E600: "
- .ascii " "
- .byte 0x8,0x8,0x8,0x8
- .byte 0
-
- delchar:.byte 0x8,0x20,0x8
- .byte 0
-
- automsg:.ascii "autoprobing... "
- .byte 0
-
- failmsg:.ascii "failed!"
- basemsg:.byte 0xa
- clrline2:.byte 0xd
- .ascii "Enter base address: "
- .ascii " "
- .byte 0x8,0x8,0x8,0x8
- .byte 0
-
- fndmsg: .byte 0xa,0xd
- .ascii "Found flash EPROM at: "
- .byte 0
-
- alignmsg:.byte 0xa,0xd
- .ascii "FlashCard requires the hardware address to be aligned to a"
- .byte 0xa,0xd
- .ascii "32kB boundary; automatically adjusting..."
- .byte 0
-
- nofndmsg:.byte 0xa,0xd
- .ascii "No AMD29F010 flash EPROM found"
- .byte 0
-
- ersmsg: .byte 0xa,0xd
- .ascii "Erasing old contents... "
- .byte 0
-
- prg1msg:.ascii "done"
- .byte 0xa,0xd
- .ascii "Programming from "
- .byte 0
-
- prg2msg:.ascii ":0000 to "
- .byte 0
-
- donemsg:.ascii "done!"
- .byte 0xa,0xd
- .byte 0
-
- failresmsg:
- .ascii "failed!"
- .byte 0xa,0xd
- .byte 0
-
-
-
-
- .align 16
- .org *-1
- .byte 0x00
- romdata:
|