[PATCH 2/3] x86: drop legacy (PC BIOS) boot in favor of EFI

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Mar 23 07:50:34 GMT 2021


The 16-bit port has experienced bitrot and failed to compile with more
recent linkers for at least a year. Fixing the linker error is insufficient
to restore a barebox that can boot to shell. This continued breakage likely
means that there are no users interested in updating. As new x86 projects
should be using MACH_EFI_GENERIC anyway, retire support for 16-bit legacy
boot (MACH_X86_GENERIC).

Acked-by: Juergen Borleis <jbe at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 Documentation/boards/x86.rst                  | 153 -----
 Makefile                                      |  29 +-
 arch/x86/Kconfig                              |  63 +-
 arch/x86/Makefile                             |  32 +-
 arch/x86/bios/Makefile                        |   3 -
 arch/x86/bios/bios_disk.S                     |  57 --
 arch/x86/bios/memory16.S                      |  54 --
 arch/x86/bios/traveler.S                      | 166 ------
 arch/x86/boards/x86_generic/Makefile          |   4 -
 arch/x86/boards/x86_generic/disk_bios_drive.c |  33 --
 arch/x86/boards/x86_generic/env/bin/boot      |  37 --
 arch/x86/boards/x86_generic/env/bin/init      |  15 -
 arch/x86/boards/x86_generic/env/config        |  31 -
 arch/x86/boards/x86_generic/envsector.h       |  24 -
 arch/x86/boards/x86_generic/generic_pc.c      |  18 -
 .../boards/x86_generic/intf_platform_ide.c    |  80 ---
 arch/x86/boards/x86_generic/serial_ns16550.c  |  35 --
 arch/x86/boot/Kconfig                         |  20 -
 arch/x86/boot/Makefile                        |  13 -
 arch/x86/boot/a20.c                           | 166 ------
 arch/x86/boot/bioscall.S                      |  90 ---
 arch/x86/boot/boot.h                          | 189 ------
 arch/x86/boot/boot_hdisk.S                    | 170 ------
 arch/x86/boot/boot_main.S                     |  39 --
 arch/x86/boot/main_entry.c                    |  24 -
 arch/x86/boot/pmjump.S                        |  82 ---
 arch/x86/boot/prepare_uboot.c                 |  80 ---
 arch/x86/boot/regs.c                          |  29 -
 arch/x86/boot/tty.c                           |  41 --
 arch/x86/configs/generic_defconfig            |  26 -
 arch/x86/include/asm/syslib.h                 |  13 -
 arch/x86/lib/.gitignore                       |   1 -
 arch/x86/lib/Makefile                         |   9 -
 arch/x86/lib/asm-offsets.c                    |   6 -
 arch/x86/lib/barebox.lds.S                    | 161 ------
 arch/x86/lib/gdt.c                            |  38 --
 arch/x86/lib/linux_start.S                    |  55 --
 arch/x86/lib/memory.c                         |  49 --
 arch/x86/mach-i386/Kconfig                    |  13 -
 arch/x86/mach-i386/Makefile                   |   2 -
 arch/x86/mach-i386/include/mach/barebox.lds.h |  82 ---
 arch/x86/mach-i386/pit_timer.c                |  53 --
 commands/Kconfig                              |  20 -
 commands/Makefile                             |   1 -
 commands/linux16.c                            | 331 -----------
 common/partitions.c                           |   2 -
 common/partitions/dos.c                       |  29 -
 drivers/ata/Kconfig                           |   9 -
 drivers/ata/Makefile                          |   1 -
 drivers/ata/disk_bios_drive.c                 | 302 ----------
 scripts/Makefile                              |   1 -
 scripts/setupmbr/.gitignore                   |   1 -
 scripts/setupmbr/Makefile                     |   3 -
 scripts/setupmbr/arch.h                       |  55 --
 scripts/setupmbr/setupmbr.c                   | 545 ------------------
 55 files changed, 13 insertions(+), 3572 deletions(-)
 delete mode 100644 Documentation/boards/x86.rst
 delete mode 100644 arch/x86/bios/Makefile
 delete mode 100644 arch/x86/bios/bios_disk.S
 delete mode 100644 arch/x86/bios/memory16.S
 delete mode 100644 arch/x86/bios/traveler.S
 delete mode 100644 arch/x86/boards/x86_generic/Makefile
 delete mode 100644 arch/x86/boards/x86_generic/disk_bios_drive.c
 delete mode 100644 arch/x86/boards/x86_generic/env/bin/boot
 delete mode 100644 arch/x86/boards/x86_generic/env/bin/init
 delete mode 100644 arch/x86/boards/x86_generic/env/config
 delete mode 100644 arch/x86/boards/x86_generic/envsector.h
 delete mode 100644 arch/x86/boards/x86_generic/generic_pc.c
 delete mode 100644 arch/x86/boards/x86_generic/intf_platform_ide.c
 delete mode 100644 arch/x86/boards/x86_generic/serial_ns16550.c
 delete mode 100644 arch/x86/boot/Kconfig
 delete mode 100644 arch/x86/boot/Makefile
 delete mode 100644 arch/x86/boot/a20.c
 delete mode 100644 arch/x86/boot/bioscall.S
 delete mode 100644 arch/x86/boot/boot.h
 delete mode 100644 arch/x86/boot/boot_hdisk.S
 delete mode 100644 arch/x86/boot/boot_main.S
 delete mode 100644 arch/x86/boot/main_entry.c
 delete mode 100644 arch/x86/boot/pmjump.S
 delete mode 100644 arch/x86/boot/prepare_uboot.c
 delete mode 100644 arch/x86/boot/regs.c
 delete mode 100644 arch/x86/boot/tty.c
 delete mode 100644 arch/x86/configs/generic_defconfig
 delete mode 100644 arch/x86/include/asm/syslib.h
 delete mode 100644 arch/x86/lib/.gitignore
 delete mode 100644 arch/x86/lib/barebox.lds.S
 delete mode 100644 arch/x86/lib/gdt.c
 delete mode 100644 arch/x86/lib/linux_start.S
 delete mode 100644 arch/x86/lib/memory.c
 delete mode 100644 arch/x86/mach-i386/Kconfig
 delete mode 100644 arch/x86/mach-i386/Makefile
 delete mode 100644 arch/x86/mach-i386/include/mach/barebox.lds.h
 delete mode 100644 arch/x86/mach-i386/pit_timer.c
 delete mode 100644 commands/linux16.c
 delete mode 100644 drivers/ata/disk_bios_drive.c
 delete mode 100644 scripts/setupmbr/.gitignore
 delete mode 100644 scripts/setupmbr/Makefile
 delete mode 100644 scripts/setupmbr/arch.h
 delete mode 100644 scripts/setupmbr/setupmbr.c

diff --git a/Documentation/boards/x86.rst b/Documentation/boards/x86.rst
deleted file mode 100644
index c0d5a64b9d45..000000000000
--- a/Documentation/boards/x86.rst
+++ /dev/null
@@ -1,153 +0,0 @@
-x86
-===
-
-.. note::
-   This is about legacy x86 PC boot, which is not as well supported as booting
-   under UEFI. Refer to :doc:`boards/efi.rst` for documentation on the barebox
-   EFI support.
-
-Features
---------
-
-barebox can act as a bootloader for PC based systems. In this case a special
-binary layout will be created to be able to store it on some media the PC
-BIOS can boot from. It can boot Linux kernels stored also on the same boot
-media and be configured at runtime, with the possibility to store the changed
-configuration on the boot media.
-
-Restrictions
-------------
-
-Due to some BIOS and barebox restrictions the boot media must be
-prepared in some special way:
-
-  * barebox must be stored in the MBR (Master Boot Record) of the boot
-    media. Currently its not possible to store and boot it in one of
-    the partition sectors to use it as a second stage loader). This is
-    no eternal restriction. It only needs further effort to add this
-    feature.
-  * barebox currently cannot run a chained boot loader. Also, this is
-    no external restriction, only further effort needed.
-  * barebox comes with limited filesystem support. There is currently
-    no support for the most common and popular filesystems used in the
-    \*NIX world. This restricts locations where to store a kernel and
-    other runtime information
-  * barebox must be stored to the first n sectors of the boot media.
-    To ensure this does not collide with partitions on the boot media,
-    the first partition must start at a sector behind the ones barebox
-    occupies.
-  * barebox handles its runtime configuration in a special way: It
-    stores it in a binary way into some reserved sectors ("persistant
-    storage").
-
-Boot Preparations
------------------
-
-To store the barebox image to a boot media, it comes with the tool
-setupmbr in the directory  scripts/setupmbr/ . To be able to use it on
-the boot media of your choice, some preparations are required.
-
-Keep Sectors free
------------------
-
-Build the barebox image and check its size. At least this amount of
-sectors must be kept free after the MBR prior the first partition. Do this
-simple calulation:
-
-.. code-block:: none
-
-  sectors = (size of barebox image + 511) / 512
-
-To be able to store the runtime configuration, further free sectors are
-required. Its up to you and your requirements, how large this persistant
-storage must be. If you need 16 kiB for this purpose, you need to keep
-additional 32 sectors free.
-
-For this example we are reserving 300 sectors for the barebox image and
-additionaly 32 sectors for the persistant storage. So, the first partition on
-the boot media must start at sector 333 or later.
-
-Run the  fdisk tool to setup such a partition table:
-
-.. code-block:: none
-
-  [jb at host]~> fdisk /dev/sda
-  Command (m for help): p
-  
-  Disk /dev/sda: 20.7 MB, 212680704 bytes
-  16 heads, 63 sectors/track, 406 cylinders
-  Units = cylinders of 1008 * 512 = 516096 bytes
-  
-  Device Boot      Start         End      Blocks   Id  System
-
-Change the used units to  sectors for easier handling.
-
-.. code-block:: none
-
-  Command (m for help): u
-  Changing display/entry units to sectors
-  
-  Command (m for help): p
-
-  Disk /dev/sda: 20.7 MB, 212680704 bytes
-  16 heads, 63 sectors/track, 406 cylinders, total 409248 sectors
-  Units = sectors of 1 * 512 = 512 bytes
-  
-  Device Boot      Start         End      Blocks   Id  System
-
-Now its possible to create the first partition with the required offset:
-
-.. code-block:: none
-
-  Command (m for help): n
-  Command action
-     e   extended
-     p   primary partition (1-4)
-  p
-  Partition number (1-4): 1
-  First sector (63-409247, default 63): 333
-  Last sector or +size or +sizeM or +sizeK (333-409247, default 409247): +18M
-  Command (m for help): p
-  
-  Disk /dev/sda: 20.7 MB, 212680704 bytes
-  16 heads, 63 sectors/track, 406 cylinders, total 409248 sectors
-  Units = sectors of 1 * 512 = 512 bytes
-  
-          Device Boot      Start         End      Blocks   Id  System
-  /dev/sda                   333       35489       17578+  83  Linux
-
-That's all. Do whatever is required now with the new partition (formatting
-and populating the root filesystem for example) to make it useful.
-
-In the next step, barebox gets installed to this boot media::
-
-  [jb at host]~> scripts/setupmbr/setupmbr -s 32 -m ./barebox -d /dev/sda
-
-This command writes the barebox image file './barebox' onto the device
- /dev/sda.
-
-The  -s option will keep the persistant storage sectors free and untouched
-and set flags in the MBR to forward its existance, size and location to
-barebox at runtime.  setupmbr also does not change the partition table.
-
-The barebox image gets stored on the boot media like this::
-
-  sector 0   1             33                              333
-         |---|-------------|--------------- ~~~ ------------|--------------
-        MBR    persistant              barebox                 first
-                storage               main image              partition
-
-If the  -s option is omitted, the "persistant storage" part simply does
-not exist:
-
-.. code-block:: none
-
-  sector 0   1                              333
-         |---|--------------- ~~~ ------------|--------------
-        MBR               barebox                 first
-                         main image              partition
-
-**NOTE:** the ``setupmbr`` tool is also working on real image file than on device
-nodes only. So, there is no restriction what kind of file will be
-modified.
-
diff --git a/Makefile b/Makefile
index 9b00acf54c6f..459cee167cd5 100644
--- a/Makefile
+++ b/Makefile
@@ -890,33 +890,6 @@ quiet_cmd_barebox_mkimage = MKIMAGE $@
 barebox.uimage: $(KBUILD_BINARY) FORCE
 	$(call if_changed,barebox_mkimage)
 
-ifdef CONFIG_X86
-barebox.S barebox.s: barebox
-ifdef CONFIG_X86_HDBOOT
-	@echo "-------------------------------------------------" > barebox.S
-	@echo " * MBR content" >> barebox.S
-	$(Q)$(OBJDUMP) -j .bootsector -mi8086 -d barebox >> barebox.S
-	@echo "-------------------------------------------------" >> barebox.S
-	@echo " * Boot loader content" >> barebox.S
-	$(Q)$(OBJDUMP) -j .bootstrapping -mi8086 -d barebox >> barebox.S
-endif
-	@echo "-------------------------------------------------" >> barebox.S
-	@echo " * Regular Text content" >> barebox.S
-	$(Q)$(OBJDUMP) -j .text -d barebox >> barebox.S
-	@echo "-------------------------------------------------" >> barebox.S
-	@echo " * Regular Data content" >> barebox.S
-	$(Q)$(OBJDUMP) -j .data -d barebox >> barebox.S
-	@echo "-------------------------------------------------" >> barebox.S
-	@echo " * Commands content" >> barebox.S
-	$(Q)$(OBJDUMP) -j .barebox_cmd -d barebox >> barebox.S
-	@echo "-------------------------------------------------" >> barebox.S
-	@echo " * Init Calls content" >> barebox.S
-	$(Q)$(OBJDUMP) -j .barebox_initcalls -d barebox >> barebox.S
-else
-barebox.S barebox.s: barebox FORCE
-	$(call if_changed,disasm)
-endif
-
 # barebox image
 barebox: $(BAREBOX_LDS) $(BAREBOX_OBJS) $(kallsyms.o) FORCE
 	$(call if_changed_rule,barebox__)
@@ -1118,7 +1091,7 @@ endif # CONFIG_MODULES
 # Directories & files removed with 'make clean'
 CLEAN_DIRS  += $(MODVERDIR)
 CLEAN_FILES +=	barebox System.map include/generated/barebox_default_env.h \
-                .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
+                .tmp_version .tmp_barebox* barebox.bin barebox.map \
 		.tmp_kallsyms* barebox.ldr compile_commands.json \
 		scripts/bareboxenv-target barebox-flash-image \
 		barebox.srec barebox.s5p barebox.ubl barebox.zynq \
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e942c79cbd49..311c3d1a8ec5 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -9,17 +9,7 @@ config X86
 
 config ARCH_TEXT_BASE
 	hex
-	default 0x00007c00 if MACH_X86_GENERIC
-	default 0x0 if MACH_EFI_GENERIC
-
-config BOARD_LINKER_SCRIPT
-	bool
-	default n
-
-config GENERIC_LINKER_SCRIPT
-	bool
-	default y
-	depends on !BOARD_LINKER_SCRIPT
+	default 0x0
 
 menu "ARCH specific settings"
 
@@ -45,51 +35,18 @@ config X86_64
 
 endmenu
 
-config X86_BOOTLOADER
-	bool
-	select X86_32
-	select HAS_MODULES
-	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
-	select HAVE_CONFIGURABLE_TEXT_BASE
-
-choice
-	prompt "Select your board"
-
-config MACH_X86_GENERIC
-	bool "Generic x86"
-	select X86_BOOTLOADER
-	depends on !X86_EFI 
-	help
-	  Say Y here if you want barebox to be your BIOS based bootloader
-
 config MACH_EFI_GENERIC
-	bool "Generic EFI"
-	depends on X86_EFI 
+	def_bool y
+	depends on X86_EFI
 	select HAS_DEBUG_LL
 	help
 	  Say Y here if you want barebox to be your EFI based bootloader
 
-endchoice
-
-choice
-	prompt "Bring up type"
 
-	config X86_EFI
-		bool "EFI"
-		select EFI_BOOTUP
-		select EFI_GUID
-		select EFI_DEVICEPATH
-		select PRINTF_UUID
-		select CLOCKSOURCE_EFI_X86
-
-	config X86_BIOS_BRINGUP
-		bool "16 bit BIOS"
-		help
-		  Barebox will act as a BIOS based bootloader. This includes
-		  some 16 bit real mode code and some restrictions everyone knows
-		  from BIOS based systems.
-
-endchoice
-
-source "arch/x86/boot/Kconfig"
-source "arch/x86/mach-i386/Kconfig"
+config X86_EFI
+	def_bool y
+	select EFI_BOOTUP
+	select EFI_GUID
+	select EFI_DEVICEPATH
+	select PRINTF_UUID
+	select CLOCKSOURCE_EFI_X86
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 61e51abc7111..fd871ca21419 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -1,12 +1,9 @@
-KBUILD_DEFCONFIG := generic_defconfig
+KBUILD_DEFCONFIG := efi_defconfig
 
 KBUILD_CPPFLAGS += -D__X86__
 
