From: Philip Homburg Date: Thu, 12 Jan 2006 14:37:37 +0000 (+0000) Subject: Added pci_init1.c, pci_attr_r16.c, pci_attr_w8.c, pci_attr_w16.c, X-Git-Tag: v3.1.2a~456 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/static/style.css?a=commitdiff_plain;h=f18faca855447c675d53fbf21bc0ddb64c6eeb06;p=minix.git Added pci_init1.c, pci_attr_r16.c, pci_attr_w8.c, pci_attr_w16.c, and pci_rescan_bus.c --- diff --git a/lib/syslib/Makefile b/lib/syslib/Makefile index 5c9fd86d3..749c8b9bd 100755 --- a/lib/syslib/Makefile +++ b/lib/syslib/Makefile @@ -42,14 +42,19 @@ libsys_OBJECTS = \ sys_vm_setbuf.o \ sys_vm_map.o \ pci_attr_r8.o \ + pci_attr_r16.o \ pci_attr_r32.o \ + pci_attr_w8.o \ + pci_attr_w16.o \ pci_attr_w32.o \ pci_dev_name.o \ pci_find_dev.o \ pci_first_dev.o \ pci_ids.o \ pci_init.o \ + pci_init1.o \ pci_next_dev.o \ + pci_rescan_bus.o \ pci_reserve.o \ pci_slot_name.o \ diff --git a/lib/syslib/pci_attr_r16.c b/lib/syslib/pci_attr_r16.c new file mode 100644 index 000000000..b5fae6088 --- /dev/null +++ b/lib/syslib/pci_attr_r16.c @@ -0,0 +1,31 @@ +/* +pci_attr_r16.c +*/ + +#include "syslib.h" +#include + +/*===========================================================================* + * pci_attr_r16 * + *===========================================================================*/ +PUBLIC u16_t pci_attr_r16(devind, port) +int devind; +int port; +{ + int r; + message m; + + m.m_type= BUSC_PCI_ATTR_R16; + m.m2_i1= devind; + m.m2_i2= port; + + r= sendrec(PCI_PROC_NR, &m); + if (r != 0) + panic("pci", "pci_attr_r16: can't talk to PCI", r); + + if (m.m_type != 0) + panic("pci", "pci_attr_r16: got bad reply from PCI", m.m_type); + + return m.m2_l1; +} + diff --git a/lib/syslib/pci_attr_w16.c b/lib/syslib/pci_attr_w16.c new file mode 100644 index 000000000..c2c8e2eb2 --- /dev/null +++ b/lib/syslib/pci_attr_w16.c @@ -0,0 +1,31 @@ +/* +pci_attr_w16.c +*/ + +#include "syslib.h" +#include + +/*===========================================================================* + * pci_attr_w16 * + *===========================================================================*/ +PUBLIC void pci_attr_w16(devind, port, value) +int devind; +int port; +u16_t value; +{ + int r; + message m; + + m.m_type= BUSC_PCI_ATTR_W16; + 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_w16: can't talk to PCI", r); + + if (m.m_type != 0) + panic("pci", "pci_attr_w16: got bad reply from PCI", m.m_type); +} + diff --git a/lib/syslib/pci_attr_w8.c b/lib/syslib/pci_attr_w8.c new file mode 100644 index 000000000..7385d9505 --- /dev/null +++ b/lib/syslib/pci_attr_w8.c @@ -0,0 +1,31 @@ +/* +pci_attr_w8.c +*/ + +#include "syslib.h" +#include + +/*===========================================================================* + * pci_attr_w8 * + *===========================================================================*/ +PUBLIC void pci_attr_w8(devind, port, value) +int devind; +int port; +u8_t value; +{ + int r; + message m; + + m.m_type= BUSC_PCI_ATTR_W8; + 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_w8: can't talk to PCI", r); + + if (m.m_type != 0) + panic("pci", "pci_attr_w8: got bad reply from PCI", m.m_type); +} + diff --git a/lib/syslib/pci_init.c b/lib/syslib/pci_init.c index 254975242..626afe45b 100644 --- a/lib/syslib/pci_init.c +++ b/lib/syslib/pci_init.c @@ -10,14 +10,6 @@ pci_init.c *===========================================================================*/ 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); + pci_init1(""); } diff --git a/lib/syslib/pci_init1.c b/lib/syslib/pci_init1.c new file mode 100644 index 000000000..76df3e572 --- /dev/null +++ b/lib/syslib/pci_init1.c @@ -0,0 +1,35 @@ +/* +pci_init1.c +*/ + +#include "syslib.h" +#include +#include + +/*===========================================================================* + * pci_init1 * + *===========================================================================*/ +PUBLIC void pci_init1(name) +char *name; +{ + int r; + size_t len; + message m; + + m.m_type= BUSC_PCI_INIT; + len= strlen(name); + if (len+1 <= sizeof(m.m3_ca1)) + strcpy(m.m3_ca1, name); + else + { + len= sizeof(m.m3_ca1)-1; + memcpy(m.m3_ca1, name, len); + m.m3_ca1[len]= '\0'; + } + r= sendrec(PCI_PROC_NR, &m); + if (r != 0) + panic("pci", "pci_init1: can't talk to PCI", r); + if (m.m_type != 0) + panic("pci", "pci_init1: got bad reply from PCI", m.m_type); +} + diff --git a/lib/syslib/pci_rescan_bus.c b/lib/syslib/pci_rescan_bus.c new file mode 100644 index 000000000..1e0c3387e --- /dev/null +++ b/lib/syslib/pci_rescan_bus.c @@ -0,0 +1,30 @@ +/* +pci_rescan_bus.c +*/ + +#include "syslib.h" +#include + +/*===========================================================================* + * pci_rescan_bus * + *===========================================================================*/ +PUBLIC void pci_rescan_bus(busnr) +u8_t busnr; +{ + int r; + message m; + + m.m_type= BUSC_PCI_RESCAN; + m.m1_i1= busnr; + + r= sendrec(PCI_PROC_NR, &m); + if (r != 0) + panic("pci", "pci_rescan_bus: can't talk to PCI", r); + + if (m.m_type != 0) + { + panic("pci", "pci_rescan_bus: got bad reply from PCI", + m.m_type); + } +} +