Code changes from my work and the AMD760MP chipset.

The primary changes is the way in which printk works.
But there are many other assorted code cleanups.
Just look and see :)
This commit is contained in:
Eric W. Biederman 2001-08-08 02:45:10 +00:00
commit ed8c9d7e0d
62 changed files with 1362 additions and 977 deletions

View file

@ -11,4 +11,5 @@ object memcmp.o
object malloc.o
object elfboot.o
object do_inflate.o
object delay.o

View file

@ -41,11 +41,11 @@ typedef unsigned long ulg;
#ifdef TRACEV
# define Trace(x) printk(KERN_DDEBUG x)
# define Tracev(x) {if (verbose) printk(KERN_DDEBUG x);}
# define Tracevv(x) {if (verbose>1) printk(KERN_DDEBUG x);}
# define Tracec(c,x) {if (verbose && (c)) printk(KERN_DDEBUG x);}
# define Tracecv(c,x) {if (verbose>1 && (c)) printk(KERN_DDEBUG x);}
# define Trace(x) printk_debug(x)
# define Tracev(x) {if (verbose) printk_debug(x);}
# define Tracevv(x) {if (verbose>1) printk_debug(x);}
# define Tracec(c,x) {if (verbose && (c)) printk_debug(x);}
# define Tracecv(c,x) {if (verbose>1 && (c)) printk_debug(x);}
#else
# define Trace(x)
# define Tracev(x)
@ -73,7 +73,7 @@ static void flush_window(void)
in = window;
out = &output_data[output_ptr];
DBG("flush 0x%08x count 0x%08x\n", (unsigned long) out, outcnt);
printk_debug("flush 0x%08x count 0x%08x\n", (unsigned long) out, outcnt);
for (n = 0; n < outcnt; n++) {
ch = *out++ = *in++;
@ -96,6 +96,6 @@ void gunzip_setup(void)
window = malloc(WSIZE);
#endif
output_data = (char *) KERNEL_START;
DBG("output data is 0x%08x\n", (unsigned long) output_data);
printk_debug("output data is 0x%08x\n", (unsigned long) output_data);
makecrc();
}

View file

@ -57,11 +57,11 @@ int elfboot(size_t totalram)
void *ptr, *entry;
int i;
printk("\n");
printk("Welcome to elfboot, the open sourced starter.\n");
printk("Febuary 2001, Eric Biederman.\n");
printk("Version 0.99\n");
printk("\n");
printk_info("\n");
printk_info("Welcome to elfboot, the open sourced starter.\n");
printk_info("Febuary 2001, Eric Biederman.\n");
printk_info("Version 0.99\n");
printk_info("\n");
ptr = get_ube_pointer(totalram);
post_code(0xf8);
@ -88,11 +88,10 @@ int elfboot(size_t totalram)
/* Sanity check the segments and zero the extra bytes */
for(i = 0; i < ehdr->e_phnum; i++) {
unsigned long start;
unsigned char *dest, *end;
if (!safe_range(phdr[i].p_paddr, phdr[i].p_memsz)) {
printk("Bad memory range: [0x%016lx, 0x%016lx)\n",
printk_err("Bad memory range: [0x%016lx, 0x%016lx)\n",
phdr[i].p_paddr, phdr[i].p_memsz);
goto out;
}
@ -100,9 +99,14 @@ int elfboot(size_t totalram)
end = dest + phdr[i].p_memsz;
dest += phdr[i].p_filesz;
/* Zero the extra bytes */
while(dest < end) {
*(dest++) = 0;
if (dest < end) {
printk_debug("Clearing Section: addr: 0x%016lx memsz: 0x%016lx\n",
(unsigned long)dest, end - dest);
/* Zero the extra bytes */
while(dest < end) {
*(dest++) = 0;
}
}
}
@ -137,7 +141,7 @@ int elfboot(size_t totalram)
if (!cur_phdr) {
break;
}
printk("Loading Section: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n",
printk_debug("Loading Section: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n",
cur_phdr->p_paddr, cur_phdr->p_memsz, cur_phdr->p_filesz);
/* Compute the boundaries of the section */
@ -186,21 +190,21 @@ int elfboot(size_t totalram)
/* The extra bytes between dest & end have been zeroed */
}
DBG("Jumping to boot code\n");
printk_debug("Jumping to boot code\n");
post_code(0xfe);
/* Jump to kernel */
jmp_to_elf_entry(entry, ptr);
out:
printk("Bad ELF Image\n");
printk_err("Bad ELF Image\n");
for(i = 0; i < sizeof(*ehdr); i++) {
if ((i & 0xf) == 0) {
printk("\n");
printk_err("\n");
}
printk("%02x ", header[i]);
printk_err("%02x ", header[i]);
}
printk("\n");
printk_err("\n");
return 0;
}

View file

@ -999,7 +999,7 @@ STATIC int inflate()
/* return success */
DBG("<%u> ", h);
printk_debug("<%u> ", h);
return 0;
}

View file

