diff options
author | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-10-13 14:56:30 +0200 |
---|---|---|
committer | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-11-17 12:09:57 +0100 |
commit | 174eecc55d178845964c58c48b1db9724232a397 (patch) | |
tree | b049c8699962b5144ead1f68bd8ac9c7a7ff5632 /slof | |
parent | 9d63b7beb2b87436d3a6042fea9127808954fb1c (diff) | |
download | SLOF-174eecc55d178845964c58c48b1db9724232a397.zip SLOF-174eecc55d178845964c58c48b1db9724232a397.tar.gz SLOF-174eecc55d178845964c58c48b1db9724232a397.tar.bz2 |
FCODE: Fixed detection of images in PCI Expansion ROMs.
There were several bugs in the pci-find-rom function that is used to detect
the FCODE in PCI Expansion ROMs. Due to these bugs, it was only able to find
the first image in the ROM. Now the function should also work fine if the
FCODE image is not the first image in the ROM.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Diffstat (limited to 'slof')
-rw-r--r-- | slof/fs/fcode/evaluator.fs | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/slof/fs/fcode/evaluator.fs b/slof/fs/fcode/evaluator.fs index 1434098..21b249c 100644 --- a/slof/fs/fcode/evaluator.fs +++ b/slof/fs/fcode/evaluator.fs @@ -1,5 +1,5 @@ \ ***************************************************************************** -\ * Copyright (c) 2004, 2008 IBM Corporation +\ * Copyright (c) 2004, 2011 IBM Corporation \ * All rights reserved. \ * This program and the accompanying materials \ * are made available under the terms of the BSD License @@ -45,47 +45,59 @@ include tokens.fs : step next-ip fcode@ exec ; immediate ( ---------------------------------------------------- ) -: rom-code-ignored ( image# name len -- ) - diagnostic-mode? IF type ." code found in image " . ." , ignoring ..." cr - ELSE 3drop THEN +: rom-code-ignored ( image-addr name len -- image-addr ) + diagnostic-mode? IF + type ." code found in image " dup . ." , ignoring ..." cr + ELSE + 2drop + THEN ; : pci-find-rom ( baseaddr -- addr ) - -8 and dup IF - dup rw@ 55aa = IF - diagnostic-mode? IF ." Device ROM found at " dup . cr THEN - ELSE drop 0 THEN - THEN + dup IF + dup rw@-le aa55 = IF + diagnostic-mode? IF ." Device ROM header found at " dup . cr THEN + ELSE + drop 0 + THEN + THEN ; : pci-find-fcode ( baseaddr -- addr len | false ) - pci-find-rom ?dup IF - dup 18 + rw@ wbflip + - 0 swap BEGIN - dup rl@ 50434952 ( 'PCIR') <> IF - diagnostic-mode? IF - ." Invalid PCI Data structure, ignoring ROM contents" cr - THEN - 2drop false EXIT - THEN - dup 14 + rb@ CASE - 0 OF over . s" Intel x86 BIOS" rom-code-ignored ENDOF - 1 OF swap diagnostic-mode? IF - ." Open Firmware FCode found at image " . cr - ELSE drop THEN - dup a + rw@ wbflip over + \ This code start - swap 10 + rw@ wbflip 200 * \ This code length - EXIT - ENDOF - 2 OF over . s" HP PA RISC" rom-code-ignored ENDOF - 3 OF over . s" EFI" rom-code-ignored ENDOF - dup OF over . s" Unknown type" rom-code-ignored ENDOF - ENDCASE - dup 15 + rb@ 80 and IF 2drop EXIT THEN \ End of last image - dup 10 + rw@ wbflip 200 * + \ Next image start - swap 1+ swap \ Next image # - 0 UNTIL - THEN false + BEGIN + 1ff NOT and \ Image must start at 512 byte boundary + pci-find-rom dup + WHILE + dup 18 + rw@-le + ( pcir-addr ) + \ Check for PCIR magic ... since pcir-addr might not be + \ 4-byte aligned, we've got to use two reads here: + dup rw@-le 4350 ( 'PC' ) <> ( pcir-addr hasPC? ) + over 2+ rw@-le 5249 ( 'IR' ) <> OR IF + diagnostic-mode? IF + ." Invalid PCI Data structure, ignoring ROM contents" cr + THEN + drop false EXIT + THEN ( pcir-addr ) + dup 14 + rb@ CASE \ Get image code type + 0 OF s" Intel x86 BIOS" rom-code-ignored ENDOF + 1 OF + diagnostic-mode? IF + ." Open Firmware FCode found in image at " dup . cr + THEN + dup 1ff NOT AND \ Back to the ROM image header + dup 2+ rw@-le + \ Pointer to FCODE (PCI bus binding ch.9) + swap 10 + rw@-le 200 * \ Image length + EXIT + ENDOF + 2 OF s" HP PA RISC" rom-code-ignored ENDOF + 3 OF s" EFI" rom-code-ignored ENDOF + dup OF s" Unknown type" rom-code-ignored ENDOF + ENDCASE + dup 15 + rb@ 80 and IF \ End of last image? + drop false EXIT + THEN + dup 10 + rw@-le 200 * + \ Next image start + REPEAT ; : execute-rom-fcode ( addr len | false -- ) |