I started looking at supporting fw_cfg in vmd. Now to make this work with
SeaBIOS there are a few fixes needed. First of all the way it reads the
FW_CFG_DATA port is not supported by vmm(4) (problem whith 'rep insb' on
IO ports). Additionally this cleans up some of the patches which I think
are not needed if the setting of screen-and-debug is changed. At least I
no longer see double printing of messages.
I enabled CONFIG_BOOTORDER because this is what I would like to tweak.
The CONFIG_DEBUG_LEVEL can be taken out before commit but it helped me
debugging this. Once vmd uses fw_cfg more of the patches can be removed.
--
:wq Claudio
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/firmware/vmm/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- Makefile 21 Nov 2018 00:26:05 -0000 1.15
+++ Makefile 9 Dec 2018 11:09:05 -0000
@@ -13,7 +13,7 @@ CC = /usr/bin/gcc
FW_DRIVER= vmm
FW_VER= 1.11.0
SB_VER= 20100422
-REVISION= 0
+REVISION= 1
DISTNAME= seabios-${FW_VER}
DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \
sgabios-20100422{23d474943dcd55d0550a3d20b3d30e9040a4f15b}.tar.gz:0
Index: files/config
===================================================================
RCS file: /cvs/ports/sysutils/firmware/vmm/files/config,v
retrieving revision 1.6
diff -u -p -r1.6 config
--- files/config 11 Jul 2018 09:09:46 -0000 1.6
+++ files/config 7 Dec 2018 20:34:05 -0000
@@ -15,7 +15,7 @@ CONFIG_QEMU_HARDWARE=y
# CONFIG_THREADS is not set
# CONFIG_RELOCATE_INIT is not set
# CONFIG_BOOTMENU is not set
-# CONFIG_BOOTORDER is not set
+CONFIG_BOOTORDER=y
# CONFIG_ENTRY_EXTRASTACK is not set
CONFIG_MALLOC_UPPERMEMORY=y
CONFIG_ROM_SIZE=0
@@ -92,7 +92,7 @@ CONFIG_VGA_EXTRA_STACK_SIZE=512
#
# Debugging
#
-CONFIG_DEBUG_LEVEL=-1
+CONFIG_DEBUG_LEVEL=1
CONFIG_DEBUG_SERIAL=y
CONFIG_DEBUG_SERIAL_PORT=0x3f8
CONFIG_DEBUG_IO=n
Index: patches/patch-src_boot_c
===================================================================
RCS file: patches/patch-src_boot_c
diff -N patches/patch-src_boot_c
--- patches/patch-src_boot_c 11 Jul 2018 09:09:46 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,43 +0,0 @@
---- src/boot.c.orig Tue Jul 10 14:52:11 2018
-+++ src/boot.c Tue Jul 10 14:53:18 2018
-@@ -659,7 +659,7 @@ boot_cdrom(struct drive_s *drive)
- {
- if (! CONFIG_CDROM_BOOT)
- return;
-- printf("Booting from DVD/CD...\n");
-+ dprintf(1, "Booting from DVD/CD...\n");
-
- int status = cdrom_boot(drive);
- if (status) {
-@@ -685,7 +685,7 @@ boot_cbfs(struct cbfs_file *file)
- {
- if (!CONFIG_COREBOOT_FLASH)
- return;
-- printf("Booting from CBFS...\n");
-+ dprintf(1, "Booting from CBFS...\n");
- cbfs_run_payload(file);
- }
-
-@@ -693,7 +693,7 @@ boot_cbfs(struct cbfs_file *file)
- static void
- boot_rom(u32 vector)
- {
-- printf("Booting from ROM...\n");
-+ dprintf(1, "Booting from ROM...\n");
- struct segoff_s so;
- so.segoff = vector;
- call_boot_entry(so, 0);
-@@ -733,11 +733,11 @@ do_boot(int seq_nr)
- struct bev_s *ie = &BEV[seq_nr];
- switch (ie->type) {
- case IPL_TYPE_FLOPPY:
-- printf("Booting from Floppy...\n");
-+ dprintf(1, "Booting from Floppy...\n");
- boot_disk(0x00, CheckFloppySig);
- break;
- case IPL_TYPE_HARDDISK:
-- printf("Booting from Hard Disk...\n");
-+ dprintf(1, "Booting from Hard Disk...\n");
- boot_disk(0x80, 1);
- break;
- case IPL_TYPE_CDROM:
Index: patches/patch-src_fw_paravirt_c
===================================================================
RCS file: /cvs/ports/sysutils/firmware/vmm/patches/patch-src_fw_paravirt_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-src_fw_paravirt_c
--- patches/patch-src_fw_paravirt_c 26 Apr 2018 12:23:32 -0000 1.2
+++ patches/patch-src_fw_paravirt_c 9 Dec 2018 10:55:37 -0000
@@ -1,18 +1,27 @@
$OpenBSD: patch-src_fw_paravirt_c,v 1.2 2018/04/26 12:23:32 sthen Exp $
+Don't use 'rep insb' to read IO ports, vmm does not support that yet.
Allow detection of >4GB RAM. Normally seabios only allows this with the
qemu config device which VMM doesn't have.
Index: src/fw/paravirt.c
--- src/fw/paravirt.c.orig
+++ src/fw/paravirt.c
-@@ -500,6 +500,18 @@ qemu_cfg_e820(void)
- dprintf(1, "RamSizeOver4G: 0x%016llx [cmos]\n", RamSizeOver4G);
+@@ -257,7 +257,9 @@ qemu_cfg_read(void *buf, int len)
+ if (qemu_cfg_dma_enabled()) {
+ qemu_cfg_dma_transfer(buf, len, QEMU_CFG_DMA_CTL_READ);
+ } else {
+- insb(PORT_QEMU_CFG_DATA, buf, len);
++ u8 *d = buf;
++ while (len-- > 0)
++ *d++ = inb(PORT_QEMU_CFG_DATA);
+ }
}
-+void
-+vmm_check_high_mem(void)
-+{
+@@ -491,6 +493,18 @@ qemu_cfg_e820(void)
+ e820_add(0xfffbc000, 4*4096, E820_RESERVED);
+ }
+
+ // Check for memory over 4Gig in cmos
+ u64 high = ((rtc_read(CMOS_MEM_HIGHMEM_LOW) << 16)
+ | ((u32)rtc_read(CMOS_MEM_HIGHMEM_MID) << 24)
@@ -22,6 +31,9 @@ Index: src/fw/paravirt.c
+ dprintf(1, "RamSizeOver4G: 0x%016llx [cmos]\n", RamSizeOver4G);
+}
+
- // Populate romfile entries for legacy fw_cfg ports (that predate the
- // "file" interface).
- static void
++void
++vmm_check_high_mem(void)
++{
+ // Check for memory over 4Gig in cmos
+ u64 high = ((rtc_read(CMOS_MEM_HIGHMEM_LOW) << 16)
+ | ((u32)rtc_read(CMOS_MEM_HIGHMEM_MID) << 24)
Index: patches/patch-src_optionroms_c
===================================================================
RCS file: /cvs/ports/sysutils/firmware/vmm/patches/patch-src_optionroms_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-src_optionroms_c
--- patches/patch-src_optionroms_c 19 Jul 2017 19:33:51 -0000 1.2
+++ patches/patch-src_optionroms_c 9 Dec 2018 10:45:01 -0000
@@ -2,9 +2,11 @@ $OpenBSD: patch-src_optionroms_c,v 1.2 2
Needed for SGABIOS option ROM for VMM. Normally these are setup based on
the qemu fw_cfg interface (or coreboot CBFS on hardware).
+Turn of screen-and-debug to prevent double printing of chars.
---- src/optionroms.c.orig Fri Mar 31 09:34:40 2017
-+++ src/optionroms.c Fri Mar 31 09:35:35 2017
+Index: src/optionroms.c
+--- src/optionroms.c.orig
++++ src/optionroms.c
@@ -361,7 +361,7 @@ optionrom_setup(void)
// All option roms found and deployed - now build BEV/BCV vectors.
@@ -14,3 +16,12 @@ the qemu fw_cfg interface (or coreboot C
while (pos < rom_get_last()) {
struct rom_header *rom = (void*)pos;
if (! is_valid_rom(rom)) {
+@@ -413,7 +413,7 @@ vgarom_setup(void)
+ EnforceChecksum = romfile_loadint("etc/optionroms-checksum", 1);
+ S3ResumeVga = romfile_loadint("etc/s3-resume-vga-init", CONFIG_QEMU);
+ RunPCIroms = romfile_loadint("etc/pci-optionrom-exec", 2);
+- ScreenAndDebug = romfile_loadint("etc/screen-and-debug", 1);
++ ScreenAndDebug = romfile_loadint("etc/screen-and-debug", 0);
+
+ // Clear option rom memory
+ memset((void*)BUILD_ROM_START, 0, rom_get_max() - BUILD_ROM_START);