@ -52,13 +52,13 @@ int linuxbiosmain(unsigned long base, unsigned long totalram)
#if USE_ELF_BOOT
return elfboot(totalram);
#else /* !ELF_BOOT */
printk("\n");
printk("Welcome to start32, the open sourced starter.\n");
printk("This space will eventually hold more diagnostic information.\n");
printk("\n");
printk("January 2000, James Hendricks, Dale Webster, and Ron Minnich.\n");
printk("Version 0.1\n");
printk("\n");
printk_info("\n");
printk_info("Welcome to start32, the open sourced starter.\n");
printk_info("This space will eventually hold more diagnostic information.\n");
printk_info("\n");
printk_info("January 2000, James Hendricks, Dale Webster, and Ron Minnich.\n");
printk_info("Version 0.1\n");
printk_info("\n");
initrd_start = 0;
initrd_size = 0;
@ -82,44 +82,44 @@ int linuxbiosmain(unsigned long base, unsigned long totalram)
post_code(0xf1);
#ifdef PYRO_TEST1
printk(KERN_NOTICE "LiLa loader, press a key to test netboot_init:");
printk_notice( "LiLa loader, press a key to test netboot_init:");
buflen = sizeof(buffer);
ttys0_rx_line(buffer, &buflen);
#endif
#ifdef USE_TFTP
netboot_init();
printk(KERN_NOTICE "\nnetboot_init test complete, all is well (I hope!)\n");
printk_notice("\nnetboot_init test complete, all is well (I hope!)\n");
#endif /* USE_TFTP */
DBG("Gunzip setup\n");
printk_debug("Gunzip setup\n");
gunzip_setup();
DBG("Gunzipping boot code\n");
printk_debug("Gunzipping boot code\n");
if (gunzip() != 0) {
printk("gunzip failed\n");
printk_notice("gunzip failed\n");
post_code(0xff);
return 0;
}
post_code(0xf8);
#ifdef TFTP_INITRD
printk("Loading initrd now\n");
printk_notice("Loading initrd now\n");
buflen = tftp_init("initrd");
printk("TFTP init complete (%d)\n",buflen);
printk_notice("TFTP init complete (%d)\n",buflen);
buflen = 512; // I know, not it's purpose,
// but it isn't being used at this point.
bufptr = (char *) initrd_start = 0x0400000;
while (buflen == 512) {
buflen = tftp_fetchone(bufptr);
#ifdef DEBUG_TFTP
printk("Got block, bufptr = %lu, size= %u\n",bufptr, buflen);
printk_spew("Got block, bufptr = %lu, size= %u\n",bufptr, buflen);
#endif
bufptr += buflen;
}
initrd_size = (unsigned long) bufptr - initrd_start;
printk("Initrd loaded\n");
printk_notice("Initrd loaded\n");
if(tftp_init("cmdline") >=0) {
buflen = tftp_fetchone(buffer);
@ -127,7 +127,7 @@ int linuxbiosmain(unsigned long base, unsigned long totalram)
cmd_line=buffer;
}
printk("Booting with command line: %s\n",cmd_line);
printk_notice("Booting with command line: %s\n",cmd_line);
#endif /* TFTP_INITRD */
@ -149,7 +149,7 @@ int linuxbiosmain(unsigned long base, unsigned long totalram)
set_memory_size(empty_zero_page, 0x3c00, totalram - 2048);
post_code(0xfa);
PRINTK(KERN_NOTICE "command line - [%s]\n", cmd_line);
printk_notice("command line - [%s]\n", cmd_line);
set_command_line(empty_zero_page, cmd_line);
set_root_rdonly(empty_zero_page);
@ -157,7 +157,7 @@ int linuxbiosmain(unsigned long base, unsigned long totalram)
set_initrd(empty_zero_page, initrd_start, initrd_size);
DBG("Jumping to boot code\n");
printk_debug("Jumping to boot code\n");
post_code(0xfe);
/* there seems to be a bug in gas? it's generating wrong bit-patterns ...

View file

@ -22,12 +22,6 @@ static char rcsid[] = "$Id$";
#include <subr.h>
#undef DEBUGSCAN
#ifdef DEBUGSCAN
#define DBGSCAN(x...) printk(KERN_DEBUG x)
#else
#define DBGSCAN(x...)
#endif
/**
* This is the root of the PCI tree. A PCI tree always has
@ -104,14 +98,14 @@ void pci_set_master(struct pci_dev *dev)
pci_read_config_word(dev, PCI_COMMAND, &cmd);
if (!(cmd & PCI_COMMAND_MASTER)) {
DBG("PCI: Enabling bus mastering for device %02x:%02x\n",
printk_debug("PCI: Enabling bus mastering for device %02x:%02x\n",
dev->bus->number, dev->devfn);
cmd |= PCI_COMMAND_MASTER;
pci_write_config_word(dev, PCI_COMMAND, cmd);
}
pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
if (lat < 16) {
DBG("PCI: Increasing latency timer of device %02x:%02x to 64\n",
printk_debug("PCI: Increasing latency timer of device %02x:%02x to 64\n",
dev->bus->number, dev->devfn);
pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
}
@ -173,7 +167,7 @@ void pci_read_bases(struct pci_dev *dev, unsigned int howmany)
addr &= (PCI_BASE_ADDRESS_SPACE | PCI_BASE_ADDRESS_MEM_TYPE_MASK);
if (addr == (PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64)) {
DBG("reg %d is 64-bit\n", reg);
printk_debug("reg %d is 64-bit\n", reg);
/* this is a 64-bit memory base address */
reg++;
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + (reg << 2), &addr);
@ -181,7 +175,7 @@ void pci_read_bases(struct pci_dev *dev, unsigned int howmany)
#if BITS_PER_LONG == 64
dev->base_address[reg - 1] |= ((unsigned long) addr) << 32;
#else
printk(KERN_ERR "PCI: Unable to handle 64-bit address for device "
printk_err("PCI: Unable to handle 64-bit address for device "
"%02x:%02x\n", dev->bus->number, dev->devfn);
dev->base_address[reg - 1] = 0;
#endif
@ -200,7 +194,7 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
struct pci_dev *dev, **bus_last;
struct pci_bus *child;
DBG("PCI: pci_scan_bus for bus %d\n", bus->number);
printk_debug("PCI: pci_scan_bus for bus %d\n", bus->number);
bus_last = &bus->devices;
max = bus->secondary;
@ -210,14 +204,14 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
/* probe all devices on this bus with some optimization for non-existance and
single funcion devices */
for (devfn = 0; devfn < 0xff; devfn++) {
u32 id, class, addr;
u32 id, class, addr;
u8 cmd, tmp, hdr_type;
// gcc just went to hell. Don't test -- this always
// returns 0 anyway.
#if GCC_WORKS_ON_O2
if (pcibios_read_config_dword(bus->number, devfn, PCI_VENDOR_ID, &id)) {
DBGSCAN("PCI: devfn 0x%x, read_config_dword fails\n",
printk_spew("PCI: devfn 0x%x, read_config_dword fails\n",
devfn);
continue;
}
@ -226,7 +220,7 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
/* some broken boards return 0 if a slot is empty: */
if (id == 0xffffffff || id == 0x00000000 || id == 0x0000ffff || id == 0xffff0000) {
DBGSCAN("PCI: devfn 0x%x, bad id 0x%x\n", devfn, id);
printk_spew("PCI: devfn 0x%x, bad id 0x%x\n", devfn, id);
if (PCI_FUNC(devfn) == 0x00) {
/* if this is a function 0 device and it is not present,
skip to next device */
@ -237,17 +231,17 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
}
if (pcibios_read_config_byte(bus->number, devfn, PCI_HEADER_TYPE, &hdr_type)){
DBGSCAN("PCI: devfn 0x%x, header type read fails\n", devfn);
printk_spew("PCI: devfn 0x%x, header type read fails\n", devfn);
continue;
}
if (pcibios_read_config_dword(bus->number, devfn, PCI_CLASS_REVISION, &class)) {
DBGSCAN("PCI: devfn 0x%x, class read fails\n", devfn);
printk_spew("PCI: devfn 0x%x, class read fails\n", devfn);
continue;
}
if ((dev = kmalloc(sizeof(*dev), GFP_ATOMIC)) == 0) {
printk(KERN_ERR "PCI: out of memory.\n");
printk_err("PCI: out of memory.\n");
continue;
}
@ -292,14 +286,14 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
break;
default: /* unknown header */
bad:
printk(KERN_ERR "PCI: %02x:%02x [%04x/%04x/%06x] has unknown header "
printk_err("PCI: %02x:%02x [%04x/%04x/%06x] has unknown header "
"type %02x, ignoring.\n",
bus->number, dev->devfn, dev->vendor, dev->device, class,
hdr_type);
continue;
}
DBG("PCI: %02x:%02x [%04x/%04x]\n", bus->number, dev->devfn,
printk_debug("PCI: %02x:%02x [%04x/%04x]\n", bus->number, dev->devfn,
dev->vendor, dev->device);
/* Put it into the global PCI device chain. It's used to find devices once
@ -374,7 +368,7 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
#endif
/* Insert it into the tree of buses. */
if ((child = kmalloc(sizeof(*child), GFP_ATOMIC)) == 0) {
printk(KERN_ERR "PCI: out of memory for bridge.\n");
printk_err("PCI: out of memory for bridge.\n");
continue;
}
memset(child, 0, sizeof(*child));
@ -454,7 +448,7 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
*
* Return how far we've got finding sub-buses.
*/
DBG("PCI: pci_scan_bus returning with max=%02x\n", max);
printk_debug("PCI: pci_scan_bus returning with max=%02x\n", max);
post_code(0x55);
return max;
}

View file

@ -5,7 +5,7 @@
#if 1
#define MALLOCDBG(x)
#else
#define MALLOCDBG(x) printk x
#define MALLOCDBG(x) printk_spew x
#endif
extern unsigned char _heap, _eheap;
static size_t free_mem_ptr = (size_t)&_heap; /* Start of heap */
@ -15,13 +15,13 @@ static size_t free_mem_end_ptr = (size_t)&_eheap; /* End of heap */
void malloc_mark(malloc_mark_t *place)
{
*place = free_mem_ptr;
DBG("malloc_mark 0x%08lx\n", (unsigned long)free_mem_ptr);
printk_spew("malloc_mark 0x%08lx\n", (unsigned long)free_mem_ptr);
}
void malloc_release(malloc_mark_t *ptr)
{
free_mem_ptr = *ptr;
DBG("malloc_release 0x%08lx\n", (unsigned long)free_mem_ptr);
printk_spew("malloc_release 0x%08lx\n", (unsigned long)free_mem_ptr);
}
void *malloc(size_t size)

View file

@ -221,7 +221,7 @@ static int pci_sanity_check(const struct pci_ops *o)
(!o->read_word(bus, devfn, PCI_VENDOR_ID, &x) &&
(x == PCI_VENDOR_ID_INTEL || x == PCI_VENDOR_ID_COMPAQ)))
return 1;
printk(KERN_ERR "PCI: Sanity check failed\n");
printk_err("PCI: Sanity check failed\n");
return 0;
}
@ -239,7 +239,7 @@ static const struct pci_ops *pci_check_direct(void)
if (inl(0xCF8) == 0x80000000 &&
pci_sanity_check(&pci_direct_conf1)) {
outl(tmp, 0xCF8);
printk(KERN_INFO "PCI: Using configuration type 1\n");
printk_debug("PCI: Using configuration type 1\n");
return &pci_direct_conf1;
}
outl(tmp, 0xCF8);
@ -254,7 +254,7 @@ static const struct pci_ops *pci_check_direct(void)
outb(0x00, 0xCFA);
if (inb(0xCF8) == 0x00 && inb(0xCFA) == 0x00 &&
pci_sanity_check(&pci_direct_conf2)) {
printk(KERN_INFO "PCI: Using configuration type 2\n");
printk_debug("PCI: Using configuration type 2\n");
return &pci_direct_conf2;
}
}
@ -267,7 +267,7 @@ int pci_read_config_byte(struct pci_dev *dev, u8 where, u8 * val)
{
int res;
res = conf->read_byte(dev->bus->number, dev->devfn, where, val);
PRINTK(KERN_SPEW "Read config byte bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
printk_spew("Read config byte bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
dev->bus->number, dev->devfn, where, *val, res);
return res;
@ -278,7 +278,7 @@ int pci_read_config_word(struct pci_dev *dev, u8 where, u16 * val)
{
int res;
res = conf->read_word(dev->bus->number, dev->devfn, where, val);
PRINTK(KERN_SPEW "Read config word bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
printk_spew( "Read config word bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
dev->bus->number, dev->devfn, where, *val, res);
return res;
}
@ -287,21 +287,21 @@ int pci_read_config_dword(struct pci_dev *dev, u8 where, u32 * val)
{
int res;
res = conf->read_dword(dev->bus->number, dev->devfn, where, val);
PRINTK(KERN_SPEW "Read config dword bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
printk_spew( "Read config dword bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
dev->bus->number, dev->devfn, where, *val, res);
return res;
}
int pci_write_config_byte(struct pci_dev *dev, u8 where, u8 val)
{
PRINTK(KERN_SPEW "Write config byte bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
printk_spew( "Write config byte bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
dev->bus->number, dev->devfn, where, val);
return conf->write_byte(dev->bus->number, dev->devfn, where, val);
}
int pci_write_config_word(struct pci_dev *dev, u8 where, u16 val)
{
PRINTK(KERN_SPEW "Write config word bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
printk_spew( "Write config word bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
dev->bus->number, dev->devfn, where, val);
return conf->write_word(dev->bus->number, dev->devfn, where, val);
@ -309,7 +309,7 @@ int pci_write_config_word(struct pci_dev *dev, u8 where, u16 val)
int pci_write_config_dword(struct pci_dev *dev, u8 where, u32 val)
{
PRINTK(KERN_SPEW "Write config dword bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
printk_spew( "Write config dword bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
dev->bus->number, dev->devfn, where, val);
return conf->write_dword(dev->bus->number, dev->devfn, where, val);
}
@ -318,7 +318,7 @@ int pcibios_read_config_byte(unsigned char bus, unsigned char devfn, u8 where, u
{
int res;
res = conf->read_byte(bus, devfn, where, val);
PRINTK(KERN_SPEW "Read config byte bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
printk_spew( "Read config byte bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
bus, devfn, where, *val, res);
return res;
}
@ -327,7 +327,7 @@ int pcibios_read_config_word(unsigned char bus, unsigned char devfn, u8 where, u
{
int res;
res = conf->read_word(bus, devfn, where, val);
PRINTK(KERN_SPEW "Read config word bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
printk_spew( "Read config word bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
bus, devfn, where, *val, res);
return res;
@ -337,7 +337,7 @@ int pcibios_read_config_dword(unsigned char bus, unsigned char devfn, u8 where,
{
int res;
res = conf->read_dword(bus, devfn, where, val);
PRINTK(KERN_SPEW "Read config dword bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
printk_spew( "Read config dword bus %d,devfn 0x%x,reg 0x%x,val 0x%x,res 0x%x\n",
bus, devfn, where, *val, res);
return res;
@ -345,7 +345,7 @@ int pcibios_read_config_dword(unsigned char bus, unsigned char devfn, u8 where,
int pcibios_write_config_byte(unsigned char bus, unsigned char devfn, u8 where, u8 val)
{
PRINTK(KERN_SPEW "Write byte bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
printk_spew( "Write byte bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
bus, devfn, where, val);
return conf->write_byte(bus, devfn, where, val);
@ -353,7 +353,7 @@ int pcibios_write_config_byte(unsigned char bus, unsigned char devfn, u8 where,
int pcibios_write_config_word(unsigned char bus, unsigned char devfn, u8 where, u16 val)
{
PRINTK(KERN_SPEW "Write word bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
printk_spew( "Write word bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
bus, devfn, where, val);
return conf->write_word(bus, devfn, where, val);
@ -361,7 +361,7 @@ int pcibios_write_config_word(unsigned char bus, unsigned char devfn, u8 where,
int pcibios_write_config_dword(unsigned char bus, unsigned char devfn, u8 where, u32 val)
{
PRINTK(KERN_SPEW "Write doubleword bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
printk_spew( "Write doubleword bus %d, devfn 0x%x, reg 0x%x, val 0x%x\n",
bus, devfn, where, val);
return conf->write_dword(bus, devfn, where, val);
}
@ -449,7 +449,7 @@ void compute_allocate_io(struct pci_bus *bus)
unsigned long io_base;
io_base = bus->iobase;
PRINTK(KERN_DEBUG"compute_allocate_io: base 0x%lx\n", bus->iobase);
printk_debug("compute_allocate_io: base 0x%lx\n", bus->iobase);
/* First, walk all the bridges. When you return, grow the limit of the current bus
since sub-busses need IO rounded to 4096 */
@ -457,7 +457,7 @@ void compute_allocate_io(struct pci_bus *bus)
curbus->iobase = io_base;
compute_allocate_io(curbus);
io_base = round(curbus->iolimit, IO_BRIDGE_ALIGN);
PRINTK(KERN_DEBUG"BUSIO: done Bridge Bus 0x%x, iobase now 0x%lx\n",
printk_debug("BUSIO: done Bridge Bus 0x%x, iobase now 0x%lx\n",
curbus->number, io_base);
}
@ -470,7 +470,7 @@ void compute_allocate_io(struct pci_bus *bus)
if (!iosize)
continue;
PRINTK(KERN_DEBUG"DEVIO: Bus 0x%x, devfn 0x%x, reg 0x%x: "
printk_debug("DEVIO: Bus 0x%x, devfn 0x%x, reg 0x%x: "
"iosize 0x%lx\n",
curdev->bus->number, curdev->devfn, i, iosize);
curdev->base_address[i] = io_base;
@ -478,7 +478,7 @@ void compute_allocate_io(struct pci_bus *bus)
// (e.g. VIA 82c686a.) So set it to be safe)
curdev->base_address[i] |=
PCI_BASE_ADDRESS_SPACE_IO;
PRINTK(KERN_DEBUG"-->set base to 0x%lx\n", io_base);
printk_debug("-->set base to 0x%lx\n", io_base);
io_base += round(iosize, IO_ALIGN);
curdev->command |= PCI_COMMAND_IO;
}
@ -486,7 +486,7 @@ void compute_allocate_io(struct pci_bus *bus)
}
bus->iolimit = iolimit(io_base);
PRINTK(KERN_DEBUG"BUS %d: set iolimit to 0x%lx\n", bus->number, bus->iolimit);
printk_debug("BUS %d: set iolimit to 0x%lx\n", bus->number, bus->iolimit);
}
/** Compute and allocate the memory for this bus.
@ -500,7 +500,7 @@ void compute_allocate_mem(struct pci_bus *bus)
unsigned long mem_base;
mem_base = bus->membase;
PRINTK(KERN_DEBUG"compute_allocate_mem: base 0x%lx\n", bus->membase);
printk_debug("compute_allocate_mem: base 0x%lx\n", bus->membase);
/* First, walk all the bridges. When you return, grow the limit of the current bus
since sub-busses need MEMORY rounded to 1 Mega */
@ -508,7 +508,7 @@ void compute_allocate_mem(struct pci_bus *bus)
curbus->membase = mem_base;
compute_allocate_mem(curbus);
mem_base = round(curbus->memlimit, ONEMEG);
PRINTK(KERN_DEBUG"BUSMEM: Bridge Bus 0x%x,membase now 0x%lx\n",
printk_debug("BUSMEM: Bridge Bus 0x%x,membase now 0x%lx\n",
curbus->number, mem_base);
}
@ -549,11 +549,11 @@ void compute_allocate_mem(struct pci_bus *bus)
consumed in 4KB unit */
regmem = round(memorysize, MEM_ALIGN);
mem_base = round(mem_base, regmem);
PRINTK(KERN_DEBUG"DEVMEM: Bus 0x%x, devfn 0x%x, reg 0x%x: "
printk_debug("DEVMEM: Bus 0x%x, devfn 0x%x, reg 0x%x: "
"memsize 0x%lx\n",
curdev->bus->number, curdev->devfn, i, regmem);
curdev->base_address[i] = mem_base;
PRINTK(KERN_DEBUG"-->set base to 0x%lx\n", mem_base);
printk_debug("-->set base to 0x%lx\n", mem_base);
mem_base += regmem;
curdev->command |= PCI_COMMAND_MEMORY;
// for 64-bit BARs, the odd ones don't count
@ -565,7 +565,7 @@ void compute_allocate_mem(struct pci_bus *bus)
}
bus->memlimit = memlimit(mem_base);
PRINTK(KERN_DEBUG"BUS %d: set memlimit to 0x%lx\n", bus->number, bus->memlimit);
printk_debug("BUS %d: set memlimit to 0x%lx\n", bus->number, bus->memlimit);
}
/** Compute and allocate the prefetch memory for this bus.
@ -579,7 +579,7 @@ void compute_allocate_prefmem(struct pci_bus *bus)
unsigned long prefmem_base;
prefmem_base = bus->prefmembase;
PRINTK(KERN_DEBUG"Compute_allocate_prefmem: base 0x%lx\n", bus->prefmembase);
printk_debug("Compute_allocate_prefmem: base 0x%lx\n", bus->prefmembase);
/* First, walk all the bridges. When you return, grow the limit of the current bus
since sub-busses need MEMORY rounded to 1 Mega */
@ -587,7 +587,7 @@ void compute_allocate_prefmem(struct pci_bus *bus)
curbus->prefmembase = prefmem_base;
compute_allocate_prefmem(curbus);
prefmem_base = round(curbus->prefmemlimit, ONEMEG);
PRINTK(KERN_DEBUG"BUSPREFMEM: Bridge Bus 0x%x, prefmem base now 0x%lx\n",
printk_debug("BUSPREFMEM: Bridge Bus 0x%x, prefmem base now 0x%lx\n",
curbus->number, prefmem_base);
}
@ -607,7 +607,7 @@ void compute_allocate_prefmem(struct pci_bus *bus)
// we don't support the 1M type
if (type & PCI_BASE_ADDRESS_MEM_TYPE_1M) {
printk(__FUNCTION__ ": 1M memory not supported\n");
printk_warning(__FUNCTION__ ": 1M memory not supported\n");
continue;
}
@ -627,11 +627,11 @@ void compute_allocate_prefmem(struct pci_bus *bus)
consumed in 4KB unit */
regmem = round(memorysize, MEM_ALIGN);
prefmem_base = round(prefmem_base, regmem);
PRINTK(KERN_DEBUG"DEVPREFMEM: Bus 0x%x, devfn 0x%x, reg 0x%x: "
printk_debug("DEVPREFMEM: Bus 0x%x, devfn 0x%x, reg 0x%x: "
"prefmemsize 0x%lx\n",
curdev->bus->number, curdev->devfn, i, regmem);
curdev->base_address[i] = prefmem_base;
PRINTK(KERN_DEBUG"-->set base to 0x%lx\n", prefmem_base);
printk_debug("-->set base to 0x%lx\n", prefmem_base);
prefmem_base += regmem;
curdev->command |= PCI_COMMAND_MEMORY;
// for 64-bit BARs, the odd ones don't count
@ -642,7 +642,7 @@ void compute_allocate_prefmem(struct pci_bus *bus)
}
bus->prefmemlimit = memlimit(prefmem_base);
PRINTK(KERN_DEBUG"BUS %d: set prefmemlimit to 0x%lx\n", bus->number, bus->prefmemlimit);
printk_debug("BUS %d: set prefmemlimit to 0x%lx\n", bus->number, bus->prefmemlimit);
}
/** Compute and allocate resources.
@ -653,16 +653,16 @@ void compute_allocate_prefmem(struct pci_bus *bus)
*/
void compute_allocate_resources(struct pci_bus *bus)
{
PRINTK(KERN_DEBUG"COMPUTE_ALLOCATE: do IO\n");
printk_debug("COMPUTE_ALLOCATE: do IO\n");
compute_allocate_io(bus);
PRINTK(KERN_DEBUG"COMPUTE_ALLOCATE: do MEM\n");
printk_debug("COMPUTE_ALLOCATE: do MEM\n");
compute_allocate_mem(bus);
// now put the prefetchable memory at the end of the memory
bus->prefmembase = round(bus->memlimit, ONEMEG);
PRINTK(KERN_DEBUG"COMPUTE_ALLOCATE: do PREFMEM\n");
printk_debug("COMPUTE_ALLOCATE: do PREFMEM\n");
compute_allocate_prefmem(bus);
}
@ -676,9 +676,9 @@ void assign_resources(struct pci_bus *bus)
struct pci_dev *curdev = pci_devices;
struct pci_bus *curbus;
PRINTK(KERN_DEBUG"ASSIGN RESOURCES, bus %d\n", bus->number);
printk_debug("ASSIGN RESOURCES, bus %d\n", bus->number);
/* wlak trhough all the buses, assign resources for bridges */
/* walk trhough all the buses, assign resources for bridges */
for (curbus = bus->children; curbus; curbus = curbus->next) {
curbus->self->command = 0;
@ -690,7 +690,7 @@ void assign_resources(struct pci_bus *bus)
curbus->iobase >> 8);
pci_write_config_byte(curbus->self, PCI_IO_LIMIT,
curbus->iolimit >> 8);
PRINTK(KERN_DEBUG"Bus 0x%x iobase to 0x%x iolimit 0x%x\n",
printk_debug("Bus 0x%x iobase to 0x%x iolimit 0x%x\n",
bus->number, curbus->iobase, curbus->iolimit);
}
@ -701,7 +701,7 @@ void assign_resources(struct pci_bus *bus)
curbus->membase >> 16);
pci_write_config_word(curbus->self, PCI_MEMORY_LIMIT,
curbus->memlimit >> 16);
PRINTK(KERN_DEBUG"Bus 0x%x membase to 0x%x memlimit 0x%x\n",
printk_debug("Bus 0x%x membase to 0x%x memlimit 0x%x\n",
bus->number, curbus->membase, curbus->memlimit);
}
@ -713,11 +713,12 @@ void assign_resources(struct pci_bus *bus)
curbus->prefmembase >> 16);
pci_write_config_word(curbus->self, PCI_PREF_MEMORY_LIMIT,
curbus->prefmemlimit >> 16);
PRINTK(KERN_DEBUG"Bus 0x%x prefmembase to 0x%x prefmemlimit 0x%x\n",
printk_debug("Bus 0x%x prefmembase to 0x%x prefmemlimit 0x%x\n",
bus->number, curbus->prefmembase, curbus->prefmemlimit);
}
curbus->self->command |= PCI_COMMAND_MASTER;
}
for (curdev = pci_devices; curdev; curdev = curdev->next) {
@ -729,10 +730,12 @@ void assign_resources(struct pci_bus *bus)
reg = PCI_BASE_ADDRESS_0 + (i << 2);
pci_write_config_dword(curdev, reg, curdev->base_address[i]);
PRINTK(KERN_DEBUG"Bus 0x%x devfn 0x%x reg 0x%x base to 0x%lx\n",
printk_debug("Bus 0x%x devfn 0x%x reg 0x%x base to 0x%lx\n",
curdev->bus->number, curdev->devfn, i,
curdev->base_address[i]);
}
/* set a default latency timer */
pci_write_config_byte(curdev, PCI_LATENCY_TIMER, 0x40);
}
}
@ -748,7 +751,7 @@ void enable_resources(struct pci_bus *bus)
pci_read_config_word(curdev, PCI_COMMAND, &command);
command |= curdev->command;
pci_write_config_word(curdev, PCI_COMMAND, command);
PRINTK(KERN_DEBUG"DEV Set command bus 0x%x devfn 0x%x to 0x%x\n",
printk_debug("DEV Set command bus 0x%x devfn 0x%x to 0x%x\n",
curdev->bus->number, curdev->devfn, command);
}
}
@ -757,8 +760,10 @@ void enable_resources(struct pci_bus *bus)
*/
void pci_enumerate()
{
printk_info("Scanning PCI bus...");
// scan it.
pci_init();
printk_info("done\n");
}
/** Starting at the root, compute what resources are needed and allocate them.
@ -768,6 +773,7 @@ void pci_enumerate()
*/
void pci_configure()
{
printk_info("Allocating PCI resources...");
pci_root.membase = PCI_MEM_START;
pci_root.prefmembase = PCI_MEM_START;
pci_root.iobase = PCI_IO_START;
@ -775,6 +781,7 @@ void pci_configure()
compute_allocate_resources(&pci_root);
// now just set things into registers ... we hope ...
assign_resources(&pci_root);
printk_info("done.\n");
}
/** Starting at the root, walk the tree and enable all devices/bridges.
@ -782,49 +789,71 @@ void pci_configure()
*/
void pci_enable()
{
printk_info("Enabling PCI resourcess...");
// now enable everything.
enable_resources(&pci_root);
printk_info("done.\n");
}
void pci_zero_irq_settings(void)
{
struct pci_dev *pcidev;
unsigned char line;
printk_info("Zeroing PCI IRQ settings...");
pcidev = pci_devices;
while (pcidev) {
pci_read_config_byte(pcidev, 0x3d, &line);
if (line) {
pci_write_config_byte(pcidev, 0x3c, 0);
}
pcidev = pcidev->next;
}
printk_info("done.\n");
}
void
handle_superio(int pass, struct superio *s, int nsuperio)
{
int i;
printk(KERN_INFO "handle_superio start, s %p nsuperio %d s->super %p\n",
printk_debug("handle_superio start, s %p nsuperio %d s->super %p\n",
s, nsuperio, s->super);
for(i = 0; i < nsuperio; i++, s++){
if (!s->super)
continue;
printk(KERN_INFO "handle_superio: Pass %d, Superio %s\n", pass,
printk_debug("handle_superio: Pass %d, Superio %s\n", pass,
s->super->name);
// if no port is assigned use the defaultport
printk(KERN_INFO __FUNCTION__ " port 0x%x, defaultport 0x%x\n",
printk_info( __FUNCTION__ " port 0x%x, defaultport 0x%x\n",
s->port, s->super->defaultport);
if (! s->port)
s->port = s->super->defaultport;
printk(KERN_INFO __FUNCTION__ " Using port 0x%x\n", s->port);
printk_info( __FUNCTION__ " Using port 0x%x\n", s->port);
// need to have both pre_pci_init and devfn defined.
if (s->super->pre_pci_init && (pass == 0)) {
printk(KERN_INFO " Call pre_pci_init\n");
printk_debug(" Call pre_pci_init\n");
s->super->pre_pci_init(s);
}
else
if (s->super->init && (pass == 1))
{
printk(KERN_INFO " Call init\n");
printk_debug(" Call init\n");
s->super->init(s);
}
else
if (s->super->finishup && (pass == 2))
{
printk(KERN_INFO " Call finishup\n");
printk_debug(" Call finishup\n");
s->super->finishup(s);
}
}
printk(KERN_INFO "handle_superio done\n");
printk_debug("handle_superio done\n");
}
void
@ -835,12 +864,12 @@ handle_southbridge(int pass, struct southbridge *s, int nsouthbridge)
if (!s->southbridge)
continue;
printk(KERN_INFO "handle_southbridge: Pass %d, Superio %s\n", pass,
printk_debug("handle_southbridge: Pass %d, Superio %s\n", pass,
s->southbridge->name);
// need to have both pre_pci_init and devfn defined.
if (s->southbridge->pre_pci_init && (pass == 0) && (s->devfn)) {
printk(KERN_INFO " Call pre_pci_init\n");
printk_debug(" Call pre_pci_init\n");
s->southbridge->pre_pci_init(s);
}
else
@ -853,7 +882,7 @@ handle_southbridge(int pass, struct southbridge *s, int nsouthbridge)
s->southbridge->device, 0);
if (! s->device) { // not there!
printk(KERN_INFO " No such device\n");
printk_info(" No such device\n");
continue;
}
// problem. We have to handle multiple devices of same type.
@ -863,12 +892,12 @@ handle_southbridge(int pass, struct southbridge *s, int nsouthbridge)
// and then continue looking if the device is in use.
// For now, let's get this basic thing to work.
if (s->southbridge->init && (pass == 1)) {
printk(KERN_INFO " Call init\n");
printk_debug(" Call init\n");
s->southbridge->init(s);
}
else
if (s->southbridge->finishup && (pass == 2)) {
printk(KERN_INFO " Call finishup\n");
printk_debug(" Call finishup\n");
s->southbridge->finishup(s);
}
}

View file

@ -12,17 +12,18 @@ static char rcsid[] = "$Id$";
//typedef void * va_list;
#include <stdarg.h>
#include <smp/spinlock.h>
static char buf[1024];
/* printk's without a loglevel use this.. */
#define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */
#define DEFAULT_MESSAGE_LOGLEVEL 4 /* BIOS_WARNING */
/* We show everything that is MORE important than this.. */
#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
#ifndef DEFAULT_CONSOLE_LOGLEVEL
#define DEFAULT_CONSOLE_LOGLEVEL 8 /* anything MORE serious than KERN_WARNING */
#define DEFAULT_CONSOLE_LOGLEVEL 8 /* anything MORE serious than BIOS_SPEW */
#endif
/* Keep together for sysctl support */
@ -35,31 +36,27 @@ int default_console_loglevel = DEFAULT_CONSOLE_LOGLEVEL;
void display(char*);
extern int vsprintf(char *buf, const char *, va_list);
int printk(const char *fmt, ...)
spinlock_t console_lock = SPIN_LOCK_UNLOCKED;
int do_printk(int msg_level, const char *fmt, ...)
{
va_list args;
int i;
char *p;
int msg_level;
if (msg_level >= console_loglevel) {
return 0;
}
spin_lock(&console_lock);
va_start(args, fmt);
i = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf)-4 */
va_end(args);
p = buf;
if (
p[0] == '<' &&
p[1] > '0' &&
p[1] <= '9' &&
p[2] == '>'
) {
msg_level = p[1] - '0';
p +=3;
} else {
msg_level = default_message_loglevel;
}
if (msg_level < console_loglevel) {
display(p);
}
display(buf);
spin_unlock(&console_lock);
return i;
}

View file

@ -8,24 +8,6 @@ static char rcsid[] = "$Id$";
/* Base Address */
#define TTYS0 0x3f8
/* Data */
#define TTYS0_RBR (TTYS0+0x00)
/* Control */
#define TTYS0_TBR TTYS0_RBR
#define TTYS0_IER (TTYS0+0x01)
#define TTYS0_IIR (TTYS0+0x02)
#define TTYS0_FCR TTYS0_IIR
#define TTYS0_LCR (TTYS0+0x03)
#define TTYS0_MCR (TTYS0+0x04)
#define TTYS0_DLL TTYS0_RBR
#define TTYS0_DLM TTYS0_IER
/* Status */
#define TTYS0_LSR (TTYS0+0x05)
#define TTYS0_MSR (TTYS0+0x06)
#define TTYS0_SCR (TTYS0+0x07)
#ifndef TTYS0_BAUD
#define TTYS0_BAUD 115200
#endif
@ -36,59 +18,177 @@ static char rcsid[] = "$Id$";
#define TTYS0_DIV (115200/TTYS0_BAUD)
/* Data */
#define UART_RBR 0x00
#define UART_TBR 0x00
/* Control */
#define UART_IER 0x01
#define UART_IIR 0x02
#define UART_FCR 0x02
#define UART_LCR 0x03
#define UART_MCR 0x04
#define UART_DLL 0x00
#define UART_DLM 0x01
/* Status */
#define UART_LSR 0x05
#define UART_MSR 0x06
#define UART_SCR 0x07
#ifndef TTYS0_BAUD
#define TTYS0_BAUD 115200
#endif
static inline int uart_can_tx_byte(unsigned base_port)
{
return inb(base_port + UART_LSR) & 0x20;
}
static inline void uart_wait_to_tx_byte(unsigned base_port)
{
while(!uart_can_tx_byte(base_port))
;
}
static inline void uart_wait_until_sent(unsigned base_port)
{
while(!(inb(base_port + UART_LSR) & 0x40))
;
}
static inline void uart_tx_byte(unsigned base_port, unsigned char data)
{
uart_wait_to_tx_byte(base_port);
outb(data, base_port + UART_TBR);
/* Make certain the data clears the fifos */
uart_wait_until_sent(base_port);
}
static inline void uart_tx_bytes(unsigned base_port, char *data, unsigned len)
{
do {
uart_wait_to_tx_byte(base_port);
outb(*data, base_port + UART_TBR);
data++;
len--;
} while(len);
uart_wait_until_sent(base_port);
}
static inline int uart_have_rx_byte(unsigned base_port)
{
return inb(base_port + UART_LSR) & 0x1;
}
static inline void uart_enable_rx_byte(unsigned base_port)
{
unsigned char byte;
/* say we are ready for a byte */
byte = inb(base_port + UART_MCR);
byte |= 0x02;
outb(byte, base_port + UART_MCR);
}
static inline void uart_disable_rx_byte(unsigned base_port)
{
unsigned char byte;
/* say we aren't ready for another byte */
byte = inb(base_port + UART_MCR);
byte &= ~0x02;
outb(byte, base_port + UART_MCR);
}
static inline void uart_wait_for_rx_byte(unsigned base_port)
{
uart_enable_rx_byte(base_port);
while(!uart_have_rx_byte(base_port))
;
uart_disable_rx_byte(base_port);
}
static inline unsigned char uart_rx_byte(unsigned base_port)
{
unsigned char data;
if (!uart_have_rx_byte(base_port)) {
uart_wait_for_rx_byte(base_port);
}
data = inb(base_port + UART_RBR);
return data;
}
static inline unsigned long uart_rx_bytes(unsigned base_port,
char * buffer, unsigned long size)
{
unsigned long bytes = 0;
if (size == 0) {
return 0;
}
if (!uart_have_rx_byte(base_port)) {
uart_wait_for_rx_byte(base_port);
}
do {
buffer[bytes++] = inb(base_port + UART_RBR);
} while((bytes < size) && uart_have_rx_byte(base_port));
return bytes;
}
inline void uart_init(unsigned base_port, unsigned divisor)
{
/* disable interrupts */
outb(0x0, base_port + UART_IER);
/* enable fifo's */
outb(0x01, base_port + UART_FCR);
/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
outb(0x83, base_port + UART_LCR);
outb(divisor & 0xFF, base_port + UART_DLL);
outb((divisor >> 8) & 0xFF, base_port + UART_DLM);
outb(0x03, base_port + UART_LCR);
}
void ttys0_init(void)
{
uart_init(TTYS0, TTYS0_DIV);
}
void ttys0_tx_byte(unsigned char data)
{
uart_tx_byte(TTYS0, data);
}
unsigned char ttys0_rx_byte(void)
{
return uart_rx_byte(TTYS0);
}
unsigned long ttys0_rx_bytes(char *buffer, unsigned long size)
{
return uart_rx_bytes(TTYS0, buffer, size);
}
#ifdef PYRO_SERIAL
/* experimental serial read stuffs */
int iskey(void)
int iskey(void)
{
if (inb(TTYS0_LSR) & 0x01)
return(1);
return(0);
return uart_have_rx_byte(TTYS0);
}
char ttys0_rx_char(void)
char ttys0_rx_char(void)
{
char result;
while (!(inb(TTYS0_LSR) & 0x01));
result = inb(TTYS0_RBR);
return(result);
return ttys0_rx_byte();
}
void ttys0_rx_line(char *buffer, int *len)
void ttys0_rx_line(char *buffer, int *len)
{
int pos=0;
char chargot=0;
while (chargot != '\r' && chargot != '\n' && pos< *len) {
while(chargot != '\r' && chargot != '\n' && pos< *len) {
chargot = ttys0_rx_char();
buffer[pos++] = chargot;
}
*len = pos-1;
}
#endif
void ttys0_init(void)
{
/* disable interrupts */
outb(0x0, TTYS0_IER);
/* disable fifo's */
outb(0x0, TTYS0_FCR);
outb(0x83, TTYS0_LCR);
/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
outb(TTYS0_DIV, TTYS0_DLL);
outb(0, TTYS0_DLM);
outb(0x03, TTYS0_LCR);
}
void ttys0_tx_byte(unsigned char data)
{
while (!(inb(TTYS0_LSR) & 0x20))
;
outb(data, TTYS0_TBR);
}

View file

@ -120,7 +120,7 @@ void post_code(uint8_t value)
#ifdef SERIAL_POST
unsigned long hi, lo;
rdtsc(lo, hi);
printk(KERN_INFO "POST: 0x%02x, TSC Lo: %d, Hi: %d\n",
printk_info("POST: 0x%02x, TSC Lo: %d, Hi: %d\n",
value, lo, hi);
#endif
outb(value, 0x80);