Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 58831
b: refs/heads/master
c: 068345f
h: refs/heads/master
i:
  58829: 07d7615
  58827: 2b8be67
  58823: a582432
  58815: 9db888c
v: v3
  • Loading branch information
Linus Torvalds committed Jul 12, 2007
1 parent 3d2bdaf commit 0c0854b
Show file tree
Hide file tree
Showing 77 changed files with 4,607 additions and 5,210 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0a85e9a271a754e352af8a8b625025017fd97449
refs/heads/master: 068345f4a873e8b0b511e8f94a595a20e176eeff
1 change: 1 addition & 0 deletions trunk/Documentation/i386/zero-page.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Offset Type Description
0x1d0 unsigned long EFI memory descriptor map pointer
0x1d4 unsigned long EFI memory descriptor map size
0x1e0 unsigned long ALT_MEM_K, alternative mem check, in Kb
0x1e4 unsigned long Scratch field for the kernel setup code
0x1e8 char number of entries in E820MAP (below)
0x1e9 unsigned char number of entries in EDDBUF (below)
0x1ea unsigned char number of entries in EDD_MBR_SIG_BUFFER (below)
Expand Down
4 changes: 2 additions & 2 deletions trunk/MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,8 @@ T: http://www.harbaum.org/till/i2c_tiny_usb
S: Maintained

i386 BOOT CODE
P: Riley H. Williams
M: Riley@Williams.Name
P: H. Peter Anvin
M: hpa@zytor.com
L: Linux-Kernel@vger.kernel.org
S: Maintained

Expand Down
6 changes: 3 additions & 3 deletions trunk/arch/i386/Kconfig.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ config X86_CMOV
depends on (MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7)
default y

config X86_MINIMUM_CPU_MODEL
config X86_MINIMUM_CPU_FAMILY
int
default "4" if X86_XADD || X86_CMPXCHG || X86_BSWAP
default "0"
default "4" if X86_XADD || X86_CMPXCHG || X86_BSWAP || X86_WP_WORKS_OK
default "3"

48 changes: 41 additions & 7 deletions trunk/arch/i386/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,74 @@ SVGA_MODE := -DSVGA_MODE=NORMAL_VGA

#RAMDISK := -DRAMDISK=512

targets := vmlinux.bin bootsect bootsect.o \
setup setup.o zImage bzImage
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)/bootsect $(obj)/setup \
cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
$(obj)/vmlinux.bin $(ROOT_DEV) > $@

$(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
$(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)

LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary
LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext
SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))

$(obj)/setup $(obj)/bootsect: %: %.o FORCE
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) $@

Expand Down
161 changes: 161 additions & 0 deletions trunk/arch/i386/boot/a20.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/* -*- 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
}
97 changes: 97 additions & 0 deletions trunk/arch/i386/boot/apm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/* -*- 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
Loading

0 comments on commit 0c0854b

Please sign in to comment.