* include cleanup. We don't provide stdint.h, so use arch/types.h
  instead.
* drop some unused variables
* fix comment style in some headers to match the template
* Fix the loglevel of some debugging output.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@275 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
Stefan Reinauer 2007-04-06 14:05:26 +00:00
commit bea6044faa
18 changed files with 183 additions and 149 deletions

View file

@ -2,14 +2,12 @@
#include <arch/hlt.h>
#include <console/console.h>
#include <uart8250.h>
// FIXME: we need this for varargs
#include <stdarg.h>
int vtxprintf(void (*)(unsigned char, void *arg),
void *arg, const char *, va_list);
static int console_loglevel(void)
{
return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;

View file

@ -4,6 +4,7 @@
* (c) 1999--2000 Martin Mares <mj@suse.cz>
* (c) 2003 Eric Biederman <ebiederm@xmission.com>
* (c) 2003 Linux Networx
* (C) 2007 coresystems GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,14 +33,14 @@
*/
#include <console/console.h>
//#include <bitops.h>
#include <arch/io.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <lib.h>
#warning Do we need spinlocks in device/device.c?
//#include <smp/spinlock.h>
/** Linked list of ALL devices */
@ -87,7 +88,11 @@ dev_init(void)
struct device *default_device_constructor(struct constructor *constructor){
struct device *dev;
dev = malloc(sizeof(*dev));
if (dev == 0) {
// FIXME: This is overkill. Our malloc will never return with
// a return value of NULL. So this is dead code (and thus would
// drop code coverage and usability in safety critical environments
if (dev == NULL) {
die("DEV: out of memory.\n");
}
memset(dev, 0, sizeof(dev));
@ -112,11 +117,13 @@ struct constructor *find_constructor(struct device_id *id){
int i;
printk(BIOS_SPEW, "%s: find %s\n", __func__, dev_id_string(id));
for(i = 0; all_constructors[i]; i++) {
printk(BIOS_SPEW, "%s: check all_constructors[i] 0x%lx\n", __func__, all_constructors[i]);
printk(BIOS_SPEW, "%s: check all_constructors[i] 0x%lx\n",
__func__, all_constructors[i]);
for(c = all_constructors[i]; c->ops; c++) {
printk(BIOS_SPEW, "%s: cons 0x%lx, cons id %s\n", __func__, c, dev_id_string(&c->id));
printk(BIOS_SPEW, "%s: cons 0x%lx, cons id %s\n",
__func__, c, dev_id_string(&c->id));
if ((! c->ops) || (!c->ops->constructor)) {
printk(BIOS_ERR, "Constructor for %s with missing ops or ops->constructor!\n",
printk(BIOS_INFO, "Constructor for %s with missing ops or ops->constructor!\n",
dev_id_string(&c->id));
continue;
}
@ -148,12 +155,12 @@ struct device *constructor(struct device_id *id){
struct device *dev = 0;
c = find_constructor(id);
printk(BIOS_INFO, "%s constructor is 0x%lx\n", __func__, c);
printk(BIOS_DEBUG, "%s constructor is 0x%lx\n", __func__, c);
if (! c)
return 0;
dev = c->ops->constructor(c);
printk(BIOS_INFO, "%s returns 0x%lx\n", __func__, dev);
printk(BIOS_DEBUG, "%s returns 0x%lx\n", __func__, dev);
return dev;
}
@ -180,23 +187,25 @@ struct device * alloc_dev(struct bus *parent, struct device_path *path, struct d
// spin_lock(&dev_lock);
/* Find the last child of our parent */
for(child = parent->children; child && child->sibling; ) {
for (child = parent->children; child && child->sibling; ) {
child = child->sibling;
}
dev = constructor(devid);
if (! dev)
printk(BIOS_INFO, "%s: No constructor, going with empty dev", dev_id_string(devid));
dev = malloc(sizeof(*dev));
if (dev == 0) {
die("DEV: alloc_dev: out of memory.\n");
}
memset(dev, 0, sizeof(*dev));
if (!dev)
printk(BIOS_DEBUG, "%s: No constructor, going with empty dev",
dev_id_string(devid));
dev = malloc(sizeof(*dev));
if (dev == NULL) {
die("DEV: out of memory.\n");
}
memset(dev, 0, sizeof(*dev));
memcpy(&dev->path, path, sizeof(*path));
/* Initialize the back pointers in the link fields */
for(link = 0; link < MAX_LINKS; link++) {
for (link = 0; link < MAX_LINKS; link++) {
dev->link[link].dev = dev;
dev->link[link].link = link;
}
@ -220,7 +229,7 @@ struct device * alloc_dev(struct bus *parent, struct device_path *path, struct d
/* give the device a name */
dev -> dtsname = malloc(32);
if (dev->dtsname == 0) {
if (dev->dtsname == NULL) {
die("DEV: out of memory.\n");
}
sprintf(dev->dtsname, "dynamic %s", dev_path(dev));
@ -251,8 +260,9 @@ static void read_resources(struct bus *bus)
{
struct device *curdev;
printk(BIOS_SPEW, "%s: %s(%s) read_resources bus %d link: %d\n", __func__, bus->dev->dtsname,
dev_path(bus->dev), bus->secondary, bus->link);
printk(BIOS_SPEW, "%s: %s(%s) read_resources bus %d link: %d\n",
__func__, bus->dev->dtsname, dev_path(bus->dev),
bus->secondary, bus->link);
/* Walk through all of the devices and find which resources they need. */
for(curdev = bus->children; curdev; curdev = curdev->sibling) {
@ -335,8 +345,8 @@ static void pick_largest_resource(void *gp,
}
}
static struct device *largest_resource(struct bus *bus, struct resource **result_res,
unsigned long type_mask, unsigned long type)
static struct device *largest_resource(struct bus *bus, struct resource
**result_res, unsigned long type_mask, unsigned long type)
{
struct pick_largest_state state;
@ -508,10 +518,11 @@ struct device * vga_pri = 0;
int vga_inited = 0;
static void allocate_vga_resource(void)
{
#warning "FIXME modify allocate_vga_resource so it is less pci centric!"
#warning "This function knows to much about PCI stuff, it should be just a iterator/visitor."
#warning Modify allocate_vga_resource so it is less pci centric.
// FIXME: This function knows to much about PCI stuff,
// it should just be an iterator/visitor.
/* FIXME handle the VGA pallette snooping */
/* FIXME: handle the VGA pallette snooping */
struct device *dev, *vga, *vga_onboard, *vga_first, *vga_last;
struct bus *bus;
bus = 0;
@ -605,12 +616,12 @@ void phase4_assign_resources(struct bus *bus)
continue;
}
if (!curdev->ops) {
printk(BIOS_ERR, "%s(%s) missing ops\n",
printk(BIOS_WARNING, "%s(%s) missing ops\n",
curdev->dtsname, dev_path(curdev));
continue;
}
if (!curdev->ops->phase4_set_resources) {
printk(BIOS_ERR, "%s(%s) ops has no missing phase4_set_resources\n",
printk(BIOS_WARNING, "%s(%s) ops has no missing phase4_set_resources\n",
curdev->dtsname, dev_path(curdev));
continue;
}
@ -644,11 +655,12 @@ void dev_phase5(struct device *dev)
return;
}
if (!dev->ops) {
printk(BIOS_ERR, "%s: %s(%s) missing ops\n", __FUNCTION__, dev->dtsname, dev_path(dev));
printk(BIOS_WARNING, "%s: %s(%s) missing ops\n",
__FUNCTION__, dev->dtsname, dev_path(dev));
return;
}
if (!dev->ops->phase5_enable_resources) {
printk(BIOS_ERR, "%s: %s(%s) ops are missing phase5_enable_resources\n", __FUNCTION__, dev->dtsname, dev_path(dev));
printk(BIOS_WARNING, "%s: %s(%s) ops are missing phase5_enable_resources\n", __FUNCTION__, dev->dtsname, dev_path(dev));
return;
}
@ -696,7 +708,7 @@ void dev_phase1(void)
}
}
post_code(0x3e);
printk(BIOS_INFO, "Phase 1: done\n");
printk(BIOS_DEBUG, "Phase 1: done\n");
post_code(0x3f);
}
@ -712,7 +724,7 @@ void dev_phase2(void)
struct device *dev;
post_code(0x41);
printk(BIOS_INFO, "Phase 2: Early setup...\n");
printk(BIOS_DEBUG, "Phase 2: Early setup...\n");
for(dev = all_devices; dev; dev = dev->next) {
printk(BIOS_SPEW, "%s: dev %s: ", __FUNCTION__, dev->dtsname);
if (dev->ops && dev->ops->phase2_setup_scan_bus) {
@ -724,7 +736,7 @@ void dev_phase2(void)
}
post_code(0x4e);
printk(BIOS_INFO, "Phase 2: Done.\n");
printk(BIOS_DEBUG, "Phase 2: Done.\n");
post_code(0x4f);
}

View file

@ -26,15 +26,16 @@
* Copyright 2003 -- Eric Biederman <ebiederman@lnxi.com>
*/
#include <console/console.h>
#include <stdlib.h>
#include <stdint.h>
#include <arch/types.h>
#include <arch/io.h>
#include <string.h>
#include <lib.h>
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
#include <lib.h>
#include <arch/io.h>
#define CONFIG_HYPERTRANSPORT_PLUGIN_SUPPORT 0
#define CONFIG_PCIX_PLUGIN_SUPPORT 0
#define CONFIG_PCIEXP_PLUGIN_SUPPORT 0

View file

@ -15,4 +15,8 @@ typedef signed int s32;
typedef signed short s16;
typedef signed char s8;
typedef u64 size_t;
#define NULL ((void *)0)
#endif

View file

@ -1,24 +1,23 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#ifndef PCI_ROM_H
#define PCI_ROM_H
#include <arch/types.h>
#include <arch/byteorder.h>
#include <stddef.h>
#define PCI_ROM_HDR 0xAA55
#define PCI_DATA_HDR (u32) ( ('R' << 24) | ('I' << 16) | ('C' << 8) | 'P' )

View file

@ -1,35 +1,36 @@
/* This file was taken from the GNU C Library, CVS rev. 1.156, and modified
for use by the LinuxBIOS project. */
/* This file was taken from the GNU C Library, CVS rev. 1.156,
* and modified for use by the LinuxBIOS project.
*/
/* This file defines standard ELF types, structures, and macros.
Copyright (C) 1995-2003,2004,2005,2006,2007 Free Software Foundation, Inc.
Copyright (C) 2001 Eric Biederman <ebiederman@lnxi.com>
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
* Copyright (C) 1995-2003,2004,2005,2006,2007 Free Software Foundation, Inc.
* Copyright (C) 2001 Eric Biederman <ebiederman@lnxi.com>
* This file is part of the GNU C Library.
*
* The GNU C Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* The GNU C Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the GNU C Library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA.
*/
#ifndef _ELF_H
#define _ELF_H 1
#include <features.h>
#include <arch/types.h>
#include <arch/elf.h>
/* Standard ELF types. */
#include <stdint.h>
/* Type for a 16-bit quantity. */
typedef u16 Elf32_Half;
@ -907,10 +908,10 @@ typedef struct
typedef struct
{
uint32_t a_type; /* Entry type */
u32 a_type; /* Entry type */
union
{
uint32_t a_val; /* Integer value */
u32 a_val; /* Integer value */
/* We use to have pointer elements added here. We cannot do that,
though, since it does not work when using 32-bit definitions
on 64-bit platforms and vice versa. */
@ -919,10 +920,10 @@ typedef struct
typedef struct
{
uint64_t a_type; /* Entry type */
u64 a_type; /* Entry type */
union
{
uint64_t a_val; /* Integer value */
u64 a_val; /* Integer value */
/* We use to have pointer elements added here. We cannot do that,
though, since it does not work when using 32-bit definitions
on 64-bit platforms and vice versa. */

View file

@ -20,7 +20,7 @@
#ifndef ELF_BOOT_H
#define ELF_BOOT_H
#include <stdint.h>
#include <arch/types.h>
/* This defines the structure of a table of parameters useful for ELF
* bootable images. These parameters are all passed and generated

View file

@ -47,7 +47,7 @@
* ---------------------------------------------------------------------------
*/
#include <stdint.h>
#include <arch/types.h>
#define MAGIC "LARCHIVE"
#define MAX_PATHLEN 1024

View file

@ -20,7 +20,7 @@
#ifndef LINUXBIOS_TABLES_H
#define LINUXBIOS_TABLES_H
#include <stdint.h>
#include <arch/types.h>
/* The LinuxBIOS table information is for conveying information
* from the firmware to the loaded OS image. Primarily this

20
include/stdlib.h Normal file
View file

@ -0,0 +1,20 @@
/*
* Copyright (C) 2007 coresystems GmbH
* Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
*/
void *malloc(size_t size);

View file

@ -21,7 +21,7 @@
#ifndef STRING_H
#define STRING_H
#include <stdlib.h>
#include <arch/types.h>
/* Prototypes for functions from lib/mem.c. */
extern void *memcpy(void *dest, const void *src, int len);

View file

@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include <arch/types.h>
#include <ip_checksum.h>
#include <string.h>
unsigned long compute_ip_checksum(void *addr, unsigned long length)
{
uint16_t *ptr;
u16 *ptr;
unsigned long sum;
unsigned long len;
unsigned long laddr;
@ -33,7 +33,7 @@ unsigned long compute_ip_checksum(void *addr, unsigned long length)
laddr = (unsigned long )addr;
sum = 0;
if (laddr & 1) {
uint16_t buffer;
u16 buffer;
unsigned char *ptr;
/* copy the first byte into a 2 byte buffer.
* This way automatically handles the endian question
@ -58,7 +58,7 @@ unsigned long compute_ip_checksum(void *addr, unsigned long length)
}
addr = ptr;
if (length & 1) {
uint16_t buffer;
u16 buffer;
unsigned char *ptr;
/* copy the last byte into a 2 byte buffer.
* This way automatically handles the endian question

View file

@ -26,13 +26,13 @@
* no calls to malloc
*/
#include <arch/types.h>
#include <string.h>
#include <console/console.h>
#include <linuxbios_tables.h>
#include <elf.h>
#include <elf_boot.h>
#include <linuxbios_tables.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
static int valid_area(struct lb_memory *mem,
unsigned long start, unsigned long len)

View file

@ -23,6 +23,7 @@
* has had this at some time or other.
*/
#include <arch/types.h>
#include <stdlib.h>
#include <console/console.h>
@ -51,11 +52,11 @@ void *malloc(size_t size)
{
void *p;
MALLOCDBG("%s Enter, size %d, free_mem_ptr %p\n", __FUNCTION__, size,
free_mem_ptr);
MALLOCDBG("%s Enter, size %d, free_mem_ptr %p\n",
__FUNCTION__, size, free_mem_ptr);
if (size > freebytes) {
die("OUT OF MEMORY\n");
die("Out of memory.\n");
}
size = (size + 3) & (~3); /* Align */

View file

@ -18,14 +18,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <arch/types.h>
#include <console/console.h>
#include <stdint.h>
#include <device/device.h>
#include <device/pci.h>
#include <stdlib.h>
#include <string.h>
#include <keyboard.h>
#include "config.h"
static void setup_onboard(struct device *dev)
{

View file

@ -16,6 +16,7 @@
* such modified SOFTWARE should be clearly marked, so as not to confuse
* it with the version available from LANL.
*/
/* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
* Copyright (C) 2007 Ronald G. Minnich <rminnich@gmail.com>
* This program is free software; you can redistribute it and/or modify
@ -31,16 +32,15 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#include <arch/types.h>
#include <console/console.h>
#include <stdint.h>
#include <device/device.h>
#include <device/pci.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "i440bx.h"
#include "config.h"
/* Here are the ops for 440BX as a PCI domain. */
/* A PCI domain contains the I/O and memory resource address space below it. */
@ -75,7 +75,7 @@ static void ram_resource(struct device *dev, unsigned long index,
resource->size = ((resource_t) sizek) << 10;
resource->flags = IORESOURCE_MEM | IORESOURCE_CACHEABLE |
IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
printk(BIOS_INFO, "%s: add ram resoource %d bytes\n", __func__,
printk(BIOS_DEBUG, "%s: add ram resoource %d bytes\n", __func__,
resource->size);
}

View file

@ -20,14 +20,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <arch/types.h>
#include <console/console.h>
#include <stdint.h>
#include <device/device.h>
#include <device/pci.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
// #include "i82371eb.h"
/* The plain PCI device uses the standard PCI operations. */
/* TODO: bring in the rest of the v2 code for controlling IDE enable.

View file

@ -1,9 +1,10 @@
/*
* Erik Arjan Hendriks <hendriks@lanl.gov>
* (C) 2000 Scyld.
* Copyright (C) 2000 Scyld.
* Copyright (C) 2000 Scyld Computing Corporation
* Copyright (C) 2001 University of California. LA-CC Number 01-67.
* (C) 2005 Nick.Barker9@btinternet.com
* Copyright (C) 2005 Nick.Barker9@btinternet.com
* Copyright (C) 2007 coresystems GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,17 +22,19 @@
*
*/
#include <console/console.h>
#include <device/pci.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>
#undef __KERNEL__
#include <arch/io.h>
//#include <printk.h>
#include <console/console.h>
#include <string.h>
//#include "vgachip.h"
/* Declare a temporary global descriptor table - necessary because the
Core part of the bios no longer sets up any 16 bit segments */
#include <arch/io.h>
/* Declare a temporary global descriptor table -
* necessary because the core part of the bios
* no longer sets up any 16 bit segments
*/
__asm__ (
/* pointer to original gdt */
"gdtarg: \n"
@ -76,6 +79,7 @@ __asm__ (
"__mygdt_end: \n"
/* FIXME: This does probably not belong here */
"idtarg:\n"
" .word _idt_end - _idt - 1\n" /* limit */
" .long _idt\n"
@ -84,10 +88,8 @@ __asm__ (
" .fill 20, 8, 0\n" // # idt is unitiailzed
"_idt_end:\n"
);
/* Declare a pointer to where our idt is going to be i.e. at mem zero */
__asm__ ("__myidt: \n"
/* Declare a pointer to where our idt is going to be i.e. at mem zero */
"__myidt: \n"
/* 16-bit limit */
" .word 1023 \n"
/* 24-bit base */
@ -99,8 +101,9 @@ __asm__ ("__myidt: \n"
static void real_mode_switch_call_vga(unsigned long devfn)
{
__asm__ __volatile__ (
// paranoia -- does ecx get saved? not sure. This is
// the easiest safe thing to do.
/* paranoia -- does ecx get saved? not sure.
* This is the easiest safe thing to do.
*/
" pushal \n"
/* save the stack */
" mov %esp, __stack \n"
@ -109,6 +112,7 @@ static void real_mode_switch_call_vga(unsigned long devfn)
"1:\n"
/* get devfn into %ecx */
" movl %esp, %ebp \n"
// FIXME: why is this 8?
" movl 8(%ebp), %ecx \n"
/* load 'our' gdt */
" lgdt %cs:__mygdtaddr \n"
@ -119,9 +123,11 @@ static void real_mode_switch_call_vga(unsigned long devfn)
" .code16 \n"
/* 16 bit code from here on... */
/* Load the segment registers w/ properly configured segment
* descriptors. They will retain these configurations (limits,
* writability, etc.) once protected mode is turned off. */
/* Load the segment registers w/ properly configured
* segment descriptors. They will retain these
* configurations (limits, writability, etc.) once
* protected mode is turned off.
*/
" mov $0x30, %ax \n"
" mov %ax, %ds \n"
" mov %ax, %es \n"
@ -138,10 +144,10 @@ static void real_mode_switch_call_vga(unsigned long devfn)
" ljmp $0, $__rms_real\n"
"__rms_real: \n"
/* put the stack at the end of page zero.
* that way we can easily share it between real and protected,
* since the 16-bit ESP at segment 0 will work for any case. */
/* Setup a stack */
/* Setup a stack: Put the stack at the end of page zero.
* That way we can easily share it between real and
* protected, since the 16-bit ESP at segment 0 will
* work for any case. */
" mov $0x0, %ax \n"
" mov %ax, %ss \n"
" movl $0x1000, %eax \n"
@ -152,7 +158,7 @@ static void real_mode_switch_call_vga(unsigned long devfn)
" mov %ax, %ds \n"
" lidt __myidt \n"
/* Dump zeros in the other segregs */
/* Dump zeros in the other segment registers */
" mov %ax, %es \n"
" mov %ax, %fs \n"
" mov %ax, %gs \n"
@ -163,13 +169,16 @@ static void real_mode_switch_call_vga(unsigned long devfn)
/* run VGA BIOS at 0xc000:0003 */
" lcall $0xc000, $0x0003\n"
/* if we got here, just about done.
* Need to get back to protected mode */
/* If we got here, just about done.
* Need to get back to protected mode
*/
" movl %cr0, %eax \n"
" orl $0x0000001, %eax\n" /* PE = 1 */
" movl %eax, %cr0 \n"
/* Now that we are in protected mode jump to a 32 bit code segment. */
/* Now that we are in protected mode
* jump to a 32 bit code segment.
*/
" data32 ljmp $0x10, $vgarestart\n"
"vgarestart:\n"
" .code32\n"
@ -191,12 +200,13 @@ static void real_mode_switch_call_vga(unsigned long devfn)
);
}
__asm__ (".text\n""real_mode_switch_end:\n");
extern char real_mode_switch_end[];
// FIXME: drop this
// __asm__ (".text\n""real_mode_switch_end:\n");
// extern char real_mode_switch_end[];
/* call vga bios int 10 function 0x4f14 to enable main console
epia-m does not always autosence the main console so forcing it on is good !! */
void vga_enable_console()
void vga_enable_console(void)
{
__asm__ __volatile__ (
/* paranoia -- does ecx get saved? not sure. This is
@ -602,7 +612,7 @@ void setup_realmode_idt(void)
// and get it that way. But that's really disgusting.
for (i = 0; i < 256; i++) {
idts[i].cs = 0;
codeptr = (char*) 4096 + i * codesize;
codeptr = (unsigned char *) 4096 + i * codesize;
idts[i].offset = (unsigned) codeptr;
memcpy(codeptr, &idthandle, codesize);
intbyte = codeptr + 3;
@ -615,7 +625,7 @@ void setup_realmode_idt(void)
// int10.
// calling convention here is the same as INTs, we can reuse
// the int entry code.
codeptr = (char*) 0xff065;
codeptr = (unsigned char *) 0xff065;
memcpy(codeptr, &idthandle, codesize);
intbyte = codeptr + 3;
*intbyte = 0x42; /* int42 is the relocated int10 */
@ -654,19 +664,11 @@ pcibios(unsigned long *pedi, unsigned long *pesi, unsigned long *pebp,
unsigned long *pesp, unsigned long *pebx, unsigned long *pedx,
unsigned long *pecx, unsigned long *peax, unsigned long *pflags)
{
unsigned long edi = *pedi;
unsigned long esi = *pesi;
unsigned long ebp = *pebp;
unsigned long esp = *pesp;
unsigned long ebx = *pebx;
unsigned long edx = *pedx;
unsigned long ecx = *pecx;
unsigned long eax = *peax;
unsigned long flags = *pflags;
unsigned short func = (unsigned short) eax;
unsigned short func = (unsigned short) *peax;
int retval = 0;
unsigned short devid, vendorid, devfn;
short devindex; /* Use short to get rid of gabage in upper half of 32-bit register */
/* Use short to get rid of gabage in upper half of 32-bit register */
short devindex;
unsigned char bus;
struct device *dev;