diff options
author | Patrick Georgi <patrick.georgi@coresystems.de> | 2010-02-22 12:58:01 +0000 |
---|---|---|
committer | Patrick Georgi <patrick.georgi@coresystems.de> | 2010-02-22 12:58:01 +0000 |
commit | f6fbfafbba2ed8b6ea87f19d485ddd53e75b6c6a (patch) | |
tree | 398852723909a46b8ac8c5110b1a3f9abb5ea3d3 | |
parent | 44ca39f0743c277a705aa7746e8646f2df979612 (diff) |
- Make walkcbfs capable of loading files other than the first
- Look more closely for files, which should make the code robust
against defective CBFS images, as long as the bootblock is usable.
Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Peter Stuge <peter@stuge.se>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5144 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r-- | src/arch/i386/lib/walkcbfs.S | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/src/arch/i386/lib/walkcbfs.S b/src/arch/i386/lib/walkcbfs.S index d043af5690..395c46e20c 100644 --- a/src/arch/i386/lib/walkcbfs.S +++ b/src/arch/i386/lib/walkcbfs.S @@ -28,6 +28,8 @@ clobbers %ebx, %ecx, %edi */ walkcbfs: + cld + mov CBFS_HEADER_PTR, %eax mov CBFS_HEADER_ROMSIZE(%eax), %ecx bswap %ecx @@ -47,6 +49,13 @@ walkcbfs: 2: add $1, %eax walker: + mov 0(%ebx), %edi + cmp %edi, filemagic + jne searchfile + mov 4(%ebx), %edi + cmp %edi, filemagic+4 + jne searchfile + mov %ebx, %edi add $CBFS_FILE_STRUCTSIZE, %edi /* edi = address of first byte after struct cbfs_file */ mov %eax, %ecx @@ -63,7 +72,8 @@ walker: jmp *%esp tryharder: - sub %ebx, %edi /* edi = # of walked bytes */ + sub %ebx, %edi + sub $CBFS_FILE_STRUCTSIZE, %edi /* edi = # of walked bytes */ sub %edi, %esi /* esi = start of filename */ /* ebx = ecx = (current+offset+len+ALIGN-1) & ~(ALIGN-1) */ @@ -73,26 +83,44 @@ tryharder: mov CBFS_FILE_LEN(%ebx), %edi bswap %edi add %edi, %ecx - mov CBFS_HEADER_PTR, %ebx - mov CBFS_HEADER_ALIGN(%ebx), %ebx - bswap %ebx - sub $1, %ebx - add %ebx, %ecx - mov %ebx, %edi + mov CBFS_HEADER_PTR, %edi + mov CBFS_HEADER_ALIGN(%edi), %edi + bswap %edi + sub $1, %edi + add %edi, %ecx not %edi and %edi, %ecx + + /* if oldaddr >= addr, leave */ + cmp %ebx, %ecx + jbe out + mov %ecx, %ebx - /* look if we should exit */ +check_for_exit: + /* look if we should exit: did we pass into the bootblock already? */ mov CBFS_HEADER_PTR, %ecx - mov CBFS_HEADER_ROMSIZE(%ecx), %ecx + mov CBFS_HEADER_BOOTBLOCKSIZE(%ecx), %ecx bswap %ecx not %ecx add $1, %ecx - cmp %ebx, %ecx - /* if we're still inside the ROM area, jump back */ + cmp %ecx, %ebx + /* if bootblockstart >= addr (==we're still in the data area) , jump back */ jbe walker +out: mov $0, %eax jmp *%esp + + +searchfile: + /* if filemagic isn't found, move forward cbfs_header->align bytes */ + mov CBFS_HEADER_PTR, %edi + mov CBFS_HEADER_ALIGN(%edi), %edi + bswap %edi + add %edi, %ebx + jmp check_for_exit + +filemagic: + .ascii "LARCHIVE" |