build: all
all install depend clean:
cd ./libdriver && $(MAKE) $@
- cd ./libpci && $(MAKE) $@
cd ./tty && $(MAKE) $@
cd ./memory && $(MAKE) $@
cd ./at_wini && $(MAKE) $@
cd ./dp8390 && $(MAKE) $@
cd ./sb16 && $(MAKE) $@
cd ./lance && $(MAKE) $@
+ cd ./pci && $(MAKE) $@
image:
cd ./libdriver && $(MAKE) build
- cd ./libpci && $(MAKE) build
cd ./tty && $(MAKE) build
cd ./memory && $(MAKE) build
cd ./at_wini && $(MAKE) build
cd ./floppy && $(MAKE) build
cd ./bios_wini && $(MAKE) build
cd ./log && $(MAKE) build
+ cd ./pci && $(MAKE) build
OBJ = at_wini.o
LIBDRIVER = $d/libdriver/driver.o $d/libdriver/drvlib.o
-LIBPCI = $p/pci.o $p/pci_table.o
# build local binary
all build: $(DRIVER)
-$(DRIVER): $(OBJ) $(LIBDRIVER) $(LIBPCI)
- $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBDRIVER) $(LIBS) $(LIBPCI)
+$(DRIVER): $(OBJ) $(LIBDRIVER)
+ $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBDRIVER) $(LIBS)
install -S 8k $(DRIVER)
-$(LIBPCI):
- cd $p && $(MAKE)
-
$(LIBDRIVER):
cd $d/libdriver && $(MAKE)
*/
#include "at_wini.h"
-#include "../libpci/pci.h"
#include <minix/sysutil.h>
#include <minix/keymap.h>
#include <sys/ioc_disk.h>
+#include <ibm/pci.h>
#define ATAPI_DEBUG 0 /* To debug ATAPI code. */
pci_attr_r8(devind, PCI_SCR) != 0x01) {
continue;
}
+
+ printf("init_params_pci: found device %04x/%04x at index %d\n",
+ vid, did, devind);
+
/* Found a controller.
* Programming interface register tells us more.
*/
LIBS = -lsys -lsysutil -ltimers
OBJ = 3c503.o dp8390.o ne2000.o rtl8029.o wdeth.o
-LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o
# build local binary
all build: $(DRIVER)
-$(DRIVER): $(OBJ) $(LIBPCI)
- $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS)
+$(DRIVER): $(OBJ)
+ $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
install -S 4096 $(DRIVER)
-$(LIBPCI):
- cd $d/libpci && $(MAKE)
-
# install with other drivers
install: /usr/sbin/$(DRIVER)
/usr/sbin/$(DRIVER): $(DRIVER)
rm -f *.o *.bak $(DRIVER)
depend:
- /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libpci/*.c > .depend
+ /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
# Include generated dependencies.
include .depend
#include <sys/types.h>
#include <net/gen/ether.h>
#include <net/gen/eth_io.h>
+#include <ibm/pci.h>
#include "assert.h"
-#include "../libpci/pci.h"
#include "local.h"
#include "dp8390.h"
LIBS = -lsys -lsysutil -ltimers
OBJ = fxp.o mii.o
-LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o
# build local binary
all build: $(DRIVER)
-$(DRIVER): $(OBJ) $(LIBPCI)
- $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS)
+$(DRIVER): $(OBJ)
+ $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
install -S 4096 $(DRIVER)
-$(LIBPCI):
- cd $d/libpci && $(MAKE)
-
# install with other drivers
install: /usr/sbin/$(DRIVER)
/usr/sbin/$(DRIVER): $(DRIVER)
rm -f *.o *.bak $(DRIVER)
depend:
- /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libpci/*.c > .depend
+ /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
# Include generated dependencies.
include .depend
#include <net/hton.h>
#include <net/gen/ether.h>
#include <net/gen/eth_io.h>
+#include <ibm/pci.h>
#include <timers.h>
#define vm_1phys2bus(p) (p)
#include "assert.h"
-#include "../libpci/pci.h"
#include "fxp.h"
#include "mii.h"
case FXP_REV_82559C: str= "82559C"; /* 0x08 */
fp->fxp_type= FT_82559;
break;
- case FXP_REV_82559ERA: str= "82559ER-A"; break; /* 0x09 */
- case FXP_REV_82550_1: str= "82550(1)"; break; /* 0x0C */
- case FXP_REV_82550_2: str= "82550(2)"; break; /* 0x0D */
- case FXP_REV_82550_3: str= "82550(3)"; break; /* 0x0E */
- case FXP_REV_82551_1: str= "82551(1)"; break; /* 0x0F */
- case FXP_REV_82551_2: str= "82551(2)"; break; /* 0x10 */
+ case FXP_REV_82559ERA: str= "82559ER-A"; /* 0x09 */
+ fp->fxp_type= FT_82559;
+ break;
+ case FXP_REV_82550_1: str= "82550(1)"; /* 0x0C */
+ fp->fxp_type= FT_82559;
+ break;
+ case FXP_REV_82550_2: str= "82550(2)"; /* 0x0D */
+ fp->fxp_type= FT_82559;
+ break;
+ case FXP_REV_82550_3: str= "82550(3)"; /* 0x0E */
+ fp->fxp_type= FT_82559;
+ break;
+ case FXP_REV_82551_1: str= "82551(1)"; /* 0x0F */
+ fp->fxp_type= FT_82559;
+ break;
+ case FXP_REV_82551_2: str= "82551(2)"; /* 0x10 */
+ fp->fxp_type= FT_82559;
+ break;
}
#if VERBOSE
#-lutils -ltimers
OBJ = lance.o
-LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o
# build local binary
all build: $(DRIVER)
-$(DRIVER): $(OBJ) $(LIBPCI)
- $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS)
+$(DRIVER): $(OBJ)
+ $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
install -S 1k $(DRIVER)
-$(LIBPCI):
- cd $d/libpci && $(MAKE)
-
# install with other drivers
install: /usr/sbin/$(DRIVER)
/usr/sbin/$(DRIVER): $(DRIVER)
rm -f *.o *.bak $(DRIVER)
depend:
- /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libpci/*.c > .depend
+ /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
# Include generated dependencies.
include .depend
#include <assert.h>
#include <minix/syslib.h>
+#include <ibm/pci.h>
#include "lance.h"
-#include "../libpci/pci.h"
/*#include "proc.h"*/
#include <sys/ioc_memory.h>
+++ /dev/null
-# 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 -lsysutil
-
-OBJECTS = pci.o pci_table.o
-
-all build install: $(OBJECTS)
-
-# $(CC) -c $@ $(LDFLAGS) $(OBJ) $(LIBS)
-
-clean:
- rm -f *.o *.bak
-
-depend:
- /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
-
-# Include generated dependencies.
-include .depend
-
--- /dev/null
+# Makefile for PCI support
+DRIVER = pci
+
+# directories
+u = /usr
+i = $u/include
+s = $i/sys
+m = $i/minix
+b = $i/ibm
+d = ..
+
+# programs, flags, etc.
+CC = cc
+CFLAGS = -I$i
+LDFLAGS = -i
+LIBS = -lsys -lsysutil -ltimers
+
+OBJ = main.o pci.o pci_table.o
+
+# build local binary
+all build: $(DRIVER)
+$(DRIVER): $(OBJ)
+ $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
+ install -S 4096 $(DRIVER)
+
+# install with other drivers
+install: /usr/sbin/$(DRIVER)
+/usr/sbin/$(DRIVER): $(DRIVER)
+ install -o root -cs $? $@
+
+# clean up local files
+clean:
+ rm -f *.o *.bak $(DRIVER)
+
+depend:
+ /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
+
+# Include generated dependencies.
+include .depend
+
--- /dev/null
+/*
+main.c
+*/
+
+#include "../drivers.h"
+
+#include <ibm/pci.h>
+
+FORWARD _PROTOTYPE( void do_init, (message *mp) );
+FORWARD _PROTOTYPE( void do_first_dev, (message *mp) );
+FORWARD _PROTOTYPE( void do_next_dev, (message *mp) );
+FORWARD _PROTOTYPE( void do_find_dev, (message *mp) );
+FORWARD _PROTOTYPE( void do_ids, (message *mp) );
+FORWARD _PROTOTYPE( void do_dev_name, (message *mp) );
+FORWARD _PROTOTYPE( void do_slot_name, (message *mp) );
+FORWARD _PROTOTYPE( void do_reserve, (message *mp) );
+FORWARD _PROTOTYPE( void do_attr_r8, (message *mp) );
+FORWARD _PROTOTYPE( void do_attr_r32, (message *mp) );
+FORWARD _PROTOTYPE( void do_attr_w32, (message *mp) );
+
+int main(void)
+{
+ int r;
+ message m;
+
+ printf("PCI says: hello world\n");
+
+ pci_init();
+
+ for(;;)
+ {
+ r= receive(ANY, &m);
+ if (r < 0)
+ {
+ printf("PCI: receive from ANY failed: %d\n", r);
+ break;
+ }
+ switch(m.m_type)
+ {
+ case BUSC_PCI_INIT: do_init(&m); break;
+ case BUSC_PCI_FIRST_DEV: do_first_dev(&m); break;
+ case BUSC_PCI_NEXT_DEV: do_next_dev(&m); break;
+ case BUSC_PCI_FIND_DEV: do_find_dev(&m); break;
+ case BUSC_PCI_IDS: do_ids(&m); break;
+ case BUSC_PCI_DEV_NAME: do_dev_name(&m); break;
+ case BUSC_PCI_SLOT_NAME: do_slot_name(&m); break;
+ case BUSC_PCI_RESERVE: do_reserve(&m); break;
+ case BUSC_PCI_ATTR_R8: do_attr_r8(&m); break;
+ case BUSC_PCI_ATTR_R32: do_attr_r32(&m); break;
+ case BUSC_PCI_ATTR_W32: do_attr_w32(&m); break;
+ default:
+ printf("got message from %d, type %d\n",
+ m.m_source, m.m_type);
+ break;
+ }
+ }
+
+ return 0;
+}
+
+PRIVATE void do_init(mp)
+message *mp;
+{
+ int r;
+
+ /* NOP for the moment */
+
+ mp->m_type= 0;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ printf("do_init: unable to send to %d: %d\n", mp->m_source, r);
+}
+
+PRIVATE void do_first_dev(mp)
+message *mp;
+{
+ int r, devind;
+ u16_t vid, did;
+
+ r= pci_first_dev(&devind, &vid, &did);
+ if (r == 1)
+ {
+ mp->m1_i1= devind;
+ mp->m1_i2= vid;
+ mp->m1_i3= did;
+ }
+ mp->m_type= r;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_first_dev: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_next_dev(mp)
+message *mp;
+{
+ int r, devind;
+ u16_t vid, did;
+
+ devind= mp->m1_i1;
+
+ r= pci_next_dev(&devind, &vid, &did);
+ if (r == 1)
+ {
+ mp->m1_i1= devind;
+ mp->m1_i2= vid;
+ mp->m1_i3= did;
+ }
+ mp->m_type= r;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_next_dev: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_find_dev(mp)
+message *mp;
+{
+ int r, devind;
+ u8_t bus, dev, func;
+
+ bus= mp->m1_i1;
+ dev= mp->m1_i2;
+ func= mp->m1_i3;
+
+ r= pci_find_dev(bus, dev, func, &devind);
+ if (r == 1)
+ mp->m1_i1= devind;
+ mp->m_type= r;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_find_dev: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_ids(mp)
+message *mp;
+{
+ int r, devind;
+ u16_t vid, did;
+
+ devind= mp->m1_i1;
+
+ pci_ids(devind, &vid, &did);
+ mp->m1_i1= vid;
+ mp->m1_i2= did;
+ mp->m_type= OK;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_ids: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_dev_name(mp)
+message *mp;
+{
+ int r, name_len, len;
+ u16_t vid, did;
+ char *name_ptr, *name;
+
+ vid= mp->m1_i1;
+ did= mp->m1_i2;
+ name_len= mp->m1_i3;
+ name_ptr= mp->m1_p1;
+
+ name= pci_dev_name(vid, did);
+ if (name == NULL)
+ {
+ /* No name */
+ r= ENOENT;
+ }
+ else
+ {
+ len= strlen(name)+1;
+ if (len > name_len)
+ len= name_len;
+ r= sys_vircopy(SELF, D, (vir_bytes)name, mp->m_source, D,
+ (vir_bytes)name_ptr, len);
+ }
+
+ mp->m_type= r;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_dev_name: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_slot_name(mp)
+message *mp;
+{
+ int r, devind, name_len, len;
+ char *name_ptr, *name;
+
+ devind= mp->m1_i1;
+ name_len= mp->m1_i2;
+ name_ptr= mp->m1_p1;
+
+ name= pci_slot_name(devind);
+
+ len= strlen(name)+1;
+ if (len > name_len)
+ len= name_len;
+ r= sys_vircopy(SELF, D, (vir_bytes)name, mp->m_source, D,
+ (vir_bytes)name_ptr, len);
+
+ mp->m_type= r;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_slot_name: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_reserve(mp)
+message *mp;
+{
+ int r, devind;
+
+ devind= mp->m1_i1;
+
+ pci_reserve(devind);
+ mp->m_type= OK;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_reserve: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_attr_r8(mp)
+message *mp;
+{
+ int r, devind, port;
+ u8_t v;
+
+ devind= mp->m2_i1;
+ port= mp->m2_i2;
+
+ v= pci_attr_r8(devind, port);
+ mp->m2_l1= v;
+ mp->m_type= OK;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_attr_r8: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_attr_r32(mp)
+message *mp;
+{
+ int r, devind, port;
+ u32_t v;
+
+ devind= mp->m2_i1;
+ port= mp->m2_i2;
+
+ v= pci_attr_r32(devind, port);
+ mp->m2_l1= v;
+ mp->m_type= OK;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_attr_r32: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
+PRIVATE void do_attr_w32(mp)
+message *mp;
+{
+ int r, devind, port;
+ u32_t v;
+
+ devind= mp->m2_i1;
+ port= mp->m2_i2;
+ v= mp->m2_l1;
+
+ pci_attr_w32(devind, port, v);
+ mp->m_type= OK;
+ r= send(mp->m_source, mp);
+ if (r != 0)
+ {
+ printf("do_attr_w32: unable to send to %d: %d\n",
+ mp->m_source, r);
+ }
+}
+
return value;
}
PUBLIC unsigned pci_inw(U16_t port) {
- U16_t value;
+ u32_t value;
int s;
if ((s=sys_inw(port, &value)) !=OK)
printf("PCI: warning, sys_inw failed: %d\n", s);
_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) );
#define PCI_VID 0x00 /* Vendor ID, 16-bit */
#define PCI_DID 0x02 /* Device ID, 16-bit */
LIBS = -lsys -lsysutil -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)
+$(DRIVER): $(OBJ)
+ $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
install -S 50kw $(DRIVER)
-$(PCI):
- cd $d/libpci && $(MAKE)
-
# install with other drivers
install: /usr/sbin/$(DRIVER)
/usr/sbin/$(DRIVER): $(DRIVER)
rm -f $(DRIVER) *.o *.bak
depend:
- /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libpci/*.c > .depend
+ /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
# Include generated dependencies.
include .depend
#include <net/hton.h>
#include <net/gen/ether.h>
#include <net/gen/eth_io.h>
+#include <ibm/pci.h>
#include <sys/types.h>
#include <fcntl.h>
#define printW() ((void)0)
#define vm_1phys2bus(p) (p)
-#define VERBOSE 0 /* display message during init */
+#define VERBOSE 1 /* display message during init */
-#include "../libpci/pci.h"
#include "rtl8139.h"
#define RX_BUFSIZE RL_RCR_RBLEN_64K_SIZE
return value;
}
static unsigned my_inw(U16_t port) {
- U16_t value;
+ u32_t value;
int s;
if ((s=sys_inw(port, &value)) !=OK)
printf("RTL8139: warning, sys_inw failed: %d\n", s);
printf("RTL8139: error, couldn't enable interrupts: %d\n", s);
#if VERBOSE /* stay silent during startup, can always get status later */
- if (rep->re_mode) {
+ if (rep->re_model) {
printf("%s: model %s\n", rep->re_name, rep->re_model);
} else
{
#endif
/* Reset the device */
+ printf("rl_reset_hw: (before reset) port = 0x%x, RL_CR = 0x%x\n",
+ port, rl_inb(port, RL_CR));
rl_outb(port, RL_CR, RL_CR_RST);
getuptime(&t0);
do {
if (!(rl_inb(port, RL_CR) & RL_CR_RST))
break;
} while (getuptime(&t1)==OK && (t1-t0) < HZ);
+ printf("rl_reset_hw: (after reset) port = 0x%x, RL_CR = 0x%x\n",
+ port, rl_inb(port, RL_CR));
if (rl_inb(port, RL_CR) & RL_CR_RST)
- panic("rtl8139","reset failed to complete", NO_NUM);
+ printf("rtl8139: reset failed to complete");
t= rl_inl(port, RL_TCR);
switch(t & (RL_TCR_HWVER_AM | RL_TCR_HWVER_BM))