- 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
This commit is contained in:
Patrick Georgi 2010-02-22 12:58:01 +00:00
parent 44ca39f074
commit f6fbfafbba
1 changed files with 39 additions and 11 deletions

View File

@ -28,6 +28,8 @@
clobbers %ebx, %ecx, %edi clobbers %ebx, %ecx, %edi
*/ */
walkcbfs: walkcbfs:
cld
mov CBFS_HEADER_PTR, %eax mov CBFS_HEADER_PTR, %eax
mov CBFS_HEADER_ROMSIZE(%eax), %ecx mov CBFS_HEADER_ROMSIZE(%eax), %ecx
bswap %ecx bswap %ecx
@ -47,6 +49,13 @@ walkcbfs:
2: 2:
add $1, %eax add $1, %eax
walker: walker:
mov 0(%ebx), %edi
cmp %edi, filemagic
jne searchfile
mov 4(%ebx), %edi
cmp %edi, filemagic+4
jne searchfile
mov %ebx, %edi mov %ebx, %edi
add $CBFS_FILE_STRUCTSIZE, %edi /* edi = address of first byte after struct cbfs_file */ add $CBFS_FILE_STRUCTSIZE, %edi /* edi = address of first byte after struct cbfs_file */
mov %eax, %ecx mov %eax, %ecx
@ -63,7 +72,8 @@ walker:
jmp *%esp jmp *%esp
tryharder: 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 */ sub %edi, %esi /* esi = start of filename */
/* ebx = ecx = (current+offset+len+ALIGN-1) & ~(ALIGN-1) */ /* ebx = ecx = (current+offset+len+ALIGN-1) & ~(ALIGN-1) */
@ -73,26 +83,44 @@ tryharder:
mov CBFS_FILE_LEN(%ebx), %edi mov CBFS_FILE_LEN(%ebx), %edi
bswap %edi bswap %edi
add %edi, %ecx add %edi, %ecx
mov CBFS_HEADER_PTR, %ebx mov CBFS_HEADER_PTR, %edi
mov CBFS_HEADER_ALIGN(%ebx), %ebx mov CBFS_HEADER_ALIGN(%edi), %edi
bswap %ebx bswap %edi
sub $1, %ebx sub $1, %edi
add %ebx, %ecx add %edi, %ecx
mov %ebx, %edi
not %edi not %edi
and %edi, %ecx and %edi, %ecx
/* if oldaddr >= addr, leave */
cmp %ebx, %ecx
jbe out
mov %ecx, %ebx 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_PTR, %ecx
mov CBFS_HEADER_ROMSIZE(%ecx), %ecx mov CBFS_HEADER_BOOTBLOCKSIZE(%ecx), %ecx
bswap %ecx bswap %ecx
not %ecx not %ecx
add $1, %ecx add $1, %ecx
cmp %ebx, %ecx cmp %ecx, %ebx
/* if we're still inside the ROM area, jump back */ /* if bootblockstart >= addr (==we're still in the data area) , jump back */
jbe walker jbe walker
out:
mov $0, %eax mov $0, %eax
jmp *%esp 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"