www.pudn.com > hpbios.rar > ATMEL020.NVM
; []===========================================================[] ; ; NOTICE: THIS PROGRAM BELONGS TO AWARD SOFTWARE INTERNATIONAL(R) ; INC. IT IS CONSIDERED A TRADE SECRET AND IS NOT TO BE ; DIVULGED OR USED BY PARTIES WHO HAVE NOT RECEIVED ; WRITTEN AUTHORIZATION FROM THE OWNER. ; ; []===========================================================[] ; ;---------------------------------------------------------------------------- ;Rev Date Name Description ;---------------------------------------------------------------------------- ;R06 02/01/00 BAR Added define post flash write use XDGROUP ;R05 12/21/99 BAR Fixed compile error. ;R04 07/07/99 BAR Move all Rxxx . ; Added Retry times when verify error. ;R03 11/30/98 BAR Update ESCD DMI use SMM mode. ; define switch "Flash_IN_SMBASE" ;R02 05/08/98 KEN Modified some codes to correspond to the ESCDCHIP ; modification that using flat mode to update flash ; ROM.(i.e. Don't destroy any segment registers at ; flash ROM reading/writing routines.) ;**************************************************************** ;* * ;* SUBROUTINES TO SUPPORT Atmel FLASH ROM * ;* * ;**************************************************************** WAIT_COUNT EQU 10 ;[]========================================================================[] ; Atmel020_Flash_Erase : ; ; Erase Flash ROM at address FA000h - FBFFFh ; ;Saves : None ;Input : None ; ;Output: CF = 0 , Successful ; CF = 1 , Error Erase ; ;[]========================================================================[] Atmel29C020_Flash_Erase Proc Near clc ret Atmel29C020_Flash_Erase Endp ifndef Flash_IN_SMBASE ;[]====================================================================[] ; Atmel29C020_Flash_Write : ; ; Program Flash ROM at address FA000h - FBFFFh ; ;Saves : ;Input : Source = DS : SI ; Target = ES : DI (Range = FA000h-FBFFFh) ; Length = CX ; ;Output: CF = 0 Successful ; CF = 1 Error Program ; ;[]====================================================================[] Atmel29C020_Flash_Write Proc Near pusha ifndef ESCD_M2 mov al, 0 ;R05 call Software_Data_Protection call AT_Software_Data_Protection ;R05 endif; ESCD_M2 add cx,255 shr cx, 8 ;cx= cx/256 Block_Loop: mov bx,25 Page_Retry_Loop: call Atmel_Page_Write call Atmel_Check_Toggle_Ready ;wait for toggle bit to be ready call Atmel_Page_Verify je short Flash_Write_Ok dec bx jnz Page_Retry_Loop jmp Ct_Flash_Write_Fail Flash_Write_Ok: add si, 256 add di, 256 loop short Block_Loop Ct_Flash_Write_Exit: ifndef ESCD_M2 mov al, 1 ;R05 call Software_Data_Protection call AT_Software_Data_Protection ;R05 endif; ESCD_M2 popa clc ret Ct_Flash_Write_Fail: ifndef ESCD_M2 mov al, 1 ;R05 call Software_Data_Protection call AT_Software_Data_Protection ;R05 endif; ESCD_M2 popa stc ret Atmel29C020_Flash_Write Endp Atmel_Page_Write Proc pusha ifdef ESCD_M2 mov byte ptr gs:[05555h],0AAh mov byte ptr gs:[02AAAh],055h mov byte ptr gs:[05555h],0A0h endif; ESCD_M2 mov cx,256 Page_Write_Loop: lodsb ifNdef POST_FLASH_IN_XGROUP ;R06 mov dx,offset Ct_Set_Flash call dx else; POST_FLASH_IN_XGROUP ;R06 mov byte ptr es:[di], al ;R06 endif; POST_FLASH_IN_XGROUP ;R06 inc di loop short Page_Write_Loop popa ret Atmel_Page_Write endp Atmel_Page_Verify Proc pusha mov cx, 256 Atmel_Page_Verify_Loop: ifNdef POST_FLASH_IN_XGROUP ;R06 mov dx,offset Ct_Get_Flash call dx else; POST_FLASH_IN_XGROUP ;R06 mov al, byte ptr es:[di] ;R06 endif; POST_FLASH_IN_XGROUP ;R06 cmp al, ds:[si] jne short Atmel_Page_Verify_Error inc si inc di loop short Atmel_Page_Verify_Loop cmp al, al Atmel_Page_Verify_Error: popa ret Atmel_Page_Verify endp ;[]====================================================================[] ; Routine Name: Software_Data_Protection ; ; ; ; Purpose: This subroutine will either ENABLE or DISABLE the data ; ; protection feature on the Atmel's 28EE011/28EE010 EEPROM. ; ; See the specification for more information. ; ; ; ; inputs: ; ; ES: ESCD segment/selector ; AL: 1 means ENABLE data protection ; ; AL: 0 means DISABLE data protection ; ; ; ; outputs: ; ; None ; ; ; ; IMPORTANT NOTICE: This version of the software will work with both ; ; ================ the OLD and NEW versions of the 28EE011/010 chips ; ; ; ; The "NEW" version of the chip will use the ; ; following address to perform the programming: ; ; "5555h" and "2AAAh" ; ; ; ; The "OLD" version of the chip will use the ; ; following address to perform the programming: ; ; "15555h" and "AAAAh" ; ; ; ; Since the "15555h" and "AAAAh" addresses will work ; ; for both versions of the chip, we have decided to ; ; use it in the program. ; ; ; ;[]====================================================================[] ifndef ESCD_M2 AT_Software_Data_Protection proc near ;R05 ;R05 Software_Data_Protection proc near mov gs:[05555h], 0AAh ; 1st byte [15555] = AAh mov gs:[02AAAh], 055h ; 2nd byte [0AAAA] = 55h cmp al, 0 ; Disable or Enable data protection? je SDP_Reset ; if ZERO, means disable ; We will trying to ENABLE the data protection on the chip mov gs:[5555h], 0A0h ; 3rd byte [15555] = A0h jmp SDP_Done SDP_Reset: ; We will trying to DISABLE the data protection on the chip mov gs:[05555h], 80h ; 3rd byte [15555] = 80h mov gs:[05555h], 0AAh ; 4th byte [15555] = AAh mov gs:[02AAAh], 055h ; 5th byte [0AAAA] = 55h mov gs:[05555h], 20h ; 6th byte [15555] = 20h SDP_Done: call Atmel_Check_Toggle_Ready ; wait for toggle bit to be ready ret AT_Software_Data_Protection endp ;R05 ;R05Software_Data_Protection endp endif; ESCD_M2 ;[]====================================================================[] ;[]====================================================================[] Atmel_Check_Toggle_Ready proc near push ax push bx push di xor di, di ifNdef POST_FLASH_IN_XGROUP ;R06 mov dx,offset Ct_Get_Flash call dx else; POST_FLASH_IN_XGROUP ;R06 mov al, byte ptr es:[di] ;R06 endif; POST_FLASH_IN_XGROUP ;R06 and al, 40h mov bx, 1000h Atmel_CTR_Tog2: mov ah, al ifNdef POST_FLASH_IN_XGROUP ;R06 mov dx,offset Write_Delay endif; POST_FLASH_IN_XGROUP ;R06 call dx ifdef More_Flash_Wait_Time call dx call dx endif; More_Flash_Wait_Time ifNdef POST_FLASH_IN_XGROUP ;R06 mov dx,offset Ct_Get_Flash call dx else; POST_FLASH_IN_XGROUP ;R06 mov al, byte ptr es:[di] ;R06 endif; POST_FLASH_IN_XGROUP ;R06 and al, 40h cmp al, ah clc je Atmel_CTR_Tog3 dec bx jnz short Atmel_CTR_Tog2 stc Atmel_CTR_Tog3: pop di pop bx pop ax ret Atmel_Check_Toggle_Ready endp else; Flash_IN_SMBASE ;[]====================================================================[] ; Atmel29C020_Flash_Write : ; ; Program Flash ROM at address FFFF8000h - FFFFBFFFh ; ;Saves : ;Input : Source = DS : ESI ; Target = ES : EDI (Range =FFFF8000h-FFFFBFFFh) ; Length = CX ; ;Output: CF = 0 Successful ; CF = 1 Error Program ;[]====================================================================[] public Atmel29C020_Flash_Write Atmel29C020_Flash_Write Proc Near pushad add ecx, 255 shr ecx, 8 ;ecx/256 Next_Block_Loop: mov bx,25 Page_Retry_Loop: call Atmel_Page_Write call Atmel_Check_Toggle_Ready ;wait for toggle bit to be ready call Atmel_Page_Verify je short Page_write_OK dec bx jz short Ct_Flash_Write_Exit jmp Page_Retry_Loop Page_write_OK: stc jne short Ct_Flash_Write_Exit add esi, 256 add edi, 256 loop short Next_Block_Loop clc Ct_Flash_Write_Exit: popad ret Atmel29C020_Flash_Write Endp ;[]========================================[] ;[]========================================[] Atmel_Check_Toggle_Ready proc near pusha xor di, di mov al,byte ptr es:[edi] and al, 40h mov bx, 1000h Atmel_CTR_Tog2: mov ah, al ifdef More_Flash_Wait_Time mov cx,10 ;delay 30 us else; More_Flash_Wait_Time mov cx,3 ;delay 10 us endif; More_Flash_Wait_Time call dx mov al,byte ptr es:[edi] and al, 40h cmp al, ah clc je Atmel_CTR_Tog3 dec bx jnz short Atmel_CTR_Tog2 stc Atmel_CTR_Tog3: popa ret Atmel_Check_Toggle_Ready endp Atmel_Page_Write Proc push cx push esi push edi mov cx, 256 ; We will trying to ENABLE the data protection on the 28EE011/28EE010 chip push esi push edi mov esi,0FFFF5555H mov edi,0FFFFAAAAH mov byte ptr es:[esi],0AAh mov byte ptr es:[edi],055h mov byte ptr es:[esi],0A0h pop edi pop esi Block_loop: mov al,byte ptr ds:[esi] mov byte ptr es:[edi],al inc esi inc edi loop short Block_loop pop edi pop esi pop cx ret Atmel_Page_Write endp Atmel_Page_Verify Proc push cx push esi push edi mov cx, 256 Compare_Loop: mov al,byte ptr es:[edi] cmp al, ds:[esi] jne short Compare_Loop_end inc esi inc edi loop short Compare_Loop cmp al, al ;set flag Compare_Loop_end: pop edi pop esi pop cx ret Atmel_Page_Verify endp endif; Flash_IN_SMBASE