cosmetic: checkpatch cleanup of arch/x86/lib/*.c

Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
This commit is contained in:
Graeme Russ
2011-11-08 02:33:15 +00:00
parent 01a0f5a1eb
commit 83088afbba
18 changed files with 519 additions and 435 deletions

View File

@ -26,6 +26,9 @@
#ifndef _PCI_I386_H_
#define _PCI_I386_H_ 1
#define DEFINE_PCI_DEVICE_TABLE(_table) \
const struct pci_device_id _table[]
void pci_setup_type1(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data);
int pci_enable_legacy_video_ports(struct pci_controller* hose);
int pci_shadow_rom(pci_dev_t dev, unsigned char *dest);

View File

@ -25,6 +25,10 @@
#define __ASM_REALMODE_H_
#include <asm/ptrace.h>
extern ulong __realmode_start;
extern ulong __realmode_size;
extern char realmode_enter;
int bios_setup(void);
int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out);
int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out);

View File

@ -24,6 +24,14 @@
#ifndef _U_BOOT_I386_H_
#define _U_BOOT_I386_H_ 1
/* Exports from the Linker Script */
extern ulong __text_start;
extern ulong __data_end;
extern ulong __rel_dyn_start;
extern ulong __rel_dyn_end;
extern ulong __bss_start;
extern ulong __bss_end;
/* cpu/.../cpu.c */
int x86_cpu_init_r(void);
int cpu_init_r(void);

View File

@ -56,16 +56,17 @@
#define OFFS_CS 42 /* 16bit */
#define OFFS_FLAGS 44 /* 16bit */
/* stack at 0x40:0x800 -> 0x800 */
#define SEGMENT 0x40
#define STACK 0x800 /* stack at 0x40:0x800 -> 0x800 */
/* save general registers */
/* save some segments */
/* save callers stack segment .. */
/* ... in gs */
/* setup my segments */
/* setup BIOS stackpointer */
#define STACK 0x800
/*
* save general registers
* save some segments
* save callers stack segment
* setup BIOS segments
* setup BIOS stackpointer
*/
#define MAKE_BIOS_STACK \
pushal; \
pushw %ds; \
@ -80,13 +81,93 @@
movw %sp, %bp; \
movw $STACK, %sp
/*
* restore callers stack segment
* restore some segments
* restore general registers
*/
#define RESTORE_CALLERS_STACK \
pushw %gs; /* restore callers stack segment */ \
pushw %gs; \
popw %ss; \
movw %bp, %sp; /* restore stackpointer */ \
popw %es; /* restore segment selectors */ \
movw %bp, %sp; \
popw %es; \
popw %gs; \
popw %ds; \
popal /* restore GP registers */
popal
#ifndef __ASSEMBLY__
#define BIOS_DATA ((char *)0x400)
#define BIOS_DATA_SIZE 256
#define BIOS_BASE ((char *)0xf0000)
#define BIOS_CS 0xf000
extern ulong __bios_start;
extern ulong __bios_size;
/* these are defined in a 16bit segment and needs
* to be accessed with the RELOC_16_xxxx() macros below
*/
extern u16 ram_in_64kb_chunks;
extern u16 bios_equipment;
extern u8 pci_last_bus;
extern void *rm_int00;
extern void *rm_int01;
extern void *rm_int02;
extern void *rm_int03;
extern void *rm_int04;
extern void *rm_int05;
extern void *rm_int06;
extern void *rm_int07;
extern void *rm_int08;
extern void *rm_int09;
extern void *rm_int0a;
extern void *rm_int0b;
extern void *rm_int0c;
extern void *rm_int0d;
extern void *rm_int0e;
extern void *rm_int0f;
extern void *rm_int10;
extern void *rm_int11;
extern void *rm_int12;
extern void *rm_int13;
extern void *rm_int14;
extern void *rm_int15;
extern void *rm_int16;
extern void *rm_int17;
extern void *rm_int18;
extern void *rm_int19;
extern void *rm_int1a;
extern void *rm_int1b;
extern void *rm_int1c;
extern void *rm_int1d;
extern void *rm_int1e;
extern void *rm_int1f;
extern void *rm_def_int;
extern void *realmode_reset;
extern void *realmode_pci_bios_call_entry;
#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))
#ifdef PCI_BIOS_DEBUG
extern u32 num_pci_bios_present;
extern u32 num_pci_bios_find_device;
extern u32 num_pci_bios_find_class;
extern u32 num_pci_bios_generate_special_cycle;
extern u32 num_pci_bios_read_cfg_byte;
extern u32 num_pci_bios_read_cfg_word;
extern u32 num_pci_bios_read_cfg_dword;
extern u32 num_pci_bios_write_cfg_byte;
extern u32 num_pci_bios_write_cfg_word;
extern u32 num_pci_bios_write_cfg_dword;
extern u32 num_pci_bios_get_irq_routing;
extern u32 num_pci_bios_set_irq;
extern u32 num_pci_bios_unknown_function;
#endif
#endif
#endif

