Skip to contentSkip to conversation

video: vesa_fb: Look up VGA device by class instead of id

PATCH Superseded Bin Meng 2 participants 25 messages Jul 1, 2015 – Jul 3, 2015 1 message not in the archive

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bin Meng

author
#1 lore raw

PATCH 1/11 video: vesa_fb: Look up VGA device by class instead of id

In reply to a message not in the archive

Per PCI spec, VGA device reports its class as standard 030000h in its configuration space, so we can use it to determine if we need run option rom instead of testing the supported vendor/device ids.

---

 drivers/video/vesa_fb.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/video/vesa_fb.c +2 -14
index 47f824a..909f8e8 100644
@@ -1,6 +1,5 @@
 /*
- *
- * Vesa frame buffer driver for x86
+ * VESA frame buffer driver
  *
  * Copyright (C) 2014 Google, Inc
  *
@@ -17,16 +16,6 @@
  */
 GraphicDevice ctfb;
 
-/* Devices to allow - only the last one works fully */
-struct pci_device_id vesa_video_ids[] = {
-	{ .vendor = 0x102b, .device = 0x0525 },
-	{ .vendor = 0x1002, .device = 0x5159 },
-	{ .vendor = 0x1002, .device = 0x4752 },
-	{ .vendor = 0x1002, .device = 0x5452 },
-	{ .vendor = 0x8086, .device = 0x0f31 },
-	{},
-};
-
 void *video_hw_init(void)
 {
 	GraphicDevice *gdev = &ctfb;
@@ -36,8 +25,7 @@ void *video_hw_init(void)
 
 	printf("Video: ");
 	if (vbe_get_video_info(gdev)) {
-		/* TODO: Should we look these up by class? */
-		dev = pci_find_devices(vesa_video_ids, 0);
+		dev = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, 0);
 		if (dev == -1) {
 			printf("no card detected\n");
 			return NULL;
Signature · 1 line
1.8.2.1
author
#3 lore raw

PATCH 2/11 x86: bios: Synchronize stack between real and protected mode

In reply to a message not in the archive

From: Jian Luo <[email protected]>

PCI option rom may use different SS during its execution, so it is not safe to assume esp pointed to the same location in the protected mode.

---

 arch/x86/lib/bios_asm.S | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/x86/lib/bios_asm.S +15 -0
index 4faa70e..a29fe0e 100644
@@ -246,6 +246,8 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
 	push	%fs
 	push	%gs
 
+	movw	%ss, %cs:__realmode_ss
+
 	/* Clear DF to not break ABI assumptions */
 	cld
 
@@ -258,12 +260,22 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
 
 	enter_protected_mode
 
+	movzwl	%cs:__realmode_ss, %ecx
+	shll	$4, %ecx
+	addl	%ecx, %esp
+
 	/* Call the C interrupt handler */
 	movl	$interrupt_handler, %eax
 	call	*%eax
 
+	movzwl	%cs:__realmode_ss, %ecx
+	shll	$4, %ecx
+	subl	%ecx, %esp
+
 	enter_real_mode
 
+	movw	%cs:__realmode_ss, %ss
+
 	/*
 	 * Restore all registers, including those manipulated by the C
 	 * handler
@@ -276,6 +288,9 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
 	popal
 	iret
 
+__realmode_ss = PTR_TO_REAL_MODE(.)
+	.word	0
+
 	.globl asm_realmode_code_size
 asm_realmode_code_size:
 	.long  . - asm_realmode_code
Signature · 1 line
1.8.2.1
author
#6 lore raw

PATCH 3/11 x86: bios: Allow pci config read/write to host bridge in int1a_handler

In reply to a message not in the archive

From: Jian Luo <[email protected]>

We should allow pci config read/write to host bridge (b.d.f = 0.0.0) in the int1a_handler() which is a valid pci device.

---

 arch/x86/lib/bios_interrupts.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/x86/lib/bios_interrupts.c +1 -9
index 290990a..47d9f59 100644
@@ -161,15 +161,7 @@ int int1a_handler(void)
 		bus = M.x86.R_EBX >> 8;
 		reg = M.x86.R_EDI;
 		dev = PCI_BDF(bus, devfn >> 3, devfn & 7);
-		if (!dev) {
-			debug("0x%x: BAD DEVICE bus %d devfn 0x%x\n", func,
-			      bus, devfn);
-			/* Or are we supposed to return PCIBIOS_NODEV? */
-			M.x86.R_EAX &= 0xffff00ff; /* Clear AH */
-			M.x86.R_EAX |= PCIBIOS_BADREG;
-			retval = 0;
-			return retval;
-		}
+
 		switch (func) {
 		case 0xb108: /* Read Config Byte */
 			byte = x86_pci_read_config8(dev, reg);
Signature · 1 line
1.8.2.1
author
#8 lore raw

PATCH 4/11 video: Add 32-bit color depth support for VBE

In reply to a message not in the archive

From: Jian Luo <[email protected]>

The TunnelCreek IGD VBE reports 32-bit color depth regardless 24-bit color depth is configured. Since 24-bit mode already uses 4 bytes internally, it should be OK to just add this option in switch case.

---

 drivers/pci/pci_rom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/pci_rom.c +1 -0
index e6f4806..83c69a5 100644
@@ -202,6 +202,7 @@ int vbe_get_video_info(struct graphic_device *gdev)
 	gdev->gdfBytesPP = vesa->bits_per_pixel / 8;
 
 	switch (vesa->bits_per_pixel) {
+	case 32:
 	case 24:
 		gdev->gdfIndex = GDF_32BIT_X888RGB;
 		break;
Signature · 1 line
1.8.2.1
author
#10 lore raw

PATCH 5/11 x86: Setup fixed range MTRRs for legacy regions

In reply to a message not in the archive

We should setup fixed range MTRRs for some legacy regions like VGA RAM and PCI ROM areas as uncacheable. Note FSP may setup these to other cache settings, but we can override this in x86_cpu_init_f().

---

 arch/x86/cpu/cpu.c          | 22 ++++++++++++++++++++++
 arch/x86/include/asm/mtrr.h | 27 ++++++++++++++++-----------
 2 files changed, 38 insertions(+), 11 deletions(-)
arch/x86/cpu/cpu.c +22 -0
index d108ee5..9afdafb 100644
@@ -28,6 +28,8 @@
 #include <asm/cpu.h>
 #include <asm/lapic.h>
 #include <asm/mp.h>
+#include <asm/msr.h>
+#include <asm/mtrr.h>
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/processor-flags.h>
@@ -352,6 +354,26 @@ int x86_cpu_init_f(void)
 		gd->arch.has_mtrr = has_mtrr();
 	}
 
+	/* Configure fixed range MTRRs for some legacy regions */
+	if (gd->arch.has_mtrr) {
+		u64 mtrr_cap;
+
+		mtrr_cap = native_read_msr(MTRR_CAP_MSR);
+		if (mtrr_cap & MTRR_CAP_FIX) {
+			/* Mark the VGA RAM area as uncacheable */
+			native_write_msr(MTRR_FIX_16K_A0000_MSR, 0, 0);
+
+			/* Mark the PCI ROM area as uncacheable */
+			native_write_msr(MTRR_FIX_4K_C0000_MSR, 0, 0);
+			native_write_msr(MTRR_FIX_4K_C8000_MSR, 0, 0);
+			native_write_msr(MTRR_FIX_4K_D0000_MSR, 0, 0);
+			native_write_msr(MTRR_FIX_4K_D8000_MSR, 0, 0);
+
+			/* Enable the fixed range MTRRs */
+			msr_setbits_64(MTRR_DEF_TYPE_MSR, MTRR_DEF_TYPE_FIX_EN);
+		}
+	}
+
 	return 0;
 }
 
arch/x86/include/asm/mtrr.h +16 -11
index 3ad617c..70762ee 100644
@@ -21,6 +21,11 @@
 #define MTRR_CAP_MSR		0x0fe
 #define MTRR_DEF_TYPE_MSR	0x2ff
 
+#define MTRR_CAP_SMRR		(1 << 11)
+#define MTRR_CAP_WC		(1 << 10)
+#define MTRR_CAP_FIX		(1 << 8)
+#define MTRR_CAP_VCNT_MASK	0xff
+
 #define MTRR_DEF_TYPE_EN	(1 << 11)
 #define MTRR_DEF_TYPE_FIX_EN	(1 << 10)
 
@@ -38,17 +43,17 @@
 #define RANGES_PER_FIXED_MTRR	8
 #define NUM_FIXED_RANGES	(NUM_FIXED_MTRRS * RANGES_PER_FIXED_MTRR)
 
-#define MTRR_FIX_64K_00000_MSR 0x250
-#define MTRR_FIX_16K_80000_MSR 0x258
-#define MTRR_FIX_16K_A0000_MSR 0x259
-#define MTRR_FIX_4K_C0000_MSR 0x268
-#define MTRR_FIX_4K_C8000_MSR 0x269
-#define MTRR_FIX_4K_D0000_MSR 0x26a
-#define MTRR_FIX_4K_D8000_MSR 0x26b
-#define MTRR_FIX_4K_E0000_MSR 0x26c
-#define MTRR_FIX_4K_E8000_MSR 0x26d
-#define MTRR_FIX_4K_F0000_MSR 0x26e
-#define MTRR_FIX_4K_F8000_MSR 0x26f
+#define MTRR_FIX_64K_00000_MSR	0x250
+#define MTRR_FIX_16K_80000_MSR	0x258
+#define MTRR_FIX_16K_A0000_MSR	0x259
+#define MTRR_FIX_4K_C0000_MSR	0x268
+#define MTRR_FIX_4K_C8000_MSR	0x269
+#define MTRR_FIX_4K_D0000_MSR	0x26a
+#define MTRR_FIX_4K_D8000_MSR	0x26b
+#define MTRR_FIX_4K_E0000_MSR	0x26c
+#define MTRR_FIX_4K_E8000_MSR	0x26d
+#define MTRR_FIX_4K_F0000_MSR	0x26e
+#define MTRR_FIX_4K_F8000_MSR	0x26f
 
 #if !defined(__ASSEMBLER__)
 
Signature · 1 line
1.8.2.1
author
#12 lore raw

PATCH 6/11 x86: queensbay: Change CPU_ADDR_BITS to 32

In reply to a message not in the archive

Per CPUID:80000008h result, the maximum physical address bits of TunnelCreek processor is 32 instead of default 36. This will fix the incorrect decoding of MTRR range mask.

---

 arch/x86/cpu/queensbay/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/cpu/queensbay/Kconfig +4 -0
index 397e599..fbf85f2 100644
@@ -38,4 +38,8 @@ config CMC_ADDR
 	  The default base address of 0xfffb0000 indicates that the binary must
 	  be located at offset 0xb0000 from the beginning of a 1MB flash device.
 
+config CPU_ADDR_BITS
+	int
+	default 32
+
 endif
Signature · 1 line
1.8.2.1
author
#14 lore raw

PATCH 7/11 x86: cmd_mtrr: Improve MTRR list information

In reply to a message not in the archive

Print the meaningful base address and mask of an MTRR range without showing the memory type encoding or valid bit.

---

 arch/x86/lib/cmd_mtrr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/lib/cmd_mtrr.c +2 -1
index 7e0506b..f632f49 100644
@@ -37,7 +37,8 @@ static int do_mtrr_list(void)
 		valid = mask & MTRR_PHYS_MASK_VALID;
 		type = mtrr_type_name[base & MTRR_BASE_TYPE_MASK];
 		printf("%d   %-5s %-12s %016llx %016llx %016llx\n", i,
-		       valid ? "Y" : "N", type, base, mask, size);
+		       valid ? "Y" : "N", type, base & ~MTRR_BASE_TYPE_MASK,
+		       mask & ~MTRR_PHYS_MASK_VALID, size);
 	}
 
 	return 0;
