From fbe1641bd319120e90ac0c0bbf46e2dc3a29fe11 Mon Sep 17 00:00:00 2001 From: Jorrit Herder Date: Wed, 11 May 2005 09:02:00 +0000 Subject: [PATCH] User-space networking! - RTL8139 driver moved to user-space; - PCI code moved to user-space; Fixed IRQ hook dump at IS server. --- drivers/Makefile | 4 +- drivers/libdriver/Makefile | 3 +- drivers/libpci/Makefile | 35 + drivers/libpci/pci.c | 147 ++- drivers/libpci/pci.h | 29 + drivers/libpci/pci_intel.h | 8 +- drivers/libpci/pci_table.c | 15 +- drivers/rtl8139/Makefile | 54 ++ {kernel => drivers/rtl8139}/rtl8139.c | 456 +++++---- {kernel => drivers/rtl8139}/rtl8139.h | 0 include/minix/com.h | 10 +- include/minix/devio.h | 3 + kernel/Makefile | 25 +- kernel/pci.c | 1227 ------------------------- kernel/pci.h | 97 -- kernel/pci_amd.h | 21 - kernel/pci_intel.h | 58 -- kernel/pci_sis.h | 17 - kernel/pci_table.c | 251 ----- kernel/pci_via.h | 27 - kernel/proto.h | 40 +- kernel/sendmask.h | 6 +- kernel/system/sysctl.c | 2 +- kernel/table.c | 10 +- kernel/type.h | 2 - servers/is/dmp.c | 2 +- tools/Makefile | 1 + 27 files changed, 549 insertions(+), 2001 deletions(-) create mode 100644 drivers/libpci/Makefile create mode 100644 drivers/rtl8139/Makefile rename {kernel => drivers/rtl8139}/rtl8139.c (87%) rename {kernel => drivers/rtl8139}/rtl8139.h (100%) delete mode 100755 kernel/pci.c delete mode 100755 kernel/pci.h delete mode 100755 kernel/pci_amd.h delete mode 100755 kernel/pci_intel.h delete mode 100755 kernel/pci_sis.h delete mode 100755 kernel/pci_table.c delete mode 100755 kernel/pci_via.h diff --git a/drivers/Makefile b/drivers/Makefile index e21d5329f..e7a515b8f 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -14,10 +14,12 @@ usage: build: all all install clean: + cd ./libdriver && $(MAKE) $@ + cd ./libpci && $(MAKE) $@ cd ./tty && $(MAKE) $@ cd ./memory && $(MAKE) $@ cd ./at_wini && $(MAKE) $@ cd ./floppy && $(MAKE) $@ cd ./printer && $(MAKE) $@ - cd ./libdriver && $(MAKE) $@ + cd ./rtl8139 && $(MAKE) $@ diff --git a/drivers/libdriver/Makefile b/drivers/libdriver/Makefile index 9132541e9..021710fe6 100644 --- a/drivers/libdriver/Makefile +++ b/drivers/libdriver/Makefile @@ -15,14 +15,13 @@ LIBS = -lsys -lutils OBJECTS = driver.o drvlib.o -all build: $(OBJECTS) +all build install: $(OBJECTS) # $(CC) -c $@ $(LDFLAGS) $(OBJ) $(LIBS) clean: rm -f *.o *.bak -install: # Dependencies a = $m/config.h $i/ansi.h $m/type.h $m/com.h $m/callnr.h $s/types.h \ diff --git a/drivers/libpci/Makefile b/drivers/libpci/Makefile new file mode 100644 index 000000000..b0712a746 --- /dev/null +++ b/drivers/libpci/Makefile @@ -0,0 +1,35 @@ +# Makefile for PCI bus library + +# Directories +u = /usr +i = $u/include +s = $i/sys +b = $i/ibm +m = $i/minix + +# Programs, flags, etc. +CC = exec cc +CFLAGS = -I$i +LDFLAGS = -i +LIBS = -lsys -lutils + +OBJECTS = pci.o pci_table.o + +all build install: $(OBJECTS) + +# $(CC) -c $@ $(LDFLAGS) $(OBJ) $(LIBS) + +clean: + rm -f *.o *.bak + + +# Dependencies +a = $m/config.h $i/ansi.h $m/type.h $m/com.h $m/callnr.h $s/types.h \ + $m/const.h $m/syslib.h $m/utils.h \ + $i/string.h $i/limits.h $i/stddef.h $i/errno.h \ + $m/partition.h $m/u64.h + +pci.o: $a +pci.o: pci.h +pci.o: pci_amd.h pci_intel.h pci_via.h pci_sis.h + diff --git a/drivers/libpci/pci.c b/drivers/libpci/pci.c index 31c1a3ea3..404ba3725 100644 --- a/drivers/libpci/pci.c +++ b/drivers/libpci/pci.c @@ -1,3 +1,4 @@ +#define USER_SPACE 1 /* pci.c @@ -6,16 +7,17 @@ Configure devices on the PCI bus Created: Jan 2000 by Philip Homburg */ -#include "../../kernel/kernel.h" +#include "../drivers.h" +#include +#include -#include "../../kernel/assert.h" #include "pci.h" #include "pci_amd.h" #include "pci_intel.h" #include "pci_sis.h" #include "pci_via.h" #if __minix_vmd -#include "../../kernel/config.h" +#include "config.h" #endif #if ENABLE_PCI @@ -25,10 +27,14 @@ Created: Jan 2000 by Philip Homburg #define irq_mode_pci(irq) ((void)0) #endif -INIT_ASSERT +#include +#include +#include +#include +INIT_SERVER_ASSERT #define NR_PCIBUS 2 -#define NR_PCIDEV 20 +#define NR_PCIDEV 40 #define PBT_INTEL 1 #define PBT_PCIBRIDGE 2 @@ -96,6 +102,47 @@ FORWARD _PROTOTYPE( void pcii_wreg32, (int busind, int devind, int port, FORWARD _PROTOTYPE( u16_t pcii_rsts, (int busind) ); FORWARD _PROTOTYPE( void pcii_wsts, (int busind, U16_t value) ); +/*===========================================================================* + * helper functions for I/O * + *===========================================================================*/ +PUBLIC unsigned pci_inb(U16_t port) { + U8_t value; + int s; + if ((s=sys_inb(port, &value)) !=OK) + printf("PCI: warning, sys_inb failed: %d\n", s); + return value; +} +PUBLIC unsigned pci_inw(U16_t port) { + U16_t value; + int s; + if ((s=sys_inw(port, &value)) !=OK) + printf("PCI: warning, sys_inw failed: %d\n", s); + return value; +} +PUBLIC unsigned pci_inl(U16_t port) { + U32_t value; + int s; + if ((s=sys_inl(port, &value)) !=OK) + printf("PCI: warning, sys_inl failed: %d\n", s); + return value; +} +PUBLIC void pci_outb(U16_t port, U8_t value) { + int s; + if ((s=sys_outb(port, value)) !=OK) + printf("PCI: warning, sys_outb failed: %d\n", s); +} +PUBLIC void pci_outw(U16_t port, U16_t value) { + int s; + if ((s=sys_outw(port, value)) !=OK) + printf("PCI: warning, sys_outw failed: %d\n", s); +} +PUBLIC void pci_outl(U16_t port, U32_t value) { + int s; + if ((s=sys_outl(port, value)) !=OK) + printf("PCI: warning, sys_outl failed: %d\n", s); +} + + /*===========================================================================* * pci_init * *===========================================================================*/ @@ -107,7 +154,7 @@ PUBLIC void pci_init() return; /* We don't expect to interrupted */ - assert(first_time == 1); + server_assert(first_time == 1); first_time= -1; /* Only Intel (compatible) PCI controllers are supported at the @@ -201,8 +248,8 @@ u16_t *didp; PUBLIC void pci_reserve(devind) int devind; { - assert(devind <= nr_pcidev); - assert(!pcidev[devind].pd_inuse); + server_assert(devind <= nr_pcidev); + server_assert(!pcidev[devind].pd_inuse); pcidev[devind].pd_inuse= 1; } @@ -215,7 +262,7 @@ int devind; u16_t *vidp; u16_t *didp; { - assert(devind <= nr_pcidev); + server_assert(devind <= nr_pcidev); *vidp= pcidev[devind].pd_vid; *didp= pcidev[devind].pd_did; } @@ -351,7 +398,7 @@ PRIVATE void pci_intel_init() */ u32_t bus, dev, func; u16_t vid, did; - int i, r, busind; + int s, i, r, busind; char *dstr; bus= 0; @@ -360,7 +407,12 @@ PRIVATE void pci_intel_init() vid= PCII_RREG16_(bus, dev, func, PCI_VID); did= PCII_RREG16_(bus, dev, func, PCI_DID); +#if USER_SPACE + if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL))) + printf("PCI: warning, sys_outl failed: %d\n", s); +#else outl(PCII_CONFADD, PCII_UNSEL); +#endif if (vid == 0xffff && did == 0xffff) return; /* Nothing here */ @@ -383,7 +435,7 @@ PRIVATE void pci_intel_init() } if (nr_pcibus >= NR_PCIBUS) - panic("too many PCI busses", nr_pcibus); + server_panic("PCI","too many PCI busses", nr_pcibus); busind= nr_pcibus; nr_pcibus++; pcibus[busind].pb_type= PBT_INTEL; @@ -445,7 +497,7 @@ int busind; printf("probe_bus(%d)\n", busind); #endif if (nr_pcidev >= NR_PCIDEV) - panic("too many PCI devices", nr_pcidev); + server_panic("PCI","too many PCI devices", nr_pcidev); devind= nr_pcidev; for (dev= 0; dev<32; dev++) @@ -519,7 +571,7 @@ printf("probe_bus(%d)\n", busind); pcidev[devind].pd_inuse= 0; if (nr_pcidev >= NR_PCIDEV) - panic("too many PCI devices", nr_pcidev); + server_panic("PCI","too many PCI devices", nr_pcidev); devind= nr_pcidev; if (func == 0 && !(headt & PHT_MULTIFUNC)) @@ -610,7 +662,7 @@ int busind; r= do_sis_isabr(bridge_dev); break; default: - panic("unknown ISA bridge type", type); + server_panic("PCI","unknown ISA bridge type", type); } return r; } @@ -671,7 +723,7 @@ int busind; #endif if (nr_pcibus >= NR_PCIBUS) - panic("too many PCI busses", nr_pcibus); + server_panic("PCI","too many PCI busses", nr_pcibus); ind= nr_pcibus; nr_pcibus++; pcibus[ind].pb_type= PBT_PCIBRIDGE; @@ -695,7 +747,7 @@ int busind; pcibus[ind].pb_wsts= pcibr_via_wsts; break; default: - panic("unknown PCI-PCI bridge type", type); + server_panic("PCI","unknown PCI-PCI bridge type", type); } probe_bus(ind); @@ -709,7 +761,7 @@ int busind; PRIVATE int do_piix(devind) int devind; { - int i, dev, func, irqrc, irq; + int i, s, dev, func, irqrc, irq; u16_t elcr1, elcr2, elcr; #if DEBUG @@ -717,8 +769,15 @@ int devind; #endif dev= pcidev[devind].pd_dev; func= pcidev[devind].pd_func; +#if USER_SPACE + if (OK != (s=sys_inb(PIIX_ELCR1, &elcr1))) + printf("Warning, sys_inb failed: %d\n", s); + if (OK != (s=sys_inb(PIIX_ELCR2, &elcr2))) + printf("Warning, sys_inb failed: %d\n", s); +#else elcr1= inb(PIIX_ELCR1); elcr2= inb(PIIX_ELCR2); +#endif elcr= elcr1 | (elcr2 << 8); for (i= 0; i<4; i++) { @@ -737,7 +796,7 @@ int devind; { printf("IRQ %d is not level triggered\n", irq); - panic(NULL, NO_NUM); + server_panic(NULL,NULL, NO_NUM); } irq_mode_pci(irq); } @@ -762,7 +821,7 @@ int devind; /* Fake a device with the required function */ if (nr_pcidev >= NR_PCIDEV) - panic("too many PCI devices", nr_pcidev); + server_panic("PCI","too many PCI devices", nr_pcidev); xdevind= nr_pcidev; pcidev[xdevind].pd_busind= bus; pcidev[xdevind].pd_dev= dev; @@ -789,7 +848,7 @@ int devind; { printf("IRQ %d is not level triggered\n", irq); - panic(NULL, NO_NUM); + server_panic(NULL, NULL, NO_NUM); } irq_mode_pci(irq); } @@ -865,7 +924,7 @@ int devind; irq= pci_attr_r8(devind, VIA_ISABR_IRQ_R1) >> 4; break; default: - assert(0); + server_assert(0); } irq &= 0xf; if (!irq) @@ -881,7 +940,7 @@ int devind; { printf("IRQ %d is not level triggered\n", irq); - panic(NULL, NO_NUM); + server_panic(NULL, NULL, NO_NUM); } irq_mode_pci(irq); } @@ -1085,12 +1144,17 @@ int devind; int port; { u8_t v; - + int s; v= PCII_RREG8_(pcibus[busind].pb_bus, pcidev[devind].pd_dev, pcidev[devind].pd_func, port); +#if USER_SPACE + if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL))) + printf("PCI: warning, sys_outl failed: %d\n", s); +#else outl(PCII_CONFADD, PCII_UNSEL); +#endif #if 0 printf("pcii_rreg8(%d, %d, 0x%X): %d.%d.%d= 0x%X\n", busind, devind, port, @@ -1110,11 +1174,17 @@ int devind; int port; { u16_t v; + int s; v= PCII_RREG16_(pcibus[busind].pb_bus, pcidev[devind].pd_dev, pcidev[devind].pd_func, port); +#if USER_SPACE + if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL))) + printf("PCI: warning, sys_outl failed: %d\n"); +#else outl(PCII_CONFADD, PCII_UNSEL); +#endif #if 0 printf("pcii_rreg16(%d, %d, 0x%X): %d.%d.%d= 0x%X\n", busind, devind, port, @@ -1134,11 +1204,17 @@ int devind; int port; { u32_t v; + int s; v= PCII_RREG32_(pcibus[busind].pb_bus, pcidev[devind].pd_dev, pcidev[devind].pd_func, port); +#if USER_SPACE + if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL))) + printf("PCI: warning, sys_outl failed: %d\n", s); +#else outl(PCII_CONFADD, PCII_UNSEL); +#endif #if 0 printf("pcii_rreg32(%d, %d, 0x%X): %d.%d.%d= 0x%X\n", busind, devind, port, @@ -1158,6 +1234,7 @@ int devind; int port; u16_t value; { + int s; #if 0 printf("pcii_wreg16(%d, %d, 0x%X, 0x%X): %d.%d.%d\n", busind, devind, port, value, @@ -1167,7 +1244,12 @@ u16_t value; PCII_WREG16_(pcibus[busind].pb_bus, pcidev[devind].pd_dev, pcidev[devind].pd_func, port, value); +#if USER_SPACE + if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL))) + printf("PCI: warning, sys_outl failed: %d\n", s); +#else outl(PCII_CONFADD, PCII_UNSEL); +#endif } @@ -1180,6 +1262,7 @@ int devind; int port; u32_t value; { + int s; #if 0 printf("pcii_wreg32(%d, %d, 0x%X, 0x%X): %d.%d.%d\n", busind, devind, port, value, @@ -1189,7 +1272,12 @@ u32_t value; PCII_WREG32_(pcibus[busind].pb_bus, pcidev[devind].pd_dev, pcidev[devind].pd_func, port, value); +#if USER_SPACE + if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL))) + printf("PCI: warning, sys_outl failed: %d\n"); +#else outl(PCII_CONFADD, PCII_UNSEL); +#endif } @@ -1200,8 +1288,15 @@ PRIVATE u16_t pcii_rsts(busind) int busind; { u16_t v; + int s; + v= PCII_RREG16_(pcibus[busind].pb_bus, 0, 0, PCI_PCISTS); +#if USER_SPACE + if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL))) + printf("PCI: warning, sys_outl failed: %d\n", s); +#else outl(PCII_CONFADD, PCII_UNSEL); +#endif return v; } @@ -1213,8 +1308,14 @@ PRIVATE void pcii_wsts(busind, value) int busind; u16_t value; { + int s; PCII_WREG16_(pcibus[busind].pb_bus, 0, 0, PCI_PCISTS, value); +#if USER_SPACE + if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL))) + printf("PCI: warning, sys_outl failed: %d\n", s); +#else outl(PCII_CONFADD, PCII_UNSEL); +#endif } #endif /* ENABLE_PCI */ diff --git a/drivers/libpci/pci.h b/drivers/libpci/pci.h index 16865d949..9655505ae 100644 --- a/drivers/libpci/pci.h +++ b/drivers/libpci/pci.h @@ -4,6 +4,35 @@ pci.h Created: Jan 2000 by Philip Homburg */ +#if ENABLE_PCI + +/* tempory functions: to be replaced later (see pci_intel.h) */ +_PROTOTYPE( unsigned pci_inb, (U16_t port) ); +_PROTOTYPE( unsigned pci_inw, (U16_t port) ); +_PROTOTYPE( unsigned pci_inl, (U16_t port) ); + +_PROTOTYPE( void pci_outb, (U16_t port, U8_t value) ); +_PROTOTYPE( void pci_outw, (U16_t port, U16_t value) ); +_PROTOTYPE( void pci_outl, (U16_t port, U32_t value) ); + +/* pci.c */ +_PROTOTYPE( void pci_init, (void) ); +_PROTOTYPE( int pci_find_dev, (U8_t bus, U8_t dev, U8_t func, + int *devindp) ); +_PROTOTYPE( int pci_first_dev, (int *devindp, u16_t *vidp, u16_t *didp) ); +_PROTOTYPE( int pci_next_dev, (int *devindp, u16_t *vidp, u16_t *didp) ); +_PROTOTYPE( void pci_reserve, (int devind) ); +_PROTOTYPE( void pci_ids, (int devind, u16_t *vidp, u16_t *didp) ); +_PROTOTYPE( char *pci_slot_name, (int devind) ); +_PROTOTYPE( char *pci_dev_name, (U16_t vid, U16_t did) ); +_PROTOTYPE( u8_t pci_attr_r8, (int devind, int port) ); +_PROTOTYPE( u16_t pci_attr_r16, (int devind, int port) ); +_PROTOTYPE( u32_t pci_attr_r32, (int devind, int port) ); +_PROTOTYPE( void pci_attr_w16, (int devind, int port, U16_t value) ); +_PROTOTYPE( void pci_attr_w32, (int devind, int port, u32_t value) ); + +#endif /* ENABLE_PCI */ + #define PCI_VID 0x00 /* Vendor ID, 16-bit */ #define PCI_DID 0x02 /* Device ID, 16-bit */ #define PCI_CR 0x04 /* Command Register, 16-bit */ diff --git a/drivers/libpci/pci_intel.h b/drivers/libpci/pci_intel.h index 50c59f0ee..6aef15a34 100644 --- a/drivers/libpci/pci_intel.h +++ b/drivers/libpci/pci_intel.h @@ -25,8 +25,8 @@ Created: Jan 2000 by Philip Homburg #define PCII_UNSEL (0) #define PCII_RREG8_(bus, dev, func, reg) \ - (outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \ - inb(PCII_CONFDATA+((reg)&3))) + (pci_outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \ + pci_inb(PCII_CONFDATA+((reg)&3))) #define PCII_RREG16_(bus, dev, func, reg) \ (PCII_RREG8_(bus, dev, func, reg) | \ (PCII_RREG8_(bus, dev, func, reg+1) << 8)) @@ -35,8 +35,8 @@ Created: Jan 2000 by Philip Homburg (PCII_RREG16_(bus, dev, func, reg+2) << 16)) #define PCII_WREG8_(bus, dev, func, reg, val) \ - (outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \ - outb(PCII_CONFDATA+((reg)&3), (val))) + (pci_outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \ + pci_outb(PCII_CONFDATA+((reg)&3), (val))) #define PCII_WREG16_(bus, dev, func, reg, val) \ (PCII_WREG8_(bus, dev, func, reg, (val)), \ (PCII_WREG8_(bus, dev, func, reg+1, (val) >> 8))) diff --git a/drivers/libpci/pci_table.c b/drivers/libpci/pci_table.c index fc4af3011..172676826 100644 --- a/drivers/libpci/pci_table.c +++ b/drivers/libpci/pci_table.c @@ -8,10 +8,15 @@ Created: Jan 2000 by Philip Homburg See the Linux PCI ID Repository . */ -#include "../../kernel/kernel.h" +/* Changes from original Minix 2.0.4 version (2003-09-05): + * 2003-11-30 (kjb) Minix 2.0.4 FIX.TAZ add D-Link RTL8139 (0x1186, 0x1300) + * 2004-08-08 (asw) add Intel 82371AB (0x8086, 0x7100) + */ + +#include "../drivers.h" #include "pci.h" #if __minix_vmd -#include "../../kernel/config.h" +#include "config.h" #endif #if ENABLE_PCI @@ -104,6 +109,7 @@ struct pci_device pci_device_table[]= { 0x8086, 0x7000, "Intel 82371SB" }, { 0x8086, 0x7010, "Intel 82371SB (IDE)" }, { 0x8086, 0x7020, "Intel 82371SB (USB)" }, + { 0x8086, 0x7100, "Intel 82371AB" }, { 0x8086, 0x7110, "Intel 82371AB (PIIX4)" }, { 0x8086, 0x7111, "Intel 82371AB (IDE)" }, { 0x8086, 0x7112, "Intel 82371AB (USB)" }, @@ -205,9 +211,12 @@ struct pci_intel_ctrl pci_intel_ctrl[]= { 0x10B9, 0x1541, }, /* ALI M1541 */ { 0x1106, 0x0305, }, /* VIA VT8363/8365 */ { 0x1106, 0x3099, }, /* VIA VT8367 [KT266] */ + { 0x1106, 0x3188, }, /* VIA */ + { 0x1106, 0x0204, }, /* VIA VT8367 [KT266] */ { 0x8086, 0x122D, }, /* Intel 82437FX */ { 0x8086, 0x1237, }, /* Intel 82441FX */ { 0x8086, 0x1250, }, /* Intel 82439HX */ + { 0x8086, 0x7100, }, /* Intel 82371AB */ { 0x8086, 0x7190, }, /* Intel 82443BX */ { 0x0000, 0x0000, }, }; @@ -219,8 +228,10 @@ struct pci_isabridge pci_isabridge[]= { 0x10B9, 0x1533, 1, PCI_IB_PIIX, }, /* ALI M1533 */ { 0x1106, 0x0686, 1, PCI_IB_VIA, }, /* VIA VT82C686 */ { 0x1106, 0x3074, 1, PCI_IB_VIA, }, /* VIA VT8233 */ + { 0x1106, 0x3227, 1, PCI_IB_VIA, }, /* VIA */ { 0x8086, 0x122E, 1, PCI_IB_PIIX, }, /* Intel 82371FB */ { 0x8086, 0x7000, 1, PCI_IB_PIIX, }, /* Intel 82371SB */ + { 0x8086, 0x7100, 1, PCI_IB_PIIX, }, /* Intel 82371AB */ { 0x8086, 0x7110, 1, PCI_IB_PIIX, }, /* Intel PIIX4 */ { 0x0000, 0x0000, 0, 0, }, }; diff --git a/drivers/rtl8139/Makefile b/drivers/rtl8139/Makefile new file mode 100644 index 000000000..7e16a3447 --- /dev/null +++ b/drivers/rtl8139/Makefile @@ -0,0 +1,54 @@ +# Makefile for the Realtek RTL8139 ethernet driver (RTL8139) +DRIVER = rtl8139 + +# directories +u = /usr +i = $u/include +s = $i/sys +m = $i/minix +b = $i/ibm +d = $u/src/drivers + +# programs, flags, etc. +MAKE = exec make +CC = exec cc +CFLAGS = -I$i +LDFLAGS = -i +LIBS = -lsys -lutils -ltimers + +OBJ = rtl8139.o +LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o + + +# build local binary +all build: $(DRIVER) +$(DRIVER): $(OBJ) $(PCI) + $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS) + install -S 256w $(DRIVER) + +$(PCI): + cd $d/libpci && $(MAKE) + +# install with other drivers +install: /usr/sbin/drivers/$(DRIVER) +/usr/sbin/drivers/$(DRIVER): $(DRIVER) + install -o root -cs $? $@ + +# clean up local files +clean: + rm -f $(DRIVER) *.o *.bak + + +# dependencies +a = $d/drivers.h $b/interrupt.h $b/bios.h \ + $i/ansi.h $i/string.h $i/limits.h $i/stddef.h $i/errno.h \ + $m/config.h $m/type.h $m/com.h $m/callnr.h $m/const.h $s/types.h \ + $m/syslib.h $s/types.h \ + $m/utils.h $m/serverassert.h $m/devio.h +l = $d/libpci/pci.h $d/libpci/pci.c $d/libpci/pci_table.c + + +rtl8139.o: $a $l + +$(LIBPCI): $a $l + diff --git a/kernel/rtl8139.c b/drivers/rtl8139/rtl8139.c similarity index 87% rename from kernel/rtl8139.c rename to drivers/rtl8139/rtl8139.c index 8a6bbe0e6..d3cd71703 100755 --- a/kernel/rtl8139.c +++ b/drivers/rtl8139/rtl8139.c @@ -46,7 +46,7 @@ * */ -#include "kernel.h" +#include "../drivers.h" #include #include @@ -81,8 +81,7 @@ #error PCI support not enabled #endif -#include "pci.h" -#include "proc.h" +#include "../libpci/pci.h" #include "rtl8139.h" INIT_SERVER_ASSERT @@ -136,7 +135,6 @@ PRIVATE struct pcitab { 0x0000, 0x0000, 0 } }; - typedef struct re { port_t re_base_port; @@ -175,7 +173,7 @@ typedef struct re u8_t re_pcifunc; /* 'large' items */ - irq_hook_t re_hook; + int re_hook_id; /* IRQ hook id at kernel */ eth_stat_t re_stat; ether_addr_t re_address; message re_rx_mess; @@ -208,12 +206,55 @@ static int rl_tasknr; static u16_t eth_ign_proto; static tmra_ut rl_watchdog; -#define rl_inb(port, offset) (inb((port) + (offset))) -#define rl_inw(port, offset) (inw((port) + (offset))) -#define rl_inl(port, offset) (inl((port) + (offset))) -#define rl_outb(port, offset, value) (outb((port) + (offset), (value))) -#define rl_outw(port, offset, value) (outw((port) + (offset), (value))) -#define rl_outl(port, offset, value) (outl((port) + (offset), (value))) +FORWARD _PROTOTYPE( unsigned my_inb, (U16_t port) ); +FORWARD _PROTOTYPE( unsigned my_inw, (U16_t port) ); +FORWARD _PROTOTYPE( unsigned my_inl, (U16_t port) ); +static unsigned my_inb(U16_t port) { + U8_t value; + int s; + if ((s=sys_inb(port, &value)) !=OK) + printf("RTL8139: warning, sys_inb failed: %d\n", s); + return value; +} +static unsigned my_inw(U16_t port) { + U16_t value; + int s; + if ((s=sys_inw(port, &value)) !=OK) + printf("RTL8139: warning, sys_inw failed: %d\n", s); + return value; +} +static unsigned my_inl(U16_t port) { + U32_t value; + int s; + if ((s=sys_inl(port, &value)) !=OK) + printf("RTL8139: warning, sys_inl failed: %d\n", s); + return value; +} +#define rl_inb(port, offset) (my_inb((port) + (offset))) +#define rl_inw(port, offset) (my_inw((port) + (offset))) +#define rl_inl(port, offset) (my_inl((port) + (offset))) + +FORWARD _PROTOTYPE( void my_outb, (U16_t port, U8_t value) ); +FORWARD _PROTOTYPE( void my_outw, (U16_t port, U16_t value) ); +FORWARD _PROTOTYPE( void my_outl, (U16_t port, U32_t value) ); +static void my_outb(U16_t port, U8_t value) { + int s; + if ((s=sys_outb(port, value)) !=OK) + printf("RTL8139: warning, sys_outb failed: %d\n", s); +} +static void my_outw(U16_t port, U16_t value) { + int s; + if ((s=sys_outw(port, value)) !=OK) + printf("RTL8139: warning, sys_outw failed: %d\n", s); +} +static void my_outl(U16_t port, U32_t value) { + int s; + if ((s=sys_outl(port, value)) !=OK) + printf("RTL8139: warning, sys_outl failed: %d\n", s); +} +#define rl_outb(port, offset, value) (my_outb((port) + (offset), (value))) +#define rl_outw(port, offset, value) (my_outw((port) + (offset), (value))) +#define rl_outl(port, offset, value) (my_outl((port) + (offset), (value))) _PROTOTYPE( static void rl_init, (message *mp) ); _PROTOTYPE( static void rl_pci_conf, (void) ); @@ -241,11 +282,13 @@ _PROTOTYPE( static void mess_reply, (message *req, message *reply) ); _PROTOTYPE( static void put_userdata, (int user_proc, vir_bytes user_addr, vir_bytes count, void *loc_addr) ); _PROTOTYPE( static void rtl8139_stop, (void) ); +_PROTOTYPE( static void check_int_events, (void) ); +_PROTOTYPE( static int do_hard_int, (void) ); _PROTOTYPE( static void rtl8139_dump, (message *m) ); #if 0 _PROTOTYPE( static void dump_phy, (re_t *rep) ); #endif -_PROTOTYPE( static int rl_handler, (irq_hook_t *hookp) ); +_PROTOTYPE( static int rl_handler, (re_t *rep) ); #if __minix_vmd _PROTOTYPE( static void rl_watchdog_f, (tmra_ut *tp, tmr_arg_ut arg) ); #else @@ -256,11 +299,12 @@ _PROTOTYPE( static void rl_watchdog_f, (timer_t *tp) ); * can change its message type to fake a HARD_INT message. */ PRIVATE message m; +PRIVATE int int_event_check; /* set to TRUE if events arrived */ /*===========================================================================* * rtl8139_task * *===========================================================================*/ -void rtl8139_task() +void main(void) { int i, r; re_t *rep; @@ -314,11 +358,29 @@ void rtl8139_task() * HARD_INT in rl_watchdog_f when needed, so that this * case falls through. */ - rl_watchdog_f(NULL); /* possibly changes m_type */ - if (m.m_type != HARD_INT) /* to HARD_INT if further */ - break; /* handling is needed */ -#endif /* fall through */ + rl_watchdog_f(NULL); +#if DEAD_CODE /* now directly done */ + if (m.m_type != HARD_INT) +#endif + break; +#endif case HARD_INT: + do_hard_int(); + if (int_event_check) + check_int_events(); + break ; + case FKEY_PRESSED: rtl8139_dump(&m); break; + case HARD_STOP: rtl8139_stop(); break; + default: + server_panic("rtl8139","illegal message", m.m_type); + } + } +} + +static void check_int_events(void) +{ + int i; + re_t *rep; for (i= 0, rep= &re_table[0]; ire_mode != REM_ENABLED) @@ -329,13 +391,6 @@ void rtl8139_task() server_assert(rep->re_flags & REF_ENABLED); rl_check_ints(rep); } - break ; - case FKEY_PRESSED: rtl8139_dump(&m); break; - case HARD_STOP: rtl8139_stop(); break; - default: - server_panic("rtl8139","illegal message", m.m_type); - } - } } /*===========================================================================* @@ -352,7 +407,7 @@ static void rtl8139_stop() continue; rl_outb(rep->re_base_port, RL_CR, 0); } - printf("RTL8139 driver stopped.\n", NO_ARG); + sys_exit(0); } /*===========================================================================* @@ -614,11 +669,8 @@ re_t *rep; dname= pci_dev_name(vid, did); if (!dname) dname= "unknown device"; - kprintf("%s: ", (karg_t) rep->re_name); - kprintf("%s ", (karg_t) dname); - kprintf("(%x/", (karg_t) vid); - kprintf("%x) ", (karg_t) did); - kprintf("at %s\n", (karg_t) pci_slot_name(devind)); + printf("%s: ", rep->re_name); + printf("%s (%x/%x) at %s\n", dname, vid, did, pci_slot_name(devind)); pci_reserve(devind); /* printf("cr = 0x%x\n", pci_attr_r16(devind, PCI_CR)); */ bar= pci_attr_r32(devind, PCI_BAR) & 0xffffffe0; @@ -708,7 +760,7 @@ re_t *rep; static void rl_init_hw(rep) re_t *rep; { - int i; + int s, i; #if __minix_vmd rl_init_buf(rep); @@ -718,15 +770,17 @@ re_t *rep; rep->re_flags |= REF_ENABLED; /* set the interrupt handler */ - put_irq_handler(&rep->re_hook, rep->re_irq, rl_handler); + /* only send HARD_INT notifications */ + if ((s=sys_irqsetpolicy(rep->re_irq, 0, &rep->re_hook_id)) != OK) + printf("RTL8139: error, couldn't set IRQ policy: %d\n", s); rl_reset_hw(rep); - enable_irq(&rep->re_hook); + if ((s=sys_irqenable(&rep->re_hook_id)) != OK) + printf("RTL8139: error, couldn't enable interrupts: %d\n", s); if (rep->re_mode) { - kprintf("%s: ", (karg_t) rep->re_name); - kprintf("model %s\n", (karg_t) rep->re_model); + printf("%s: model %s\n", rep->re_name, rep->re_model); } else { printf("%s: unknown model 0x%08x\n", @@ -948,6 +1002,7 @@ int vectored; u32_t l, rxstat; re_t *rep; iovec_t *iovp; + int cps; dl_port = mp->DL_PORT; count = mp->DL_COUNT; @@ -989,8 +1044,8 @@ int vectored; amount= d_end+RX_BUFSIZE - d_start; src_phys= rep->re_rx_buf + d_start; - dst_phys= vir2phys(&rxstat); - phys_copy(src_phys, dst_phys, sizeof(rxstat)); + cps = sys_physcopy(NONE, PHYS_SEG, src_phys, SELF, D, (vir_bytes) &rxstat, sizeof(rxstat)); + if (cps != OK) printf("RTL8139: warning, sys_abscopy failed: %d\n", cps); if (rep->re_clear_rx) { @@ -1038,10 +1093,9 @@ int vectored; if (vectored) { - iov_src = numap_local(re_client, (vir_bytes)mp->DL_ADDR, - count * sizeof(rep->re_iovec[0])); - if (!iov_src) - server_panic("rtl8139","umap_local failed", NO_NUM); + if ((cps = sys_umap(re_client, D, (vir_bytes) mp->DL_ADDR, + count * sizeof(rep->re_iovec[0]), &iov_src)) != OK) + printf("sys_umap failed: %d\n", cps); size= 0; o= d_start+4; @@ -1052,8 +1106,9 @@ int vectored; n= IOVEC_NR; if (i+n > count) n= count-i; - phys_copy(iov_src, vir2phys(rep->re_iovec), + cps = sys_physcopy(NONE, PHYS_SEG, iov_src, SELF, D, (vir_bytes) rep->re_iovec, n * sizeof(rep->re_iovec[0])); + if (cps != OK) printf("RTL8139: warning, sys_abscopy failed: %d\n", cps); for (j= 0, iovp= rep->re_iovec; jiov_addr, s); - if (!dst_phys) - server_panic("rtl8139","umap_local failed\n", - NO_NUM); + if (sys_umap(re_client, D, iovp->iov_addr, s, &dst_phys) != OK) + server_panic("rtl8139","umap_local failed\n", NO_NUM); if (o >= RX_BUFSIZE) { @@ -1080,12 +1133,15 @@ int vectored; server_assert(oDL_COUNT; if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE_TAGGED) server_panic("rtl8139","invalid packet size", size); - phys_user = numap_local(re_client, (vir_bytes)mp->DL_ADDR, size); - if (!phys_user) + if (OK != sys_umap(re_client, D, (vir_bytes)mp->DL_ADDR, size, &phys_user)) server_panic("rtl8139","umap_local failed", NO_NUM); p= rep->re_tx[tx_head].ret_buf; - phys_copy(phys_user, p, size); -#endif - } - - if (rep->re_clear_rx) - { - /* For some reason the receiver FIFO is not stopped when - * the buffer is full. - */ -#if 0 - printf("rl_readv: later buffer overflow\n"); -#endif - goto suspend; /* Buffer overflow */ - } + cps = sys_abscopy(phys_user, p, size); + if (cps != OK) printf("RTL8139: warning, sys_abscopy failed: %d\n", cps); + #endif + } + if (rep->re_clear_rx) + { + /* For some reason the receiver FIFO is not stopped when + * the buffer is full. + */ + #if 0 + printf("rl_readv: later buffer overflow\n"); + #endif + goto suspend; /* Buffer overflow */ + } - rep->re_stat.ets_packetR++; - rep->re_read_s= packlen; - rep->re_flags= (rep->re_flags & ~REF_READING) | REF_PACK_RECV; - /* Avoid overflow in 16-bit computations */ - l= d_start; - l += totlen+4; - l= (l+3) & ~3; /* align */ - if (l >= RX_BUFSIZE) - { - l -= RX_BUFSIZE; - server_assert(l < RX_BUFSIZE); - } - rl_outw(port, RL_CAPR, l-RL_CAPR_DATA_OFF); + rep->re_stat.ets_packetR++; + rep->re_read_s= packlen; + rep->re_flags= (rep->re_flags & ~REF_READING) | REF_PACK_RECV; - if (!from_int) - reply(rep, OK, FALSE); + /* Avoid overflow in 16-bit computations */ + l= d_start; + l += totlen+4; + l= (l+3) & ~3; /* align */ + if (l >= RX_BUFSIZE) + { + l -= RX_BUFSIZE; + server_assert(l < RX_BUFSIZE); + } + rl_outw(port, RL_CAPR, l-RL_CAPR_DATA_OFF); - return; + if (!from_int) + reply(rep, OK, FALSE); -suspend: - if (from_int) - { - server_assert(rep->re_flags & REF_READING); - - /* No need to store any state */ return; - } - - rep->re_rx_mess= *mp; - server_assert(!(rep->re_flags & REF_READING)); - rep->re_flags |= REF_READING; - reply(rep, OK, FALSE); -} - -/*===========================================================================* - * rl_writev * - *===========================================================================*/ -static void rl_writev(mp, from_int, vectored) -message *mp; -int from_int; -int vectored; -{ - phys_bytes p, iov_src, phys_user; - int i, j, n, s, port, count, size; - int tx_head, re_client; - re_t *rep; - iovec_t *iovp; + suspend: + if (from_int) + { + server_assert(rep->re_flags & REF_READING); - port = mp->DL_PORT; - count = mp->DL_COUNT; - if (port < 0 || port >= RE_PORT_NR) - server_panic("rtl8139","illegal port", port); - rep= &re_table[port]; - re_client= mp->DL_PROC; - rep->re_client= re_client; + /* No need to store any state */ + return; + } - server_assert(rep->re_mode == REM_ENABLED); - server_assert(rep->re_flags & REF_ENABLED); + rep->re_rx_mess= *mp; + server_assert(!(rep->re_flags & REF_READING)); + rep->re_flags |= REF_READING; - if (from_int) - { - server_assert(rep->re_flags & REF_SEND_AVAIL); - rep->re_flags &= ~REF_SEND_AVAIL; - rep->re_send_int= FALSE; - rep->re_tx_alive= TRUE; + reply(rep, OK, FALSE); } - tx_head= rep->re_tx_head; - if (rep->re_tx[tx_head].ret_busy) - { - server_assert(!(rep->re_flags & REF_SEND_AVAIL)); - rep->re_flags |= REF_SEND_AVAIL; - if (rep->re_tx[tx_head].ret_busy) - goto suspend; + /*===========================================================================* + * rl_writev * + *===========================================================================*/ + static void rl_writev(mp, from_int, vectored) + message *mp; + int from_int; + int vectored; + { + phys_bytes p, iov_src, phys_user; + int i, j, n, s, port, count, size; + int tx_head, re_client; + re_t *rep; + iovec_t *iovp; + int cps; + + port = mp->DL_PORT; + count = mp->DL_COUNT; + if (port < 0 || port >= RE_PORT_NR) + server_panic("rtl8139","illegal port", port); + rep= &re_table[port]; + re_client= mp->DL_PROC; + rep->re_client= re_client; + + server_assert(rep->re_mode == REM_ENABLED); + server_assert(rep->re_flags & REF_ENABLED); + + if (from_int) + { + server_assert(rep->re_flags & REF_SEND_AVAIL); + rep->re_flags &= ~REF_SEND_AVAIL; + rep->re_send_int= FALSE; + rep->re_tx_alive= TRUE; + } - /* Race condition, the interrupt handler may clear re_busy - * before we got a chance to set REF_SEND_AVAIL. Checking - * ret_busy twice should be sufficient. - */ -#if 0 - printf("rl_writev: race detected\n"); -#endif - rep->re_flags &= ~REF_SEND_AVAIL; - rep->re_send_int= FALSE; - } + tx_head= rep->re_tx_head; + if (rep->re_tx[tx_head].ret_busy) + { + server_assert(!(rep->re_flags & REF_SEND_AVAIL)); + rep->re_flags |= REF_SEND_AVAIL; + if (rep->re_tx[tx_head].ret_busy) + goto suspend; + + /* Race condition, the interrupt handler may clear re_busy + * before we got a chance to set REF_SEND_AVAIL. Checking + * ret_busy twice should be sufficient. + */ + #if 0 + printf("rl_writev: race detected\n"); + #endif + rep->re_flags &= ~REF_SEND_AVAIL; + rep->re_send_int= FALSE; + } - server_assert(!(rep->re_flags & REF_SEND_AVAIL)); - server_assert(!(rep->re_flags & REF_PACK_SENT)); + server_assert(!(rep->re_flags & REF_SEND_AVAIL)); + server_assert(!(rep->re_flags & REF_PACK_SENT)); - if (vectored) - { + if (vectored) + { - iov_src = numap_local(re_client, (vir_bytes)mp->DL_ADDR, - count * sizeof(rep->re_iovec[0])); - if (!iov_src) - server_panic("rtl8139","umap_local failed", NO_NUM); + if (OK != sys_umap(re_client, D, (vir_bytes)mp->DL_ADDR, + count * sizeof(rep->re_iovec[0]), &iov_src)) + server_panic("rtl8139","umap_local failed", NO_NUM); - size= 0; - p= rep->re_tx[tx_head].ret_buf; - for (i= 0; ire_iovec[0])) - { - n= IOVEC_NR; - if (i+n > count) - n= count-i; - phys_copy(iov_src, vir2phys(rep->re_iovec), - n * sizeof(rep->re_iovec[0])); + size= 0; + p= rep->re_tx[tx_head].ret_buf; + for (i= 0; ire_iovec[0])) + { + n= IOVEC_NR; + if (i+n > count) + n= count-i; + cps = sys_physcopy(NONE, PHYS_SEG, iov_src, SELF, D, (vir_bytes) rep->re_iovec, + n * sizeof(rep->re_iovec[0])); + if (cps != OK) printf("RTL8139: warning, sys_abscopy failed: %d\n", cps); for (j= 0, iovp= rep->re_iovec; jiov_addr, s); - if (!phys_user) - server_panic("rtl8139","umap_local failed\n", - NO_NUM); - phys_copy(phys_user, p, s); + if (OK != sys_umap(re_client, D, iovp->iov_addr, s, &phys_user)) + server_panic("rtl8139","umap_local failed\n", NO_NUM); + + cps = sys_abscopy(phys_user, p, s); + if (cps != OK) printf("RTL8139: warning, sys_abscopy failed: %d\n", cps); size += s; p += s; } @@ -1265,12 +1322,12 @@ int vectored; size= mp->DL_COUNT; if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE_TAGGED) server_panic("rtl8139","invalid packet size", size); - phys_user = numap_local(re_client, (vir_bytes)mp->DL_ADDR, size); - if (!phys_user) + if (OK != sys_umap(re_client, D, (vir_bytes)mp->DL_ADDR, size, &phys_user)) server_panic("rtl8139","umap_local failed\n", NO_NUM); p= rep->re_tx[tx_head].ret_buf; - phys_copy(phys_user, p, size); + cps = sys_abscopy(phys_user, p, size); + if (cps != OK) printf("RTL8139: warning, sys_abscopy failed: %d\n", cps); } rl_outl(rep->re_base_port, RL_TSD0+tx_head*4, @@ -1422,7 +1479,7 @@ re_t *rep; rep->re_link_up= link_up; if (!link_up) { - kprintf("%s: link down\n", (karg_t) rep->re_name); + printf("%s: link down\n", rep->re_name); return; } @@ -1491,7 +1548,7 @@ re_t *rep; rep->re_name); } if (!(mii_status & MII_STATUS_LS)) - kprintf("%s: link down\n", (karg_t) rep->re_name); + printf("%s: link down\n", rep->re_name); if (mii_status & MII_STATUS_JD) printf("%s: jabber condition detected\n", rep->re_name); if (!(mii_status & MII_STATUS_EC)) @@ -1520,9 +1577,9 @@ re_t *rep; printf("\n"); resspeed: - kprintf("%s: ", (karg_t) rep->re_name); - kprintf("link up at %d Mbps, ", (msr & RL_MSR_SPEED_10) ? 10 : 100); - kprintf("%s duplex\n", (karg_t) ((mii_ctrl & MII_CTRL_DM) ? "full" : "half")); + printf("%s: ", rep->re_name); + printf("link up at %d Mbps, ", (msr & RL_MSR_SPEED_10) ? 10 : 100); + printf("%s duplex\n", ((mii_ctrl & MII_CTRL_DM) ? "full" : "half")); } @@ -1779,9 +1836,7 @@ message *mp; server_assert(rep->re_mode == REM_ENABLED); server_assert(rep->re_flags & REF_ENABLED); - lock(); /* Interrupt handler updates stats */ stats= rep->re_stat; - unlock(); put_userdata(mp->DL_PROC, (vir_bytes) mp->DL_ADDR, (vir_bytes) sizeof(stats), &stats); @@ -1854,13 +1909,9 @@ vir_bytes user_addr; vir_bytes count; void *loc_addr; { - phys_bytes dst; - - dst = numap_local(user_proc, user_addr, count); - if (!dst) - server_panic("rtl8139","umap_local failed", NO_NUM); - - phys_copy(vir2phys(loc_addr), dst, (phys_bytes) count); + int cps; + cps = sys_datacopy(SELF, (vir_bytes) loc_addr, user_proc, user_addr, count); + if (cps != OK) printf("RTL8139: warning, scopy failed: %d\n", cps); } #if 0 @@ -1959,12 +2010,27 @@ re_t *rep; } #endif +static int do_hard_int(void) +{ + int i,s; + + for (i=0; i < RE_PORT_NR; i ++) { + + /* Run interrupt handler at driver level. */ + rl_handler( &re_table[i]); + + /* Reenable interrupts for this hook. */ + if ((s=sys_irqenable(&re_table[i].re_hook_id)) != OK) + printf("RTL8139: error, couldn't enable interrupts: %d\n", s); + } +} + /*===========================================================================* * rl_handler * *===========================================================================*/ -static int rl_handler(hookp) -irq_hook_t *hookp; +static int rl_handler(rep) +re_t *rep; { int i, port, tx_head, tx_tail, link_up; u16_t isr, tsad; @@ -1972,12 +2038,12 @@ irq_hook_t *hookp; #if 0 u8_t cr; #endif - re_t *rep; static int timeout; /* must be static if not cancelled */ + int_event_check = FALSE; /* disable check by default */ + RAND_UPDATE - rep= structof(re_t, re_hook, hookp); port= rep->re_base_port; @@ -2004,7 +2070,7 @@ irq_hook_t *hookp; { rep->re_report_link= TRUE; rep->re_got_int= TRUE; - notify(rl_tasknr, HARD_INT); + int_event_check = TRUE; } } if (isr & RL_IMR_RXOVW) @@ -2014,7 +2080,7 @@ irq_hook_t *hookp; /* Clear the receive buffer */ rep->re_clear_rx= TRUE; rep->re_got_int= TRUE; - notify(rl_tasknr, HARD_INT); + int_event_check = TRUE; } if (isr & (RL_ISR_RER | RL_ISR_ROK)) @@ -2024,7 +2090,7 @@ irq_hook_t *hookp; if (!rep->re_got_int && (rep->re_flags & REF_READING)) { rep->re_got_int= TRUE; - notify(rl_tasknr, HARD_INT); + int_event_check = TRUE; } } #if 0 @@ -2061,7 +2127,7 @@ irq_hook_t *hookp; /* Just reset the whole chip */ rep->re_need_reset= TRUE; rep->re_got_int= TRUE; - notify(rl_tasknr, HARD_INT); + int_event_check = TRUE; #elif 0 /* Reset transmitter */ rep->re_stat.ets_transAb++; @@ -2093,7 +2159,7 @@ irq_hook_t *hookp; printf("rl_handler: REF_SEND_AVAIL\n"); rep->re_send_int= TRUE; rep->re_got_int= TRUE; - notify(rl_tasknr, HARD_INT); + int_event_check = TRUE; } for (i= 0; i< N_TX_BUF; i++) rep->re_tx[i].ret_busy= FALSE; @@ -2226,7 +2292,7 @@ irq_hook_t *hookp; if (!rep->re_got_int) { rep->re_got_int= TRUE; - notify(rl_tasknr, HARD_INT); + int_event_check = TRUE; } } } @@ -2296,14 +2362,22 @@ timer_t *tp; rep->re_need_reset= TRUE; rep->re_got_int= TRUE; #if __minix_vmd - notify(rl_tasknr, HARD_INT); +#if DEAD_CODE + notify(rl_tasknr, HARD_INT); +#else + check_int_events(); +#endif #else /* Under MINIX, we got here via a synchronous alarm call. * Change the message type to HARD_INT to fake an interrupt. * The switch in the main loop 'falls through' if it sees * the HARD_INT message type. */ +#if DEAD_CODE m.m_type = HARD_INT; +#else + check_int_events(); +#endif #endif } } diff --git a/kernel/rtl8139.h b/drivers/rtl8139/rtl8139.h similarity index 100% rename from kernel/rtl8139.h rename to drivers/rtl8139/rtl8139.h diff --git a/include/minix/com.h b/include/minix/com.h index 2e34e58da..3d370c418 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -32,14 +32,13 @@ */ /* Kernel tasks. These all run in the same address space. */ -#define RTL8139 IDLE - ENABLE_RTL8139 /* networking */ #define IDLE -4 /* runs when no one else can run */ #define CLOCK -3 /* alarms and other clock functions */ #define SYSTASK -2 /* request system functionality */ #define HARDWARE -1 /* used as source on notify() messages */ /* Number of tasks. Note that NR_PROCS is defined in . */ -#define NR_TASKS (4 + ENABLE_RTL8139) +#define NR_TASKS 4 /* Magic numbers for controllers. Device driver mapping is dynamic. */ #define CTRLR(n) (NONE + (n)) @@ -53,15 +52,16 @@ #define AT_WINI (MEMORY + ENABLE_AT_WINI) /* AT Winchester */ #define FLOPPY (AT_WINI + ENABLE_FLOPPY) /* floppy disk */ #define PRINTER (FLOPPY + ENABLE_PRINTER) /* Centronics */ -#define INIT_PROC_NR (PRINTER + 1) /* init -- goes multiuser */ +#define USR8139 (PRINTER + ENABLE_RTL8139) /* Realtek RTL8139 */ +#define INIT_PROC_NR (USR8139 + 1) /* init -- goes multiuser */ /* Number of first user process not part of the operating system. */ #define LOW_USER INIT_PROC_NR -/* The number of processes that are contained in the system image. */ +/* Number of processes contained in the system image. */ #define IMAGE_SIZE (NR_TASKS + \ 5 + ENABLE_AT_WINI + ENABLE_FLOPPY + \ - ENABLE_PRINTER + 1 ) + ENABLE_PRINTER + ENABLE_RTL8139 + 1 ) /*===========================================================================* diff --git a/include/minix/devio.h b/include/minix/devio.h index 04e2acc84..cb8902951 100644 --- a/include/minix/devio.h +++ b/include/minix/devio.h @@ -12,6 +12,9 @@ #include /* needed to include */ #include /* u8_t, u16_t, u32_t needed */ +typedef u16_t port_t; +typedef U16_t Port_t; + /* We have different granularities of port I/O: 8, 16, 32 bits. * Also see , which has functions for bytes, words, * and longs. Hence, we need different (port,value)-pair types. diff --git a/kernel/Makefile b/kernel/Makefile index 8a83bb9a0..05dabc70f 100755 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -22,8 +22,7 @@ HEAD = mpx.o OBJS = start.o protect.o klibc.o klib.o table.o main.o proc.o \ i8259.o exception.o system.o clock.o misc.o \ - dummy.o \ - rtl8139.o pci.o pci_table.o + dummy.o SYS = system/system.a @@ -136,28 +135,6 @@ table.o: proc.h table.o: sendmask.h table.o: $b/int86.h -rtl8139.o: $a -rtl8139.o: $h/com.h -rtl8139.o: $n/hton.h -rtl8139.o: $g/ether.h -rtl8139.o: $g/eth_io.h -rtl8139.o: $i/stddef.h -rtl8139.o: assert.h -rtl8139.o: pci.h -rtl8139.o: proc.h -rtl8139.o: rtl8139.h - -pci.o: $a -pci.o: assert.h -pci.o: pci.h -pci.o: pci_amd.h -pci.o: pci_intel.h -pci.o: pci_via.h -pci.o: pci_sis.h - -pci_table.o: $a -pci_table.o: pci.h - dummy.o: $a system/system.a: $a $h/devio.h $h/com.h diff --git a/kernel/pci.c b/kernel/pci.c deleted file mode 100755 index 3ddd1b0b6..000000000 --- a/kernel/pci.c +++ /dev/null @@ -1,1227 +0,0 @@ -/* -pci.c - -Configure devices on the PCI bus - -Created: Jan 2000 by Philip Homburg -*/ - -#include "kernel.h" - - -#include "pci.h" -#include "pci_amd.h" -#include "pci_intel.h" -#include "pci_sis.h" -#include "pci_via.h" -#if __minix_vmd -#include "config.h" -#endif - -#if ENABLE_PCI - -#if !__minix_vmd -#define debug 0 -#define irq_mode_pci(irq) ((void)0) -#endif - -#include -#include -#include -#include -INIT_SERVER_ASSERT - -#define NR_PCIBUS 2 -#define NR_PCIDEV 40 - -#define PBT_INTEL 1 -#define PBT_PCIBRIDGE 2 - -PRIVATE struct pcibus -{ - int pb_type; - int pb_isabridge_dev; - int pb_isabridge_type; - - int pb_devind; - int pb_bus; - u8_t (*pb_rreg8)(int busind, int devind, int port); - u16_t (*pb_rreg16)(int busind, int devind, int port); - u32_t (*pb_rreg32)(int busind, int devind, int port); - void (*pb_wreg16)(int busind, int devind, int port, U16_t value); - void (*pb_wreg32)(int busind, int devind, int port, u32_t value); - u16_t (*pb_rsts)(int busind); - void (*pb_wsts)(int busind, U16_t value); -} pcibus[NR_PCIBUS]; -PRIVATE int nr_pcibus= 0; - -PRIVATE struct pcidev -{ - u8_t pd_busind; - u8_t pd_dev; - u8_t pd_func; - u8_t pd_baseclass; - u8_t pd_subclass; - u8_t pd_infclass; - u16_t pd_vid; - u16_t pd_did; - u8_t pd_inuse; -} pcidev[NR_PCIDEV]; -PRIVATE int nr_pcidev= 0; - -FORWARD _PROTOTYPE( void pci_intel_init, (void) ); -FORWARD _PROTOTYPE( void probe_bus, (int busind) ); -FORWARD _PROTOTYPE( int do_isabridge, (int busind) ); -FORWARD _PROTOTYPE( void do_pcibridge, (int busind) ); -FORWARD _PROTOTYPE( int do_piix, (int devind) ); -FORWARD _PROTOTYPE( int do_amd_isabr, (int devind) ); -FORWARD _PROTOTYPE( int do_sis_isabr, (int devind) ); -FORWARD _PROTOTYPE( int do_via_isabr, (int devind) ); -FORWARD _PROTOTYPE( char *pci_vid_name, (U16_t vid) ); -FORWARD _PROTOTYPE( char *pci_baseclass_name, (U8_t baseclass) ); -FORWARD _PROTOTYPE( char *pci_subclass_name, (U8_t baseclass, - U8_t subclass, U8_t infclass) ); -FORWARD _PROTOTYPE( void ntostr, (unsigned n, char **str, char *end) ); -FORWARD _PROTOTYPE( u16_t pci_attr_rsts, (int devind) ); -FORWARD _PROTOTYPE( void pci_attr_wsts, (int devind, U16_t value) ); -FORWARD _PROTOTYPE( u16_t pcibr_intel_rsts, (int busind) ); -FORWARD _PROTOTYPE( void pcibr_intel_wsts, (int busind, U16_t value) ); -FORWARD _PROTOTYPE( u16_t pcibr_via_rsts, (int busind) ); -FORWARD _PROTOTYPE( void pcibr_via_wsts, (int busind, U16_t value) ); -FORWARD _PROTOTYPE( u8_t pcii_rreg8, (int busind, int devind, int port) ); -FORWARD _PROTOTYPE( u16_t pcii_rreg16, (int busind, int devind, - int port) ); -FORWARD _PROTOTYPE( u32_t pcii_rreg32, (int busind, int devind, - int port) ); -FORWARD _PROTOTYPE( void pcii_wreg16, (int busind, int devind, int port, - U16_t value) ); -FORWARD _PROTOTYPE( void pcii_wreg32, (int busind, int devind, int port, - u32_t value) ); -FORWARD _PROTOTYPE( u16_t pcii_rsts, (int busind) ); -FORWARD _PROTOTYPE( void pcii_wsts, (int busind, U16_t value) ); - -/*===========================================================================* - * pci_init * - *===========================================================================*/ -PUBLIC void pci_init() -{ - static int first_time= 1; - - if (!first_time) - return; - - /* We don't expect to interrupted */ - server_assert(first_time == 1); - first_time= -1; - - /* Only Intel (compatible) PCI controllers are supported at the - * moment. - */ - pci_intel_init(); - - first_time= 0; -} - -/*===========================================================================* - * pci_find_dev * - *===========================================================================*/ -PUBLIC int pci_find_dev(bus, dev, func, devindp) -u8_t bus; -u8_t dev; -u8_t func; -int *devindp; -{ - int devind; - - for (devind= 0; devind < nr_pcidev; devind++) - { - if (pcidev[devind].pd_busind == bus && - pcidev[devind].pd_dev == dev && - pcidev[devind].pd_func == func) - { - break; - } - } - if (devind >= nr_pcidev) - return 0; - if (pcidev[devind].pd_inuse) - return 0; - *devindp= devind; - return 1; -} - - -/*===========================================================================* - * pci_first_dev * - *===========================================================================*/ -PUBLIC int pci_first_dev(devindp, vidp, didp) -int *devindp; -u16_t *vidp; -u16_t *didp; -{ - int devind; - - for (devind= 0; devind < nr_pcidev; devind++) - { - if (!pcidev[devind].pd_inuse) - break; - } - if (devind >= nr_pcidev) - return 0; - *devindp= devind; - *vidp= pcidev[devind].pd_vid; - *didp= pcidev[devind].pd_did; - return 1; -} - - -/*===========================================================================* - * pci_next_dev * - *===========================================================================*/ -PUBLIC int pci_next_dev(devindp, vidp, didp) -int *devindp; -u16_t *vidp; -u16_t *didp; -{ - int devind; - - for (devind= *devindp+1; devind < nr_pcidev; devind++) - { - if (!pcidev[devind].pd_inuse) - break; - } - if (devind >= nr_pcidev) - return 0; - *devindp= devind; - *vidp= pcidev[devind].pd_vid; - *didp= pcidev[devind].pd_did; - return 1; -} - - -/*===========================================================================* - * pci_reserve * - *===========================================================================*/ -PUBLIC void pci_reserve(devind) -int devind; -{ - server_assert(devind <= nr_pcidev); - server_assert(!pcidev[devind].pd_inuse); - pcidev[devind].pd_inuse= 1; -} - - -/*===========================================================================* - * pci_ids * - *===========================================================================*/ -PUBLIC void pci_ids(devind, vidp, didp) -int devind; -u16_t *vidp; -u16_t *didp; -{ - server_assert(devind <= nr_pcidev); - *vidp= pcidev[devind].pd_vid; - *didp= pcidev[devind].pd_did; -} - - -/*===========================================================================* - * pci_slot_name * - *===========================================================================*/ -PUBLIC char *pci_slot_name(devind) -int devind; -{ - static char label[]= "ddd.ddd.ddd"; - char *end; - char *p; - - p= label; - end= label+sizeof(label); - - ntostr(pcidev[devind].pd_busind, &p, end); - *p++= '.'; - - ntostr(pcidev[devind].pd_dev, &p, end); - *p++= '.'; - - ntostr(pcidev[devind].pd_func, &p, end); - - return label; -} - -/*===========================================================================* - * pci_dev_name * - *===========================================================================*/ -PUBLIC char *pci_dev_name(vid, did) -u16_t vid; -u16_t did; -{ - int i; - - for (i= 0; pci_device_table[i].name; i++) - { - if (pci_device_table[i].vid == vid && - pci_device_table[i].did == did) - { - return pci_device_table[i].name; - } - } - return NULL; -} - - -/*===========================================================================* - * pci_attr_r8 * - *===========================================================================*/ -PUBLIC u8_t pci_attr_r8(devind, port) -int devind; -int port; -{ - int busind; - - busind= pcidev[devind].pd_busind; - return pcibus[busind].pb_rreg8(busind, devind, port); -} - - -/*===========================================================================* - * pci_attr_r16 * - *===========================================================================*/ -PUBLIC u16_t pci_attr_r16(devind, port) -int devind; -int port; -{ - int busind; - - busind= pcidev[devind].pd_busind; - return pcibus[busind].pb_rreg16(busind, devind, port); -} - - -/*===========================================================================* - * pci_attr_r32 * - *===========================================================================*/ -PUBLIC u32_t pci_attr_r32(devind, port) -int devind; -int port; -{ - int busind; - - busind= pcidev[devind].pd_busind; - return pcibus[busind].pb_rreg32(busind, devind, port); -} - - -/*===========================================================================* - * pci_attr_w16 * - *===========================================================================*/ -PUBLIC void pci_attr_w16(devind, port, value) -int devind; -int port; -u16_t value; -{ - int busind; - - busind= pcidev[devind].pd_busind; - pcibus[busind].pb_wreg16(busind, devind, port, value); -} - - -/*===========================================================================* - * pci_attr_w32 * - *===========================================================================*/ -PUBLIC void pci_attr_w32(devind, port, value) -int devind; -int port; -u32_t value; -{ - int busind; - - busind= pcidev[devind].pd_busind; - pcibus[busind].pb_wreg32(busind, devind, port, value); -} - - -/*===========================================================================* - * pci_intel_init * - *===========================================================================*/ -PRIVATE void pci_intel_init() -{ - /* Try to detect a know PCI controller. Read the Vendor ID and - * the Device ID for function 0 of device 0. - * Two times the value 0xffff suggests a system without a (compatible) - * PCI controller. Only controllers with values listed in the table - * pci_intel_ctrl are actually used. - */ - u32_t bus, dev, func; - u16_t vid, did; - int i, r, busind; - char *dstr; - - bus= 0; - dev= 0; - func= 0; - - vid= PCII_RREG16_(bus, dev, func, PCI_VID); - did= PCII_RREG16_(bus, dev, func, PCI_DID); - outl(PCII_CONFADD, PCII_UNSEL); - - if (vid == 0xffff && did == 0xffff) - return; /* Nothing here */ - - for (i= 0; pci_intel_ctrl[i].vid; i++) - { - if (pci_intel_ctrl[i].vid == vid && - pci_intel_ctrl[i].did == did) - { - break; - } - } - - if (!pci_intel_ctrl[i].vid) - { - printf("pci_intel_init: unknown PCI-controller:\n" - "\tvendor %04X (%s), device %04X\n", - vid, pci_vid_name(vid), did); - return; - } - - if (nr_pcibus >= NR_PCIBUS) - server_panic("PCI","too many PCI busses", nr_pcibus); - busind= nr_pcibus; - nr_pcibus++; - pcibus[busind].pb_type= PBT_INTEL; - pcibus[busind].pb_isabridge_dev= -1; - pcibus[busind].pb_isabridge_type= 0; - pcibus[busind].pb_devind= -1; - pcibus[busind].pb_bus= 0; - pcibus[busind].pb_rreg8= pcii_rreg8; - pcibus[busind].pb_rreg16= pcii_rreg16; - pcibus[busind].pb_rreg32= pcii_rreg32; - pcibus[busind].pb_wreg16= pcii_wreg16; - pcibus[busind].pb_wreg32= pcii_wreg32; - pcibus[busind].pb_rsts= pcii_rsts; - pcibus[busind].pb_wsts= pcii_wsts; - - dstr= pci_dev_name(vid, did); - if (!dstr) - dstr= "unknown device"; - if (debug) - { - printf("pci_intel_init: %s (%04X/%04X)\n", - dstr, vid, did); - } - - probe_bus(busind); - - r= do_isabridge(busind); - if (r != OK) - { - /* Disable all devices for this bus */ - for (i= 0; i= NR_PCIDEV) - server_panic("PCI","too many PCI devices", nr_pcidev); - devind= nr_pcidev; - - for (dev= 0; dev<32; dev++) - { - - for (func= 0; func < 8; func++) - { - pcidev[devind].pd_busind= busind; - pcidev[devind].pd_dev= dev; - pcidev[devind].pd_func= func; - - pci_attr_wsts(devind, - PSR_SSE|PSR_RMAS|PSR_RTAS); - vid= pci_attr_r16(devind, PCI_VID); - did= pci_attr_r16(devind, PCI_DID); - headt= pci_attr_r8(devind, PCI_HEADT); - sts= pci_attr_rsts(devind); - if (sts & (PSR_SSE|PSR_RMAS|PSR_RTAS)) - break; - if (vid == NO_VID) - { - /* Some bridge implementations do support - * pci_attr_rsts. - */ - break; - } - - dstr= pci_dev_name(vid, did); - if (debug) - { - if (dstr) - { - printf("%d.%lu.%lu: %s (%04X/%04X)\n", - busind, (unsigned long)dev, - (unsigned long)func, dstr, - vid, did); - } - else - { - printf( - "%d.%lu.%lu: Unknown device, vendor %04X (%s), device %04X\n", - busind, (unsigned long)dev, - (unsigned long)func, vid, - pci_vid_name(vid), did); - } - } - - baseclass= pci_attr_r8(devind, PCI_BCR); - subclass= pci_attr_r8(devind, PCI_SCR); - infclass= pci_attr_r8(devind, PCI_PIFR); - s= pci_subclass_name(baseclass, subclass, infclass); - if (!s) - s= pci_baseclass_name(baseclass); - { - if (!s) - s= "(unknown class)"; - } - if (debug) - { - printf("\tclass %s (%X/%X/%X)\n", s, - baseclass, subclass, infclass); - } - - devind= nr_pcidev; - nr_pcidev++; - pcidev[devind].pd_baseclass= baseclass; - pcidev[devind].pd_subclass= subclass; - pcidev[devind].pd_infclass= infclass; - pcidev[devind].pd_vid= vid; - pcidev[devind].pd_did= did; - pcidev[devind].pd_inuse= 0; - - if (nr_pcidev >= NR_PCIDEV) - server_panic("PCI","too many PCI devices", nr_pcidev); - devind= nr_pcidev; - - if (func == 0 && !(headt & PHT_MULTIFUNC)) - break; - } - } -} - - -/*===========================================================================* - * do_isabridge * - *===========================================================================*/ -PRIVATE int do_isabridge(busind) -int busind; -{ - int unknown_bridge= -1; - int bridge_dev= -1; - int i, j, r, type; - u16_t vid, did; - char *dstr; - - j= 0; /* lint */ - vid= did= 0; /* lint */ - for (i= 0; i< nr_pcidev; i++) - { - if (pcidev[i].pd_busind != busind) - continue; - if (pcidev[i].pd_baseclass == 0x06 && - pcidev[i].pd_subclass == 0x01 && - pcidev[i].pd_infclass == 0x00) - { - /* ISA bridge. Report if no supported bridge is - * found. - */ - unknown_bridge= i; - } - - vid= pcidev[i].pd_vid; - did= pcidev[i].pd_did; - for (j= 0; pci_isabridge[j].vid != 0; j++) - { - if (pci_isabridge[j].vid != vid) - continue; - if (pci_isabridge[j].did != did) - continue; - if (pci_isabridge[j].checkclass && - unknown_bridge != i) - { - /* This part of multifunction device is - * not the bridge. - */ - continue; - } - break; - } - if (pci_isabridge[j].vid) - { - bridge_dev= i; - break; - } - } - - if (bridge_dev != -1) - { - dstr= pci_dev_name(vid, did); - if (!dstr) - dstr= "unknown device"; - if (debug) - { - printf("found ISA bridge (%04X/%04X) %s\n", - vid, did, dstr); - } - pcibus[busind].pb_isabridge_dev= bridge_dev; - type= pci_isabridge[j].type; - pcibus[busind].pb_isabridge_type= type; - switch(type) - { - case PCI_IB_PIIX: - r= do_piix(bridge_dev); - break; - case PCI_IB_VIA: - r= do_via_isabr(bridge_dev); - break; - case PCI_IB_AMD: - r= do_amd_isabr(bridge_dev); - break; - case PCI_IB_SIS: - r= do_sis_isabr(bridge_dev); - break; - default: - server_panic("PCI","unknown ISA bridge type", type); - } - return r; - } - - if (unknown_bridge == -1) - { - printf("do_isabridge: no ISA bridge found for bus %d", busind); - return -1; - } - printf("Unsupported ISA bridge %04X/%04X for bus %d\n", - pcidev[unknown_bridge].pd_vid, - pcidev[unknown_bridge].pd_did, - busind); - return -1; -} - - -/*===========================================================================* - * do_pcibridge * - *===========================================================================*/ -PRIVATE void do_pcibridge(busind) -int busind; -{ - int devind, i; - int ind, type; - u16_t vid, did; - u8_t sbusn; - - vid= did= 0; /* lint */ - for (devind= 0; devind< nr_pcidev; devind++) - { - if (pcidev[devind].pd_busind != busind) - continue; - - vid= pcidev[devind].pd_vid; - did= pcidev[devind].pd_did; - for (i= 0; pci_pcibridge[i].vid != 0; i++) - { - if (pci_pcibridge[i].vid != vid) - continue; - if (pci_pcibridge[i].did != did) - continue; - break; - } - if (pci_pcibridge[i].vid == 0) - continue; - type= pci_pcibridge[i].type; - - if (debug) - printf("PCI-to-PCI bridge: %04X/%04X\n", vid, did); - - /* Assume that the BIOS initialized the secondary bus - * number. - */ - sbusn= pci_attr_r8(devind, PPB_SBUSN); -#if DEBUG - printf("sbusn = %d\n", sbusn); -#endif - - if (nr_pcibus >= NR_PCIBUS) - server_panic("PCI","too many PCI busses", nr_pcibus); - ind= nr_pcibus; - nr_pcibus++; - pcibus[ind].pb_type= PBT_PCIBRIDGE; - pcibus[ind].pb_isabridge_dev= -1; - pcibus[ind].pb_isabridge_type= 0; - pcibus[ind].pb_devind= devind; - pcibus[ind].pb_bus= sbusn; - pcibus[ind].pb_rreg8= pcibus[busind].pb_rreg8; - pcibus[ind].pb_rreg16= pcibus[busind].pb_rreg16; - pcibus[ind].pb_rreg32= pcibus[busind].pb_rreg32; - pcibus[ind].pb_wreg16= pcibus[busind].pb_wreg16; - pcibus[ind].pb_wreg32= pcibus[busind].pb_wreg32; - switch(type) - { - case PCI_AGPB_INTEL: - pcibus[ind].pb_rsts= pcibr_intel_rsts; - pcibus[ind].pb_wsts= pcibr_intel_wsts; - break; - case PCI_AGPB_VIA: - pcibus[ind].pb_rsts= pcibr_via_rsts; - pcibus[ind].pb_wsts= pcibr_via_wsts; - break; - default: - server_panic("PCI","unknown PCI-PCI bridge type", type); - } - - probe_bus(ind); - } -} - - -/*===========================================================================* - * do_piix * - *===========================================================================*/ -PRIVATE int do_piix(devind) -int devind; -{ - int i, dev, func, irqrc, irq; - u16_t elcr1, elcr2, elcr; - -#if DEBUG - printf("in piix\n"); -#endif - dev= pcidev[devind].pd_dev; - func= pcidev[devind].pd_func; - elcr1= inb(PIIX_ELCR1); - elcr2= inb(PIIX_ELCR2); - elcr= elcr1 | (elcr2 << 8); - for (i= 0; i<4; i++) - { - irqrc= pci_attr_r8(devind, PIIX_PIRQRCA+i); - if (irqrc & PIIX_IRQ_DI) - { - if (debug) - printf("INT%c: disabled\n", 'A'+i); - } - else - { - irq= irqrc & PIIX_IRQ_MASK; - if (debug) - printf("INT%c: %d\n", 'A'+i, irq); - if (!(elcr & (1 << irq))) - { - printf("IRQ %d is not level triggered\n", - irq); - server_panic(NULL,NULL, NO_NUM); - } - irq_mode_pci(irq); - } - } - return 0; -} - -/*===========================================================================* - * do_amd_isabr * - *===========================================================================*/ -PRIVATE int do_amd_isabr(devind) -int devind; -{ - int i, bus, dev, func, xdevind, irq, edge; - u8_t levmask; - u16_t pciirq; - - /* Find required function */ - func= AMD_ISABR_FUNC; - bus= pcidev[devind].pd_busind; - dev= pcidev[devind].pd_dev; - - /* Fake a device with the required function */ - if (nr_pcidev >= NR_PCIDEV) - server_panic("PCI","too many PCI devices", nr_pcidev); - xdevind= nr_pcidev; - pcidev[xdevind].pd_busind= bus; - pcidev[xdevind].pd_dev= dev; - pcidev[xdevind].pd_func= func; - pcidev[xdevind].pd_inuse= 1; - nr_pcidev++; - - levmask= pci_attr_r8(xdevind, AMD_ISABR_PCIIRQ_LEV); - pciirq= pci_attr_r16(xdevind, AMD_ISABR_PCIIRQ_ROUTE); - for (i= 0; i<4; i++) - { - edge= (levmask >> i) & 1; - irq= (pciirq >> (4*i)) & 0xf; - if (!irq) - { - if (debug) - printf("INT%c: disabled\n", 'A'+i); - } - else - { - if (debug) - printf("INT%c: %d\n", 'A'+i, irq); - if (edge) - { - printf("IRQ %d is not level triggered\n", - irq); - server_panic(NULL, NULL, NO_NUM); - } - irq_mode_pci(irq); - } - } - nr_pcidev--; - return 0; -} - - -/*===========================================================================* - * do_sis_isabr * - *===========================================================================*/ -PRIVATE int do_sis_isabr(devind) -int devind; -{ - int i, dev, func, irq; - - dev= pcidev[devind].pd_dev; - func= pcidev[devind].pd_func; - irq= 0; /* lint */ - for (i= 0; i<4; i++) - { - irq= pci_attr_r8(devind, SIS_ISABR_IRQ_A+i); - if (irq & SIS_IRQ_DISABLED) - { - if (debug) - printf("INT%c: disabled\n", 'A'+i); - } - else - { - irq &= SIS_IRQ_MASK; - if (debug) - printf("INT%c: %d\n", 'A'+i, irq); - irq_mode_pci(irq); - } - } - return 0; -} - - -/*===========================================================================* - * do_via_isabr * - *===========================================================================*/ -PRIVATE int do_via_isabr(devind) -int devind; -{ - int i, dev, func, irq, edge; - u8_t levmask; - - dev= pcidev[devind].pd_dev; - func= pcidev[devind].pd_func; - levmask= pci_attr_r8(devind, VIA_ISABR_EL); - irq= 0; /* lint */ - edge= 0; /* lint */ - for (i= 0; i<4; i++) - { - switch(i) - { - case 0: - edge= (levmask & VIA_ISABR_EL_INTA); - irq= pci_attr_r8(devind, VIA_ISABR_IRQ_R2) >> 4; - break; - case 1: - edge= (levmask & VIA_ISABR_EL_INTB); - irq= pci_attr_r8(devind, VIA_ISABR_IRQ_R2); - break; - case 2: - edge= (levmask & VIA_ISABR_EL_INTC); - irq= pci_attr_r8(devind, VIA_ISABR_IRQ_R3) >> 4; - break; - case 3: - edge= (levmask & VIA_ISABR_EL_INTD); - irq= pci_attr_r8(devind, VIA_ISABR_IRQ_R1) >> 4; - break; - default: - server_assert(0); - } - irq &= 0xf; - if (!irq) - { - if (debug) - printf("INT%c: disabled\n", 'A'+i); - } - else - { - if (debug) - printf("INT%c: %d\n", 'A'+i, irq); - if (edge) - { - printf("IRQ %d is not level triggered\n", - irq); - server_panic(NULL, NULL, NO_NUM); - } - irq_mode_pci(irq); - } - } - return 0; -} - - -/*===========================================================================* - * pci_vid_name * - *===========================================================================*/ -PRIVATE char *pci_vid_name(vid) -u16_t vid; -{ - int i; - - for (i= 0; pci_vendor_table[i].name; i++) - { - if (pci_vendor_table[i].vid == vid) - return pci_vendor_table[i].name; - } - return "unknown"; -} - -/*===========================================================================* - * pci_baseclass_name * - *===========================================================================*/ -PRIVATE char *pci_baseclass_name(baseclass) -u8_t baseclass; -{ - int i; - - for (i= 0; pci_baseclass_table[i].name; i++) - { - if (pci_baseclass_table[i].baseclass == baseclass) - return pci_baseclass_table[i].name; - } - return NULL; -} - -/*===========================================================================* - * pci_subclass_name * - *===========================================================================*/ -PRIVATE char *pci_subclass_name(baseclass, subclass, infclass) -u8_t baseclass; -u8_t subclass; -u8_t infclass; -{ - int i; - - for (i= 0; pci_subclass_table[i].name; i++) - { - if (pci_subclass_table[i].baseclass != baseclass) - continue; - if (pci_subclass_table[i].subclass != subclass) - continue; - if (pci_subclass_table[i].infclass != infclass && - pci_subclass_table[i].infclass != (u16_t)-1) - { - continue; - } - return pci_subclass_table[i].name; - } - return NULL; -} - -/*===========================================================================* - * ntostr * - *===========================================================================*/ -PRIVATE void ntostr(n, str, end) -unsigned n; -char **str; -char *end; -{ - char tmpstr[20]; - int i; - - if (n == 0) - { - tmpstr[0]= '0'; - i= 1; - } - else - { - for (i= 0; n; i++) - { - tmpstr[i]= '0' + (n%10); - n /= 10; - } - } - for (; i>0; i--) - { - if (*str == end) - { - break; - } - **str= tmpstr[i-1]; - (*str)++; - } - if (*str == end) - end[-1]= '\0'; - else - **str= '\0'; -} - - -/*===========================================================================* - * pci_attr_rsts * - *===========================================================================*/ -PRIVATE u16_t pci_attr_rsts(devind) -int devind; -{ - int busind; - - busind= pcidev[devind].pd_busind; - return pcibus[busind].pb_rsts(busind); -} - - -/*===========================================================================* - * pcibr_intel_rsts * - *===========================================================================*/ -PRIVATE u16_t pcibr_intel_rsts(busind) -int busind; -{ - int devind; - devind= pcibus[busind].pb_devind; - - return pci_attr_r16(devind, PPB_SSTS); -} - - -/*===========================================================================* - * pcibr_intel_wsts * - *===========================================================================*/ -PRIVATE void pcibr_intel_wsts(busind, value) -int busind; -u16_t value; -{ - int devind; - devind= pcibus[busind].pb_devind; - -#if 0 - printf("pcibr_intel_wsts(%d, 0x%X), devind= %d\n", - busind, value, devind); -#endif - pci_attr_w16(devind, PPB_SSTS, value); -} - - -/*===========================================================================* - * pcibr_via_rsts * - *===========================================================================*/ -PRIVATE u16_t pcibr_via_rsts(busind) -int busind; -{ - int devind; - devind= pcibus[busind].pb_devind; - - return 0; -} - - -/*===========================================================================* - * pcibr_via_wsts * - *===========================================================================*/ -PRIVATE void pcibr_via_wsts(busind, value) -int busind; -u16_t value; -{ - int devind; - devind= pcibus[busind].pb_devind; - -#if 0 - printf("pcibr_via_wsts(%d, 0x%X), devind= %d (not implemented)\n", - busind, value, devind); -#endif -} - - -/*===========================================================================* - * pci_attr_wsts * - *===========================================================================*/ -PRIVATE void pci_attr_wsts(devind, value) -int devind; -u16_t value; -{ - int busind; - - busind= pcidev[devind].pd_busind; - pcibus[busind].pb_wsts(busind, value); -} - - -/*===========================================================================* - * pcii_rreg8 * - *===========================================================================*/ -PRIVATE u8_t pcii_rreg8(busind, devind, port) -int busind; -int devind; -int port; -{ - u8_t v; - - - v= PCII_RREG8_(pcibus[busind].pb_bus, - pcidev[devind].pd_dev, pcidev[devind].pd_func, - port); - outl(PCII_CONFADD, PCII_UNSEL); -#if 0 - printf("pcii_rreg8(%d, %d, 0x%X): %d.%d.%d= 0x%X\n", - busind, devind, port, - pcibus[busind].pb_bus, pcidev[devind].pd_dev, - pcidev[devind].pd_func, v); -#endif - return v; -} - - -/*===========================================================================* - * pcii_rreg16 * - *===========================================================================*/ -PRIVATE u16_t pcii_rreg16(busind, devind, port) -int busind; -int devind; -int port; -{ - u16_t v; - - v= PCII_RREG16_(pcibus[busind].pb_bus, - pcidev[devind].pd_dev, pcidev[devind].pd_func, - port); - outl(PCII_CONFADD, PCII_UNSEL); -#if 0 - printf("pcii_rreg16(%d, %d, 0x%X): %d.%d.%d= 0x%X\n", - busind, devind, port, - pcibus[busind].pb_bus, pcidev[devind].pd_dev, - pcidev[devind].pd_func, v); -#endif - return v; -} - - -/*===========================================================================* - * pcii_rreg32 * - *===========================================================================*/ -PRIVATE u32_t pcii_rreg32(busind, devind, port) -int busind; -int devind; -int port; -{ - u32_t v; - - v= PCII_RREG32_(pcibus[busind].pb_bus, - pcidev[devind].pd_dev, pcidev[devind].pd_func, - port); - outl(PCII_CONFADD, PCII_UNSEL); -#if 0 - printf("pcii_rreg32(%d, %d, 0x%X): %d.%d.%d= 0x%X\n", - busind, devind, port, - pcibus[busind].pb_bus, pcidev[devind].pd_dev, - pcidev[devind].pd_func, v); -#endif - return v; -} - - -/*===========================================================================* - * pcii_wreg16 * - *===========================================================================*/ -PRIVATE void pcii_wreg16(busind, devind, port, value) -int busind; -int devind; -int port; -u16_t value; -{ -#if 0 - printf("pcii_wreg16(%d, %d, 0x%X, 0x%X): %d.%d.%d\n", - busind, devind, port, value, - pcibus[busind].pb_bus, pcidev[devind].pd_dev, - pcidev[devind].pd_func); -#endif - PCII_WREG16_(pcibus[busind].pb_bus, - pcidev[devind].pd_dev, pcidev[devind].pd_func, - port, value); - outl(PCII_CONFADD, PCII_UNSEL); -} - - -/*===========================================================================* - * pcii_wreg32 * - *===========================================================================*/ -PRIVATE void pcii_wreg32(busind, devind, port, value) -int busind; -int devind; -int port; -u32_t value; -{ -#if 0 - printf("pcii_wreg32(%d, %d, 0x%X, 0x%X): %d.%d.%d\n", - busind, devind, port, value, - pcibus[busind].pb_bus, pcidev[devind].pd_dev, - pcidev[devind].pd_func); -#endif - PCII_WREG32_(pcibus[busind].pb_bus, - pcidev[devind].pd_dev, pcidev[devind].pd_func, - port, value); - outl(PCII_CONFADD, PCII_UNSEL); -} - - -/*===========================================================================* - * pcii_rsts * - *===========================================================================*/ -PRIVATE u16_t pcii_rsts(busind) -int busind; -{ - u16_t v; - v= PCII_RREG16_(pcibus[busind].pb_bus, 0, 0, PCI_PCISTS); - outl(PCII_CONFADD, PCII_UNSEL); - return v; -} - - -/*===========================================================================* - * pcii_wsts * - *===========================================================================*/ -PRIVATE void pcii_wsts(busind, value) -int busind; -u16_t value; -{ - PCII_WREG16_(pcibus[busind].pb_bus, 0, 0, PCI_PCISTS, value); - outl(PCII_CONFADD, PCII_UNSEL); -} -#endif /* ENABLE_PCI */ - -/* - * $PchId: pci.c,v 1.7 2003/08/07 09:06:51 philip Exp $ - */ diff --git a/kernel/pci.h b/kernel/pci.h deleted file mode 100755 index 16865d949..000000000 --- a/kernel/pci.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -pci.h - -Created: Jan 2000 by Philip Homburg -*/ - -#define PCI_VID 0x00 /* Vendor ID, 16-bit */ -#define PCI_DID 0x02 /* Device ID, 16-bit */ -#define PCI_CR 0x04 /* Command Register, 16-bit */ -#define PCI_PCISTS 0x06 /* PCI status, 16-bit */ -#define PSR_SSE 0x4000 /* Signaled System Error */ -#define PSR_RMAS 0x2000 /* Received Master Abort Status */ -#define PSR_RTAS 0x1000 /* Received Target Abort Status */ -#define PCI_PIFR 0x09 /* Prog. Interface Register */ -#define PCI_SCR 0x0A /* Sub-Class Register */ -#define PCI_BCR 0x0B /* Base-Class Register */ -#define PCI_HEADT 0x0E /* Header type, 8-bit */ -#define PHT_MULTIFUNC 0x80 /* Multiple functions */ -#define PCI_BAR 0x10 /* Base Address Register */ -#define PCI_ILR 0x3C /* Interrupt Line Register */ -#define PCI_IPR 0x3D /* Interrupt Pin Register */ - -/* PCI bridge devices (AGP) */ -#define PPB_SBUSN 0x19 /* Secondary Bus Number */ - -/* Intel compatible PCI bridge devices (AGP) */ -#define PPB_SSTS 0x1E /* Secondary PCI-to-PCI Status Register */ - -#define NO_VID 0xffff /* No PCI card present */ - -struct pci_vendor -{ - u16_t vid; - char *name; -}; - -struct pci_device -{ - u16_t vid; - u16_t did; - char *name; -}; - -struct pci_baseclass -{ - u8_t baseclass; - char *name; -}; - -struct pci_subclass -{ - u8_t baseclass; - u8_t subclass; - u16_t infclass; - char *name; -}; - -struct pci_intel_ctrl -{ - u16_t vid; - u16_t did; -}; - -struct pci_isabridge -{ - u16_t vid; - u16_t did; - int checkclass; - int type; -}; - -struct pci_pcibridge -{ - u16_t vid; - u16_t did; - int type; -}; - -#define PCI_IB_PIIX 1 /* Intel PIIX compatible ISA bridge */ -#define PCI_IB_VIA 2 /* VIA compatible ISA bridge */ -#define PCI_IB_AMD 3 /* AMD compatible ISA bridge */ -#define PCI_IB_SIS 4 /* SIS compatible ISA bridge */ - -#define PCI_AGPB_INTEL 1 /* Intel compatible AGP bridge */ -#define PCI_AGPB_VIA 2 /* VIA compatible AGP bridge */ - -extern struct pci_vendor pci_vendor_table[]; -extern struct pci_device pci_device_table[]; -extern struct pci_baseclass pci_baseclass_table[]; -extern struct pci_subclass pci_subclass_table[]; -extern struct pci_intel_ctrl pci_intel_ctrl[]; -extern struct pci_isabridge pci_isabridge[]; -extern struct pci_pcibridge pci_pcibridge[]; - -/* - * $PchId: pci.h,v 1.4 2001/12/06 20:21:22 philip Exp $ - */ diff --git a/kernel/pci_amd.h b/kernel/pci_amd.h deleted file mode 100755 index 2d709d2f3..000000000 --- a/kernel/pci_amd.h +++ /dev/null @@ -1,21 +0,0 @@ -/* -pci_amd.h - -Created: Nov 2001 by Philip Homburg -*/ - -#define AMD_ISABR_FUNC 3 /* Registers are in function 3 */ -#define AMD_ISABR_PCIIRQ_LEV 0x54 -#define AMD_PCILEV_INTA 0x1 -#define AMD_PCILEV_INTB 0x2 -#define AMD_PCILEV_INTC 4x2 -#define AMD_PCILEV_INTD 4x8 -#define AMD_ISABR_PCIIRQ_ROUTE 0x56 -#define AMD_PCIIRQ_INTA_MASK 0x000F -#define AMD_PCIIRQ_INTB_MASK 0x00F0 -#define AMD_PCIIRQ_INTC_MASK 0x0F00 -#define AMD_PCIIRQ_INTD_MASK 0xF000 - -/* - * $PchId: pci_amd.h,v 1.1 2001/11/09 19:57:37 philip Exp $ - */ diff --git a/kernel/pci_intel.h b/kernel/pci_intel.h deleted file mode 100755 index 50c59f0ee..000000000 --- a/kernel/pci_intel.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -pci_intel.h - -Created: Jan 2000 by Philip Homburg -*/ - -#define PCII_CONFADD 0xCF8 -#define PCIIC_CODE 0x80000000 -#define PCIIC_BUSNUM_MASK 0xff0000 -#define PCIIC_BUSNUM_SHIFT 16 -#define PCIIC_DEVNUM_MASK 0xf800 -#define PCIIC_DEVNUM_SHIFT 11 -#define PCIIC_FUNCNUM_MASK 0x700 -#define PCIIC_FUNCNUM_SHIFT 8 -#define PCIIC_REGNUM_MASK 0xfc -#define PCIIC_REGNUM_SHIFT 2 -#define PCII_CONFDATA 0xCFC - -#define PCII_SELREG_(bus, dev, func, reg) \ - (PCIIC_CODE | \ - (((bus) << PCIIC_BUSNUM_SHIFT) & PCIIC_BUSNUM_MASK) | \ - (((dev) << PCIIC_DEVNUM_SHIFT) & PCIIC_DEVNUM_MASK) | \ - (((func) << PCIIC_FUNCNUM_SHIFT) & PCIIC_FUNCNUM_MASK) | \ - ((((reg)/4) << PCIIC_REGNUM_SHIFT) & PCIIC_REGNUM_MASK)) -#define PCII_UNSEL (0) - -#define PCII_RREG8_(bus, dev, func, reg) \ - (outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \ - inb(PCII_CONFDATA+((reg)&3))) -#define PCII_RREG16_(bus, dev, func, reg) \ - (PCII_RREG8_(bus, dev, func, reg) | \ - (PCII_RREG8_(bus, dev, func, reg+1) << 8)) -#define PCII_RREG32_(bus, dev, func, reg) \ - (PCII_RREG16_(bus, dev, func, reg) | \ - (PCII_RREG16_(bus, dev, func, reg+2) << 16)) - -#define PCII_WREG8_(bus, dev, func, reg, val) \ - (outl(PCII_CONFADD, PCII_SELREG_(bus, dev, func, reg)), \ - outb(PCII_CONFDATA+((reg)&3), (val))) -#define PCII_WREG16_(bus, dev, func, reg, val) \ - (PCII_WREG8_(bus, dev, func, reg, (val)), \ - (PCII_WREG8_(bus, dev, func, reg+1, (val) >> 8))) -#define PCII_WREG32_(bus, dev, func, reg, val) \ - (PCII_WREG16_(bus, dev, func, reg, (val)), \ - (PCII_WREG16_(bus, dev, func, reg+2, (val) >> 16))) - -/* PIIX configuration registers */ -#define PIIX_PIRQRCA 0x60 -#define PIIX_IRQ_DI 0x80 -#define PIIX_IRQ_MASK 0x0F - -/* PIIX extensions to the PIC */ -#define PIIX_ELCR1 0x4D0 -#define PIIX_ELCR2 0x4D1 - -/* - * $PchId: pci_intel.h,v 1.1 2000/08/12 11:20:17 philip Exp $ - */ diff --git a/kernel/pci_sis.h b/kernel/pci_sis.h deleted file mode 100755 index 252300952..000000000 --- a/kernel/pci_sis.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -pci_sis.h - -Created: Nov 2001 by Philip Homburg -*/ - -/* Constants are taken from pci-irq.c in the Linux kernel source */ -#define SIS_ISABR_IRQ_A 0x41 /* IRQA routing */ -#define SIS_ISABR_IRQ_B 0x42 /* IRQB routing */ -#define SIS_ISABR_IRQ_C 0x43 /* IRQC routing */ -#define SIS_ISABR_IRQ_D 0x44 /* IRQD routing */ -#define SIS_IRQ_DISABLED 0x80 -#define SIS_IRQ_MASK 0x0F - -/* - * $PchId: pci_sis.h,v 1.1 2001/12/06 20:22:52 philip Exp $ - */ diff --git a/kernel/pci_table.c b/kernel/pci_table.c deleted file mode 100755 index deaac96eb..000000000 --- a/kernel/pci_table.c +++ /dev/null @@ -1,251 +0,0 @@ -/* -pci_table.c - -Tables with PCI vendor and device identifiers - -Created: Jan 2000 by Philip Homburg - -See the Linux PCI ID Repository . -*/ - -/* Changes from original Minix 2.0.4 version (2003-09-05): - * 2003-11-30 (kjb) Minix 2.0.4 FIX.TAZ add D-Link RTL8139 (0x1186, 0x1300) - * 2004-08-08 (asw) add Intel 82371AB (0x8086, 0x7100) - */ - -#include "kernel.h" -#include "pci.h" -#if __minix_vmd -#include "config.h" -#endif - -#if ENABLE_PCI - -struct pci_vendor pci_vendor_table[]= -{ - { 0x1000, "NCR" }, - { 0x1002, "ATI Technologies" }, - { 0x100B, "National Semiconductor Corporation" }, - { 0x1013, "Cirrus Logic" }, - { 0x1022, "Advanced Micro Devices" }, - { 0x102B, "Matrox Graphics, Inc." }, - { 0x1039, "Silicon Integrated Systems (SiS)" }, - { 0x104C, "Texas Instruments" }, - { 0x105A, "Promise Technology" }, - { 0x10B7, "3Com Corporation" }, - { 0x10B9, "AcerLabs (ALI)" }, - { 0x10DE, "nVidia Corporation" }, - { 0x10EC, "Realtek" }, - { 0x1106, "VIA" }, - { 0x110A, "Siemens Nixdorf AG" }, - { 0x125D, "ESS Technology" }, - { 0x1274, "Ensoniq" }, - { 0x5333, "S3" }, - { 0x8086, "Intel" }, - { 0x9004, "Adaptec" }, - { 0x9005, "Adaptec" }, - { 0x0000, NULL } -}; - -struct pci_device pci_device_table[]= -{ - { 0x1000, 0x0001, "NCR 53C810" }, - { 0x1000, 0x000F, "NCR 53C875" }, - { 0x1002, 0x4752, "ATI Rage XL PCI" }, - { 0x100B, 0xD001, "Nat. Semi. 87410" }, - { 0x1013, 0x00B8, "Cirrus Logic GD 5446" }, - { 0x1013, 0x6003, "Cirrus Logic CS4614/22/24 CrystalClear" }, - { 0x1022, 0x700C, "AMD-762 CPU to PCI Bridge (SMP chipset)" }, - { 0x1022, 0x700D, "AMD-762 CPU to PCI Bridge (AGP 4x)" }, - { 0x1022, 0x7410, "AMD-766 PCI to ISA/LPC Bridge" }, - { 0x1022, 0x7411, "AMD-766 EIDE Controller" }, - { 0x102B, 0x051B, "Matrox MGA 2164W [Millennium II]" }, - { 0x102B, 0x0525, "Matrox MGA G400 AGP" }, - { 0x1039, 0x0008, "SiS 85C503/5513" }, - { 0x1039, 0x0200, "SiS 5597/5598 VGA" }, - { 0x1039, 0x0406, "SiS 85C501/2" }, - { 0x1039, 0x5597, "SiS 5582" }, - { 0x104C, 0xAC1C, "TI PCI1225" }, - { 0x105A, 0x0D30, "Promise Technology 20265" }, - { 0x10B7, 0x9058, "3Com 3c905B-Combo" }, - { 0x10B7, 0x9805, "3Com 3c980-TX Python-T" }, - { 0x10B9, 0x1533, "ALI M1533 ISA-bridge [Aladdin IV]" }, - { 0x10B9, 0x1541, "ALI M1541" }, - { 0x10B9, 0x5229, "ALI M5229 (IDE)" }, - { 0x10B9, 0x5243, "ALI M5243" }, - { 0x10B9, 0x7101, "ALI M7101 PMU" }, - { 0x10DE, 0x0020, "nVidia Riva TnT [NV04]" }, - { 0x10DE, 0x0110, "nVidia GeForce2 MX [NV11]" }, - { 0x10EC, 0x8029, "Realtek RTL8029" }, - { 0x10EC, 0x8139, "Realtek RTL8139" }, - { 0x1106, 0x0305, "VIA VT8363/8365 [KT133/KM133]" }, - { 0x1106, 0x0571, "VIA IDE controller" }, - { 0x1106, 0x0686, "VIA VT82C686 (Apollo South Bridge)" }, - { 0x1106, 0x3038, "VT83C572 PCI USB Controller" }, - { 0x1106, 0x3057, "VT82C686A ACPI Power Management Controller" }, - { 0x1106, 0x3058, "VIA AC97 Audio Controller" }, - { 0x1106, 0x3059, "VIA AC97 Audio Controller" }, - { 0x1106, 0x3074, "VIA VT8233" }, - { 0x1106, 0x3099, "VIA VT8367 [KT266]" }, - { 0x1106, 0x8305, "VIA VT8365 [KM133 AGP]" }, - { 0x1106, 0xB099, "VIA VT8367 [KT266 AGP]" }, - { 0x110A, 0x0005, "Siemens Nixdorf Tulip Cntlr., Power Management" }, - { 0x1186, 0x1300, "D-Link RTL8139" }, - { 0x125D, 0x1969, "ESS ES1969 Solo-1 Audiodrive" }, - { 0x1274, 0x1371, "Ensoniq ES1371 [AudioPCI-97]" }, - { 0x1274, 0x5000, "Ensoniq ES1370" }, - { 0x1274, 0x5880, "Ensoniq CT5880 [AudioPCI]" }, - { 0x5333, 0x8811, "S3 86c764/765 [Trio32/64/64V+]" }, - { 0x5333, 0x883d, "S3 Virge/VX" }, - { 0x5333, 0x88d0, "S3 Vision 964 vers 0" }, - { 0x5333, 0x8a01, "S3 Virge/DX or /GX" }, - { 0x8086, 0x1004, "Intel 82543GC Gigabit Ethernet Controller" }, - { 0x8086, 0x1229, "Intel 82557" }, - { 0x8086, 0x122D, "Intel 82437FX" }, - { 0x8086, 0x122E, "Intel 82371FB (PIIX)" }, - { 0x8086, 0x1230, "Intel 82371FB (IDE)" }, - { 0x8086, 0x1237, "Intel 82441FX (440FX)" }, - { 0x8086, 0x1250, "Intel 82439HX" }, - { 0x8086, 0x7000, "Intel 82371SB" }, - { 0x8086, 0x7010, "Intel 82371SB (IDE)" }, - { 0x8086, 0x7020, "Intel 82371SB (USB)" }, - { 0x8086, 0x7100, "Intel 82371AB" }, - { 0x8086, 0x7110, "Intel 82371AB (PIIX4)" }, - { 0x8086, 0x7111, "Intel 82371AB (IDE)" }, - { 0x8086, 0x7112, "Intel 82371AB (USB)" }, - { 0x8086, 0x7113, "Intel 82371AB (Power)" }, - { 0x8086, 0x7190, "Intel 82443BX" }, - { 0x8086, 0x7191, "Intel 82443BX (AGP bridge)" }, - { 0x9004, 0x8178, "Adaptec AHA-2940U/2940UW Ultra/Ultra-Wide SCSI Ctrlr" }, - { 0x9005, 0x0080, "Adaptec AIC-7892A Ultra160/m PCI SCSI Controller" }, - { 0x0000, 0x0000, NULL } -}; - -struct pci_baseclass pci_baseclass_table[]= -{ - { 0x00, "No device class" }, - { 0x01, "Mass storage controller" }, - { 0x02, "Network controller" }, - { 0x03, "Display controller" }, - { 0x04, "Multimedia device" }, - { 0x05, "Memory controller" }, - { 0x06, "Bridge device" }, - { 0x07, "Simple comm. controller" }, - { 0x08, "Base system peripheral" }, - { 0x09, "Input device" }, - { 0x0A, "Docking station" }, - { 0x0B, "Processor" }, - { 0x0C, "Serial bus controller" }, - { 0x0d, "Wireless controller" }, - { 0x0e, "Intelligent I/O controller" }, - { 0x0f, "Satellite comm. controller" }, - { 0x10, "Encryption/decryption controller" }, - { 0x11, "Data acquisition controller" }, - { 0xff, "Misc. device" }, - - { 0x00, NULL } -}; - -/* -1 in the infclass field is a wildcard for infclass */ -struct pci_subclass pci_subclass_table[]= -{ - { 0x00, 0x01, 0x00, "VGA-compatible device" }, - - { 0x01, 0x00, 0x00, "SCSI bus controller" }, - { 0x01, 0x01, -1, "IDE controller" }, - { 0x01, 0x02, 0x00, "Floppy disk controller" }, - { 0x01, 0x03, 0x00, "IPI controller" }, - { 0x01, 0x04, 0x00, "RAID controller" }, - { 0x01, 0x80, 0x00, "Other mass storage controller" }, - - { 0x02, 0x00, 0x00, "Ethernet controller" }, - { 0x02, 0x01, 0x00, "Token Ring controller" }, - { 0x02, 0x02, 0x00, "FDDI controller" }, - { 0x02, 0x03, 0x00, "ATM controller" }, - { 0x02, 0x04, 0x00, "ISDN controller" }, - { 0x02, 0x80, 0x00, "Other network controller" }, - - { 0x03, 0x00, 0x00, "VGA-compatible controller" }, - { 0x03, 0x00, 0x01, "8514-compatible controller" }, - { 0x03, 0x01, 0x00, "XGA controller" }, - { 0x03, 0x02, 0x00, "3D controller" }, - { 0x03, 0x80, 0x00, "Other display controller" }, - - { 0x04, 0x00, 0x00, "Video device" }, - { 0x04, 0x01, 0x00, "Audio device" }, - { 0x04, 0x02, 0x00, "Computer telephony device" }, - { 0x04, 0x80, 0x00, "Other multimedia device" }, - - { 0x06, 0x00, 0x00, "Host bridge" }, - { 0x06, 0x01, 0x00, "ISA bridge" }, - { 0x06, 0x02, 0x00, "EISA bridge" }, - { 0x06, 0x03, 0x00, "MCA bridge" }, - { 0x06, 0x04, 0x00, "PCI-to-PCI bridge" }, - { 0x06, 0x04, 0x01, "Subtractive decode PCI-to-PCI bridge" }, - { 0x06, 0x05, 0x00, "PCMCIA bridge" }, - { 0x06, 0x06, 0x00, "NuBus bridge" }, - { 0x06, 0x07, 0x00, "CardBus bridge" }, - { 0x06, 0x08, -1, "RACEway bridge" }, - { 0x06, 0x09, -1, "Semi-transparent PCI-to-PCI bridge" }, - { 0x06, 0x80, 0x00, "Other bridge device" }, - - { 0x0C, 0x00, 0x00, "IEEE 1394 (FireWire)" }, - { 0x0C, 0x00, 0x10, "IEEE 1394 (OpenHCI)" }, - { 0x0C, 0x01, 0x00, "ACCESS bus" }, - { 0x0C, 0x02, 0x00, "SSA" }, - { 0x0C, 0x03, 0x00, "USB (with UHC)" }, - { 0x0C, 0x03, 0x10, "USB (with OHC)" }, - { 0x0C, 0x03, 0x80, "USB (other host inf.)" }, - { 0x0C, 0x03, 0xFE, "USB device" }, - { 0x0C, 0x04, 0x00, "Fibre Channel" }, - { 0x0C, 0x05, 0x00, "SMBus" }, - - { 0x00, 0x00, 0x00, NULL } -}; - -struct pci_intel_ctrl pci_intel_ctrl[]= -{ - { 0x1022, 0x700C, }, /* AMD-762 */ - { 0x1039, 0x0406, }, /* SiS 85C501/2 */ - { 0x1039, 0x5597, }, /* SiS 5582 */ - { 0x10B9, 0x1541, }, /* ALI M1541 */ - { 0x1106, 0x0305, }, /* VIA VT8363/8365 */ - { 0x1106, 0x3099, }, /* VIA VT8367 [KT266] */ - { 0x1106, 0x3188, }, /* VIA */ - { 0x1106, 0x0204, }, /* VIA VT8367 [KT266] */ - { 0x8086, 0x122D, }, /* Intel 82437FX */ - { 0x8086, 0x1237, }, /* Intel 82441FX */ - { 0x8086, 0x1250, }, /* Intel 82439HX */ - { 0x8086, 0x7100, }, /* Intel 82371AB */ - { 0x8086, 0x7190, }, /* Intel 82443BX */ - { 0x0000, 0x0000, }, -}; - -struct pci_isabridge pci_isabridge[]= -{ - { 0x1022, 0x7410, 1, PCI_IB_AMD, }, /* AMD-766 */ - { 0x1039, 0x0008, 1, PCI_IB_SIS, }, /* SiS 85C503/5513 */ - { 0x10B9, 0x1533, 1, PCI_IB_PIIX, }, /* ALI M1533 */ - { 0x1106, 0x0686, 1, PCI_IB_VIA, }, /* VIA VT82C686 */ - { 0x1106, 0x3074, 1, PCI_IB_VIA, }, /* VIA VT8233 */ - { 0x1106, 0x3227, 1, PCI_IB_VIA, }, /* VIA */ - { 0x8086, 0x122E, 1, PCI_IB_PIIX, }, /* Intel 82371FB */ - { 0x8086, 0x7000, 1, PCI_IB_PIIX, }, /* Intel 82371SB */ - { 0x8086, 0x7100, 1, PCI_IB_PIIX, }, /* Intel 82371AB */ - { 0x8086, 0x7110, 1, PCI_IB_PIIX, }, /* Intel PIIX4 */ - { 0x0000, 0x0000, 0, 0, }, -}; - -struct pci_pcibridge pci_pcibridge[]= -{ - { 0x8086, 0x7191, PCI_AGPB_INTEL, }, /* Intel 82443BX (AGP bridge) */ - { 0x1022, 0x700D, PCI_AGPB_INTEL, }, /* AMD-762 (AGP 4x) */ - { 0x10B9, 0x5243, PCI_AGPB_INTEL, }, /* ALI M5243 */ - { 0x1106, 0x8305, PCI_AGPB_VIA, }, /* VIA VT8365 [KM133 AGP] */ - { 0x0000, 0x0000, 0, }, -}; -#endif /* ENABLE_PCI */ - -/* - * $PchId: pci_table.c,v 1.7 2003/09/05 10:53:22 philip Exp $ - */ diff --git a/kernel/pci_via.h b/kernel/pci_via.h deleted file mode 100755 index 3d2fee378..000000000 --- a/kernel/pci_via.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -pci_via.h - -Created: Jun 2001 by Philip Homburg -*/ - -#define VIA_ISABR_EL 0x54 /* Edge or level triggered */ -#define VIA_ISABR_EL_INTA 0x08 /* Edge (1) or level (0) */ -#define VIA_ISABR_EL_INTB 0x04 -#define VIA_ISABR_EL_INTC 0x02 -#define VIA_ISABR_EL_INTD 0x01 - -#define VIA_ISABR_IRQ_R1 0x55 /* IRQ routing 1 */ -#define VIA_ISABR_IRQ_INTD 0xf0 /* routing for INTD */ -#define VIA_ISABR_IRQ_INT0 0x0f /* routing for INT0 */ -#define VIA_ISABR_IRQ_R2 0x56 /* IRQ routing 2 */ -#define VIA_ISABR_IRQ_INTA 0xf0 /* routing for INTA */ -#define VIA_ISABR_IRQ_INTB 0x0f /* routing for INTB */ -#define VIA_ISABR_IRQ_R3 0x57 /* IRQ routing 3 */ -#define VIA_ISABR_IRQ_INTC 0xf0 /* routing for INTC */ -#define VIA_ISABR_IRQ_INT1 0x0f /* routing for INT1 */ -#define VIA_ISABR_IRQ_R4 0x58 /* IRQ routing 4 */ -#define VIA_ISABR_IRQ_INT2 0x0f /* routing for INT2 */ - -/* - * $PchId: pci_via.h,v 1.1 2001/06/20 15:50:25 philip Exp $ - */ diff --git a/kernel/proto.h b/kernel/proto.h index 626370912..ceb6b6a20 100755 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -4,9 +4,6 @@ #define PROTO_H /* Struct declarations. */ -#if TEMP_CODE -struct dpeth; -#endif struct proc; struct time_info; struct timer; @@ -46,32 +43,6 @@ _PROTOTYPE( void stop_sequence, (struct timer *tp) ); /* misc.c */ _PROTOTYPE( void panic, (_CONST char *s, int n) ); -#if TEMP_CODE -#if ENABLE_PCI -/* pci.c */ -_PROTOTYPE( void pci_init, (void) ); -_PROTOTYPE( int pci_find_dev, (U8_t bus, U8_t dev, U8_t func, - int *devindp) ); -_PROTOTYPE( int pci_first_dev, (int *devindp, u16_t *vidp, u16_t *didp) ); -_PROTOTYPE( int pci_next_dev, (int *devindp, u16_t *vidp, u16_t *didp) ); -_PROTOTYPE( void pci_reserve, (int devind) ); -_PROTOTYPE( void pci_ids, (int devind, u16_t *vidp, u16_t *didp) ); -_PROTOTYPE( char *pci_slot_name, (int devind) ); -_PROTOTYPE( char *pci_dev_name, (U16_t vid, U16_t did) ); -_PROTOTYPE( u8_t pci_attr_r8, (int devind, int port) ); -_PROTOTYPE( u16_t pci_attr_r16, (int devind, int port) ); -_PROTOTYPE( u32_t pci_attr_r32, (int devind, int port) ); -_PROTOTYPE( void pci_attr_w16, (int devind, int port, U16_t value) ); -_PROTOTYPE( void pci_attr_w32, (int devind, int port, u32_t value) ); - -/* rtl8029.c */ -_PROTOTYPE( int rtl_probe, (struct dpeth *dep) ); -#endif /* ENABLE_PCI */ -/* rtl8139.c */ -_PROTOTYPE( void rtl8139_task, (void) ); -#endif /* TEMP_CODE */ - - /* proc.c */ _PROTOTYPE( int sys_call, (int function, int src_dest, message *m_ptr) ); _PROTOTYPE( void notify, (int proc_nr, int notify_type) ); @@ -102,9 +73,6 @@ _PROTOTYPE( phys_bytes umap_bios, (struct proc *rp, vir_bytes vir_addr, vir_bytes bytes) ); _PROTOTYPE( int generic_handler, (irq_hook_t *hook) ); -/* table.c */ -_PROTOTYPE( void mapdrivers, (void) ); - #if (CHIP == INTEL) /* exception.c */ @@ -124,10 +92,10 @@ _PROTOTYPE( int disable_irq, (irq_hook_t *hook) ); _PROTOTYPE( u16_t mem_rdw, (U16_t segm, vir_bytes offset) ); _PROTOTYPE( void phys_copy, (phys_bytes source, phys_bytes dest, phys_bytes count) ); -_PROTOTYPE( void phys_insb, (Port_t port, phys_bytes buf, size_t count) ); -_PROTOTYPE( void phys_insw, (Port_t port, phys_bytes buf, size_t count) ); -_PROTOTYPE( void phys_outsb, (Port_t port, phys_bytes buf, size_t count)); -_PROTOTYPE( void phys_outsw, (Port_t port, phys_bytes buf, size_t count)); +_PROTOTYPE( void phys_insb, (U16_t port, phys_bytes buf, size_t count) ); +_PROTOTYPE( void phys_insw, (U16_t port, phys_bytes buf, size_t count) ); +_PROTOTYPE( void phys_outsb, (U16_t port, phys_bytes buf, size_t count)); +_PROTOTYPE( void phys_outsw, (U16_t port, phys_bytes buf, size_t count)); _PROTOTYPE( void reset, (void) ); _PROTOTYPE( void level0, (void (*func)(void)) ); _PROTOTYPE( void monitor, (void) ); diff --git a/kernel/sendmask.h b/kernel/sendmask.h index 2730a6a27..137e0b6cb 100644 --- a/kernel/sendmask.h +++ b/kernel/sendmask.h @@ -54,11 +54,7 @@ allow_all_mask #define RTL8139_SENDMASK \ - deny_all_mask \ - allow(1, USER_PROC_NR) /* inet server starts as user process */ \ - allow(1, TTY) /* need to register function key */ \ - allow(1, SYSTASK) /* need system functionality */ \ - allow(1, CLOCK) /* need clock functionality */ + allow_all_mask #define IDLE_SENDMASK \ deny_all_mask diff --git a/kernel/system/sysctl.c b/kernel/system/sysctl.c index b633e858f..158befdc7 100644 --- a/kernel/system/sysctl.c +++ b/kernel/system/sysctl.c @@ -99,7 +99,7 @@ message *m_ptr; /* pointer to request message */ case SYSSENDMASK: { rp->p_type = P_SERVER; rp->p_sendmask = ALLOW_ALL_MASK; - send_mask_allow(proc_addr(RTL8139)->p_sendmask, proc_nr); + send_mask_allow(proc_addr(USR8139)->p_sendmask, proc_nr); send_mask_allow(proc_addr(PM_PROC_NR)->p_sendmask, proc_nr); send_mask_allow(proc_addr(FS_PROC_NR)->p_sendmask, proc_nr); send_mask_allow(proc_addr(IS_PROC_NR)->p_sendmask, proc_nr); diff --git a/kernel/table.c b/kernel/table.c index b7e886e65..1233f86da 100755 --- a/kernel/table.c +++ b/kernel/table.c @@ -47,11 +47,9 @@ #define HARDWARE_STACK NO_STACK /* dummy task, uses kernel stack */ #define SYS_STACK SMALL_STACK #define CLOCK_STACK SMALL_STACK -#define RTL8139_STACK (2 * SMALL_STACK * ENABLE_RTL8139) /* Stack space for all the task stacks. Declared as (char *) to align it. */ -#define TOT_STACK_SPACE (IDLE_STACK + HARDWARE_STACK + CLOCK_STACK + SYS_STACK \ - + RTL8139_STACK ) +#define TOT_STACK_SPACE (IDLE_STACK+HARDWARE_STACK+CLOCK_STACK+SYS_STACK ) PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)]; @@ -63,9 +61,6 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)]; * routine and stack size is also provided. */ PUBLIC struct system_image image[] = { -#if ENABLE_RTL8139 - { RTL8139, rtl8139_task, P_TASK, PPRI_TASK, RTL8139_STACK, RTL8139_SENDMASK, "RTL8139" }, -#endif { IDLE, idle_task, P_IDLE, PPRI_IDLE, IDLE_STACK, IDLE_SENDMASK, "IDLE" }, { CLOCK, clock_task, P_TASK, PPRI_TASK, CLOCK_STACK, CLOCK_SENDMASK, "CLOCK" }, { SYSTASK, sys_task, P_TASK, PPRI_TASK, SYS_STACK, SYSTEM_SENDMASK, "SYS" }, @@ -83,6 +78,9 @@ PUBLIC struct system_image image[] = { #endif #if ENABLE_PRINTER { PRINTER, 0, P_DRIVER, PPRI_NORMAL, 0, PRN_SENDMASK, "PRINTER" }, +#endif +#if ENABLE_RTL8139 + { USR8139, 0, P_DRIVER, PPRI_HIGH, 0, RTL8139_SENDMASK, "RTL8139" }, #endif { INIT_PROC_NR, 0, P_USER, PPRI_USER, 0, INIT_SENDMASK, "INIT" }, }; diff --git a/kernel/type.h b/kernel/type.h index 6e3045080..2e1c44875 100755 --- a/kernel/type.h +++ b/kernel/type.h @@ -28,8 +28,6 @@ struct memory { #if (CHIP == INTEL) -typedef u16_t port_t; -typedef U16_t Port_t; typedef unsigned reg_t; /* machine register */ /* The stack frame layout is determined by the software, but for efficiency diff --git a/servers/is/dmp.c b/servers/is/dmp.c index 54d673c31..1832dbcc6 100644 --- a/servers/is/dmp.c +++ b/servers/is/dmp.c @@ -203,7 +203,7 @@ PRIVATE void irqtab_dmp() continue; } printf("%10d ", e->proc_nr); - printf(" %9.9s (%02d) ", irq[i], i); + printf(" %9.9s (%02d) ", irq[e->irq], e->irq); printf(" %s\n", (e->policy & IRQ_REENABLE) ? "reenable" : "-"); } printf("\n"); diff --git a/tools/Makefile b/tools/Makefile index 66878cc52..31d3873bd 100755 --- a/tools/Makefile +++ b/tools/Makefile @@ -16,6 +16,7 @@ PROGRAMS= ../kernel/kernel \ ../drivers/at_wini/at_wini \ ../drivers/floppy/floppy \ ../drivers/printer/printer \ + ../drivers/rtl8139/rtl8139 \ ../servers/init/init \ #bootfs.img -- 2.44.0