-board-$(CONFIG_MACH_X86_GENERIC) := x86_generic
-
 TEXT_BASE = $(CONFIG_TEXT_BASE)
 
-ifeq ($(CONFIG_X86_EFI),y)
 machine-y := efi
 KBUILD_CFLAGS += -fpic -fshort-wchar -mno-sse -mno-mmx
 ifeq ($(CONFIG_X86_32),y)
@@ -14,13 +11,6 @@ ifeq ($(CONFIG_X86_32),y)
 else
 	TARGET = efi-app-x86_64
 endif
-else
-KBUILD_CPPFLAGS += -fno-strict-aliasing
-KBUILD_CPPFLAGS += -march=i386 -DTEXT_BASE=$(TEXT_BASE) \
-	-fno-unwind-tables -fno-asynchronous-unwind-tables
-
-machine-y := i386
-endif
 
 ifeq ($(CONFIG_X86_32),y)
 	UTS_MACHINE := i386
@@ -48,25 +38,17 @@ machdirs := $(patsubst %,arch/x86/mach-%/,$(machine-y))
 
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
 
-ifneq ($(board-y),)
-BOARD  := arch/x86/boards/$(board-y)/
-else
-BOARD  :=
-endif
-
 ifneq ($(machine-y),)
 MACH  := arch/x86/mach-$(machine-y)/
 else
 MACH  :=
 endif
 
-common-y += $(BOARD) $(MACH)
+common-y += $(MACH)
 common-y += arch/x86/lib/
-common-$(CONFIG_X86_BIOS_BRINGUP) += arch/x86/bios/
 
 # arch/x86/cpu/
 
-ifeq ($(CONFIG_X86_EFI),y)
 lds-$(CONFIG_X86_32)   := arch/x86/mach-efi/elf_ia32_efi.lds
 lds-$(CONFIG_X86_64)   := arch/x86/mach-efi/elf_x86_64_efi.lds
 
@@ -92,16 +74,6 @@ barebox.efi: $(KBUILD_BINARY) FORCE
 
 KBUILD_IMAGE := barebox.efi
 
-else
-common-y += arch/x86/boot/
-
-lds-$(CONFIG_GENERIC_LINKER_SCRIPT)   := arch/x86/lib/barebox.lds
-lds-$(CONFIG_BOARD_LINKER_SCRIPT)     := $(BOARD)/barebox.lds
-
-endif
-
 KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
 
 CLEAN_FILES += $(lds-y)