Signature · 1 line
1.8.2.1
author
#16 lore raw

PATCH 8/11 x86: Move VGA option rom macros to Kconfig

In reply to a message not in the archive

Move X86_OPTION_ROM_FILE & X86_OPTION_ROM_ADDR to arch/x86/Kconfig and rename them to VGA_BIOS_FILE & VGA_BIOS_ADDR which depend on HAVE_VGA_BIOS. The new names are consistent with other x86 binary blob options like HAVE_FSP/FSP_FILE/FSP_ADDR.

---

 Makefile                            |  4 ++--
 arch/x86/Kconfig                    | 22 ++++++++++++++++++++++
 configs/chromebook_link_defconfig   |  1 +
 configs/chromebox_panther_defconfig |  1 +
 configs/minnowmax_defconfig         |  1 +
 doc/README.x86                      |  2 +-
 drivers/pci/pci_rom.c               |  6 +++---
 include/configs/minnowmax.h         |  3 ---
 include/configs/x86-chromebook.h    |  3 ---
 9 files changed, 31 insertions(+), 12 deletions(-)
Makefile +2 -2
index 0a674bf..2601e87 100644
@@ -1034,8 +1034,8 @@ ifneq ($(CONFIG_HAVE_CMC),)
 IFDTOOL_FLAGS += -w $(CONFIG_CMC_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_CMC_FILE)
 endif
 
