Stubs for accessing the PCI driver

This commit is contained in:
Philip Homburg 2005-12-02 14:41:46 +00:00
parent b3cd15b01b
commit 3dd0a97049
12 changed files with 391 additions and 0 deletions

View file

@ -41,5 +41,16 @@ libsys_OBJECTS = \
taskcall.o \
sys_vm_setbuf.o \
sys_vm_map.o \
pci_attr_r8.o \
pci_attr_r32.o \
pci_attr_w32.o \
pci_dev_name.o \
pci_find_dev.o \
pci_first_dev.o \
pci_ids.o \
pci_init.o \
pci_next_dev.o \
pci_reserve.o \
pci_slot_name.o \
include ../Makefile.inc

31
lib/syslib/pci_attr_r32.c Normal file
View file

@ -0,0 +1,31 @@
/*
pci_attr_r32.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_attr_r32 *
*===========================================================================*/
PUBLIC u32_t pci_attr_r32(devind, port)
int devind;
int port;
{
int r;
message m;
m.m_type= BUSC_PCI_ATTR_R32;
m.m2_i1= devind;
m.m2_i2= port;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_attr_r32: can't talk to PCI", r);
if (m.m_type != 0)
panic("pci", "pci_attr_r32: got bad reply from PCI", m.m_type);
return m.m2_l1;
}

31
lib/syslib/pci_attr_r8.c Normal file
View file

@ -0,0 +1,31 @@
/*
pci_attr_r8.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_attr_r8 *
*===========================================================================*/
PUBLIC u8_t pci_attr_r8(devind, port)
int devind;
int port;
{
int r;
message m;
m.m_type= BUSC_PCI_ATTR_R8;
m.m2_i1= devind;
m.m2_i2= port;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_attr_r8: can't talk to PCI", r);
if (m.m_type != 0)
panic("pci", "pci_attr_r8: got bad reply from PCI", m.m_type);
return m.m2_l1;
}

31
lib/syslib/pci_attr_w32.c Normal file
View file

@ -0,0 +1,31 @@
/*
pci_attr_w32.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_attr_w32 *
*===========================================================================*/
PUBLIC void pci_attr_w32(devind, port, value)
int devind;
int port;
u32_t value;
{
int r;
message m;
m.m_type= BUSC_PCI_ATTR_W32;
m.m2_i1= devind;
m.m2_i2= port;
m.m2_l1= value;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_attr_w32: can't talk to PCI", r);
if (m.m_type != 0)
panic("pci", "pci_attr_w32: got bad reply from PCI", m.m_type);
}

45
lib/syslib/pci_dev_name.c Normal file
View file

@ -0,0 +1,45 @@
/*
pci_dev_name.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_dev_name *
*===========================================================================*/
PUBLIC char *pci_dev_name(vid, did)
u16_t vid;
u16_t did;
{
static char name[80]; /* We need a better interface for this */
int r;
message m;
m.m_type= BUSC_PCI_DEV_NAME;
m.m1_i1= vid;
m.m1_i2= did;
m.m1_i3= sizeof(name);
m.m1_p1= name;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_dev_name: can't talk to PCI", r);
if (m.m_type == ENOENT)
{
printf("pci_dev_name: got no name\n");
return NULL; /* No name for this device */
}
if (m.m_type != 0)
panic("pci", "pci_dev_name: got bad reply from PCI", m.m_type);
name[sizeof(name)-1]= '\0'; /* Make sure that the string is NUL
* terminated.
*/
printf("pci_dev_name: got name %s\n", name);
return name;
}

42
lib/syslib/pci_find_dev.c Normal file
View file

@ -0,0 +1,42 @@
/*
pci_find_dev.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_find_dev *
*===========================================================================*/
PUBLIC int pci_find_dev(bus, dev, func, devindp)
u8_t bus;
u8_t dev;
u8_t func;
int *devindp;
{
int r;
message m;
m.m_type= BUSC_PCI_FIND_DEV;
m.m1_i1= bus;
m.m1_i2= dev;
m.m1_i3= func;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_find_dev: can't talk to PCI", r);
if (m.m_type == 1)
{
*devindp= m.m1_i1;
printf("pci_find_dev: got device %d for %d.%d.%d\n",
*devindp, bus, dev, func);
return 1;
}
if (m.m_type != 0)
panic("pci", "pci_find_dev: got bad reply from PCI", m.m_type);
printf("pci_find_dev: got nothing\n");
return 0;
}