-CLEAN_FILES    += arch/x86/lib/barebox.lds barebox.map barebox.S
-
diff --git a/arch/x86/bios/Makefile b/arch/x86/bios/Makefile
deleted file mode 100644
index 414ee42a4a74..000000000000
--- a/arch/x86/bios/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-y += memory16.o
-obj-y += traveler.o
-obj-y += bios_disk.o
diff --git a/arch/x86/bios/bios_disk.S b/arch/x86/bios/bios_disk.S
deleted file mode 100644
index c2a824ed6eb4..000000000000
--- a/arch/x86/bios/bios_disk.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-/* SPDX-FileCopyrightText: 1999-2008 Free Software Foundation, Inc. */
-
-/* Mostly stolen from the GRUB2 project */
-
-/**
- * @file
- * @brief Do BIOS calls to load or save data from disks
- *
- * @note These functions are running in flat and real mode. Due to some
- * other restrictions these routines must running from an address
- * space below 0x10000
- */
-
-/*
- *   int bios_disk_rw_int13_extensions (int ah, int drive, void *dap)
- *
- *   Call IBM/MS INT13 Extensions (int 13 %ah=AH) for DRIVE. DAP
- *   is passed for disk address packet. If an error occurs, return
- *   non-zero, otherwise zero.
- */
-	.section .boot.text.bios_disk_rw_int13_extensions, "ax"
-	.code32
-	.globl bios_disk_rw_int13_extensions
-	.type bios_disk_rw_int13_extensions, @function
-
-	.extern prot_to_real
-	.extern real_to_prot
-
-bios_disk_rw_int13_extensions:
-	pushl %ebp
-	pushl %esi
-
-	/* compute the address of disk_address_packet */
-	movw %cx, %si
-	xorw %cx, %cx
-	shrl $4, %ecx	/* save the segment to cx */
-
-	movb %al, %dh
-	call prot_to_real	/* enter real mode right now */
-
-	.code16
-	movb %dh, %ah
-	movw %cx, %ds
-	int $0x13		/* do the operation */
-	movb %ah, %dl		/* save return value */
-	/* back to protected mode */
-	DATA32 call real_to_prot
-
-	.code32
-	movb %dl, %al	/* return value in %eax */
-
-	popl %esi
-	popl %ebp
-
-	ret
diff --git a/arch/x86/bios/memory16.S b/arch/x86/bios/memory16.S
deleted file mode 100644
index e4aef2f256ea..000000000000
--- a/arch/x86/bios/memory16.S
+++ /dev/null
@@ -1,54 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-/* This code was inspired by the GRUB2 project. */
-
-/**
- * @file
- * @brief Query the memory layout information from the BIOS
- *
- * Note: This function is running in flat and real mode. Due to some
- * other restrictions it must running from an address space below 0x10000
- */
-
-/**
- * @fn unsigned short bios_get_memsize(void)
- * @brief Does a BIOS call "INT 15H, AH=88H" to get extended memory size
- * @return Extended memory size in KB
- *
- * @note This call is limited to 64 MiB. So, if the system provides more than
- * 64 MiB of memory, still 64 MiB are reported.
- *
- */
-
-
-	.section .boot.text.bios_get_memsize, "ax"
-	.code32
-	.globl bios_get_memsize
-	.type bios_get_memsize, @function
-
-	.extern prot_to_real
-
-bios_get_memsize:
-
-	pushl %ebp
-
-	call prot_to_real	/* enter real mode */
-	.code16
-
-	movb $0x88, %ah
-	int $0x15
-
-	movw %ax, %dx
-
-	DATA32	call real_to_prot
-
-	.code32
-
-	movw %dx, %ax
-
-	popl %ebp
-	ret
-
-	.size bios_get_memsize, .-bios_get_memsize
-
diff --git a/arch/x86/bios/traveler.S b/arch/x86/bios/traveler.S
deleted file mode 100644
index 1c11c9dc747d..000000000000
--- a/arch/x86/bios/traveler.S
+++ /dev/null
@@ -1,166 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-/* Mostly stolen from the GRUB2 project */
-
-/**
- * @file
- * @brief Switch from the flat mode world into the real mode world and vice versa
- *
- * Note: These functions are *called* and return in a different operating mode
- */
-
-/**
- * @fn void real_to_prot(void)
- * @brief Switch from temp. real mode back to flat mode
- *
- * Called from a 32 bit flat mode segment and returns into a 16 bit segment
- */
-
-/**
- * @fn void prot_to_real(void)
- * @brief Switch from flat mode to real mode
- *
- * Called from a 16 bit real mode segment and returns into a 32 bit segment
- */
-
-#include <asm/modes.h>
-
-	.file "walkyrie.S"
-
-/* keep the current flat mode stack pointer, while playing in real mode */
-	.section .boot.data.protstack
-	.code32
-protstack: .long 4
-/* temp. store */
-return_addr: .long 4
-
-
-	.section .boot.text.real_to_prot, "ax"
-	.code16
-	.globl	real_to_prot
-	.type	real_to_prot, @function
-
-/* Note: This routine should not change any other standard registers than eax */
-real_to_prot:
-	/*
-	 * Always disable the interrupts, when returning to flat mode
-	 */
-	cli
-
-	/* turn on protected mode */
-	movl %cr0, %eax
-	orl $0x00000001, %eax
-	movl %eax, %cr0
-
-	/* jump to relocation, flush prefetch queue, and reload %cs */
-	DATA32 ljmp $__BOOT_CS, $return_to_flatmode
-	.size real_to_prot, .-real_to_prot
-
-/* ----------------------------------------------------------------------- */
-	.section .boot.text.return_to_flatmode, "ax"
-	.type return_to_flatmode, @function
-	.code32
-
-return_to_flatmode:
-	/* reload other segment registers */
-	movw $__BOOT_DS, %ax
-	movw %ax, %ds
-	movw %ax, %es
-	movw %ax, %fs
-	movw %ax, %gs
-	movw %ax, %ss
-
-	/* move the return address from the real mode to the flat mode stack */
-	movl (%esp), %eax
-	movl %eax, return_addr
-
-	/* setup again the flat mode stack */
-	movl protstack, %eax
-	movl %eax, %esp
-	movl %eax, %ebp
-
-	movl return_addr, %eax
-	movl %eax, (%esp)
-
-	/* flag we returned happy here */
-	xorl %eax, %eax
-	ret
-	.size return_to_flatmode, .-return_to_flatmode
-
-/* ------------------------------------------------------------------------ */
-
-/* Note: This routine should not change any other standard registers than eax */
-
-	.section .boot.text.prot_to_real, "ax"
-	.globl prot_to_real
-	.type prot_to_real, @function
-	.extern boot_stack
-	.code32
-
-prot_to_real:
-	/* save the protected mode stack */
-	movl %esp, %eax
-	movl %eax, protstack
-
-	/* prepare the real mode stack */
-	/* - address to call to the top of this stack */
-	movl (%esp), %eax
-	movl %eax, boot_stack - 4
-
-	/* - the stack itself */
-	movl $boot_stack - 4, %eax
-	movl %eax, %esp
-	movl %eax, %ebp
-
-	/* prepare segments limits to 16 bit */
-	movw $__REAL_DS, %ax
-	movw %ax, %ds
-	movw %ax, %es
-	movw %ax, %fs
-	movw %ax, %gs
-	movw %ax, %ss
-
-	/* at last, also limit the code segment to 16 bit */
-	ljmp $__REAL_CS, $return_to_realmode
-	.size prot_to_real, .-prot_to_real
-
-/* ----------------------------------------------------------------------- */
-
-	.section .boot.text.return_to_realmode, "ax"
-	.globl return_to_realmode
-	.type return_to_realmode, @function
-	.code16
-
-return_to_realmode:
-	/* disable protected mode */
-	movl %cr0, %eax
-	andl $(~0x00000001), %eax
-	movl %eax, %cr0
-
-	/*
-	 * all the protected mode settings are still cached in the CPU.
-	 * Refresh them by re-loading all registers in realmode
-	 * Start with the CS, continue with the data registers
-	 */
-	ljmp $0, $enter_realmode
-
-enter_realmode:
-	xorl %eax, %eax
-	movw %ax, %ds
-	movw %ax, %es
-	movw %ax, %fs
-	movw %ax, %gs
-	movw %ax, %ss
-	/*
-	 * back in plain real mode now, we can play again with the BIOS
-	 */
-
-	/* restore interrupts */
-	sti
-
-	/* return on realmode stack! */
-	DATA32 ret
-
-	.size return_to_realmode, .-return_to_realmode
-
diff --git a/arch/x86/boards/x86_generic/Makefile b/arch/x86/boards/x86_generic/Makefile
deleted file mode 100644
index fca707dd8b29..000000000000
--- a/arch/x86/boards/x86_generic/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-obj-y += generic_pc.o
-obj-$(CONFIG_DISK_INTF_PLATFORM_IDE) += intf_platform_ide.o
-obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
-obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial_ns16550.o
diff --git a/arch/x86/boards/x86_generic/disk_bios_drive.c b/arch/x86/boards/x86_generic/disk_bios_drive.c
deleted file mode 100644
index c8e9ae85232a..000000000000
--- a/arch/x86/boards/x86_generic/disk_bios_drive.c
+++ /dev/null
@@ -1,33 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/**
- * @file
- * @brief Generic PC support for the BIOS disk interface
- */
-
-#include <common.h>
-#include <driver.h>
-#include <init.h>
-#include <linux/err.h>
-#include "envsector.h"
-
-static int bios_disk_init(void)
-{
-	struct cdev *cdev;
-
-	add_generic_device("biosdrive", DEVICE_ID_DYNAMIC, NULL, 0, 0,
-			   IORESOURCE_MEM, NULL);
-
-	if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
-		cdev = devfs_add_partition("biosdisk0",
-				pers_env_storage * 512,
-				(unsigned)pers_env_size * 512,
-				DEVFS_PARTITION_FIXED, "env0");
-		printf("Partition: %ld\n", IS_ERR(cdev) ? PTR_ERR(cdev) : 0);
-	} else
-		printf("No persistent storage defined\n");
-
-	return 0;
-}
-device_initcall(bios_disk_init);
diff --git a/arch/x86/boards/x86_generic/env/bin/boot b/arch/x86/boards/x86_generic/env/bin/boot
deleted file mode 100644
index fcfffe319424..000000000000
--- a/arch/x86/boards/x86_generic/env/bin/boot
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-if [ x$1 = xdisk ]; then
-	root=disk
-	kernel=disk
-fi
-
-if [ x$1 = xnet ]; then
-	root=net
-	kernel=net
-fi
-
-if [ x$ip = xdhcp ]; then
-	bootargs="$bootargs ip=dhcp"
-else
-	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::"
-fi
-
-if [ x$root = xdisk ]; then
-	bootargs="$bootargs root=$rootpart_disk rootfstype=$rootpart_fs rw"
-else
-	bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp rw"
-fi
-
-if [ $kernel = net ]; then
-	if [ x$ip = xdhcp ]; then
-		dhcp
-	fi
-	tftp $uimage uImage || exit 1
-	bootm uImage
-else
-	bootargs="BOOT_IMAGE=$kernel_device auto $bootargs"
-	linux16 $kernel_device
-fi
-
diff --git a/arch/x86/boards/x86_generic/env/bin/init b/arch/x86/boards/x86_generic/env/bin/init
deleted file mode 100644
index 2924a4449a8d..000000000000
--- a/arch/x86/boards/x86_generic/env/bin/init
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-PATH=/env/bin
-export PATH
-
-. /env/config
-
-echo
-echo -n "Hit any key to stop autoboot: "
-timeout -a $autoboot_timeout
-if [ $? != 0 ]; then
-        exit
-fi
-
-boot
diff --git a/arch/x86/boards/x86_generic/env/config b/arch/x86/boards/x86_generic/env/config
deleted file mode 100644
index dd57aad7169a..000000000000
--- a/arch/x86/boards/x86_generic/env/config
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# basic config
-#
-# boot source: 'disk' or 'net'
-kernel=disk
-root=disk
-
-# data for the NFS case
-nfsroot="/path/to/nfs_root"
-
-# data for the disk case
-kernel_device=/dev/biosdisk0.1
-rootpart_disk=/dev/sda1
-rootpart_fs=ext2
-
-baudrate=115200
-serial=ttyS0
-
-# use UART for console
-bootargs="console=$serial,$baudrate"
-
-autoboot_timeout=3
-
-# use 'dhcp' to do dhcp in uboot and in kernel
-#  ip=dhcp
-# or set your networking parameters here
-#  eth0.ipaddr=192.168.3.11
-#  eth0.netmask=255.255.255.0
-#  eth0.gateway=a.b.c.d
-#  eth0.serverip=192.168.3.10
-#  eth0.ethaddr=aa.bb.cc.dd.ee.ff
diff --git a/arch/x86/boards/x86_generic/envsector.h b/arch/x86/boards/x86_generic/envsector.h
deleted file mode 100644
index 57a6d2a21ff2..000000000000
--- a/arch/x86/boards/x86_generic/envsector.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-/**
- * @file
- * @brief x86 Generic PC common definitions
- */
-#ifndef __X86_ENVSECTOR_H
-#define __ENVSECTOR_H
-
-/*
- * These datas are from the MBR, created by the linker and filled by the
- * setup tool while installing barebox on the disk drive
- */
-extern uint64_t pers_env_storage;
-extern uint16_t pers_env_size;
-extern uint8_t pers_env_drive;
-
-/**
- * Persistent environment "not used" marker.
- * Note: Must be in accordance to the value the tool "setup_mbr" writes.
- */
-#define PATCH_AREA_PERS_SIZE_UNUSED 0x000
-
-#endif
diff --git a/arch/x86/boards/x86_generic/generic_pc.c b/arch/x86/boards/x86_generic/generic_pc.c
deleted file mode 100644
index 2f1db7aca18d..000000000000
--- a/arch/x86/boards/x86_generic/generic_pc.c
+++ /dev/null
@@ -1,18 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-#include <common.h>
-#include <types.h>
-#include <driver.h>
-#include <init.h>
-#include <asm/syslib.h>
-#include <linux/err.h>
-
-static int devices_init(void)
-{
-	/* extended memory only */
-	add_mem_device("ram0", 0x0, bios_get_memsize() << 10,
-		       IORESOURCE_MEM_WRITEABLE);
-	return 0;
-}
-device_initcall(devices_init);
diff --git a/arch/x86/boards/x86_generic/intf_platform_ide.c b/arch/x86/boards/x86_generic/intf_platform_ide.c
deleted file mode 100644
index 0db031484fb1..000000000000
--- a/arch/x86/boards/x86_generic/intf_platform_ide.c
+++ /dev/null
@@ -1,80 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2014 Juergen Beisert, Pengutronix
-// SPDX-FileCopyrightText: 2014 Michel Stam, Fugro Intersite
-
-/**
- * @file
- * @brief Generic PC support for the IDE platform driver
- */
-
-#include <common.h>
-#include <driver.h>
-#include <init.h>
-#include <linux/err.h>
-#include <platform_data/ide.h>
-#include "envsector.h"
-
-static struct ide_port_info ide_plat = {
-	.ioport_shift = 0,
-	.dataif_be = 0,
-};
-
-static struct resource primary_ide_resources[] = {
-	{
-		.name = "base",
-		.start = 0x1f0,
-		.end =  0x1f7,
-		.flags = IORESOURCE_IO
-	},
-	{
-		.name = "alt",
-		.start = 0x3f6,
-		.end =  0x3f7,
-		.flags = IORESOURCE_IO
-	}
-};
-
-static struct resource secondary_ide_resources[] = {
-	{
-		.name = "base",
-		.start = 0x170,
-		.end =  0x177,
-		.flags = IORESOURCE_IO
-	},
-};
-
-static struct device_d primary_ide_device = {
-	.name = "ide_intf",
-	.id = 0,
-	.platform_data = &ide_plat,
-	.resource = primary_ide_resources,
-	.num_resources = ARRAY_SIZE(primary_ide_resources),
-};
-
-static struct device_d secondary_ide_device = {
-	.name = "ide_intf",
-	.id = 1,
-	.platform_data = &ide_plat,
-	.resource = secondary_ide_resources,
-	.num_resources = ARRAY_SIZE(secondary_ide_resources),
-};
-
-static int platform_ide_init(void)
-{
-	struct cdev *cdev;
-
-	platform_device_register(&primary_ide_device);
-	platform_device_register(&secondary_ide_device);
-
-	if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
-		cdev = devfs_add_partition("ata0",
-				pers_env_storage * 512,
-				(unsigned)pers_env_size * 512,
-				DEVFS_PARTITION_FIXED, "env0");
-		printf("Partition: %ld\n", IS_ERR(cdev) ? PTR_ERR(cdev) : 0);
-	} else
-		printf("No persistent storage defined\n");
-
-	return 0;
-}
-device_initcall(platform_ide_init);
diff --git a/arch/x86/boards/x86_generic/serial_ns16550.c b/arch/x86/boards/x86_generic/serial_ns16550.c
deleted file mode 100644
index 4159bc39fb76..000000000000
--- a/arch/x86/boards/x86_generic/serial_ns16550.c
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-// SPDX-FileCopyrightText: 2009 Michel Stam, Fugro Intersite
-
-/**
- * @file
- * @brief Generic PC support to let barebox acting as a boot loader
- */
-
-#include <common.h>
-#include <types.h>
-#include <driver.h>
-#include <init.h>
-#include <asm/syslib.h>
-#include <platform_data/serial-ns16550.h>
-#include <linux/err.h>
-
-static struct NS16550_plat serial_plat = {
-	.clock = 1843200,
-};
-
-static int pc_console_init(void)
-{
-	barebox_set_model("X86 generic barebox");
-	barebox_set_hostname("x86");
-
-	/* Register the serial port */
-	add_ns16550_device(DEVICE_ID_DYNAMIC, 0x3f8, 8, IORESOURCE_IO,
-			   &serial_plat);
-	add_ns16550_device(DEVICE_ID_DYNAMIC, 0x2f8, 8, IORESOURCE_IO,
-			   &serial_plat);
-
-	return 0;
-}
-console_initcall(pc_console_init);
diff --git a/arch/x86/boot/Kconfig b/arch/x86/boot/Kconfig
deleted file mode 100644
index 8dba00d59161..000000000000
--- a/arch/x86/boot/Kconfig
+++ /dev/null
@@ -1,20 +0,0 @@
-if X86_BIOS_BRINGUP
-
-menu "BIOS boot source"
-
-config X86_HDBOOT
-	bool "HD boot"
-	help
-	  Add code to boot from harddisk
-
-config X86_VESA
-	bool
-	default y if X86_GENERIC_HAS_VIDEO
-
-config X86_VGA
-	bool
-	default y if X86_GENERIC_HAS_VIDEO
-
-endmenu
-
-endif
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
deleted file mode 100644
index 4a520a2a84d4..000000000000
--- a/arch/x86/boot/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-
-KBUILD_CPPFLAGS += -D__I386__ -fno-strict-aliasing -m32 -g -Os -march=i386 \
-	-mregparm=3 -fno-strict-aliasing -fomit-frame-pointer -ffreestanding \
-	-fno-toplevel-reorder -fno-unit-at-a-time -fno-stack-protector \
-	-mpreferred-stack-boundary=2
-
-obj-$(CONFIG_X86_HDBOOT)	+= boot_main.o boot_hdisk.o
-
-obj-$(CONFIG_X86_BIOS_BRINGUP)	+= prepare_uboot.o a20.o bioscall.o regs.o tty.o pmjump.o main_entry.o
-
-obj-$(CONFIG_X86_VESA) += console_vesa.o
-obj-$(CONFIG_X86_VGA) += console_vga.o
-obj-$(CONFIG_X86_SERIAL) += console_serial.o
diff --git a/arch/x86/boot/a20.c b/arch/x86/boot/a20.c
deleted file mode 100644
index f501feeeddc2..000000000000
--- a/arch/x86/boot/a20.c
+++ /dev/null
@@ -1,166 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-// SPDX-FileCopyrightText: 1991,1992 Linus Torvalds
-// SPDX-FileCopyrightText: 2007-2008 rPath, Inc.
-// SPDX-FileCopyrightText: 2009 Intel Corporation
-
-/* Author: H. Peter Anvin and others */
-
-/*
- * Enable A20 gate (return -1 on failure)
- */
-
-#include <asm/segment.h>
-#include <io.h>
-#include "boot.h"
-
-#define MAX_8042_LOOPS	100000
-#define MAX_8042_FF	32
-
-/* be aware of: */
-THIS_IS_REALMODE_CODE
-
-static int __bootcode empty_8042(void)
-{
-	u8 status;
-	int loops = MAX_8042_LOOPS;
-	int ffs   = MAX_8042_FF;
-
-	while (loops--) {
-		io_delay();
-
-		status = inb(0x64);
-		if (status == 0xff) {
-			/* FF is a plausible, but very unlikely status */
-			if (!--ffs)
-				return -1; /* Assume no KBC present */
-		}
-		if (status & 1) {
-			/* Read and discard input data */
-			io_delay();
-			(void)inb(0x60);
-		} else if (!(status & 2)) {
-			/* Buffers empty, finished! */
-			return 0;
-		}
-	}
-
-	return -1;
-}
-
-/* Returns nonzero if the A20 line is enabled.  The memory address
-   used as a test is the int $0x80 vector, which should be safe. */
-
-#define A20_TEST_ADDR	(4*0x80)
-#define A20_TEST_SHORT  32
-#define A20_TEST_LONG	2097152	/* 2^21 */
-
-static int __bootcode a20_test(int loops)
-{
-	int ok = 0;
-	int saved, ctr;
-
-	set_fs(0x0000);
-	set_gs(0xffff);
-
-	saved = ctr = rdfs32(A20_TEST_ADDR);
-
-	while (loops--) {
-		wrfs32(++ctr, A20_TEST_ADDR);
-		io_delay();	/* Serialize and make delay constant */
-		ok = rdgs32(A20_TEST_ADDR+0x10) ^ ctr;
-		if (ok)
-			break;
-	}
-
-	wrfs32(saved, A20_TEST_ADDR);
-	return ok;
-}
-
-/* Quick test to see if A20 is already enabled */
-static int __bootcode a20_test_short(void)
-{
-	return a20_test(A20_TEST_SHORT);
-}
-
-/* Longer test that actually waits for A20 to come on line; this
-   is useful when dealing with the KBC or other slow external circuitry. */
-static int __bootcode a20_test_long(void)
-{
-	return a20_test(A20_TEST_LONG);
-}
-
-static void __bootcode enable_a20_bios(void)
-{
-	struct biosregs ireg;
-
-	initregs(&ireg);
-	ireg.ax = 0x2401;
-	intcall(0x15, &ireg, NULL);
-}
-
-static void __bootcode enable_a20_kbc(void)
-{
-	empty_8042();
-
-	outb(0xd1, 0x64);	/* Command write */
-	empty_8042();
-
-	outb(0xdf, 0x60);	/* A20 on */
-	empty_8042();
-
-	outb(0xff, 0x64);	/* Null command, but UHCI wants it */
-	empty_8042();
-}
-
-static void __bootcode enable_a20_fast(void)
-{
-	u8 port_a;
-
-	port_a = inb(0x92);	/* Configuration port A */
-	port_a |=  0x02;	/* Enable A20 */
-	port_a &= ~0x01;	/* Do not reset machine */
-	outb(port_a, 0x92);
-}
-
-/*
- * Actual routine to enable A20; return 0 on ok, -1 on failure
- */
-
-#define A20_ENABLE_LOOPS 255	/* Number of times to try */
-
-int __bootcode enable_a20(void)
-{
-       int loops = A20_ENABLE_LOOPS;
-       int kbc_err;
-
-       while (loops--) {
-	       /* First, check to see if A20 is already enabled
-		  (legacy free, etc.) */
-	       if (a20_test_short())
-		       return 0;
-
-	       /* Next, try the BIOS (INT 0x15, AX=0x2401) */
-	       enable_a20_bios();
-	       if (a20_test_short())
-		       return 0;
-
-	       /* Try enabling A20 through the keyboard controller */
-	       kbc_err = empty_8042();
-
-	       if (a20_test_short())
-		       return 0; /* BIOS worked, but with delayed reaction */
-
-	       if (!kbc_err) {
-		       enable_a20_kbc();
-		       if (a20_test_long())
-			       return 0;
-	       }
-
-	       /* Finally, try enabling the "fast A20 gate" */
-	       enable_a20_fast();
-	       if (a20_test_long())
-		       return 0;
-       }
-
-       return -1;
-}
diff --git a/arch/x86/boot/bioscall.S b/arch/x86/boot/bioscall.S
deleted file mode 100644
index 6cda1eb40a49..000000000000
--- a/arch/x86/boot/bioscall.S
+++ /dev/null
@@ -1,90 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Intel Corporation */
-
-/* Author: H. Peter Anvin */
-
-/*
- * "Glove box" for BIOS calls.  Avoids the constant problems with BIOSes
- * touching registers they shouldn't be.
- */
-
-	.file	"bioscall.S"
-	.code16
-	.section .boot.text.intcall, "ax"
-
-	.globl	intcall
-	.type	intcall, @function
-intcall:
-	/* Self-modify the INT instruction.  Ugly, but works. */
-	cmpb	%al, 3f
-	je	1f
-	movb	%al, 3f
-	jmp	1f		/* Synchronize pipeline */
-1:
-	/* Save state */
-	pushfl
-	pushw	%fs
-	pushw	%gs
-	pushal
-
-	/* Copy input state to stack frame */
-	subw	$44, %sp
-	movw	%dx, %si
-	movw	%sp, %di
-	movw	$11, %cx
-	rep; movsd
-
-	/* Pop full state from the stack */
-	popal
-	popw	%gs
-	popw	%fs
-	popw	%es
-	popw	%ds
-	popfl
-
-	/* Actual INT */
-	.byte	0xcd		/* INT opcode */
-3:	.byte	0
-
-	/* Push full state to the stack */
-	pushfl
-	pushw	%ds
-	pushw	%es
-	pushw	%fs
-	pushw	%gs
-	pushal
-
-	/* Re-establish C environment invariants */
-	cld
-	movzwl	%sp, %esp
-	movw	%cs, %ax
-	movw	%ax, %ds
-	movw	%ax, %es
-
-	/* Copy output state from stack frame */
-	movw	68(%esp), %di	/* Original %cx == 3rd argument */
-	andw	%di, %di
-	jz	4f
-	movw	%sp, %si
-	movw	$11, %cx
-	rep; movsd
-4:	addw	$44, %sp
-
-	/* Restore state and return */
-	popal
-	popw	%gs
-	popw	%fs
-	popfl
-	retl
-	.size	intcall, .-intcall
-
-/* ------------------------------------------------------------------------ */
-	.code16
-	.section .boot.text.die, "ax"
-
-	.globl	die
-	.type	die, @function
-die:
-        hlt
-        jmp     die
-	.size	die, .-die
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
deleted file mode 100644
index 54483c46c697..000000000000
--- a/arch/x86/boot/boot.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/* SPDX-FileCopyrightText: 1991,1992 Linus Torvalds */
-/* SPDX-FileCopyrightText: 2007 rPath, Inc. */
-/* SPDX-FileCopyrightText: 2009 Intel Corporation */
-
-/* Author: H. Peter Anvin and others */
-
-/**
- * @file
- * @brief Main declarations for the real mode code
- */
-
-#ifndef BOOT_BOOT_H
-#define BOOT_BOOT_H
-
-#define STACK_SIZE	512	/* Minimum number of bytes for stack */
-
-/** Carry flag */
-#define X86_EFLAGS_CF	0x00000001
-
-/** PE flag */
-#define X86_CR0_PE      0x00000001
-
-#ifndef __ASSEMBLY__
-
-#include <types.h>
-
-/* we are still in real mode here! */
-#define THIS_IS_REALMODE_CODE asm(".code16gcc");
-
-struct biosregs {
-	union {
-		struct {
-			uint32_t edi;
-			uint32_t esi;
-			uint32_t ebp;
-			uint32_t _esp;
-			uint32_t ebx;
-			uint32_t edx;
-			uint32_t ecx;
-			uint32_t eax;
-			uint32_t _fsgs;
-			uint32_t _dses;
-			uint32_t eflags;
-		};
-		struct {
-			uint16_t di, hdi;
-			uint16_t si, hsi;
-			uint16_t bp, hbp;
-			uint16_t _sp, _hsp;
-			uint16_t bx, hbx;
-			uint16_t dx, hdx;
-			uint16_t cx, hcx;
-			uint16_t ax, hax;
-			uint16_t gs, fs;
-			uint16_t es, ds;
-			uint16_t flags, hflags;
-		};
-		struct {
-			uint8_t dil, dih, edi2, edi3;
-			uint8_t sil, sih, esi2, esi3;
-			uint8_t bpl, bph, ebp2, ebp3;
-			uint8_t _spl, _sph, _esp2, _esp3;
-			uint8_t bl, bh, ebx2, ebx3;
-			uint8_t dl, dh, edx2, edx3;
-			uint8_t cl, ch, ecx2, ecx3;
-			uint8_t al, ah, eax2, eax3;
-		};
-	};
-};
-
-/* functions in the realmode part */
-extern int enable_a20(void);
-extern void initregs(struct biosregs *regs);
-extern void intcall(uint8_t int_no, const struct biosregs *ireg, struct biosregs *oreg);
-extern void boot_puts(char*);
-extern void __attribute__((noreturn)) die(void);
-extern void __attribute__((noreturn)) protected_mode_jump(void);
-
-struct gdt_ptr {
-	uint16_t len;
-	uint32_t ptr;
-} __attribute__((packed));
-
-/* These functions are used to reference data in other segments. */
-
-static inline uint16_t ds(void)
-{
-	uint16_t seg;
-	asm("movw %%ds,%0" : "=rm" (seg));
-	return seg;
-}
-
-static inline void set_fs(uint16_t seg)
-{
-	asm volatile("movw %0,%%fs" : : "rm" (seg));
-}
-
-static inline uint16_t fs(void)
-{
-	uint16_t seg;
-	asm volatile("movw %%fs,%0" : "=rm" (seg));
-	return seg;
-}
-
-static inline void set_gs(uint16_t seg)
-{
-	asm volatile("movw %0,%%gs" : : "rm" (seg));
-}
-
-static inline uint16_t gs(void)
-{
-	uint16_t seg;
-	asm volatile("movw %%gs,%0" : "=rm" (seg));
-	return seg;
-}
-
-typedef unsigned int addr_t;
-
-static inline uint8_t rdfs8(addr_t addr)
-{
-	uint8_t v;
-	asm volatile("movb %%fs:%1,%0" : "=q" (v) : "m" (*(uint8_t *)addr));
-	return v;
-}
-static inline uint16_t rdfs16(addr_t addr)
-{
-	uint16_t v;
-	asm volatile("movw %%fs:%1,%0" : "=r" (v) : "m" (*(uint16_t *)addr));
-	return v;
-}
-static inline uint32_t rdfs32(addr_t addr)
-{
-	uint32_t v;
-	asm volatile("movl %%fs:%1,%0" : "=r" (v) : "m" (*(uint32_t *)addr));
-	return v;
-}
-
-static inline void wrfs8(uint8_t v, addr_t addr)
-{
-	asm volatile("movb %1,%%fs:%0" : "+m" (*(uint8_t *)addr) : "qi" (v));
-}
-static inline void wrfs16(uint16_t v, addr_t addr)
-{
-	asm volatile("movw %1,%%fs:%0" : "+m" (*(uint16_t *)addr) : "ri" (v));
-}
-static inline void wrfs32(uint32_t v, addr_t addr)
-{
-	asm volatile("movl %1,%%fs:%0" : "+m" (*(uint32_t *)addr) : "ri" (v));
-}
-
-static inline uint8_t rdgs8(addr_t addr)
-{
-	uint8_t v;
-	asm volatile("movb %%gs:%1,%0" : "=q" (v) : "m" (*(uint8_t *)addr));
-	return v;
-}
-static inline uint16_t rdgs16(addr_t addr)
-{
-	uint16_t v;
-	asm volatile("movw %%gs:%1,%0" : "=r" (v) : "m" (*(uint16_t *)addr));
-	return v;
-}
-static inline uint32_t rdgs32(addr_t addr)
-{
-	uint32_t v;
-	asm volatile("movl %%gs:%1,%0" : "=r" (v) : "m" (*(uint32_t *)addr));
-	return v;
-}
-
-static inline void wrgs8(uint8_t v, addr_t addr)
-{
-	asm volatile("movb %1,%%gs:%0" : "+m" (*(uint8_t *)addr) : "qi" (v));
-}
-static inline void wrgs16(uint16_t v, addr_t addr)
-{
-	asm volatile("movw %1,%%gs:%0" : "+m" (*(uint16_t *)addr) : "ri" (v));
-}
-static inline void wrgs32(uint32_t v, addr_t addr)
-{
-	asm volatile("movl %1,%%gs:%0" : "+m" (*(uint32_t *)addr) : "ri" (v));
-}
-
-/** use the built in memset function for the real mode code */
-#define memset(d,c,l) __builtin_memset(d,c,l)
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* BOOT_BOOT_H */
diff --git a/arch/x86/boot/boot_hdisk.S b/arch/x86/boot/boot_hdisk.S
deleted file mode 100644
index 6f98197512a0..000000000000
--- a/arch/x86/boot/boot_hdisk.S
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2009 Juergen Beisert, Pengutronix
- *
- * This code was inspired by the GRUB2 project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- *
- */
-
-/**
- * @file
- * @brief Loading the barebox image from a disk drive in LBA mode
- */
-
-/**
- * @fn void real_start(void)
- * @brief A very simple and small loader to fetch all required sectors
- * from the boot media.
- */
-
-
-	.file "boot_hdisk.S"
-	.code16
-
-	/*
-	 * These symbols are generated by the linker, because they need a
-	 * special layout. This layout is needed to be able to setup this
-	 * bootloader by patching the binary when it gets stored into the
-	 * master boot record.
-	 */
-	.extern indirect_sector_lba
-	.extern boot_stack
-	.extern start_pre_uboot
-	.extern boot_disk
-	.section .boot_code, "ax"
-
-	.globl real_start
-	.type real_start, @function
-
-real_start:
-
-	xorw %ax, %ax	/* set up %ds and %ss as offset from 0 */
-	movw %ax, %ds
-	movw %ax, %ss
-
-	/* set up the REAL stack */
-	movw $boot_stack, %sp
-
-	sti		/* we're safe again */
-
-	/* save drive reference first thing! */
-	movb %dl, boot_disk
-	pushw %dx
-
-	movw $notification_string, %si
-	call output_message
-
-	/*
-	 * This boot code only supports LBA. We fail here, if the BIOS
-	 * does not support LBA for the harddisk
-	 */
-
-	/* check if LBA is supported */
-	movb $0x41, %ah
-	movw $0x55aa, %bx
-	int $0x13
-
-	/*
-	 *  %dl may have been clobbered by INT 13, AH=41H.
-	 *  This happens, for example, with AST BIOS 1.04.
-	 */
-	popw %dx
-	pushw %dx
-
-	/* stop if no LBA support */
-	jc no_lba
-	cmpw $0xaa55, %bx
-	jne no_lba
-	andw $1, %cx
-	jz no_lba
-
-lba_mode:
-	/*
-	 * Load the indirect sector. Its content is ready for use,
-	 * provided by the installer
-	 */
-	movw $indirect_sector_lba, %si
-	movb $0x42, %ah
-	int $0x13
-	jc no_lba	/* error? Then die */
-
-	/*
-	 * Now loop through all valid entries in the indirect sector
-	 */
-	movw $indirect_area, %si
-
-load_loop:
-	/*
-	 * Stop if this "Disk Address Packet Structure" is invalid
-	 * We call it invalid, if the size member is zero. If it is invalid
-	 * we are optimistic and calling the loaded image
-	 */
-	movw (%si), %ax
-	cmpw $0x0000, %ax
-	je start_main
-
-	/*
-	 * Load this entry
-	 */
-	movb $0x42, %ah
-	int $0x13
-	jc no_lba
-
-	addw (%si), %si	/* next entry */
-	cmpw $indirect_area + 512, %si
-	jne load_loop
-	/*
-	 * fall through to start u-boot.
-	 */
-start_main:
-	movw $jmp_string, %si
-	call output_message
-	jmp start_pre_uboot
-/*
- * die if there is no LBA support
- */
-no_lba:	movw $chs_string, %si
-	call output_message
-	hlt
-
-/*
- * message: write the string pointed to by %si
- *
- *   WARNING: trashes %si, %ax, and %bx
- */
-
-/*
- * Use BIOS "int 10H Function 0Eh" to write character in teletype mode
- *	%ah = 0xe	%al = character
- *	%bh = page	%bl = foreground color (graphics modes)
- */
-
-1:
-	movw	$0x0001, %bx
-	movb	$0xe, %ah
-	int	$0x10		/* display this char */
-
-output_message:
-	lodsb
-	cmpb	$0, %al
-	jne	1b	/* if not end of string, next char */
-	ret
-
-/* ---------------------------------------------------------------------- */
-
-	.section .boot_data
-
-notification_string:	.asciz "BAREBOX "
-chs_string:	.asciz "CHS "
-jmp_string:	.asciz "JMP "
-
diff --git a/arch/x86/boot/boot_main.S b/arch/x86/boot/boot_main.S
deleted file mode 100644
index 632b3f4ffa6f..000000000000
--- a/arch/x86/boot/boot_main.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: Juergen Beisert, Pengutronix */
-
-/* This code was inspired by the GRUB2 project. */
-
-/**
- * @file
- * @brief Common boot sector main routine to be entered by the BIOS
- */
-/**
- * @fn void _start(void)
- *
- * @brief Fix segment:offset settings of some buggy BIOSs
- */
-
-
-	.file "boot_main.S"
-	.code16
-
-	.extern real_start
-
-	.section .boot_start, "ax"
-	.type _start, @function
-
-	/*
-	 * The BIOS loads this code to address 0x00007c00.
-	 * The code should be called with CS:IP 0:0x7c00 (hopefully).
-	 */
-	.globl _start
-_start:
-	cli		/* we're not safe here! */
-	/*
-	 * It seems there are implementations in the wild which call this
-	 * code with CS:IP 0x07C0:0000 instead. We fix it immediately.
-	 */
-	ljmp $0, $real_start
-
-	.size _start, .-_start
-
diff --git a/arch/x86/boot/main_entry.c b/arch/x86/boot/main_entry.c
deleted file mode 100644
index b37aa38fca20..000000000000
--- a/arch/x86/boot/main_entry.c
+++ /dev/null
@@ -1,24 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/**
- * @file
- * @brief Start of the 32 bit flat mode
- */
-
-#include <string.h>
-#include <asm/sections.h>
-
-extern void x86_start_barebox(void);
-
-/**
- * Called plainly from assembler that switches from real to flat mode
- *
- * @note The C environment isn't initialized yet
- */
-void uboot_entry(void)
-{
-	/* clear the BSS first */
-	memset(__bss_start, 0x00, __bss_stop - __bss_start);
-	x86_start_barebox();
-}
diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S
deleted file mode 100644
index 4dd1881e65bb..000000000000
--- a/arch/x86/boot/pmjump.S
+++ /dev/null
@@ -1,82 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/* SPDX-FileCopyrightText: 1991,1992 Linus Torvalds */
-/* SPDX-FileCopyrightText: 2007 rPath, Inc. */
-
-/**
- * @file
- * @brief The actual transition into protected mode
- *
- * Note: This function is running in flat and real mode. Due to some
- * other restrictions it must running from an address space below 0x10000
- */
-
-/**
- * @fn void protected_mode_jump(void)
- * @brief Switches the first time from real mode to flat mode
- */
-
-#include <asm/modes.h>
-#include "boot.h"
-
-	.file "pmjump.S"
-	.code16
-	.section .boot.text.protected_mode_jump, "ax"
-
-	.globl	protected_mode_jump
-	.type	protected_mode_jump, @function
-
-protected_mode_jump:
-	jmp 1f			/* Short jump to serialize on 386/486 */
-1:
-
-	movw $__BOOT_DS, %cx
-	movw $__BOOT_TSS, %di
-
-	movl %cr0, %edx
-	orb $X86_CR0_PE, %dl	/* enable protected mode */
-	movl %edx, %cr0
-
-	/* Transition to 32-bit flat mode */
-	data32  ljmp $__BOOT_CS, $in_pm32
-	.size protected_mode_jump, .-protected_mode_jump
-
-/* ------------------------------------------------------------------------ */
-
-	.section ".text.in_pm32","ax"
-	.code32
-
-	.extern uboot_entry
-	.extern __bss_stop
-
-	.type	in_pm32, @function
-in_pm32:
-	# Set up data segments for flat 32-bit mode
-	movl %ecx, %ds
-	movl %ecx, %es
-	movl %ecx, %fs
-	movl %ecx, %gs
-	movl %ecx, %ss
-/*
- * Our flat mode code uses its own stack area behind the bss. With this we
- * are still able to return to real mode temporarely
- */
-	movl $__bss_stop + 32768, %esp
-
-	# Set up TR to make Intel VT happy
-	ltr %di
-
-	# Clear registers to allow for future extensions to the
-	# 32-bit boot protocol
-	xorl %ecx, %ecx
-	xorl %edx, %edx
-	xorl %ebx, %ebx
-	xorl %ebp, %ebp
-	xorl %edi, %edi
-
-	# Set up LDTR to make Intel VT happy
-	lldt %cx
-
-	jmp uboot_entry
-
-	.size in_pm32, .-in_pm32
-
diff --git a/arch/x86/boot/prepare_uboot.c b/arch/x86/boot/prepare_uboot.c
deleted file mode 100644
index 9cac594a4633..000000000000
--- a/arch/x86/boot/prepare_uboot.c
+++ /dev/null
@@ -1,80 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-// SPDX-FileCopyrightText: 1991,1992 Linus Torvalds
-// SPDX-FileCopyrightText: 2007 rPath, Inc.
-
-/*
- * Prepare the machine for transition to protected mode.
- */
-#include <asm/segment.h>
-#include <asm/modes.h>
-#include <io.h>
-#include "boot.h"
-
-/* be aware of: */
-THIS_IS_REALMODE_CODE
-
-/*
- * While we are in flat mode, we can't handle interrupts. But we can't
- * switch them off for ever in the PIC, because we need them again while
- * entering real mode code again and again....
- */
-static void __bootcode realmode_switch_hook(void)
-{
-	asm volatile("cli");
-	outb(0x80, 0x70); /* Disable NMI */
-	io_delay();
-}
-
-/*
- * Reset IGNNE# if asserted in the FPU.
- */
-static void __bootcode reset_coprocessor(void)
-{
-	outb(0, 0xf0);
-	io_delay();
-	outb(0, 0xf1);
-	io_delay();
-}
-
-/**
- * Setup and register the global descriptor table (GDT)
- *
- * @note This is for the first time only
- */
-static void __bootcode setup_gdt(void)
-{
-	/* Xen HVM incorrectly stores a pointer to the gdt_ptr, instead
-	   of the gdt_ptr contents.  Thus, make it static so it will
-	   stay in memory, at least long enough that we switch to the
-	   proper kernel GDT. */
-	static struct gdt_ptr __bootdata gdt_ptr;
-
-	gdt_ptr.len = gdt_size - 1;
-	gdt_ptr.ptr = (uint32_t)&gdt + (ds() << 4);
-
-	asm volatile("lgdtl %0" : : "m" (gdt_ptr));
-}
-
-static char a20_message[] __bootdata = "A20 gate not responding, unable to boot...\n";
-
-/*
- * Actual invocation sequence
- */
-void __bootcode start_pre_uboot(void)
-{
-	/* Hook before leaving real mode, also disables interrupts */
-	realmode_switch_hook();
-
-	/* Enable the A20 gate */
-	if (enable_a20()) {
-		boot_puts(a20_message);
-		die();
-	}
-
-	/* Reset coprocessor (IGNNE#) */
-	reset_coprocessor();
-
-	setup_gdt();
-	/* Actual transition to protected mode... */
-	protected_mode_jump();
-}
diff --git a/arch/x86/boot/regs.c b/arch/x86/boot/regs.c
deleted file mode 100644
index 318b662175b3..000000000000
--- a/arch/x86/boot/regs.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Intel Corporation
-
-/* Author: H. Peter Anvin */
-
-/**
- * @file
- * @brief Simple helper function for initializing a register set.
- *
- * Note that this sets EFLAGS_CF in the input register set; this
- * makes it easier to catch functions which do nothing but don't
- * explicitly set CF.
- */
-
-#include <asm/segment.h>
-#include "boot.h"
-
-/* be aware of: */
-THIS_IS_REALMODE_CODE
-
-void __bootcode initregs(struct biosregs *reg)
-{
-	memset(reg, 0, sizeof *reg);
-	reg->eflags |= X86_EFLAGS_CF;
-	reg->ds = ds();
-	reg->es = ds();
-	reg->fs = fs();
-	reg->gs = gs();
-}
diff --git a/arch/x86/boot/tty.c b/arch/x86/boot/tty.c
deleted file mode 100644
index 620197c67701..000000000000
--- a/arch/x86/boot/tty.c
+++ /dev/null
@@ -1,41 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-// SPDX-FileCopyrightText: 1991,1992 Linus Torvalds
-// SPDX-FileCopyrightText: 2007 rPath, Inc.
-// SPDX-FileCopyrightText: 2009 Intel Corporation
-
-/* Author: H. Peter Anvin and others */
-
-/**
- * @file
- * @brief Very simple screen I/O for the initialization stage
- *
- * @todo Probably should add very simple serial I/O?
- * @attention This is real mode code!
- */
-
-#include <asm/segment.h>
-#include "boot.h"
-
-/* be aware of: */
-THIS_IS_REALMODE_CODE
-
-static void __bootcode putchar(int ch)
-{
-	struct biosregs ireg;
-
-	if (ch == '\n')
-		putchar('\r');	/* \n -> \r\n */
-
-	initregs(&ireg);
-	ireg.bx = 0x0007;
-	ireg.cx = 0x0001;
-	ireg.ah = 0x0e;
-	ireg.al = ch;
-	intcall(0x10, &ireg, NULL);
-}
-
-void __bootcode boot_puts(char *str)
-{
-	while (*str)
-		putchar(*str++);
-}
diff --git a/arch/x86/configs/generic_defconfig b/arch/x86/configs/generic_defconfig
deleted file mode 100644
index 4620280136bb..000000000000
--- a/arch/x86/configs/generic_defconfig
+++ /dev/null
@@ -1,26 +0,0 @@
-CONFIG_X86_BIOS_BRINGUP=y
-CONFIG_X86_HDBOOT=y
-CONFIG_STACK_SIZE=0x7000
-CONFIG_EXPERIMENTAL=y
-CONFIG_GLOB=y
-CONFIG_CMDLINE_EDITING=y
-CONFIG_AUTO_COMPLETE=y
-CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/x86/boards/x86_generic/env"
-CONFIG_LONGHELP=y
-CONFIG_CMD_MEMINFO=y
-# CONFIG_CMD_BOOTM is not set
-CONFIG_CMD_GO=y
-CONFIG_CMD_RESET=y
-CONFIG_CMD_EXPORT=y
-CONFIG_CMD_LOADENV=y
-CONFIG_CMD_PRINTENV=y
-CONFIG_CMD_SAVEENV=y
-# CONFIG_CMD_FALSE is not set
-CONFIG_CMD_SLEEP=y
-# CONFIG_CMD_TRUE is not set
-CONFIG_CMD_EDIT=y
-CONFIG_CMD_READLINE=y
-CONFIG_CMD_TIMEOUT=y
-CONFIG_DRIVER_SERIAL_NS16550=y
-# CONFIG_SPI is not set
diff --git a/arch/x86/include/asm/syslib.h b/arch/x86/include/asm/syslib.h
deleted file mode 100644
index 7e08cfd44e47..000000000000
--- a/arch/x86/include/asm/syslib.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-#ifdef CONFIG_X86_BIOS_BRINGUP
-
-extern int bios_disk_rw_int13_extensions(int, int, void*) __attribute__((regparm(3)));
-extern uint16_t bios_get_memsize(void);
-
-#endif
-
-#ifdef CONFIG_CMD_LINUX16
-extern void bios_start_linux(unsigned) __attribute__((regparm(1)));
-#endif
diff --git a/arch/x86/lib/.gitignore b/arch/x86/lib/.gitignore
deleted file mode 100644
index d1165788c9ab..000000000000
--- a/arch/x86/lib/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-barebox.lds
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 6a8fa7c0ff3e..360aebf56936 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -1,11 +1,2 @@
-extra-$(CONFIG_GENERIC_LINKER_SCRIPT) += barebox.lds
-ifneq ($(CONFIG_X86_EFI),y)
-obj-y += memory.o
-obj-y += gdt.o
-endif
-
 obj-$(CONFIG_X86_32) += setjmp_32.o
 obj-$(CONFIG_X86_64) += setjmp_64.o