-ifneq ($(CONFIG_X86_OPTION_ROM_ADDR),)
-IFDTOOL_FLAGS += -w $(CONFIG_X86_OPTION_ROM_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_X86_OPTION_ROM_FILE)
+ifneq ($(CONFIG_HAVE_VGA_BIOS),)
+IFDTOOL_FLAGS += -w $(CONFIG_VGA_BIOS_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_VGA_BIOS_FILE)
 endif
 
 quiet_cmd_ifdtool = IFDTOOL $@
arch/x86/Kconfig +22 -0
index 6b46ec4..0e308ce 100644
@@ -293,6 +293,28 @@ config TSC_FREQ_IN_MHZ
 	help
 	  The running frequency in MHz of Time-Stamp Counter (TSC).
 
+config HAVE_VGA_BIOS
+	bool "Add a VGA BIOS image"
+	help
+	  Select this option if you have a VGA BIOS image that you would
+	  like to add to your ROM.
+
+config VGA_BIOS_FILE
+	string "VGA BIOS image filename"
+	depends on HAVE_VGA_BIOS
+	default "vga.bin"
+	help
+	  The filename of the VGA BIOS image in the board directory.
+
+config VGA_BIOS_ADDR
+	hex "VGA BIOS image location"
+	depends on HAVE_VGA_BIOS
+	default 0xfff90000
+	help
+	  The location of VGA BIOS image in the SPI flash. For example, base
+	  address of 0xfff90000 indicates that the image will be put at offset
+	  0x90000 from the beginning of a 1MB flash device.
+
 menu "System tables"
 
 config GENERATE_PIRQ_TABLE
configs/chromebook_link_defconfig +1 -0
index 4f7f779..08743f0 100644
@@ -3,6 +3,7 @@ CONFIG_VENDOR_GOOGLE=y
 CONFIG_DEFAULT_DEVICE_TREE="chromebook_link"
 CONFIG_TARGET_CHROMEBOOK_LINK=y
 CONFIG_HAVE_MRC=y
+CONFIG_HAVE_VGA_BIOS=y
 CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_FRAMEBUFFER_VESA_MODE_11A=y
 CONFIG_CMD_NET=y
configs/chromebox_panther_defconfig +1 -0
index 941033f..9cd422a 100644
@@ -3,6 +3,7 @@ CONFIG_VENDOR_GOOGLE=y
 CONFIG_DEFAULT_DEVICE_TREE="chromebox_panther"
 CONFIG_TARGET_CHROMEBOX_PANTHER=y
 CONFIG_HAVE_MRC=y
+CONFIG_HAVE_VGA_BIOS=y
 CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_FRAMEBUFFER_VESA_MODE_11A=y
 CONFIG_CMD_NET=y
configs/minnowmax_defconfig +1 -0
index 744aca3..bfe2cdf 100644
@@ -3,6 +3,7 @@ CONFIG_VENDOR_INTEL=y
 CONFIG_DEFAULT_DEVICE_TREE="minnowmax"
 CONFIG_TARGET_MINNOWMAX=y
 CONFIG_HAVE_INTEL_ME=y
+CONFIG_HAVE_VGA_BIOS=y
 CONFIG_VIDEO_VESA=y
 CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_FRAMEBUFFER_VESA_MODE_11A=y
doc/README.x86 +1 -1
index 49d6e83..7f3914f 100644
@@ -79,7 +79,7 @@ Find the following files:
 * ./northbridge/intel/sandybridge/systemagent-r6.bin
 
 The 3rd one should be renamed to mrc.bin.
-As for the video ROM, you can get it here [3].
+As for the video ROM, you can get it here [3] and rename it to vga.bin.
 Make sure all these binary blobs are put in the board directory.
 
 Now you can build U-Boot and obtain u-boot.rom:
drivers/pci/pci_rom.c +3 -3
index 83c69a5..4a91033 100644
@@ -79,8 +79,8 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
 	if (vendev != mapped_vendev)
 		debug("Device ID mapped to %#08x\n", mapped_vendev);
 
-#ifdef CONFIG_X86_OPTION_ROM_ADDR
-	rom_address = CONFIG_X86_OPTION_ROM_ADDR;
+#ifdef CONFIG_VGA_BIOS_ADDR
+	rom_address = CONFIG_VGA_BIOS_ADDR;
 #else
 
 	pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_address);
