Skip to contentSkip to conversation

x86: Support booting SeaBIOS

PATCH New Bin Meng 2 participants 8 messages Feb 29, 2016 – Mar 11, 2016 x86

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

v2 cover x86: Support booting SeaBIOS

This is the initial attempt to support booting SeaBIOS from U-Boot.

This is tested:
- On Intel Crown Bay board with a PCIe graphics card, booting SeaBIOS then chain-loading a GRUB on a USB drive, then Linux kernel finally.
- On QEMU x86 target with U-Boot chain-loading SeaBIOS to install/boot a Windows XP OS.

This series is available on u-boot-x86/seabios-working.

Previous RFC patch @ http://patchwork.ozlabs.org/patch/523764/

Changes in v2:
- Drop patches which were already applied
- Add more detailed information for testing QEMU/SeaBIOS (eg: how to create 'disk.img')

Bin Meng (3):
x86: Support booting SeaBIOS
x86: qemu: Enable ACPI table generation by default
x86: Document how to play with SeaBIOS

 arch/x86/Kconfig              | 10 ++++++++
 arch/x86/include/asm/tables.h |  3 +++
 arch/x86/lib/tables.c         | 15 ++++++++++++
 configs/qemu-x86_defconfig    |  1 +
 doc/README.x86                | 57 +++++++++++++++++++++++++++++++++++++++++--
 5 files changed, 84 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.2.1
author
#1 lore raw

PATCH v2 1/3 x86: Support booting SeaBIOS

SeaBIOS is an open source implementation of a 16-bit x86 BIOS. It can run in an emulator or natively on x86 hardware with the use of coreboot. With SeaBIOS's help, we can boot some OSes that require 16-bit BIOS services like Windows/DOS.

As U-Boot, we have to manually create a table where SeaBIOS gets system information (eg: E820) from. The table unfortunately has to follow the coreboot table format as SeaBIOS currently supports booting as a coreboot payload.

---

Changes in v2: None

 arch/x86/Kconfig              | 10 ++++++++++
 arch/x86/include/asm/tables.h |  3 +++
 arch/x86/lib/tables.c         | 15 +++++++++++++++
 3 files changed, 28 insertions(+)
arch/x86/Kconfig +10 -0
index a0bd344..5fad794 100644
@@ -449,6 +449,16 @@ config I8042_KEYB
 config DM_KEYBOARD
 	default y
 
+config SEABIOS
+	bool "Support booting SeaBIOS"
+	help
+	  SeaBIOS is an open source implementation of a 16-bit X86 BIOS.
+	  It can run in an emulator or natively on X86 hardware with the use
+	  of coreboot/U-Boot. By turning on this option, U-Boot prepares
+	  all the configuration tables that are necessary to boot SeaBIOS.
+
+	  Check http://www.seabios.org/SeaBIOS for details.
+
 source "arch/x86/lib/efi/Kconfig"
 
 endmenu
arch/x86/include/asm/tables.h +3 -0
index 9e6754f..ae9f0d0 100644
@@ -16,6 +16,9 @@
 
 #define ROM_TABLE_ALIGN	1024
 
+/* SeaBIOS expects coreboot tables at address range 0x0000-0x1000 */
+#define CB_TABLE_ADDR	0x800
+
 /**
  * table_compute_checksum() - Compute a table checksum
  *
arch/x86/lib/tables.c +15 -0
index eccef8a..a156f2c 100644
@@ -10,6 +10,7 @@
 #include <asm/smbios.h>
 #include <asm/tables.h>
 #include <asm/acpi_table.h>
+#include <asm/coreboot_tables.h>
 
 /**
  * Function prototype to write a specific configuration table
@@ -67,22 +68,36 @@ void write_tables(void)
 {
 	u32 rom_table_start = ROM_TABLE_ADDR;
 	u32 rom_table_end;
+#ifdef CONFIG_SEABIOS
 	u32 high_table, table_size;
+	struct memory_area cfg_tables[ARRAY_SIZE(table_write_funcs) + 1];
+#endif
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(table_write_funcs); i++) {
 		rom_table_end = table_write_funcs[i](rom_table_start);
 		rom_table_end = ALIGN(rom_table_end, ROM_TABLE_ALIGN);
 
+#ifdef CONFIG_SEABIOS
 		table_size = rom_table_end - rom_table_start;
 		high_table = (u32)memalign(ROM_TABLE_ALIGN, table_size);
 		if (high_table) {
 			memset((void *)high_table, 0, table_size);
 			table_write_funcs[i](high_table);
+
+			cfg_tables[i].start = high_table;
+			cfg_tables[i].size = table_size;
 		} else {
 			printf("%d: no memory for configuration tables\n", i);
 		}
+#endif
 
 		rom_table_start = rom_table_end;
 	}
+
+#ifdef CONFIG_SEABIOS
+	/* make sure the last item is zero */
+	cfg_tables[i].size = 0;
+	write_coreboot_table(CB_TABLE_ADDR, cfg_tables);
+#endif
 }
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH v2 1/3 x86: Support booting SeaBIOS

