PCI support in a separate driver.
This commit is contained in:
parent
3dd0a97049
commit
24cf667abb
21 changed files with 393 additions and 98 deletions
|
@ -16,7 +16,6 @@ usage:
|
|||
build: all
|
||||
all install depend clean:
|
||||
cd ./libdriver && $(MAKE) $@
|
||||
cd ./libpci && $(MAKE) $@
|
||||
cd ./tty && $(MAKE) $@
|
||||
cd ./memory && $(MAKE) $@
|
||||
cd ./at_wini && $(MAKE) $@
|
||||
|
@ -32,13 +31,14 @@ all install depend clean:
|
|||
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
|
||||
|
|
|
@ -19,18 +19,14 @@ LIBS = -lsysutil -lsys -ltimers
|
|||
|
||||
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)
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
*/
|
||||
|
||||
#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. */
|
||||
|
||||
|
@ -416,6 +416,10 @@ PRIVATE void init_params_pci(int skip)
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -16,17 +16,13 @@ LDFLAGS = -i
|
|||
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)
|
||||
|
@ -37,7 +33,7 @@ clean:
|
|||
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
|
||||
|
|
|
@ -12,9 +12,9 @@ Created: April 2000 by Philip Homburg <philip@f-mnx.phicoh.com>
|
|||
#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"
|
||||
|
|
|
@ -16,17 +16,13 @@ LDFLAGS = -i
|
|||
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)
|
||||
|
@ -37,7 +33,7 @@ clean:
|
|||
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
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <net/hton.h>
|
||||
#include <net/gen/ether.h>
|
||||
#include <net/gen/eth_io.h>
|
||||
#include <ibm/pci.h>
|
||||
|
||||
#include <timers.h>
|
||||
|
||||
|
@ -58,7 +59,6 @@
|
|||
#define vm_1phys2bus(p) (p)
|
||||
|
||||
#include "assert.h"
|
||||
#include "../libpci/pci.h"
|
||||
#include "fxp.h"
|
||||
#include "mii.h"
|
||||
|
||||
|
@ -585,12 +585,24 @@ fxp_t *fp;
|
|||
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
|
||||
|
|
|
@ -17,17 +17,13 @@ LIBS = -lsys -lsysutil
|
|||
#-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)
|
||||
|
@ -38,7 +34,7 @@ clean:
|
|||
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
|
||||
|
|
|
@ -52,9 +52,9 @@
|
|||
#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>
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
# 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
|
||||
|
40
drivers/pci/Makefile
Normal file
40
drivers/pci/Makefile
Normal file
|
@ -0,0 +1,40 @@
|
|||
# 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
|
||||
|
301
drivers/pci/main.c
Normal file
301
drivers/pci/main.c
Normal file
|
@ -0,0 +1,301 @@
|
|||
/*
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ PUBLIC unsigned pci_inb(U16_t port) {
|
|||
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);
|
|
@ -13,21 +13,6 @@ _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) );
|
||||
|
||||
#define PCI_VID 0x00 /* Vendor ID, 16-bit */
|
||||
#define PCI_DID 0x02 /* Device ID, 16-bit */
|
|
@ -17,18 +17,13 @@ LDFLAGS = -i
|
|||
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)
|
||||
|
@ -39,7 +34,7 @@ clean:
|
|||
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
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#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>
|
||||
|
@ -81,9 +82,8 @@
|
|||
#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
|
||||
|
@ -189,7 +189,7 @@ static unsigned my_inb(U16_t port) {
|
|||
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);
|
||||
|
@ -775,7 +775,7 @@ re_t *rep;
|
|||
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
|
||||
{
|
||||
|
@ -825,14 +825,18 @@ re_t *rep;
|
|||
#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))
|
||||
|
|
Loading…
Reference in a new issue