View file

@ -0,0 +1,37 @@
/*
pci_first_dev.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_first_dev *
*===========================================================================*/
PUBLIC int pci_first_dev(devindp, vidp, didp)
int *devindp;
u16_t *vidp;
u16_t *didp;
{
int r;
message m;
m.m_type= BUSC_PCI_FIRST_DEV;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_first_dev: can't talk to PCI", r);
if (m.m_type == 1)
{
*devindp= m.m1_i1;
*vidp= m.m1_i2;
*didp= m.m1_i3;
printf("pci_first_dev: got device %d, %04x/%04x\n",
*devindp, *vidp, *didp);
return 1;
}
if (m.m_type != 0)
panic("pci", "pci_first_dev: got bad reply from PCI", m.m_type);
printf("pci_first_dev: got nothing\n");
return 0;
}

32
lib/syslib/pci_ids.c Normal file
View file

@ -0,0 +1,32 @@
/*
pci_ids.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_ids *
*===========================================================================*/
PUBLIC void pci_ids(devind, vidp, didp)
int devind;
u16_t *vidp;
u16_t *didp;
{
int r;
message m;
m.m_type= BUSC_PCI_IDS;
m.m1_i1= devind;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_ids: can't talk to PCI", r);
if (m.m_type != 0)
panic("pci", "pci_ids: got bad reply from PCI", m.m_type);
*vidp= m.m1_i1;
*didp= m.m1_i2;
printf("pci_ids: %04x/%04x\n", *vidp, *didp);
}

23
lib/syslib/pci_init.c Normal file
View file

@ -0,0 +1,23 @@
/*
pci_init.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_init *
*===========================================================================*/
PUBLIC void pci_init()
{
int r;
message m;
m.m_type= BUSC_PCI_INIT;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_init: can't talk to PCI", r);
if (m.m_type != 0)
panic("pci", "pci_init: got bad reply from PCI", m.m_type);
}

43
lib/syslib/pci_next_dev.c Normal file
View file

@ -0,0 +1,43 @@
/*
pci_next_dev.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_next_dev *
*===========================================================================*/
PUBLIC int pci_next_dev(devindp, vidp, didp)
int *devindp;
u16_t *vidp;
u16_t *didp;
{
int r;
message m;
m.m_type= BUSC_PCI_NEXT_DEV;
m.m1_i1= *devindp;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_next_dev: can't talk to PCI", r);
if (m.m_type == 1)
{
*devindp= m.m1_i1;
*vidp= m.m1_i2;
*didp= m.m1_i3;
#if 0
printf("pci_next_dev: got device %d, %04x/%04x\n",
*devindp, *vidp, *didp);
#endif
return 1;
}
if (m.m_type != 0)
panic("pci", "pci_next_dev: got bad reply from PCI", m.m_type);
printf("pci_next_dev: got nothing\n");
return 0;
}

27
lib/syslib/pci_reserve.c Normal file
View file

@ -0,0 +1,27 @@
/*
pci_reserve.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_reserve *
*===========================================================================*/
PUBLIC void pci_reserve(devind)
int devind;
{
int r;
message m;
m.m_type= BUSC_PCI_RESERVE;
m.m1_i1= devind;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_reserve: can't talk to PCI", r);
if (m.m_type != 0)
panic("pci", "pci_reserve: got bad reply from PCI", m.m_type);
}

View file

@ -0,0 +1,38 @@
/*
pci_slot_name.c
*/
#include "syslib.h"
#include <minix/sysutil.h>
/*===========================================================================*
* pci_slot_name *
*===========================================================================*/
PUBLIC char *pci_slot_name(devind)
int devind;
{
static char name[80]; /* We need a better interface for this */
int r;
message m;
m.m_type= BUSC_PCI_SLOT_NAME;
m.m1_i1= devind;
m.m1_i2= sizeof(name);
m.m1_p1= name;
r= sendrec(PCI_PROC_NR, &m);
if (r != 0)
panic("pci", "pci_slot_name: can't talk to PCI", r);
if (m.m_type != 0)
panic("pci", "pci_slot_name: got bad reply from PCI", m.m_type);
name[sizeof(name)-1]= '\0'; /* Make sure that the string is NUL
* terminated.
*/
printf("pci_slot_name: got name %s\n", name);
return name;
}