View File

@ -80,11 +80,15 @@ cs incl num_pci_bios_present
#endif
movl $0x20494350, %eax
gs movl %eax, OFFS_EDX(%bp)
/* We support cfg type 1 version 2.10 */
movb $0x01, %al
gs movb %al, OFFS_AL(%bp) /* We support cfg type 1 */
movw $0x0210, %ax /* version 2.10 */
gs movb %al, OFFS_AL(%bp)
movw $0x0210, %ax
gs movw %ax, OFFS_BX(%bp)
cs movb pci_last_bus, %al /* last bus number */
/* last bus number */
cs movb pci_last_bus, %al
gs movb %al, OFFS_CL(%bp)
jmp clear_carry
@ -97,16 +101,22 @@ cs incl num_pci_bios_find_device
#endif
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_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 */
/* start at bus 0 dev 0 function 0 */
xorw %bx, %bx
pfd_loop:
xorw %ax, %ax /* dword 0 is vendor/device */
/* dword 0 is vendor/device */
xorw %ax, %ax
call __pci_bios_select_register
movw $0xcfc, %dx
inl %dx, %eax
cmpl %edi, %eax /* our device ? */
/* our device ? */
cmpl %edi, %eax
je pfd_found_one
pfd_next_dev:
/* check for multi function devices */
@ -120,13 +130,16 @@ pfd_next_dev:
andb $0x80, %al
jz pfd_not_multi_function
pfd_function_not_zero:
incw %bx /* next function, overflows in to
* device number, then bus number */
/* next function, overflows in to device number, then bus number */
incw %bx
jmp pfd_check_bus
pfd_not_multi_function:
andw $0xfff8, %bx /* remove function bits */
addw $0x0008, %bx /* next device, overflows in to bus number */
/* remove function bits */
andw $0xfff8, %bx
/* next device, overflows in to bus number */
addw $0x0008, %bx
pfd_check_bus:
cs movb pci_last_bus, %ah
cmpb %ah, %bh
@ -142,7 +155,8 @@ gs movw %bx, OFFS_BX(%bp)
jmp clear_carry
pfd_not_found:
movb $0x86, %ah /* device not found */
/* device not found */
movb $0x86, %ah
jmp set_carry
/*****************************************************************************/
@ -152,17 +166,24 @@ pci_bios_find_class:
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 */
/* edi now holds class-code in lower 24 bits */
andl $0x00ffffff, %edi
gs movw OFFS_SI(%bp), %si
xorw %bx, %bx /* start at bus 0 dev 0 function 0 */
/* start at bus 0 dev 0 function 0 */
xorw %bx, %bx
pfc_loop:
movw $8, %ax /* dword 8 is class-code high 24bits */
/* dword 8 is class-code high 24bits */
movw $8, %ax
call __pci_bios_select_register
movw $0xcfc, %dx
inl %dx, %eax
shrl $8, %eax
andl $0x00ffffff, %eax
cmpl %edi, %eax /* our device ? */
/* our device ? */
cmpl %edi, %eax
je pfc_found_one
pfc_next_dev:
/* check for multi function devices */
@ -175,13 +196,16 @@ pfc_next_dev:
andb $0x80, %al
jz pfc_not_multi_function
pfc_function_not_zero:
incw %bx /* next function, overflows in to
* device number, then bus number */
/* next function, overflows in to device number, then bus number */
incw %bx
jmp pfc_check_bus
pfc_not_multi_function:
andw $0xfff8, %bx /* remove function bits */
addw $0x0008, %bx /* next device, overflows in to bus number */
/* remove function bits */
andw $0xfff8, %bx
/* next device, overflows in to bus number */
addw $0x0008, %bx
pfc_check_bus:
cs movb pci_last_bus, %ah
cmpb %ah, %bh
@ -197,7 +221,8 @@ gs movw %bx, OFFS_BX(%bp)
jmp clear_carry
pfc_not_found:
movb $0x86, %ah /* device not found */
/* device not found */
movb $0x86, %ah
jmp set_carry
/*****************************************************************************/
@ -206,7 +231,8 @@ pci_bios_generate_special_cycle:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_generate_special_cycle
#endif
movb $0x81, %ah /* function not supported */
/* function not supported */
movb $0x81, %ah
jmp set_carry
/*****************************************************************************/
@ -296,7 +322,8 @@ pci_bios_get_irq_routing:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_get_irq_routing
#endif
movb $0x81, %ah /* function not supported */
/* function not supported */
movb $0x81, %ah
jmp set_carry
/*****************************************************************************/
@ -305,7 +332,8 @@ pci_bios_set_irq:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_set_irq
#endif
movb $0x81, %ah /* function not supported */
/* function not supported */
movb $0x81, %ah
jmp set_carry
/*****************************************************************************/
@ -314,7 +342,8 @@ unknown_function:
#ifdef PCI_BIOS_DEBUG
cs incl num_pci_bios_unknown_function
#endif
movb $0x81, %ah /* function not supported */
/* function not supported */
movb $0x81, %ah
jmp set_carry
/*****************************************************************************/
@ -323,7 +352,8 @@ pci_bios_select_register:
gs movw OFFS_BX(%bp), %bx
gs movw OFFS_DI(%bp), %ax
/* destroys eax, dx */
__pci_bios_select_register: /* BX holds device id, AX holds register index */
__pci_bios_select_register:
/* BX holds device id, AX holds register index */
pushl %ebx
andl $0xfc, %eax
andl $0xffff, %ebx
@ -338,7 +368,9 @@ __pci_bios_select_register: /* BX holds device id, AX holds regist
clear_carry:
gs movw OFFS_FLAGS(%bp), %ax
andw $0xfffe, %ax /* clear carry -- function succeeded */
/* clear carry -- function succeeded */
andw $0xfffe, %ax
gs movw %ax, OFFS_FLAGS(%bp)
xorw %ax, %ax
gs movb %ah, OFFS_AH(%bp)
@ -347,7 +379,9 @@ gs movb %ah, OFFS_AH(%bp)
set_carry:
gs movb %ah, OFFS_AH(%bp)
gs movw OFFS_FLAGS(%bp), %ax
orw $1, %ax /* return carry -- function not supported */
/* return carry -- function not supported */
orw $1, %ax
gs movw %ax, OFFS_FLAGS(%bp)
movw $-1, %ax
ret

