Author: wmb
Date: 2007-08-01 05:15:29 +0200 (Wed, 01 Aug 2007)
New Revision: 509
Modified:
cpu/x86/pc/biosload/addrs.fth
cpu/x86/pc/biosload/config.fth
cpu/x86/pc/biosload/fw.bth
cpu/x86/pc/biosload/ofw.bth
cpu/x86/pc/elfhdr.fth
cpu/x86/pc/resetend.fth
Log:
Patch from Jens Freimann to support running OFW under LinuxBIOS on QEMU.
Modified: cpu/x86/pc/biosload/addrs.fth
===================================================================
--- cpu/x86/pc/biosload/addrs.fth 2007-08-01 03:13:15 UTC (rev 508)
+++ cpu/x86/pc/biosload/addrs.fth 2007-08-01 03:15:29 UTC (rev 509)
@@ -9,9 +9,15 @@
\ copies it to get it out of the way of things like OS load areas.
[ifdef] linuxbios-loaded
-h# fff8.0000 constant dropin-base \ Location of payload in FLASH
-h# 08.0000 constant dropin-size
-dropin-base h# 80 + h# 20 + constant ResetBase \ Location of "reset" dropin in ROM
+ [ifdef] qemu-loaded
+ \ when running in qemu OFW is not in ROM but loaded to RAM by elfboot
+ h# 198.0080 constant dropin-base \ Location of payload in RAM
+ dropin-base h# 20 + constant ResetBase \ Location of "reset" dropin in RAM
+ [else]
+ h# fff8.0000 constant dropin-base \ Location of payload in FLASH
+ dropin-base h# 80 + h# 20 + constant ResetBase \ Location of "reset" dropin in ROM
+ [then]
+ h# 08.0000 constant dropin-size
[then]
\needs dropin-base h# 198.0000 constant dropin-base
Modified: cpu/x86/pc/biosload/config.fth
===================================================================
--- cpu/x86/pc/biosload/config.fth 2007-08-01 03:13:15 UTC (rev 508)
+++ cpu/x86/pc/biosload/config.fth 2007-08-01 03:15:29 UTC (rev 509)
@@ -21,6 +21,9 @@
\ - ELF format (no pheader) - ROM - LinuxBIOS direct
\ create linuxbios-loaded
+\ Load and run in qemu
+\ create qemu-loaded
+
[ifdef] pc-serial
create serial-console
create pc
Modified: cpu/x86/pc/biosload/fw.bth
===================================================================
--- cpu/x86/pc/biosload/fw.bth 2007-08-01 03:13:15 UTC (rev 508)
+++ cpu/x86/pc/biosload/fw.bth 2007-08-01 03:15:29 UTC (rev 509)
@@ -257,7 +257,10 @@
auto-banner? if
" Probing" ?type probe-all
+ \ install-console doesn't work with qemu, use -serial `tty` instead
+ [ifndef] qemu-loaded
" Install console" ?type install-console
+ [then]
banner
then
Modified: cpu/x86/pc/biosload/ofw.bth
===================================================================
--- cpu/x86/pc/biosload/ofw.bth 2007-08-01 03:13:15 UTC (rev 508)
+++ cpu/x86/pc/biosload/ofw.bth 2007-08-01 03:15:29 UTC (rev 509)
@@ -32,21 +32,25 @@
[ifdef] grub-loaded
fload ${BP}/cpu/x86/pc/elfhdr.fth
-[ifdef] etherboot-variant
- .( --- Saving as ofwnet.elf - GRUB multiboot format) cr
- writing ofwnet.elf
-[else]
- .( --- Saving as ofwgrub.elf - GRUB multiboot format) cr
- writing ofwgrub.elf
+ [ifdef] etherboot-variant
+ .( --- Saving as ofwnet.elf - GRUB multiboot format) cr
+ writing ofwnet.elf
+ [else]
+ .( --- Saving as ofwgrub.elf - GRUB multiboot format) cr
+ writing ofwgrub.elf
+ [then]
+ elf-header /elf-header ofd @ fputs
[then]
- elf-header /elf-header ofd @ fputs
-[then]
[ifdef] linuxbios-loaded
.( --- Saving as ofwlb.elf - LinuxBIOS payload format) cr
fload ${BP}/cpu/x86/pc/elfhdr.fth
writing ofwlb.elf
+ [ifdef] qemu-loaded
+ elf-header /elf-header ofd @ fputs
+ [else]
elf-header /elf-header 0 " elf-header" write-dropin
+ [then]
[then]
[ifdef] syslinux-loaded
@@ -118,4 +122,12 @@
pad 4 ofd @ fputs \ Patch file size
pad 4 ofd @ fputs \ Patch memory size
[then]
+
+[ifdef] qemu-loaded
+ ofd @ fsize pad ! \ file size; store in memory for convenience below
+ h# 44 ofd @ fseek \ Seek to file size field; see elfhdr.bth
+ pad 4 ofd @ fputs \ Patch file size
+ pad 4 ofd @ fputs \ Patch memory size
+[then]
+
ofd @ fclose
Modified: cpu/x86/pc/elfhdr.fth
===================================================================
--- cpu/x86/pc/elfhdr.fth 2007-08-01 03:13:15 UTC (rev 508)
+++ cpu/x86/pc/elfhdr.fth 2007-08-01 03:15:29 UTC (rev 509)
@@ -18,6 +18,10 @@
\ elf-header is not a dropin, so we only need to skip OBMD header of reset
\ we adjust the load-address below at position 0x40
dropin-base h# 20 + l, \ 0x18 entry point virtual address
+[then]
+[ifdef] qemu-loaded
+ \ skip OBMD header but keep elf-header because elfboot in LinuxBIOS needs it
+ dropin-base h# 20 + l, \ 0x18 entry point virtual address
[else]
\ Skip this ELF dropin (80) + the OBMD header of the next dropin (20)
dropin-base h# 80 + h# 20 + l, \ 0x18 entry point virtual address
@@ -29,6 +33,9 @@
h# 20 w, \ 0x2a program header table entry size
[ifdef] grub-loaded
1 w, \ 0x2c program header table entry count (one pheader)
+[then]
+[ifdef] qemu-loaded
+ 1 w, \ 0x2c program header table entry count (one pheader)
[else]
0 w, \ 0x2c program header table entry count (no pheaders)
[then]
@@ -41,22 +48,39 @@
1 l, \ 0x34 entry type PT_LOAD
h# 54 l, \ 0x38 file offset
0 l, \ 0x3c vaddr
+[then]
+
+[ifdef] qemu-loaded \ Pheader causes elfboot to copy us to RAM
+ \ 0x34 Pheader
+ 1 l, \ 0x34 entry type PT_LOAD
+ 0 l, \ 0x38 file offset
+ dropin-base 80 - l, \ 0x3c vaddr
+[then]
+
[ifdef] etherboot-variant
\ we need to skip what left of elf-hdr. to get it to point to a dropin
\ why is it 0x14 ? I would have thought it should be the size of the multiboot header
\ which is 0x0c
dropin-base h# 14 - l, \ 0x40 paddr \ Where to put the bits
+[then]
+
+[ifdef] qemu-loaded
+ dropin-base h# 80 - l, \ 0x40 paddr \ Where to put the bits
[else]
dropin-base l, \ 0x40 paddr \ Where to put the bits
[then]
h# ffffffff l, \ 0x44 file size \ backpatched later
h# ffffffff l, \ 0x48 memory size \ backpatched later
+
+[ifndef] qemu-loaded
0 l,
0 l,
+[then]
7 l, \ 0x4c entry flags RWX
0 l, \ 0x50 alignment
\ 0x54 End of pheader
-
+[then]
+[ifdef] grub-loaded
\ "Multiboot" header that GRUB looks for
h# 1BADB002 , \ 0x54
h# 0 , \ 0x58
Modified: cpu/x86/pc/resetend.fth
===================================================================
--- cpu/x86/pc/resetend.fth 2007-08-01 03:13:15 UTC (rev 508)
+++ cpu/x86/pc/resetend.fth 2007-08-01 03:15:29 UTC (rev 509)
@@ -4,6 +4,7 @@
\ The memory layout information from the start dropin is stored in low
\ memory.
+[ifndef] qemu-loaded
\ Move GDT to low memory. We use the first location at gdt-pa as
\ scratch memory for sgdt, and put the actual gdt at gdt-pa + 0x10
gdt-pa # ax mov
@@ -30,10 +31,10 @@
\ Next time segment registers are changed, they will be
\ reloaded from memory.
+ \ qemu hangs when trying to do this
here asm-base - ResetBase + 7 + h# 60 #) far jmp \ 7-byte instruction
\ nop nop nop nop
- h# 20 # al mov al h# 80 # out
\ begin again
h# 68 # ax mov
ax ds mov
@@ -41,7 +42,10 @@
ax fs mov
ax gs mov
ax ss mov
+[then]
+ h# 20 # al mov al h# 80 # out
+
[ifdef] mem-info-pa
gdt-pa /page round-up # ax mov \ Current low-memory high water mark
ax mem-info-pa 2 la+ #) mov \ Store in memory info area