summaryrefslogtreecommitdiff
path: root/arch/i386/boot
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/boot')
-rw-r--r--arch/i386/boot/.gitignore3
-rw-r--r--arch/i386/boot/Makefile171
-rw-r--r--arch/i386/boot/a20.c161
-rw-r--r--arch/i386/boot/apm.c97
-rw-r--r--arch/i386/boot/bitops.h45
-rw-r--r--arch/i386/boot/boot.h296
-rw-r--r--arch/i386/boot/cmdline.c97
-rw-r--r--arch/i386/boot/code16gcc.h15
-rw-r--r--arch/i386/boot/compressed/.gitignore1
-rw-r--r--arch/i386/boot/compressed/Makefile50
-rw-r--r--arch/i386/boot/compressed/head.S180
-rw-r--r--arch/i386/boot/compressed/misc.c379
-rw-r--r--arch/i386/boot/compressed/relocs.c628
-rw-r--r--arch/i386/boot/compressed/vmlinux.lds43
-rw-r--r--arch/i386/boot/compressed/vmlinux.scr10
-rw-r--r--arch/i386/boot/copy.S101
-rw-r--r--arch/i386/boot/cpu.c69
-rw-r--r--arch/i386/boot/cpucheck.c267
-rw-r--r--arch/i386/boot/edd.c196
-rw-r--r--arch/i386/boot/header.S283
-rw-r--r--arch/i386/boot/install.sh54
-rw-r--r--arch/i386/boot/main.c161
-rw-r--r--arch/i386/boot/mca.c43
-rw-r--r--arch/i386/boot/memory.c99
-rw-r--r--arch/i386/boot/mtools.conf.in17
-rw-r--r--arch/i386/boot/pm.c170
-rw-r--r--arch/i386/boot/pmjump.S54
-rw-r--r--arch/i386/boot/printf.c307
-rw-r--r--arch/i386/boot/setup.ld54
-rw-r--r--arch/i386/boot/string.c52
-rw-r--r--arch/i386/boot/tools/.gitignore1
-rw-r--r--arch/i386/boot/tools/build.c168
-rw-r--r--arch/i386/boot/tty.c112
-rw-r--r--arch/i386/boot/version.c23
-rw-r--r--arch/i386/boot/vesa.h79
-rw-r--r--arch/i386/boot/video-bios.c125
-rw-r--r--arch/i386/boot/video-vesa.c284
-rw-r--r--arch/i386/boot/video-vga.c260
-rw-r--r--arch/i386/boot/video.c456
-rw-r--r--arch/i386/boot/video.h145
-rw-r--r--arch/i386/boot/voyager.c46
41 files changed, 0 insertions, 5802 deletions
diff --git a/arch/i386/boot/.gitignore b/arch/i386/boot/.gitignore
deleted file mode 100644
index 495f20c085de..000000000000
--- a/arch/i386/boot/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bootsect
-bzImage
-setup
diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
deleted file mode 100644
index 08678a0a3d19..000000000000
--- a/arch/i386/boot/Makefile
+++ /dev/null
@@ -1,171 +0,0 @@
-#
-# arch/i386/boot/Makefile
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License. See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1994 by Linus Torvalds
-#
-
-# ROOT_DEV specifies the default root-device when making the image.
-# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
-# the default of FLOPPY is used by 'build'.
-
-ROOT_DEV := CURRENT
-
-# If you want to preset the SVGA mode, uncomment the next line and
-# set SVGA_MODE to whatever number you want.
-# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
-# The number is the same as you would ordinarily press at bootup.
-
-SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
-
-# If you want the RAM disk device, define this to be the size in blocks.
-
-#RAMDISK := -DRAMDISK=512
-
-targets := vmlinux.bin setup.bin setup.elf zImage bzImage
-subdir- := compressed
-
-setup-y += a20.o apm.o cmdline.o copy.o cpu.o cpucheck.o edd.o
-setup-y += header.o main.o mca.o memory.o pm.o pmjump.o
-setup-y += printf.o string.o tty.o video.o version.o voyager.o
-
-# The link order of the video-*.o modules can matter. In particular,
-# video-vga.o *must* be listed first, followed by video-vesa.o.
-# Hardware-specific drivers should follow in the order they should be
-# probed, and video-bios.o should typically be last.
-setup-y += video-vga.o
-setup-y += video-vesa.o
-setup-y += video-bios.o
-
-hostprogs-y := tools/build
-
-HOSTCFLAGS_build.o := $(LINUXINCLUDE)
-
-# ---------------------------------------------------------------------------
-
-# How to compile the 16-bit code. Note we always compile for -march=i386,
-# that way we can complain to the user if the CPU is insufficient.
-cflags-i386 :=
-cflags-x86_64 := -m32
-CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
- $(cflags-$(ARCH)) \
- -Wall -Wstrict-prototypes \
- -march=i386 -mregparm=3 \
- -include $(srctree)/$(src)/code16gcc.h \
- -fno-strict-aliasing -fomit-frame-pointer \
- $(call cc-option, -ffreestanding) \
- $(call cc-option, -fno-toplevel-reorder,\
- $(call cc-option, -fno-unit-at-a-time)) \
- $(call cc-option, -fno-stack-protector) \
- $(call cc-option, -mpreferred-stack-boundary=2)
-AFLAGS := $(CFLAGS) -D__ASSEMBLY__
-
-$(obj)/zImage: IMAGE_OFFSET := 0x1000
-$(obj)/zImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK)
-$(obj)/bzImage: IMAGE_OFFSET := 0x100000
-$(obj)/bzImage: EXTRA_CFLAGS := -D__BIG_KERNEL__
-$(obj)/bzImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
-$(obj)/bzImage: BUILDFLAGS := -b
-
-quiet_cmd_image = BUILD $@
-cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
- $(obj)/vmlinux.bin $(ROOT_DEV) > $@
-
-$(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
- $(obj)/vmlinux.bin $(obj)/tools/build FORCE
- $(call if_changed,image)
- @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
-
-$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
- $(call if_changed,objcopy)
-
-SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
-
-LDFLAGS_setup.elf := -T
-$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
- $(call if_changed,ld)
-
-OBJCOPYFLAGS_setup.bin := -O binary
-
-$(obj)/setup.bin: $(obj)/setup.elf FORCE
- $(call if_changed,objcopy)
-
-$(obj)/compressed/vmlinux: FORCE
- $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
-
-# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
-FDARGS =
-# Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
-FDINITRD =
-
-image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
-
-$(obj)/mtools.conf: $(src)/mtools.conf.in
- sed -e 's|@OBJ@|$(obj)|g' < $< > $@
-
-# This requires write access to /dev/fd0
-zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
- MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
- syslinux /dev/fd0 ; sync
- echo '$(image_cmdline)' | \
- MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
- if [ -f '$(FDINITRD)' ] ; then \
- MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
- fi
- MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
-
-# These require being root or having syslinux 2.02 or higher installed
-fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
- dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
- MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
- syslinux $(obj)/fdimage ; sync
- echo '$(image_cmdline)' | \
- MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
- if [ -f '$(FDINITRD)' ] ; then \
- MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
- fi
- MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
-
-fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
- dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
- MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
- syslinux $(obj)/fdimage ; sync
- echo '$(image_cmdline)' | \
- MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
- if [ -f '$(FDINITRD)' ] ; then \
- MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
- fi
- MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
-
-isoimage: $(BOOTIMAGE)
- -rm -rf $(obj)/isoimage
- mkdir $(obj)/isoimage
- for i in lib lib64 share end ; do \
- if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
- cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
- break ; \
- fi ; \
- if [ $$i = end ] ; then exit 1 ; fi ; \
- done
- cp $(BOOTIMAGE) $(obj)/isoimage/linux
- echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
- if [ -f '$(FDINITRD)' ] ; then \
- cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
- fi
- mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
- -no-emul-boot -boot-load-size 4 -boot-info-table \
- $(obj)/isoimage
- rm -rf $(obj)/isoimage
-
-zlilo: $(BOOTIMAGE)
- if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
- if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
- cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
- cp System.map $(INSTALL_PATH)/
- if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
-
-install:
- sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
diff --git a/arch/i386/boot/a20.c b/arch/i386/boot/a20.c
deleted file mode 100644
index 31348d054fca..000000000000
--- a/arch/i386/boot/a20.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/a20.c
- *
- * Enable A20 gate (return -1 on failure)
- */
-
-#include "boot.h"
-
-#define MAX_8042_LOOPS 100000
-
-static int empty_8042(void)
-{
- u8 status;
- int loops = MAX_8042_LOOPS;
-
- while (loops--) {
- io_delay();
-
- status = inb(0x64);
- 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 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 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 a20_test_long(void)
-{
- return a20_test(A20_TEST_LONG);
-}
-
-static void enable_a20_bios(void)
-{
- asm volatile("pushfl; int $0x15; popfl"
- : : "a" ((u16)0x2401));
-}
-
-static void enable_a20_kbc(void)
-{
- empty_8042();
-
- outb(0xd1, 0x64); /* Command write */
- empty_8042();
-
- outb(0xdf, 0x60); /* A20 on */
- empty_8042();
-}
-
-static void 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 enable_a20(void)
-{
- int loops = A20_ENABLE_LOOPS;
-
-#if defined(CONFIG_X86_ELAN)
- /* Elan croaks if we try to touch the KBC */
- enable_a20_fast();
- while (!a20_test_long())
- ;
- return 0;
-#elif defined(CONFIG_X86_VOYAGER)
- /* On Voyager, a20_test() is unsafe? */
- enable_a20_kbc();
- return 0;
-#else
- 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 */
- empty_8042();
- if (a20_test_short())
- return 0; /* BIOS worked, but with delayed reaction */
-
- 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;
-#endif
-}
diff --git a/arch/i386/boot/apm.c b/arch/i386/boot/apm.c
deleted file mode 100644
index a34087c370c0..000000000000
--- a/arch/i386/boot/apm.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * Original APM BIOS checking by Stephen Rothwell, May 1994
- * (sfr@canb.auug.org.au)
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/apm.c
- *
- * Get APM BIOS information
- */
-
-#include "boot.h"
-
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
-
-int query_apm_bios(void)
-{
- u16 ax, bx, cx, dx, di;
- u32 ebx, esi;
- u8 err;
-
- /* APM BIOS installation check */
- ax = 0x5300;
- bx = cx = 0;
- asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
- : "=d" (err), "+a" (ax), "+b" (bx), "+c" (cx)
- : : "esi", "edi");
-
- if (err)
- return -1; /* No APM BIOS */
-
- if (bx != 0x504d) /* "PM" signature */
- return -1;
-
- if (cx & 0x02) /* 32 bits supported? */
- return -1;
-
- /* Disconnect first, just in case */
- ax = 0x5304;
- asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
- : "+a" (ax)
- : : "ebx", "ecx", "edx", "esi", "edi");
-
- /* Paranoia */
- ebx = esi = 0;
- cx = dx = di = 0;
-
- /* 32-bit connect */
- asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %6"
- : "=a" (ax), "+b" (ebx), "+c" (cx), "+d" (dx),
- "+S" (esi), "+D" (di), "=m" (err)
- : "a" (0x5303));
-
- boot_params.apm_bios_info.cseg = ax;
- boot_params.apm_bios_info.offset = ebx;
- boot_params.apm_bios_info.cseg_16 = cx;
- boot_params.apm_bios_info.dseg = dx;
- boot_params.apm_bios_info.cseg_len = (u16)esi;
- boot_params.apm_bios_info.cseg_16_len = esi >> 16;
- boot_params.apm_bios_info.dseg_len = di;
-
- if (err)
- return -1;
-
- /* Redo the installation check as the 32-bit connect;
- some BIOSes return different flags this way... */
-
- ax = 0x5300;
- bx = cx = 0;
- asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
- : "=d" (err), "+a" (ax), "+b" (bx), "+c" (cx)
- : : "esi", "edi");
-
- if (err || bx != 0x504d) {
- /* Failure with 32-bit connect, try to disconect and ignore */
- ax = 0x5304;
- bx = 0;
- asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
- : "+a" (ax), "+b" (bx)
- : : "ecx", "edx", "esi", "edi");
- return -1;
- }
-
- boot_params.apm_bios_info.version = ax;
- boot_params.apm_bios_info.flags = cx;
- return 0;
-}
-
-#endif
diff --git a/arch/i386/boot/bitops.h b/arch/i386/boot/bitops.h
deleted file mode 100644
index 8dcc8dc7db88..000000000000
--- a/arch/i386/boot/bitops.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/bitops.h
- *
- * Very simple bitops for the boot code.
- */
-
-#ifndef BOOT_BITOPS_H
-#define BOOT_BITOPS_H
-#define _LINUX_BITOPS_H /* Inhibit inclusion of <linux/bitops.h> */
-
-static inline int constant_test_bit(int nr, const void *addr)
-{
- const u32 *p = (const u32 *)addr;
- return ((1UL << (nr & 31)) & (p[nr >> 5])) != 0;
-}
-static inline int variable_test_bit(int nr, const void *addr)
-{
- u8 v;
- const u32 *p = (const u32 *)addr;
-
- asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
- return v;
-}
-
-#define test_bit(nr,addr) \
-(__builtin_constant_p(nr) ? \
- constant_test_bit((nr),(addr)) : \
- variable_test_bit((nr),(addr)))
-
-static inline void set_bit(int nr, void *addr)
-{
- asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
-}
-
-#endif /* BOOT_BITOPS_H */
diff --git a/arch/i386/boot/boot.h b/arch/i386/boot/boot.h
deleted file mode 100644
index 0329c4fe4f88..000000000000
--- a/arch/i386/boot/boot.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/boot.h
- *
- * Header file for the real-mode kernel code
- */
-
-#ifndef BOOT_BOOT_H
-#define BOOT_BOOT_H
-
-#ifndef __ASSEMBLY__
-
-#include <stdarg.h>
-#include <linux/types.h>
-#include <linux/edd.h>
-#include <asm/boot.h>
-#include <asm/bootparam.h>
-
-/* Useful macros */
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-
-extern struct setup_header hdr;
-extern struct boot_params boot_params;
-
-/* Basic port I/O */
-static inline void outb(u8 v, u16 port)
-{
- asm volatile("outb %0,%1" : : "a" (v), "dN" (port));
-}
-static inline u8 inb(u16 port)
-{
- u8 v;
- asm volatile("inb %1,%0" : "=a" (v) : "dN" (port));
- return v;
-}
-
-static inline void outw(u16 v, u16 port)
-{
- asm volatile("outw %0,%1" : : "a" (v), "dN" (port));
-}
-static inline u16 inw(u16 port)
-{
- u16 v;
- asm volatile("inw %1,%0" : "=a" (v) : "dN" (port));
- return v;
-}
-
-static inline void outl(u32 v, u16 port)
-{
- asm volatile("outl %0,%1" : : "a" (v), "dn" (port));
-}
-static inline u32 inl(u32 port)
-{
- u32 v;
- asm volatile("inl %1,%0" : "=a" (v) : "dN" (port));
- return v;
-}
-
-static inline void io_delay(void)
-{
- const u16 DELAY_PORT = 0x80;
- asm volatile("outb %%al,%0" : : "dN" (DELAY_PORT));
-}
-
-/* These functions are used to reference data in other segments. */
-
-static inline u16 ds(void)
-{
- u16 seg;
- asm("movw %%ds,%0" : "=rm" (seg));
- return seg;
-}
-
-static inline void set_fs(u16 seg)
-{
- asm volatile("movw %0,%%fs" : : "rm" (seg));
-}
-static inline u16 fs(void)
-{
- u16 seg;
- asm("movw %%fs,%0" : "=rm" (seg));
- return seg;
-}
-
-static inline void set_gs(u16 seg)
-{
- asm volatile("movw %0,%%gs" : : "rm" (seg));
-}
-static inline u16 gs(void)
-{
- u16 seg;
- asm("movw %%gs,%0" : "=rm" (seg));
- return seg;
-}
-
-typedef unsigned int addr_t;
-
-static inline u8 rdfs8(addr_t addr)
-{
- u8 v;
- asm("movb %%fs:%1,%0" : "=r" (v) : "m" (*(u8 *)addr));
- return v;
-}
-static inline u16 rdfs16(addr_t addr)
-{
- u16 v;
- asm("movw %%fs:%1,%0" : "=r" (v) : "m" (*(u16 *)addr));
- return v;
-}
-static inline u32 rdfs32(addr_t addr)
-{
- u32 v;
- asm("movl %%fs:%1,%0" : "=r" (v) : "m" (*(u32 *)addr));
- return v;
-}
-
-static inline void wrfs8(u8 v, addr_t addr)
-{
- asm volatile("movb %1,%%fs:%0" : "+m" (*(u8 *)addr) : "r" (v));
-}
-static inline void wrfs16(u16 v, addr_t addr)
-{
- asm volatile("movw %1,%%fs:%0" : "+m" (*(u16 *)addr) : "r" (v));
-}
-static inline void wrfs32(u32 v, addr_t addr)
-{
- asm volatile("movl %1,%%fs:%0" : "+m" (*(u32 *)addr) : "r" (v));
-}
-
-static inline u8 rdgs8(addr_t addr)
-{
- u8 v;
- asm("movb %%gs:%1,%0" : "=r" (v) : "m" (*(u8 *)addr));
- return v;
-}
-static inline u16 rdgs16(addr_t addr)
-{
- u16 v;
- asm("movw %%gs:%1,%0" : "=r" (v) : "m" (*(u16 *)addr));
- return v;
-}
-static inline u32 rdgs32(addr_t addr)
-{
- u32 v;
- asm("movl %%gs:%1,%0" : "=r" (v) : "m" (*(u32 *)addr));
- return v;
-}
-
-static inline void wrgs8(u8 v, addr_t addr)
-{
- asm volatile("movb %1,%%gs:%0" : "+m" (*(u8 *)addr) : "r" (v));
-}
-static inline void wrgs16(u16 v, addr_t addr)
-{
- asm volatile("movw %1,%%gs:%0" : "+m" (*(u16 *)addr) : "r" (v));
-}
-static inline void wrgs32(u32 v, addr_t addr)
-{
- asm volatile("movl %1,%%gs:%0" : "+m" (*(u32 *)addr) : "r" (v));
-}
-
-/* Note: these only return true/false, not a signed return value! */
-static inline int memcmp(const void *s1, const void *s2, size_t len)
-{
- u8 diff;
- asm("repe; cmpsb; setnz %0"
- : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
- return diff;
-}
-
-static inline int memcmp_fs(const void *s1, addr_t s2, size_t len)
-{
- u8 diff;
- asm("fs; repe; cmpsb; setnz %0"
- : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
- return diff;
-}
-static inline int memcmp_gs(const void *s1, addr_t s2, size_t len)
-{
- u8 diff;
- asm("gs; repe; cmpsb; setnz %0"
- : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
- return diff;
-}
-
-static inline int isdigit(int ch)
-{
- return (ch >= '0') && (ch <= '9');
-}
-
-/* Heap -- available for dynamic lists. */
-#define STACK_SIZE 512 /* Minimum number of bytes for stack */
-
-extern char _end[];
-extern char *HEAP;
-extern char *heap_end;
-#define RESET_HEAP() ((void *)( HEAP = _end ))
-static inline char *__get_heap(size_t s, size_t a, size_t n)
-{
- char *tmp;
-
- HEAP = (char *)(((size_t)HEAP+(a-1)) & ~(a-1));
- tmp = HEAP;
- HEAP += s*n;
- return tmp;
-}
-#define GET_HEAP(type, n) \
- ((type *)__get_heap(sizeof(type),__alignof__(type),(n)))
-
-static inline int heap_free(void)
-{
- return heap_end-HEAP;
-}
-
-/* copy.S */
-
-void copy_to_fs(addr_t dst, void *src, size_t len);
-void *copy_from_fs(void *dst, addr_t src, size_t len);
-void copy_to_gs(addr_t dst, void *src, size_t len);
-void *copy_from_gs(void *dst, addr_t src, size_t len);
-void *memcpy(void *dst, void *src, size_t len);
-void *memset(void *dst, int c, size_t len);
-
-#define memcpy(d,s,l) __builtin_memcpy(d,s,l)
-#define memset(d,c,l) __builtin_memset(d,c,l)
-
-/* a20.c */
-int enable_a20(void);
-
-/* apm.c */
-int query_apm_bios(void);
-
-/* cmdline.c */
-int cmdline_find_option(const char *option, char *buffer, int bufsize);
-
-/* cpu.c, cpucheck.c */
-int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr);
-int validate_cpu(void);
-
-/* edd.c */
-void query_edd(void);
-
-/* header.S */
-void __attribute__((noreturn)) die(void);
-
-/* mca.c */
-int query_mca(void);
-
-/* memory.c */
-int detect_memory(void);
-
-/* pm.c */
-void __attribute__((noreturn)) go_to_protected_mode(void);
-
-/* pmjump.S */
-void __attribute__((noreturn))
- protected_mode_jump(u32 entrypoint, u32 bootparams);
-
-/* printf.c */
-int sprintf(char *buf, const char *fmt, ...);
-int vsprintf(char *buf, const char *fmt, va_list args);
-int printf(const char *fmt, ...);
-
-/* string.c */
-int strcmp(const char *str1, const char *str2);
-size_t strnlen(const char *s, size_t maxlen);
-unsigned int atou(const char *s);
-
-/* tty.c */
-void puts(const char *);
-void putchar(int);
-int getchar(void);
-void kbd_flush(void);
-int getchar_timeout(void);
-
-/* video.c */
-void set_video(void);
-
-/* video-vesa.c */
-void vesa_store_edid(void);
-
-/* voyager.c */
-int query_voyager(void);
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* BOOT_BOOT_H */
diff --git a/arch/i386/boot/cmdline.c b/arch/i386/boot/cmdline.c
deleted file mode 100644
index 34bb778c4357..000000000000
--- a/arch/i386/boot/cmdline.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/cmdline.c
- *
- * Simple command-line parser for early boot.
- */
-
-#include "boot.h"
-
-static inline int myisspace(u8 c)
-{
- return c <= ' '; /* Close enough approximation */
-}
-
-/*
- * Find a non-boolean option, that is, "option=argument". In accordance
- * with standard Linux practice, if this option is repeated, this returns
- * the last instance on the command line.
- *
- * Returns the length of the argument (regardless of if it was
- * truncated to fit in the buffer), or -1 on not found.
- */
-int cmdline_find_option(const char *option, char *buffer, int bufsize)
-{
- u32 cmdline_ptr = boot_params.hdr.cmd_line_ptr;
- addr_t cptr;
- char c;
- int len = -1;
- const char *opptr = NULL;
- char *bufptr = buffer;
- enum {
- st_wordstart, /* Start of word/after whitespace */
- st_wordcmp, /* Comparing this word */
- st_wordskip, /* Miscompare, skip */
- st_bufcpy /* Copying this to buffer */
- } state = st_wordstart;
-
- if (!cmdline_ptr || cmdline_ptr >= 0x100000)
- return -1; /* No command line, or inaccessible */
-
- cptr = cmdline_ptr & 0xf;
- set_fs(cmdline_ptr >> 4);
-
- while (cptr < 0x10000 && (c = rdfs8(cptr++))) {
- switch (state) {
- case st_wordstart:
- if (myisspace(c))
- break;
-
- /* else */
- state = st_wordcmp;
- opptr = option;
- /* fall through */
-
- case st_wordcmp:
- if (c == '=' && !*opptr) {
- len = 0;
- bufptr = buffer;
- state = st_bufcpy;
- } else if (myisspace(c)) {
- state = st_wordstart;
- } else if (c != *opptr++) {
- state = st_wordskip;
- }
- break;
-
- case st_wordskip:
- if (myisspace(c))
- state = st_wordstart;
- break;
-
- case st_bufcpy:
- if (myisspace(c)) {
- state = st_wordstart;
- } else {
- if (len < bufsize-1)
- *bufptr++ = c;
- len++;
- }
- break;
- }
- }
-
- if (bufsize)
- *bufptr = '\0';
-
- return len;
-}
diff --git a/arch/i386/boot/code16gcc.h b/arch/i386/boot/code16gcc.h
deleted file mode 100644
index 3bd848093b9d..000000000000
--- a/arch/i386/boot/code16gcc.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * code16gcc.h
- *
- * This file is -include'd when compiling 16-bit C code.
- * Note: this asm() needs to be emitted before gcc omits any code.
- * Depending on gcc version, this requires -fno-unit-at-a-time or
- * -fno-toplevel-reorder.
- *
- * Hopefully gcc will eventually have a real -m16 option so we can
- * drop this hack long term.
- */
-
-#ifndef __ASSEMBLY__
-asm(".code16gcc");
-#endif
diff --git a/arch/i386/boot/compressed/.gitignore b/arch/i386/boot/compressed/.gitignore
deleted file mode 100644
index be0ed065249b..000000000000
--- a/arch/i386/boot/compressed/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-relocs
diff --git a/arch/i386/boot/compressed/Makefile b/arch/i386/boot/compressed/Makefile
deleted file mode 100644
index 189fa1dbefcc..000000000000
--- a/arch/i386/boot/compressed/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# linux/arch/i386/boot/compressed/Makefile
-#
-# create a compressed vmlinux image from the original vmlinux
-#
-
-targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o \
- vmlinux.bin.all vmlinux.relocs
-EXTRA_AFLAGS := -traditional
-
-LDFLAGS_vmlinux := -T
-hostprogs-y := relocs
-
-CFLAGS := -m32 -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
- -fno-strict-aliasing -fPIC \
- $(call cc-option,-ffreestanding) \
- $(call cc-option,-fno-stack-protector)
-LDFLAGS := -m elf_i386
-
-$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
- $(call if_changed,ld)
- @:
-
-$(obj)/vmlinux.bin: vmlinux FORCE
- $(call if_changed,objcopy)
-
-quiet_cmd_relocs = RELOCS $@
- cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
-$(obj)/vmlinux.relocs: vmlinux $(obj)/relocs FORCE
- $(call if_changed,relocs)
-
-vmlinux.bin.all-y := $(obj)/vmlinux.bin
-vmlinux.bin.all-$(CONFIG_RELOCATABLE) += $(obj)/vmlinux.relocs
-quiet_cmd_relocbin = BUILD $@
- cmd_relocbin = cat $(filter-out FORCE,$^) > $@
-$(obj)/vmlinux.bin.all: $(vmlinux.bin.all-y) FORCE
- $(call if_changed,relocbin)
-
-ifdef CONFIG_RELOCATABLE
-$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
- $(call if_changed,gzip)
-else
-$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
- $(call if_changed,gzip)
-endif
-
-LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
-
-$(obj)/piggy.o: $(src)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
- $(call if_changed,ld)
diff --git a/arch/i386/boot/compressed/head.S b/arch/i386/boot/compressed/head.S
deleted file mode 100644
index f35ea2237522..000000000000
--- a/arch/i386/boot/compressed/head.S
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * linux/boot/head.S
- *
- * Copyright (C) 1991, 1992, 1993 Linus Torvalds
- */
-
-/*
- * head.S contains the 32-bit startup code.
- *
- * NOTE!!! Startup happens at absolute address 0x00001000, which is also where
- * the page directory will exist. The startup code will be overwritten by
- * the page directory. [According to comments etc elsewhere on a compressed
- * kernel it will end up at 0x1000 + 1Mb I hope so as I assume this. - AC]
- *
- * Page 0 is deliberately kept safe, since System Management Mode code in
- * laptops may need to access the BIOS data stored there. This is also
- * useful for future device drivers that either access the BIOS via VM86
- * mode.
- */
-
-/*
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- */
-.text
-
-#include <linux/linkage.h>
-#include <asm/segment.h>
-#include <asm/page.h>
-#include <asm/boot.h>
-
-.section ".text.head","ax",@progbits
- .globl startup_32
-
-startup_32:
- cld
- cli
- movl $(__BOOT_DS),%eax
- movl %eax,%ds
- movl %eax,%es
- movl %eax,%fs
- movl %eax,%gs
- movl %eax,%ss
-
-/* Calculate the delta between where we were compiled to run
- * at and where we were actually loaded at. This can only be done
- * with a short local call on x86. Nothing else will tell us what
- * address we are running at. The reserved chunk of the real-mode
- * data at 0x1e4 (defined as a scratch field) are used as the stack
- * for this calculation. Only 4 bytes are needed.
- */
- leal (0x1e4+4)(%esi), %esp
- call 1f
-1: popl %ebp
- subl $1b, %ebp
-
-/* %ebp contains the address we are loaded at by the boot loader and %ebx
- * contains the address where we should move the kernel image temporarily
- * for safe in-place decompression.
- */
-
-#ifdef CONFIG_RELOCATABLE
- movl %ebp, %ebx
- addl $(CONFIG_PHYSICAL_ALIGN - 1), %ebx
- andl $(~(CONFIG_PHYSICAL_ALIGN - 1)), %ebx
-#else
- movl $LOAD_PHYSICAL_ADDR, %ebx
-#endif
-
- /* Replace the compressed data size with the uncompressed size */
- subl input_len(%ebp), %ebx
- movl output_len(%ebp), %eax
- addl %eax, %ebx
- /* Add 8 bytes for every 32K input block */
- shrl $12, %eax
- addl %eax, %ebx
- /* Add 32K + 18 bytes of extra slack */
- addl $(32768 + 18), %ebx
- /* Align on a 4K boundary */
- addl $4095, %ebx
- andl $~4095, %ebx
-
-/* Copy the compressed kernel to the end of our buffer
- * where decompression in place becomes safe.
- */
- pushl %esi
- leal _end(%ebp), %esi
- leal _end(%ebx), %edi
- movl $(_end - startup_32), %ecx
- std
- rep
- movsb
- cld
- popl %esi
-
-/* Compute the kernel start address.
- */
-#ifdef CONFIG_RELOCATABLE
- addl $(CONFIG_PHYSICAL_ALIGN - 1), %ebp
- andl $(~(CONFIG_PHYSICAL_ALIGN - 1)), %ebp
-#else
- movl $LOAD_PHYSICAL_ADDR, %ebp
-#endif
-
-/*
- * Jump to the relocated address.
- */
- leal relocated(%ebx), %eax
- jmp *%eax
-.section ".text"
-relocated:
-
-/*
- * Clear BSS
- */
- xorl %eax,%eax
- leal _edata(%ebx),%edi
- leal _end(%ebx), %ecx
- subl %edi,%ecx
- cld
- rep
- stosb
-
-/*
- * Setup the stack for the decompressor
- */
- leal stack_end(%ebx), %esp
-
-/*
- * Do the decompression, and jump to the new kernel..
- */
- movl output_len(%ebx), %eax
- pushl %eax
- pushl %ebp # output address
- movl input_len(%ebx), %eax
- pushl %eax # input_len
- leal input_data(%ebx), %eax
- pushl %eax # input_data
- leal _end(%ebx), %eax
- pushl %eax # end of the image as third argument
- pushl %esi # real mode pointer as second arg
- call decompress_kernel
- addl $20, %esp
- popl %ecx
-
-#if CONFIG_RELOCATABLE
-/* Find the address of the relocations.
- */
- movl %ebp, %edi
- addl %ecx, %edi
-
-/* Calculate the delta between where vmlinux was compiled to run
- * and where it was actually loaded.
- */
- movl %ebp, %ebx
- subl $LOAD_PHYSICAL_ADDR, %ebx
- jz 2f /* Nothing to be done if loaded at compiled addr. */
-/*
- * Process relocations.
- */
-
-1: subl $4, %edi
- movl 0(%edi), %ecx
- testl %ecx, %ecx
- jz 2f
- addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
- jmp 1b
-2:
-#endif
-
-/*
- * Jump to the decompressed kernel.
- */
- xorl %ebx,%ebx
- jmp *%ebp
-
-.bss
-.balign 4
-stack:
- .fill 4096, 1, 0
-stack_end:
diff --git a/arch/i386/boot/compressed/misc.c b/arch/i386/boot/compressed/misc.c
deleted file mode 100644
index b28505c544c9..000000000000
--- a/arch/i386/boot/compressed/misc.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * misc.c
- *
- * This is a collection of several routines from gzip-1.0.3
- * adapted for Linux.
- *
- * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
- * puts by Nick Holloway 1993, better puts by Martin Mares 1995
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- */
-
-#undef CONFIG_PARAVIRT
-#include <linux/linkage.h>
-#include <linux/vmalloc.h>
-#include <linux/screen_info.h>
-#include <asm/io.h>
-#include <asm/page.h>
-#include <asm/boot.h>
-
-/* WARNING!!
- * This code is compiled with -fPIC and it is relocated dynamically
- * at run time, but no relocation processing is performed.
- * This means that it is not safe to place pointers in static structures.
- */
-
-/*
- * Getting to provable safe in place decompression is hard.
- * Worst case behaviours need to be analized.
- * Background information:
- *
- * The file layout is:
- * magic[2]
- * method[1]
- * flags[1]
- * timestamp[4]
- * extraflags[1]
- * os[1]
- * compressed data blocks[N]
- * crc[4] orig_len[4]
- *
- * resulting in 18 bytes of non compressed data overhead.
- *
- * Files divided into blocks
- * 1 bit (last block flag)
- * 2 bits (block type)
- *
- * 1 block occurs every 32K -1 bytes or when there 50% compression has been achieved.
- * The smallest block type encoding is always used.
- *
- * stored:
- * 32 bits length in bytes.
- *
- * fixed:
- * magic fixed tree.
- * symbols.
- *
- * dynamic:
- * dynamic tree encoding.
- * symbols.
- *
- *
- * The buffer for decompression in place is the length of the
- * uncompressed data, plus a small amount extra to keep the algorithm safe.
- * The compressed data is placed at the end of the buffer. The output
- * pointer is placed at the start of the buffer and the input pointer
- * is placed where the compressed data starts. Problems will occur
- * when the output pointer overruns the input pointer.
- *
- * The output pointer can only overrun the input pointer if the input
- * pointer is moving faster than the output pointer. A condition only
- * triggered by data whose compressed form is larger than the uncompressed
- * form.
- *
- * The worst case at the block level is a growth of the compressed data
- * of 5 bytes per 32767 bytes.
- *
- * The worst case internal to a compressed block is very hard to figure.
- * The worst case can at least be boundined by having one bit that represents
- * 32764 bytes and then all of the rest of the bytes representing the very
- * very last byte.
- *
- * All of which is enough to compute an amount of extra data that is required
- * to be safe. To avoid problems at the block level allocating 5 extra bytes
- * per 32767 bytes of data is sufficient. To avoind problems internal to a block
- * adding an extra 32767 bytes (the worst case uncompressed block size) is
- * sufficient, to ensure that in the worst case the decompressed data for
- * block will stop the byte before the compressed data for a block begins.
- * To avoid problems with the compressed data's meta information an extra 18
- * bytes are needed. Leading to the formula:
- *
- * extra_bytes = (uncompressed_size >> 12) + 32768 + 18 + decompressor_size.
- *
- * Adding 8 bytes per 32K is a bit excessive but much easier to calculate.
- * Adding 32768 instead of 32767 just makes for round numbers.
- * Adding the decompressor_size is necessary as it musht live after all
- * of the data as well. Last I measured the decompressor is about 14K.
- * 10K of actuall data and 4K of bss.
- *
- */
-
-/*
- * gzip declarations
- */
-
-#define OF(args) args
-#define STATIC static
-
-#undef memset
-#undef memcpy
-#define memzero(s, n) memset ((s), 0, (n))
-
-typedef unsigned char uch;
-typedef unsigned short ush;
-typedef unsigned long ulg;
-
-#define WSIZE 0x80000000 /* Window size must be at least 32k,
- * and a power of two
- * We don't actually have a window just
- * a huge output buffer so I report
- * a 2G windows size, as that should
- * always be larger than our output buffer.
- */
-
-static uch *inbuf; /* input buffer */
-static uch *window; /* Sliding window buffer, (and final output buffer) */
-
-static unsigned insize; /* valid bytes in inbuf */
-static unsigned inptr; /* index of next byte to be processed in inbuf */
-static unsigned outcnt; /* bytes in output buffer */
-
-/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
-#define RESERVED 0xC0 /* bit 6,7: reserved */
-
-#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) error(msg);}
-# define Trace(x) fprintf x
-# define Tracev(x) {if (verbose) fprintf x ;}
-# define Tracevv(x) {if (verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-static int fill_inbuf(void);
-static void flush_window(void);
-static void error(char *m);
-static void gzip_mark(void **);
-static void gzip_release(void **);
-
-/*
- * This is set up by the setup-routine at boot-time
- */
-static unsigned char *real_mode; /* Pointer to real-mode data */
-
-#define RM_EXT_MEM_K (*(unsigned short *)(real_mode + 0x2))
-#ifndef STANDARD_MEMORY_BIOS_CALL
-#define RM_ALT_MEM_K (*(unsigned long *)(real_mode + 0x1e0))
-#endif
-#define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0))
-
-extern unsigned char input_data[];
-extern int input_len;
-
-static long bytes_out = 0;
-
-static void *malloc(int size);
-static void free(void *where);
-
-static void *memset(void *s, int c, unsigned n);
-static void *memcpy(void *dest, const void *src, unsigned n);
-
-static void putstr(const char *);
-
-static unsigned long free_mem_ptr;
-static unsigned long free_mem_end_ptr;
-
-#define HEAP_SIZE 0x4000
-
-static char *vidmem = (char *)0xb8000;
-static int vidport;
-static int lines, cols;
-
-#ifdef CONFIG_X86_NUMAQ
-void *xquad_portio;
-#endif
-
-#include "../../../../lib/inflate.c"
-
-static void *malloc(int size)
-{
- void *p;
-
- if (size <0) error("Malloc error");
- if (free_mem_ptr <= 0) error("Memory error");
-
- free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
-
- p = (void *)free_mem_ptr;
- free_mem_ptr += size;
-
- if (free_mem_ptr >= free_mem_end_ptr)
- error("Out of memory");
-
- return p;
-}
-
-static void free(void *where)
-{ /* Don't care */
-}
-
-static void gzip_mark(void **ptr)
-{
- *ptr = (void *) free_mem_ptr;
-}
-
-static void gzip_release(void **ptr)
-{
- free_mem_ptr = (unsigned long) *ptr;
-}
-
-static void scroll(void)
-{
- int i;
-
- memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 );
- for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 )
- vidmem[i] = ' ';
-}
-
-static void putstr(const char *s)
-{
- int x,y,pos;
- char c;
-
- x = RM_SCREEN_INFO.orig_x;
- y = RM_SCREEN_INFO.orig_y;
-
- while ( ( c = *s++ ) != '\0' ) {
- if ( c == '\n' ) {
- x = 0;
- if ( ++y >= lines ) {
- scroll();
- y--;
- }
- } else {
- vidmem [ ( x + cols * y ) * 2 ] = c;
- if ( ++x >= cols ) {
- x = 0;
- if ( ++y >= lines ) {
- scroll();
- y--;
- }
- }
- }
- }
-
- RM_SCREEN_INFO.orig_x = x;
- RM_SCREEN_INFO.orig_y = y;
-
- pos = (x + cols * y) * 2; /* Update cursor position */
- outb_p(14, vidport);
- outb_p(0xff & (pos >> 9), vidport+1);
- outb_p(15, vidport);
- outb_p(0xff & (pos >> 1), vidport+1);
-}
-
-static void* memset(void* s, int c, unsigned n)
-{
- int i;
- char *ss = (char*)s;
-
- for (i=0;i<n;i++) ss[i] = c;
- return s;
-}
-
-static void* memcpy(void* dest, const void* src, unsigned n)
-{
- int i;
- char *d = (char *)dest, *s = (char *)src;
-
- for (i=0;i<n;i++) d[i] = s[i];
- return dest;
-}
-
-/* ===========================================================================
- * Fill the input buffer. This is called only when the buffer is empty
- * and at least one byte is really needed.
- */
-static int fill_inbuf(void)
-{
- error("ran out of input data");
- return 0;
-}
-
-/* ===========================================================================
- * Write the output window window[0..outcnt-1] and update crc and bytes_out.
- * (Used for the decompressed data only.)
- */
-static void flush_window(void)
-{
- /* With my window equal to my output buffer
- * I only need to compute the crc here.
- */
- ulg c = crc; /* temporary variable */
- unsigned n;
- uch *in, ch;
-
- in = window;
- for (n = 0; n < outcnt; n++) {
- ch = *in++;
- c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
- }
- crc = c;
- bytes_out += (ulg)outcnt;
- outcnt = 0;
-}
-
-static void error(char *x)
-{
- putstr("\n\n");
- putstr(x);
- putstr("\n\n -- System halted");
-
- while(1); /* Halt */
-}
-
-asmlinkage void decompress_kernel(void *rmode, unsigned long end,
- uch *input_data, unsigned long input_len, uch *output)
-{
- real_mode = rmode;
-
- if (RM_SCREEN_INFO.orig_video_mode == 7) {
- vidmem = (char *) 0xb0000;
- vidport = 0x3b4;
- } else {
- vidmem = (char *) 0xb8000;
- vidport = 0x3d4;
- }
-
- lines = RM_SCREEN_INFO.orig_video_lines;
- cols = RM_SCREEN_INFO.orig_video_cols;
-
- window = output; /* Output buffer (Normally at 1M) */
- free_mem_ptr = end; /* Heap */
- free_mem_end_ptr = end + HEAP_SIZE;
- inbuf = input_data; /* Input buffer */
- insize = input_len;
- inptr = 0;
-
- if ((u32)output & (CONFIG_PHYSICAL_ALIGN -1))
- error("Destination address not CONFIG_PHYSICAL_ALIGN aligned");
- if (end > ((-__PAGE_OFFSET-(512 <<20)-1) & 0x7fffffff))
- error("Destination address too large");
-#ifndef CONFIG_RELOCATABLE
- if ((u32)output != LOAD_PHYSICAL_ADDR)
- error("Wrong destination address");
-#endif
-
- makecrc();
- putstr("Uncompressing Linux... ");
- gunzip();
- putstr("Ok, booting the kernel.\n");
- return;
-}
diff --git a/arch/i386/boot/compressed/relocs.c b/arch/i386/boot/compressed/relocs.c
deleted file mode 100644
index ce4fda261aaf..000000000000
--- a/arch/i386/boot/compressed/relocs.c
+++ /dev/null
@@ -1,628 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <elf.h>
-#include <byteswap.h>
-#define USE_BSD
-#include <endian.h>
-
-#define MAX_SHDRS 100
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-static Elf32_Ehdr ehdr;
-static Elf32_Shdr shdr[MAX_SHDRS];
-static Elf32_Sym *symtab[MAX_SHDRS];
-static Elf32_Rel *reltab[MAX_SHDRS];
-static char *strtab[MAX_SHDRS];
-static unsigned long reloc_count, reloc_idx;
-static unsigned long *relocs;
-
-/*
- * Following symbols have been audited. There values are constant and do
- * not change if bzImage is loaded at a different physical address than
- * the address for which it has been compiled. Don't warn user about
- * absolute relocations present w.r.t these symbols.
- */
-static const char* safe_abs_relocs[] = {
- "__kernel_vsyscall",
- "__kernel_rt_sigreturn",
- "__kernel_sigreturn",
- "SYSENTER_RETURN",
-};
-
-static int is_safe_abs_reloc(const char* sym_name)
-{
- int i, array_size;
-
- array_size = sizeof(safe_abs_relocs)/sizeof(char*);
-
- for(i = 0; i < array_size; i++) {
- if (!strcmp(sym_name, safe_abs_relocs[i]))
- /* Match found */
- return 1;
- }
- if (strncmp(sym_name, "__crc_", 6) == 0)
- return 1;
- return 0;
-}
-
-static void die(char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- exit(1);
-}
-
-static const char *sym_type(unsigned type)
-{
- static const char *type_name[] = {
-#define SYM_TYPE(X) [X] = #X
- SYM_TYPE(STT_NOTYPE),
- SYM_TYPE(STT_OBJECT),
- SYM_TYPE(STT_FUNC),
- SYM_TYPE(STT_SECTION),
- SYM_TYPE(STT_FILE),
- SYM_TYPE(STT_COMMON),
- SYM_TYPE(STT_TLS),
-#undef SYM_TYPE
- };
- const char *name = "unknown sym type name";
- if (type < ARRAY_SIZE(type_name)) {
- name = type_name[type];
- }
- return name;
-}
-
-static const char *sym_bind(unsigned bind)
-{
- static const char *bind_name[] = {
-#define SYM_BIND(X) [X] = #X
- SYM_BIND(STB_LOCAL),
- SYM_BIND(STB_GLOBAL),
- SYM_BIND(STB_WEAK),
-#undef SYM_BIND
- };
- const char *name = "unknown sym bind name";
- if (bind < ARRAY_SIZE(bind_name)) {
- name = bind_name[bind];
- }
- return name;
-}
-
-static const char *sym_visibility(unsigned visibility)
-{
- static const char *visibility_name[] = {
-#define SYM_VISIBILITY(X) [X] = #X
- SYM_VISIBILITY(STV_DEFAULT),
- SYM_VISIBILITY(STV_INTERNAL),
- SYM_VISIBILITY(STV_HIDDEN),
- SYM_VISIBILITY(STV_PROTECTED),
-#undef SYM_VISIBILITY
- };
- const char *name = "unknown sym visibility name";
- if (visibility < ARRAY_SIZE(visibility_name)) {
- name = visibility_name[visibility];
- }
- return name;
-}
-
-static const char *rel_type(unsigned type)
-{
- static const char *type_name[] = {
-#define REL_TYPE(X) [X] = #X
- REL_TYPE(R_386_NONE),
- REL_TYPE(R_386_32),
- REL_TYPE(R_386_PC32),
- REL_TYPE(R_386_GOT32),
- REL_TYPE(R_386_PLT32),
- REL_TYPE(R_386_COPY),
- REL_TYPE(R_386_GLOB_DAT),
- REL_TYPE(R_386_JMP_SLOT),
- REL_TYPE(R_386_RELATIVE),
- REL_TYPE(R_386_GOTOFF),
- REL_TYPE(R_386_GOTPC),
-#undef REL_TYPE
- };
- const char *name = "unknown type rel type name";
- if (type < ARRAY_SIZE(type_name)) {
- name = type_name[type];
- }
- return name;
-}
-
-static const char *sec_name(unsigned shndx)
-{
- const char *sec_strtab;
- const char *name;
- sec_strtab = strtab[ehdr.e_shstrndx];
- name = "<noname>";
- if (shndx < ehdr.e_shnum) {
- name = sec_strtab + shdr[shndx].sh_name;
- }
- else if (shndx == SHN_ABS) {
- name = "ABSOLUTE";
- }
- else if (shndx == SHN_COMMON) {
- name = "COMMON";
- }
- return name;
-}
-
-static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym)
-{
- const char *name;
- name = "<noname>";
- if (sym->st_name) {
- name = sym_strtab + sym->st_name;
- }
- else {
- name = sec_name(shdr[sym->st_shndx].sh_name);
- }
- return name;
-}
-
-
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define le16_to_cpu(val) (val)
-#define le32_to_cpu(val) (val)
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
-#define le16_to_cpu(val) bswap_16(val)
-#define le32_to_cpu(val) bswap_32(val)
-#endif
-
-static uint16_t elf16_to_cpu(uint16_t val)
-{
- return le16_to_cpu(val);
-}
-
-static uint32_t elf32_to_cpu(uint32_t val)
-{
- return le32_to_cpu(val);
-}
-
-static void read_ehdr(FILE *fp)
-{
- if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
- die("Cannot read ELF header: %s\n",
- strerror(errno));
- }
- if (memcmp(ehdr.e_ident, ELFMAG, 4) != 0) {
- die("No ELF magic\n");
- }
- if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
- die("Not a 32 bit executable\n");
- }
- if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
- die("Not a LSB ELF executable\n");
- }
- if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
- die("Unknown ELF version\n");
- }
- /* Convert the fields to native endian */
- ehdr.e_type = elf16_to_cpu(ehdr.e_type);
- ehdr.e_machine = elf16_to_cpu(ehdr.e_machine);
- ehdr.e_version = elf32_to_cpu(ehdr.e_version);
- ehdr.e_entry = elf32_to_cpu(ehdr.e_entry);
- ehdr.e_phoff = elf32_to_cpu(ehdr.e_phoff);
- ehdr.e_shoff = elf32_to_cpu(ehdr.e_shoff);
- ehdr.e_flags = elf32_to_cpu(ehdr.e_flags);
- ehdr.e_ehsize = elf16_to_cpu(ehdr.e_ehsize);
- ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
- ehdr.e_phnum = elf16_to_cpu(ehdr.e_phnum);
- ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
- ehdr.e_shnum = elf16_to_cpu(ehdr.e_shnum);
- ehdr.e_shstrndx = elf16_to_cpu(ehdr.e_shstrndx);
-
- if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
- die("Unsupported ELF header type\n");
- }
- if (ehdr.e_machine != EM_386) {
- die("Not for x86\n");
- }
- if (ehdr.e_version != EV_CURRENT) {
- die("Unknown ELF version\n");
- }
- if (ehdr.e_ehsize != sizeof(Elf32_Ehdr)) {
- die("Bad Elf header size\n");
- }
- if (ehdr.e_phentsize != sizeof(Elf32_Phdr)) {
- die("Bad program header entry\n");
- }
- if (ehdr.e_shentsize != sizeof(Elf32_Shdr)) {
- die("Bad section header entry\n");
- }
- if (ehdr.e_shstrndx >= ehdr.e_shnum) {
- die("String table index out of bounds\n");
- }
-}
-
-static void read_shdrs(FILE *fp)
-{
- int i;
- if (ehdr.e_shnum > MAX_SHDRS) {
- die("%d section headers supported: %d\n",
- ehdr.e_shnum, MAX_SHDRS);
- }
- if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
- die("Seek to %d failed: %s\n",
- ehdr.e_shoff, strerror(errno));
- }
- if (fread(&shdr, sizeof(shdr[0]), ehdr.e_shnum, fp) != ehdr.e_shnum) {
- die("Cannot read ELF section headers: %s\n",
- strerror(errno));
- }
- for(i = 0; i < ehdr.e_shnum; i++) {
- shdr[i].sh_name = elf32_to_cpu(shdr[i].sh_name);
- shdr[i].sh_type = elf32_to_cpu(shdr[i].sh_type);
- shdr[i].sh_flags = elf32_to_cpu(shdr[i].sh_flags);
- shdr[i].sh_addr = elf32_to_cpu(shdr[i].sh_addr);
- shdr[i].sh_offset = elf32_to_cpu(shdr[i].sh_offset);
- shdr[i].sh_size = elf32_to_cpu(shdr[i].sh_size);
- shdr[i].sh_link = elf32_to_cpu(shdr[i].sh_link);
- shdr[i].sh_info = elf32_to_cpu(shdr[i].sh_info);
- shdr[i].sh_addralign = elf32_to_cpu(shdr[i].sh_addralign);
- shdr[i].sh_entsize = elf32_to_cpu(shdr[i].sh_entsize);
- }
-
-}
-
-static void read_strtabs(FILE *fp)
-{
- int i;
- for(i = 0; i < ehdr.e_shnum; i++) {
- if (shdr[i].sh_type != SHT_STRTAB) {
- continue;
- }
- strtab[i] = malloc(shdr[i].sh_size);
- if (!strtab[i]) {
- die("malloc of %d bytes for strtab failed\n",
- shdr[i].sh_size);
- }
- if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
- die("Seek to %d failed: %s\n",
- shdr[i].sh_offset, strerror(errno));
- }
- if (fread(strtab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
- die("Cannot read symbol table: %s\n",
- strerror(errno));
- }
- }
-}
-
-static void read_symtabs(FILE *fp)
-{
- int i,j;
- for(i = 0; i < ehdr.e_shnum; i++) {
- if (shdr[i].sh_type != SHT_SYMTAB) {
- continue;
- }
- symtab[i] = malloc(shdr[i].sh_size);
- if (!symtab[i]) {
- die("malloc of %d bytes for symtab failed\n",
- shdr[i].sh_size);
- }
- if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
- die("Seek to %d failed: %s\n",
- shdr[i].sh_offset, strerror(errno));
- }
- if (fread(symtab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
- die("Cannot read symbol table: %s\n",
- strerror(errno));
- }
- for(j = 0; j < shdr[i].sh_size/sizeof(symtab[i][0]); j++) {
- symtab[i][j].st_name = elf32_to_cpu(symtab[i][j].st_name);
- symtab[i][j].st_value = elf32_to_cpu(symtab[i][j].st_value);
- symtab[i][j].st_size = elf32_to_cpu(symtab[i][j].st_size);
- symtab[i][j].st_shndx = elf16_to_cpu(symtab[i][j].st_shndx);
- }
- }
-}
-
-
-static void read_relocs(FILE *fp)
-{
- int i,j;
- for(i = 0; i < ehdr.e_shnum; i++) {
- if (shdr[i].sh_type != SHT_REL) {
- continue;
- }
- reltab[i] = malloc(shdr[i].sh_size);
- if (!reltab[i]) {
- die("malloc of %d bytes for relocs failed\n",
- shdr[i].sh_size);
- }
- if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
- die("Seek to %d failed: %s\n",
- shdr[i].sh_offset, strerror(errno));
- }
- if (fread(reltab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
- die("Cannot read symbol table: %s\n",
- strerror(errno));
- }
- for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
- reltab[i][j].r_offset = elf32_to_cpu(reltab[i][j].r_offset);
- reltab[i][j].r_info = elf32_to_cpu(reltab[i][j].r_info);
- }
- }
-}
-
-
-static void print_absolute_symbols(void)
-{
- int i;
- printf("Absolute symbols\n");
- printf(" Num: Value Size Type Bind Visibility Name\n");
- for(i = 0; i < ehdr.e_shnum; i++) {
- char *sym_strtab;
- Elf32_Sym *sh_symtab;
- int j;
- if (shdr[i].sh_type != SHT_SYMTAB) {
- continue;
- }
- sh_symtab = symtab[i];
- sym_strtab = strtab[shdr[i].sh_link];
- for(j = 0; j < shdr[i].sh_size/sizeof(symtab[0][0]); j++) {
- Elf32_Sym *sym;
- const char *name;
- sym = &symtab[i][j];
- name = sym_name(sym_strtab, sym);
- if (sym->st_shndx != SHN_ABS) {
- continue;
- }
- printf("%5d %08x %5d %10s %10s %12s %s\n",
- j, sym->st_value, sym->st_size,
- sym_type(ELF32_ST_TYPE(sym->st_info)),
- sym_bind(ELF32_ST_BIND(sym->st_info)),
- sym_visibility(ELF32_ST_VISIBILITY(sym->st_other)),
- name);
- }
- }
- printf("\n");
-}
-
-static void print_absolute_relocs(void)
-{
- int i, printed = 0;
-
- for(i = 0; i < ehdr.e_shnum; i++) {
- char *sym_strtab;
- Elf32_Sym *sh_symtab;
- unsigned sec_applies, sec_symtab;
- int j;
- if (shdr[i].sh_type != SHT_REL) {
- continue;
- }
- sec_symtab = shdr[i].sh_link;
- sec_applies = shdr[i].sh_info;
- if (!(shdr[sec_applies].sh_flags & SHF_ALLOC)) {
- continue;
- }
- sh_symtab = symtab[sec_symtab];
- sym_strtab = strtab[shdr[sec_symtab].sh_link];
- for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
- Elf32_Rel *rel;
- Elf32_Sym *sym;
- const char *name;
- rel = &reltab[i][j];
- sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
- name = sym_name(sym_strtab, sym);
- if (sym->st_shndx != SHN_ABS) {
- continue;
- }
-
- /* Absolute symbols are not relocated if bzImage is
- * loaded at a non-compiled address. Display a warning
- * to user at compile time about the absolute
- * relocations present.
- *
- * User need to audit the code to make sure
- * some symbols which should have been section
- * relative have not become absolute because of some
- * linker optimization or wrong programming usage.
- *
- * Before warning check if this absolute symbol
- * relocation is harmless.
- */
- if (is_safe_abs_reloc(name))
- continue;
-
- if (!printed) {
- printf("WARNING: Absolute relocations"
- " present\n");
- printf("Offset Info Type Sym.Value "
- "Sym.Name\n");
- printed = 1;
- }
-
- printf("%08x %08x %10s %08x %s\n",
- rel->r_offset,
- rel->r_info,
- rel_type(ELF32_R_TYPE(rel->r_info)),
- sym->st_value,
- name);
- }
- }
-
- if (printed)
- printf("\n");
-}
-
-static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
-{
- int i;
- /* Walk through the relocations */
- for(i = 0; i < ehdr.e_shnum; i++) {
- char *sym_strtab;
- Elf32_Sym *sh_symtab;
- unsigned sec_applies, sec_symtab;
- int j;
- if (shdr[i].sh_type != SHT_REL) {
- continue;
- }
- sec_symtab = shdr[i].sh_link;
- sec_applies = shdr[i].sh_info;
- if (!(shdr[sec_applies].sh_flags & SHF_ALLOC)) {
- continue;
- }
- sh_symtab = symtab[sec_symtab];
- sym_strtab = strtab[shdr[sec_symtab].sh_link];
- for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
- Elf32_Rel *rel;
- Elf32_Sym *sym;
- unsigned r_type;
- rel = &reltab[i][j];
- sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
- r_type = ELF32_R_TYPE(rel->r_info);
- /* Don't visit relocations to absolute symbols */
- if (sym->st_shndx == SHN_ABS) {
- continue;
- }
- if (r_type == R_386_PC32) {
- /* PC relative relocations don't need to be adjusted */
- }
- else if (r_type == R_386_32) {
- /* Visit relocations that need to be adjusted */
- visit(rel, sym);
- }
- else {
- die("Unsupported relocation type: %d\n", r_type);
- }
- }
- }
-}
-
-static void count_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
-{
- reloc_count += 1;
-}
-
-static void collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
-{
- /* Remember the address that needs to be adjusted. */
- relocs[reloc_idx++] = rel->r_offset;
-}
-
-static int cmp_relocs(const void *va, const void *vb)
-{
- const unsigned long *a, *b;
- a = va; b = vb;
- return (*a == *b)? 0 : (*a > *b)? 1 : -1;
-}
-
-static void emit_relocs(int as_text)
-{
- int i;
- /* Count how many relocations I have and allocate space for them. */
- reloc_count = 0;
- walk_relocs(count_reloc);
- relocs = malloc(reloc_count * sizeof(relocs[0]));
- if (!relocs) {
- die("malloc of %d entries for relocs failed\n",
- reloc_count);
- }
- /* Collect up the relocations */
- reloc_idx = 0;
- walk_relocs(collect_reloc);
-
- /* Order the relocations for more efficient processing */
- qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
-
- /* Print the relocations */
- if (as_text) {
- /* Print the relocations in a form suitable that
- * gas will like.
- */
- printf(".section \".data.reloc\",\"a\"\n");
- printf(".balign 4\n");
- for(i = 0; i < reloc_count; i++) {
- printf("\t .long 0x%08lx\n", relocs[i]);
- }
- printf("\n");
- }
- else {
- unsigned char buf[4];
- buf[0] = buf[1] = buf[2] = buf[3] = 0;
- /* Print a stop */
- printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
- /* Now print each relocation */
- for(i = 0; i < reloc_count; i++) {
- buf[0] = (relocs[i] >> 0) & 0xff;
- buf[1] = (relocs[i] >> 8) & 0xff;
- buf[2] = (relocs[i] >> 16) & 0xff;
- buf[3] = (relocs[i] >> 24) & 0xff;
- printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
- }
- }
-}
-
-static void usage(void)
-{
- die("relocs [--abs-syms |--abs-relocs | --text] vmlinux\n");
-}
-
-int main(int argc, char **argv)
-{
- int show_absolute_syms, show_absolute_relocs;
- int as_text;
- const char *fname;
- FILE *fp;
- int i;
-
- show_absolute_syms = 0;
- show_absolute_relocs = 0;
- as_text = 0;
- fname = NULL;
- for(i = 1; i < argc; i++) {
- char *arg = argv[i];
- if (*arg == '-') {
- if (strcmp(argv[1], "--abs-syms") == 0) {
- show_absolute_syms = 1;
- continue;
- }
-
- if (strcmp(argv[1], "--abs-relocs") == 0) {
- show_absolute_relocs = 1;
- continue;
- }
- else if (strcmp(argv[1], "--text") == 0) {
- as_text = 1;
- continue;
- }
- }
- else if (!fname) {
- fname = arg;
- continue;
- }
- usage();
- }
- if (!fname) {
- usage();
- }
- fp = fopen(fname, "r");
- if (!fp) {
- die("Cannot open %s: %s\n",
- fname, strerror(errno));
- }
- read_ehdr(fp);
- read_shdrs(fp);
- read_strtabs(fp);
- read_symtabs(fp);
- read_relocs(fp);
- if (show_absolute_syms) {
- print_absolute_symbols();
- return 0;
- }
- if (show_absolute_relocs) {
- print_absolute_relocs();
- return 0;
- }
- emit_relocs(as_text);
- return 0;
-}
diff --git a/arch/i386/boot/compressed/vmlinux.lds b/arch/i386/boot/compressed/vmlinux.lds
deleted file mode 100644
index cc4854f6c6c1..000000000000
--- a/arch/i386/boot/compressed/vmlinux.lds
+++ /dev/null
@@ -1,43 +0,0 @@
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-ENTRY(startup_32)
-SECTIONS
-{
- /* Be careful parts of head.S assume startup_32 is at
- * address 0.
- */
- . = 0 ;
- .text.head : {
- _head = . ;
- *(.text.head)
- _ehead = . ;
- }
- .data.compressed : {
- *(.data.compressed)
- }
- .text : {
- _text = .; /* Text */
- *(.text)
- *(.text.*)
- _etext = . ;
- }
- .rodata : {
- _rodata = . ;
- *(.rodata) /* read-only data */
- *(.rodata.*)
- _erodata = . ;
- }
- .data : {
- _data = . ;
- *(.data)
- *(.data.*)
- _edata = . ;
- }
- .bss : {
- _bss = . ;
- *(.bss)
- *(.bss.*)
- *(COMMON)
- _end = . ;
- }
-}
diff --git a/arch/i386/boot/compressed/vmlinux.scr b/arch/i386/boot/compressed/vmlinux.scr
deleted file mode 100644
index 707a88f7f29e..000000000000
--- a/arch/i386/boot/compressed/vmlinux.scr
+++ /dev/null
@@ -1,10 +0,0 @@
-SECTIONS
-{
- .data.compressed : {
- input_len = .;
- LONG(input_data_end - input_data) input_data = .;
- *(.data)
- output_len = . - 4;
- input_data_end = .;
- }
-}
diff --git a/arch/i386/boot/copy.S b/arch/i386/boot/copy.S
deleted file mode 100644
index ef127e56a3cf..000000000000
--- a/arch/i386/boot/copy.S
+++ /dev/null
@@ -1,101 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/copy.S
- *
- * Memory copy routines
- */
-
- .code16gcc
- .text
-
- .globl memcpy
- .type memcpy, @function
-memcpy:
- pushw %si
- pushw %di
- movw %ax, %di
- movw %dx, %si
- pushw %cx
- shrw $2, %cx
- rep; movsl
- popw %cx
- andw $3, %cx
- rep; movsb
- popw %di
- popw %si
- ret
- .size memcpy, .-memcpy
-
- .globl memset
- .type memset, @function
-memset:
- pushw %di
- movw %ax, %di
- movzbl %dl, %eax
- imull $0x01010101,%eax
- pushw %cx
- shrw $2, %cx
- rep; stosl
- popw %cx
- andw $3, %cx
- rep; stosb
- popw %di
- ret
- .size memset, .-memset
-
- .globl copy_from_fs
- .type copy_from_fs, @function
-copy_from_fs:
- pushw %ds
- pushw %fs
- popw %ds
- call memcpy
- popw %ds
- ret
- .size copy_from_fs, .-copy_from_fs
-
- .globl copy_to_fs
- .type copy_to_fs, @function
-copy_to_fs:
- pushw %es
- pushw %fs
- popw %es
- call memcpy
- popw %es
- ret
- .size copy_to_fs, .-copy_to_fs
-
-#if 0 /* Not currently used, but can be enabled as needed */
-
- .globl copy_from_gs
- .type copy_from_gs, @function
-copy_from_gs:
- pushw %ds
- pushw %gs
- popw %ds
- call memcpy
- popw %ds
- ret
- .size copy_from_gs, .-copy_from_gs
- .globl copy_to_gs
-
- .type copy_to_gs, @function
-copy_to_gs:
- pushw %es
- pushw %gs
- popw %es
- call memcpy
- popw %es
- ret
- .size copy_to_gs, .-copy_to_gs
-
-#endif
diff --git a/arch/i386/boot/cpu.c b/arch/i386/boot/cpu.c
deleted file mode 100644
index 2a5c32da5852..000000000000
--- a/arch/i386/boot/cpu.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/cpu.c
- *
- * Check for obligatory CPU features and abort if the features are not
- * present.
- */
-
-#include "boot.h"
-#include "bitops.h"
-#include <asm/cpufeature.h>
-
-static char *cpu_name(int level)
-{
- static char buf[6];
-
- if (level == 64) {
- return "x86-64";
- } else {
- sprintf(buf, "i%d86", level);
- return buf;
- }
-}
-
-int validate_cpu(void)
-{
- u32 *err_flags;
- int cpu_level, req_level;
-
- check_cpu(&cpu_level, &req_level, &err_flags);
-
- if (cpu_level < req_level) {
- printf("This kernel requires an %s CPU, ",
- cpu_name(req_level));
- printf("but only detected an %s CPU.\n",
- cpu_name(cpu_level));
- return -1;
- }
-
- if (err_flags) {
- int i, j;
- puts("This kernel requires the following features "
- "not present on the CPU:\n");
-
- for (i = 0; i < NCAPINTS; i++) {
- u32 e = err_flags[i];
-
- for (j = 0; j < 32; j++) {
- if (e & 1)
- printf("%d:%d ", i, j);
-
- e >>= 1;
- }
- }
- putchar('\n');
- return -1;
- } else {
- return 0;
- }
-}
diff --git a/arch/i386/boot/cpucheck.c b/arch/i386/boot/cpucheck.c
deleted file mode 100644
index 8b0f4473b083..000000000000
--- a/arch/i386/boot/cpucheck.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/cpucheck.c
- *
- * Check for obligatory CPU features and abort if the features are not
- * present. This code should be compilable as 16-, 32- or 64-bit
- * code, so be very careful with types and inline assembly.
- *
- * This code should not contain any messages; that requires an
- * additional wrapper.
- *
- * As written, this code is not safe for inclusion into the kernel
- * proper (after FPU initialization, in particular).
- */
-
-#ifdef _SETUP
-# include "boot.h"
-# include "bitops.h"
-#endif
-#include <linux/types.h>
-#include <asm/cpufeature.h>
-#include <asm/processor-flags.h>
-#include <asm/required-features.h>
-#include <asm/msr-index.h>
-
-struct cpu_features {
- int level; /* Family, or 64 for x86-64 */
- int model;
- u32 flags[NCAPINTS];
-};
-
-static struct cpu_features cpu;
-static u32 cpu_vendor[3];
-static u32 err_flags[NCAPINTS];
-
-#ifdef CONFIG_X86_64
-static const int req_level = 64;
-#elif defined(CONFIG_X86_MINIMUM_CPU_FAMILY)
-static const int req_level = CONFIG_X86_MINIMUM_CPU_FAMILY;
-#else
-static const int req_level = 3;
-#endif
-
-static const u32 req_flags[NCAPINTS] =
-{
- REQUIRED_MASK0,
- REQUIRED_MASK1,
- REQUIRED_MASK2,
- REQUIRED_MASK3,
- REQUIRED_MASK4,
- REQUIRED_MASK5,
- REQUIRED_MASK6,
- REQUIRED_MASK7,
-};
-
-#define A32(a,b,c,d) (((d) << 24)+((c) << 16)+((b) << 8)+(a))
-
-static int is_amd(void)
-{
- return cpu_vendor[0] == A32('A','u','t','h') &&
- cpu_vendor[1] == A32('e','n','t','i') &&
- cpu_vendor[2] == A32('c','A','M','D');
-}
-
-static int is_centaur(void)
-{
- return cpu_vendor[0] == A32('C','e','n','t') &&
- cpu_vendor[1] == A32('a','u','r','H') &&
- cpu_vendor[2] == A32('a','u','l','s');
-}
-
-static int is_transmeta(void)
-{
- return cpu_vendor[0] == A32('G','e','n','u') &&
- cpu_vendor[1] == A32('i','n','e','T') &&
- cpu_vendor[2] == A32('M','x','8','6');
-}
-
-static int has_fpu(void)
-{
- u16 fcw = -1, fsw = -1;
- u32 cr0;
-
- asm("movl %%cr0,%0" : "=r" (cr0));
- if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
- cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
- asm volatile("movl %0,%%cr0" : : "r" (cr0));
- }
-
- asm("fninit ; fnstsw %0 ; fnstcw %1" : "+m" (fsw), "+m" (fcw));
-
- return fsw == 0 && (fcw & 0x103f) == 0x003f;
-}
-
-static int has_eflag(u32 mask)
-{
- u32 f0, f1;
-
- asm("pushfl ; "
- "pushfl ; "
- "popl %0 ; "
- "movl %0,%1 ; "
- "xorl %2,%1 ; "
- "pushl %1 ; "
- "popfl ; "
- "pushfl ; "
- "popl %1 ; "
- "popfl"
- : "=r" (f0), "=r" (f1)
- : "g" (mask));
-
- return !!((f0^f1) & mask);
-}
-
-static void get_flags(void)
-{
- u32 max_intel_level, max_amd_level;
- u32 tfms;
-
- if (has_fpu())
- set_bit(X86_FEATURE_FPU, cpu.flags);
-
- if (has_eflag(X86_EFLAGS_ID)) {
- asm("cpuid"
- : "=a" (max_intel_level),
- "=b" (cpu_vendor[0]),
- "=d" (cpu_vendor[1]),
- "=c" (cpu_vendor[2])
- : "a" (0));
-
- if (max_intel_level >= 0x00000001 &&
- max_intel_level <= 0x0000ffff) {
- asm("cpuid"
- : "=a" (tfms),
- "=c" (cpu.flags[4]),
- "=d" (cpu.flags[0])
- : "a" (0x00000001)
- : "ebx");
- cpu.level = (tfms >> 8) & 15;
- cpu.model = (tfms >> 4) & 15;
- if (cpu.level >= 6)
- cpu.model += ((tfms >> 16) & 0xf) << 4;
- }
-
- asm("cpuid"
- : "=a" (max_amd_level)
- : "a" (0x80000000)
- : "ebx", "ecx", "edx");
-
- if (max_amd_level >= 0x80000001 &&
- max_amd_level <= 0x8000ffff) {
- u32 eax = 0x80000001;
- asm("cpuid"
- : "+a" (eax),
- "=c" (cpu.flags[6]),
- "=d" (cpu.flags[1])
- : : "ebx");
- }
- }
-}
-
-/* Returns a bitmask of which words we have error bits in */
-static int check_flags(void)
-{
- u32 err;
- int i;
-
- err = 0;
- for (i = 0; i < NCAPINTS; i++) {
- err_flags[i] = req_flags[i] & ~cpu.flags[i];
- if (err_flags[i])
- err |= 1 << i;
- }
-
- return err;
-}
-
-/*
- * Returns -1 on error.
- *
- * *cpu_level is set to the current CPU level; *req_level to the required
- * level. x86-64 is considered level 64 for this purpose.
- *
- * *err_flags_ptr is set to the flags error array if there are flags missing.
- */
-int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
-{
- int err;
-
- memset(&cpu.flags, 0, sizeof cpu.flags);
- cpu.level = 3;
-
- if (has_eflag(X86_EFLAGS_AC))
- cpu.level = 4;
-
- get_flags();
- err = check_flags();
-
- if (test_bit(X86_FEATURE_LM, cpu.flags))
- cpu.level = 64;
-
- if (err == 0x01 &&
- !(err_flags[0] &
- ~((1 << X86_FEATURE_XMM)|(1 << X86_FEATURE_XMM2))) &&
- is_amd()) {
- /* If this is an AMD and we're only missing SSE+SSE2, try to
- turn them on */
-
- u32 ecx = MSR_K7_HWCR;
- u32 eax, edx;
-
- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
- eax &= ~(1 << 15);
- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
-
- get_flags(); /* Make sure it really did something */
- err = check_flags();
- } else if (err == 0x01 &&
- !(err_flags[0] & ~(1 << X86_FEATURE_CX8)) &&
- is_centaur() && cpu.model >= 6) {
- /* If this is a VIA C3, we might have to enable CX8
- explicitly */
-
- u32 ecx = MSR_VIA_FCR;
- u32 eax, edx;
-
- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
- eax |= (1<<1)|(1<<7);
- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
-
- set_bit(X86_FEATURE_CX8, cpu.flags);
- err = check_flags();
- } else if (err == 0x01 && is_transmeta()) {
- /* Transmeta might have masked feature bits in word 0 */
-
- u32 ecx = 0x80860004;
- u32 eax, edx;
- u32 level = 1;
-
- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
- asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
- asm("cpuid"
- : "+a" (level), "=d" (cpu.flags[0])
- : : "ecx", "ebx");
- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
-
- err = check_flags();
- }
-
- if (err_flags_ptr)
- *err_flags_ptr = err ? err_flags : NULL;
- if (cpu_level_ptr)
- *cpu_level_ptr = cpu.level;
- if (req_level_ptr)
- *req_level_ptr = req_level;
-
- return (cpu.level < req_level || err) ? -1 : 0;
-}
diff --git a/arch/i386/boot/edd.c b/arch/i386/boot/edd.c
deleted file mode 100644
index 25a282494f4c..000000000000
--- a/arch/i386/boot/edd.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/edd.c
- *
- * Get EDD BIOS disk information
- */
-
-#include "boot.h"
-#include <linux/edd.h>
-
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
-
-struct edd_dapa {
- u8 pkt_size;
- u8 rsvd;
- u16 sector_cnt;
- u16 buf_off, buf_seg;
- u64 lba;
- u64 buf_lin_addr;
-};
-
-/*
- * Read the MBR (first sector) from a specific device.
- */
-static int read_mbr(u8 devno, void *buf)
-{
- struct edd_dapa dapa;
- u16 ax, bx, cx, dx, si;
-
- memset(&dapa, 0, sizeof dapa);
- dapa.pkt_size = sizeof(dapa);
- dapa.sector_cnt = 1;
- dapa.buf_off = (size_t)buf;
- dapa.buf_seg = ds();
- /* dapa.lba = 0; */
-
- ax = 0x4200; /* Extended Read */
- si = (size_t)&dapa;
- dx = devno;
- asm("pushfl; stc; int $0x13; setc %%al; popfl"
- : "+a" (ax), "+S" (si), "+d" (dx)
- : "m" (dapa)
- : "ebx", "ecx", "edi", "memory");
-
- if (!(u8)ax)
- return 0; /* OK */
-
- ax = 0x0201; /* Legacy Read, one sector */
- cx = 0x0001; /* Sector 0-0-1 */
- dx = devno;
- bx = (size_t)buf;
- asm("pushfl; stc; int $0x13; setc %%al; popfl"
- : "+a" (ax), "+c" (cx), "+d" (dx), "+b" (bx)
- : : "esi", "edi", "memory");
-
- return -(u8)ax; /* 0 or -1 */
-}
-
-static u32 read_mbr_sig(u8 devno, struct edd_info *ei)
-{
- int sector_size;
- char *mbrbuf_ptr, *mbrbuf_end;
- u32 mbrsig;
- u32 buf_base, mbr_base;
- extern char _end[];
- static char mbr_buf[1024];
-
- sector_size = ei->params.bytes_per_sector;
- if (!sector_size)
- sector_size = 512; /* Best available guess */
-
- buf_base = (ds() << 4) + (u32)&_end;
- mbr_base = (buf_base+sector_size-1) & ~(sector_size-1);
- mbrbuf_ptr = mbr_buf + (mbr_base-buf_base);
- mbrbuf_end = mbrbuf_ptr + sector_size;
-
- if (!(boot_params.hdr.loadflags & CAN_USE_HEAP))
- return 0;
- if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr)
- return 0;
-
- if (read_mbr(devno, mbrbuf_ptr))
- return 0;
-
- mbrsig = *(u32 *)&mbrbuf_ptr[EDD_MBR_SIG_OFFSET];
- return mbrsig;
-}
-
-static int get_edd_info(u8 devno, struct edd_info *ei)
-{
- u16 ax, bx, cx, dx, di;
-
- memset(ei, 0, sizeof *ei);
-
- /* Check Extensions Present */
-
- ax = 0x4100;
- bx = EDDMAGIC1;
- dx = devno;
- asm("pushfl; stc; int $0x13; setc %%al; popfl"
- : "+a" (ax), "+b" (bx), "=c" (cx), "+d" (dx)
- : : "esi", "edi");
-
- if ((u8)ax)
- return -1; /* No extended information */
-
- if (bx != EDDMAGIC2)
- return -1;
-
- ei->device = devno;
- ei->version = ax >> 8; /* EDD version number */
- ei->interface_support = cx; /* EDD functionality subsets */
-
- /* Extended Get Device Parameters */
-
- ei->params.length = sizeof(ei->params);
- ax = 0x4800;
- dx = devno;
- asm("pushfl; int $0x13; popfl"
- : "+a" (ax), "+d" (dx)
- : "S" (&ei->params)
- : "ebx", "ecx", "edi");
-
- /* Get legacy CHS parameters */
-
- /* Ralf Brown recommends setting ES:DI to 0:0 */
- ax = 0x0800;
- dx = devno;
- di = 0;
- asm("pushw %%es; "
- "movw %%di,%%es; "
- "pushfl; stc; int $0x13; setc %%al; popfl; "
- "popw %%es"
- : "+a" (ax), "=b" (bx), "=c" (cx), "+d" (dx), "+D" (di)
- : : "esi");
-
- if ((u8)ax == 0) {
- ei->legacy_max_cylinder = (cx >> 8) + ((cx & 0xc0) << 2);
- ei->legacy_max_head = dx >> 8;
- ei->legacy_sectors_per_track = cx & 0x3f;
- }
-
- return 0;
-}
-
-void query_edd(void)
-{
- char eddarg[8];
- int do_mbr = 1;
- int do_edd = 1;
- int devno;
- struct edd_info ei, *edp;
-
- if (cmdline_find_option("edd", eddarg, sizeof eddarg) > 0) {
- if (!strcmp(eddarg, "skipmbr") || !strcmp(eddarg, "skip"))
- do_mbr = 0;
- else if (!strcmp(eddarg, "off"))
- do_edd = 0;
- }
-
- edp = (struct edd_info *)boot_params.eddbuf;
-
- if (!do_edd)
- return;
-
- for (devno = 0x80; devno < 0x80+EDD_MBR_SIG_MAX; devno++) {
- /*
- * Scan the BIOS-supported hard disks and query EDD
- * information...
- */
- get_edd_info(devno, &ei);
-
- if (boot_params.eddbuf_entries < EDDMAXNR) {
- memcpy(edp, &ei, sizeof ei);
- edp++;
- boot_params.eddbuf_entries++;
- }
-
- if (do_mbr) {
- u32 mbr_sig;
- mbr_sig = read_mbr_sig(devno, &ei);
- boot_params.edd_mbr_sig_buffer[devno-0x80] = mbr_sig;
- }
- }
-}
-
-#endif
diff --git a/arch/i386/boot/header.S b/arch/i386/boot/header.S
deleted file mode 100644
index 6b9923fb6eae..000000000000
--- a/arch/i386/boot/header.S
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * header.S
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- *
- * Based on bootsect.S and setup.S
- * modified by more people than can be counted
- *
- * Rewritten as a common file by H. Peter Anvin (Apr 2007)
- *
- * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
- * addresses must be multiplied by 16 to obtain their respective linear
- * addresses. To avoid confusion, linear addresses are written using leading
- * hex while segment addresses are written as segment:offset.
- *
- */
-
-#include <asm/segment.h>
-#include <linux/utsrelease.h>
-#include <asm/boot.h>
-#include <asm/e820.h>
-#include <asm/page.h>
-#include <asm/setup.h>
-#include "boot.h"
-
-SETUPSECTS = 4 /* default nr of setup-sectors */
-BOOTSEG = 0x07C0 /* original address of boot-sector */
-SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
-SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
- /* to be loaded */
-ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
-SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
-
-#ifndef SVGA_MODE
-#define SVGA_MODE ASK_VGA
-#endif
-
-#ifndef RAMDISK
-#define RAMDISK 0
-#endif
-
-#ifndef ROOT_RDONLY
-#define ROOT_RDONLY 1
-#endif
-
- .code16
- .section ".bstext", "ax"
-
- .global bootsect_start
-bootsect_start:
-
- # Normalize the start address
- ljmp $BOOTSEG, $start2
-
-start2:
- movw %cs, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %ss
- xorw %sp, %sp
- sti
- cld
-
- movw $bugger_off_msg, %si
-
-msg_loop:
- lodsb
- andb %al, %al
- jz bs_die
- movb $0xe, %ah
- movw $7, %bx
- int $0x10
- jmp msg_loop
-
-bs_die:
- # Allow the user to press a key, then reboot
- xorw %ax, %ax
- int $0x16
- int $0x19
-
- # int 0x19 should never return. In case it does anyway,
- # invoke the BIOS reset code...
- ljmp $0xf000,$0xfff0
-
- .section ".bsdata", "a"
-bugger_off_msg:
- .ascii "Direct booting from floppy is no longer supported.\r\n"
- .ascii "Please use a boot loader program instead.\r\n"
- .ascii "\n"
- .ascii "Remove disk and press any key to reboot . . .\r\n"
- .byte 0
-
-
- # Kernel attributes; used by setup. This is part 1 of the
- # header, from the old boot sector.
-
- .section ".header", "a"
- .globl hdr
-hdr:
-setup_sects: .byte SETUPSECTS
-root_flags: .word ROOT_RDONLY
-syssize: .long SYSSIZE
-ram_size: .word RAMDISK
-vid_mode: .word SVGA_MODE
-root_dev: .word ROOT_DEV
-boot_flag: .word 0xAA55
-
- # offset 512, entry point
-
- .globl _start
-_start:
- # Explicitly enter this as bytes, or the assembler
- # tries to generate a 3-byte jump here, which causes
- # everything else to push off to the wrong offset.
- .byte 0xeb # short (2-byte) jump
- .byte start_of_setup-1f
-1:
-
- # Part 2 of the header, from the old setup.S
-
- .ascii "HdrS" # header signature
- .word 0x0206 # header version number (>= 0x0105)
- # or else old loadlin-1.5 will fail)
- .globl realmode_swtch
-realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
-start_sys_seg: .word SYSSEG
- .word kernel_version-512 # pointing to kernel version string
- # above section of header is compatible
- # with loadlin-1.5 (header v1.5). Don't
- # change it.
-
-type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
- # Bootlin, SYSLX, bootsect...)
- # See Documentation/i386/boot.txt for
- # assigned ids
-
-# flags, unused bits must be zero (RFU) bit within loadflags
-loadflags:
-LOADED_HIGH = 1 # If set, the kernel is loaded high
-CAN_USE_HEAP = 0x80 # If set, the loader also has set
- # heap_end_ptr to tell how much
- # space behind setup.S can be used for
- # heap purposes.
- # Only the loader knows what is free
-#ifndef __BIG_KERNEL__
- .byte 0
-#else
- .byte LOADED_HIGH
-#endif
-
-setup_move_size: .word 0x8000 # size to move, when setup is not
- # loaded at 0x90000. We will move setup
- # to 0x90000 then just before jumping
- # into the kernel. However, only the
- # loader knows how much data behind
- # us also needs to be loaded.
-
-code32_start: # here loaders can put a different
- # start address for 32-bit code.
-#ifndef __BIG_KERNEL__
- .long 0x1000 # 0x1000 = default for zImage
-#else
- .long 0x100000 # 0x100000 = default for big kernel
-#endif
-
-ramdisk_image: .long 0 # address of loaded ramdisk image
- # Here the loader puts the 32-bit
- # address where it loaded the image.
- # This only will be read by the kernel.
-
-ramdisk_size: .long 0 # its size in bytes
-
-bootsect_kludge:
- .long 0 # obsolete
-
-heap_end_ptr: .word _end+1024 # (Header version 0x0201 or later)
- # space from here (exclusive) down to
- # end of setup code can be used by setup
- # for local heap purposes.
-
-pad1: .word 0
-cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
- # If nonzero, a 32-bit pointer
- # to the kernel command line.
- # The command line should be
- # located between the start of
- # setup and the end of low
- # memory (0xa0000), or it may
- # get overwritten before it
- # gets read. If this field is
- # used, there is no longer
- # anything magical about the
- # 0x90000 segment; the setup
- # can be located anywhere in
- # low memory 0x10000 or higher.
-
-ramdisk_max: .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
- # (Header version 0x0203 or later)
- # The highest safe address for
- # the contents of an initrd
-
-kernel_alignment: .long CONFIG_PHYSICAL_ALIGN #physical addr alignment
- #required for protected mode
- #kernel
-#ifdef CONFIG_RELOCATABLE
-relocatable_kernel: .byte 1
-#else
-relocatable_kernel: .byte 0
-#endif
-pad2: .byte 0
-pad3: .word 0
-
-cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
- #added with boot protocol
- #version 2.06
-
-# End of setup header #####################################################
-
- .section ".inittext", "ax"
-start_of_setup:
-#ifdef SAFE_RESET_DISK_CONTROLLER
-# Reset the disk controller.
- movw $0x0000, %ax # Reset disk controller
- movb $0x80, %dl # All disks
- int $0x13
-#endif
-
-# We will have entired with %cs = %ds+0x20, normalize %cs so
-# it is on par with the other segments.
- pushw %ds
- pushw $setup2
- lretw
-
-setup2:
-# Force %es = %ds
- movw %ds, %ax
- movw %ax, %es
- cld
-
-# Stack paranoia: align the stack and make sure it is good
-# for both 16- and 32-bit references. In particular, if we
-# were meant to have been using the full 16-bit segment, the
-# caller might have set %sp to zero, which breaks %esp-based
-# references.
- andw $~3, %sp # dword align (might as well...)
- jnz 1f
- movw $0xfffc, %sp # Make sure we're not zero
-1: movzwl %sp, %esp # Clear upper half of %esp
- sti
-
-# Check signature at end of setup
- cmpl $0x5a5aaa55, setup_sig
- jne setup_bad
-
-# Zero the bss
- movw $__bss_start, %di
- movw $_end+3, %cx
- xorl %eax, %eax
- subw %di, %cx
- shrw $2, %cx
- rep; stosl
-
-# Jump to C code (should not return)
- calll main
-
-# Setup corrupt somehow...
-setup_bad:
- movl $setup_corrupt, %eax
- calll puts
- # Fall through...
-
- .globl die
- .type die, @function
-die:
- hlt
- jmp die
-
- .size die, .-due
-
- .section ".initdata", "a"
-setup_corrupt:
- .byte 7
- .string "No setup signature found..."
diff --git a/arch/i386/boot/install.sh b/arch/i386/boot/install.sh
deleted file mode 100644
index 5e44c736eea8..000000000000
--- a/arch/i386/boot/install.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-#
-# arch/i386/boot/install.sh
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License. See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-#
-# "make install" script for i386 architecture
-#
-# Arguments:
-# $1 - kernel version
-# $2 - kernel image file
-# $3 - kernel map file
-# $4 - default install path (blank if root directory)
-#
-
-verify () {
- if [ ! -f "$1" ]; then
- echo "" 1>&2
- echo " *** Missing file: $1" 1>&2
- echo ' *** You need to run "make" before "make install".' 1>&2
- echo "" 1>&2
- exit 1
- fi
-}
-
-# Make sure the files actually exist
-verify "$2"
-verify "$3"
-
-# User may have a custom install script
-
-if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
-if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi
-
-# Default install - same as make zlilo
-
-if [ -f $4/vmlinuz ]; then
- mv $4/vmlinuz $4/vmlinuz.old
-fi
-
-if [ -f $4/System.map ]; then
- mv $4/System.map $4/System.old
-fi
-
-cat $2 > $4/vmlinuz
-cp $3 $4/System.map
-
-if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
diff --git a/arch/i386/boot/main.c b/arch/i386/boot/main.c
deleted file mode 100644
index 7f01f96c4fb8..000000000000
--- a/arch/i386/boot/main.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/main.c
- *
- * Main module for the real-mode kernel code
- */
-
-#include "boot.h"
-
-struct boot_params boot_params __attribute__((aligned(16)));
-
-char *HEAP = _end;
-char *heap_end = _end; /* Default end of heap = no heap */
-
-/*
- * Copy the header into the boot parameter block. Since this
- * screws up the old-style command line protocol, adjust by
- * filling in the new-style command line pointer instead.
- */
-#define OLD_CL_MAGIC 0xA33F
-#define OLD_CL_ADDRESS 0x20
-
-static void copy_boot_params(void)
-{
- struct old_cmdline {
- u16 cl_magic;
- u16 cl_offset;
- };
- const struct old_cmdline * const oldcmd =
- (const struct old_cmdline *)OLD_CL_ADDRESS;
-
- BUILD_BUG_ON(sizeof boot_params != 4096);
- memcpy(&boot_params.hdr, &hdr, sizeof hdr);
-
- if (!boot_params.hdr.cmd_line_ptr &&
- oldcmd->cl_magic == OLD_CL_MAGIC) {
- /* Old-style command line protocol. */
- u16 cmdline_seg;
-
- /* Figure out if the command line falls in the region
- of memory that an old kernel would have copied up
- to 0x90000... */
- if (oldcmd->cl_offset < boot_params.hdr.setup_move_size)
- cmdline_seg = ds();
- else
- cmdline_seg = 0x9000;
-
- boot_params.hdr.cmd_line_ptr =
- (cmdline_seg << 4) + oldcmd->cl_offset;
- }
-}
-
-/*
- * Set the keyboard repeat rate to maximum. Unclear why this
- * is done here; this might be possible to kill off as stale code.
- */
-static void keyboard_set_repeat(void)
-{
- u16 ax = 0x0305;
- u16 bx = 0;
- asm volatile("int $0x16"
- : "+a" (ax), "+b" (bx)
- : : "ecx", "edx", "esi", "edi");
-}
-
-/*
- * Get Intel SpeedStep IST information.
- */
-static void query_speedstep_ist(void)
-{
- asm("int $0x15"
- : "=a" (boot_params.speedstep_info[0]),
- "=b" (boot_params.speedstep_info[1]),
- "=c" (boot_params.speedstep_info[2]),
- "=d" (boot_params.speedstep_info[3])
- : "a" (0x0000e980), /* IST Support */
- "d" (0x47534943)); /* Request value */
-}
-
-/*
- * Tell the BIOS what CPU mode we intend to run in.
- */
-static void set_bios_mode(void)
-{
-#ifdef CONFIG_X86_64
- u32 eax, ebx;
-
- eax = 0xec00;
- ebx = 2;
- asm volatile("int $0x15"
- : "+a" (eax), "+b" (ebx)
- : : "ecx", "edx", "esi", "edi");
-#endif
-}
-
-void main(void)
-{
- /* First, copy the boot header into the "zeropage" */
- copy_boot_params();
-
- /* End of heap check */
- if (boot_params.hdr.loadflags & CAN_USE_HEAP) {
- heap_end = (char *)(boot_params.hdr.heap_end_ptr
- +0x200-STACK_SIZE);
- } else {
- /* Boot protocol 2.00 only, no heap available */
- puts("WARNING: Ancient bootloader, some functionality "
- "may be limited!\n");
- }
-
- /* Make sure we have all the proper CPU support */
- if (validate_cpu()) {
- puts("Unable to boot - please use a kernel appropriate "
- "for your CPU.\n");
- die();
- }
-
- /* Tell the BIOS what CPU mode we intend to run in. */
- set_bios_mode();
-
- /* Detect memory layout */
- detect_memory();
-
- /* Set keyboard repeat rate (why?) */
- keyboard_set_repeat();
-
- /* Set the video mode */
- set_video();
-
- /* Query MCA information */
- query_mca();
-
- /* Voyager */
-#ifdef CONFIG_X86_VOYAGER
- query_voyager();
-#endif
-
- /* Query SpeedStep IST information */
- query_speedstep_ist();
-
- /* Query APM information */
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
- query_apm_bios();
-#endif
-
- /* Query EDD information */
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
- query_edd();
-#endif
- /* Do the last things and invoke protected mode */
- go_to_protected_mode();
-}
diff --git a/arch/i386/boot/mca.c b/arch/i386/boot/mca.c
deleted file mode 100644
index 9b68bd1aef19..000000000000
--- a/arch/i386/boot/mca.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/mca.c
- *
- * Get the MCA system description table
- */
-
-#include "boot.h"
-
-int query_mca(void)
-{
- u8 err;
- u16 es, bx, len;
-
- asm("pushw %%es ; "
- "int $0x15 ; "
- "setc %0 ; "
- "movw %%es, %1 ; "
- "popw %%es"
- : "=acdSDm" (err), "=acdSDm" (es), "=b" (bx)
- : "a" (0xc000));
-
- if (err)
- return -1; /* No MCA present */
-
- set_fs(es);
- len = rdfs16(bx);
-
- if (len > sizeof(boot_params.sys_desc_table))
- len = sizeof(boot_params.sys_desc_table);
-
- copy_from_fs(&boot_params.sys_desc_table, bx, len);
- return 0;
-}
diff --git a/arch/i386/boot/memory.c b/arch/i386/boot/memory.c
deleted file mode 100644
index 1a2e62db8bed..000000000000
--- a/arch/i386/boot/memory.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/memory.c
- *
- * Memory detection code
- */
-
-#include "boot.h"
-
-#define SMAP 0x534d4150 /* ASCII "SMAP" */
-
-static int detect_memory_e820(void)
-{
- u32 next = 0;
- u32 size, id;
- u8 err;
- struct e820entry *desc = boot_params.e820_map;
-
- do {
- size = sizeof(struct e820entry);
- id = SMAP;
- asm("int $0x15; setc %0"
- : "=am" (err), "+b" (next), "+d" (id), "+c" (size),
- "=m" (*desc)
- : "D" (desc), "a" (0xe820));
-
- if (err || id != SMAP)
- break;
-
- boot_params.e820_entries++;
- desc++;
- } while (next && boot_params.e820_entries < E820MAX);
-
- return boot_params.e820_entries;
-}
-
-static int detect_memory_e801(void)
-{
- u16 ax, bx, cx, dx;
- u8 err;
-
- bx = cx = dx = 0;
- ax = 0xe801;
- asm("stc; int $0x15; setc %0"
- : "=m" (err), "+a" (ax), "+b" (bx), "+c" (cx), "+d" (dx));
-
- if (err)
- return -1;
-
- /* Do we really need to do this? */
- if (cx || dx) {
- ax = cx;
- bx = dx;
- }
-
- if (ax > 15*1024)
- return -1; /* Bogus! */
-
- /* This ignores memory above 16MB if we have a memory hole
- there. If someone actually finds a machine with a memory
- hole at 16MB and no support for 0E820h they should probably
- generate a fake e820 map. */
- boot_params.alt_mem_k = (ax == 15*1024) ? (dx << 6)+ax : ax;
-
- return 0;
-}
-
-static int detect_memory_88(void)
-{
- u16 ax;
- u8 err;
-
- ax = 0x8800;
- asm("stc; int $0x15; setc %0" : "=bcdm" (err), "+a" (ax));
-
- boot_params.screen_info.ext_mem_k = ax;
-
- return -err;
-}
-
-int detect_memory(void)
-{
- if (detect_memory_e820() > 0)
- return 0;
-
- if (!detect_memory_e801())
- return 0;
-
- return detect_memory_88();
-}
diff --git a/arch/i386/boot/mtools.conf.in b/arch/i386/boot/mtools.conf.in
deleted file mode 100644
index efd6d2490c1d..000000000000
--- a/arch/i386/boot/mtools.conf.in
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# mtools configuration file for "make (b)zdisk"
-#
-
-# Actual floppy drive
-drive a:
- file="/dev/fd0"
-
-# 1.44 MB floppy disk image
-drive v:
- file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=18 filter
-
-# 2.88 MB floppy disk image (mostly for virtual uses)
-drive w:
- file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=36 filter
-
-
diff --git a/arch/i386/boot/pm.c b/arch/i386/boot/pm.c
deleted file mode 100644
index 3fa53e15ed77..000000000000
--- a/arch/i386/boot/pm.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/pm.c
- *
- * Prepare the machine for transition to protected mode.
- */
-
-#include "boot.h"
-#include <asm/segment.h>
-
-/*
- * Invoke the realmode switch hook if present; otherwise
- * disable all interrupts.
- */
-static void realmode_switch_hook(void)
-{
- if (boot_params.hdr.realmode_swtch) {
- asm volatile("lcallw *%0"
- : : "m" (boot_params.hdr.realmode_swtch)
- : "eax", "ebx", "ecx", "edx");
- } else {
- asm volatile("cli");
- outb(0x80, 0x70); /* Disable NMI */
- io_delay();
- }
-}
-
-/*
- * A zImage kernel is loaded at 0x10000 but wants to run at 0x1000.
- * A bzImage kernel is loaded and runs at 0x100000.
- */
-static void move_kernel_around(void)
-{
- /* Note: rely on the compile-time option here rather than
- the LOADED_HIGH flag. The Qemu kernel loader unconditionally
- sets the loadflags to zero. */
-#ifndef __BIG_KERNEL__
- u16 dst_seg, src_seg;
- u32 syssize;
-
- dst_seg = 0x1000 >> 4;
- src_seg = 0x10000 >> 4;
- syssize = boot_params.hdr.syssize; /* Size in 16-byte paragraphs */
-
- while (syssize) {
- int paras = (syssize >= 0x1000) ? 0x1000 : syssize;
- int dwords = paras << 2;
-
- asm volatile("pushw %%es ; "
- "pushw %%ds ; "
- "movw %1,%%es ; "
- "movw %2,%%ds ; "
- "xorw %%di,%%di ; "
- "xorw %%si,%%si ; "
- "rep;movsl ; "
- "popw %%ds ; "
- "popw %%es"
- : "+c" (dwords)
- : "rm" (dst_seg), "rm" (src_seg)
- : "esi", "edi");
-
- syssize -= paras;
- dst_seg += paras;
- src_seg += paras;
- }
-#endif
-}
-
-/*
- * Disable all interrupts at the legacy PIC.
- */
-static void mask_all_interrupts(void)
-{
- outb(0xff, 0xa1); /* Mask all interrupts on the seconday PIC */
- io_delay();
- outb(0xfb, 0x21); /* Mask all but cascade on the primary PIC */
- io_delay();
-}
-
-/*
- * Reset IGNNE# if asserted in the FPU.
- */
-static void reset_coprocessor(void)
-{
- outb(0, 0xf0);
- io_delay();
- outb(0, 0xf1);
- io_delay();
-}
-
-/*
- * Set up the GDT
- */
-#define GDT_ENTRY(flags,base,limit) \
- (((u64)(base & 0xff000000) << 32) | \
- ((u64)flags << 40) | \
- ((u64)(limit & 0x00ff0000) << 32) | \
- ((u64)(base & 0x00ffff00) << 16) | \
- ((u64)(limit & 0x0000ffff)))
-
-struct gdt_ptr {
- u16 len;
- u32 ptr;
-} __attribute__((packed));
-
-static void setup_gdt(void)
-{
- /* There are machines which are known to not boot with the GDT
- being 8-byte unaligned. Intel recommends 16 byte alignment. */
- static const u64 boot_gdt[] __attribute__((aligned(16))) = {
- /* 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),
- };
- struct gdt_ptr gdt;
-
- gdt.len = sizeof(boot_gdt)-1;
- gdt.ptr = (u32)&boot_gdt + (ds() << 4);
-
- asm volatile("lgdtl %0" : : "m" (gdt));
-}
-
-/*
- * Set up the IDT
- */
-static void setup_idt(void)
-{
- static const struct gdt_ptr null_idt = {0, 0};
- asm volatile("lidtl %0" : : "m" (null_idt));
-}
-
-/*
- * Actual invocation sequence
- */
-void go_to_protected_mode(void)
-{
- /* Hook before leaving real mode, also disables interrupts */
- realmode_switch_hook();
-
- /* Move the kernel/setup to their final resting places */
- move_kernel_around();
-
- /* Enable the A20 gate */
- if (enable_a20()) {
- puts("A20 gate not responding, unable to boot...\n");
- die();
- }
-
- /* Reset coprocessor (IGNNE#) */
- reset_coprocessor();
-
- /* Mask all interrupts in the PIC */
- mask_all_interrupts();
-
- /* Actual transition to protected mode... */
- setup_idt();
- setup_gdt();
- protected_mode_jump(boot_params.hdr.code32_start,
- (u32)&boot_params + (ds() << 4));
-}
diff --git a/arch/i386/boot/pmjump.S b/arch/i386/boot/pmjump.S
deleted file mode 100644
index 2e559233725a..000000000000
--- a/arch/i386/boot/pmjump.S
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/pmjump.S
- *
- * The actual transition into protected mode
- */
-
-#include <asm/boot.h>
-#include <asm/segment.h>
-
- .text
-
- .globl protected_mode_jump
- .type protected_mode_jump, @function
-
- .code16
-
-/*
- * void protected_mode_jump(u32 entrypoint, u32 bootparams);
- */
-protected_mode_jump:
- xorl %ebx, %ebx # Flag to indicate this is a boot
- movl %edx, %esi # Pointer to boot_params table
- movl %eax, 2f # Patch ljmpl instruction
- jmp 1f # Short jump to flush instruction q.
-
-1:
- movw $__BOOT_DS, %cx
-
- movl %cr0, %edx
- orb $1, %dl # Protected mode (PE) bit
- movl %edx, %cr0
-
- movw %cx, %ds
- movw %cx, %es
- movw %cx, %fs
- movw %cx, %gs
- movw %cx, %ss
-
- # Jump to the 32-bit entrypoint
- .byte 0x66, 0xea # ljmpl opcode
-2: .long 0 # offset
- .word __BOOT_CS # segment
-
- .size protected_mode_jump, .-protected_mode_jump
diff --git a/arch/i386/boot/printf.c b/arch/i386/boot/printf.c
deleted file mode 100644
index 1a09f9309d3c..000000000000
--- a/arch/i386/boot/printf.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/printf.c
- *
- * Oh, it's a waste of space, but oh-so-yummy for debugging. This
- * version of printf() does not include 64-bit support. "Live with
- * it."
- *
- */
-
-#include "boot.h"
-
-static int skip_atoi(const char **s)
-{
- int i = 0;
-
- while (isdigit(**s))
- i = i * 10 + *((*s)++) - '0';
- return i;
-}
-
-#define ZEROPAD 1 /* pad with zero */
-#define SIGN 2 /* unsigned/signed long */
-#define PLUS 4 /* show plus */
-#define SPACE 8 /* space if plus */
-#define LEFT 16 /* left justified */
-#define SPECIAL 32 /* 0x */
-#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
-
-#define do_div(n,base) ({ \
-int __res; \
-__res = ((unsigned long) n) % (unsigned) base; \
-n = ((unsigned long) n) / (unsigned) base; \
-__res; })
-
-static char *number(char *str, long num, int base, int size, int precision,
- int type)
-{
- char c, sign, tmp[66];
- const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz";
- int i;
-
- if (type & LARGE)
- digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- if (type & LEFT)
- type &= ~ZEROPAD;
- if (base < 2 || base > 36)
- return 0;
- c = (type & ZEROPAD) ? '0' : ' ';
- sign = 0;
- if (type & SIGN) {
- if (num < 0) {
- sign = '-';
- num = -num;
- size--;
- } else if (type & PLUS) {
- sign = '+';
- size--;
- } else if (type & SPACE) {
- sign = ' ';
- size--;
- }
- }
- if (type & SPECIAL) {
- if (base == 16)
- size -= 2;
- else if (base == 8)
- size--;
- }
- i = 0;
- if (num == 0)
- tmp[i++] = '0';
- else
- while (num != 0)
- tmp[i++] = digits[do_div(num, base)];
- if (i > precision)
- precision = i;
- size -= precision;
- if (!(type & (ZEROPAD + LEFT)))
- while (size-- > 0)
- *str++ = ' ';
- if (sign)
- *str++ = sign;
- if (type & SPECIAL) {
- if (base == 8)
- *str++ = '0';
- else if (base == 16) {
- *str++ = '0';
- *str++ = digits[33];
- }
- }
- if (!(type & LEFT))
- while (size-- > 0)
- *str++ = c;
- while (i < precision--)
- *str++ = '0';
- while (i-- > 0)
- *str++ = tmp[i];
- while (size-- > 0)
- *str++ = ' ';
- return str;
-}
-
-int vsprintf(char *buf, const char *fmt, va_list args)
-{
- int len;
- unsigned long num;
- int i, base;
- char *str;
- const char *s;
-
- int flags; /* flags to number() */
-
- int field_width; /* width of output field */
- int precision; /* min. # of digits for integers; max
- number of chars for from string */
- int qualifier; /* 'h', 'l', or 'L' for integer fields */
-
- for (str = buf; *fmt; ++fmt) {
- if (*fmt != '%') {
- *str++ = *fmt;
- continue;
- }
-
- /* process flags */
- flags = 0;
- repeat:
- ++fmt; /* this also skips first '%' */
- switch (*fmt) {
- case '-':
- flags |= LEFT;
- goto repeat;
- case '+':
- flags |= PLUS;
- goto repeat;
- case ' ':
- flags |= SPACE;
- goto repeat;
- case '#':
- flags |= SPECIAL;
- goto repeat;
- case '0':
- flags |= ZEROPAD;
- goto repeat;
- }
-
- /* get field width */
- field_width = -1;
- if (isdigit(*fmt))
- field_width = skip_atoi(&fmt);
- else if (*fmt == '*') {
- ++fmt;
- /* it's the next argument */
- field_width = va_arg(args, int);
- if (field_width < 0) {
- field_width = -field_width;
- flags |= LEFT;
- }
- }
-
- /* get the precision */
- precision = -1;
- if (*fmt == '.') {
- ++fmt;
- if (isdigit(*fmt))
- precision = skip_atoi(&fmt);
- else if (*fmt == '*') {
- ++fmt;
- /* it's the next argument */
- precision = va_arg(args, int);
- }
- if (precision < 0)
- precision = 0;
- }
-
- /* get the conversion qualifier */
- qualifier = -1;
- if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
- qualifier = *fmt;
- ++fmt;
- }
-
- /* default base */
- base = 10;
-
- switch (*fmt) {
- case 'c':
- if (!(flags & LEFT))
- while (--field_width > 0)
- *str++ = ' ';
- *str++ = (unsigned char)va_arg(args, int);
- while (--field_width > 0)
- *str++ = ' ';
- continue;
-
- case 's':
- s = va_arg(args, char *);
- len = strnlen(s, precision);
-
- if (!(flags & LEFT))
- while (len < field_width--)
- *str++ = ' ';
- for (i = 0; i < len; ++i)
- *str++ = *s++;
- while (len < field_width--)
- *str++ = ' ';
- continue;
-
- case 'p':
- if (field_width == -1) {
- field_width = 2 * sizeof(void *);
- flags |= ZEROPAD;
- }
- str = number(str,
- (unsigned long)va_arg(args, void *), 16,
- field_width, precision, flags);
- continue;
-
- case 'n':
- if (qualifier == 'l') {
- long *ip = va_arg(args, long *);
- *ip = (str - buf);
- } else {
- int *ip = va_arg(args, int *);
- *ip = (str - buf);
- }
- continue;
-
- case '%':
- *str++ = '%';
- continue;
-
- /* integer number formats - set up the flags and "break" */
- case 'o':
- base = 8;
- break;
-
- case 'X':
- flags |= LARGE;
- case 'x':
- base = 16;
- break;
-
- case 'd':
- case 'i':
- flags |= SIGN;
- case 'u':
- break;
-
- default:
- *str++ = '%';
- if (*fmt)
- *str++ = *fmt;
- else
- --fmt;
- continue;
- }
- if (qualifier == 'l')
- num = va_arg(args, unsigned long);
- else if (qualifier == 'h') {
- num = (unsigned short)va_arg(args, int);
- if (flags & SIGN)
- num = (short)num;
- } else if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- str = number(str, num, base, field_width, precision, flags);
- }
- *str = '\0';
- return str - buf;
-}
-
-int sprintf(char *buf, const char *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i = vsprintf(buf, fmt, args);
- va_end(args);
- return i;
-}
-
-int printf(const char *fmt, ...)
-{
- char printf_buf[1024];
- va_list args;
- int printed;
-
- va_start(args, fmt);
- printed = vsprintf(printf_buf, fmt, args);
- va_end(args);
-
- puts(printf_buf);
-
- return printed;
-}
diff --git a/arch/i386/boot/setup.ld b/arch/i386/boot/setup.ld
deleted file mode 100644
index df9234b3a5e0..000000000000
--- a/arch/i386/boot/setup.ld
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * setup.ld
- *
- * Linker script for the i386 setup code
- */
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-ENTRY(_start)
-
-SECTIONS
-{
- . = 0;
- .bstext : { *(.bstext) }
- .bsdata : { *(.bsdata) }
-
- . = 497;
- .header : { *(.header) }
- .inittext : { *(.inittext) }
- .initdata : { *(.initdata) }
- .text : { *(.text*) }
-
- . = ALIGN(16);
- .rodata : { *(.rodata*) }
-
- .videocards : {
- video_cards = .;
- *(.videocards)
- video_cards_end = .;
- }
-
- . = ALIGN(16);
- .data : { *(.data*) }
-
- .signature : {
- setup_sig = .;
- LONG(0x5a5aaa55)
- }
-
-
- . = ALIGN(16);
- .bss :
- {
- __bss_start = .;
- *(.bss)
- __bss_end = .;
- }
- . = ALIGN(16);
- _end = .;
-
- /DISCARD/ : { *(.note*) }
-
- . = ASSERT(_end <= 0x8000, "Setup too big!");
- . = ASSERT(hdr == 0x1f1, "The setup header has the wrong offset!");
-}
diff --git a/arch/i386/boot/string.c b/arch/i386/boot/string.c
deleted file mode 100644
index 481a22097781..000000000000
--- a/arch/i386/boot/string.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/string.c
- *
- * Very basic string functions
- */
-
-#include "boot.h"
-
-int strcmp(const char *str1, const char *str2)
-{
- const unsigned char *s1 = (const unsigned char *)str1;
- const unsigned char *s2 = (const unsigned char *)str2;
- int delta = 0;
-
- while (*s1 || *s2) {
- delta = *s2 - *s1;
- if (delta)
- return delta;
- s1++;
- s2++;
- }
- return 0;
-}
-
-size_t strnlen(const char *s, size_t maxlen)
-{
- const char *es = s;
- while (*es && maxlen) {
- es++;
- maxlen--;
- }
-
- return (es - s);
-}
-
-unsigned int atou(const char *s)
-{
- unsigned int i = 0;
- while (isdigit(*s))
- i = i * 10 + (*s++ - '0');
- return i;
-}
diff --git a/arch/i386/boot/tools/.gitignore b/arch/i386/boot/tools/.gitignore
deleted file mode 100644
index 378eac25d311..000000000000
--- a/arch/i386/boot/tools/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-build
diff --git a/arch/i386/boot/tools/build.c b/arch/i386/boot/tools/build.c
deleted file mode 100644
index 886f47d8a488..000000000000
--- a/arch/i386/boot/tools/build.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright (C) 1997 Martin Mares
- * Copyright (C) 2007 H. Peter Anvin
- */
-
-/*
- * This file builds a disk-image from three different files:
- *
- * - setup: 8086 machine code, sets up system parm
- * - system: 80386 code for actual system
- *
- * It does some checking that all files are of the correct type, and
- * just writes the result to stdout, removing headers and padding to
- * the right amount. It also writes some system data to stderr.
- */
-
-/*
- * Changes by tytso to allow root device specification
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- * Cross compiling fixes by Gertjan van Wingerde, July 1996
- * Rewritten by Martin Mares, April 1997
- * Substantially overhauled by H. Peter Anvin, April 2007
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/sysmacros.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <asm/boot.h>
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned long u32;
-
-#define DEFAULT_MAJOR_ROOT 0
-#define DEFAULT_MINOR_ROOT 0
-
-/* Minimal number of setup sectors */
-#define SETUP_SECT_MIN 5
-#define SETUP_SECT_MAX 64
-
-/* This must be large enough to hold the entire setup */
-u8 buf[SETUP_SECT_MAX*512];
-int is_big_kernel;
-
-static void die(const char * str, ...)
-{
- va_list args;
- va_start(args, str);
- vfprintf(stderr, str, args);
- fputc('\n', stderr);
- exit(1);
-}
-
-static void usage(void)
-{
- die("Usage: build [-b] setup system [rootdev] [> image]");
-}
-
-int main(int argc, char ** argv)
-{
- unsigned int i, sz, setup_sectors;
- int c;
- u32 sys_size;
- u8 major_root, minor_root;
- struct stat sb;
- FILE *file;
- int fd;
- void *kernel;
-
- if (argc > 2 && !strcmp(argv[1], "-b"))
- {
- is_big_kernel = 1;
- argc--, argv++;
- }
- if ((argc < 3) || (argc > 4))
- usage();
- if (argc > 3) {
- if (!strcmp(argv[3], "CURRENT")) {
- if (stat("/", &sb)) {
- perror("/");
- die("Couldn't stat /");
- }
- major_root = major(sb.st_dev);
- minor_root = minor(sb.st_dev);
- } else if (strcmp(argv[3], "FLOPPY")) {
- if (stat(argv[3], &sb)) {
- perror(argv[3]);
- die("Couldn't stat root device.");
- }
- major_root = major(sb.st_rdev);
- minor_root = minor(sb.st_rdev);
- } else {
- major_root = 0;
- minor_root = 0;
- }
- } else {
- major_root = DEFAULT_MAJOR_ROOT;
- minor_root = DEFAULT_MINOR_ROOT;
- }
- fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
-
- /* Copy the setup code */
- file = fopen(argv[1], "r");
- if (!file)
- die("Unable to open `%s': %m", argv[1]);
- c = fread(buf, 1, sizeof(buf), file);
- if (ferror(file))
- die("read-error on `setup'");
- if (c < 1024)
- die("The setup must be at least 1024 bytes");
- if (buf[510] != 0x55 || buf[511] != 0xaa)
- die("Boot block hasn't got boot flag (0xAA55)");
- fclose(file);
-
- /* Pad unused space with zeros */
- setup_sectors = (c + 511) / 512;
- if (setup_sectors < SETUP_SECT_MIN)
- setup_sectors = SETUP_SECT_MIN;
- i = setup_sectors*512;
- memset(buf+c, 0, i-c);
-
- /* Set the default root device */
- buf[508] = minor_root;
- buf[509] = major_root;
-
- fprintf(stderr, "Setup is %d bytes (padded to %d bytes).\n", c, i);
-
- /* Open and stat the kernel file */
- fd = open(argv[2], O_RDONLY);
- if (fd < 0)
- die("Unable to open `%s': %m", argv[2]);
- if (fstat(fd, &sb))
- die("Unable to stat `%s': %m", argv[2]);
- sz = sb.st_size;
- fprintf (stderr, "System is %d kB\n", (sz+1023)/1024);
- kernel = mmap(NULL, sz, PROT_READ, MAP_SHARED, fd, 0);
- if (kernel == MAP_FAILED)
- die("Unable to mmap '%s': %m", argv[2]);
- sys_size = (sz + 15) / 16;
- if (!is_big_kernel && sys_size > DEF_SYSSIZE)
- die("System is too big. Try using bzImage or modules.");
-
- /* Patch the setup code with the appropriate size parameters */
- buf[0x1f1] = setup_sectors-1;
- buf[0x1f4] = sys_size;
- buf[0x1f5] = sys_size >> 8;
- buf[0x1f6] = sys_size >> 16;
- buf[0x1f7] = sys_size >> 24;
-
- if (fwrite(buf, 1, i, stdout) != i)
- die("Writing setup failed");
-
- /* Copy the kernel code */
- if (fwrite(kernel, 1, sz, stdout) != sz)
- die("Writing kernel failed");
- close(fd);
-
- /* Everything is OK */
- return 0;
-}
diff --git a/arch/i386/boot/tty.c b/arch/i386/boot/tty.c
deleted file mode 100644
index a8db78736b02..000000000000
--- a/arch/i386/boot/tty.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/tty.c
- *
- * Very simple screen I/O
- * XXX: Probably should add very simple serial I/O?
- */
-
-#include "boot.h"
-
-/*
- * These functions are in .inittext so they can be used to signal
- * error during initialization.
- */
-
-void __attribute__((section(".inittext"))) putchar(int ch)
-{
- unsigned char c = ch;
-
- if (c == '\n')
- putchar('\r'); /* \n -> \r\n */
-
- /* int $0x10 is known to have bugs involving touching registers
- it shouldn't. Be extra conservative... */
- asm volatile("pushal; int $0x10; popal"
- : : "b" (0x0007), "c" (0x0001), "a" (0x0e00|ch));
-}
-
-void __attribute__((section(".inittext"))) puts(const char *str)
-{
- int n = 0;
- while (*str) {
- putchar(*str++);
- n++;
- }
-}
-
-/*
- * Read the CMOS clock through the BIOS, and return the
- * seconds in BCD.
- */
-
-static u8 gettime(void)
-{
- u16 ax = 0x0200;
- u16 cx, dx;
-
- asm("int $0x1a"
- : "+a" (ax), "=c" (cx), "=d" (dx)
- : : "ebx", "esi", "edi");
-
- return dx >> 8;
-}
-
-/*
- * Read from the keyboard
- */
-int getchar(void)
-{
- u16 ax = 0;
- asm("int $0x16" : "+a" (ax));
-
- return ax & 0xff;
-}
-
-static int kbd_pending(void)
-{
- u8 pending;
- asm("int $0x16; setnz %0"
- : "=rm" (pending)
- : "a" (0x0100));
- return pending;
-}
-
-void kbd_flush(void)
-{
- for (;;) {
- if (!kbd_pending())
- break;
- getchar();
- }
-}
-
-int getchar_timeout(void)
-{
- int cnt = 30;
- int t0, t1;
-
- t0 = gettime();
-
- while (cnt) {
- if (kbd_pending())
- return getchar();
-
- t1 = gettime();
- if (t0 != t1) {
- cnt--;
- t0 = t1;
- }
- }
-
- return 0; /* Timeout! */
-}
diff --git a/arch/i386/boot/version.c b/arch/i386/boot/version.c
deleted file mode 100644
index c61462f7d9a7..000000000000
--- a/arch/i386/boot/version.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/version.c
- *
- * Kernel version string
- */
-
-#include "boot.h"
-#include <linux/utsrelease.h>
-#include <linux/compile.h>
-
-const char kernel_version[] =
- UTS_RELEASE " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") "
- UTS_VERSION;
diff --git a/arch/i386/boot/vesa.h b/arch/i386/boot/vesa.h
deleted file mode 100644
index ff5b73cd406f..000000000000
--- a/arch/i386/boot/vesa.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 1999-2007 H. Peter Anvin - All Rights Reserved
- *
- * 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, Inc., 53 Temple Place Ste 330,
- * Boston MA 02111-1307, USA; either version 2 of the License, or
- * (at your option) any later version; incorporated herein by reference.
- *
- * ----------------------------------------------------------------------- */
-
-#ifndef BOOT_VESA_H
-#define BOOT_VESA_H
-
-typedef struct {
- u16 off, seg;
-} far_ptr;
-
-/* VESA General Information table */
-struct vesa_general_info {
- u32 signature; /* 0 Magic number = "VESA" */
- u16 version; /* 4 */
- far_ptr vendor_string; /* 6 */
- u32 capabilities; /* 10 */
- far_ptr video_mode_ptr; /* 14 */
- u16 total_memory; /* 18 */
-
- u16 oem_software_rev; /* 20 */
- far_ptr oem_vendor_name_ptr; /* 22 */
- far_ptr oem_product_name_ptr; /* 26 */
- far_ptr oem_product_rev_ptr; /* 30 */
-
- u8 reserved[222]; /* 34 */
- u8 oem_data[256]; /* 256 */
-} __attribute__ ((packed));
-
-#define VESA_MAGIC ('V' + ('E' << 8) + ('S' << 16) + ('A' << 24))
-#define VBE2_MAGIC ('V' + ('B' << 8) + ('E' << 16) + ('2' << 24))
-
-struct vesa_mode_info {
- u16 mode_attr; /* 0 */
- u8 win_attr[2]; /* 2 */
- u16 win_grain; /* 4 */
- u16 win_size; /* 6 */
- u16 win_seg[2]; /* 8 */
- far_ptr win_scheme; /* 12 */
- u16 logical_scan; /* 16 */
-
- u16 h_res; /* 18 */
- u16 v_res; /* 20 */
- u8 char_width; /* 22 */
- u8 char_height; /* 23 */
- u8 memory_planes; /* 24 */
- u8 bpp; /* 25 */
- u8 banks; /* 26 */
- u8 memory_layout; /* 27 */
- u8 bank_size; /* 28 */
- u8 image_planes; /* 29 */
- u8 page_function; /* 30 */
-
- u8 rmask; /* 31 */
- u8 rpos; /* 32 */
- u8 gmask; /* 33 */
- u8 gpos; /* 34 */
- u8 bmask; /* 35 */
- u8 bpos; /* 36 */
- u8 resv_mask; /* 37 */
- u8 resv_pos; /* 38 */
- u8 dcm_info; /* 39 */
-
- u32 lfb_ptr; /* 40 Linear frame buffer address */
- u32 offscreen_ptr; /* 44 Offscreen memory address */
- u16 offscreen_size; /* 48 */
-
- u8 reserved[206]; /* 50 */
-} __attribute__ ((packed));
-
-#endif /* LIB_SYS_VESA_H */
diff --git a/arch/i386/boot/video-bios.c b/arch/i386/boot/video-bios.c
deleted file mode 100644
index afea46c500cc..000000000000
--- a/arch/i386/boot/video-bios.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/video-bios.c
- *
- * Standard video BIOS modes
- *
- * We have two options for this; silent and scanned.
- */
-
-#include "boot.h"
-#include "video.h"
-
-__videocard video_bios;
-
-/* Set a conventional BIOS mode */
-static int set_bios_mode(u8 mode);
-
-static int bios_set_mode(struct mode_info *mi)
-{
- return set_bios_mode(mi->mode - VIDEO_FIRST_BIOS);
-}
-
-static int set_bios_mode(u8 mode)
-{
- u16 ax;
- u8 new_mode;
-
- ax = mode; /* AH=0x00 Set Video Mode */
- asm volatile(INT10
- : "+a" (ax)
- : : "ebx", "ecx", "edx", "esi", "edi");
-
- ax = 0x0f00; /* Get Current Video Mode */
- asm volatile(INT10
- : "+a" (ax)
- : : "ebx", "ecx", "edx", "esi", "edi");
-
- do_restore = 1; /* Assume video contents was lost */
- new_mode = ax & 0x7f; /* Not all BIOSes are clean with the top bit */
-
- if (new_mode == mode)
- return 0; /* Mode change OK */
-
- if (new_mode != boot_params.screen_info.orig_video_mode) {
- /* Mode setting failed, but we didn't end up where we
- started. That's bad. Try to revert to the original
- video mode. */
- ax = boot_params.screen_info.orig_video_mode;
- asm volatile(INT10
- : "+a" (ax)
- : : "ebx", "ecx", "edx", "esi", "edi");
- }
- return -1;
-}
-
-static int bios_probe(void)
-{
- u8 mode;
- u8 saved_mode = boot_params.screen_info.orig_video_mode;
- u16 crtc;
- struct mode_info *mi;
- int nmodes = 0;
-
- if (adapter != ADAPTER_EGA && adapter != ADAPTER_VGA)
- return 0;
-
- set_fs(0);
- crtc = vga_crtc();
-
- video_bios.modes = GET_HEAP(struct mode_info, 0);
-
- for (mode = 0x14; mode <= 0x7f; mode++) {
- if (heap_free() < sizeof(struct mode_info))
- break;
-
- if (mode_defined(VIDEO_FIRST_BIOS+mode))
- continue;
-
- if (set_bios_mode(mode))
- continue;
-
- /* Try to verify that it's a text mode. */
-
- /* Attribute Controller: make graphics controller disabled */
- if (in_idx(0x3c0, 0x10) & 0x01)
- continue;
-
- /* Graphics Controller: verify Alpha addressing enabled */
- if (in_idx(0x3ce, 0x06) & 0x01)
- continue;
-
- /* CRTC cursor location low should be zero(?) */
- if (in_idx(crtc, 0x0f))
- continue;
-
- mi = GET_HEAP(struct mode_info, 1);
- mi->mode = VIDEO_FIRST_BIOS+mode;
- mi->x = rdfs16(0x44a);
- mi->y = rdfs8(0x484)+1;
- nmodes++;
- }
-
- set_bios_mode(saved_mode);
-
- return nmodes;
-}
-
-__videocard video_bios =
-{
- .card_name = "BIOS (scanned)",
- .probe = bios_probe,
- .set_mode = bios_set_mode,
- .unsafe = 1,
- .xmode_first = VIDEO_FIRST_BIOS,
- .xmode_n = 0x80,
-};
diff --git a/arch/i386/boot/video-vesa.c b/arch/i386/boot/video-vesa.c
deleted file mode 100644
index e6aa9eb8d93a..000000000000
--- a/arch/i386/boot/video-vesa.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/video-vesa.c
- *
- * VESA text modes
- */
-
-#include "boot.h"
-#include "video.h"
-#include "vesa.h"
-
-/* VESA information */
-static struct vesa_general_info vginfo;
-static struct vesa_mode_info vminfo;
-
-__videocard video_vesa;
-
-static void vesa_store_mode_params_graphics(void);
-
-static int vesa_probe(void)
-{
-#if defined(CONFIG_VIDEO_VESA) || defined(CONFIG_FIRMWARE_EDID)
- u16 ax;
- u16 mode;
- addr_t mode_ptr;
- struct mode_info *mi;
- int nmodes = 0;
-
- video_vesa.modes = GET_HEAP(struct mode_info, 0);
-
- vginfo.signature = VBE2_MAGIC;
-
- /* Optimistically assume a VESA BIOS is register-clean... */
- ax = 0x4f00;
- asm("int $0x10" : "+a" (ax), "=m" (vginfo) : "D" (&vginfo));
-
- if (ax != 0x004f ||
- vginfo.signature != VESA_MAGIC ||
- vginfo.version < 0x0102)
- return 0; /* Not present */
-#endif /* CONFIG_VIDEO_VESA || CONFIG_FIRMWARE_EDID */
-#ifdef CONFIG_VIDEO_VESA
- set_fs(vginfo.video_mode_ptr.seg);
- mode_ptr = vginfo.video_mode_ptr.off;
-
- while ((mode = rdfs16(mode_ptr)) != 0xffff) {
- mode_ptr += 2;
-
- if (heap_free() < sizeof(struct mode_info))
- break; /* Heap full, can't save mode info */
-
- if (mode & ~0x1ff)
- continue;
-
- memset(&vminfo, 0, sizeof vminfo); /* Just in case... */
-
- ax = 0x4f01;
- asm("int $0x10"
- : "+a" (ax), "=m" (vminfo)
- : "c" (mode), "D" (&vminfo));
-
- if (ax != 0x004f)
- continue;
-
- if ((vminfo.mode_attr & 0x15) == 0x05) {
- /* Text Mode, TTY BIOS supported,
- supported by hardware */
- mi = GET_HEAP(struct mode_info, 1);
- mi->mode = mode + VIDEO_FIRST_VESA;
- mi->x = vminfo.h_res;
- mi->y = vminfo.v_res;
- nmodes++;
- } else if ((vminfo.mode_attr & 0x99) == 0x99) {
-#ifdef CONFIG_FB
- /* Graphics mode, color, linear frame buffer
- supported -- register the mode but hide from
- the menu. Only do this if framebuffer is
- configured, however, otherwise the user will
- be left without a screen. */
- mi = GET_HEAP(struct mode_info, 1);
- mi->mode = mode + VIDEO_FIRST_VESA;
- mi->x = mi->y = 0;
- nmodes++;
-#endif
- }
- }
-
- return nmodes;
-#else
- return 0;
-#endif /* CONFIG_VIDEO_VESA */
-}
-
-static int vesa_set_mode(struct mode_info *mode)
-{
- u16 ax;
- int is_graphic;
- u16 vesa_mode = mode->mode - VIDEO_FIRST_VESA;
-
- memset(&vminfo, 0, sizeof vminfo); /* Just in case... */
-
- ax = 0x4f01;
- asm("int $0x10"
- : "+a" (ax), "=m" (vminfo)
- : "c" (vesa_mode), "D" (&vminfo));
-
- if (ax != 0x004f)
- return -1;
-
- if ((vminfo.mode_attr & 0x15) == 0x05) {
- /* It's a supported text mode */
- is_graphic = 0;
- } else if ((vminfo.mode_attr & 0x99) == 0x99) {
- /* It's a graphics mode with linear frame buffer */
- is_graphic = 1;
- vesa_mode |= 0x4000; /* Request linear frame buffer */
- } else {
- return -1; /* Invalid mode */
- }
-
-
- ax = 0x4f02;
- asm volatile("int $0x10"
- : "+a" (ax)
- : "b" (vesa_mode), "D" (0));
-
- if (ax != 0x004f)
- return -1;
-
- graphic_mode = is_graphic;
- if (!is_graphic) {
- /* Text mode */
- force_x = mode->x;
- force_y = mode->y;
- do_restore = 1;
- } else {
- /* Graphics mode */
- vesa_store_mode_params_graphics();
- }
-
- return 0;
-}
-
-
-/* Switch DAC to 8-bit mode */
-static void vesa_dac_set_8bits(void)
-{
- u8 dac_size = 6;
-
- /* If possible, switch the DAC to 8-bit mode */
- if (vginfo.capabilities & 1) {
- u16 ax, bx;
-
- ax = 0x4f08;
- bx = 0x0800;
- asm volatile(INT10
- : "+a" (ax), "+b" (bx)
- : : "ecx", "edx", "esi", "edi");
-
- if (ax == 0x004f)
- dac_size = bx >> 8;
- }
-
- /* Set the color sizes to the DAC size, and offsets to 0 */
- boot_params.screen_info.red_size = dac_size;
- boot_params.screen_info.green_size = dac_size;
- boot_params.screen_info.blue_size = dac_size;
- boot_params.screen_info.rsvd_size = dac_size;
-
- boot_params.screen_info.red_pos = 0;
- boot_params.screen_info.green_pos = 0;
- boot_params.screen_info.blue_pos = 0;
- boot_params.screen_info.rsvd_pos = 0;
-}
-
-/* Save the VESA protected mode info */
-static void vesa_store_pm_info(void)
-{
- u16 ax, bx, di, es;
-
- ax = 0x4f0a;
- bx = di = 0;
- asm("pushw %%es; "INT10"; movw %%es,%0; popw %%es"
- : "=d" (es), "+a" (ax), "+b" (bx), "+D" (di)
- : : "ecx", "esi");
-
- if (ax != 0x004f)
- return;
-
- boot_params.screen_info.vesapm_seg = es;
- boot_params.screen_info.vesapm_off = di;
-}
-
-/*
- * Save video mode parameters for graphics mode
- */
-static void vesa_store_mode_params_graphics(void)
-{
- /* Tell the kernel we're in VESA graphics mode */
- boot_params.screen_info.orig_video_isVGA = 0x23;
-
- /* Mode parameters */
- boot_params.screen_info.vesa_attributes = vminfo.mode_attr;
- boot_params.screen_info.lfb_linelength = vminfo.logical_scan;
- boot_params.screen_info.lfb_width = vminfo.h_res;
- boot_params.screen_info.lfb_height = vminfo.v_res;
- boot_params.screen_info.lfb_depth = vminfo.bpp;
- boot_params.screen_info.pages = vminfo.image_planes;
- boot_params.screen_info.lfb_base = vminfo.lfb_ptr;
- memcpy(&boot_params.screen_info.red_size,
- &vminfo.rmask, 8);
-
- /* General parameters */
- boot_params.screen_info.lfb_size = vginfo.total_memory;
-
- if (vminfo.bpp <= 8)
- vesa_dac_set_8bits();
-
- vesa_store_pm_info();
-}
-
-/*
- * Save EDID information for the kernel; this is invoked, separately,
- * after mode-setting.
- */
-void vesa_store_edid(void)
-{
-#ifdef CONFIG_FIRMWARE_EDID
- u16 ax, bx, cx, dx, di;
-
- /* Apparently used as a nonsense token... */
- memset(&boot_params.edid_info, 0x13, sizeof boot_params.edid_info);
-
- if (vginfo.version < 0x0200)
- return; /* EDID requires VBE 2.0+ */
-
- ax = 0x4f15; /* VBE DDC */
- bx = 0x0000; /* Report DDC capabilities */
- cx = 0; /* Controller 0 */
- di = 0; /* ES:DI must be 0 by spec */
-
- /* Note: The VBE DDC spec is different from the main VESA spec;
- we genuinely have to assume all registers are destroyed here. */
-
- asm("pushw %%es; movw %2,%%es; "INT10"; popw %%es"
- : "+a" (ax), "+b" (bx)
- : "c" (cx), "D" (di)
- : "esi");
-
- if (ax != 0x004f)
- return; /* No EDID */
-
- /* BH = time in seconds to transfer EDD information */
- /* BL = DDC level supported */
-
- ax = 0x4f15; /* VBE DDC */
- bx = 0x0001; /* Read EDID */
- cx = 0; /* Controller 0 */
- dx = 0; /* EDID block number */
- di =(size_t) &boot_params.edid_info; /* (ES:)Pointer to block */
- asm(INT10
- : "+a" (ax), "+b" (bx), "+d" (dx)
- : "c" (cx), "D" (di)
- : "esi");
-#endif /* CONFIG_FIRMWARE_EDID */
-}
-
-__videocard video_vesa =
-{
- .card_name = "VESA",
- .probe = vesa_probe,
- .set_mode = vesa_set_mode,
- .xmode_first = VIDEO_FIRST_VESA,
- .xmode_n = 0x200,
-};
diff --git a/arch/i386/boot/video-vga.c b/arch/i386/boot/video-vga.c
deleted file mode 100644
index 700d09a9c9b3..000000000000
--- a/arch/i386/boot/video-vga.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/video-vga.c
- *
- * Common all-VGA modes
- */
-
-#include "boot.h"
-#include "video.h"
-
-static struct mode_info vga_modes[] = {
- { VIDEO_80x25, 80, 25 },
- { VIDEO_8POINT, 80, 50 },
- { VIDEO_80x43, 80, 43 },
- { VIDEO_80x28, 80, 28 },
- { VIDEO_80x30, 80, 30 },
- { VIDEO_80x34, 80, 34 },
- { VIDEO_80x60, 80, 60 },
-};
-
-static struct mode_info ega_modes[] = {
- { VIDEO_80x25, 80, 25 },
- { VIDEO_8POINT, 80, 43 },
-};
-
-static struct mode_info cga_modes[] = {
- { VIDEO_80x25, 80, 25 },
-};
-
-__videocard video_vga;
-
-/* Set basic 80x25 mode */
-static u8 vga_set_basic_mode(void)
-{
- u16 ax;
- u8 rows;
- u8 mode;
-
-#ifdef CONFIG_VIDEO_400_HACK
- if (adapter >= ADAPTER_VGA) {
- asm(INT10
- : : "a" (0x1202), "b" (0x0030)
- : "ecx", "edx", "esi", "edi");
- }
-#endif
-
- ax = 0x0f00;
- asm(INT10
- : "+a" (ax)
- : : "ebx", "ecx", "edx", "esi", "edi");
-
- mode = (u8)ax;
-
- set_fs(0);
- rows = rdfs8(0x484); /* rows minus one */
-
-#ifndef CONFIG_VIDEO_400_HACK
- if ((ax == 0x5003 || ax == 0x5007) &&
- (rows == 0 || rows == 24))
- return mode;
-#endif
-
- if (mode != 3 && mode != 7)
- mode = 3;
-
- /* Set the mode */
- asm volatile(INT10
- : : "a" (mode)
- : "ebx", "ecx", "edx", "esi", "edi");
- do_restore = 1;
- return mode;
-}
-
-static void vga_set_8font(void)
-{
- /* Set 8x8 font - 80x43 on EGA, 80x50 on VGA */
-
- /* Set 8x8 font */
- asm volatile(INT10 : : "a" (0x1112), "b" (0));
-
- /* Use alternate print screen */
- asm volatile(INT10 : : "a" (0x1200), "b" (0x20));
-
- /* Turn off cursor emulation */
- asm volatile(INT10 : : "a" (0x1201), "b" (0x34));
-
- /* Cursor is scan lines 6-7 */
- asm volatile(INT10 : : "a" (0x0100), "c" (0x0607));
-}
-
-static void vga_set_14font(void)
-{
- /* Set 9x14 font - 80x28 on VGA */
-
- /* Set 9x14 font */
- asm volatile(INT10 : : "a" (0x1111), "b" (0));
-
- /* Turn off cursor emulation */
- asm volatile(INT10 : : "a" (0x1201), "b" (0x34));
-
- /* Cursor is scan lines 11-12 */
- asm volatile(INT10 : : "a" (0x0100), "c" (0x0b0c));
-}
-
-static void vga_set_80x43(void)
-{
- /* Set 80x43 mode on VGA (not EGA) */
-
- /* Set 350 scans */
- asm volatile(INT10 : : "a" (0x1201), "b" (0x30));
-
- /* Reset video mode */
- asm volatile(INT10 : : "a" (0x0003));
-
- vga_set_8font();
-}
-
-/* I/O address of the VGA CRTC */
-u16 vga_crtc(void)
-{
- return (inb(0x3cc) & 1) ? 0x3d4 : 0x3b4;
-}
-
-static void vga_set_480_scanlines(int end)
-{
- u16 crtc;
- u8 csel;
-
- crtc = vga_crtc();
-
- out_idx(0x0c, crtc, 0x11); /* Vertical sync end, unlock CR0-7 */
- out_idx(0x0b, crtc, 0x06); /* Vertical total */
- out_idx(0x3e, crtc, 0x07); /* Vertical overflow */
- out_idx(0xea, crtc, 0x10); /* Vertical sync start */
- out_idx(end, crtc, 0x12); /* Vertical display end */
- out_idx(0xe7, crtc, 0x15); /* Vertical blank start */
- out_idx(0x04, crtc, 0x16); /* Vertical blank end */
- csel = inb(0x3cc);
- csel &= 0x0d;
- csel |= 0xe2;
- outb(csel, 0x3cc);
-}
-
-static void vga_set_80x30(void)
-{
- vga_set_480_scanlines(0xdf);
-}
-
-static void vga_set_80x34(void)
-{
- vga_set_14font();
- vga_set_480_scanlines(0xdb);
-}
-
-static void vga_set_80x60(void)
-{
- vga_set_8font();
- vga_set_480_scanlines(0xdf);
-}
-
-static int vga_set_mode(struct mode_info *mode)
-{
- /* Set the basic mode */
- vga_set_basic_mode();
-
- /* Override a possibly broken BIOS */
- force_x = mode->x;
- force_y = mode->y;
-
- switch (mode->mode) {
- case VIDEO_80x25:
- break;
- case VIDEO_8POINT:
- vga_set_8font();
- break;
- case VIDEO_80x43:
- vga_set_80x43();
- break;
- case VIDEO_80x28:
- vga_set_14font();
- break;
- case VIDEO_80x30:
- vga_set_80x30();
- break;
- case VIDEO_80x34:
- vga_set_80x34();
- break;
- case VIDEO_80x60:
- vga_set_80x60();
- break;
- }
-
- return 0;
-}
-
-/*
- * Note: this probe includes basic information required by all
- * systems. It should be executed first, by making sure
- * video-vga.c is listed first in the Makefile.
- */
-static int vga_probe(void)
-{
- static const char *card_name[] = {
- "CGA/MDA/HGC", "EGA", "VGA"
- };
- static struct mode_info *mode_lists[] = {
- cga_modes,
- ega_modes,
- vga_modes,
- };
- static int mode_count[] = {
- sizeof(cga_modes)/sizeof(struct mode_info),
- sizeof(ega_modes)/sizeof(struct mode_info),
- sizeof(vga_modes)/sizeof(struct mode_info),
- };
- u8 vga_flag;
-
- asm(INT10
- : "=b" (boot_params.screen_info.orig_video_ega_bx)
- : "a" (0x1200), "b" (0x10) /* Check EGA/VGA */
- : "ecx", "edx", "esi", "edi");
-
- /* If we have MDA/CGA/HGC then BL will be unchanged at 0x10 */
- if ((u8)boot_params.screen_info.orig_video_ega_bx != 0x10) {
- /* EGA/VGA */
- asm(INT10
- : "=a" (vga_flag)
- : "a" (0x1a00)
- : "ebx", "ecx", "edx", "esi", "edi");
-
- if (vga_flag == 0x1a) {
- adapter = ADAPTER_VGA;
- boot_params.screen_info.orig_video_isVGA = 1;
- } else {
- adapter = ADAPTER_EGA;
- }
- } else {
- adapter = ADAPTER_CGA;
- }
-
- video_vga.modes = mode_lists[adapter];
- video_vga.card_name = card_name[adapter];
- return mode_count[adapter];
-}
-
-__videocard video_vga =
-{
- .card_name = "VGA",
- .probe = vga_probe,
- .set_mode = vga_set_mode,
-};
diff --git a/arch/i386/boot/video.c b/arch/i386/boot/video.c
deleted file mode 100644
index 3bb3573cd6a1..000000000000
--- a/arch/i386/boot/video.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/video.c
- *
- * Select video mode
- */
-
-#include "boot.h"
-#include "video.h"
-#include "vesa.h"
-
-/*
- * Mode list variables
- */
-static struct card_info cards[]; /* List of cards to probe for */
-
-/*
- * Common variables
- */
-int adapter; /* 0=CGA/MDA/HGC, 1=EGA, 2=VGA+ */
-u16 video_segment;
-int force_x, force_y; /* Don't query the BIOS for cols/rows */
-
-int do_restore = 0; /* Screen contents changed during mode flip */
-int graphic_mode; /* Graphic mode with linear frame buffer */
-
-static void store_cursor_position(void)
-{
- u16 curpos;
- u16 ax, bx;
-
- ax = 0x0300;
- bx = 0;
- asm(INT10
- : "=d" (curpos), "+a" (ax), "+b" (bx)
- : : "ecx", "esi", "edi");
-
- boot_params.screen_info.orig_x = curpos;
- boot_params.screen_info.orig_y = curpos >> 8;
-}
-
-static void store_video_mode(void)
-{
- u16 ax, page;
-
- /* N.B.: the saving of the video page here is a bit silly,
- since we pretty much assume page 0 everywhere. */
- ax = 0x0f00;
- asm(INT10
- : "+a" (ax), "=b" (page)
- : : "ecx", "edx", "esi", "edi");
-
- /* Not all BIOSes are clean with respect to the top bit */
- boot_params.screen_info.orig_video_mode = ax & 0x7f;
- boot_params.screen_info.orig_video_page = page;
-}
-
-/*
- * Store the video mode parameters for later usage by the kernel.
- * This is done by asking the BIOS except for the rows/columns
- * parameters in the default 80x25 mode -- these are set directly,
- * because some very obscure BIOSes supply insane values.
- */
-static void store_mode_params(void)
-{
- u16 font_size;
- int x, y;
-
- /* For graphics mode, it is up to the mode-setting driver
- (currently only video-vesa.c) to store the parameters */
- if (graphic_mode)
- return;
-
- store_cursor_position();
- store_video_mode();
-
- if (boot_params.screen_info.orig_video_mode == 0x07) {
- /* MDA, HGC, or VGA in monochrome mode */
- video_segment = 0xb000;
- } else {
- /* CGA, EGA, VGA and so forth */
- video_segment = 0xb800;
- }
-
- set_fs(0);
- font_size = rdfs16(0x485); /* Font size, BIOS area */
- boot_params.screen_info.orig_video_points = font_size;
-
- x = rdfs16(0x44a);
- y = (adapter == ADAPTER_CGA) ? 25 : rdfs8(0x484)+1;
-
- if (force_x)
- x = force_x;
- if (force_y)
- y = force_y;
-
- boot_params.screen_info.orig_video_cols = x;
- boot_params.screen_info.orig_video_lines = y;
-}
-
-/* Probe the video drivers and have them generate their mode lists. */
-static void probe_cards(int unsafe)
-{
- struct card_info *card;
- static u8 probed[2];
-
- if (probed[unsafe])
- return;
-
- probed[unsafe] = 1;
-
- for (card = video_cards; card < video_cards_end; card++) {
- if (card->unsafe == unsafe) {
- if (card->probe)
- card->nmodes = card->probe();
- else
- card->nmodes = 0;
- }
- }
-}
-
-/* Test if a mode is defined */
-int mode_defined(u16 mode)
-{
- struct card_info *card;
- struct mode_info *mi;
- int i;
-
- for (card = video_cards; card < video_cards_end; card++) {
- mi = card->modes;
- for (i = 0; i < card->nmodes; i++, mi++) {
- if (mi->mode == mode)
- return 1;
- }
- }
-
- return 0;
-}
-
-/* Set mode (without recalc) */
-static int raw_set_mode(u16 mode)
-{
- int nmode, i;
- struct card_info *card;
- struct mode_info *mi;
-
- /* Drop the recalc bit if set */
- mode &= ~VIDEO_RECALC;
-
- /* Scan for mode based on fixed ID, position, or resolution */
- nmode = 0;
- for (card = video_cards; card < video_cards_end; card++) {
- mi = card->modes;
- for (i = 0; i < card->nmodes; i++, mi++) {
- int visible = mi->x || mi->y;
-
- if ((mode == nmode && visible) ||
- mode == mi->mode ||
- mode == (mi->y << 8)+mi->x)
- return card->set_mode(mi);
-
- if (visible)
- nmode++;
- }
- }
-
- /* Nothing found? Is it an "exceptional" (unprobed) mode? */
- for (card = video_cards; card < video_cards_end; card++) {
- if (mode >= card->xmode_first &&
- mode < card->xmode_first+card->xmode_n) {
- struct mode_info mix;
- mix.mode = mode;
- mix.x = mix.y = 0;
- return card->set_mode(&mix);
- }
- }
-
- /* Otherwise, failure... */
- return -1;
-}
-
-/*
- * Recalculate the vertical video cutoff (hack!)
- */
-static void vga_recalc_vertical(void)
-{
- unsigned int font_size, rows;
- u16 crtc;
- u8 ov;
-
- set_fs(0);
- font_size = rdfs8(0x485); /* BIOS: font size (pixels) */
- rows = force_y ? force_y : rdfs8(0x484)+1; /* Text rows */
-
- rows *= font_size; /* Visible scan lines */
- rows--; /* ... minus one */
-
- crtc = vga_crtc();
-
- out_idx((u8)rows, crtc, 0x12); /* Lower height register */
- ov = in_idx(crtc, 0x07); /* Overflow register */
- ov &= 0xbd;
- ov |= (rows >> (8-1)) & 0x02;
- ov |= (rows >> (9-6)) & 0x40;
- out_idx(ov, crtc, 0x07);
-}
-
-/* Set mode (with recalc if specified) */
-static int set_mode(u16 mode)
-{
- int rv;
-
- /* Very special mode numbers... */
- if (mode == VIDEO_CURRENT_MODE)
- return 0; /* Nothing to do... */
- else if (mode == NORMAL_VGA)
- mode = VIDEO_80x25;
- else if (mode == EXTENDED_VGA)
- mode = VIDEO_8POINT;
-
- rv = raw_set_mode(mode);
- if (rv)
- return rv;
-
- if (mode & VIDEO_RECALC)
- vga_recalc_vertical();
-
- return 0;
-}
-
-static unsigned int get_entry(void)
-{
- char entry_buf[4];
- int i, len = 0;
- int key;
- unsigned int v;
-
- do {
- key = getchar();
-
- if (key == '\b') {
- if (len > 0) {
- puts("\b \b");
- len--;
- }
- } else if ((key >= '0' && key <= '9') ||
- (key >= 'A' && key <= 'Z') ||
- (key >= 'a' && key <= 'z')) {
- if (len < sizeof entry_buf) {
- entry_buf[len++] = key;
- putchar(key);
- }
- }
- } while (key != '\r');
- putchar('\n');
-
- if (len == 0)
- return VIDEO_CURRENT_MODE; /* Default */
-
- v = 0;
- for (i = 0; i < len; i++) {
- v <<= 4;
- key = entry_buf[i] | 0x20;
- v += (key > '9') ? key-'a'+10 : key-'0';
- }
-
- return v;
-}
-
-static void display_menu(void)
-{
- struct card_info *card;
- struct mode_info *mi;
- char ch;
- int i;
-
- puts("Mode: COLSxROWS:\n");
-
- ch = '0';
- for (card = video_cards; card < video_cards_end; card++) {
- mi = card->modes;
- for (i = 0; i < card->nmodes; i++, mi++) {
- int visible = mi->x && mi->y;
- u16 mode_id = mi->mode ? mi->mode :
- (mi->y << 8)+mi->x;
-
- if (!visible)
- continue; /* Hidden mode */
-
- printf("%c %04X %3dx%-3d %s\n",
- ch, mode_id, mi->x, mi->y, card->card_name);
-
- if (ch == '9')
- ch = 'a';
- else if (ch == 'z' || ch == ' ')
- ch = ' '; /* Out of keys... */
- else
- ch++;
- }
- }
-}
-
-#define H(x) ((x)-'a'+10)
-#define SCAN ((H('s')<<12)+(H('c')<<8)+(H('a')<<4)+H('n'))
-
-static unsigned int mode_menu(void)
-{
- int key;
- unsigned int sel;
-
- puts("Press <ENTER> to see video modes available, "
- "<SPACE> to continue, or wait 30 sec\n");
-
- kbd_flush();
- while (1) {
- key = getchar_timeout();
- if (key == ' ' || key == 0)
- return VIDEO_CURRENT_MODE; /* Default */
- if (key == '\r')
- break;
- putchar('\a'); /* Beep! */
- }
-
-
- for (;;) {
- display_menu();
-
- puts("Enter a video mode or \"scan\" to scan for "
- "additional modes: ");
- sel = get_entry();
- if (sel != SCAN)
- return sel;
-
- probe_cards(1);
- }
-}
-
-#ifdef CONFIG_VIDEO_RETAIN
-/* Save screen content to the heap */
-struct saved_screen {
- int x, y;
- int curx, cury;
- u16 *data;
-} saved;
-
-static void save_screen(void)
-{
- /* Should be called after store_mode_params() */
- saved.x = boot_params.screen_info.orig_video_cols;
- saved.y = boot_params.screen_info.orig_video_lines;
- saved.curx = boot_params.screen_info.orig_x;
- saved.cury = boot_params.screen_info.orig_y;
-
- if (heap_free() < saved.x*saved.y*sizeof(u16)+512)
- return; /* Not enough heap to save the screen */
-
- saved.data = GET_HEAP(u16, saved.x*saved.y);
-
- set_fs(video_segment);
- copy_from_fs(saved.data, 0, saved.x*saved.y*sizeof(u16));
-}
-
-static void restore_screen(void)
-{
- /* Should be called after store_mode_params() */
- int xs = boot_params.screen_info.orig_video_cols;
- int ys = boot_params.screen_info.orig_video_lines;
- int y;
- addr_t dst = 0;
- u16 *src = saved.data;
- u16 ax, bx, dx;
-
- if (graphic_mode)
- return; /* Can't restore onto a graphic mode */
-
- if (!src)
- return; /* No saved screen contents */
-
- /* Restore screen contents */
-
- set_fs(video_segment);
- for (y = 0; y < ys; y++) {
- int npad;
-
- if (y < saved.y) {
- int copy = (xs < saved.x) ? xs : saved.x;
- copy_to_fs(dst, src, copy*sizeof(u16));
- dst += copy*sizeof(u16);
- src += saved.x;
- npad = (xs < saved.x) ? 0 : xs-saved.x;
- } else {
- npad = xs;
- }
-
- /* Writes "npad" blank characters to
- video_segment:dst and advances dst */
- asm volatile("pushw %%es ; "
- "movw %2,%%es ; "
- "shrw %%cx ; "
- "jnc 1f ; "
- "stosw \n\t"
- "1: rep;stosl ; "
- "popw %%es"
- : "+D" (dst), "+c" (npad)
- : "bdSm" (video_segment),
- "a" (0x07200720));
- }
-
- /* Restore cursor position */
- ax = 0x0200; /* Set cursor position */
- bx = 0; /* Page number (<< 8) */
- dx = (saved.cury << 8)+saved.curx;
- asm volatile(INT10
- : "+a" (ax), "+b" (bx), "+d" (dx)
- : : "ecx", "esi", "edi");
-}
-#else
-#define save_screen() ((void)0)
-#define restore_screen() ((void)0)
-#endif
-
-void set_video(void)
-{
- u16 mode = boot_params.hdr.vid_mode;
-
- RESET_HEAP();
-
- store_mode_params();
- save_screen();
- probe_cards(0);
-
- for (;;) {
- if (mode == ASK_VGA)
- mode = mode_menu();
-
- if (!set_mode(mode))
- break;
-
- printf("Undefined video mode number: %x\n", mode);
- mode = ASK_VGA;
- }
- vesa_store_edid();
- store_mode_params();
-
- if (do_restore)
- restore_screen();
-}
diff --git a/arch/i386/boot/video.h b/arch/i386/boot/video.h
deleted file mode 100644
index 29eca1710b2c..000000000000
--- a/arch/i386/boot/video.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/video.h
- *
- * Header file for the real-mode video probing code
- */
-
-#ifndef BOOT_VIDEO_H
-#define BOOT_VIDEO_H
-
-#include <linux/types.h>
-
-/* Enable autodetection of SVGA adapters and modes. */
-#undef CONFIG_VIDEO_SVGA
-
-/* Enable autodetection of VESA modes */
-#define CONFIG_VIDEO_VESA
-
-/* Retain screen contents when switching modes */
-#define CONFIG_VIDEO_RETAIN
-
-/* Force 400 scan lines for standard modes (hack to fix bad BIOS behaviour */
-#undef CONFIG_VIDEO_400_HACK
-
-/* This code uses an extended set of video mode numbers. These include:
- * Aliases for standard modes
- * NORMAL_VGA (-1)
- * EXTENDED_VGA (-2)
- * ASK_VGA (-3)
- * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
- * of compatibility when extending the table. These are between 0x00 and 0xff.
- */
-#define VIDEO_FIRST_MENU 0x0000
-
-/* Standard BIOS video modes (BIOS number + 0x0100) */
-#define VIDEO_FIRST_BIOS 0x0100
-
-/* VESA BIOS video modes (VESA number + 0x0200) */
-#define VIDEO_FIRST_VESA 0x0200
-
-/* Video7 special modes (BIOS number + 0x0900) */
-#define VIDEO_FIRST_V7 0x0900
-
-/* Special video modes */
-#define VIDEO_FIRST_SPECIAL 0x0f00
-#define VIDEO_80x25 0x0f00
-#define VIDEO_8POINT 0x0f01
-#define VIDEO_80x43 0x0f02
-#define VIDEO_80x28 0x0f03
-#define VIDEO_CURRENT_MODE 0x0f04
-#define VIDEO_80x30 0x0f05
-#define VIDEO_80x34 0x0f06
-#define VIDEO_80x60 0x0f07
-#define VIDEO_GFX_HACK 0x0f08
-#define VIDEO_LAST_SPECIAL 0x0f09
-
-/* Video modes given by resolution */
-#define VIDEO_FIRST_RESOLUTION 0x1000
-
-/* The "recalculate timings" flag */
-#define VIDEO_RECALC 0x8000
-
-/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
-#ifdef CONFIG_VIDEO_RETAIN
-void store_screen(void);
-#define DO_STORE() store_screen()
-#else
-#define DO_STORE() ((void)0)
-#endif /* CONFIG_VIDEO_RETAIN */
-
-/*
- * Mode table structures
- */
-
-struct mode_info {
- u16 mode; /* Mode number (vga= style) */
- u8 x, y; /* Width, height */
-};
-
-struct card_info {
- const char *card_name;
- int (*set_mode)(struct mode_info *mode);
- int (*probe)(void);
- struct mode_info *modes;
- int nmodes; /* Number of probed modes so far */
- int unsafe; /* Probing is unsafe, only do after "scan" */
- u16 xmode_first; /* Unprobed modes to try to call anyway */
- u16 xmode_n; /* Size of unprobed mode range */
-};
-
-#define __videocard struct card_info __attribute__((section(".videocards")))
-extern struct card_info video_cards[], video_cards_end[];
-
-int mode_defined(u16 mode); /* video.c */
-
-/* Basic video information */
-#define ADAPTER_CGA 0 /* CGA/MDA/HGC */
-#define ADAPTER_EGA 1
-#define ADAPTER_VGA 2
-
-extern int adapter;
-extern u16 video_segment;
-extern int force_x, force_y; /* Don't query the BIOS for cols/rows */
-extern int do_restore; /* Restore screen contents */
-extern int graphic_mode; /* Graphics mode with linear frame buffer */
-
-/*
- * int $0x10 is notorious for touching registers it shouldn't.
- * gcc doesn't like %ebp being clobbered, so define it as a push/pop
- * sequence here.
- */
-#define INT10 "pushl %%ebp; int $0x10; popl %%ebp"
-
-/* Accessing VGA indexed registers */
-static inline u8 in_idx(u16 port, u8 index)
-{
- outb(index, port);
- return inb(port+1);
-}
-
-static inline void out_idx(u8 v, u16 port, u8 index)
-{
- outw(index+(v << 8), port);
-}
-
-/* Writes a value to an indexed port and then reads the port again */
-static inline u8 tst_idx(u8 v, u16 port, u8 index)
-{
- out_idx(port, index, v);
- return in_idx(port, index);
-}
-
-/* Get the I/O port of the VGA CRTC */
-u16 vga_crtc(void); /* video-vga.c */
-
-#endif /* BOOT_VIDEO_H */
diff --git a/arch/i386/boot/voyager.c b/arch/i386/boot/voyager.c
deleted file mode 100644
index 9221614d0db8..000000000000
--- a/arch/i386/boot/voyager.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- * This file is part of the Linux kernel, and is made available under
- * the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * arch/i386/boot/voyager.c
- *
- * Get the Voyager config information
- */
-
-#include "boot.h"
-
-#ifdef CONFIG_X86_VOYAGER
-
-int query_voyager(void)
-{
- u8 err;
- u16 es, di;
- /* Abuse the apm_bios_info area for this */
- u8 *data_ptr = (u8 *)&boot_params.apm_bios_info;
-
- data_ptr[0] = 0xff; /* Flag on config not found(?) */
-
- asm("pushw %%es ; "
- "int $0x15 ; "
- "setc %0 ; "
- "movw %%es, %1 ; "
- "popw %%es"
- : "=qm" (err), "=rm" (es), "=D" (di)
- : "a" (0xffc0));
-
- if (err)
- return -1; /* Not Voyager */
-
- set_fs(es);
- copy_from_fs(data_ptr, di, 7); /* Table is 7 bytes apparently */
- return 0;
-}
-
-#endif /* CONFIG_X86_VOYAGER */