Quoted 11 lines · Bin Meng

SeaBIOS is an open source implementation of a 16-bit x86 BIOS. It can run in an emulator or natively on x86 hardware with the use of coreboot. With SeaBIOS's help, we can boot some OSes that require 16-bit BIOS services like Windows/DOS.

As U-Boot, we have to manually create a table where SeaBIOS gets system information (eg: E820) from. The table unfortunately has to follow the coreboot table format as SeaBIOS currently supports booting as a coreboot payload.

Quoted 8 lines

---

Changes in v2: None

 arch/x86/Kconfig              | 10 ++++++++++
 arch/x86/include/asm/tables.h |  3 +++
 arch/x86/lib/tables.c         | 15 +++++++++++++++
 3 files changed, 28 insertions(+)
author
#3 lore raw

PATCH v2 1/3 x86: Support booting SeaBIOS

Quoted 14 lines · Simon Glass
Quoted 13 lines · Bin Meng

SeaBIOS is an open source implementation of a 16-bit x86 BIOS. It can run in an emulator or natively on x86 hardware with the use of coreboot. With SeaBIOS's help, we can boot some OSes that require 16-bit BIOS services like Windows/DOS.

As U-Boot, we have to manually create a table where SeaBIOS gets system information (eg: E820) from. The table unfortunately has to follow the coreboot table format as SeaBIOS currently supports booting as a coreboot payload.

---

Quoted 8 lines
Quoted 6 lines

Changes in v2: None

 arch/x86/Kconfig              | 10 ++++++++++
 arch/x86/include/asm/tables.h |  3 +++
 arch/x86/lib/tables.c         | 15 +++++++++++++++
 3 files changed, 28 insertions(+)

applied to u-boot-x86/next, thanks!

author
#4 lore raw

PATCH v2 2/3 x86: qemu: Enable ACPI table generation by default

In reply to Bin Meng

Now that ACPI is supported on QEMU, enable it.

---

Changes in v2: None

 configs/qemu-x86_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/qemu-x86_defconfig +1 -0
index b0c935c..f0e6512 100644
@@ -4,6 +4,7 @@ CONFIG_SMP=y
 CONFIG_MAX_CPUS=2
 CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
+CONFIG_GENERATE_ACPI_TABLE=y
 CONFIG_CMD_CPU=y
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
Signature · 1 line
1.8.2.1
author
#5 lore raw

PATCH v2 2/3 x86: qemu: Enable ACPI table generation by default

Quoted 11 lines · Bin Meng

Now that ACPI is supported on QEMU, enable it.

---

Changes in v2: None

 configs/qemu-x86_defconfig | 1 +
 1 file changed, 1 insertion(+)

applied to u-boot-x86/next, thanks!

author
#6 lore raw

PATCH v2 3/3 x86: Document how to play with SeaBIOS

In reply to Bin Meng

Boting SeaBIOS is done via U-Boot's bootelf command. Document this.

---

Changes in v2:
- Drop patches which were already applied
- Add more detailed information for testing QEMU/SeaBIOS (eg: how to create 'disk.img')

 doc/README.x86 | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)
doc/README.x86 +55 -2
index d3fea5d..41acf0b 100644
@@ -669,6 +669,58 @@ environment variables if you add this to minnowmax.h:
 #undef CONFIG_EXTRA_ENV_SETTINGS
 #define CONFIG_EXTRA_ENV_SETTINGS "boot=zboot 03000000 0 04000000 ${filesize}"
 