@@ -103,7 +103,7 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
 	if (le16_to_cpu(rom_header->signature) != PCI_ROM_HDR) {
 		printf("Incorrect expansion ROM header signature %04x\n",
 		       le16_to_cpu(rom_header->signature));
-#ifndef CONFIG_X86_OPTION_ROM_ADDR
+#ifndef CONFIG_VGA_BIOS_ADDR
 		/* Disable expansion ROM address decoding */
 		pci_write_config_dword(dev, PCI_ROM_ADDRESS, rom_address);
 #endif
include/configs/minnowmax.h +0 -3
index 547765d..8ee84a6 100644
@@ -52,9 +52,6 @@
 #undef CONFIG_USB_MAX_CONTROLLER_COUNT
 #define CONFIG_USB_MAX_CONTROLLER_COUNT		1
 
-#define CONFIG_X86_OPTION_ROM_FILE		vga.bin
-#define CONFIG_X86_OPTION_ROM_ADDR		0xfff90000
-
 #define VIDEO_IO_OFFSET				0
 #define CONFIG_X86EMU_RAW_IO
 #define CONFIG_VGA_AS_SINGLE_DEVICE
include/configs/x86-chromebook.h +0 -3
index e0e7fca..408cbb1 100644
@@ -26,9 +26,6 @@
 	{PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PANTHERPOINT_AHCI_MOBILE}, \
 	{PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_AHCI}
 
-#define CONFIG_X86_OPTION_ROM_FILE		pci8086,0166.bin
-#define CONFIG_X86_OPTION_ROM_ADDR		0xfff90000
-
 #define CONFIG_PCI_MEM_BUS	0xe0000000
 #define CONFIG_PCI_MEM_PHYS	CONFIG_PCI_MEM_BUS
 #define CONFIG_PCI_MEM_SIZE	0x10000000
Signature · 1 line
1.8.2.1
author
#20 lore raw

PATCH 9/11 x86: Remove MARK_GRAPHICS_MEM_WRCOMB

In reply to a message not in the archive

MARK_GRAPHICS_MEM_WRCOMB is not referenced anywhere in the code, hence remove it.

---

 arch/x86/Kconfig                       | 8 --------
 board/google/chromebook_link/Kconfig   | 1 -
 board/google/chromebox_panther/Kconfig | 1 -
 3 files changed, 10 deletions(-)
arch/x86/Kconfig +0 -8
index 0e308ce..0036344 100644
@@ -194,14 +194,6 @@ config X86_RAMTEST
 	  to work correctly. It is not exhaustive but can save time by
 	  detecting obvious failures.
 
-config MARK_GRAPHICS_MEM_WRCOMB
-	bool "Mark graphics memory as write-combining"
-	default n
-	help
-	  The graphics performance may increase if the graphics
-	  memory is set as write-combining cache type. This option
-	  enables marking the graphics memory as write-combining.
-
 config HAVE_FSP
 	bool "Add an Firmware Support Package binary"
 	help
board/google/chromebook_link/Kconfig +0 -1
index 9c8d020..d3644a9 100644
@@ -22,7 +22,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	select NORTHBRIDGE_INTEL_IVYBRIDGE
 	select SOUTHBRIDGE_INTEL_C216
 	select HAVE_ACPI_RESUME
-	select MARK_GRAPHICS_MEM_WRCOMB
 	select BOARD_ROMSIZE_KB_8192
 
 config PCIE_ECAM_BASE
board/google/chromebox_panther/Kconfig +0 -1
index e3604eb..d56d903 100644
@@ -23,7 +23,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	select NORTHBRIDGE_INTEL_IVYBRIDGE
 	select SOUTHBRIDGE_INTEL_C216
 	select HAVE_ACPI_RESUME
-	select MARK_GRAPHICS_MEM_WRCOMB
 	select BOARD_ROMSIZE_KB_8192
 
 config SYS_CAR_ADDR
Signature · 1 line
1.8.2.1
author
#22 lore raw

PATCH 10/11 x86: crownbay: Enable graphics support

In reply to a message not in the archive

Enable graphics support on Intel Crown Bay board With the help of vgabios for Intel TunnelCreek IGD. Tested with an external LVDS panel connected to X4 connector and SDVO adapter connected to X9 connector on the board.

---

 configs/crownbay_defconfig |  3 +++
 doc/README.x86             | 20 +++++++++++++-------
 include/configs/crownbay.h | 14 +++++++-------
 3 files changed, 23 insertions(+), 14 deletions(-)
configs/crownbay_defconfig +3 -0
index e4edad0..de24bb6 100644
@@ -4,10 +4,13 @@ CONFIG_DEFAULT_DEVICE_TREE="crownbay"
 CONFIG_TARGET_CROWNBAY=y
 CONFIG_SMP=y
 CONFIG_MAX_CPUS=2
+CONFIG_HAVE_VGA_BIOS=y
 CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_NET=y
 CONFIG_OF_CONTROL=y
 CONFIG_CPU=y
+CONFIG_VIDEO_VESA=y
+CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_DM_RTC=y
doc/README.x86 +13 -7
index 7f3914f..646eff1 100644
@@ -113,6 +113,10 @@ binary using any hex editor (eg: bvi). Go to the offset 0x1fcd8 of the FSP
 binary, change the following five bytes values from orginally E8 42 FF FF FF
 to B8 00 80 0B 00.
 
+As for the video ROM, you need manually extract it from the Intel provided
+BIOS for Crown Bay here [6], using the AMI MMTool [7]. Check PCI option ROM
+ID 8086:4108, extract and save it as vga.bin in the board directory.
+
 Now you can build U-Boot and obtain u-boot.rom
 
 $ make crownbay_defconfig
@@ -254,7 +258,7 @@ If you want to check both consoles, use '-serial stdio'.
 
 CPU Microcode
 -------------
-Modern CPUs usually require a special bit stream called microcode [6] to be
+Modern CPUs usually require a special bit stream called microcode [8] to be
 loaded on the processor after power up in order to function properly. U-Boot
 has already integrated these as hex dumps in the source tree.
 
@@ -265,9 +269,9 @@ Additional application processors (AP) can be brought up by U-Boot. In order to
 have an SMP kernel to discover all of the available processors, U-Boot needs to
 prepare configuration tables which contain the multi-CPUs information before
 loading the OS kernel. Currently U-Boot supports generating two types of tables
-for SMP, called Simple Firmware Interface (SFI) [7] and Multi-Processor (MP) [8]
-tables. The writing of these two tables are controlled by two Kconfig options
-GENERATE_SFI_TABLE and GENERATE_MP_TABLE.
+for SMP, called Simple Firmware Interface (SFI) [9] and Multi-Processor (MP)
+[10] tables. The writing of these two tables are controlled by two Kconfig
+options GENERATE_SFI_TABLE and GENERATE_MP_TABLE.
 
 Driver Model
 ------------
@@ -372,6 +376,8 @@ References
 [3] http://www.coreboot.org/~stepan/pci8086,0166.rom
 [4] http://www.intel.com/content/www/us/en/embedded/design-tools/evaluation-platforms/atom-e660-eg20t-development-kit.html
 [5] http://www.intel.com/fsp
-[6] http://en.wikipedia.org/wiki/Microcode
-[7] http://simplefirmware.org
-[8] http://www.intel.com/design/archives/processors/pro/docs/242016.htm
+[6] http://www.intel.com/content/www/us/en/secure/intelligent-systems/privileged/e6xx-35-b1-cmc22211.html
+[7] http://www.ami.com/products/bios-uefi-tools-and-utilities/bios-uefi-utilities/
+[8] http://en.wikipedia.org/wiki/Microcode
+[9] http://simplefirmware.org
+[10] http://www.intel.com/design/archives/processors/pro/docs/242016.htm
include/configs/crownbay.h +7 -7
index 0e1f046..6cf53a3 100644
@@ -32,15 +32,16 @@
 #define CONFIG_PCI_IO_PHYS		CONFIG_PCI_IO_BUS
 #define CONFIG_PCI_IO_SIZE		0xe000
 
+#define CONFIG_PCI_CONFIG_HOST_BRIDGE
 #define CONFIG_SYS_EARLY_PCI_INIT
 #define CONFIG_PCI_PNP
 #define CONFIG_E1000
 
-#define CONFIG_STD_DEVICES_SETTINGS     "stdin=serial\0" \
-					"stdout=serial\0" \
-					"stderr=serial\0"
+#define CONFIG_STD_DEVICES_SETTINGS	"stdin=serial,vga,usbkbd\0" \
+					"stdout=serial,vga\0" \
+					"stderr=serial,vga\0"
 
-#define CONFIG_SCSI_DEV_LIST            \
+#define CONFIG_SCSI_DEV_LIST		\
 	{PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SATA}
 
 #define CONFIG_SPI_FLASH_SST
@@ -55,9 +56,8 @@
 #define CONFIG_PCH_GBE
 #define CONFIG_PHYLIB
 
-/* Video is not supported */
-#undef CONFIG_VIDEO
-#undef CONFIG_CFB_CONSOLE
+/* TunnelCreek IGD support */
+#define CONFIG_VGA_AS_SINGLE_DEVICE
 
 /* Environment configuration */
 #define CONFIG_ENV_SECT_SIZE		0x1000
Signature · 1 line
1.8.2.1
author
#24 lore raw

PATCH 11/11 x86: Configure VESA parameters before loading Linux kernel

In reply to a message not in the archive

Store VESA parameters to Linux setup header so that vesafb driver in the kernel could work.

---

 arch/x86/include/asm/zimage.h |  1 +
 arch/x86/lib/zimage.c         |  2 ++
 drivers/pci/pci_rom.c         | 28 ++++++++++++++++++++++++++++
 include/vbe.h                 |  4 ++--
 4 files changed, 33 insertions(+), 2 deletions(-)
arch/x86/include/asm/zimage.h +1 -0
index 8e7dd42..bf351ed 100644
@@ -38,5 +38,6 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
 				ulong *load_addressp);
 int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
 		 unsigned long initrd_addr, unsigned long initrd_size);
