ICE_TEA_BIOS/Board/Oem/L05AlderLakePMultiBoardPkg/PlatformConfig/BiosGuard/BGSL/InsydeBiosGuardSbbRevertScript.bgsl
LCFC\AiXia.Jiang a870bff2f4 1.Frist commit
2022-09-30 14:59:06 +08:00

132 lines
3.4 KiB
Plaintext

Begin
;---------------Do NOT Modify Section-----------
Set I8 0x0; Reserved
Set I9 0x0; Image Size
Set I7 0x0; Image BIOS Offset
Set I5 0x0; Variable Reserved Offset
Set I6 0x0; Varialbe Reserve Size
Set IA 0x0; SBB Reserved Offset
Set IB 0x0; SBB Reserved Size
;---------------Do NOT Modify Section-----------
;Reserve I8 IC ID IE
// ---- Get Bios Base and Limit Process ----
// Referenced SPI Programming Guide
Set I0 0x0; Init I0 for save Bios Base
Set I1 0x0; Init I1 for save Bios limit
Set I2 0x0; Temp
// [Step1] Find FRBA(Flash Region Base Address) offset[23:16] from FLMAP0 (FDBAR+0x14)
Set F0 0x16; Point to offset 0x16 to get FRBA for FLMAP0 [23:16]
Set B1 0x0; Init Buffer1 Offset
Read B1 F0 0x1;
Loadbyte I2 B1;
Shiftl I2 4; FRBA
// [Step2] Get Bios Base and size from FRBA
Set B1 0x0;
Add I2 0x4;
Set F0 I2;
Read B1 F0 0x4;
LoadDword I2 B1; Get Base and limit to I2
Set I0 I2;
Set I1 I2;
// Get BIOS Base for low Endian
And I0 0x00007FFF;
Shiftl I0 0xC;
// Get BIOS Limit for high Endian
And I1 0x7FFF0000;
Shiftr I1 0x10
Add I1 0x1;
Shiftl I1 0xC
// Step3 - Check image in Bios Range
// Check (BIOS Base[I0] + image offset[I7] + image size[I9]) < bios limit[I1]
Add I7 I0;
Set I2 I7;
Add I2 I9;
Compare I2 I1;
Jg _end;
// ---- Flash Process -----
Set I1 0x0; Intit Erase try count
Set I2 0x0; Intit Write try count
Set I3 0x0; Record HW Status
Set I4 0x0; Flash Offset
Set If 0x0; Init HW Status 0:Success
Set B0 0x0;
_Flash_start:
Add I5 I0; Add Variable offset with bios base
Add IA I0; Add reserveed offset with bios base
Jmp _Flash_Loop
_error_label:
Add I1 0x1;
Compare I1 0x3; Check erase error Max try 3 time
Jge _erase_error_report;
Jmp _erase;
_write_label:
Add I2 0x1;
Compare I2 0x3; Check write error Max try 3 time
Jge _write_error_report;
Jmp _erase;
_Flash_Loop:
_SkipVar:
Compare I6 0x0; Check Variable region exist by Size != 0
Je _check_SkipRegion
Compare I7 I5; Check Flash Offset[I7] == Variable Region Offset[I6]
Jne _check_SkipRegion
Add I7 I6;
Add I4 I6;
_check_SkipRegion:
Compare IB 0x0; Check Reserved Region exist By Reserved Size
Je _check_SkipRegion_End;
Compare I7 IA; Check Flash Offset[I4] == Reserved Offset[I8]
Jne _check_SkipRegion_End;
Add I7 IB; Add Reserved Size to skip reserved space.
Add I4 IB;
_check_SkipRegion_End:
Set F0 I7; Set the address in flash where the BIOS image resides
Set B0 I4;
_erase:
Eraseblk F0; Erase
Rdsts I3; Get HW status to I3
Compare I3 0; Check Stats is SUCCESS(0):
Jne _error_label;
_write:
Write F0 B0 0x1000;
Rdsts I3;
Compare I3 0;
Jne _write_label;
_continue:
Set I1 0x0; Clean erase error try count
Set I2 0x0; Clean write error try count
Add I4 0x1000
Compare I4 I9; Check Flash Offset in Bios Limit
Jge _end;
Add I7 0x1000; Increase 0x1000 for Flash Offset
Jmp _Flash_Loop;
_erase_error_report:
Set If 0x1; Set If as 0x1 means Erase failed
Jmp _end;
_write_error_report:
Set If 0x2; Set If as 0x2 means Write failed
Jmp _end;
_end:
End