View File

@ -34,72 +34,20 @@
#include <pci.h>
#include <asm/realmode.h>
#include <asm/io.h>
#include "bios.h"
DECLARE_GLOBAL_DATA_PTR;
#define NUMVECTS 256
#define BIOS_DATA ((char*)0x400)
#define BIOS_DATA_SIZE 256
#define BIOS_BASE ((char*)0xf0000)
#define BIOS_CS 0xf000
extern ulong __bios_start;
extern ulong __bios_size;
/* these are defined in a 16bit segment and needs
* to be accessed with the RELOC_16_xxxx() macros below
*/
extern u16 ram_in_64kb_chunks;
extern u16 bios_equipment;
extern u8 pci_last_bus;
extern void *rm_int00;
extern void *rm_int01;
extern void *rm_int02;
extern void *rm_int03;
extern void *rm_int04;
extern void *rm_int05;
extern void *rm_int06;
extern void *rm_int07;
extern void *rm_int08;
extern void *rm_int09;
extern void *rm_int0a;
extern void *rm_int0b;
extern void *rm_int0c;
extern void *rm_int0d;
extern void *rm_int0e;
extern void *rm_int0f;
extern void *rm_int10;
extern void *rm_int11;
extern void *rm_int12;
extern void *rm_int13;
extern void *rm_int14;
extern void *rm_int15;
extern void *rm_int16;
extern void *rm_int17;
extern void *rm_int18;
extern void *rm_int19;
extern void *rm_int1a;
extern void *rm_int1b;
extern void *rm_int1c;
extern void *rm_int1d;
extern void *rm_int1e;
extern void *rm_int1f;
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)
{
if (entry_point & ~0xffff) {
if (entry_point & ~0xffff)
return -1;
}
if (((u32)target-0xf0000) & ~0xffff) {
if (((u32)target - 0xf0000) & ~0xffff)
return -1;
}
printf("set_jmp_vector: 0xf000:%04x -> %p\n",
entry_point, target);
@ -115,13 +63,7 @@ static int set_jmp_vector(int entry_point, void *target)
return 0;
}
/*
************************************************************
* Install an interrupt vector
************************************************************
*/
/* Install an interrupt vector */
static void setvector(int vector, u16 segment, void *handler)
{
u16 *ptr = (u16 *)(vector * 4);
@ -134,23 +76,19 @@ static void setvector(int vector, u16 segment, void *handler)
#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)
int bios_setup(void)
{
ulong bios_start = (ulong)&__bios_start + gd->reloc_off;
ulong bios_size = (ulong)&__bios_size;
static int done=0;
static int done;
int vector;
#ifdef CONFIG_PCI
struct pci_controller *pri_hose;
#endif
if (done) {
if (done)
return 0;
}
done = 1;
if (bios_size > 65536) {
@ -178,9 +116,8 @@ int bios_setup(void)
/* setup realmode interrupt vectors */
for (vector = 0; vector < NUMVECTS; vector++) {
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);

View File

@ -56,15 +56,6 @@
#define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CONFIG_SYS_INIT_GD_ADDR);
/* Exports from the Linker Script */
extern ulong __text_start;
extern ulong __data_end;
extern ulong __rel_dyn_start;
extern ulong __rel_dyn_end;
extern ulong __bss_start;
extern ulong __bss_end;
/************************************************************************
* Init Utilities *
************************************************************************
@ -82,18 +73,8 @@ static int display_banner (void)
{
printf("\n\n%s\n\n", version_string);
/*
printf ("U-Boot code: %08lX -> %08lX data: %08lX -> %08lX\n"
" BSS: %08lX -> %08lX stack: %08lX -> %08lX\n",
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+CONFIG_SYS_STACK_SIZE-1);
*/
return (0);
return 0;
}
static int display_dram_config(void)
@ -107,7 +88,7 @@ static int display_dram_config (void)
print_size(gd->bd->bi_dram[i].size, "\n");
}
return (0);
return 0;
}
static void display_flash_config(ulong size)
@ -214,7 +195,7 @@ static int clear_bss(void)
void *bss_end = &__bss_end;
ulong *dst_addr = (ulong *)(bss_start + gd->reloc_off);
ulong *end_addr = (ulong *)(bss_end + gd->reloc_off);;
ulong *end_addr = (ulong *)(bss_end + gd->reloc_off);
while (dst_addr < end_addr)
*dst_addr++ = 0x00000000;
@ -227,10 +208,23 @@ static int do_elf_reloc_fixups(void)
Elf32_Rel *re_src = (Elf32_Rel *)(&__rel_dyn_start);
Elf32_Rel *re_end = (Elf32_Rel *)(&__rel_dyn_end);
Elf32_Addr *offset_ptr_rom;
Elf32_Addr *offset_ptr_ram;
do {
if (re_src->r_offset >= CONFIG_SYS_TEXT_BASE)
if (*(Elf32_Addr *)(re_src->r_offset + gd->reloc_off) >= CONFIG_SYS_TEXT_BASE)
*(Elf32_Addr *)(re_src->r_offset + gd->reloc_off) += gd->reloc_off;
/* Get the location from the relocation entry */
offset_ptr_rom = (Elf32_Addr *)re_src->r_offset;
/* Check that the location of the relocation is in .text */
if (offset_ptr_rom >= (Elf32_Addr *)CONFIG_SYS_TEXT_BASE) {
/* Switch to the in-RAM version */
offset_ptr_ram = offset_ptr_rom + gd->reloc_off;
/* Check that the target points into .text */
if (*offset_ptr_ram >= CONFIG_SYS_TEXT_BASE)
*offset_ptr_ram += gd->reloc_off;
}
} while (re_src++ < re_end);
return 0;
@ -254,7 +248,8 @@ void board_init_f(ulong boot_flags)
relocate_code(gd->start_addr_sp, gd, gd->relocaddr);
/* NOTREACHED - relocate_code() does not return */
while(1);
while (1)
;
}
void board_init_r(gd_t *id, ulong dest_addr)
@ -356,9 +351,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
if ((s = getenv ("bootfile")) != NULL) {
s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif
WATCHDOG_RESET();
@ -413,13 +409,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
post_run(NULL, POST_RAM | post_bootmode_get(0));
#endif
show_boot_progress(0x29);
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;) {
for (;;)
main_loop();
}
/* NOTREACHED - no way out of command loop except booting */
}
@ -427,10 +421,12 @@ void board_init_r(gd_t *id, ulong dest_addr)
void hang(void)
{
puts("### ERROR ### Please RESET the board ###\n");
for (;;);
for (;;)
;
}
unsigned long do_go_exec (ulong (*entry)(int, char * const []), int argc, char * const argv[])
unsigned long do_go_exec(ulong (*entry)(int, char * const []),
int argc, char * const argv[])
{
unsigned long ret = 0;
char **argv_tmp;

View File

@ -32,7 +32,8 @@
#include <asm/zimage.h>
/*cmd_boot.c*/
int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
int do_bootm_linux(int flag, int argc, char * const argv[],
bootm_headers_t *images)
{
void *base_ptr;
ulong os_data, os_len;

View File

@ -56,8 +56,8 @@ struct irq_action {
};
static struct irq_action irq_handlers[CONFIG_SYS_NUM_IRQS] = { {0} };
static int spurious_irq_cnt = 0;
static int spurious_irq = 0;
static int spurious_irq_cnt;
static int spurious_irq;
void irq_install_handler(int irq, interrupt_handler_t *handler, void *arg)
{

View File

@ -30,7 +30,7 @@
#define TIMER0_VALUE 0x04aa /* 1kHz 1.9318MHz / 1000 */
#define TIMER2_VALUE 0x0a8e /* 440Hz */
static int timer_init_done = 0;
static int timer_init_done;
int timer_init(void)
{
@ -67,7 +67,7 @@ static u16 read_pit(void)
outb(PIT_CMD_LATCH, PIT_BASE + PIT_COMMAND);
low = inb(PIT_BASE + PIT_T0);
return ((inb (PIT_BASE + PIT_T0) << 8) | low);
return (inb(PIT_BASE + PIT_T0) << 8) | low;
}
/* this is not very exact */
@ -76,8 +76,7 @@ void __udelay (unsigned long usec)
int counter;
int wraps;
if (timer_init_done)
{
if (timer_init_done) {
counter = read_pit();
wraps = usec / 1000;
usec = usec % 1000;

View File

@ -42,11 +42,13 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
u16 device;
u32 class_code;
u32 pci_data;
hose = pci_bus_to_hose(PCI_BUS(dev));
#if 0
printf("pci_shadow_rom() asked to shadow device %x to %x\n",
debug("pci_shadow_rom() asked to shadow device %x to %x\n",
dev, (u32)dest);
#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);
@ -81,10 +83,7 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
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
@ -93,7 +92,8 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
if (0 == memcmp((void *)pci_data, "PCIR", 4)) {
#ifdef PCI_ROM_SCAN_VERBOSE
printf("Fount PCI rom image at offset %d\n", i-rom_addr);
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);
@ -111,35 +111,38 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
printf("PARISC code\n");
break;
}
printf("Image size %d\n", readw(pci_data+0x10) * 512);
printf("Image size %d\n",
readw(pci_data + 0x10) * 512);
#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 */
/*
* 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 &&
readw(pci_data + 6) == device &&
/* (readl(pci_data+0x0d)&0xffffff) == class_code && */
readb(pci_data+0x14) == 0 /* x86 code image */ ) {
readb(pci_data + 0x14) == 0) {
#ifdef PCI_ROM_SCAN_VERBOSE
printf("Suitable ROM image found, copying\n");
printf("Suitable ROM image found\n");
#endif
memmove(dest, (void*)rom_addr, readw(pci_data+0x10) * 512);
memmove(dest, (void *)rom_addr,
readw(pci_data + 0x10) * 512);
res = 0;
break;
}
if (readw(pci_data+0x15) &0x80) {
if (readw(pci_data + 0x15) & 0x80)
break;
}
}
}
}
#ifdef PCI_ROM_SCAN_VERBOSE
if (res) {
if (res)
printf("No suitable image found\n");
}
#endif
/* disable PAR register and PCI device ROM address devocer */
pci_remove_rom_window(hose, rom_addr);

View File

@ -29,7 +29,7 @@
#include <asm/io.h>
#include <pci.h>
#define cfg_read(val, addr, op) *val = op((int)(addr))
#define cfg_read(val, addr, op) (*val = op((int)(addr)))
#define cfg_write(val, addr, op) op((val), (int)(addr))
#define TYPE1_PCI_OP(rw, size, type, op, mask) \
@ -42,7 +42,6 @@ type1_##rw##_config_##size(struct pci_controller *hose, \
return 0; \
}
TYPE1_PCI_OP(read, byte, u8 *, inb, 3)
TYPE1_PCI_OP(read, word, u16 *, inw, 2)
TYPE1_PCI_OP(read, dword, u32 *, inl, 0)

