;This Intel(r) Pentium(r) code is based on the AMD Am29F010B datasheet ;It erases either the complete flash device or one specified sector ;of 4 parallel Am29F010B 8-bit devices (32-bit wide flash bus) ;Protected sectors are not erased ;following paramaters assumed to be passed: ; EBP = Start Address of Sector or Device ; AL = Erase Mode (0 = Chip Erase, 1 = Sector Erase) ;other registers used during algorithm: ; BX = max timeout reg ; CX = timer counter register ; EAX = read back status register ; EDI = datapole register ; ESI= Command Address - 555 from datasheet ; ESP= Command Address - 2AA from datasheet .386P CODE_SEG SEGMENT USE32 ASSUME CS:CODE_SEG,DS:CODE_SEG ;setup usercode breakpoint BreakPoint: JMP BreakPoint ;calculate command addresses ;(multiplied by 4h to account for 4 parallel devices) MOV ESI, EBP ADD ESI, 1554h ; Commmand address offset from datasheet 555h x 4h MOV ESP, EBP ADD ESP, 0AA8h ; Commmand address offset from datasheet 2AAh x 4h ;load max timeout counter value MOV BX, 3FFFh ;check chip(0) or sector(1) erase ;break if neither CMP AL, 0 JE ChipErase CMP AL, 1 JE SectorErase MOV EBP, -2 ; TSL script checks for FFFFFFFE returned - bad param JMP BreakPoint ;begin chip erase in 4 parallel devices ChipErase: MOV DWORD PTR [ESI], 0AAAAAAAAh ; Command Cycle 1 from datasheet MOV DWORD PTR [ESP], 55555555h ; Command Cycle 2 from datasheet MOV DWORD PTR [ESI], 80808080h ; Command Cycle 3 from datasheet MOV DWORD PTR [ESI], 0AAAAAAAAh ; Command Cycle 4 from datasheet MOV DWORD PTR [ESP], 55555555h ; Command Cycle 5 from datasheet MOV DWORD PTR [ESI], 10101010h ; Command Cycle 6 from datasheet MOV EDI, ESI JMP Counter ;begin sector erase in 4 parallel devices SectorErase: MOV DWORD PTR [ESI], 0AAAAAAAAh ; Command Cycle 1 from datasheet MOV DWORD PTR [ESP], 55555555h ; Command Cycle 2 from datasheet MOV DWORD PTR [ESI], 80808080h ; Command Cycle 3 from datasheet MOV DWORD PTR [ESI], 0AAAAAAAAh ; Command Cycle 4 from datasheet MOV DWORD PTR [ESP], 55555555h ; Command Cycle 5 from datasheet MOV DWORD PTR [EBP], 30303030h ; Command Cycle 6 from datasheet MOV EDI, EBP Counter: ;set timeout to be zero MOV CX, 0 DataPoll: ;store current state of dq31:0 and mask for dq31, dq23, dq15, dq7 MOV EAX, [EDI] AND EAX, 80808080h ;check if erase has completed CMP EAX, 80808080h JE Completed ;check for timeout ADD CX, 1 CMP BX, CX JGE DataPoll MOV EBP, -1 ; TSL script checks for FFFFFFFF returned - timeout JMP BreakPoint Completed: ;set flag for successful completion MOV EBP, 0 ; TSL script checks for 0 returned - success JMP BreakPoint ;****************************************************** ;CODE ENDS HERE. ;****************************************************** CODE_SEG ENDS END BreakPoint