+void setup_video(struct screen_info *screen_info);
 
 #endif
arch/x86/lib/zimage.c +2 -0
index c3f8a73..144471c 100644
@@ -273,6 +273,8 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
 		build_command_line(cmd_line, auto_boot);
 	}
 
+	setup_video(&setup_base->screen_info);
+
 	return 0;
 }
 
drivers/pci/pci_rom.c +28 -0
index 4a91033..a33efae 100644
@@ -31,6 +31,7 @@
 #include <pci_rom.h>
 #include <vbe.h>
 #include <video_fb.h>
+#include <linux/screen_info.h>
 
 #ifdef CONFIG_HAVE_ACPI_RESUME
 #include <asm/acpi.h>
@@ -229,6 +230,33 @@ int vbe_get_video_info(struct graphic_device *gdev)
 #endif
 }
 
+void setup_video(struct screen_info *screen_info)
+{
+#ifdef CONFIG_FRAMEBUFFER_SET_VESA_MODE
+	struct vesa_mode_info *vesa = &mode_info.vesa;
+
+	screen_info->orig_video_isVGA = VIDEO_TYPE_VLFB;
+
+	screen_info->lfb_width = vesa->x_resolution;
+	screen_info->lfb_height = vesa->y_resolution;
+	screen_info->lfb_depth = vesa->bits_per_pixel;
+	screen_info->lfb_linelength = vesa->bytes_per_scanline;
+	screen_info->lfb_base = vesa->phys_base_ptr;
+	screen_info->lfb_size =
+		ALIGN(screen_info->lfb_linelength * screen_info->lfb_height,
+		      65536);
+	screen_info->lfb_size >>= 16;
+	screen_info->red_size = vesa->red_mask_size;
+	screen_info->red_pos = vesa->red_mask_pos;
+	screen_info->green_size = vesa->green_mask_size;
+	screen_info->green_pos = vesa->green_mask_pos;
+	screen_info->blue_size = vesa->blue_mask_size;
+	screen_info->blue_pos = vesa->blue_mask_pos;
+	screen_info->rsvd_size = vesa->reserved_mask_size;
+	screen_info->rsvd_pos = vesa->reserved_mask_pos;
+#endif
+}
+
 int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), int exec_method)
 {
 	struct pci_rom_header *rom, *ram;
include/vbe.h +2 -2
index c5deee9..1a86db8 100644
@@ -12,7 +12,7 @@
 #define _VBE_H
 
 /* these structs are for input from and output to OF */
-struct __packed screen_info {
+struct __packed vbe_screen_info {
 	u8 display_type;	/* 0=NONE, 1= analog, 2=digital */
 	u16 screen_width;
 	u16 screen_height;
@@ -23,7 +23,7 @@ struct __packed screen_info {
 	u8 edid_block_zero[128];
 };
 
-struct __packed screen_info_input {
+struct __packed vbe_screen_info_input {
 	u8 signature[4];
 	u16 size_reserved;
 	u8 monitor_number;
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH 1/11 video: vesa_fb: Look up VGA device by class instead of id

In reply to Bin Meng
Quoted 9 lines · Bin Meng

Per PCI spec, VGA device reports its class as standard 030000h in its configuration space, so we can use it to determine if we need run option rom instead of testing the supported vendor/device ids.

---

 drivers/video/vesa_fb.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
#4 lore raw

PATCH 2/11 x86: bios: Synchronize stack between real and protected mode

In reply to Bin Meng

Hi,

Quoted 27 lines · Bin Meng

From: Jian Luo <[email protected]>

PCI option rom may use different SS during its execution, so it is not safe to assume esp pointed to the same location in the protected mode.

---

 arch/x86/lib/bios_asm.S | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/x86/lib/bios_asm.S +2 -0
index 4faa70e..a29fe0e 100644
@@ -246,6 +246,8 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
        push    %fs
        push    %gs
 
+       movw    %ss, %cs:__realmode_ss
+
        /* Clear DF to not break ABI assumptions */
        cld
 

arch/x86/lib/bios_asm.S __interrupt_handler_16bit = PTR_TO_REAL_MODE(.) · line 262

Quoted 3 lines
arch/x86/lib/bios_asm.S +0 -0
@@ -258,12 +260,22 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
 
        enter_protected_mode
 

Please can you add a comment here for the next person who changes this, about what is going on? It looks like it is saving and restoring the real mode SS register?

Quoted 30 lines
arch/x86/lib/bios_asm.S +13 -1
+       movzwl  %cs:__realmode_ss, %ecx
+       shll    $4, %ecx
+       addl    %ecx, %esp
+
        /* Call the C interrupt handler */
        movl    $interrupt_handler, %eax
        call    *%eax
 
+       movzwl  %cs:__realmode_ss, %ecx
+       shll    $4, %ecx
+       subl    %ecx, %esp
+
        enter_real_mode
 
+       movw    %cs:__realmode_ss, %ss
+
        /*
         * Restore all registers, including those manipulated by the C
         * handler
@@ -276,6 +288,9 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
        popal
        iret
 
+__realmode_ss = PTR_TO_REAL_MODE(.)
+       .word   0
+
        .globl asm_realmode_code_size
 asm_realmode_code_size:
        .long  . - asm_realmode_code
--
Quoted 2 lines

1.8.2.1

Regards,
Simon

#7 lore raw

PATCH 3/11 x86: bios: Allow pci config read/write to host bridge in int1a_handler

In reply to Bin Meng
Quoted 11 lines · Bin Meng

From: Jian Luo <[email protected]>

We should allow pci config read/write to host bridge (b.d.f = 0.0.0) in the int1a_handler() which is a valid pci device.

---

 arch/x86/lib/bios_interrupts.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
#9 lore raw

PATCH 4/11 video: Add 32-bit color depth support for VBE

In reply to Bin Meng
Quoted 6 lines · Bin Meng

From: Jian Luo <[email protected]>

The TunnelCreek IGD VBE reports 32-bit color depth regardless 24-bit color depth is configured. Since 24-bit mode already uses 4 bytes internally, it should be OK to just add this option in switch case.

Quoted 6 lines

---

 drivers/pci/pci_rom.c | 1 +
 1 file changed, 1 insertion(+)
#11 lore raw

PATCH 5/11 x86: Setup fixed range MTRRs for legacy regions

In reply to Bin Meng

Hi Bin,

Quoted 1 line · Bin Meng

We should setup fixed range MTRRs for some legacy regions like VGA

nit: fixed-range

Quoted 9 lines

RAM and PCI ROM areas as uncacheable. Note FSP may setup these to other cache settings, but we can override this in x86_cpu_init_f().

---

 arch/x86/cpu/cpu.c          | 22 ++++++++++++++++++++++
 arch/x86/include/asm/mtrr.h | 27 ++++++++++++++++-----------
 2 files changed, 38 insertions(+), 11 deletions(-)

Other than the nits:

Quoted 15 lines
arch/x86/cpu/cpu.c +2 -0
index d108ee5..9afdafb 100644
@@ -28,6 +28,8 @@
 #include <asm/cpu.h>
 #include <asm/lapic.h>
 #include <asm/mp.h>
+#include <asm/msr.h>
+#include <asm/mtrr.h>
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/processor-flags.h>

arch/x86/cpu/cpu.c int x86_cpu_init_f(void) · line 357

Quoted 4 lines
arch/x86/cpu/cpu.c +1 -0
@@ -352,6 +354,26 @@ int x86_cpu_init_f(void)
                gd->arch.has_mtrr = has_mtrr();
        }
 
+       /* Configure fixed range MTRRs for some legacy regions */

nit: fixed-range

Quoted 5 lines
arch/x86/cpu/cpu.c +5 -0
+       if (gd->arch.has_mtrr) {
+               u64 mtrr_cap;
+
+               mtrr_cap = native_read_msr(MTRR_CAP_MSR);
+               if (mtrr_cap & MTRR_CAP_FIX) {

arch/x86/cpu/cpu.c int x86_cpu_init_f(void) · line 372

Quoted 10 lines
arch/x86/cpu/cpu.c +10 -0
+                       /* Mark the VGA RAM area as uncacheable */
+                       native_write_msr(MTRR_FIX_16K_A0000_MSR, 0, 0);
+
+                       /* Mark the PCI ROM area as uncacheable */
+                       native_write_msr(MTRR_FIX_4K_C0000_MSR, 0, 0);
+                       native_write_msr(MTRR_FIX_4K_C8000_MSR, 0, 0);
+                       native_write_msr(MTRR_FIX_4K_D0000_MSR, 0, 0);
+                       native_write_msr(MTRR_FIX_4K_D8000_MSR, 0, 0);
+
+                       /* Enable the fixed range MTRRs */

nit: fixed-range

Quoted 53 lines
arch/x86/cpu/cpu.c +4 -0
+                       msr_setbits_64(MTRR_DEF_TYPE_MSR, MTRR_DEF_TYPE_FIX_EN);
+               }
+       }
+
        return 0;
 }
 
arch/x86/include/asm/mtrr.h +16 -12
index 3ad617c..70762ee 100644
@@ -21,6 +21,11 @@
 #define MTRR_CAP_MSR           0x0fe
 #define MTRR_DEF_TYPE_MSR      0x2ff
 
+#define MTRR_CAP_SMRR          (1 << 11)
+#define MTRR_CAP_WC            (1 << 10)
+#define MTRR_CAP_FIX           (1 << 8)
+#define MTRR_CAP_VCNT_MASK     0xff
+
 #define MTRR_DEF_TYPE_EN       (1 << 11)
 #define MTRR_DEF_TYPE_FIX_EN   (1 << 10)
 
@@ -38,17 +43,17 @@
 #define RANGES_PER_FIXED_MTRR  8
 #define NUM_FIXED_RANGES       (NUM_FIXED_MTRRS * RANGES_PER_FIXED_MTRR)
 
-#define MTRR_FIX_64K_00000_MSR 0x250
-#define MTRR_FIX_16K_80000_MSR 0x258
-#define MTRR_FIX_16K_A0000_MSR 0x259
-#define MTRR_FIX_4K_C0000_MSR 0x268
-#define MTRR_FIX_4K_C8000_MSR 0x269
-#define MTRR_FIX_4K_D0000_MSR 0x26a
-#define MTRR_FIX_4K_D8000_MSR 0x26b
-#define MTRR_FIX_4K_E0000_MSR 0x26c
-#define MTRR_FIX_4K_E8000_MSR 0x26d
-#define MTRR_FIX_4K_F0000_MSR 0x26e
-#define MTRR_FIX_4K_F8000_MSR 0x26f
+#define MTRR_FIX_64K_00000_MSR 0x250
+#define MTRR_FIX_16K_80000_MSR 0x258
+#define MTRR_FIX_16K_A0000_MSR 0x259
+#define MTRR_FIX_4K_C0000_MSR  0x268
+#define MTRR_FIX_4K_C8000_MSR  0x269
+#define MTRR_FIX_4K_D0000_MSR  0x26a
+#define MTRR_FIX_4K_D8000_MSR  0x26b
+#define MTRR_FIX_4K_E0000_MSR  0x26c
+#define MTRR_FIX_4K_E8000_MSR  0x26d
+#define MTRR_FIX_4K_F0000_MSR  0x26e
+#define MTRR_FIX_4K_F8000_MSR  0x26f
 
 #if !defined(__ASSEMBLER__)
 
--
Quoted 2 lines

1.8.2.1

Regards,
Simon

#17 lore raw

PATCH 8/11 x86: Move VGA option rom macros to Kconfig

In reply to Bin Meng

Hi Bin,

Quoted 8 lines · Bin Meng

Move X86_OPTION_ROM_FILE & X86_OPTION_ROM_ADDR to arch/x86/Kconfig and rename them to VGA_BIOS_FILE & VGA_BIOS_ADDR which depend on HAVE_VGA_BIOS. The new names are consistent with other x86 binary blob options like HAVE_FSP/FSP_FILE/FSP_ADDR.

---

Quoted 10 lines
 Makefile                            |  4 ++--
 arch/x86/Kconfig                    | 22 ++++++++++++++++++++++
 configs/chromebook_link_defconfig   |  1 +
 configs/chromebox_panther_defconfig |  1 +
 configs/minnowmax_defconfig         |  1 +
 doc/README.x86                      |  2 +-
 drivers/pci/pci_rom.c               |  6 +++---
 include/configs/minnowmax.h         |  3 ---
 include/configs/x86-chromebook.h    |  3 ---
 9 files changed, 31 insertions(+), 12 deletions(-)

It's good to move these to Kconfig. But why should we rename it from option ROM to VGA ROM? Is it not possible that we might want to run some other ROM?

[snip]

Regards,
Simon

#23 lore raw

PATCH 10/11 x86: crownbay: Enable graphics support

In reply to Bin Meng

Hi,

Quoted 5 lines · Bin Meng

Enable graphics support on Intel Crown Bay board With the help of vgabios for Intel TunnelCreek IGD. Tested with an external LVDS panel connected to X4 connector and SDVO adapter connected to X9 connector on the board.

Quoted 8 lines

---

 configs/crownbay_defconfig |  3 +++
 doc/README.x86             | 20 +++++++++++++-------
 include/configs/crownbay.h | 14 +++++++-------
 3 files changed, 23 insertions(+), 14 deletions(-)

Nit below, otherwise:

Quoted 24 lines
configs/crownbay_defconfig +3 -0
index e4edad0..de24bb6 100644
@@ -4,10 +4,13 @@ CONFIG_DEFAULT_DEVICE_TREE="crownbay"
 CONFIG_TARGET_CROWNBAY=y
 CONFIG_SMP=y
 CONFIG_MAX_CPUS=2
+CONFIG_HAVE_VGA_BIOS=y
 CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_NET=y
 CONFIG_OF_CONTROL=y
 CONFIG_CPU=y
+CONFIG_VIDEO_VESA=y
+CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_DM_RTC=y
doc/README.x86 +0 -0
index 7f3914f..646eff1 100644

doc/README.x86 binary using any hex editor (eg: bvi). Go to the offset 0x1fcd8 of the FSP · line 116

Quoted 4 lines
doc/README.x86 +1 -0
@@ -113,6 +113,10 @@ binary using any hex editor (eg: bvi). Go to the offset 0x1fcd8 of the FSP
 binary, change the following five bytes values from orginally E8 42 FF FF FF
 to B8 00 80 0B 00.
 
+As for the video ROM, you need manually extract it from the Intel provided

nit: Intel-provided

Quoted 78 lines
doc/README.x86 +12 -7
+BIOS for Crown Bay here [6], using the AMI MMTool [7]. Check PCI option ROM
+ID 8086:4108, extract and save it as vga.bin in the board directory.
+
 Now you can build U-Boot and obtain u-boot.rom
 
 $ make crownbay_defconfig
@@ -254,7 +258,7 @@ If you want to check both consoles, use '-serial stdio'.
 
 CPU Microcode
 -------------
-Modern CPUs usually require a special bit stream called microcode [6] to be
+Modern CPUs usually require a special bit stream called microcode [8] to be
 loaded on the processor after power up in order to function properly. U-Boot
 has already integrated these as hex dumps in the source tree.
 
@@ -265,9 +269,9 @@ Additional application processors (AP) can be brought up by U-Boot. In order to
 have an SMP kernel to discover all of the available processors, U-Boot needs to
 prepare configuration tables which contain the multi-CPUs information before
 loading the OS kernel. Currently U-Boot supports generating two types of tables
-for SMP, called Simple Firmware Interface (SFI) [7] and Multi-Processor (MP) [8]
-tables. The writing of these two tables are controlled by two Kconfig options
-GENERATE_SFI_TABLE and GENERATE_MP_TABLE.
+for SMP, called Simple Firmware Interface (SFI) [9] and Multi-Processor (MP)
+[10] tables. The writing of these two tables are controlled by two Kconfig
+options GENERATE_SFI_TABLE and GENERATE_MP_TABLE.
 
 Driver Model
 ------------
@@ -372,6 +376,8 @@ References
 [3] http://www.coreboot.org/~stepan/pci8086,0166.rom
 [4] http://www.intel.com/content/www/us/en/embedded/design-tools/evaluation-platforms/atom-e660-eg20t-development-kit.html
 [5] http://www.intel.com/fsp
-[6] http://en.wikipedia.org/wiki/Microcode
-[7] http://simplefirmware.org
-[8] http://www.intel.com/design/archives/processors/pro/docs/242016.htm
+[6] http://www.intel.com/content/www/us/en/secure/intelligent-systems/privileged/e6xx-35-b1-cmc22211.html
+[7] http://www.ami.com/products/bios-uefi-tools-and-utilities/bios-uefi-utilities/
+[8] http://en.wikipedia.org/wiki/Microcode
+[9] http://simplefirmware.org
+[10] http://www.intel.com/design/archives/processors/pro/docs/242016.htm
include/configs/crownbay.h +7 -8
index 0e1f046..6cf53a3 100644
@@ -32,15 +32,16 @@
 #define CONFIG_PCI_IO_PHYS             CONFIG_PCI_IO_BUS
 #define CONFIG_PCI_IO_SIZE             0xe000
 
+#define CONFIG_PCI_CONFIG_HOST_BRIDGE
 #define CONFIG_SYS_EARLY_PCI_INIT
 #define CONFIG_PCI_PNP
 #define CONFIG_E1000
 
-#define CONFIG_STD_DEVICES_SETTINGS     "stdin=serial\0" \
-                                       "stdout=serial\0" \
-                                       "stderr=serial\0"
+#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,vga,usbkbd\0" \
+                                       "stdout=serial,vga\0" \
+                                       "stderr=serial,vga\0"
 
-#define CONFIG_SCSI_DEV_LIST            \
+#define CONFIG_SCSI_DEV_LIST           \
        {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SATA}
 
 #define CONFIG_SPI_FLASH_SST
@@ -55,9 +56,8 @@
 #define CONFIG_PCH_GBE
 #define CONFIG_PHYLIB
 
-/* Video is not supported */
-#undef CONFIG_VIDEO
-#undef CONFIG_CFB_CONSOLE
+/* TunnelCreek IGD support */
+#define CONFIG_VGA_AS_SINGLE_DEVICE
 
 /* Environment configuration */
 #define CONFIG_ENV_SECT_SIZE           0x1000
--
Quoted 2 lines

1.8.2.1

Regards,
Simon

#25 lore raw

PATCH 11/11 x86: Configure VESA parameters before loading Linux kernel

In reply to Bin Meng
Quoted 6 lines · Bin Meng

Store VESA parameters to Linux setup header so that vesafb driver in the kernel could work.

Quoted 7 lines

---

 arch/x86/include/asm/zimage.h |  1 +
 arch/x86/lib/zimage.c         |  2 ++
 drivers/pci/pci_rom.c         | 28 ++++++++++++++++++++++++++++
 include/vbe.h                 |  4 ++--
 4 files changed, 33 insertions(+), 2 deletions(-)
author
#5 lore raw

PATCH 2/11 x86: bios: Synchronize stack between real and protected mode

In reply to Simon Glass

Hi Simon,

Quoted 29 lines · Simon Glass

Hi,

Quoted 26 lines · Bin Meng

From: Jian Luo <[email protected]>

PCI option rom may use different SS during its execution, so it is not safe to assume esp pointed to the same location in the protected mode.

---

 arch/x86/lib/bios_asm.S | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/x86/lib/bios_asm.S +2 -0
index 4faa70e..a29fe0e 100644
@@ -246,6 +246,8 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
        push    %fs
        push    %gs
 
+       movw    %ss, %cs:__realmode_ss
+
        /* Clear DF to not break ABI assumptions */
        cld
 
Quoted 9 lines

arch/x86/lib/bios_asm.S __interrupt_handler_16bit = PTR_TO_REAL_MODE(.) · line 262

Quoted 4 lines
arch/x86/lib/bios_asm.S +0 -0
@@ -258,12 +260,22 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
 
        enter_protected_mode
 

Please can you add a comment here for the next person who changes this, about what is going on? It looks like it is saving and restoring the real mode SS register?

Will add a comment in v2.

Quoted 23 lines
Quoted 23 lines
arch/x86/lib/bios_asm.S +10 -0
+       movzwl  %cs:__realmode_ss, %ecx
+       shll    $4, %ecx
+       addl    %ecx, %esp
+
        /* Call the C interrupt handler */
        movl    $interrupt_handler, %eax
        call    *%eax
 
+       movzwl  %cs:__realmode_ss, %ecx
+       shll    $4, %ecx
+       subl    %ecx, %esp
+
        enter_real_mode
 
+       movw    %cs:__realmode_ss, %ss
+
        /*
         * Restore all registers, including those manipulated by the C
         * handler
@@ -276,6 +288,9 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
        popal
        iret
 
Quoted 7 lines

arch/x86/lib/bios_asm.S __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)

Quoted 7 lines
arch/x86/lib/bios_asm.S +3 -1
+__realmode_ss = PTR_TO_REAL_MODE(.)
+       .word   0
+
        .globl asm_realmode_code_size
 asm_realmode_code_size:
        .long  . - asm_realmode_code
--

Regards,
Bin

author
#18 lore raw

PATCH 8/11 x86: Move VGA option rom macros to Kconfig

In reply to Simon Glass

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Bin,

Quoted 8 lines · Bin Meng

Move X86_OPTION_ROM_FILE & X86_OPTION_ROM_ADDR to arch/x86/Kconfig and rename them to VGA_BIOS_FILE & VGA_BIOS_ADDR which depend on HAVE_VGA_BIOS. The new names are consistent with other x86 binary blob options like HAVE_FSP/FSP_FILE/FSP_ADDR.

---

Quoted 10 lines
 Makefile                            |  4 ++--
 arch/x86/Kconfig                    | 22 ++++++++++++++++++++++
 configs/chromebook_link_defconfig   |  1 +
 configs/chromebox_panther_defconfig |  1 +
 configs/minnowmax_defconfig         |  1 +
 doc/README.x86                      |  2 +-
 drivers/pci/pci_rom.c               |  6 +++---
 include/configs/minnowmax.h         |  3 ---
 include/configs/x86-chromebook.h    |  3 ---
 9 files changed, 31 insertions(+), 12 deletions(-)
Quoted 4 lines

It's good to move these to Kconfig. But why should we rename it from option ROM to VGA ROM? Is it not possible that we might want to run some other ROM?

I think the only ROM we want to support in U-Boot is VGA, so I changed it to specifically mention VGA. There are other two typical type of ROMs, PXE ROM for network boot and AHCI ROM for disk read/write which U-Boot has native drivers to do that. Besides, I suspect current bios interrupts codes could handle PXE ROM or AHCI ROM call correctly as they were written for VBE calls.

Quoted 2 lines

[snip]

Regards,
Bin

#19 lore raw

PATCH 8/11 x86: Move VGA option rom macros to Kconfig

Hi Bin,

Quoted 30 lines · Bin Meng

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Bin,

Quoted 8 lines · Bin Meng

Move X86_OPTION_ROM_FILE & X86_OPTION_ROM_ADDR to arch/x86/Kconfig and rename them to VGA_BIOS_FILE & VGA_BIOS_ADDR which depend on HAVE_VGA_BIOS. The new names are consistent with other x86 binary blob options like HAVE_FSP/FSP_FILE/FSP_ADDR.

---

Quoted 10 lines
 Makefile                            |  4 ++--
 arch/x86/Kconfig                    | 22 ++++++++++++++++++++++
 configs/chromebook_link_defconfig   |  1 +
 configs/chromebox_panther_defconfig |  1 +
 configs/minnowmax_defconfig         |  1 +
 doc/README.x86                      |  2 +-
 drivers/pci/pci_rom.c               |  6 +++---
 include/configs/minnowmax.h         |  3 ---
 include/configs/x86-chromebook.h    |  3 ---
 9 files changed, 31 insertions(+), 12 deletions(-)
Quoted 4 lines

It's good to move these to Kconfig. But why should we rename it from option ROM to VGA ROM? Is it not possible that we might want to run some other ROM?

Quoted 6 lines

I think the only ROM we want to support in U-Boot is VGA, so I changed it to specifically mention VGA. There are other two typical type of ROMs, PXE ROM for network boot and AHCI ROM for disk read/write which U-Boot has native drivers to do that. Besides, I suspect current bios interrupts codes could handle PXE ROM or AHCI ROM call correctly as they were written for VBE calls.

OK, sounds reasonable. We could generalise later if such supported becomes needed. But it sounds unlikely from what you are saying.

Regards,
Simon