--- trunk/src/devices/bus_isa.c 2007/10/08 16:19:28 21 +++ trunk/src/devices/bus_isa.c 2007/10/08 16:19:37 22 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 Anders Gavare. All rights reserved. + * Copyright (C) 2005-2006 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: bus_isa.c,v 1.5 2005/11/21 11:10:11 debug Exp $ + * $Id: bus_isa.c,v 1.9 2006/01/16 01:45:27 debug Exp $ * * Generic ISA bus. This is not a normal device, but it can be used as a quick * way of adding most of the common legacy ISA devices to a machine. @@ -35,6 +35,8 @@ #include #include +#define BUS_ISA_C + #include "bus_isa.h" #include "device.h" #include "devices.h" @@ -44,7 +46,24 @@ /* - * bus_isa(): + * bus_isa_debug_dump(): + */ +void bus_isa_debug_dump(void *extra) +{ + struct bus_isa_data *d = (struct bus_isa_data *) extra; + + debug("isa:\n"); + debug_indentation(DEBUG_INDENTATION); + debug("portbase: 0x%llx\n", (long long)d->isa_portbase); + debug("membase: 0x%llx\n", (long long)d->isa_membase); + debug("irqbase: %i\n", (int)d->isa_irqbase); + debug("reassert_irq: %i\n", (int)d->reassert_irq); + debug_indentation(-DEBUG_INDENTATION); +} + + +/* + * bus_isa_init(): * * Flags are zero or more of the following, ORed together: * @@ -56,6 +75,7 @@ * BUS_ISA_PCKBC_FORCE_USE Always assume keyboard console, not serial. (*3) * BUS_ISA_PCKBC_NONPCSTYLE Don't set the pc-style flag for the keyboard. * BUS_ISA_NO_SECOND_PIC Only useful for 8086 XT (pre-AT) emulation. :-) + * BUS_ISA_LPTBASE_3BC Set lptbase to 0x3bc instead of 0x378. * * (*1) For machines with a PCI bus, this flag should not be used. Instead, a * PCI VGA card should be added to the PCI bus. @@ -67,13 +87,22 @@ * (*3) Similar to *2 above; machines that always boot up with VGA console * should have this flag set, so that the keyboard is always used. */ -void bus_isa(struct machine *machine, uint32_t bus_isa_flags, - uint64_t isa_portbase, uint64_t isa_membase, int isa_irqbase, - int reassert_irq) +struct bus_isa_data *bus_isa_init(struct machine *machine, + uint32_t bus_isa_flags, uint64_t isa_portbase, uint64_t isa_membase, + int isa_irqbase, int reassert_irq) { + struct bus_isa_data *d = malloc(sizeof(struct bus_isa_data)); char tmpstr[300]; int wdc0_irq = 14, wdc1_irq = 15; int tmp_handle, kbd_in_use; + int lptbase = 0x378; + + memset(d, 0, sizeof(struct bus_isa_data)); + d->isa_portbase = isa_portbase; + d->isa_membase = isa_membase; + d->isa_irqbase = isa_irqbase; + d->reassert_irq = reassert_irq; + machine_bus_register(machine, "isa", bus_isa_debug_dump, d); kbd_in_use = ((bus_isa_flags & BUS_ISA_PCKBC_FORCE_USE) || (machine->use_x11))? 1 : 0; @@ -112,8 +141,13 @@ " in_use=0", isa_irqbase +3, (long long)(isa_portbase + 0x2f8)); device_add(machine, tmpstr); + if (bus_isa_flags & BUS_ISA_LPTBASE_3BC) { + bus_isa_flags &= ~BUS_ISA_LPTBASE_3BC; + lptbase = 0x3bc; + } + snprintf(tmpstr, sizeof(tmpstr), "lpt irq=%i addr=0x%llx name2=lpt" - " in_use=0", isa_irqbase + 7, (long long)(isa_portbase + 0x378)); + " in_use=0", isa_irqbase + 7, (long long)(isa_portbase + lptbase)); device_add(machine, tmpstr); if (bus_isa_flags & BUS_ISA_IDE0) { @@ -161,5 +195,7 @@ if (bus_isa_flags != 0) fatal("WARNING! bus_isa(): unimplemented bus_isa_flags 0x%x\n", bus_isa_flags); + + return d; }