-
-# needed, when running via a 16 bit BIOS
-obj-$(CONFIG_CMD_LINUX16) += linux_start.o
diff --git a/arch/x86/lib/asm-offsets.c b/arch/x86/lib/asm-offsets.c
index 0f9c47eaa9ed..22f382b71e7b 100644
--- a/arch/x86/lib/asm-offsets.c
+++ b/arch/x86/lib/asm-offsets.c
@@ -6,13 +6,7 @@
 
 #include <linux/kbuild.h>
 
-#ifdef CONFIG_EFI_BOOTUP
 int main(void)
 {
 	return 0;
 }
-#else
-void common(void)
-{
-}
-#endif
diff --git a/arch/x86/lib/barebox.lds.S b/arch/x86/lib/barebox.lds.S
deleted file mode 100644
index b24c4807b59d..000000000000
--- a/arch/x86/lib/barebox.lds.S
+++ /dev/null
@@ -1,161 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#undef i386
-#include <asm-generic/barebox.lds.h>
-
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-ENTRY(_start)
-
-MEMORY
-{
-	mbr(rwx): ORIGIN = TEXT_BASE, LENGTH = 2 * SECTOR_SIZE
-	barebox (rwx) : ORIGIN = TEXT_BASE + SECTOR_SIZE, LENGTH = (256 * 1024 * 1024)
-}
-
-SECTIONS
-{
-#ifdef CONFIG_X86_HDBOOT
-
-	.ramlayout : {
-		boot_stack = INDIRECT_AREA;
-		indirect_area = INDIRECT_AREA;
-	}
-	/* describing the main boot sector */
-	.bootsector : AT (0) {
-		*(.boot_start)
-
-		. = 0x00b;
-		/*
-		 * Maybe later on occupied by a "BIOS parameter block". So,
-		 * keep it free from code.
-		 * - BytesPerSector dw at 0x000B
-		 * - SectorsPerCluster db at 0x000D
-		 * - ReservedSectors dw at 0x000E
-		 * - FatCopies db at 0x0010
-		 * - RootDirEntries dw at 0x0011
-		 * - NumSectors dw at 0x0013
-		 * - MediaType db at 0x0015
-		 * - SectorsPerFAT dw at 0x0016
-		 * - SectorsPerTrack dw at 0x0018
-		 * - NumberOfHeads dw at 0x001A
-		 * - HiddenSectors dd at 0x001C
-		 * - SectorsBig dd at 0x0020
-		 */
-		LONG(0);
-
-		. = 0x024;
-		*(.boot_code)
-		*(.boot_data)
-
-		/*
-		 * embed one "Disk Address Packet Structure" into the boot sector
-		 * This DAPS points to the 'indirect' sector to give the boot code
-		 * an idea what and where to load. Its content must be adapted
-		 * to the system it should run on, so, this structure must be
-		 * located at a well known offset.
-		 */
-		. = PATCH_AREA;
-		indirect_sector_lba = .;
-		SHORT(0x0010);		/* size of this structure */
-		SHORT(0x0001);		/* one sector */
-		SHORT(indirect_area);	/* where to store: offset */
-		SHORT(0x0000);		/* where to store: segment */
-		/* the following values are filled by the installer */
-		LONG(0x00000000);	/* LBA start lower */
-		LONG(0x00000000);	/* LBA start upper */
-
-		/* boot disk number used by upper layers */
-		. = PATCH_AREA + PATCH_AREA_BOOT_DEV;
-		boot_disk = .;
-		BYTE(0x00);		/* boot disk number (provided by the BIOS)
-
-		/* information about the persistent environment storage */
-		. = PATCH_AREA + PATCH_AREA_PERS_START;
-		pers_env_storage = .;
-		LONG(0x00000000);	/* LBA start lower */
-		LONG(0x00000000);	/* LBA start upper */
-
-		. = PATCH_AREA + PATCH_AREA_PERS_SIZE;
-		pers_env_size = .;
-		SHORT(PATCH_AREA_PERS_SIZE_UNUSED);	/* size of this area in sectors */
-
-		. = PATCH_AREA + PATCH_AREA_PERS_DRIVE;
-		pers_env_drive = .;
-		BYTE(0x00);		/* used drive */
-
-		/* partition table area (fixed location) */
-		. = OFFSET_OF_PARTITION_TABLE;
-		/* create an empty one */
-		LONG(0x00000000); LONG(0x00000000); LONG(0x00000000); LONG(0x00000000);
-		LONG(0x00000000); LONG(0x00000000); LONG(0x00000000); LONG(0x00000000);
-		LONG(0x00000000); LONG(0x00000000); LONG(0x00000000); LONG(0x00000000);
-		LONG(0x00000000); LONG(0x00000000); LONG(0x00000000); LONG(0x00000000);
-
-		/* boot sector signature */
-		. = OFFSET_OF_SIGNATURE;
-		BYTE(0x55);
-		BYTE(0xAA);
-		/* end of the first sector */
-
-		/*
-		 * The indirect sector starts here
-		 */
-		. = SECTOR_SIZE;
-		BYTE(MARK_DAPS_INVALID);	/* mark the first entry invalid */
-		BYTE(0x00);
-		. = SECTOR_SIZE + 496;
-		BYTE(MARK_DAPS_INVALID);	/* mark the last entry invalid */
-		BYTE(0x00);
-		. = SECTOR_SIZE + 508;
-		LONG(0x00000000);	/* LBA start upper */
-	} > mbr
-
-	/* some real mode bootstrapping */
-	.bootstrapping : AT ( LOADADDR(.bootsector) + SIZEOF(.bootsector) ) {
-		*(.boot.head)
-		*(.boot.text*)
-		*(.boot.rodata*)
-		*(.boot.data*)
-		. = ALIGN(4);
-		RO_DATA_SECTION
-	} > barebox
-#endif
-
-	/* the main barebox part (32 bit) */
-	.text : AT ( LOADADDR(.bootstrapping) + SIZEOF(.bootstrapping) ) {
-		/* do not align here! It may fails with the LOADADDR! */
-		_stext = .;
-		_text = .;
-		*(.text_entry*)
-		__bare_init_start = .;
-		*(.text_bare_init*)
-		__bare_init_end = .;
-		*(.text*)
-		. = ALIGN(4);
-		*(.rodata*)
-		. = ALIGN(4);
-		_etext = .;			/* End of text and rodata section */
-	} > barebox
-	BAREBOX_BARE_INIT_SIZE
-
-	_sdata = .;
-	.data : AT ( LOADADDR(.text) + SIZEOF(.text) ) {
-		*(.data*)
-		. = ALIGN(4);
-	} > barebox
-
-	.got : AT ( LOADADDR(.data) + SIZEOF (.data) ) {
-		*(.got*)
-		. = ALIGN(4);
-	} > barebox
-
-	_edata = .;
-	.bss : {
-		__bss_start = .;
-		*(.bss*);
-		*( COMMON )
-		__bss_stop = .;
-		_end = .;
-	} > barebox
-}
diff --git a/arch/x86/lib/gdt.c b/arch/x86/lib/gdt.c
deleted file mode 100644
index 4cd1622b6b63..000000000000
--- a/arch/x86/lib/gdt.c
+++ /dev/null
@@ -1,38 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/**
- * @file
- * @brief Definition of the Global Descriptor Table
- */
-
-#include <types.h>
-#include <asm/modes.h>
-#include <asm/segment.h>
-
-/**
- * The 'Global Descriptor Table' used in barebox
- *
- * Note: This table must reachable by real and flat mode code
- */
-uint64_t gdt[] __attribute__((aligned(16))) __bootdata = {
-	/* CS: code, read/execute, 4 GB, base 0 */
-	[GDT_ENTRY_BOOT_CS] = GDT_ENTRY(0xc09b, 0, 0xfffff),
-	/* DS: data, read/write, 4 GB, base 0 */
-	[GDT_ENTRY_BOOT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff),
-	/* CS: for real mode calls */
-	[GDT_ENTRY_REAL_CS] = GDT_ENTRY(0x009E, 0, 0x0ffff),
-	/* DS: for real mode calls */
-	[GDT_ENTRY_REAL_DS] = GDT_ENTRY(0x0092, 0, 0x0ffff),
-	/* TSS: 32-bit tss, 104 bytes, base 4096 */
-	/* We only have a TSS here to keep Intel VT happy;
-	   we don't actually use it for anything. */
-	[GDT_ENTRY_BOOT_TSS] = GDT_ENTRY(0x0089, 4096, 103),
-};
-
-/**
- * Size of the GDT must be known to load it
- *
- * Note: This varibale must reachable by real and flat mode code
- */
-unsigned gdt_size __bootdata = sizeof(gdt);
diff --git a/arch/x86/lib/linux_start.S b/arch/x86/lib/linux_start.S
deleted file mode 100644
index 07be37fed4a9..000000000000
--- a/arch/x86/lib/linux_start.S
+++ /dev/null
@@ -1,55 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-/* SPDX-FileCopyrightText: 1999-2008 Free Software Foundation, Inc. */
-
-/* Mostly stolen from the GRUB2 project */
-
-/**
- * @file
- * @brief Start the Linux real mode setup code
- *
- * Note: These functions are running in flat and real mode. Due to some
- * other restrictions these routines must running from an address
- * space below 0x10000
- */
-
-/*
- *   void bios_start_linux(unsigned segment)
- *
- */
-
-	.section .boot.text.bios_start_linux, "ax"
-	.code32
-	.globl bios_start_linux
-	.type bios_start_linux, @function
-
-	.extern prot_to_real
-
-bios_start_linux:
-	/* 'prot_to_real' eats our eax content */
-	movl %eax, %ebx
-	addl $0x20, %eax
-	movw %ax, setup_seg
-
-	call prot_to_real
-
-	.code16
-
-	cli
-	/* all segment registers are using the same segment */
-	movw %bx, %ss
-	movw %bx, %ds
-	movw %bx, %es
-	movw %bx, %fs
-	movw %bx, %gs
-
-	/* stack for the setup code (end of heap) */
-	movw $0x9000, %sp
-
-	/* do an 'ljmp' and never return */
-	.byte	0xea
-	.word	0
-setup_seg:
-	.word	0
-
-	.code32
diff --git a/arch/x86/lib/memory.c b/arch/x86/lib/memory.c
deleted file mode 100644
index 64fbbb9300e5..000000000000
--- a/arch/x86/lib/memory.c
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/* This code was inspired by the GRUB2 project. */
-
-/**
- * @file
- * @brief Memory management
- */
-
-#include <common.h>
-#include <init.h>
-#include <stdio.h>
-#include <memory.h>
-#include <asm/syslib.h>
-#include <asm-generic/memory_layout.h>
-
-/**
- * Handling of free memory
- *
- * Topics:
- * - areas used by BIOS code
- * - The 0xa0000... 0xfffff hole
- * - memory above 0x100000
- */
-
-int x86_start_barebox(void)
-{
-#ifdef CONFIG_MEMORY_LAYOUT_DEFAULT
-	unsigned long memory_size;
-
-	memory_size = bios_get_memsize();
-	memory_size <<= 10;	/* BIOS reports in kiB */
-
-	/*
-	 * We do not want to conflict with the kernel. So, we keep the
-	 * area from 0x100000 ... 0xFFFFFF free from usage
-	 */
-	if (memory_size >= (15 * 1024 * 1024 + MALLOC_SIZE))
-		mem_malloc_init((void*)(16 * 1024 * 1024),
-				(void*)(16 * 1024 * 1024 + MALLOC_SIZE - 1));
-	else
-		return -1;
-#else
-	mem_malloc_init((void *)MALLOC_BASE,
-			(void *)(MALLOC_BASE + MALLOC_SIZE - 1));
-#endif
-	start_barebox();
-}
diff --git a/arch/x86/mach-i386/Kconfig b/arch/x86/mach-i386/Kconfig
deleted file mode 100644
index 2d0bfb475947..000000000000
--- a/arch/x86/mach-i386/Kconfig
+++ /dev/null
@@ -1,13 +0,0 @@
-
-menu "Board specific settings"
-
-if X86_BOOTLOADER
-
-config X86_GENERIC_HAS_VIDEO
-	bool "video support"
-	help
-	  Say Y here if the target supports a video output
-
-endif
-
-endmenu
diff --git a/arch/x86/mach-i386/Makefile b/arch/x86/mach-i386/Makefile
deleted file mode 100644
index 225b4811c575..000000000000
--- a/arch/x86/mach-i386/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# reference clocksource
-obj-y += pit_timer.o
diff --git a/arch/x86/mach-i386/include/mach/barebox.lds.h b/arch/x86/mach-i386/include/mach/barebox.lds.h
deleted file mode 100644
index 50f17340e40a..000000000000
--- a/arch/x86/mach-i386/include/mach/barebox.lds.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-/**
- * @file
- * @brief Adapt linker script content in accordance to Kconfig settings
- */
-
-/**
- * Area in the MBR of the barebox basic boot code. This offset must be in
- * accordance to the 'indirect_sector_lba' label.
- */
-#define PATCH_AREA 400
-
-/**
- * Offset where to store the boot drive number (BIOS number, 1 byte)
- */
-#define PATCH_AREA_BOOT_DEV 16
-
-/**
- * Offset where to store information about the persistent environment storage
- * It points to an LBA number (8 bytes) and defines the first sector of this
- * storage on disk.
- */
-#define PATCH_AREA_PERS_START 20
-
-/**
- * Offset where to store information about the persistent environment storage
- * It points to a short number (2 bytes) and defines the sector count of this
- * storage on disk.
- */
-#define PATCH_AREA_PERS_SIZE 28
-
-/**
- * Offset where to store information about the persistent environment storage
- * drive number (BIOS number, 1 byte)
- */
-#define PATCH_AREA_PERS_DRIVE 30
-
-/**
- * Mark the persistent environment as not used
- */
-#define PATCH_AREA_PERS_SIZE_UNUSED 0x000
-
-/**
- * Mark a DAPS as unused/invalid
- */
-#define MARK_DAPS_INVALID 0x0000
-
-/**
- * Offset of the partition table in an MBR
- */
-#define OFFSET_OF_PARTITION_TABLE 446
-
-/**
- * Offset of the signature in an MBR
- */
-#define OFFSET_OF_SIGNATURE 510
-
-/**
- * Area where to store indirect sector to loop through. Keep this value
- * in accordance to the 'indirect_area' label. Note: .
- *
- * @attention These addresses are real mode ones (seg:offset)
- */
-#define INDIRECT_AREA 0x7A00
-#define INDIRECT_SEGMENT 0x0000
-
-/**
- * Area where to load sectors from disk to. They should start after the
- * MBR area and must be in accordance to the offset of the '.bootstrapping'
- * section in the linker file.
- *
- * @attention The address must be a multiple of 512.
- */
-#define LOAD_AREA 0x7e00
-#define LOAD_SEGMENT 0x0000
-
-/**
- * Size of one sector.
- */
-#define SECTOR_SIZE 512
diff --git a/arch/x86/mach-i386/pit_timer.c b/arch/x86/mach-i386/pit_timer.c
deleted file mode 100644
index d2da3b60d48b..000000000000
--- a/arch/x86/mach-i386/pit_timer.c
+++ /dev/null
@@ -1,53 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-/**
- * @file
- * @brief Clocksource based on the 'Programmable Interval Timer' PIT (8253)
- *
- * This timer should be available on almost all PCs. It also should be run
- * at a fixed frequency (1193181.8181 Hz) and not modified to use another
- * reload value than 0xFFFF. So, it always counts from 0xffff down to 0.
- *
- * @note: We can't reprogram the PIT, it will be still used by the BIOS. This
- * clocksource driver does not touch any PIT settings.
- */
-
-#include <init.h>
-#include <clock.h>
-#include <io.h>
-
-/** base address of the PIT in a standard PC */
-#define PIT 0x40
-
-static uint64_t pit_clocksource_read(void)
-{
-	uint16_t val1, val2;
-
-	outb(0x00, PIT + 3);	/* latch counter 0 */
-	outb(0x00, 0x80);
-
-	val1 = inb(PIT);
-	outb(0x00, 0x80);
-
-	val2 = inb(PIT);
-	val2 <<= 8;
-
-	/* note: its a down counter */
-	return 0xFFFFU - (val1 | val2);
-}
-
-static struct clocksource cs = {
-	.read	= pit_clocksource_read,
-	.mask	= CLOCKSOURCE_MASK(16),
-	.shift	= 10,
-};
-
-static int clocksource_init (void)
-{
-	cs.mult = clocksource_hz2mult(1193182, cs.shift);
-
-	return init_clock(&cs);
-}
-
-core_initcall(clocksource_init);
diff --git a/commands/Kconfig b/commands/Kconfig
index 6d84c956e576..767a20ed24c4 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -380,26 +380,6 @@ config CMD_BOOTZ
 
 	  Usage: bootz FILE
 