View File

@ -28,10 +28,6 @@
#define REALMODE_MAILBOX ((char *)0xe00)
extern ulong __realmode_start;
extern ulong __realmode_size;
extern char realmode_enter;
int realmode_setup(void)
{
ulong realmode_start = (ulong)&__realmode_start + gd->reloc_off;
@ -63,9 +59,8 @@ int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out)
in->eip = off;
in->xcs = seg;
if (3>(in->esp & 0xffff)) {
if ((in->esp & 0xffff) < 4)
printf("Warning: entering realmode with sp < 4 will fail\n");
}
memcpy(REALMODE_MAILBOX, in, sizeof(struct pt_regs));
asm("wbinvd\n");
@ -79,9 +74,10 @@ int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out)
return out->eax;
}
/* This code is supposed to access a realmode interrupt
* it does currently not work for me */
/*
* This code is supposed to access a realmode interrupt
* it does currently not work for me
*/
int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out)
{
/* place two instructions at 0x700 */
@ -92,5 +88,5 @@ int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out)
enter_realmode(0x00, 0x700, in, out);
return out->eflags&1;
return out->eflags & 0x00000001;
}

View File

@ -35,8 +35,8 @@ struct timer_isr_function {
timer_fnc_t *isr_func;
};
static struct timer_isr_function *first_timer_isr = NULL;
static volatile unsigned long system_ticks = 0;
static struct timer_isr_function *first_timer_isr;
static unsigned long system_ticks;
/*
* register_timer_isr() allows multiple architecture and board specific
@ -96,5 +96,5 @@ void timer_isr(void *unused)
ulong get_timer(ulong base)
{
return (system_ticks - base);
return system_ticks - base;
}

View File

@ -28,6 +28,7 @@
#include <asm/realmode.h>
#include <asm/io.h>
#include <asm/pci.h>
#include "bios.h"
#undef PCI_BIOS_DEBUG
#undef VGA_BIOS_DEBUG
@ -41,37 +42,36 @@
#ifdef CONFIG_PCI
#ifdef PCI_BIOS_DEBUG
#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;
extern u32 num_pci_bios_generate_special_cycle;
extern u32 num_pci_bios_read_cfg_byte;
extern u32 num_pci_bios_read_cfg_word;
extern u32 num_pci_bios_read_cfg_dword;
extern u32 num_pci_bios_write_cfg_byte;
extern u32 num_pci_bios_write_cfg_word;
extern u32 num_pci_bios_write_cfg_dword;
extern u32 num_pci_bios_get_irq_routing;
extern u32 num_pci_bios_set_irq;
extern u32 num_pci_bios_unknown_function;
void print_bios_bios_stat(void)
{
printf("16 bit functions:\n");
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_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));
printf("pci_bios_write_cfg_byte: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_byte));
printf("pci_bios_write_cfg_word: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_word));
printf("pci_bios_write_cfg_dword: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_dword));
printf("pci_bios_get_irq_routing: %d\n", RELOC_16(0xf000, num_pci_bios_get_irq_routing));
printf("pci_bios_set_irq: %d\n", RELOC_16(0xf000, num_pci_bios_set_irq));
printf("pci_bios_unknown_function: %d\n", RELOC_16(0xf000, num_pci_bios_unknown_function));
printf("pci_bios_present: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_present));
printf("pci_bios_find_device: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_find_device));
printf("pci_bios_find_class: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_find_class));
printf("pci_bios_generate_special_cycle: %d\n",
RELOC_16_LONG(0xf000,
num_pci_bios_generate_special_cycle));
printf("pci_bios_read_cfg_byte: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_read_cfg_byte));
printf("pci_bios_read_cfg_word: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_read_cfg_word));
printf("pci_bios_read_cfg_dword: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_read_cfg_dword));
printf("pci_bios_write_cfg_byte: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_write_cfg_byte));
printf("pci_bios_write_cfg_word: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_write_cfg_word));
printf("pci_bios_write_cfg_dword: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_write_cfg_dword));
printf("pci_bios_get_irq_routing: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_get_irq_routing));
printf("pci_bios_set_irq: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_set_irq));
printf("pci_bios_unknown_function: %d\n",
RELOC_16_LONG(0xf000, num_pci_bios_unknown_function));
}
#endif
@ -82,32 +82,40 @@ void print_bios_bios_stat(void)
#define PCI_CLASS_VIDEO_STD 0
#define PCI_CLASS_VIDEO_PROG_IF_VGA 0
static struct pci_device_id supported[] = {
DEFINE_PCI_DEVICE_TABLE(supported) = {
{PCI_VIDEO_VENDOR_ID, PCI_VIDEO_DEVICE_ID},
{}
};
static u32 probe_pci_video(void)
{
pci_dev_t devbusfn;
struct pci_controller *hose;
pci_dev_t devbusfn = pci_find_devices(supported, 0);
if ((devbusfn = pci_find_devices(supported, 0) != -1)) {
if ((devbusfn != -1)) {
u32 old;
u32 addr;
/* PCI video device detected */
printf("Found PCI VGA device at %02x.%02x.%x\n",
PCI_BUS(devbusfn), PCI_DEV(devbusfn), PCI_FUNC(devbusfn));
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);
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_write_config_dword(devbusfn, PCI_ROM_ADDRESS, (u32)PCI_ROM_ADDRESS_MASK);
pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS,
(u32)PCI_ROM_ADDRESS_MASK);
pci_read_config_dword(devbusfn, PCI_ROM_ADDRESS, &addr);
pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS, old);
@ -123,7 +131,8 @@ static u32 probe_pci_video(void)
}
/* Now enable lagacy VGA port access */
if (pci_enable_legacy_video_ports(pci_bus_to_hose(PCI_BUS(devbusfn)))) {
hose = pci_bus_to_hose(PCI_BUS(devbusfn));
if (pci_enable_legacy_video_ports(hose)) {
printf("PCI VGA enable failed\n");
return 0;
}
@ -142,13 +151,17 @@ static int probe_isa_video(void)
u32 ptr;
char *buf;
if (0 == (ptr = isa_map_rom(0xc0000, 0x8000))) {
ptr = isa_map_rom(0xc0000, 0x8000);
if (!ptr)
return -1;
}
if (NULL == (buf=malloc(0x8000))) {
buf = malloc(0x8000);
if (!buf) {
isa_unmap_rom(ptr);
return -1;
}
if (readw(ptr) != 0xaa55) {
free(buf);
isa_unmap_rom(ptr);
@ -168,35 +181,35 @@ static int probe_isa_video(void)
int video_bios_init(void)
{
struct pt_regs regs;
int size;
int i;
u8 sum;
/* clear the video bios area in case we warmbooted */
memset((void *)0xc0000, 0, 0x8000);
memset(&regs, 0, sizeof(struct pt_regs));
if (probe_isa_video()) {
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);
size = readb(0xc0002) * 512;
PRINTF("size %d\n", size);
sum = 0;
for (i=0;i<size;i++) {
sum += readb(0xc0000 + i);
}
PRINTF("Checksum is %sOK\n",sum?"NOT ":"");
if (sum) {
return 1;
}
/* some video bioses (ATI Mach64) seem to think that
for (i = 0; i < size; i++)
sum += readb(0xc0000 + i);
PRINTF("Checksum is %sOK\n", sum ? "NOT " : "");
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
*/
@ -205,13 +218,15 @@ int video_bios_init(void)
regs.esp = 0x8000;
regs.xss = 0x2000;
enter_realmode(0xc000, 3, &regs, &regs);
PRINTF("INT 0x10 vector after: %04x:%04x\n",
readw(0x42), readw(0x40));
PRINTF("BIOS returned %scarry\n", regs.eflags & 1?"":"NOT ");
PRINTF("BIOS returned %scarry\n",
regs.eflags & 0x00000001 ? "" : "NOT ");
#ifdef PCI_BIOS_DEBUG
print_bios_bios_stat();
#endif
return (regs.eflags & 1);
return regs.eflags & 0x00000001;
}

View File

@ -60,8 +60,8 @@ static void build_command_line(char *command_line, int auto_boot)
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")) {
if (!strstr(env_command_line, "console=")) {
if (!strcmp(getenv("stdout"), "serial")) {
/* We seem to use serial console */
sprintf(command_line, "console=ttyS0,%s ",
@ -69,14 +69,11 @@ static void build_command_line(char *command_line, int auto_boot)
}
}
if (auto_boot) {
if (auto_boot)
strcat(command_line, "auto ");
}
if (NULL != env_command_line) {
if (env_command_line)
strcat(command_line, env_command_line);
}
printf("Kernel command line: \"%s\"\n", command_line);
}
@ -90,10 +87,12 @@ void *load_zimage(char *image, unsigned long kernel_size,
int bootproto;
int big_image;
void *load_address;
struct setup_header *hdr;
struct setup_header *hdr = (struct setup_header *)(image + SETUP_SECTS_OFF);
hdr = (struct setup_header *)(image + SETUP_SECTS_OFF);
setup_base = (void*)DEFAULT_SETUP_BASE; /* base address for real-mode segment */
/* base address for real-mode segment */
setup_base = (void *)DEFAULT_SETUP_BASE;
if (KERNEL_MAGIC != hdr->boot_flag) {
printf("Error: Invalid Boot Flag (found 0x%04x, expected 0x%04x)\n",
@ -124,43 +123,50 @@ void *load_zimage(char *image, unsigned long kernel_size,
printf("Setup Size = 0x%8.8lx\n", (ulong)setup_size);
if (setup_size > SETUP_MAX_SIZE) {
if (setup_size > SETUP_MAX_SIZE)
printf("Error: Setup is too large (%d bytes)\n", setup_size);
}
/* Determine image type */
big_image = (bootproto >= 0x0200) && (hdr->loadflags & BIG_KERNEL_FLAG);
big_image = (bootproto >= 0x0200) &&
(hdr->loadflags & BIG_KERNEL_FLAG);
/* Determine load address */
load_address = (void*)(big_image ? BZIMAGE_LOAD_ADDR : ZIMAGE_LOAD_ADDR);
load_address = (void *)(big_image ?
BZIMAGE_LOAD_ADDR :
ZIMAGE_LOAD_ADDR);
/* load setup */
printf("Moving Real-Mode Code to 0x%8.8lx (%d bytes)\n", (ulong)setup_base, setup_size);
printf("Moving Real-Mode Code to 0x%8.8lx (%d bytes)\n",
(ulong)setup_base, setup_size);
memmove(setup_base, image, setup_size);
printf("Using boot protocol version %x.%02x\n",
(bootproto & 0xff00) >> 8, bootproto & 0xff);
if (bootproto == 0x0100) {
*(u16 *)(setup_base + CMD_LINE_MAGIC_OFF) = COMMAND_LINE_MAGIC;
*(u16 *)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET;
/* A very old kernel MUST have its real-mode code
* loaded at 0x90000 */
/*
* 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 */
/* Relocated */
setup_base = (void *)0x90000;
}
/* It is recommended to clear memory up to the 32K mark */
memset((void*)0x90000 + setup_size, 0, SETUP_MAX_SIZE-setup_size);
memset((void *)0x90000 + setup_size, 0,
SETUP_MAX_SIZE-setup_size);
}
/* We are now setting up the real-mode version of the header */
@ -170,8 +176,9 @@ void *load_zimage(char *image, unsigned long kernel_size,
hdr->type_of_loader = 8;
if (hdr->setup_sects >= 15)
printf("Linux kernel version %s\n", (char *)
(setup_base + (hdr->kernel_version + 0x200)));
printf("Linux kernel version %s\n",
(char *)(setup_base +
(hdr->kernel_version + 0x200)));
else
printf("Setup Sectors < 15 - Cannot print kernel version.\n");
@ -221,8 +228,8 @@ void *load_zimage(char *image, unsigned long kernel_size,
/* 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' : ' ',
(u32)load_address, kernel_size);
printf("Loading %czImage at address 0x%08x (%ld bytes)\n",
big_image ? 'b' : ' ', (u32)load_address, kernel_size);
memmove(load_address, image + setup_size, kernel_size);
@ -241,7 +248,8 @@ void boot_zimage(void *setup_base)
regs.xss = regs.xds;
regs.esp = 0x9000;
regs.eflags = 0;
enter_realmode(((u32)setup_base+SETUP_START_OFFSET)>>4, 0, &regs, &regs);
enter_realmode(((u32)setup_base+SETUP_START_OFFSET)>>4, 0, &regs,
&regs);
}
int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
@ -272,7 +280,7 @@ int do_zboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/* Lets look for*/
base_ptr = load_zimage(bzImage_addr, bzImage_size, 0, 0, 0);
if (NULL == base_ptr) {
if (!base_ptr) {
printf("## Kernel loading failed ...\n");
} else {
printf("## Transferring control to Linux (at address %08x) ...\n",