Changeset 5144


Ignore:
Timestamp:
Feb 22, 2010 1:58:01 PM (3 years ago)
Author:
oxygene
Message:
  • 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@…>
Acked-by: Peter Stuge <peter@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/arch/i386/lib/walkcbfs.S

    r4994 r5144  
    2929*/ 
    3030walkcbfs: 
     31        cld 
     32 
    3133        mov CBFS_HEADER_PTR, %eax 
    3234        mov CBFS_HEADER_ROMSIZE(%eax), %ecx 
     
    4850        add $1, %eax 
    4951walker: 
     52        mov 0(%ebx), %edi 
     53        cmp %edi, filemagic 
     54        jne searchfile 
     55        mov 4(%ebx), %edi 
     56        cmp %edi, filemagic+4 
     57        jne searchfile 
     58 
    5059        mov %ebx, %edi 
    5160        add $CBFS_FILE_STRUCTSIZE, %edi /* edi = address of first byte after struct cbfs_file */ 
     
    6473 
    6574tryharder: 
    66         sub %ebx, %edi /* edi = # of walked bytes */ 
     75        sub %ebx, %edi 
     76        sub $CBFS_FILE_STRUCTSIZE, %edi /* edi = # of walked bytes */ 
    6777        sub %edi, %esi /* esi = start of filename */ 
    6878 
     
    7484        bswap %edi 
    7585        add %edi, %ecx 
    76         mov CBFS_HEADER_PTR, %ebx 
    77         mov CBFS_HEADER_ALIGN(%ebx), %ebx 
    78         bswap %ebx 
    79         sub $1, %ebx 
    80         add %ebx, %ecx 
    81         mov %ebx, %edi 
     86        mov CBFS_HEADER_PTR, %edi 
     87        mov CBFS_HEADER_ALIGN(%edi), %edi 
     88        bswap %edi 
     89        sub $1, %edi 
     90        add %edi, %ecx 
    8291        not %edi 
    8392        and %edi, %ecx 
     93 
     94        /* if oldaddr >= addr, leave */ 
     95        cmp %ebx, %ecx 
     96        jbe out 
     97 
    8498        mov %ecx, %ebx 
    8599 
    86         /* look if we should exit */ 
     100check_for_exit: 
     101        /* look if we should exit: did we pass into the bootblock already? */ 
    87102        mov CBFS_HEADER_PTR, %ecx 
    88         mov CBFS_HEADER_ROMSIZE(%ecx), %ecx 
     103        mov CBFS_HEADER_BOOTBLOCKSIZE(%ecx), %ecx 
    89104        bswap %ecx 
    90105        not %ecx 
    91106        add $1, %ecx 
    92107 
    93         cmp %ebx, %ecx 
    94         /* if we're still inside the ROM area, jump back */ 
     108        cmp %ecx, %ebx 
     109        /* if bootblockstart >= addr (==we're still in the data area) , jump back */ 
    95110        jbe walker 
    96111 
     112out: 
    97113        mov $0, %eax 
    98114        jmp *%esp 
     115 
     116 
     117searchfile: 
     118        /* if filemagic isn't found, move forward cbfs_header->align bytes */ 
     119        mov CBFS_HEADER_PTR, %edi 
     120        mov CBFS_HEADER_ALIGN(%edi), %edi 
     121        bswap %edi 
     122        add %edi, %ebx 
     123        jmp check_for_exit 
     124 
     125filemagic: 
     126        .ascii "LARCHIVE" 
Note: See TracChangeset for help on using the changeset viewer.