+Test with SeaBIOS
+-----------------
+SeaBIOS [14] is an open source implementation of a 16-bit x86 BIOS. It can run
+in an emulator or natively on x86 hardware with the use of U-Boot. With its
+help, we can boot some OSes that require 16-bit BIOS services like Windows/DOS.
+
+As U-Boot, we have to manually create a table where SeaBIOS gets various system
+information (eg: E820) from. The table unfortunately has to follow the coreboot
+table format as SeaBIOS currently supports booting as a coreboot payload.
+
+To support loading SeaBIOS, U-Boot should be built with CONFIG_SEABIOS on.
+Booting SeaBIOS is done via U-Boot's bootelf command, like below:
+
+   => tftp bios.bin.elf;bootelf
+   Using e1000#0 device
+   TFTP from server 10.10.0.100; our IP address is 10.10.0.108
+   ...
+   Bytes transferred = 122124 (1dd0c hex)
+   ## Starting application at 0x000ff06e ...
+   SeaBIOS (version rel-1.9.0)
+   ...
+
+bios.bin.elf is the SeaBIOS image built from SeaBIOS source tree.
+Make sure it is built as follows:
+
+   $ make menuconfig
+
+Inside the "General Features" menu, select "Build for coreboot" as the
+"Build Target". Inside the "Debugging" menu, turn on "Serial port debugging"
+so that we can see something as soon as SeaBIOS boots. Leave other options
+as in their default state. Then,
+
+   $ make
+   ...
+   Total size: 121888  Fixed: 66496  Free: 9184 (used 93.0% of 128KiB rom)
+   Creating out/bios.bin.elf
+
+Currently this is tested on QEMU x86 target with U-Boot chain-loading SeaBIOS
+to install/boot a Windows XP OS (below for example command to install Windows).
+
+   # Create a 10G disk.img as the virtual hard disk
+   $ qemu-img create -f qcow2 disk.img 10G
+
+   # Install a Windows XP OS from an ISO image 'winxp.iso'
+   $ qemu-system-i386 -serial stdio -bios u-boot.rom -hda disk.img -cdrom winxp.iso -smp 2 -m 512
+
+   # Boot a Windows XP OS installed on the virutal hard disk
+   $ qemu-system-i386 -serial stdio -bios u-boot.rom -hda disk.img -smp 2 -m 512
+
+This is also tested on Intel Crown Bay board with a PCIe graphics card, booting
+SeaBIOS then chain-loading a GRUB on a USB drive, then Linux kernel finally.
+
 
 Development Flow
 ----------------
@@ -736,7 +788,7 @@ debug serial port may be useful here. See setup_internal_uart() for an example.
 During the U-Boot porting, one of the important steps is to write correct PIRQ
 routing information in the board device tree. Without it, device drivers in the
 Linux kernel won't function correctly due to interrupt is not working. Please
-refer to U-Boot doc [14] for the device tree bindings of Intel interrupt router.
+refer to U-Boot doc [15] for the device tree bindings of Intel interrupt router.
 Here we have more details on the intel,pirq-routing property below.
 
 	intel,pirq-routing = <
@@ -833,4 +885,5 @@ References
 [11] https://en.wikipedia.org/wiki/GUID_Partition_Table
 [12] http://events.linuxfoundation.org/sites/events/files/slides/chromeos_and_diy_vboot_0.pdf
 [13] http://events.linuxfoundation.org/sites/events/files/slides/elce-2014.pdf
-[14] doc/device-tree-bindings/misc/intel,irq-router.txt
+[14] http://www.seabios.org/SeaBIOS
+[15] doc/device-tree-bindings/misc/intel,irq-router.txt
Signature · 1 line
1.8.2.1
author
#7 lore raw

PATCH v2 3/3 x86: Document how to play with SeaBIOS

Quoted 7 lines · Bin Meng

Boting SeaBIOS is done via U-Boot's bootelf command. Document this.

---

Quoted 8 lines

Changes in v2:
- Drop patches which were already applied
- Add more detailed information for testing QEMU/SeaBIOS (eg: how to create 'disk.img')

 doc/README.x86 | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

applied to u-boot-x86/next, thanks!