-config CMD_LINUX16
-	tristate
-	depends on X86 && !X86_EFI
-	default y if X86
-	prompt "linux16"
-	help
-	  Usage: linux16 [-v VESAMODE] FILE
-
-	  Load kernel from FILE and boot on x86 in real-mode.
-
-	  Only kernel images in bzImage format are supported by now.
-
-	  For the video mode refer the Linux kernel documentation
-	  'Documentation/fb/vesafb.txt' for correct VESA mode numbers. Use 'ask'
-	  instead of a number to make Linux prompt for options.
-
-	  Options:
-	  -v VESAMODE   set VESAMODE
-
-
 config CMD_GO
 	tristate
 	prompt "go"
diff --git a/commands/Makefile b/commands/Makefile
index cdf14a5e1d8d..447349fd157d 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -3,7 +3,6 @@ obj-$(CONFIG_CMD_DIGEST)	+= digest.o
 obj-$(CONFIG_COMPILE_HASH)	+= hashsum.o
 obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
 obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
-obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
 obj-$(CONFIG_CMD_LOADB)		+= loadb.o
 obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
diff --git a/commands/linux16.c b/commands/linux16.c
deleted file mode 100644
index 73e402d87741..000000000000
--- a/commands/linux16.c
+++ /dev/null
@@ -1,331 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: © 2009 Juergen Beisert, Pengutronix
-
-/*
- * In parts from the GRUB2 project:
- *
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008  Free Software Foundation, Inc.
- */
-
-#include <common.h>
-#include <command.h>
-#include <environment.h>
-#include <fs.h>
-#include <errno.h>
-#include <libfile.h>
-#include <getopt.h>
-#include <malloc.h>
-#include <boot.h>
-#include <asm/syslib.h>
-
-/** FIXME */
-#define LINUX_MAGIC_SIGNATURE       0x53726448      /* "HdrS" */
-
-/** FIXME */
-#define LINUX_FLAG_BIG_KERNEL       0x1
-
-/** FIXME */
-#define LINUX_BOOT_LOADER_TYPE      0x72
-
-/** FIXME */
-#define LINUX_DEFAULT_SETUP_SECTS	4
-
-/** FIXME */
-#define LINUX_MAX_SETUP_SECTS		64
-
-/** FIXME */
-#define LINUX_OLD_REAL_MODE_SEGMT	0x9000
-
-/** FIXME */
-#define LINUX_OLD_REAL_MODE_ADDR	(LINUX_OLD_REAL_MODE_SEGMT << 4)
-
-/** FIXME */
-#define LINUX_HEAP_END_OFFSET		(LINUX_OLD_REAL_MODE_SEGMT - 0x200)
-
-/** FIXME */
-#define LINUX_FLAG_CAN_USE_HEAP		0x80
-
-/** Define kernel command lines's start offset in the setup segment */
-#define LINUX_CL_OFFSET			0x9000
-
-/** Define kernel command lines's end offset */
-#define LINUX_CL_END_OFFSET		0x90FF
-
-/** FIXME */
-#define LINUX_CL_MAGIC			0xA33F
-
-/** FIXME */
-#define LINUX_SETUP_MOVE_SIZE		0x9100
-
-/** Sector size */
-#define DISK_SECTOR_BITS		9
-#define DISK_SECTOR_SIZE		0x200
-
-/** Where to load a bzImage */
-#define LINUX_BZIMAGE_ADDR		0x100000
-
-struct linux_kernel_header {
-	/* first sector of the image */
-	uint8_t code1[0x0020];
-	uint16_t cl_magic;		/**< Magic number 0xA33F */
-	uint16_t cl_offset;		/**< The offset of command line */
-	uint8_t code2[0x01F1 - 0x0020 - 2 - 2];
-	uint8_t setup_sects;		/**< The size of the setup in sectors */
-	uint16_t root_flags;		/**< If the root is mounted readonly */
-	uint16_t syssize;		/**< obsolete */
-	uint16_t swap_dev;		/**< obsolete */
-	uint16_t ram_size;		/**< obsolete */
-	uint16_t vid_mode;		/**< Video mode control */
-	uint16_t root_dev;		/**< Default root device number */
-	uint16_t boot_flag;		/**< 0xAA55 magic number */
-
-	/* second sector of the image */
-	uint16_t jump;			/**< Jump instruction (this is code!) */
-	uint32_t header;		/**< Magic signature "HdrS" */
-	uint16_t version;		/**< Boot protocol version supported */
-	uint32_t realmode_swtch;	/**< Boot loader hook */
-	uint16_t start_sys;		/**< The load-low segment (obsolete) */
-	uint16_t kernel_version;	/**< Points to kernel version string */
-	uint8_t type_of_loader;		/**< Boot loader identifier */
-#define LINUX_LOADER_ID_LILO		0x0
-#define LINUX_LOADER_ID_LOADLIN		0x1
-#define LINUX_LOADER_ID_BOOTSECT	0x2
-#define LINUX_LOADER_ID_SYSLINUX	0x3
-#define LINUX_LOADER_ID_ETHERBOOT	0x4
-#define LINUX_LOADER_ID_ELILO		0x5
-#define LINUX_LOADER_ID_GRUB		0x7
-#define LINUX_LOADER_ID_UBOOT		0x8
-#define LINUX_LOADER_ID_XEN		0x9
-#define LINUX_LOADER_ID_GUJIN		0xa
-#define LINUX_LOADER_ID_QEMU		0xb
-	uint8_t loadflags;		/**< Boot protocol option flags */
-	uint16_t setup_move_size;	/**< Move to high memory size */
-	uint32_t code32_start;		/**< Boot loader hook */
-	uint32_t ramdisk_image;		/**< initrd load address */
-	uint32_t ramdisk_size;		/**< initrd size */
-	uint32_t bootsect_kludge;	/**< obsolete */
-	uint16_t heap_end_ptr;		/**< Free memory after setup end */
-	uint8_t ext_loader_ver;		/**< boot loader's extension of the version number */
-	uint8_t ext_loader_type;	/**< boot loader's extension of its type */
-	char *cmd_line_ptr;		/**< Points to the kernel command line */
-	uint32_t initrd_addr_max;	/**< Highest address for initrd */
-#if 0
-	/* for the records only. These members are defined in
-	 * more recent Linux kernels
-	 */
-	uint32_t kernel_alignment;	/**< Alignment unit required by the kernel */
-	uint8_t relocatable_kernel;	/** */
-	uint8_t min_alignment;		/** */
-	uint32_t cmdline_size;		/** */
-	uint32_t hardware_subarch;	/** */
-	uint64_t hardware_subarch_data;	/** */
-	uint32_t payload_offset;	/** */
-	uint32_t payload_length;	/** */
-	uint64_t setup_data;		/** */
-	uint64_t pref_address;		/** */
-	uint32_t init_size;		/** */
-#endif
-} __attribute__ ((packed));
-
-/* This is -1. Keep this value in sync with the kernel */
-#define NORMAL_VGA	0xffff		/* 80x25 mode */
-#define ASK_VGA		0xfffd		/* ask for it at bootup */
-
-/**
- * Load an x86 Linux kernel bzImage and start it
- * @param argc parameter count
- * @param argv list of parameter
- *
- * Loads an x86 bzImage, checks for its integrity, stores the two parts
- * (setup = 'real mode code' and kernel = 'protected mode code') to their
- * default locations, switches back to real mode and runs the setup code.
- */
-static int do_linux16(int argc, char *argv[])
-{
-	struct linux_kernel_header *lh = NULL;
-	int rc, opt;
-	unsigned setup_sects;
-	unsigned real_mode_size;
-	int vid_mode = NORMAL_VGA;
-	size_t image_size;
-	const char *cmdline = linux_bootargs_get();
-	const char *kernel_file;
-
-	while((opt = getopt(argc, argv, "v:")) > 0) {
-		switch(opt) {
-		case 'v':
-			vid_mode = simple_strtoul(optarg, NULL, 0);
-			if (vid_mode == 0) {
-				if (!strcmp(optarg, "ask"))
-					vid_mode = ASK_VGA;
-				else {
-					printf("Unknown video mode: %s\n", optarg);
-					return 1;
-				}
-			}
-			break;
-		default:
-			return COMMAND_ERROR_USAGE;
-		}
-	}
-
-	if (optind == argc) {
-		printf("No kernel filename given\n");
-		return 1;
-	}
-	kernel_file = argv[optind];
-
-	lh = read_file(kernel_file, &image_size);
-	if (lh == NULL) {
-		printf("Cannot read file '%s'\n", argv[1]);
-		return 1;
-	}
-
-	if (lh->boot_flag != 0xaa55) {
-		printf("File '%s' has invalid magic number\n", argv[1]);
-		rc = 1;
-		goto on_error;
-	}
-
-	if (lh->setup_sects > LINUX_MAX_SETUP_SECTS) {
-		printf("File '%s' contains too many setup sectors\n", argv[1]);
-		rc = 1;
-		goto on_error;
-	}
-
-	setup_sects = lh->setup_sects;
-
-	printf("Found a %d.%d image header\n", lh->version >> 8, lh->version & 0xFF);
-
-	if (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0200) {
-		/* kernel is recent enough */
-		;
-		if (!(lh->loadflags & LINUX_FLAG_BIG_KERNEL)) {
-			printf("Cannot load a classic zImage. Use a bzImage instead\n");
-			goto on_error;
-		}
-		lh->type_of_loader = LINUX_BOOT_LOADER_TYPE;	/* TODO */
-
-		if (lh->version >= 0x0201) {
-			lh->heap_end_ptr = LINUX_HEAP_END_OFFSET;
-			lh->loadflags |= LINUX_FLAG_CAN_USE_HEAP;
-		}
-
-		if (lh->version >= 0x0202)
-			lh->cmd_line_ptr = (void*)(LINUX_OLD_REAL_MODE_ADDR + LINUX_CL_OFFSET);	/* FIXME */
-		else {
-			lh->cl_magic = LINUX_CL_MAGIC;
-			lh->cl_offset = LINUX_CL_OFFSET;
-			lh->setup_move_size = LINUX_SETUP_MOVE_SIZE;
-		}
-	} else {
-		printf("Kernel too old to handle\n");
-		rc = 1;
-		goto on_error;
-	}
-
-	if (strlen(cmdline) >= (LINUX_CL_END_OFFSET -  LINUX_CL_OFFSET)) {
-		printf("Kernel command line exceeds the available space\n");
-		rc = 1;
-		goto on_error;
-	}
-
-	/*
-	 * The kernel does not check for the "vga=<val>" kernel command line
-	 * parameter anymore. It expects this kind of information in the
-	 * boot parameters instead.
-	 */
-	if (vid_mode != NORMAL_VGA)
-		lh->vid_mode = vid_mode;
-
-	/* If SETUP_SECTS is not set, set it to the default.  */
-	if (setup_sects == 0) {
-		printf("Fixing setup sector count\n");
-		setup_sects = LINUX_DEFAULT_SETUP_SECTS;
-	}
-
-	if (setup_sects >= 15) {
-		void *src = lh;
-		if (lh->kernel_version != 0)
-			printf("Kernel version: '%s'\n",
-			       (char *)src + lh->kernel_version + DISK_SECTOR_SIZE);
-	}
-
-	/*
-	 * Size of the real mode part to handle in a separate way
-	 */
-	real_mode_size = (setup_sects << DISK_SECTOR_BITS) + DISK_SECTOR_SIZE;
-
-	/*
-	 *                real mode space                     hole            extended memory
-	 * |---------------------------------------------->|----------->|------------------------------>
-	 * 0                                            0xa0000     0x100000
-	 *  <-1-|----------2-----------><-3-   |
-	 *    0x7e00                        0x90000
-	 *                                <-4--|-5-->                   |---------6------------->
-	 *
-	 * 1) real mode stack
-	 * 2) barebox code
-	 * 3) flat mode stack
-	 * 4) realmode stack when starting a Linux kernel
-	 * 5) Kernel's real mode setup code
-	 * 6) compressed kernel image
-	 */
-	/*
-	 * Parts of the image we know:
-	 * - real mode part
-	 * - kernel payload
-	 */
-	/*
-	 * NOTE: This part is dangerous, as it copies some image content to
-	 * various locations in the main memory. This could overwrite important
-	 * data of the running barebox (hopefully not)
-	 */
-	/* copy the real mode part of the image to the 9th segment */
-	memcpy((void*)LINUX_OLD_REAL_MODE_ADDR, lh, LINUX_SETUP_MOVE_SIZE);
-
-	/* TODO add 'BOOT_IMAGE=<file>' and 'auto' if no user intervention was done (in front of all other params) */
-	/* copy also the command line into this area */
-	memcpy((void*)(LINUX_OLD_REAL_MODE_ADDR + LINUX_CL_OFFSET), cmdline, strlen(cmdline) + 1);
-	printf("Using kernel command line: '%s'\n", cmdline);
-
-	/* copy the compressed image part to its final address the setup code expects it
-	 * Note: The protected mode part starts at offset (setup_sects + 1) * 512
-	 */
-	memcpy((void*)LINUX_BZIMAGE_ADDR, ((void*)lh) + real_mode_size, image_size - real_mode_size);
-
-	/*
-	 * switch back to real mode now and start the real mode part of the
-	 * image at address "(LINUX_OLD_REAL_MODE_ADDR >> 4) + 0x20:0x0000"
-	 * which means "0x9020:0x000" -> 0x90200
-	 */
-	bios_start_linux(LINUX_OLD_REAL_MODE_SEGMT);	/* does not return */
-
-on_error:
-	if (lh != NULL)
-		free(lh);
-
-	return rc;
-}
-
-BAREBOX_CMD_HELP_START(linux16)
-BAREBOX_CMD_HELP_TEXT("Load kernel from FILE and boot on x86 in real-mode.")
-BAREBOX_CMD_HELP_TEXT("")
-BAREBOX_CMD_HELP_TEXT("Only kernel images in bzImage format are supported by now.")
-BAREBOX_CMD_HELP_TEXT("")
-BAREBOX_CMD_HELP_TEXT("For the video mode refer the Linux kernel documentation")
-BAREBOX_CMD_HELP_TEXT("'Documentation/fb/vesafb.txt' for correct VESA mode numbers. Use 'ask'")
-BAREBOX_CMD_HELP_TEXT("instead of a number to make Linux for options..")
-BAREBOX_CMD_HELP_TEXT("")
-BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT ("-v VESAMODE",   "set VESAMODE")
-BAREBOX_CMD_HELP_END
-
-BAREBOX_CMD_START(linux16)
-	.cmd		= do_linux16,
-	BAREBOX_CMD_DESC("boot a linux kernel on x86 via real-mode code")
-	BAREBOX_CMD_OPTS("[-v VESAMODE] FILE")
-	BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
-	BAREBOX_CMD_HELP(cmd_linux16_help)
-BAREBOX_CMD_END
diff --git a/common/partitions.c b/common/partitions.c
index 10ce53a6a125..1c1d0da99a8a 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -6,8 +6,6 @@
 /**
  * @file
  * @brief Generic support for partition tables on disk like media
- *
- * @todo Reliable size detection for BIOS based disks (on x86 only)
  */
 #include <common.h>
 #include <malloc.h>
diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 488c2936f715..8df0d5eb816a 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -37,31 +37,6 @@ static inline int is_extended_partition(struct partition *p)
 		p->dos_partition_type == LINUX_EXTENDED_PARTITION);
 }
 
-/**
- * Guess the size of the disk, based on the partition table entries
- * @param dev device to create partitions for
- * @param table partition table
- * @return sector count
- */
-static uint64_t disk_guess_size(struct device_d *dev,
-		struct partition_entry *table)
-{
-	uint64_t size = 0;
-	int i;
-
-	for (i = 0; i < 4; i++) {
-		if (get_unaligned_le32(&table[i].partition_start) != 0) {
-			uint64_t part_end = get_unaligned_le32(&table[i].partition_start) +
-				get_unaligned_le32(&table[i].partition_size);
-
-			if (size < part_end)
-				size = part_end;
-		}
-	}
-
-	return size;
-}
-
 static void *read_mbr(struct block_device *blk)
 {
 	void *buf = dma_alloc(SECTOR_SIZE);
@@ -210,10 +185,6 @@ static void dos_partition(void *buf, struct block_device *blk,
 
 	table = (struct partition_entry *)&buffer[446];
 
-	/* valid for x86 BIOS based disks only */
-	if (IS_ENABLED(CONFIG_DISK_BIOS) && blk->num_blocks == 0)
-		blk->num_blocks = disk_guess_size(blk->dev, table);
-
 	for (i = 0; i < 4; i++) {
 		pentry.first_sec = get_unaligned_le32(&table[i].partition_start);
 		pentry.size = get_unaligned_le32(&table[i].partition_size);
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index c0f0a3dbe3f3..50d3ba7f3a9f 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -20,15 +20,6 @@ source "drivers/block/Kconfig"
 
 comment "drive types"
 
-config DISK_BIOS
-	bool "BIOS based"
-	depends on X86_BIOS_BRINGUP
-	help
-	  Gain disk drive access via int13 calls to the standard PC-BIOS.
-	  The advantage of this driver is, it still uses user's defined boot
-	  media to work on. Disadvantage is: Due to its 16 bit nature it is
-	  slow.
-
 config DISK_ATA
 	bool "ATA type drives"
 	help
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 6b83ae2ef542..d3f5a0b57ee1 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -1,6 +1,5 @@
 # drive types
 
-obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
 obj-$(CONFIG_DISK_IDE_SFF) += ide-sff.o
 obj-$(CONFIG_DISK_ATA) += disk_ata_drive.o
 obj-$(CONFIG_DISK_AHCI) += ahci.o
diff --git a/drivers/ata/disk_bios_drive.c b/drivers/ata/disk_bios_drive.c
deleted file mode 100644
index 8f522eeba65b..000000000000
--- a/drivers/ata/disk_bios_drive.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (C) 2009...2011 Juergen Beisert, Pengutronix
- *
- * Mostly stolen from the GRUB2 project
- *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008  Free Software Foundation, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- *
- */
-
-/**
- * @file
- * @brief Media communication layer through the standard 16 bit PC-BIOS
- *
- * This communication driver does all accesses to the boot medium via 16 bit
- * real mode calls into the standard BIOS. Due to this method, its possible
- * to use all the medias to boot from that are supported by the BIOS. This
- * also includes emulated only medias.
- *
- * To be able to call the real mode BIOS, this driver must switch back to
- * real mode for each access. This will slow down the access a little bit, but
- * we are a boot loader here, not an operating system...
- *
- * Note: We need scratch memory for the BIOS communication, because the BIOS
- * can only handle memory below 0xA0000. So we must copy all data between
- * the flat mode buffers and realmode buffers.
- *
- * Note: This driver makes no sense on other architectures than x86.
- *
- * Note: This driver does only support LBA addressing. Currently no CHS!
- */
-
-#include <common.h>
-#include <init.h>
-#include <asm/syslib.h>
-#include <errno.h>
-#include <block.h>
-#include <disks.h>
-#include <malloc.h>
-
-/**
- * Sector count handled in one count
- *
- * @todo 127 are always possible, some BIOS manufacturer supports up to 255.
- * Is it's worth to detect Phoenic's restriction?
- */
-#define SECTORS_AT_ONCE 64
-
-/** Command to read sectors from media */
-#define BIOS_READ_CMD 0
-
-/** Command to write sectors to media */
-#define BIOS_WRT_CMD 1
-
-/**
- * "Disk Address Packet Structure" to be used when calling
- * BIOS's int13, function 0x42/0x43
- */
-struct DAPS
-{
-	uint8_t size;		/**< always '16' */
-	uint8_t res1;		/**< always '0' */
-	int8_t count;		/**< number of sectors 0...127 */
-	uint8_t res2;		/**< always '0' */
-	uint16_t offset;	/**< buffer address: offset */
-	uint16_t segment;	/**< buffer address: segment */
-	uint64_t lba;		/**< LBA of the start sector */
-} __attribute__ ((packed));
-
-/**
- * Collection of data we need to know about the connected drive
- */
-struct media_access {
-	struct block_device blk; /**< the main device */
-	int drive_no;	/**< drive number used by the BIOS */
-	int is_cdrom;	/**< drive is a CDROM e.g. no write support */
-};
-
-#define to_media_access(x) container_of((x), struct media_access, blk)
-
-/**
- * Scratch memory for BIOS communication to handle data in chunks of 32 kiB
- *
- * Note: This variable is located in the .bss segment, assuming it is located
- * below 0xA0000. If not, the BIOS is not able to read or store any data
- * from/to it. The variable must also aligned to a 16 byte boundary to easify
- * linear to segment:offset address conversion.
- */
-static uint8_t scratch_buffer[SECTORS_AT_ONCE * SECTOR_SIZE] __attribute__((aligned(16)));
-
-/**
- * Communication buffer for the 16 bit int13 BIOS call
- *
- * Note: This variable is located in the .bss segment, assuming it is located
- * below 0xA0000. If not, the BIOS is not able to read or store any data
- * from/to it. The variable must also aligned to a 16 byte boundary to easify
- * linear to segment:offset conversion.
- */
-static struct DAPS bios_daps __attribute__((aligned(16)));
-
-/**
- * @param media our data we need to do the access
- * @param cmd Command to forward to the BIOS
- * @param sector_start LBA of the start sector
- * @param sector_count Sector count
- * @param buffer Buffer to read from or write to (in the low memory area)
- * @return 0 on success, anything else on failure
- */
-static int biosdisk_bios_call(struct media_access *media, int cmd, sector_t sector_start, blkcnt_t sector_count, void *buffer)
-{
-	int rc;
-
-	/* prepare the DAPS for the int13 call */
-	bios_daps.size = sizeof(struct DAPS);
-	bios_daps.res1 = 0;
-	bios_daps.count = sector_count;	/* always less than 128! */
-	bios_daps.res2 = 0;
-	bios_daps.segment = (unsigned long)buffer >> 4;
-	bios_daps.offset = (unsigned long)buffer - (unsigned long)(bios_daps.segment << 4);
-	bios_daps.lba = sector_start;
-
-	if (cmd == BIOS_READ_CMD)
-		rc = bios_disk_rw_int13_extensions(0x42, media->drive_no, &bios_daps);
-	else if (cmd == BIOS_WRT_CMD)
-		rc = bios_disk_rw_int13_extensions(0x43, media->drive_no, &bios_daps);
-	else
-		return -1;
-
-	return rc;
-}
-
-/**
- * Read a chunk of sectors from media
- * @param blk All info about the block device we need
- * @param buffer Buffer to read into
- * @param block Sector's LBA number to start read from
- * @param num_blocks Sector count to read
- * @return 0 on success, anything else on failure
- *
- * This routine expects the buffer has the correct size to store all data!
- *
- * @note Due to 'block' is of type 'int' only small disks can be handled!
- */
-static int biosdisk_read(struct block_device *blk, void *buffer, sector_t block,
-				blkcnt_t num_blocks)
-{
-	int rc;
-	sector_t sector_start = block;
-	blkcnt_t sector_count = num_blocks;
-	struct media_access *media = to_media_access(blk);
-
-	while (sector_count >= SECTORS_AT_ONCE) {
-		rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
-		if (rc != 0)
-			return rc;
-		__builtin_memcpy(buffer, scratch_buffer, sizeof(scratch_buffer));
-		buffer += sizeof(scratch_buffer);
-		sector_start += SECTORS_AT_ONCE;
-		sector_count -= SECTORS_AT_ONCE;
-	};
-
-	/* Are sectors still remaining? */
-	if (sector_count) {
-		rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, sector_count, scratch_buffer);
-		__builtin_memcpy(buffer, scratch_buffer, sector_count * SECTOR_SIZE);
-	} else
-		rc = 0;
-
-	return rc;
-}
-
-/**
- * Write a chunk of sectors to media
- * @param blk All info about the block device we need
- * @param buffer Buffer to write from
- * @param block Sector's LBA number to start write to
- * @param num_blocks Sector count to write
- * @return 0 on success, anything else on failure
- *
- * This routine expects the buffer has the correct size to read all data!
- *
- * @note Due to 'block' is of type 'int' only small disks can be handled!
- */
-static int __maybe_unused biosdisk_write(struct block_device *blk,
-				const void *buffer, sector_t block, blkcnt_t num_blocks)
-{
-	int rc;
-	sector_t sector_start = block;
-	blkcnt_t sector_count = num_blocks;
-	struct media_access *media = to_media_access(blk);
-
-	while (sector_count >= SECTORS_AT_ONCE) {
-		__builtin_memcpy(scratch_buffer, buffer, sizeof(scratch_buffer));
-		rc = biosdisk_bios_call(media, BIOS_WRT_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
-		if (rc != 0)
-			return rc;
-		buffer += sizeof(scratch_buffer);
-		sector_start += SECTORS_AT_ONCE;
-		sector_count -= SECTORS_AT_ONCE;
-	};
-
-	/* Are sectors still remaining? */
-	if (sector_count) {
-		__builtin_memcpy(scratch_buffer, buffer, sector_count * SECTOR_SIZE);
-		rc = biosdisk_bios_call(media, BIOS_WRT_CMD, sector_start, sector_count, scratch_buffer);
-	} else
-		rc = 0;
-
-	return rc;
-}
-
-static struct block_device_ops bios_ata = {
-	.read = biosdisk_read,
-#ifdef CONFIG_BLOCK_WRITE
-	.write = biosdisk_write,
-#endif
-};
-
-/**
- * Probe for connected drives and register them
- *
- * Detecting if a drive is present is done by simply reading its MBR.
- *
- * FIXME: Relation between BIOS disk numbering scheme and our representation
- * here in barebox (and later on in the linux kernel)
- */
-static int biosdisk_probe(struct device_d *dev)
-{
-	int drive, rc;
-	struct media_access media, *m;
-
-	for (drive = 0x80; drive < 0x90; drive++) {
-		media.drive_no = drive;
-		media.is_cdrom = 0;	/* don't know yet */
-		rc = biosdisk_bios_call(&media, BIOS_READ_CMD, 0, 1, scratch_buffer);
-		if (rc != 0)
-			continue;
-
-		printf("BIOSdrive %d seems valid. Registering...\n", media.drive_no);
-
-		m = xzalloc(sizeof(struct media_access));
-
-		m->blk.dev = dev;
-		m->blk.ops = &bios_ata;
-		/*
-		 * keep the 'blk.num_blocks' member 0, as we don't know
-		 * the size of this disk yet!
-		 */
-		rc = cdev_find_free_index("disk");
-		if (rc < 0)
-			pr_err("Cannot find a free number for the disk node\n");
-		m->blk.cdev.name = basprintf("disk%d", rc);
-		m->blk.blockbits = SECTOR_SHIFT;
-
-		rc = blockdevice_register(&m->blk);
-		if (rc != 0) {
-			dev_err(dev, "Cannot register BIOSdrive %d\n",
-						media.drive_no);
-			free(m);
-			return rc;
-		}
-
-		/* create partitions on demand */
-		rc = parse_partition_table(&m->blk);
-		if (rc != 0)
-			dev_warn(dev, "No partition table found\n");
-	}
-
-	return 0;
-}
-
-static struct driver_d biosdisk_driver = {
-        .name   = "biosdrive",
-        .probe  = biosdisk_probe,
-};
-
-static int biosdisk_init(void)
-{
-	/* sanity */
-	if (scratch_buffer > (uint8_t*)0x9FFFF) {
-		printf("BIOS driver: Scratch memory not in real mode area. Cannot continue!\n");
-		return -EIO;
-	}
-	if (&bios_daps > (struct DAPS*)0x9FFFF) {
-		printf("BIOS driver: DAPS memory not in real mode area. Cannot continue!\n");
-		return -EIO;
-	}
-
-	platform_driver_register(&biosdisk_driver);
-	return 0;
-}
-
-device_initcall(biosdisk_init);
diff --git a/scripts/Makefile b/scripts/Makefile
index 744f4dd0e7e6..9c5309ee88e9 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -42,7 +42,6 @@ userccflags += -I $(srctree)/$(src)/include
 
 subdir-y			+= mod
 subdir-y			+= imx
-subdir-$(CONFIG_X86)		+= setupmbr
 subdir-$(CONFIG_DTC)		+= dtc
 subdir-$(CONFIG_ARCH_TEGRA)	+= tegra
 
diff --git a/scripts/setupmbr/.gitignore b/scripts/setupmbr/.gitignore
deleted file mode 100644
index a7301f911168..000000000000
--- a/scripts/setupmbr/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-setupmbr
diff --git a/scripts/setupmbr/Makefile b/scripts/setupmbr/Makefile
deleted file mode 100644
index 6e33d1536258..000000000000
--- a/scripts/setupmbr/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-HOST_EXTRACFLAGS=-I$(srctree)
-
-hostprogs-always-y += setupmbr
diff --git a/scripts/setupmbr/arch.h b/scripts/setupmbr/arch.h
deleted file mode 100644
index a720dfe95ef5..000000000000
--- a/scripts/setupmbr/arch.h
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/* we need the one from the host */
-#include <endian.h>
-#include <stdint.h>
-
-/* Byte-orders.  */
-#define swap16(x)	\
-({ \
-   uint16_t _x = (x); \
-   (uint16_t) ((_x << 8) | (_x >> 8)); \
-})
-
-#define swap32(x)	\
-({ \
-   uint32_t _x = (x); \
-   (uint32_t) ((_x << 24) \
-                    | ((_x & (uint32_t) 0xFF00UL) << 8) \
-                    | ((_x & (uint32_t) 0xFF0000UL) >> 8) \
-                    | (_x >> 24)); \
-})
-
-#define swap64(x)	\
-({ \
-   uint64_t _x = (x); \
-   (uint64_t) ((_x << 56) \
-                    | ((_x & (uint64_t) 0xFF00ULL) << 40) \
-                    | ((_x & (uint64_t) 0xFF0000ULL) << 24) \
-                    | ((_x & (uint64_t) 0xFF000000ULL) << 8) \
-                    | ((_x & (uint64_t) 0xFF00000000ULL) >> 8) \
-                    | ((_x & (uint64_t) 0xFF0000000000ULL) >> 24) \
-                    | ((_x & (uint64_t) 0xFF000000000000ULL) >> 40) \
-                    | (_x >> 56)); \
-})
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-
-/* Our target is a ia32 machine, always little endian */
-
-# define host2target_16(x)	swap16(x)
-# define host2target_32(x)	swap32(x)
-# define host2target_64(x)	swap64(x)
-# define target2host_16(x)	swap16(x)
-# define target2host_32(x)	swap32(x)
-# define target2host_64(x)	swap64(x)
-
-#else
-
-# define host2target_16(x)	(x)
-# define host2target_32(x)	(x)
-# define host2target_64(x)	(x)
-# define target2host_16(x)	(x)
-# define target2host_32(x)	(x)
-# define target2host_64(x)	(x)
-
-#endif
diff --git a/scripts/setupmbr/setupmbr.c b/scripts/setupmbr/setupmbr.c
deleted file mode 100644
index 38af55080907..000000000000
--- a/scripts/setupmbr/setupmbr.c
+++ /dev/null
@@ -1,545 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/**
- * @file
- * @brief Write the barebox binary to the MBR and the following disk sectors
- *
- * Also patch dedicated locations in the image to make it work at runtime
- *
- * Current restrictions are:
- * - only installs into MBR and the sectors after it
- * - tested only with QEMU
- * - and maybe some others
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <assert.h>
-
-/* include the info from this barebox release */
-#include "../../include/generated/utsrelease.h"
-#include "../../arch/x86/mach-i386/include/mach/barebox.lds.h"
-
-/** define to disable integrity tests and debug messages */
-#define NDEBUG
-
-/* some infos about our target architecture */
-#include "arch.h"
-
-/**
- * "Disk Address Packet Structure" to be used when calling int13,
- * function 0x42
- *
- * @note All entries are in target endianess
- */
-struct DAPS
-{
-	uint8_t size;		/**< size of this data set, 0 marks it as invalid */
-	uint8_t res1;		/**< always 0 */
-	int8_t count;		/**< number of sectors 0...127 to handle */
-	uint8_t res2;		/**< always 0 */
-	uint16_t offset;	/**< store address: offset */
-	uint16_t segment;	/**< store address: segment */
-	uint64_t lba;		/**< start sector number in LBA */
-} __attribute__ ((packed));
-
-/**
- * Description of one partition table entry (D*S type)
- *
- * @note All entries are in target endianess
- */
-struct partition_entry {
-	uint8_t boot_indicator;
-	uint8_t chs_begin[3];
-	uint8_t type;
-	uint8_t chs_end[3];
-	uint32_t partition_start;	/* LE */
-	uint32_t partition_size;	/* LE */
-} __attribute__ ((packed));
-
-#ifndef NDEBUG
-static void debugout(const struct DAPS *entry, int supress_entry)
-{
-	if (supress_entry)
-		printf("DAPS entry: ");
-	else
-		printf("DAPS entry % 3u: ", ((unsigned)entry & ( SECTOR_SIZE - 1)) / sizeof(struct DAPS));
-
-	printf("Size: % 2u, Count: % 3d, Offset: 0x%04hX, Segment: 0x%04hX, LBA: %llu\n",
-		entry->size, entry->count,
-		target2host_16(entry->offset), target2host_16(entry->segment),
-		target2host_64(entry->lba));
-}
-#else
-# define debugout(x,y) (__ASSERT_VOID_CAST(0))
-#endif
-
-/**
- * Fill *one* DAPS
- * @param sector The DAPS to fill
- * @param count Sector count
- * @param offset Realmode offset in the segment
- * @param segment Real mode segment
- * @param lba LBA of the first sector to read
- * @return 0 on success
- */
-static int fill_daps(struct DAPS *sector, unsigned count, unsigned offset, unsigned segment, uint64_t lba)
-{
-	assert(sector != NULL);
-	assert(count < 128);
-	assert(offset < 0x10000);
-	assert(segment < 0x10000);
-
-	sector->size = sizeof(struct DAPS);
-	sector->res1 = 0;
-	sector->count = (int8_t)count;
-	sector->res2 = 0;
-	sector->offset = host2target_16(offset);
-	sector->segment = host2target_16(segment);
-	sector->lba = host2target_64(lba);
-
-	return 0;
-}
-
-/**
- * Mark a DAPS invalid to let the boot loader code stop at this entry.
- * @param sector The DAPS to be marked as invalid
- *
- * Marking as invalid must be done in accordance to the detection method
- * the assembler routine in the boot loader uses:
- * The current code tests for zero in the first two bytes of the DAPS.
- */
-static void invalidate_daps(struct DAPS *sector)
-{
-	sector->size = MARK_DAPS_INVALID;
-	sector->res1 = 0;
-}
-
-/**
- * Create the indirect sector with the DAPS entries
- * @param daps_table Where to store the entries
- * @param size Size of the whole image in bytes
- * @param pers_sector_count Count of sectors to skip after MBR for the persistent environment storage
- * @return 0 on success
- *
- * This routine calculates the DAPS entries for the case the whole
- * barebox images fits into the MBR itself and the sectors after it.
- * This means the start of the first partition must keep enough sectors
- * unused.
- * It also skips 'pers_sector_count' sectors after the MBR for special
- * usage if given.
- */
-static int barebox_linear_image(struct DAPS *daps_table, off_t size, long pers_sector_count)
-{
-	unsigned offset = LOAD_AREA, next_offset;
-	unsigned segment = LOAD_SEGMENT;
-	unsigned chunk_size, i = 0;
-	uint64_t lba = 2 + pers_sector_count;
-	int rc;
-
-	/*
-	 * We can load up to 127 sectors in one chunk. What a bad number...
-	 * So, we will load in chunks of 32 kiB.
-	 */
-
-	/* at runtime two sectors from the image are already loaded: MBR and indirect */
-	size -= 2 * SECTOR_SIZE;
-	/* and now round up to multiple of sector size */
-	size = (size + SECTOR_SIZE - 1) & ~(SECTOR_SIZE - 1);
-
-	/*
-	 * The largest image we can load with this method is:
-	 * (SECTOR_SIZE / sizeof(DAPS) - 1) * 32 kiB
-	 * For a 512 byte sector and a 16 byte DAPS:
-	 * (512 / 16 - 1) * 32 kiB = 992 kiB
-	 * Note: '- 1' to consider one entry is required to pad to a 32 kiB boundary
-	 */
-
-	if (size >= (SECTOR_SIZE / sizeof(struct DAPS) - 1) * 32 * 1024) {
-		fprintf(stderr, "Image too large to boot. Max size is %zu kiB, image size is %lu kiB\n",
-			(SECTOR_SIZE / sizeof(struct DAPS) - 1) * 32, size / 1024);
-		return -1;
-	}
-
-	if (size > 32 * 1024) {
-		/* first fill up until the next 32 k boundary */
-		next_offset = (offset + 32 * 1024 -1) & ~0x7fff;
-		chunk_size = next_offset - offset;
-		if (chunk_size & (SECTOR_SIZE-1)) {
-			fprintf(stderr, "Unable to pad from %X to %X in multiple of sectors\n", offset, next_offset);
-			return -1;
-		}
-
-		rc = fill_daps(&daps_table[i], chunk_size / SECTOR_SIZE, offset, segment, lba);
-		if (rc != 0)
-			return -1;
-		debugout(&daps_table[i], 0);
-
-		/* calculate values to enter the loop for the other entries */
-		size -= chunk_size;
-		i++;
-		lba += chunk_size / SECTOR_SIZE;
-		offset += chunk_size;
-		if (offset >= 0x10000) {
-			segment += 4096;
-			offset = 0;
-		}
-
-		/*
-		 * Now load the remaining image part in 32 kiB chunks
-		 */
-		while (size) {
-			if (size >= 32 * 1024 ) {
-				if (i >= (SECTOR_SIZE / sizeof(struct DAPS))) {
-					fprintf(stderr, "Internal tool error: Too many DAPS entries!\n");
-					return -1;
-				}
-				rc = fill_daps(&daps_table[i], 64, offset, segment, lba);
-				if (rc != 0)
-					return -1;
-				debugout(&daps_table[i], 0);
-
-				size -= 32 * 1024;
-				lba += 64;
-				offset += 32 * 1024;
-				if (offset >= 0x10000) {
-					segment += 4096;
-					offset = 0;
-				}
-				i++;
-			} else {
-				if (i >= (SECTOR_SIZE / sizeof(struct DAPS))) {
-					fprintf(stderr, "Internal tool error: Too many DAPS entries!\n");
-					return -1;
-				}
-				rc = fill_daps(&daps_table[i], size / SECTOR_SIZE, offset, segment, lba);
-				if (rc != 0)
-					return -1;
-				debugout(&daps_table[i], 0);
-				size = 0;	/* finished */
-				i++;
-			}
-		};
-	} else {
-		/* less than 32 kiB. Very small image... */
-		rc = fill_daps(&daps_table[i], size / SECTOR_SIZE, offset, segment, lba);
-		if (rc != 0)
-			return -1;
-		debugout(&daps_table[i], 0);
-		i++;
-	}
-
-	/*
-	 * Do not mark an entry as invalid if the buffer is full. The
-	 * boot code stops if all entries of a buffer are read.
-	 */
-	if (i >= (SECTOR_SIZE / sizeof(struct DAPS)))
-		return 0;
-
-	/* mark the last DAPS invalid */
-	invalidate_daps(&daps_table[i]);
-	debugout(&daps_table[i], 0);
-
-	return 0;
-}
-
-/**
- * Do some simple sanity checks if this sector could be an MBR
- * @param sector Sector with data to check
- * @param size Size of the buffer
- * @return 0 if successfull
- */
-static int check_for_valid_mbr(const uint8_t *sector, off_t size)
-{
-	if (size < SECTOR_SIZE) {
-		fprintf(stderr, "MBR too small to be valid\n");
-		return -1;
-	}
-
-	if ((sector[OFFSET_OF_SIGNATURE] != 0x55) ||
-		(sector[OFFSET_OF_SIGNATURE + 1] != 0xAA)) {
-		fprintf(stderr, "No MBR signature found\n");
-		return -1;
-	}
-
-	/* FIXME: try to check if there is a valid partition table */
-	return 0;
-}
-
-/**
- * Check space between start of the image and the start of the first partition
- * @param hd_image HD image to examine
- * @param size Size of the barebox image
- * @return 0 on success, -1 if the barebox image is too large
- */
-static int check_for_space(const void *hd_image, off_t size)
-{
-	struct partition_entry *partition;
-	uint8_t *mbr_disk_sector = (uint8_t*)hd_image;
-	off_t spare_sector_count;
-
-	assert(hd_image != NULL);
-	assert(size > 0);
-
-	if (check_for_valid_mbr(hd_image, size) != 0)
-		return -1;
-
-	/* where to read */
-	partition = (struct partition_entry*) &mbr_disk_sector[OFFSET_OF_PARTITION_TABLE];
-
-	/* TODO describes the first entry always the first partition? */
-	spare_sector_count = target2host_32(partition->partition_start);
-
-#ifdef DEBUG
-	printf("Debug: Required free sectors for barebox prior first partition: %lu, hd image provides: %lu\n",
-		(size + SECTOR_SIZE - 1) / SECTOR_SIZE, spare_sector_count);
-#endif
-	spare_sector_count *= SECTOR_SIZE;
-	if (spare_sector_count < size) {
-		fprintf(stderr, "Not enough space after MBR to store barebox\n");
-		fprintf(stderr, "Move begin of the first partition beyond sector %lu\n", (size + SECTOR_SIZE - 1) / SECTOR_SIZE);
-		return -1;
-	}
-
-	return 0;
-}
-
-/**
- * Setup the persistent environment storage information
- * @param patch_area Where to patch
- * @param pers_sector_start Start sector of the persistent environment storage
- * @param pers_sector_count Count of sectors for the persistent environment storage
- * @return 0 on success
- */
-static int store_pers_env_info(void *patch_area, uint64_t pers_sector_start, long pers_sector_count)
-{
-	uint64_t *start_lba = (uint64_t*)(patch_area + PATCH_AREA_PERS_START);
-	uint16_t *count_lba = (uint16_t*)(patch_area + PATCH_AREA_PERS_SIZE);
-
-	assert(patch_area != NULL);
-	assert(pers_sector_count >= 0);
-
-	if (pers_sector_count == 0) {
-		*count_lba = host2target_16(PATCH_AREA_PERS_SIZE_UNUSED);
-		return 0;
-	}
-
-	*start_lba = host2target_64(pers_sector_start);
-	*count_lba = host2target_16(pers_sector_count);
-
-	return 0;
-}
-
-/**
- * Prepare the MBR and indirect sector for runtime
- * @param fd_barebox barebox image to use
- * @param fd_hd Hard disk image to prepare
- * @param pers_sector_count Count of sectors to skip after MBR for the persistent environment storage
- * @return 0 on success
- *
- * This routine expects a prepared hard disk image file with a partition table
- * in its first sector. This method only is currently supported.
- */
-static int barebox_overlay_mbr(int fd_barebox, int fd_hd, long pers_sector_count)
-{
-	const void *barebox_image;
-	void *hd_image;
-	int rc;
-	struct stat sb;
-	struct DAPS *embed;	/* part of the MBR */
-	struct DAPS *indirect;	/* sector with indirect DAPS */
-	off_t required_size;
-
-	if (fstat(fd_barebox, &sb) == -1) {
-		perror("fstat");
-		return -1;
-	}
-
-	/* the barebox image won't be touched */
-	barebox_image = mmap(NULL, sb.st_size,  PROT_READ, MAP_SHARED, fd_barebox, 0);
-	if (barebox_image == MAP_FAILED) {
-		perror("mmap");
-		return -1;
-	}
-
-	rc = check_for_valid_mbr(barebox_image, sb.st_size);
-	if (rc != 0) {
-		fprintf(stderr, "barebox image seems not valid: Bad MBR signature\n");
-		goto on_error_hd;
-	}
-
-	/*
-	 * the persistent environment storage is in front of the main
-	 * barebox image. To handle both, we need more space in front of the
-	 * the first partition.
-	 */
-	required_size = sb.st_size + pers_sector_count * SECTOR_SIZE;
-
-	/* the hd image will be modified */
-	hd_image = mmap(NULL, required_size,  PROT_READ | PROT_WRITE,
-					MAP_SHARED, fd_hd, 0);
-	if (hd_image == MAP_FAILED) {
-		perror("mmap");
-		rc = -1;
-		goto on_error_hd;
-	}
-
-	/* check for space */
-	rc = check_for_space(hd_image, required_size);
-	if (rc != 0)
-		goto on_error_space;
-
-	/* embed barebox's boot code into the disk drive image */
-	memcpy(hd_image, barebox_image, OFFSET_OF_PARTITION_TABLE);
-
-	/*
-	 * embed the barebox main image into the disk drive image,
-	 * but keep the persistent environment storage untouched
-	 * (if defined), e.g. store the main image behind this special area.
-	 */
-	memcpy(hd_image + ((pers_sector_count + 1) * SECTOR_SIZE),
-			barebox_image + SECTOR_SIZE, sb.st_size - SECTOR_SIZE);
-
-	/* now, prepare this hard disk image for BIOS based booting */
-	embed = hd_image + PATCH_AREA;
-	indirect = hd_image + ((pers_sector_count + 1) * SECTOR_SIZE);
-
-	/*
-	 * Fill the embedded DAPS to let the basic boot code find the
-	 * indirect sector at runtime
-	 */
-#ifdef DEBUG
-	printf("Debug: Fill in embedded DAPS\n");
-#endif
-	rc = fill_daps(embed, 1, INDIRECT_AREA, INDIRECT_SEGMENT,
-				1 + pers_sector_count);
-	if (rc != 0)
-		goto on_error_space;
-	debugout(embed, 1);
-
-#ifdef DEBUG
-	printf("Debug: Fill in indirect sector\n");
-#endif
-	/*
-	 * fill the indirect sector with the remaining DAPS to load the
-	 * whole barebox image at runtime
-	 */
-	rc = barebox_linear_image(indirect, sb.st_size, pers_sector_count);
-	if (rc != 0)
-		goto on_error_space;
-
-	/*
-	 * TODO: Replace the fixed LBA starting number by a calculated one,
-	 * to support barebox as a chained loader in a different start
-	 * sector than the MBR
-	 */
-	rc = store_pers_env_info(embed, 1, pers_sector_count);
-	if (rc != 0)
-		goto on_error_space;
-
-on_error_space:
-	munmap(hd_image, required_size);
-
-on_error_hd:
-	munmap((void*)barebox_image, sb.st_size);
-
-	return rc;
-}
-
-static void print_usage(const char *pname)
-{
-	printf("%s: Preparing a hard disk image for boot with barebox on x86.\n", pname);
-	printf("Usage is\n %s [options] -m <barebox image> -d <hd image>\n", pname);
-	printf(" [options] are:\n -s <count> sector count of the persistent environment storage\n");
-	printf(" <barebox image> barebox's boot image file\n");
-	printf(" <hd image> HD image to store the barebox image\n");
-	printf(" If no '-s <x>' was given, barebox occupies sectors 0 to n, else sector 0 and x+1 to n\n");
-}
-
-int main(int argc, char *argv[])
-{
-	int rc = 0, c;
-	char *barebox_image_filename = NULL, *hd_image_filename = NULL;
-	int fd_barebox_image = 0, fd_hd_image = 0;
-	long barebox_pers_size = -1;
-
-	if (argc == 1) {
-		print_usage(argv[0]);
-		exit(0);
-	}
-
-	/* handle command line options first */
-	while (1) {
-		c = getopt(argc, argv, "m:d:s:hv");
-		if (c == -1)
-			break;
-
-		switch (c) {
-		case 's':
-			barebox_pers_size = strtol(optarg, NULL, 0);
-			break;
-		case 'm':
-			barebox_image_filename = strdup(optarg);
-			break;
-		case 'd':
-			hd_image_filename = strdup(optarg);
-			break;
-		case 'h':
-			print_usage(argv[0]);
-			rc = 0;
-			goto on_error;
-		case 'v':
-			printf("setupmbr for u-boot-v%s\n", UTS_RELEASE);
-			printf("Send bug reports to 'barebox at lists.infradead.org'\n");
-			rc = 0;
-			goto on_error;
-		}
-	}
-
-	if (barebox_image_filename == NULL) {
-		print_usage(argv[0]);
-		rc = -1;
-		goto on_error;
-	}
-
-	fd_barebox_image = open(barebox_image_filename, O_RDONLY);
-	if (fd_barebox_image == -1) {
-		fprintf(stderr, "Cannot open '%s' for reading\n",
-				barebox_image_filename);
-		rc = -1;
-		goto on_error;
-	}
-
-	fd_hd_image = open(hd_image_filename, O_RDWR);
-	if (fd_hd_image == -1) {
-		fprintf(stderr, "Cannot open '%s'\n", hd_image_filename);
-		rc = -1;
-		goto on_error;
-	}
-
-	if (barebox_pers_size < 0)
-		barebox_pers_size = 0;
-
-	rc = barebox_overlay_mbr(fd_barebox_image, fd_hd_image, barebox_pers_size);
-
-on_error:
-	if (fd_barebox_image != -1)
-		close(fd_barebox_image);
-	if (fd_hd_image != -1)
-		close(fd_hd_image);
-
-	if (barebox_image_filename != NULL)
-		free(barebox_image_filename);
-	if (hd_image_filename != NULL)
-		free(hd_image_filename);
-
-	return rc;
-}
-- 
2.29.2




More information about the barebox mailing list