summaryrefslogtreecommitdiff
path: root/lib_i386
diff options
context:
space:
mode:
Diffstat (limited to 'lib_i386')
-rw-r--r--lib_i386/Makefile6
-rw-r--r--lib_i386/bios.S48
-rw-r--r--lib_i386/bios.h16
-rw-r--r--lib_i386/bios_pci.S110
-rw-r--r--lib_i386/bios_setup.c61
-rw-r--r--lib_i386/board.c58
-rw-r--r--lib_i386/i386_linux.c59
-rw-r--r--lib_i386/pci.c69
-rw-r--r--lib_i386/realmode.c29
-rw-r--r--lib_i386/realmode_switch.S100
-rw-r--r--lib_i386/video.c109
-rw-r--r--lib_i386/video_bios.c86
-rw-r--r--lib_i386/zimage.c143
13 files changed, 440 insertions, 454 deletions
diff --git a/lib_i386/Makefile b/lib_i386/Makefile
index 47c5d2c..e5925e5 100644
--- a/lib_i386/Makefile
+++ b/lib_i386/Makefile
@@ -25,11 +25,11 @@ include $(TOPDIR)/config.mk
LIB = lib$(ARCH).a
-AOBJS = bios.o bios_pci.o realmode_switch.o
+AOBJS = bios.o bios_pci.o realmode_switch.o
COBJS = board.o bios_setup.o i386_linux.o zimage.o realmode.o \
- pci_type1.o pci.o video_bios.o video.o
-
+ pci_type1.o pci.o video_bios.o video.o
+
OBJS = $(AOBJS) $(COBJS)
$(LIB): .depend $(OBJS)
diff --git a/lib_i386/bios.S b/lib_i386/bios.S
index ce6e94c..4606419 100644
--- a/lib_i386/bios.S
+++ b/lib_i386/bios.S
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
- *
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -46,9 +46,9 @@
.section .bios, "ax"
.code16
.org 0
- /* a call to f000:0 should warmboot */
+ /* a call to f000:0 should warmboot */
jmp realmode_reset
-
+
.globl rm_int00
rm_int00:
pushw $0
@@ -181,18 +181,18 @@ rm_int1f:
rm_def_int:
iret
-
+
/*
* All interrupt jumptable entries jump to here
* after pushing the interrupt vector number onto the
* stack.
*/
any_interrupt16:
- MAKE_BIOS_STACK
+ MAKE_BIOS_STACK
gs movw OFFS_VECTOR(%bp), %ax
cmpw $0x10, %ax
- je Lint_10h
+ je Lint_10h
cmpw $0x11, %ax
je Lint_11h
cmpw $0x12, %ax
@@ -210,10 +210,10 @@ gs movw OFFS_VECTOR(%bp), %ax
Lint_10h: /* VGA BIOS services */
call bios_10h
jmp Lout
-Lint_11h:
+Lint_11h:
call bios_11h
jmp Lout
-Lint_12h:
+Lint_12h:
call bios_12h
jmp Lout
Lint_13h: /* BIOS disk services */
@@ -228,13 +228,13 @@ Lint_16h: /* keyboard services */
Lint_1ah: /* PCI bios */
call bios_1ah
jmp Lout
-Lout:
+Lout:
cmpw $0, %ax
je Lhandeled
-
+
/* Insert code for unhandeled INTs here.
*
- * ROLO prints a message to the console
+ * ROLO prints a message to the console
* (we could do that but then we're in 16bit mode
* so we'll have to get back into 32bit mode
* to use the console I/O routines (if we do this
@@ -286,7 +286,7 @@ gs movw $0x10, OFFS_BX(%bp) /* indicate CGA/MDA/HGA */
bios_11h:
cs movw bios_equipment, %ax
-gs movw %ax, OFFS_AX(%bp)
+gs movw %ax, OFFS_AX(%bp)
xorw %ax, %ax
ret
@@ -327,14 +327,13 @@ gs movw OFFS_AX(%bp), %ax
je Lfunc_15h
movw $0xffff, %ax
ret
-Lfunc_15h:
+Lfunc_15h:
gs movw OFFS_AX(%bp), %ax
andw $0xff, %ax /* return AH=0->drive not present */
gs movw %ax, OFFS_AX(%bp)
xorw %ax, %ax
ret
-
-
+
/*
***********************************************************
@@ -359,7 +358,7 @@ gs movw OFFS_FLAGS(%bp), %ax
gs movw %ax, OFFS_FLAGS(%bp)
xorw %ax, %ax
ret
-
+
Lfunc_e8h:
gs movw OFFS_AX(%bp), %ax
andw $0xff, %ax
@@ -370,31 +369,31 @@ gs movw OFFS_FLAGS(%bp), %ax
gs movw %ax, OFFS_FLAGS(%bp)
xorw %ax, %ax
ret
-
+
Lfunc_e801h: /* Get memory size for >64M Configurations */
cs movw ram_in_64kb_chunks, %ax
cmpw $0x100, %ax
ja e801_more_than_16mb
shlw $6, %ax /* multiply by 64 */
subw $0x400, %ax /* 1st meg does not count */
-
+
gs movw %ax, OFFS_AX(%bp) /* return memory size between 1M and 16M in 1kb chunks in AX and CX */
gs movw %ax, OFFS_CX(%bp)
gs movw $0, OFFS_BX(%bp) /* set BX and DX to 0*/
-gs movw $0, OFFS_DX(%bp)
+gs movw $0, OFFS_DX(%bp)
gs movw OFFS_FLAGS(%bp), %ax
andw $0xfffe, %ax /* clear carry -- function succeeded */
gs movw %ax, OFFS_FLAGS(%bp)
xorw %ax, %ax
ret
-
+
e801_more_than_16mb:
- subw $0x100, %ax /* subtract 16MB */
-
+ subw $0x100, %ax /* subtract 16MB */
+
gs movw $0x3c00, OFFS_AX(%bp) /* return 0x3c00 (16MB-1MB) in AX and CX */
gs movw $0x3c00, OFFS_CX(%bp)
gs movw %ax, OFFS_BX(%bp) /* set BX and DX to number of 64kb chunks above 16MB */
-gs movw %ax, OFFS_DX(%bp)
+gs movw %ax, OFFS_DX(%bp)
gs movw OFFS_FLAGS(%bp), %ax
andw $0xfffe, %ax /* clear carry -- function succeeded */
@@ -410,7 +409,7 @@ cs movw ram_in_64kb_chunks, %ax
b88_not_more_than16:
shlw $6, %ax
subw $0x400, %ax /* 1st meg does not count */
-
+
gs movw %ax, OFFS_AX(%bp) /* return number of kilobytes between 16MB and 16MB in ax */
gs movw OFFS_FLAGS(%bp), %ax
@@ -461,4 +460,3 @@ ram_in_64kb_chunks:
.globl bios_equipment
bios_equipment:
.word 0
-
diff --git a/lib_i386/bios.h b/lib_i386/bios.h
index 876fe31..59143dd 100644
--- a/lib_i386/bios.h
+++ b/lib_i386/bios.h
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
- *
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -28,9 +28,9 @@
#define OFFS_GS 2 /* 16bit */
#define OFFS_DS 4 /* 16bit */
#define OFFS_EDI 6 /* 32bit */
-#define OFFS_DI 6 /* low 16 bits of EDI */
+#define OFFS_DI 6 /* low 16 bits of EDI */
#define OFFS_ESI 10 /* 32bit */
-#define OFFS_SI 10 /* low 16 bits of ESI */
+#define OFFS_SI 10 /* low 16 bits of ESI */
#define OFFS_EBP 14 /* 32bit */
#define OFFS_BP 14 /* low 16 bits of EBP */
#define OFFS_ESP 18 /* 32bit */
@@ -54,7 +54,7 @@
#define OFFS_VECTOR 38 /* 16bit */
#define OFFS_IP 40 /* 16bit */
#define OFFS_CS 42 /* 16bit */
-#define OFFS_FLAGS 44 /* 16bit */
+#define OFFS_FLAGS 44 /* 16bit */
#define SEGMENT 0x40
#define STACK 0x800 /* stack at 0x40:0x800 -> 0x800 */
@@ -63,9 +63,9 @@
/* save some segments */
/* save callers stack segment .. */
/* ... in gs */
- /* setup my segments */
- /* setup BIOS stackpointer */
-
+ /* setup my segments */
+ /* setup BIOS stackpointer */
+
#define MAKE_BIOS_STACK \
pushal ; \
pushw %ds ; \
@@ -89,6 +89,6 @@
popw %gs ; \
popw %ds ; \
\
- popal /* restore GP registers */
+ popal /* restore GP registers */
#endif
diff --git a/lib_i386/bios_pci.S b/lib_i386/bios_pci.S
index e53791a..b57b726 100644
--- a/lib_i386/bios_pci.S
+++ b/lib_i386/bios_pci.S
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
- *
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -23,10 +23,10 @@
/*
* x86 realmode assembly implementation of a PCI BIOS
- * for platforms that use one PCI hose and configuration
+ * for platforms that use one PCI hose and configuration
* access type 1. (The common case for low-end PC's)
*/
-
+
#include "bios.h"
#define PCI_BIOS_DEBUG
@@ -39,8 +39,8 @@ realmode_pci_bios_call_entry:
call realmode_pci_bios
RESTORE_CALLERS_STACK
ret
-
-
+
+
.globl realmode_pci_bios
realmode_pci_bios:
gs movw OFFS_AX(%bp), %ax
@@ -69,7 +69,7 @@ gs movw OFFS_AX(%bp), %ax
cmpb $15, %al
je pci_bios_set_irq
jmp unknown_function
-
+
/*****************************************************************************/
pci_bios_present:
@@ -77,31 +77,31 @@ pci_bios_present:
cs incl num_pci_bios_present
#endif
movl $0x20494350, %eax
-gs movl %eax, OFFS_EDX(%bp)
+gs movl %eax, OFFS_EDX(%bp)
movb $0x01, %al
-gs movb %al, OFFS_AL(%bp) /* We support cfg type 1 */
- movw $0x0210, %ax /* version 2.10 */
-gs movw %ax, OFFS_BX(%bp)
+gs movb %al, OFFS_AL(%bp) /* We support cfg type 1 */
+ movw $0x0210, %ax /* version 2.10 */
+gs movw %ax, OFFS_BX(%bp)
cs movb pci_last_bus, %al /* last bus number */
-gs movb %al, OFFS_CL(%bp)
+gs movb %al, OFFS_CL(%bp)
jmp clear_carry
/*****************************************************************************/
/* device 0-31, function 0-7 */
-pci_bios_find_device:
+pci_bios_find_device:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_find_device
#endif
-gs movw OFFS_CX(%bp), %di
+gs movw OFFS_CX(%bp), %di
shll $16, %edi
-gs movw OFFS_DX(%bp), %di /* edi now holds device in upper 16
- * bits and vendor in lower 16 bits */
-gs movw OFFS_SI(%bp), %si
+gs movw OFFS_DX(%bp), %di /* edi now holds device in upper 16
+ * bits and vendor in lower 16 bits */
+gs movw OFFS_SI(%bp), %si
xorw %bx, %bx /* start at bus 0 dev 0 function 0 */
-pfd_loop:
- xorw %ax, %ax /* dword 0 is vendor/device */
- call __pci_bios_select_register
+pfd_loop:
+ xorw %ax, %ax /* dword 0 is vendor/device */
+ call __pci_bios_select_register
movw $0xcfc, %dx
inl %dx, %eax
cmpl %edi, %eax /* our device ? */
@@ -111,8 +111,8 @@ pfd_next_dev:
movw %bx, %ax
andw $3, %ax
jnz pfd_function_not_zero
- movw $0x000c, %ax
- call __pci_bios_select_register
+ movw $0x000c, %ax
+ call __pci_bios_select_register
movw $0xcfe, %dx
inb %dx, %al
andb $0x80, %al
@@ -121,11 +121,11 @@ pfd_function_not_zero:
incw %bx /* next function, overflows in to
* device number, then bus number */
jmp pfd_check_bus
-
+
pfd_not_multi_function:
andw $0xfff8, %bx /* remove function bits */
addw $0x0008, %bx /* next device, overflows in to bus number */
-pfd_check_bus:
+pfd_check_bus:
cs movb pci_last_bus, %ah
cmpb %ah, %bh
ja pfd_not_found
@@ -136,7 +136,7 @@ pfd_found_one:
jmp pfd_next_dev
pfd_done:
-gs movw %bx, OFFS_BX(%bp)
+gs movw %bx, OFFS_BX(%bp)
jmp clear_carry
pfd_not_found:
@@ -149,13 +149,13 @@ pci_bios_find_class:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_find_class
#endif
-gs movl OFFS_ECX(%bp), %edi
- andl $0x00ffffff, %edi /* edi now holds class-code in lower 24 bits */
-gs movw OFFS_SI(%bp), %si
+gs movl OFFS_ECX(%bp), %edi
+ andl $0x00ffffff, %edi /* edi now holds class-code in lower 24 bits */
+gs movw OFFS_SI(%bp), %si
xorw %bx, %bx /* start at bus 0 dev 0 function 0 */
-pfc_loop:
- movw $8, %ax /* dword 8 is class-code high 24bits */
- call __pci_bios_select_register
+pfc_loop:
+ movw $8, %ax /* dword 8 is class-code high 24bits */
+ call __pci_bios_select_register
movw $0xcfc, %dx
inl %dx, %eax
shrl $8, %eax
@@ -166,8 +166,8 @@ pfc_next_dev:
/* check for multi function devices */
andw $3, %bx
jnz pfc_function_not_zero
- movw $0x000c, %ax
- call __pci_bios_select_register
+ movw $0x000c, %ax
+ call __pci_bios_select_register
movw $0xcfe, %dx
inb %dx, %al
andb $0x80, %al
@@ -176,11 +176,11 @@ pfc_function_not_zero:
incw %bx /* next function, overflows in to
* device number, then bus number */
jmp pfc_check_bus
-
+
pfc_not_multi_function:
andw $0xfff8, %bx /* remove function bits */
addw $0x0008, %bx /* next device, overflows in to bus number */
-pfc_check_bus:
+pfc_check_bus:
cs movb pci_last_bus, %ah
cmpb %ah, %bh
ja pfc_not_found
@@ -191,7 +191,7 @@ pfc_found_one:
jmp pfc_next_dev
pfc_done:
-gs movw %bx, OFFS_BX(%bp)
+gs movw %bx, OFFS_BX(%bp)
jmp clear_carry
pfc_not_found:
@@ -206,24 +206,24 @@ cs incl num_pci_bios_generate_special_cycle
#endif
movb $0x81, %ah /* function not supported */
jmp set_carry
-
+
/*****************************************************************************/
-pci_bios_read_cfg_byte:
+pci_bios_read_cfg_byte:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_read_cfg_byte
#endif
- call pci_bios_select_register
+ call pci_bios_select_register
gs movw OFFS_DI(%bp), %dx
andw $3, %dx
addw $0xcfc, %dx
inb %dx, %al
-gs movb %al, OFFS_CL(%bp)
+gs movb %al, OFFS_CL(%bp)
jmp clear_carry
/*****************************************************************************/
-pci_bios_read_cfg_word:
+pci_bios_read_cfg_word:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_read_cfg_word
#endif
@@ -232,20 +232,20 @@ gs movw OFFS_DI(%bp), %dx
andw $2, %dx
addw $0xcfc, %dx
inw %dx, %ax
-gs movw %ax, OFFS_CX(%bp)
+gs movw %ax, OFFS_CX(%bp)
jmp clear_carry
/*****************************************************************************/
-pci_bios_read_cfg_dword:
+pci_bios_read_cfg_dword:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_read_cfg_dword
#endif
call pci_bios_select_register
movw $0xcfc, %dx
inl %dx, %eax
-gs movl %eax, OFFS_ECX(%bp)
+gs movl %eax, OFFS_ECX(%bp)
jmp clear_carry
/*****************************************************************************/
@@ -254,35 +254,35 @@ pci_bios_write_cfg_byte:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_write_cfg_byte
#endif
- call pci_bios_select_register
+ call pci_bios_select_register
gs movw OFFS_DI(%bp), %dx
gs movb OFFS_CL(%bp), %al
andw $3, %dx
addw $0xcfc, %dx
outb %al, %dx
jmp clear_carry
-
+
/*****************************************************************************/
pci_bios_write_cfg_word:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_write_cfg_word
#endif
- call pci_bios_select_register
+ call pci_bios_select_register
gs movw OFFS_DI(%bp), %dx
gs movw OFFS_CX(%bp), %ax
andw $2, %dx
addw $0xcfc, %dx
outw %ax, %dx
jmp clear_carry
-
+
/*****************************************************************************/
pci_bios_write_cfg_dword:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_write_cfg_dword
#endif
- call pci_bios_select_register
+ call pci_bios_select_register
gs movl OFFS_ECX(%bp), %eax
movw $0xcfc, %dx
outl %eax, %dx
@@ -296,7 +296,7 @@ cs incl num_pci_bios_get_irq_routing
#endif
movb $0x81, %ah /* function not supported */
jmp set_carry
-
+
/*****************************************************************************/
pci_bios_set_irq:
@@ -316,7 +316,7 @@ cs incl num_pci_bios_unknown_function
jmp set_carry
/*****************************************************************************/
-
+
pci_bios_select_register:
gs movw OFFS_BX(%bp), %bx
gs movw OFFS_DI(%bp), %ax
@@ -339,11 +339,11 @@ gs movw OFFS_FLAGS(%bp), %ax
andw $0xfffe, %ax /* clear carry -- function succeeded */
gs movw %ax, OFFS_FLAGS(%bp)
xorw %ax, %ax
-gs movb %ah, OFFS_AH(%bp)
+gs movb %ah, OFFS_AH(%bp)
ret
set_carry:
-gs movb %ah, OFFS_AH(%bp)
+gs movb %ah, OFFS_AH(%bp)
gs movw OFFS_FLAGS(%bp), %ax
orw $1, %ax /* return carry -- function not supported */
gs movw %ax, OFFS_FLAGS(%bp)
@@ -360,7 +360,7 @@ pci_last_bus:
.globl num_pci_bios_present
num_pci_bios_present:
.long 0
-
+
.globl num_pci_bios_find_device
num_pci_bios_find_device:
.long 0
@@ -370,9 +370,9 @@ num_pci_bios_find_class:
.long 0
.globl num_pci_bios_generate_special_cycle
-num_pci_bios_generate_special_cycle:
+num_pci_bios_generate_special_cycle:
.long 0
-
+
.globl num_pci_bios_read_cfg_byte
num_pci_bios_read_cfg_byte:
.long 0
diff --git a/lib_i386/bios_setup.c b/lib_i386/bios_setup.c
index 3da7858..bc97815 100644
--- a/lib_i386/bios_setup.c
+++ b/lib_i386/bios_setup.c
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
- *
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -87,27 +87,27 @@ extern void *rm_def_int;
extern void *realmode_reset;
extern void *realmode_pci_bios_call_entry;
-static int set_jmp_vector(int entry_point, void *target)
+static int set_jmp_vector(int entry_point, void *target)
{
if (entry_point & ~0xffff) {
return -1;
}
-
+
if (((u32)target-0xf0000) & ~0xffff) {
return -1;
}
printf("set_jmp_vector: 0xf000:%04x -> %p\n",
entry_point, target);
-
+
/* jmp opcode */
writeb(0xea, 0xf0000 + entry_point);
-
+
/* offset */
writew(((u32)target-0xf0000), 0xf0000 + entry_point + 1);
-
+
/* segment */
writew(0xf000, 0xf0000 + entry_point + 3);
-
+
return 0;
}
@@ -123,40 +123,40 @@ static void setvector(int vector, u16 segment, void *handler)
u16 *ptr = (u16*)(vector*4);
ptr[0] = ((u32)handler - (segment << 4))&0xffff;
ptr[1] = segment;
-
-#if 0
+
+#if 0
printf("setvector: int%02x -> %04x:%04x\n",
vector, ptr[1], ptr[0]);
-#endif
+#endif
}
-#define RELOC_16_LONG(seg, off) *(u32*)(seg << 4 | (u32)&off)
-#define RELOC_16_WORD(seg, off) *(u16*)(seg << 4 | (u32)&off)
-#define RELOC_16_BYTE(seg, off) *(u8*)(seg << 4 | (u32)&off)
+#define RELOC_16_LONG(seg, off) *(u32*)(seg << 4 | (u32)&off)
+#define RELOC_16_WORD(seg, off) *(u16*)(seg << 4 | (u32)&off)
+#define RELOC_16_BYTE(seg, off) *(u8*)(seg << 4 | (u32)&off)
int bios_setup(void)
{
DECLARE_GLOBAL_DATA_PTR;
- static int done=0;
+ static int done=0;
int vector;
struct pci_controller *pri_hose;
-
+
if (done) {
return 0;
}
done = 1;
-
+
if (i386boot_bios_size > 65536) {
- printf("BIOS too large (%ld bytes, max is 65536)\n",
+ printf("BIOS too large (%ld bytes, max is 65536)\n",
i386boot_bios_size);
return -1;
}
-
+
memcpy(BIOS_BASE, (void*)i386boot_bios, i386boot_bios_size);
/* clear bda */
memset(BIOS_DATA, 0, BIOS_DATA_SIZE);
-
+
/* enter some values to the bda */
writew(0x3f8, BIOS_DATA); /* com1 addr */
writew(0x2f8, BIOS_DATA+2); /* com2 addr */
@@ -169,12 +169,12 @@ int bios_setup(void)
*/
writew(0, BIOS_DATA+0x13); /* base memory size */
-
- /* setup realmode interrupt vectors */
+
+ /* setup realmode interrupt vectors */
for (vector = 0; vector < NUMVECTS; vector++) {
setvector(vector, BIOS_CS, &rm_def_int);
}
-
+
setvector(0x00, BIOS_CS, &rm_int00);
setvector(0x01, BIOS_CS, &rm_int01);
setvector(0x02, BIOS_CS, &rm_int02);
@@ -210,25 +210,24 @@ int bios_setup(void)
set_jmp_vector(0xfff0, &realmode_reset);
set_jmp_vector(0xfe6e, &realmode_pci_bios_call_entry);
-
+
/* fill in data area */
RELOC_16_WORD(0xf000, ram_in_64kb_chunks) = gd->ram_size >> 16;
RELOC_16_WORD(0xf000, bios_equipment) = 0; /* FixMe */
-
+
/* If we assume only one PCI hose, this PCI hose
- * will own PCI bus #0, and the last PCI bus of
- * that PCI hose will be the last PCI bus in the
- * system.
+ * will own PCI bus #0, and the last PCI bus of
+ * that PCI hose will be the last PCI bus in the
+ * system.
* (This, ofcause break on multi hose systems,
- * but our PCI BIOS only support one hose anyway)
+ * but our PCI BIOS only support one hose anyway)
*/
pri_hose = pci_bus_to_hose(0);
if (NULL != pri_hose) {
- /* fill in last pci bus number for use by the realmode
+ /* fill in last pci bus number for use by the realmode
* PCI BIOS */
RELOC_16_BYTE(0xf000, pci_last_bus) = pri_hose->last_busno;
}
-
+
return 0;
}
-
diff --git a/lib_i386/board.c b/lib_i386/board.c
index 85d7d7f..5d1c1fb 100644
--- a/lib_i386/board.c
+++ b/lib_i386/board.c
@@ -1,10 +1,10 @@
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
- *
+ *
* (C) Copyright 2002
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
+ *
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
@@ -39,18 +39,18 @@
#include <ide.h>
#include <asm/u-boot-i386.h>
-extern long _i386boot_start;
-extern long _i386boot_end;
+extern long _i386boot_start;
+extern long _i386boot_end;
extern long _i386boot_romdata_start;
-extern long _i386boot_romdata_dest;
-extern long _i386boot_romdata_size;
-extern long _i386boot_bss_start;
-extern long _i386boot_bss_size;
+extern long _i386boot_romdata_dest;
+extern long _i386boot_romdata_size;
+extern long _i386boot_bss_start;
+extern long _i386boot_bss_size;
-extern long _i386boot_realmode;
+extern long _i386boot_realmode;
extern long _i386boot_realmode_size;
-extern long _i386boot_bios;
-extern long _i386boot_bios_size;
+extern long _i386boot_bios;
+extern long _i386boot_bios_size;
/* The symbols defined by the linker script becomes pointers
* which is somewhat inconveient ... */
@@ -82,15 +82,15 @@ static ulong mem_malloc_brk = 0;
static int mem_malloc_init(void)
{
DECLARE_GLOBAL_DATA_PTR;
-
+
/* start malloc area right after the stack */
- mem_malloc_start = i386boot_bss_start +
+ mem_malloc_start = i386boot_bss_start +
i386boot_bss_size + CFG_STACK_SIZE;
mem_malloc_start = (mem_malloc_start+3)&~3;
-
+
/* Use all available RAM for malloc() */
mem_malloc_end = gd->ram_size;
-
+
mem_malloc_brk = mem_malloc_start;
return 0;
@@ -162,9 +162,9 @@ static int display_banner (void)
i386boot_start, i386boot_romdata_start-1,
i386boot_romdata_dest, i386boot_romdata_dest+i386boot_romdata_size-1,
i386boot_bss_start, i386boot_bss_start+i386boot_bss_size-1,
- i386boot_bss_start+i386boot_bss_size,
+ i386boot_bss_start+i386boot_bss_size,
i386boot_bss_start+i386boot_bss_size+CFG_STACK_SIZE-1);
-
+
return (0);
}
@@ -187,7 +187,7 @@ static int display_dram_config (void)
printf ("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
print_size (gd->bd->bi_dram[i].size, "\n");
}
-
+
return (0);
}
@@ -198,7 +198,6 @@ static void display_flash_config (ulong size)
}
-
/*
* Breath some life into the board...
*
@@ -230,7 +229,7 @@ init_fnc_t *init_sequence[] = {
dram_init, /* configure available RAM banks */
mem_malloc_init, /* dependant on dram_init */
interrupt_init, /* set up exceptions */
- timer_init,
+ timer_init,
serial_init,
env_init, /* initialize environment */
init_baudrate, /* initialze baudrate settings */
@@ -252,18 +251,18 @@ void start_i386boot (void)
static gd_t gd_data;
static bd_t bd_data;
init_fnc_t **init_fnc_ptr;
-
+
show_boot_progress(0x21);
gd = global_data = &gd_data;
-
+
memset (gd, 0, sizeof (gd_t));
gd->bd = &bd_data;
memset (gd->bd, 0, sizeof (bd_t));
show_boot_progress(0x22);
gd->baudrate = CONFIG_BAUDRATE;
-
+
for (init_fnc_ptr = init_sequence, i=0; *init_fnc_ptr; ++init_fnc_ptr, i++) {
show_boot_progress(0xa130|i);
@@ -320,7 +319,7 @@ void start_i386boot (void)
/* allocate syscalls table (console_init_r will fill it in */
syscall_tbl = (void **) malloc (NR_SYSCALLS * sizeof (void *));
memset(syscall_tbl, 0, NR_SYSCALLS * sizeof (void *));
-
+
/* Initialize the console (after the relocation and devices init) */
console_init_r();
syscalls_init();
@@ -361,7 +360,7 @@ void start_i386boot (void)
#ifdef CONFIG_SERIAL_SOFTWARE_FIFO
serial_buffered_init();
#endif
-
+
#ifdef CONFIG_STATUS_LED
status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
#endif
@@ -417,7 +416,6 @@ void start_i386boot (void)
#endif
-
#ifdef CONFIG_POST
post_run (NULL, POST_RAM | post_bootmode_get(0));
if (post_bootmode_get(0) & POST_POWERFAIL) {
@@ -425,10 +423,10 @@ void start_i386boot (void)
board_poweroff();
}
#endif
-
-
+
+
show_boot_progress(0x29);
-
+
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;) {
main_loop();
@@ -442,5 +440,3 @@ void hang (void)
puts ("### ERROR ### Please RESET the board ###\n");
for (;;);
}
-
-
diff --git a/lib_i386/i386_linux.c b/lib_i386/i386_linux.c
index 5a596ff..e5d8eea 100644
--- a/lib_i386/i386_linux.c
+++ b/lib_i386/i386_linux.c
@@ -23,12 +23,13 @@
#include <common.h>
#include <command.h>
-#include <cmd_boot.h>
#include <image.h>
#include <zlib.h>
#include <asm/byteorder.h>
#include <asm/zimage.h>
+/*cmd_boot.c*/
+extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
extern image_header_t header; /* from cmd_bootm.c */
@@ -39,7 +40,7 @@ image_header_t *fake_header(image_header_t *hdr, void *ptr, int size)
if (NULL != fake_zimage_header(hdr, ptr, size)) {
return hdr;
}
-
+
return NULL;
}
@@ -48,47 +49,47 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ulong addr, ulong *len_ptr, int verify)
{
void *base_ptr;
-
+
ulong len = 0, checksum;
ulong initrd_start, initrd_end;
ulong data;
image_header_t *hdr = &header;
-
+
/*
* Check if there is an initrd image
*/
if (argc >= 3) {
addr = simple_strtoul(argv[2], NULL, 16);
-
+
printf ("## Loading Ramdisk Image at %08lx ...\n", addr);
-
+
/* Copy header so we can blank CRC field for re-calculation */
memcpy (&header, (char *)addr, sizeof(image_header_t));
-
+
if (ntohl(hdr->ih_magic) != IH_MAGIC) {
printf ("Bad Magic Number\n");
do_reset (cmdtp, flag, argc, argv);
}
-
+
data = (ulong)&header;
len = sizeof(image_header_t);
-
+
checksum = ntohl(hdr->ih_hcrc);
hdr->ih_hcrc = 0;
-
+
if (crc32 (0, (char *)data, len) != checksum) {
printf ("Bad Header Checksum\n");
do_reset (cmdtp, flag, argc, argv);
}
-
+
print_image_hdr (hdr);
-
+
data = addr + sizeof(image_header_t);
len = ntohl(hdr->ih_size);
-
+
if (verify) {
ulong csum = 0;
-
+
printf (" Verifying Checksum ... ");
csum = crc32 (0, (char *)data, len);
if (csum != ntohl(hdr->ih_dcrc)) {
@@ -97,21 +98,21 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
}
printf ("OK\n");
}
-
+
if ((hdr->ih_os != IH_OS_LINUX) ||
(hdr->ih_arch != IH_CPU_I386) ||
(hdr->ih_type != IH_TYPE_RAMDISK) ) {
printf ("No Linux i386 Ramdisk Image\n");
do_reset (cmdtp, flag, argc, argv);
}
-
+
/*
* Now check if we have a multifile image
*/
} else if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1])) {
ulong tail = ntohl(len_ptr[0]) % 4;
int i;
-
+
/* skip kernel length and terminator */
data = (ulong)(&len_ptr[2]);
/* skip any additional image length fields */
@@ -122,22 +123,22 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if (tail) {
data += 4 - tail;
}
-
+
len = ntohl(len_ptr[1]);
-
+
} else {
/*
* no initrd image
*/
data = 0;
}
-
+
#ifdef DEBUG
if (!data) {
printf ("No initrd\n");
}
#endif
-
+
if (data) {
initrd_start = data;
initrd_end = initrd_start + len;
@@ -149,26 +150,24 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
initrd_start = 0;
initrd_end = 0;
}
-
- base_ptr = load_zimage((void*)addr + sizeof(image_header_t), ntohl(hdr->ih_size),
+
+ base_ptr = load_zimage((void*)addr + sizeof(image_header_t), ntohl(hdr->ih_size),
initrd_start, initrd_end-initrd_start, 0);
if (NULL == base_ptr) {
printf ("## Kernel loading failed ...\n");
do_reset(cmdtp, flag, argc, argv);
-
+
}
-
+
#ifdef DEBUG
printf ("## Transferring control to Linux (at address %08x) ...\n",
(u32)base_ptr);
#endif
-
+
/* we assume that the kernel is in place */
printf("\nStarting kernel ...\n\n");
-
- boot_zimage(base_ptr);
-
-}
+ boot_zimage(base_ptr);
+}
diff --git a/lib_i386/pci.c b/lib_i386/pci.c
index acd1d25..a7f16aa 100644
--- a/lib_i386/pci.c
+++ b/lib_i386/pci.c
@@ -21,24 +21,24 @@
* MA 02111-1307 USA
*/
-#include <common.h>
-#include <pci.h>
-#include <asm/io.h>
-#include <asm/pci.h>
+#include <common.h>
+#include <pci.h>
+#include <asm/io.h>
+#include <asm/pci.h>
#ifdef CONFIG_PCI
#undef PCI_ROM_SCAN_VERBOSE
-int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
+int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
{
struct pci_controller *hose;
int res = -1;
int i;
-
+
u32 rom_addr;
u32 addr_reg;
u32 size;
-
+
u16 vendor;
u16 device;
u32 class_code;
@@ -47,18 +47,18 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
#if 0
printf("pci_shadow_rom() asked to shadow device %x to %x\n",
dev, (u32)dest);
-#endif
+#endif
pci_read_config_word(dev, PCI_VENDOR_ID, &vendor);
pci_read_config_word(dev, PCI_DEVICE_ID, &device);
pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_code);
-
+
class_code &= 0xffffff00;
class_code >>= 8;
-#if 0
+#if 0
printf("PCI Header Vendor %04x device %04x class %06x\n",
vendor, device, class_code);
-#endif
+#endif
/* Enable the rom addess decoder */
pci_write_config_dword(dev, PCI_ROM_ADDRESS, PCI_ROM_ADDRESS_MASK);
pci_read_config_dword(dev, PCI_ROM_ADDRESS, &addr_reg);
@@ -68,40 +68,39 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
printf("pci_chadow_rom: device do not seem to have a rom\n");
return -1;
}
-
- size = (~(addr_reg&PCI_ROM_ADDRESS_MASK))+1;
-
-#if 0
+
+ size = (~(addr_reg&PCI_ROM_ADDRESS_MASK))+1;
+
+#if 0
printf("ROM is %d bytes\n", size);
-#endif
+#endif
rom_addr = pci_get_rom_window(hose, size);
-#if 0
+#if 0
printf("ROM mapped at %x \n", rom_addr);
-#endif
- pci_write_config_dword(dev, PCI_ROM_ADDRESS,
+#endif
+ pci_write_config_dword(dev, PCI_ROM_ADDRESS,
pci_phys_to_mem(dev, rom_addr)
|PCI_ROM_ADDRESS_ENABLE);
-
for (i=rom_addr;i<rom_addr+size; i+=512) {
-
-
+
+
if (readw(i) == 0xaa55) {
u32 pci_data;
#ifdef PCI_ROM_SCAN_VERBOSE
printf("ROM signature found\n");
-#endif
+#endif
pci_data = readw(0x18+i);
pci_data += i;
-
+
if (0==memcmp((void*)pci_data, "PCIR", 4)) {
-#ifdef PCI_ROM_SCAN_VERBOSE
+#ifdef PCI_ROM_SCAN_VERBOSE
printf("Fount PCI rom image at offset %d\n", i-rom_addr);
printf("Vendor %04x device %04x class %06x\n",
readw(pci_data+4), readw(pci_data+6),
readl(pci_data+0x0d)&0xffffff);
- printf("%s\n",
+ printf("%s\n",
(readw(pci_data+0x15) &0x80)?
"Last image":"More images follow");
switch (readb(pci_data+0x14)) {
@@ -116,38 +115,38 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
break;
}
printf("Image size %d\n", readw(pci_data+0x10) * 512);
-#endif
+#endif
/* FixMe: I think we should compare the class code
* bytes as well but I have no reference on the
* exact order of these bytes in the PCI ROM header */
- if (readw(pci_data+4) == vendor &&
+ if (readw(pci_data+4) == vendor &&
readw(pci_data+6) == device &&
/* (readl(pci_data+0x0d)&0xffffff) == class_code && */
readb(pci_data+0x14) == 0 /* x86 code image */ ) {
-#ifdef PCI_ROM_SCAN_VERBOSE
+#ifdef PCI_ROM_SCAN_VERBOSE
printf("Suitable ROM image found, copying\n");
-#endif
+#endif
memmove(dest, (void*)rom_addr, readw(pci_data+0x10) * 512);
res = 0;
break;
-
+
}
if (readw(pci_data+0x15) &0x80) {
break;
}
}
}
-
+
}
-
+
#ifdef PCI_ROM_SCAN_VERBOSE
if (res) {
printf("No suitable image found\n");
}
-#endif
+#endif
/* disable PAR register and PCI device ROM address devocer */
pci_remove_rom_window(hose, rom_addr);
-
+
pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0);
return res;
diff --git a/lib_i386/realmode.c b/lib_i386/realmode.c
index d7bb81c..6cf2738 100644
--- a/lib_i386/realmode.c
+++ b/lib_i386/realmode.c
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
- *
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -37,39 +37,39 @@ int realmode_setup(void)
{
/* copy the realmode switch code */
if (i386boot_realmode_size > (REALMODE_MAILBOX-REALMODE_BASE)) {
- printf("realmode switch too large (%ld bytes, max is %d)\n",
+ printf("realmode switch too large (%ld bytes, max is %d)\n",
i386boot_realmode_size, (REALMODE_MAILBOX-REALMODE_BASE));
return -1;
}
-
+
memcpy(REALMODE_BASE, (void*)i386boot_realmode, i386boot_realmode_size);
asm("wbinvd\n");
-
+
return 0;
}
-
+
int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out)
{
-
+
/* setup out thin bios emulation */
if (bios_setup()) {
return -1;
}
-
+
if (realmode_setup()) {
return -1;
}
-
+
in->eip = off;
in->xcs = seg;
if (3>(in->esp & 0xffff)) {
printf("Warning: entering realmode with sp < 4 will fail\n");
}
-
+
memcpy(REALMODE_MAILBOX, in, sizeof(struct pt_regs));
asm("wbinvd\n");
-
- __asm__ volatile (
+
+ __asm__ volatile (
"lcall $0x20,%0\n" : : "i" (&realmode_enter) );
asm("wbinvd\n");
@@ -88,9 +88,8 @@ int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out)
writeb(lvl, 0x701);
writeb(0xcb, 0x702); /* lret */
asm("wbinvd\n");
-
- enter_realmode(0x00, 0x700, in, out);
-
+
+ enter_realmode(0x00, 0x700, in, out);
+
return out->eflags&1;
}
-
diff --git a/lib_i386/realmode_switch.S b/lib_i386/realmode_switch.S
index 17adcbd..0433cd4 100644
--- a/lib_i386/realmode_switch.S
+++ b/lib_i386/realmode_switch.S
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
- *
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -31,11 +31,11 @@
* e08 edx;
* e0c esi;
* e10 edi;
- * e14 ebp;
+ * e14 ebp;
* e18 eax;
- * e1c ds;
+ * e1c ds;
* e20 es;
- * e24 fs;
+ * e24 fs;
* e28 gs;
* e2c orig_eax;
* e30 eip;
@@ -46,7 +46,7 @@
*/
#define a32 .byte 0x67; /* address size prefix 32 */
-#define o32 .byte 0x66; /* operand size prefix 32 */
+#define o32 .byte 0x66; /* operand size prefix 32 */
.section .realmode, "ax"
.code16
@@ -56,11 +56,11 @@ realmode_enter:
o32 pusha
o32 pushf
cli
- sidt saved_idt
- sgdt saved_gdt
- movl %esp, %eax
- movl %eax, saved_protected_mode_esp
-
+ sidt saved_idt
+ sgdt saved_gdt
+ movl %esp, %eax
+ movl %eax, saved_protected_mode_esp
+
movl $0x10, %eax
movl %eax, %esp
movw $0x28, %ax
@@ -74,21 +74,21 @@ o32 pushf
andl $0x7ffffffe, %eax /* clearing PE to 0 */
movl %eax, %cr0
ljmp $0x0,$do_realmode /* switch to real mode */
-
-do_realmode: /* realmode code from here */
+
+do_realmode: /* realmode code from here */
movw %cs,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%fs
movw %ax,%gs
-
+
/* create a temporary stack */
-
- movw $0xc0, %ax
- movw %ax, %ss
- movw $0x200, %ax
- movw %ax, %sp
-
+
+ movw $0xc0, %ax
+ movw %ax, %ss
+ movw $0x200, %ax
+ movw %ax, %sp
+
popl %ebx
popl %ecx
popl %edx
@@ -117,11 +117,11 @@ o32 popf
cs movl temp_eax, %eax
wbinvd /* self-modifying code,
* better flush the cache */
-
+
.byte 0x9a /* lcall */
temp_ip:
.word 0 /* new ip */
-temp_cs:
+temp_cs:
.word 0 /* new cs */
realmode_ret:
/* save eax, esp and ss */
@@ -130,16 +130,16 @@ cs movl %eax, saved_eax
cs movl %eax, saved_esp
movw %ss, %ax
cs movw %ax, saved_ss
-
+
/* restore the stack, note that we set sp to 0x244;
* pt_regs is 0x44 bytes long and we push the structure
* backwards on to the stack, bottom first */
-
- movw $0xc0, %ax
- movw %ax, %ss
- movw $0x244, %ax
- movw %ax, %sp
-
+
+ movw $0xc0, %ax
+ movw %ax, %ss
+ movw $0x244, %ax
+ movw %ax, %sp
+
xorl %eax,%eax
cs movw saved_ss, %ax
pushl %eax
@@ -172,28 +172,28 @@ cs movw temp_ip, %ax
o32 cs lidt saved_idt
o32 cs lgdt saved_gdt /* Set GDTR */
- movl %cr0, %eax /* Go back into protected mode */
- orl $1,%eax /* reset PE to 1 */
- movl %eax, %cr0
- jmp next_line /* flush prefetch queue */
-next_line:
- movw $return_ptr, %ax
- movw %ax,%bp
+ movl %cr0, %eax /* Go back into protected mode */
+ orl $1,%eax /* reset PE to 1 */
+ movl %eax, %cr0
+ jmp next_line /* flush prefetch queue */
+next_line:
+ movw $return_ptr, %ax
+ movw %ax,%bp
o32 cs ljmp *(%bp)
.code32
protected_mode:
- movl $0x18,%eax /* reload GDT[3] */
- movw %ax,%fs /* reset FS */
+ movl $0x18,%eax /* reload GDT[3] */
+ movw %ax,%fs /* reset FS */
movw %ax,%ds /* reset DS */
- movw %ax,%gs /* reset GS */
- movw %ax,%es /* reset ES */
- movw %ax,%ss /* reset SS */
- movl saved_protected_mode_esp, %eax
+ movw %ax,%gs /* reset GS */
+ movw %ax,%es /* reset ES */
+ movw %ax,%ss /* reset SS */
+ movl saved_protected_mode_esp, %eax
movl %eax, %esp
popf
popa
- ret
+ ret
temp_eax:
.long 0
@@ -204,19 +204,19 @@ saved_esp:
.long 0
saved_eax:
.long 0
-
+
realmode_idt_ptr:
- .word 0x400
- .word 0x0, 0x0
-
-saved_gdt:
- .word 0, 0, 0, 0
+ .word 0x400
+ .word 0x0, 0x0
+
+saved_gdt:
+ .word 0, 0, 0, 0
saved_idt:
- .word 0, 0, 0, 0
+ .word 0, 0, 0, 0
saved_protected_mode_esp:
.long 0
-
+
return_ptr:
.long protected_mode
.word 0x10
diff --git a/lib_i386/video.c b/lib_i386/video.c
index 776022e..cd89457 100644
--- a/lib_i386/video.c
+++ b/lib_i386/video.c
@@ -21,14 +21,14 @@
* MA 02111-1307 USA
*/
-#include <common.h>
-#include <pci.h>
+#include <common.h>
+#include <pci.h>
#include <devices.h>
#include <i8042.h>
-#include <asm/ptrace.h>
-#include <asm/realmode.h>
-#include <asm/io.h>
-#include <asm/pci.h>
+#include <asm/ptrace.h>
+#include <asm/realmode.h>
+#include <asm/io.h>
+#include <asm/pci.h>
/* basic textmode I/O from linux kernel */
@@ -40,7 +40,7 @@ static int orig_x, orig_y;
static void beep(int dur)
{
int i;
-
+
outb_p(3, 0x61);
for (i=0;i<10*dur;i++) {
udelay(1000);
@@ -60,23 +60,23 @@ static void scroll(void)
static void __video_putc(const char c, int *x, int *y)
{
if (c == '\n') {
- (*x) = 0;
+ (*x) = 0;
if ( ++(*y) >= lines ) {
scroll();
(*y)--;
}
- } else if (c == '\b') {
+ } else if (c == '\b') {
if ((*x) != 0) {
--(*x);
- vidmem [ ( (*x) + cols * (*y) ) * 2 ] = ' ';
+ vidmem [ ( (*x) + cols * (*y) ) * 2 ] = ' ';
}
- } else if (c == '\r') {
+ } else if (c == '\r') {
(*x) = 0;
-
- } else if (c == '\a') {
+
+ } else if (c == '\a') {
beep(3);
-
- } else if (c == '\t') {
+
+ } else if (c == '\t') {
__video_putc(' ', x, y);
__video_putc(' ', x, y);
__video_putc(' ', x, y);
@@ -85,7 +85,7 @@ static void __video_putc(const char c, int *x, int *y)
__video_putc(' ', x, y);
__video_putc(' ', x, y);
__video_putc(' ', x, y);
- } else if (c == '\v') {
+ } else if (c == '\v') {
switch ((*x) % 8) {
case 0:
__video_putc(' ', x, y);
@@ -104,7 +104,7 @@ static void __video_putc(const char c, int *x, int *y)
case 1:
__video_putc(' ', x, y);
}
- } else if (c == '\f') {
+ } else if (c == '\f') {
int i;
for (i=0;i<lines*cols*2;i+=2) {
vidmem[i] = 0;
@@ -112,7 +112,7 @@ static void __video_putc(const char c, int *x, int *y)
(*x) = 0;
(*y) = 0;
} else {
- vidmem [ ( (*x) + cols * (*y) ) * 2 ] = c;
+ vidmem [ ( (*x) + cols * (*y) ) * 2 ] = c;
if ( ++(*x) >= cols ) {
(*x) = 0;
if ( ++(*y) >= lines ) {
@@ -126,15 +126,15 @@ static void __video_putc(const char c, int *x, int *y)
static void video_putc(const char c)
{
int x,y,pos;
-
+
x = orig_x;
y = orig_y;
-
+
__video_putc(c, &x, &y);
orig_x = x;
orig_y = y;
-
+
pos = (x + cols * y) * 2; /* Update cursor position */
outb_p(14, vidport);
outb_p(0xff & (pos >> 9), vidport+1);
@@ -167,72 +167,71 @@ static void video_puts(const char *s)
int video_init(void)
{
u16 pos;
-
+
static device_t vga_dev;
static device_t kbd_dev;
-
+
vidmem = (char *) 0xb8000;
vidport = 0x3d4;
lines = 25;
cols = 80;
-
+
outb_p(14, vidport);
pos = inb_p(vidport+1);
pos <<= 8;
outb_p(15, vidport);
pos |= inb_p(vidport+1);
-
+
orig_x = pos%cols;
orig_y = pos/cols;
-#if 0
+#if 0
printf("pos %x %d %d\n", pos, orig_x, orig_y);
-#endif
+#endif
if (orig_y > lines) {
orig_x = orig_y =0;
}
-
-
+
+
memset(&vga_dev, 0, sizeof(vga_dev));
- strcpy(vga_dev.name, "vga");
- vga_dev.ext = 0;
- vga_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
- vga_dev.putc = video_putc; /* 'putc' function */
- vga_dev.puts = video_puts; /* 'puts' function */
- vga_dev.tstc = NULL; /* 'tstc' function */
- vga_dev.getc = NULL; /* 'getc' function */
-
- if (device_register(&vga_dev) == 0) {
- return 1;
+ strcpy(vga_dev.name, "vga");
+ vga_dev.ext = 0;
+ vga_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
+ vga_dev.putc = video_putc; /* 'putc' function */
+ vga_dev.puts = video_puts; /* 'puts' function */
+ vga_dev.tstc = NULL; /* 'tstc' function */
+ vga_dev.getc = NULL; /* 'getc' function */
+
+ if (device_register(&vga_dev) == 0) {
+ return 1;
}
-
+
if (i8042_kbd_init()) {
return 1;
}
-
+
memset(&kbd_dev, 0, sizeof(kbd_dev));
- strcpy(kbd_dev.name, "kbd");
- kbd_dev.ext = 0;
- kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- kbd_dev.putc = NULL; /* 'putc' function */
- kbd_dev.puts = NULL; /* 'puts' function */
- kbd_dev.tstc = i8042_tstc; /* 'tstc' function */
- kbd_dev.getc = i8042_getc; /* 'getc' function */
-
- if (device_register(&kbd_dev) == 0) {
- return 1;
+ strcpy(kbd_dev.name, "kbd");
+ kbd_dev.ext = 0;
+ kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
+ kbd_dev.putc = NULL; /* 'putc' function */
+ kbd_dev.puts = NULL; /* 'puts' function */
+ kbd_dev.tstc = i8042_tstc; /* 'tstc' function */
+ kbd_dev.getc = i8042_getc; /* 'getc' function */
+
+ if (device_register(&kbd_dev) == 0) {
+ return 1;
}
return 0;
}
-int drv_video_init(void)
+int drv_video_init(void)
{
if (video_bios_init()) {
return 1;
}
-
- return video_init();
+
+ return video_init();
}
-
diff --git a/lib_i386/video_bios.c b/lib_i386/video_bios.c
index d9709b9..45f78e2 100644
--- a/lib_i386/video_bios.c
+++ b/lib_i386/video_bios.c
@@ -21,13 +21,13 @@
* MA 02111-1307 USA
*/
-#include <common.h>
-#include <pci.h>
-#include <malloc.h>
-#include <asm/ptrace.h>
-#include <asm/realmode.h>
-#include <asm/io.h>
-#include <asm/pci.h>
+#include <common.h>
+#include <pci.h>
+#include <malloc.h>
+#include <asm/ptrace.h>
+#include <asm/realmode.h>
+#include <asm/io.h>
+#include <asm/pci.h>
#undef PCI_BIOS_DEBUG
#undef VGA_BIOS_DEBUG
@@ -41,7 +41,7 @@
#ifdef CONFIG_PCI
#ifdef PCI_BIOS_DEBUG
-#define RELOC_16(seg, off) *(u32*)(seg << 4 | (u32)&off)
+#define RELOC_16(seg, off) *(u32*)(seg << 4 | (u32)&off)
extern u32 num_pci_bios_present;
extern u32 num_pci_bios_find_device;
extern u32 num_pci_bios_find_class;
@@ -62,7 +62,7 @@ void print_bios_bios_stat(void)
printf("pci_bios_present: %d\n", RELOC_16(0xf000, num_pci_bios_present));
printf("pci_bios_find_device: %d\n", RELOC_16(0xf000, num_pci_bios_find_device));
printf("pci_bios_find_class: %d\n", RELOC_16(0xf000, num_pci_bios_find_class));
- printf("pci_bios_generate_special_cycle: %d\n", RELOC_16(0xf000, num_pci_bios_generate_special_cycle));
+ printf("pci_bios_generate_special_cycle: %d\n", RELOC_16(0xf000, num_pci_bios_generate_special_cycle));
printf("pci_bios_read_cfg_byte: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_byte));
printf("pci_bios_read_cfg_word: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_word));
printf("pci_bios_read_cfg_dword: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_dword));
@@ -84,52 +84,52 @@ void print_bios_bios_stat(void)
static u32 probe_pci_video(void)
{
pci_dev_t devbusfn;
-
- if ((devbusfn = pci_find_class(PCI_CLASS_VIDEO,
- PCI_CLASS_VIDEO_STD,
+
+ if ((devbusfn = pci_find_class(PCI_CLASS_VIDEO,
+ PCI_CLASS_VIDEO_STD,
PCI_CLASS_VIDEO_PROG_IF_VGA, 0)) != -1) {
u32 old;
u32 addr;
-
+
/* PCI video device detected */
- printf("Found PCI VGA device at %02x.%02x.%x\n",
+ printf("Found PCI VGA device at %02x.%02x.%x\n",
PCI_BUS(devbusfn), PCI_DEV(devbusfn), PCI_FUNC(devbusfn));
-
+
/* Enable I/O decoding as well, PCI viudeo boards
* support I/O accesses, but they provide no
* bar register for this since the ports are fixed.
*/
pci_write_config_word(devbusfn, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_IO | PCI_COMMAND_MASTER);
-
+
/* Test the ROM decoder, do the device support a rom? */
- pci_read_config_dword(devbusfn, PCI_ROM_ADDRESS, &old);
+ pci_read_config_dword(devbusfn, PCI_ROM_ADDRESS, &old);
pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS, PCI_ROM_ADDRESS_MASK);
pci_read_config_dword(devbusfn, PCI_ROM_ADDRESS, &addr);
pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS, old);
-
+
if (!addr) {
printf("PCI VGA have no ROM?\n");
return 0;
}
-
+
/* device have a rom */
- if (pci_shadow_rom(devbusfn, (void*)0xc0000)) {
+ if (pci_shadow_rom(devbusfn, (void*)0xc0000)) {
printf("Shadowing of PCI VGA BIOS failed\n");
return 0;
}
-
+
/* Now enable lagacy VGA port access */
if (pci_enable_legacy_video_ports(pci_bus_to_hose(PCI_BUS(devbusfn)))) {
printf("PCI VGA enable failed\n");
return 0;
}
-
-
+
+
/* return the pci device info, that we'll need later */
- return PCI_BUS(devbusfn) << 8 |
+ return PCI_BUS(devbusfn) << 8 |
PCI_DEV(devbusfn) << 3 | (PCI_FUNC(devbusfn)&7);
}
-
+
return 0;
}
@@ -139,8 +139,8 @@ static u32 probe_pci_video(void)
static int probe_isa_video(void)
{
u32 ptr;
- char *buf;
-
+ char *buf;
+
if (0 == (ptr = isa_map_rom(0xc0000, 0x8000))) {
return -1;
}
@@ -153,14 +153,14 @@ static int probe_isa_video(void)
isa_unmap_rom(ptr);
return -1;
}
-
+
/* shadow the rom */
memcpy(buf, (void*)ptr, 0x8000);
isa_unmap_rom(ptr);
memcpy((void*)0xc0000, buf, 0x8000);
-
+
free(buf);
-
+
return 0;
}
@@ -169,20 +169,20 @@ int video_bios_init(void)
struct pt_regs regs;
/* clear the video bios area in case we warmbooted */
- memset((void*)0xc0000, 0, 0x8000);
+ memset((void*)0xc0000, 0, 0x8000);
memset(&regs, 0, sizeof(struct pt_regs));
-
+
if (probe_isa_video()) {
/* No ISA board found, try the PCI bus */
regs.eax = probe_pci_video();
}
-
+
/* Did we succeed in mapping any video bios */
if (readw(0xc0000) == 0xaa55) {
int size;
int i;
u8 sum;
-
+
PRINTF("Found video bios signature\n");
size = 512*readb(0xc0002);
PRINTF("size %d\n", size);
@@ -194,28 +194,26 @@ int video_bios_init(void)
if (sum) {
return 1;
}
-
+
/* some video bioses (ATI Mach64) seem to think that
* the original int 10 handler is always at
* 0xf000:0xf065 , place an iret instruction there
*/
writeb(0xcf, 0xff065);
-
+
regs.esp = 0x8000;
regs.xss = 0x2000;
enter_realmode(0xc000, 3, &regs, &regs);
PRINTF("INT 0x10 vector after: %04x:%04x\n",
- readw(0x42), readw(0x40));
+ readw(0x42), readw(0x40));
PRINTF("BIOS returned %scarry\n", regs.eflags & 1?"":"NOT ");
-#ifdef PCI_BIOS_DEBUG
+#ifdef PCI_BIOS_DEBUG
print_bios_bios_stat();
-#endif
+#endif
return (regs.eflags & 1);
-
+
}
-
- return 1;
-
-}
+ return 1;
+}
diff --git a/lib_i386/zimage.c b/lib_i386/zimage.c
index 9d33b2d..3510f2f 100644
--- a/lib_i386/zimage.c
+++ b/lib_i386/zimage.c
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
- *
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -21,10 +21,10 @@
* MA 02111-1307 USA
*/
-/*
+/*
* Linux i386 zImage and bzImage loading
- *
- * based on the procdure described in
+ *
+ * based on the procdure described in
* linux/Documentation/i386/boot.txt
*/
@@ -37,10 +37,10 @@
/*
* Memory lay-out:
- *
+ *
* relative to setup_base (which is 0x90000 currently)
- *
- * 0x0000-0x7FFF Real mode kernel
+ *
+ * 0x0000-0x7FFF Real mode kernel
* 0x8000-0x8FFF Stack and heap
* 0x9000-0x90FF Kernel command line
*/
@@ -53,53 +53,53 @@
static void build_command_line(char *command_line, int auto_boot)
{
char *env_command_line;
-
+
command_line[0] = '\0';
-
+
env_command_line = getenv("bootargs");
-
+
/* set console= argument if we use a serial console */
if (NULL == strstr(env_command_line, "console=")) {
if (0==strcmp(getenv("stdout"), "serial")) {
-
+
/* We seem to use serial console */
- sprintf(command_line, "console=ttyS0,%s ",
+ sprintf(command_line, "console=ttyS0,%s ",
getenv("baudrate"));
}
}
-
+
if (auto_boot) {
strcat(command_line, "auto ");
}
-
+
if (NULL != env_command_line) {
strcat(command_line, env_command_line);
- }
-
-
+ }
+
+
printf("Kernel command line: \"%s\"\n", command_line);
}
-void *load_zimage(char *image, unsigned long kernel_size,
+void *load_zimage(char *image, unsigned long kernel_size,
unsigned long initrd_addr, unsigned long initrd_size,
int auto_boot)
{
- void *setup_base;
+ void *setup_base;
int setup_size;
int bootproto;
int big_image;
void *load_address;
-
-
+
+
setup_base = (void*)DEFAULT_SETUP_BASE; /* base address for real-mode segment */
-
- if (KERNEL_MAGIC != *(u16*)(image + BOOT_FLAG_OFF)) {
+
+ if (KERNEL_MAGIC != *(u16*)(image + BOOT_FLAG_OFF)) {
printf("Error: Invalid kernel magic (found 0x%04x, expected 0xaa55)\n",
*(u16*)(image + BOOT_FLAG_OFF));
return 0;
}
-
-
+
+
/* determine boot protocol version */
if (KERNEL_V2_MAGIC == *(u32*)(image+HEADER_OFF)) {
bootproto = *(u16*)(image+VERSION_OFF);
@@ -107,108 +107,107 @@ void *load_zimage(char *image, unsigned long kernel_size,
/* Very old kernel */
bootproto = 0x0100;
}
-
+
/* determine size of setup */
if (0 == *(u8*)(image + SETUP_SECTS_OFF)) {
setup_size = 5 * 512;
} else {
setup_size = (*(u8*)(image + SETUP_SECTS_OFF) + 1) * 512;
}
-
+
if (setup_size > SETUP_MAX_SIZE) {
printf("Error: Setup is too large (%d bytes)\n", setup_size);
}
-
+
/* Determine image type */
- big_image = (bootproto >= 0x0200) && (*(u8*)(image + LOADFLAGS_OFF) & BIG_KERNEL_FLAG);
-
+ big_image = (bootproto >= 0x0200) && (*(u8*)(image + LOADFLAGS_OFF) & BIG_KERNEL_FLAG);
+
/* Derermine load address */
load_address = (void*)(big_image ? BZIMAGE_LOAD_ADDR:ZIMAGE_LOAD_ADDR);
-
+
/* load setup */
memmove(setup_base, image, setup_size);
-
- printf("Using boot protocol version %x.%02x\n",
+
+ printf("Using boot protocol version %x.%02x\n",
(bootproto & 0xff00) >> 8, bootproto & 0xff);
-
-
- if (bootproto == 0x0100) {
-
+
+
+ if (bootproto == 0x0100) {
+
*(u16*)(setup_base + CMD_LINE_MAGIC_OFF) = COMMAND_LINE_MAGIC;
- *(u16*)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET;
-
+ *(u16*)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET;
+
/* A very old kernel MUST have its real-mode code
* loaded at 0x90000 */
-
+
if ((u32)setup_base != 0x90000) {
/* Copy the real-mode kernel */
memmove((void*)0x90000, setup_base, setup_size);
/* Copy the command line */
- memmove((void*)0x99000, setup_base+COMMAND_LINE_OFFSET,
+ memmove((void*)0x99000, setup_base+COMMAND_LINE_OFFSET,
COMMAND_LINE_SIZE);
-
+
setup_base = (void*)0x90000; /* Relocated */
}
-
+
/* It is recommended to clear memory up to the 32K mark */
memset((void*)0x90000 + setup_size, 0, SETUP_MAX_SIZE-setup_size);
}
-
+
if (bootproto >= 0x0200) {
*(u8*)(setup_base + TYPE_OF_LOADER_OFF) = 0xff;
- printf("Linux kernel version %s\n",
- (char*)(setup_base + SETUP_START_OFFSET +
+ printf("Linux kernel version %s\n",
+ (char*)(setup_base + SETUP_START_OFFSET +
*(u16*)(setup_base + START_SYS_OFF + 2)));
-
+
if (initrd_addr) {
printf("Initial RAM disk at linear address 0x%08lx, size %ld bytes\n",
initrd_addr, initrd_size);
-
+
*(u32*)(setup_base + RAMDISK_IMAGE_OFF) = initrd_addr;
*(u32*)(setup_base + RAMDISK_SIZE_OFF)=initrd_size;
}
}
-
+
if (bootproto >= 0x0201) {
*(u16*)(setup_base + HEAP_END_PTR_OFF) = HEAP_END_OFFSET;
-
+
/* CAN_USE_HEAP */
- *(u8*)(setup_base + LOADFLAGS_OFF) =
+ *(u8*)(setup_base + LOADFLAGS_OFF) =
*(u8*)(setup_base + LOADFLAGS_OFF) | HEAP_FLAG;
}
-
+
if (bootproto >= 0x0202) {
*(u32*)(setup_base + CMD_LINE_PTR_OFF) = (u32)setup_base + COMMAND_LINE_OFFSET;
} else if (bootproto >= 0x0200) {
*(u16*)(setup_base + CMD_LINE_MAGIC_OFF) = COMMAND_LINE_MAGIC;
- *(u16*)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET;
+ *(u16*)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET;
*(u16*)(setup_base + SETUP_MOVE_SIZE_OFF) = 0x9100;
}
-
-
+
if (big_image) {
- if ((kernel_size - setup_size) > BZIMAGE_MAX_SIZE) {
+ if ((kernel_size - setup_size) > BZIMAGE_MAX_SIZE) {
printf("Error: bzImage kernel too big! (size: %ld, max: %d)\n",
kernel_size - setup_size, BZIMAGE_MAX_SIZE);
return 0;
}
-
+
} else if ((kernel_size - setup_size) > ZIMAGE_MAX_SIZE) {
printf("Error: zImage kernel too big! (size: %ld, max: %d)\n",
kernel_size - setup_size, ZIMAGE_MAX_SIZE);
return 0;
}
-
+
/* build command line at COMMAND_LINE_OFFSET */
build_command_line(setup_base + COMMAND_LINE_OFFSET, auto_boot);
-
- printf("Loading %czImage at address 0x%08x (%ld bytes)\n", big_image ? 'b' : ' ',
+
+ printf("Loading %czImage at address 0x%08x (%ld bytes)\n", big_image ? 'b' : ' ',
(u32)load_address, kernel_size - setup_size);
-
+
memmove(load_address, image + setup_size, kernel_size - setup_size);
-
+
/* ready for booting */
return setup_base;
}
@@ -217,7 +216,7 @@ void *load_zimage(char *image, unsigned long kernel_size,
void boot_zimage(void *setup_base)
{
struct pt_regs regs;
-
+
memset(&regs, 0, sizeof(struct pt_regs));
regs.xds = (u32)setup_base >> 4;
regs.xss = 0x9000;
@@ -228,18 +227,18 @@ void boot_zimage(void *setup_base)
image_header_t *fake_zimage_header(image_header_t *hdr, void *ptr, int size)
-{
+{
/* There is no way to know the size of a zImage ... *
* so we assume that 2MB will be enough for now */
#define ZIMAGE_SIZE 0x200000
-
+
/* load a 1MB, the loaded will have to be moved to its final
* position again later... */
#define ZIMAGE_LOAD 0x100000
-
+
ulong checksum;
-
- if (KERNEL_MAGIC != *(u16*)(ptr + BOOT_FLAG_OFF)) {
+
+ if (KERNEL_MAGIC != *(u16*)(ptr + BOOT_FLAG_OFF)) {
/* not a zImage or bzImage */
return NULL;
}
@@ -247,13 +246,13 @@ image_header_t *fake_zimage_header(image_header_t *hdr, void *ptr, int size)
if (-1 == size) {
size = ZIMAGE_SIZE;
}
-#if 0
+#if 0
checksum = crc32 (0, ptr, size);
#else
checksum = 0;
-#endif
+#endif
memset(hdr, 0, sizeof(image_header_t));
-
+
/* Build new header */
hdr->ih_magic = htonl(IH_MAGIC);
hdr->ih_time = 0;
@@ -271,6 +270,6 @@ image_header_t *fake_zimage_header(image_header_t *hdr, void *ptr, int size)
checksum = crc32(0,(const char *)hdr,sizeof(image_header_t));
hdr->ih_hcrc = htonl(checksum);
-
+
return hdr;
}