Merge pull request #2 from Stichting-MINIX-Research-Foundation/master
Merge from Minix code
This commit is contained in:
commit
6238e058c4
|
|
@ -23,6 +23,7 @@
|
||||||
./etc/system.conf.d/vbfs minix-base
|
./etc/system.conf.d/vbfs minix-base
|
||||||
./etc/system.conf.d/vbox minix-base
|
./etc/system.conf.d/vbox minix-base
|
||||||
./etc/system.conf.d/virtio_net minix-base
|
./etc/system.conf.d/virtio_net minix-base
|
||||||
|
./etc/system.conf.d/vt6105 minix-base
|
||||||
./service/3c90x minix-base
|
./service/3c90x minix-base
|
||||||
./service/acpi minix-base
|
./service/acpi minix-base
|
||||||
./service/ahci minix-base
|
./service/ahci minix-base
|
||||||
|
|
@ -53,6 +54,9 @@
|
||||||
./service/vbox minix-base
|
./service/vbox minix-base
|
||||||
./service/virtio_blk minix-base
|
./service/virtio_blk minix-base
|
||||||
./service/virtio_net minix-base
|
./service/virtio_net minix-base
|
||||||
|
./service/vt6105 minix-base
|
||||||
|
./usr/lib/libacpi.a minix-base
|
||||||
|
./usr/lib/libacpi_pic.a minix-base
|
||||||
./usr/lib/libhgfs.a minix-base
|
./usr/lib/libhgfs.a minix-base
|
||||||
./usr/lib/libhgfs_pic.a minix-base
|
./usr/lib/libhgfs_pic.a minix-base
|
||||||
./usr/lib/libm387.a minix-base
|
./usr/lib/libm387.a minix-base
|
||||||
|
|
|
||||||
|
|
@ -1312,6 +1312,7 @@
|
||||||
./usr/include/net/if_arp.h minix-comp
|
./usr/include/net/if_arp.h minix-comp
|
||||||
./usr/include/net/if_dl.h minix-comp
|
./usr/include/net/if_dl.h minix-comp
|
||||||
./usr/include/net/if_ether.h minix-comp
|
./usr/include/net/if_ether.h minix-comp
|
||||||
|
./usr/include/net/if_ieee1394.h minix-comp
|
||||||
./usr/include/net/if_media.h minix-comp
|
./usr/include/net/if_media.h minix-comp
|
||||||
./usr/include/net/if_pflog.h minix-comp
|
./usr/include/net/if_pflog.h minix-comp
|
||||||
./usr/include/net/if_types.h minix-comp
|
./usr/include/net/if_types.h minix-comp
|
||||||
|
|
@ -1866,6 +1867,7 @@
|
||||||
./usr/include/zlib.h minix-comp
|
./usr/include/zlib.h minix-comp
|
||||||
./usr/lib minix-comp
|
./usr/lib minix-comp
|
||||||
./usr/lib/bc minix-comp
|
./usr/lib/bc minix-comp
|
||||||
|
./usr/lib/bc/libacpi.a minix-comp bitcode
|
||||||
./usr/lib/bc/libarchive.a minix-comp bitcode
|
./usr/lib/bc/libarchive.a minix-comp bitcode
|
||||||
./usr/lib/bc/libasyn.a minix-comp bitcode
|
./usr/lib/bc/libasyn.a minix-comp bitcode
|
||||||
./usr/lib/bc/libaudiodriver.a minix-comp bitcode
|
./usr/lib/bc/libaudiodriver.a minix-comp bitcode
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
./usr/libdata/debug/service/vbox.debug minix-debug debug
|
./usr/libdata/debug/service/vbox.debug minix-debug debug
|
||||||
./usr/libdata/debug/service/virtio_blk.debug minix-debug debug
|
./usr/libdata/debug/service/virtio_blk.debug minix-debug debug
|
||||||
./usr/libdata/debug/service/virtio_net.debug minix-debug debug
|
./usr/libdata/debug/service/virtio_net.debug minix-debug debug
|
||||||
|
./usr/libdata/debug/service/vt6105.debug minix-debug debug
|
||||||
./usr/libdata/debug/usr/lib/libm387.so.0.1.debug minix-debug debug
|
./usr/libdata/debug/usr/lib/libm387.so.0.1.debug minix-debug debug
|
||||||
./usr/libdata/debug/usr/tests/minix-posix/test47.debug minix-debug debug
|
./usr/libdata/debug/usr/tests/minix-posix/test47.debug minix-debug debug
|
||||||
./usr/libdata/debug/usr/tests/minix-posix/test51.debug minix-debug debug
|
./usr/libdata/debug/usr/tests/minix-posix/test51.debug minix-debug debug
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,8 @@ SUBDIR+= ../minix/lib/liblwip \
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.if (${MACHINE_ARCH} == "i386")
|
.if (${MACHINE_ARCH} == "i386")
|
||||||
SUBDIR+= ../minix/lib/libhgfs \
|
SUBDIR+= ../minix/lib/libacpi \
|
||||||
|
../minix/lib/libhgfs \
|
||||||
../minix/lib/libvassert \
|
../minix/lib/libvassert \
|
||||||
../minix/lib/libvboxfs \
|
../minix/lib/libvboxfs \
|
||||||
../minix/lib/libvirtio
|
../minix/lib/libvirtio
|
||||||
|
|
|
||||||
|
|
@ -57,12 +57,10 @@ __RCSID("$NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $");
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#if !defined(__minix)
|
|
||||||
#include <net/if_dl.h>
|
#include <net/if_dl.h>
|
||||||
#include <net/if_ieee1394.h>
|
#include <net/if_ieee1394.h>
|
||||||
#include <net/if_types.h>
|
#include <net/if_types.h>
|
||||||
#include <netatalk/at.h>
|
#include <netatalk/at.h>
|
||||||
#endif /* !defined(__minix) */
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <arpa/nameser.h>
|
#include <arpa/nameser.h>
|
||||||
|
|
@ -110,7 +108,6 @@ static int ip6_parsenumeric(const struct sockaddr *, const char *, char *,
|
||||||
socklen_t, int);
|
socklen_t, int);
|
||||||
static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int);
|
static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(__minix)
|
|
||||||
static int getnameinfo_atalk(const struct sockaddr *, socklen_t, char *,
|
static int getnameinfo_atalk(const struct sockaddr *, socklen_t, char *,
|
||||||
socklen_t, char *, socklen_t, int);
|
socklen_t, char *, socklen_t, int);
|
||||||
static int getnameinfo_local(const struct sockaddr *, socklen_t, char *,
|
static int getnameinfo_local(const struct sockaddr *, socklen_t, char *,
|
||||||
|
|
@ -119,7 +116,6 @@ static int getnameinfo_local(const struct sockaddr *, socklen_t, char *,
|
||||||
static int getnameinfo_link(const struct sockaddr *, socklen_t, char *,
|
static int getnameinfo_link(const struct sockaddr *, socklen_t, char *,
|
||||||
socklen_t, char *, socklen_t, int);
|
socklen_t, char *, socklen_t, int);
|
||||||
static int hexname(const uint8_t *, size_t, char *, socklen_t);
|
static int hexname(const uint8_t *, size_t, char *, socklen_t);
|
||||||
#endif /* !defined(__minix) */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Top-level getnameinfo() code. Look at the address family, and pick an
|
* Top-level getnameinfo() code. Look at the address family, and pick an
|
||||||
|
|
@ -133,29 +129,24 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (sa->sa_family) {
|
switch (sa->sa_family) {
|
||||||
#if !defined(__minix)
|
|
||||||
case AF_APPLETALK:
|
case AF_APPLETALK:
|
||||||
return getnameinfo_atalk(sa, salen, host, hostlen,
|
return getnameinfo_atalk(sa, salen, host, hostlen,
|
||||||
serv, servlen, flags);
|
serv, servlen, flags);
|
||||||
#endif /* !defined(__minix) */
|
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
return getnameinfo_inet(sa, salen, host, hostlen,
|
return getnameinfo_inet(sa, salen, host, hostlen,
|
||||||
serv, servlen, flags);
|
serv, servlen, flags);
|
||||||
#if !defined(__minix)
|
|
||||||
case AF_LINK:
|
case AF_LINK:
|
||||||
return getnameinfo_link(sa, salen, host, hostlen,
|
return getnameinfo_link(sa, salen, host, hostlen,
|
||||||
serv, servlen, flags);
|
serv, servlen, flags);
|
||||||
case AF_LOCAL:
|
case AF_LOCAL:
|
||||||
return getnameinfo_local(sa, salen, host, hostlen,
|
return getnameinfo_local(sa, salen, host, hostlen,
|
||||||
serv, servlen, flags);
|
serv, servlen, flags);
|
||||||
#endif /* !defined(__minix) */
|
|
||||||
default:
|
default:
|
||||||
return EAI_FAMILY;
|
return EAI_FAMILY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(__minix)
|
|
||||||
/*
|
/*
|
||||||
* getnameinfo_atalk():
|
* getnameinfo_atalk():
|
||||||
* Format an AppleTalk address into a printable format.
|
* Format an AppleTalk address into a printable format.
|
||||||
|
|
@ -238,7 +229,6 @@ getnameinfo_local(const struct sockaddr *sa, socklen_t salen,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* !defined(__minix) */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* getnameinfo_inet():
|
* getnameinfo_inet():
|
||||||
|
|
@ -538,7 +528,6 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
|
||||||
#endif /* INET6 */
|
#endif /* INET6 */
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__minix)
|
|
||||||
/*
|
/*
|
||||||
* getnameinfo_link():
|
* getnameinfo_link():
|
||||||
* Format a link-layer address into a printable format, paying attention to
|
* Format a link-layer address into a printable format, paying attention to
|
||||||
|
|
@ -635,4 +624,3 @@ hexname(const uint8_t *cp, size_t len, char *host, socklen_t hostlen)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* !defined(__minix) */
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ CWARNFLAGS.clang=-Wno-unused
|
||||||
DPADD+= ${LIBCHARDRIVER}
|
DPADD+= ${LIBCHARDRIVER}
|
||||||
LDADD+= -lchardriver
|
LDADD+= -lchardriver
|
||||||
|
|
||||||
|
DPADD+= ${LIBACPI}
|
||||||
|
LDADD+= -lacpi
|
||||||
|
|
||||||
WARNS= 3
|
WARNS= 3
|
||||||
|
|
||||||
.include <minix.service.mk>
|
.include <minix.service.mk>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ Created: Jan 2000 by Philip Homburg <philip@cs.vu.nl>
|
||||||
#include <minix/acpi.h>
|
#include <minix/acpi.h>
|
||||||
#include <minix/chardriver.h>
|
#include <minix/chardriver.h>
|
||||||
#include <minix/driver.h>
|
#include <minix/driver.h>
|
||||||
#include <minix/ds.h>
|
|
||||||
#include <minix/param.h>
|
#include <minix/param.h>
|
||||||
#include <minix/rs.h>
|
#include <minix/rs.h>
|
||||||
|
|
||||||
|
|
@ -94,7 +93,6 @@ static struct pcidev
|
||||||
static int nr_pcidev= 0;
|
static int nr_pcidev= 0;
|
||||||
|
|
||||||
static struct machine machine;
|
static struct machine machine;
|
||||||
static endpoint_t acpi_ep;
|
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* helper functions for I/O *
|
* helper functions for I/O *
|
||||||
|
|
@ -890,26 +888,6 @@ do_isabridge(int busind)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
|
||||||
* IRQ handling *
|
|
||||||
*===========================================================================*/
|
|
||||||
static int
|
|
||||||
acpi_get_irq(unsigned bus, unsigned dev, unsigned pin)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
message m;
|
|
||||||
|
|
||||||
((struct acpi_get_irq_req *)&m)->hdr.request = ACPI_REQ_GET_IRQ;
|
|
||||||
((struct acpi_get_irq_req *)&m)->bus = bus;
|
|
||||||
((struct acpi_get_irq_req *)&m)->dev = dev;
|
|
||||||
((struct acpi_get_irq_req *)&m)->pin = pin;
|
|
||||||
|
|
||||||
if ((err = ipc_sendrec(acpi_ep, &m)) != OK)
|
|
||||||
panic("PCI: error %d while receiveing from ACPI\n", err);
|
|
||||||
|
|
||||||
return ((struct acpi_get_irq_resp *)&m)->irq;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
derive_irq(struct pcidev * dev, int pin)
|
derive_irq(struct pcidev * dev, int pin)
|
||||||
{
|
{
|
||||||
|
|
@ -1801,30 +1779,6 @@ complete_bridges(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* tells acpi which two busses are connected by this bridge. The primary bus
|
|
||||||
* (pbnr) must be already known to acpi and it must map dev as the connection to
|
|
||||||
* the secondary (sbnr) bus
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
acpi_map_bridge(unsigned int pbnr, unsigned int dev, unsigned int sbnr)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
message m;
|
|
||||||
|
|
||||||
((struct acpi_map_bridge_req *)&m)->hdr.request = ACPI_REQ_MAP_BRIDGE;
|
|
||||||
((struct acpi_map_bridge_req *)&m)->primary_bus = pbnr;
|
|
||||||
((struct acpi_map_bridge_req *)&m)->secondary_bus = sbnr;
|
|
||||||
((struct acpi_map_bridge_req *)&m)->device = dev;
|
|
||||||
|
|
||||||
if ((err = ipc_sendrec(acpi_ep, &m)) != OK)
|
|
||||||
panic("PCI: error %d while receiveing from ACPI\n", err);
|
|
||||||
|
|
||||||
if (((struct acpi_map_bridge_resp *)&m)->err != OK)
|
|
||||||
printf("PCI: acpi failed to map pci (%d) to pci (%d) bridge\n",
|
|
||||||
pbnr, sbnr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_pcibridge(int busind)
|
do_pcibridge(int busind)
|
||||||
{
|
{
|
||||||
|
|
@ -2148,7 +2102,7 @@ sef_cb_init(int type, sef_init_info_t *info)
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
}
|
}
|
||||||
if (machine.apic_enabled &&
|
if (machine.apic_enabled &&
|
||||||
ds_retrieve_label_endpt("acpi", &acpi_ep) != OK) {
|
acpi_init() != OK) {
|
||||||
panic("PCI: Cannot use APIC mode without ACPI!\n");
|
panic("PCI: Cannot use APIC mode without ACPI!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ SUBDIR+= lance
|
||||||
SUBDIR+= rtl8139
|
SUBDIR+= rtl8139
|
||||||
SUBDIR+= rtl8169
|
SUBDIR+= rtl8169
|
||||||
SUBDIR+= virtio_net
|
SUBDIR+= virtio_net
|
||||||
|
SUBDIR+= vt6105
|
||||||
.endif # ${MACHINE_ARCH} == "i386"
|
.endif # ${MACHINE_ARCH} == "i386"
|
||||||
|
|
||||||
.if ${MACHINE_ARCH} == "earm"
|
.if ${MACHINE_ARCH} == "earm"
|
||||||
|
|
|
||||||
14
minix/drivers/net/vt6105/Makefile
Executable file
14
minix/drivers/net/vt6105/Makefile
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Makefile for the VIA Technology 6105/6106S Ethernet driver (vt6105)
|
||||||
|
PROG= vt6105
|
||||||
|
SRCS= vt6105.c
|
||||||
|
|
||||||
|
FILES=${PROG}.conf
|
||||||
|
FILESNAME=${PROG}
|
||||||
|
FILESDIR= /etc/system.conf.d
|
||||||
|
|
||||||
|
DPADD+= ${LIBNETDRIVER} ${LIBSYS}
|
||||||
|
LDADD+= -lnetdriver -lsys
|
||||||
|
|
||||||
|
CPPFLAGS+= -I${NETBSDSRCDIR}/minix
|
||||||
|
|
||||||
|
.include <minix.service.mk>
|
||||||
17
minix/drivers/net/vt6105/README
Normal file
17
minix/drivers/net/vt6105/README
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
The vt6105 driver is for VIA Technology 6105/6106S Ethernet card.
|
||||||
|
|
||||||
|
This driver is referred to Minix(3.4.0) rtl8169 driver,
|
||||||
|
Linux(4.2.1) via-rhine driver and VT6105 Rhine III Specification(Rev 1.2).
|
||||||
|
|
||||||
|
The supported PCI number is 1106:3106:1186:1403.
|
||||||
|
Maybe other PCI numbers for VIA Rhine III can be supported.
|
||||||
|
|
||||||
|
Revision 1.0 2016/10/18
|
||||||
|
Authored by Jia-Ju Bai <baijiaju1990@163.com>
|
||||||
|
|
||||||
|
Something can be improved:
|
||||||
|
1. MII, WOL functions are not adequately defined and used.
|
||||||
|
2. Link status report does not work well.
|
||||||
|
3. Ethernet address can not be modified at present.
|
||||||
|
4. Programming PHY registers and EEPROM are not adequately used.
|
||||||
|
5. Dump interfaces are not provided.
|
||||||
807
minix/drivers/net/vt6105/vt6105.c
Normal file
807
minix/drivers/net/vt6105/vt6105.c
Normal file
|
|
@ -0,0 +1,807 @@
|
||||||
|
#include "vt6105.h"
|
||||||
|
|
||||||
|
/* global value */
|
||||||
|
static vt_driver g_driver;
|
||||||
|
static int g_instance;
|
||||||
|
|
||||||
|
/* I/O function */
|
||||||
|
static u8_t my_inb(u16_t port) {
|
||||||
|
u32_t value;
|
||||||
|
int r;
|
||||||
|
if ((r = sys_inb(port, &value)) != OK)
|
||||||
|
printf("VT6105: sys_inb failed: %d\n", r);
|
||||||
|
return (u8_t)value;
|
||||||
|
}
|
||||||
|
#define vt_inb(port, offset) (my_inb((port) + (offset)))
|
||||||
|
|
||||||
|
static u16_t my_inw(u16_t port) {
|
||||||
|
u32_t value;
|
||||||
|
int r;
|
||||||
|
if ((r = sys_inw(port, &value)) != OK)
|
||||||
|
printf("VT6105: sys_inw failed: %d\n", r);
|
||||||
|
return (u16_t)value;
|
||||||
|
}
|
||||||
|
#define vt_inw(port, offset) (my_inw((port) + (offset)))
|
||||||
|
|
||||||
|
static u32_t my_inl(u16_t port) {
|
||||||
|
u32_t value;
|
||||||
|
int r;
|
||||||
|
if ((r = sys_inl(port, &value)) != OK)
|
||||||
|
printf("VT6105: sys_inl failed: %d\n", r);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
#define vt_inl(port, offset) (my_inl((port) + (offset)))
|
||||||
|
|
||||||
|
static void my_outb(u16_t port, u8_t value) {
|
||||||
|
int r;
|
||||||
|
if ((r = sys_outb(port, value)) != OK)
|
||||||
|
printf("VT6105: sys_outb failed: %d\n", r);
|
||||||
|
}
|
||||||
|
#define vt_outb(port, offset, value) (my_outb((port) + (offset), (value)))
|
||||||
|
|
||||||
|
static void my_outw(u16_t port, u16_t value) {
|
||||||
|
int r;
|
||||||
|
if ((r = sys_outw(port, value)) != OK)
|
||||||
|
printf("VT6105: sys_outw failed: %d\n", r);
|
||||||
|
}
|
||||||
|
#define vt_outw(port, offset, value) (my_outw((port) + (offset), (value)))
|
||||||
|
|
||||||
|
static void my_outl(u16_t port, u32_t value) {
|
||||||
|
int r;
|
||||||
|
if ((r = sys_outl(port, value)) != OK)
|
||||||
|
printf("VT6105: sys_outl failed: %d\n", r);
|
||||||
|
}
|
||||||
|
#define vt_outl(port, offset, value) (my_outl((port) + (offset), (value)))
|
||||||
|
|
||||||
|
/* driver interface */
|
||||||
|
static int vt_init(unsigned int instance, ether_addr_t *addr);
|
||||||
|
static void vt_stop(void);
|
||||||
|
static void vt_mode(unsigned int mode);
|
||||||
|
static ssize_t vt_recv(struct netdriver_data *data, size_t max);
|
||||||
|
static int vt_send(struct netdriver_data *data, size_t size);
|
||||||
|
static void vt_intr(unsigned int mask);
|
||||||
|
static void vt_stat(eth_stat_t *stat);
|
||||||
|
static void vt_alarm(clock_t stamp);
|
||||||
|
|
||||||
|
static int vt_probe(vt_driver *pdev, int instance);
|
||||||
|
static int vt_init_buf(vt_driver *pdev);
|
||||||
|
static int vt_init_hw(vt_driver *pdev, ether_addr_t *addr);
|
||||||
|
static void vt_reset_hw(vt_driver *pdev);
|
||||||
|
static void vt_power_init(vt_driver *pdev);
|
||||||
|
static void vt_conf_addr(vt_driver *pdev, ether_addr_t *addr);
|
||||||
|
static void vt_check_link(vt_driver *pdev);
|
||||||
|
static void vt_handler(vt_driver *pdev);
|
||||||
|
static void vt_check_ints(vt_driver *pdev);
|
||||||
|
|
||||||
|
static const struct netdriver vt_table = {
|
||||||
|
.ndr_init = vt_init,
|
||||||
|
.ndr_stop = vt_stop,
|
||||||
|
.ndr_mode = vt_mode,
|
||||||
|
.ndr_recv = vt_recv,
|
||||||
|
.ndr_send = vt_send,
|
||||||
|
.ndr_stat = vt_stat,
|
||||||
|
.ndr_intr = vt_intr,
|
||||||
|
.ndr_alarm = vt_alarm
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
env_setargs(argc, argv);
|
||||||
|
netdriver_task(&vt_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the driver */
|
||||||
|
static int vt_init(unsigned int instance, ether_addr_t *addr) {
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
/* Intialize driver data structure */
|
||||||
|
memset(&g_driver, 0, sizeof(g_driver));
|
||||||
|
g_driver.vt_link = VT_LINK_UNKNOWN;
|
||||||
|
strcpy(g_driver.vt_name, "vt6105#0");
|
||||||
|
g_driver.vt_name[7] += instance;
|
||||||
|
g_instance = instance;
|
||||||
|
|
||||||
|
/* Probe the device */
|
||||||
|
if (vt_probe(&g_driver, instance)) {
|
||||||
|
printf("VT6105: Device is not found!\n");
|
||||||
|
ret = -ENODEV;
|
||||||
|
goto err_probe;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate and initialize buffer */
|
||||||
|
if (vt_init_buf(&g_driver)) {
|
||||||
|
printf("VT6105: Device is not found!\n");
|
||||||
|
ret = -ENODEV;
|
||||||
|
goto err_init_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Intialize hardware */
|
||||||
|
if (vt_init_hw(&g_driver, addr)) {
|
||||||
|
printf("VT6105: Find to initialize hardware!\n");
|
||||||
|
ret = -EIO;
|
||||||
|
goto err_init_hw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use a synchronous alarm instead of a watchdog timer */
|
||||||
|
sys_setalarm(sys_hz(), 0);
|
||||||
|
|
||||||
|
/* Clear send and recv flag */
|
||||||
|
g_driver.vt_send_flag = FALSE;
|
||||||
|
g_driver.vt_recv_flag = FALSE;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_init_hw:
|
||||||
|
free_contig(g_driver.vt_buf, g_driver.vt_buf_size);
|
||||||
|
err_init_buf:
|
||||||
|
err_probe:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Match the device and get base address */
|
||||||
|
static int vt_probe(vt_driver *pdev, int instance) {
|
||||||
|
int devind;
|
||||||
|
u16_t cr, vid, did;
|
||||||
|
u32_t bar;
|
||||||
|
u8_t irq, rev;
|
||||||
|
|
||||||
|
/* Find pci device */
|
||||||
|
pci_init();
|
||||||
|
if (!pci_first_dev(&devind, &vid, &did))
|
||||||
|
return -EIO;
|
||||||
|
while (instance--) {
|
||||||
|
if (!pci_next_dev(&devind, &vid, &did))
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
pci_reserve(devind);
|
||||||
|
|
||||||
|
/* Enable bus mastering */
|
||||||
|
cr = pci_attr_r16(devind, PCI_CR);
|
||||||
|
if (!(cr & PCI_CR_MAST_EN))
|
||||||
|
pci_attr_w16(devind, PCI_CR, cr | PCI_CR_MAST_EN);
|
||||||
|
|
||||||
|
/* Get base address */
|
||||||
|
bar = pci_attr_r32(devind, PCI_BAR) & 0xffffffe0;
|
||||||
|
if (bar < 0x400) {
|
||||||
|
printf("VT6105: base address is not properly configured!\n");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
pdev->vt_base_addr = bar;
|
||||||
|
|
||||||
|
/* Get irq number */
|
||||||
|
irq = pci_attr_r8(devind, PCI_ILR);
|
||||||
|
pdev->vt_irq = irq;
|
||||||
|
|
||||||
|
/* Get revision ID */
|
||||||
|
rev = pci_attr_r8(devind, PCI_REV);
|
||||||
|
pdev->vt_revision = rev;
|
||||||
|
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Base address is 0x%08x\n", pdev->vt_base_addr);
|
||||||
|
printf("VT6105: IRQ number is 0x%08x\n", pdev->vt_irq);
|
||||||
|
printf("VT6105: Revision ID is 0x%08x\n", pdev->vt_revision);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate and initialize buffer */
|
||||||
|
static int vt_init_buf(vt_driver *pdev) {
|
||||||
|
size_t rx_desc_size, tx_desc_size, rx_buf_size, tx_buf_size, tot_buf_size;
|
||||||
|
vt_desc *desc;
|
||||||
|
phys_bytes buf_dma, next;
|
||||||
|
char *buf;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Build Rx and Tx descriptor buffer */
|
||||||
|
rx_desc_size = VT_RX_DESC_NUM * sizeof(vt_desc);
|
||||||
|
tx_desc_size = VT_TX_DESC_NUM * sizeof(vt_desc);
|
||||||
|
|
||||||
|
/* Allocate Rx and Tx buffer */
|
||||||
|
tx_buf_size = VT_TX_BUF_SIZE;
|
||||||
|
if (tx_buf_size % 4)
|
||||||
|
tx_buf_size += 4 - (tx_buf_size % 4);
|
||||||
|
rx_buf_size = VT_RX_BUF_SIZE;
|
||||||
|
tot_buf_size = rx_desc_size + tx_desc_size;
|
||||||
|
tot_buf_size += VT_TX_DESC_NUM * tx_buf_size + VT_RX_DESC_NUM * rx_buf_size;
|
||||||
|
if (tot_buf_size % 4096)
|
||||||
|
tot_buf_size += 4096 - (tot_buf_size % 4096);
|
||||||
|
|
||||||
|
if (!(buf = alloc_contig(tot_buf_size, 0, &buf_dma))) {
|
||||||
|
printf("VT6105: Fail to allocate memory!\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
pdev->vt_buf_size = tot_buf_size;
|
||||||
|
pdev->vt_buf = buf;
|
||||||
|
|
||||||
|
/* Rx descriptor */
|
||||||
|
pdev->vt_rx_desc = (vt_desc *)buf;
|
||||||
|
pdev->vt_rx_desc_dma = buf_dma;
|
||||||
|
memset(buf, 0, rx_desc_size);
|
||||||
|
buf += rx_desc_size;
|
||||||
|
buf_dma += rx_desc_size;
|
||||||
|
|
||||||
|
/* Tx descriptor */
|
||||||
|
pdev->vt_tx_desc = (vt_desc *)buf;
|
||||||
|
pdev->vt_tx_desc_dma = buf_dma;
|
||||||
|
memset(buf, 0, tx_desc_size);
|
||||||
|
buf += tx_desc_size;
|
||||||
|
buf_dma += tx_desc_size;
|
||||||
|
|
||||||
|
/* Rx buffer assignment */
|
||||||
|
desc = pdev->vt_rx_desc;
|
||||||
|
next = pdev->vt_rx_desc_dma;
|
||||||
|
for (i = 0; i < VT_RX_DESC_NUM; i++) {
|
||||||
|
/* Set Rx buffer */
|
||||||
|
pdev->vt_rx[i].buf_dma = buf_dma;
|
||||||
|
pdev->vt_rx[i].buf = buf;
|
||||||
|
buf_dma += rx_buf_size;
|
||||||
|
buf += rx_buf_size;
|
||||||
|
|
||||||
|
/* Set Rx descriptor */
|
||||||
|
desc->status = VT_DESC_OWN |
|
||||||
|
((VT_RX_BUF_SIZE << 16) & VT_DESC_RX_LENMASK);
|
||||||
|
desc->addr = pdev->vt_rx[i].buf_dma;
|
||||||
|
desc->length = VT_RX_BUF_SIZE;
|
||||||
|
if (i == (VT_RX_DESC_NUM - 1))
|
||||||
|
desc->next_desc = pdev->vt_rx_desc_dma;
|
||||||
|
else {
|
||||||
|
next += sizeof(vt_desc);
|
||||||
|
desc->next_desc = next;
|
||||||
|
desc++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tx buffer assignment */
|
||||||
|
desc = pdev->vt_tx_desc;
|
||||||
|
next = pdev->vt_tx_desc_dma;
|
||||||
|
for (i = 0; i < VT_TX_DESC_NUM; i++) {
|
||||||
|
/* Set Tx buffer */
|
||||||
|
pdev->vt_tx[i].busy = 0;
|
||||||
|
pdev->vt_tx[i].buf_dma = buf_dma;
|
||||||
|
pdev->vt_tx[i].buf = buf;
|
||||||
|
buf_dma += tx_buf_size;
|
||||||
|
buf += tx_buf_size;
|
||||||
|
|
||||||
|
/* Set Rx descriptor */
|
||||||
|
desc->addr = pdev->vt_tx[i].buf_dma;
|
||||||
|
desc->length = VT_TX_BUF_SIZE;
|
||||||
|
if (i == (VT_TX_DESC_NUM - 1))
|
||||||
|
desc->next_desc = pdev->vt_tx_desc_dma;
|
||||||
|
else {
|
||||||
|
next += sizeof(vt_desc);
|
||||||
|
desc->next_desc = next;
|
||||||
|
desc++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pdev->vt_tx_busy_num = 0;
|
||||||
|
pdev->vt_tx_head = 0;
|
||||||
|
pdev->vt_tx_tail = 0;
|
||||||
|
pdev->vt_rx_head = 0;
|
||||||
|
pdev->vt_tx_alive = FALSE;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Intialize hardware */
|
||||||
|
static int vt_init_hw(vt_driver *pdev, ether_addr_t *addr) {
|
||||||
|
int r, ret;
|
||||||
|
|
||||||
|
/* Set the interrupt handler */
|
||||||
|
pdev->vt_hook = pdev->vt_irq;
|
||||||
|
if ((r = sys_irqsetpolicy(pdev->vt_irq, 0, &pdev->vt_hook)) != OK) {
|
||||||
|
printf("VT6105: Fail to set IRQ policy: %d!\n", r);
|
||||||
|
ret = -EFAULT;
|
||||||
|
goto err_irq_policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset hardware */
|
||||||
|
vt_reset_hw(pdev);
|
||||||
|
|
||||||
|
/* Enable IRQ */
|
||||||
|
if ((r = sys_irqenable(&pdev->vt_hook)) != OK) {
|
||||||
|
printf("VT6105: Fail to enable IRQ: %d!\n", r);
|
||||||
|
ret = -EFAULT;
|
||||||
|
goto err_irq_enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Configure MAC address */
|
||||||
|
vt_conf_addr(pdev, addr);
|
||||||
|
|
||||||
|
/* Detect link status */
|
||||||
|
vt_check_link(pdev);
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
if (pdev->vt_link)
|
||||||
|
printf("VT6105: Link up!\n");
|
||||||
|
else
|
||||||
|
printf("VT6105: Link down!\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_irq_enable:
|
||||||
|
err_irq_policy:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset hardware */
|
||||||
|
static void vt_reset_hw(vt_driver *pdev) {
|
||||||
|
u16_t base = pdev->vt_base_addr;
|
||||||
|
u8_t db;
|
||||||
|
u16_t dw;
|
||||||
|
u32_t dl;
|
||||||
|
|
||||||
|
/* Let power registers into sane state */
|
||||||
|
vt_power_init(pdev);
|
||||||
|
|
||||||
|
/* Reset the chip */
|
||||||
|
vt_outw(base, VT_REG_CR, VT_CMD_RESET);
|
||||||
|
vt_inb(base, VT_REG_ADDR);
|
||||||
|
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
if (vt_inw(base, VT_REG_CR) & VT_CMD_RESET) {
|
||||||
|
vt_outb(base, VT_REG_MCR1, 0x40);
|
||||||
|
usleep(100000);
|
||||||
|
if (vt_inw(base, VT_REG_CR) & VT_CMD_RESET)
|
||||||
|
printf("VT6105: Fail to completely reset!\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("VT6105: Reset successfully!\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initialize regsiters */
|
||||||
|
vt_outw(base, VT_REG_BCR0, 0x0006);
|
||||||
|
vt_outb(base, VT_REG_TCR, 0x20); /* Tx threshold is 256 bytes */
|
||||||
|
vt_outb(base, VT_REG_RCR, 0x78); /* Rx threshold is 256 bytes */
|
||||||
|
vt_outl(base, VT_REG_RD_BASE, pdev->vt_rx_desc_dma); /* Set Rx descriptor base address */
|
||||||
|
vt_outl(base, VT_REG_TD_BASE, pdev->vt_tx_desc_dma); /* Set Tx descriptor base address */
|
||||||
|
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
dl = vt_inl(base, VT_REG_RD_BASE);
|
||||||
|
printf("VT6105: Rx descriptor DMA address is: 0x%08x\n", dl);
|
||||||
|
dl = vt_inl(base, VT_REG_TD_BASE);
|
||||||
|
printf("VT6105: Tx descriptor DMA address is: 0x%08x\n", dl);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Enable interrupts */
|
||||||
|
vt_outw(base, VT_REG_IMR, 0xfeff);
|
||||||
|
|
||||||
|
/* Start the device, Rx and Tx */
|
||||||
|
dw = VT_CMD_START | VT_CMD_RX_ON | VT_CMD_TX_ON | VT_CMD_NO_POLL | VT_CMD_FDUPLEX;
|
||||||
|
vt_outw(base, VT_REG_CR, dw);
|
||||||
|
dw = vt_inw(base, VT_REG_CR);
|
||||||
|
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
dw = vt_inw(base, VT_REG_CR);
|
||||||
|
printf("VT6105: Control status is 0x%04x\n", dw);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize power registers */
|
||||||
|
static void vt_power_init(vt_driver *pdev) {
|
||||||
|
u8_t db, wolstat;
|
||||||
|
u16_t dw, base = pdev->vt_base_addr;
|
||||||
|
u32_t dl;
|
||||||
|
|
||||||
|
/* Make sure chip is in power state D0 */
|
||||||
|
db = vt_inb(base, VT_REG_STICK);
|
||||||
|
vt_outb(base, VT_REG_STICK, db & 0xfc);
|
||||||
|
|
||||||
|
/* Disable "force PME-enable" */
|
||||||
|
vt_outb(base, VT_REG_WOLC_SET, 0x80);
|
||||||
|
|
||||||
|
/* Clear power-event config bits (WOL) */
|
||||||
|
vt_outb(base, VT_REG_WOL_SET, 0xff);
|
||||||
|
|
||||||
|
/* Save power-event status bits */
|
||||||
|
wolstat = vt_inb(base, VT_REG_WOLS_SET);
|
||||||
|
|
||||||
|
/* Clear power-event status bits */
|
||||||
|
vt_outb(base, VT_REG_WOLS_CLR, 0xff);
|
||||||
|
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
if (wolstat) {
|
||||||
|
char reason[50];
|
||||||
|
switch (wolstat) {
|
||||||
|
case VT_WOL_MAGIC:
|
||||||
|
strcpy(reason, "Magic packet");
|
||||||
|
break;
|
||||||
|
case VT_WOL_LINK_UP:
|
||||||
|
strcpy(reason, "Link up");
|
||||||
|
break;
|
||||||
|
case VT_WOL_LINK_DOWN:
|
||||||
|
strcpy(reason, "Link down");
|
||||||
|
break;
|
||||||
|
case VT_WOL_UCAST:
|
||||||
|
strcpy(reason, "Unicast packet");
|
||||||
|
break;
|
||||||
|
case VT_WOL_MCAST:
|
||||||
|
strcpy(reason, "Multicast/Broadcast packet");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strcpy(reason, "Unknown");
|
||||||
|
}
|
||||||
|
printf("VT6105: Wake system up: %s\n", reason);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vt_conf_addr(vt_driver *pdev, ether_addr_t *addr) {
|
||||||
|
u16_t dw, base = pdev->vt_base_addr;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i<6; i++)
|
||||||
|
addr->ea_addr[i] = vt_inb(base, VT_REG_ADDR + i);
|
||||||
|
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Ethernet address is %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
|
addr->ea_addr[0], addr->ea_addr[1], addr->ea_addr[2],
|
||||||
|
addr->ea_addr[3], addr->ea_addr[4], addr->ea_addr[5]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Detect link status (MII interface) */
|
||||||
|
static void vt_check_link(vt_driver *pdev) {
|
||||||
|
u16_t base = pdev->vt_base_addr;
|
||||||
|
u32_t res;
|
||||||
|
|
||||||
|
vt_outb(base, VT_REG_MII_CFG, 0x01);
|
||||||
|
vt_outb(base, VT_REG_MII_ADDR, 0x01);
|
||||||
|
vt_outb(base, VT_REG_MII_CR, 0x40);
|
||||||
|
usleep(10000);
|
||||||
|
res = vt_inw(base, VT_REG_MII_DATA);
|
||||||
|
if (res & 0x0004)
|
||||||
|
pdev->vt_link = TRUE;
|
||||||
|
else
|
||||||
|
pdev->vt_link = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stop the driver */
|
||||||
|
static void vt_stop(void) {
|
||||||
|
u16_t base = g_driver.vt_base_addr;
|
||||||
|
|
||||||
|
/* Free Rx and Tx buffer*/
|
||||||
|
free_contig(g_driver.vt_buf, g_driver.vt_buf_size);
|
||||||
|
|
||||||
|
/* Stop IRQ and device */
|
||||||
|
vt_outw(base, VT_REG_IMR, 0x0000);
|
||||||
|
vt_outw(base, VT_REG_CR, VT_CMD_STOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set driver mode */
|
||||||
|
static void vt_mode(unsigned int mode) {
|
||||||
|
vt_driver *pdev = &g_driver;
|
||||||
|
u16_t base = pdev->vt_base_addr;
|
||||||
|
u8_t rcr;
|
||||||
|
|
||||||
|
pdev->vt_mode = mode;
|
||||||
|
vt_outl(base, VT_REG_MAR0, 0xffffffff);
|
||||||
|
vt_outl(base, VT_REG_MAR1, 0xffffffff);
|
||||||
|
|
||||||
|
rcr = vt_inb(base, VT_REG_RCR);
|
||||||
|
rcr &= ~(VT_RCR_AB | VT_RCR_AM | VT_RCR_AP | VT_RCR_AE | VT_RCR_AR);
|
||||||
|
if (pdev->vt_mode & NDEV_PROMISC)
|
||||||
|
rcr |= VT_RCR_AB | VT_RCR_AM | VT_RCR_AE | VT_RCR_AR;
|
||||||
|
if (pdev->vt_mode & NDEV_BROAD)
|
||||||
|
rcr |= VT_RCR_AB;
|
||||||
|
if (pdev->vt_mode & NDEV_MULTI)
|
||||||
|
rcr |= VT_RCR_AM;
|
||||||
|
rcr |= VT_RCR_AP;
|
||||||
|
vt_outb(base, VT_REG_RCR, 0x60 | rcr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Receive data */
|
||||||
|
static ssize_t vt_recv(struct netdriver_data *data, size_t max) {
|
||||||
|
vt_driver *pdev = &g_driver;
|
||||||
|
u32_t rxstat, totlen, packlen;
|
||||||
|
vt_desc *desc;
|
||||||
|
int index, i;
|
||||||
|
|
||||||
|
index = pdev->vt_rx_head;
|
||||||
|
desc = pdev->vt_rx_desc;
|
||||||
|
desc += index;
|
||||||
|
|
||||||
|
/* Manage Rx buffer */
|
||||||
|
for (;;) {
|
||||||
|
rxstat = desc->status;
|
||||||
|
|
||||||
|
if (rxstat & VT_DESC_OWN)
|
||||||
|
return SUSPEND;
|
||||||
|
|
||||||
|
if (rxstat & VT_DESC_RX_ALL_ERR) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Rx error: 0x%08x\n", rxstat);
|
||||||
|
#endif
|
||||||
|
if (rxstat & VT_DESC_RX_FOV) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Rx buffer overflow\n");
|
||||||
|
#endif
|
||||||
|
pdev->vt_stat.ets_fifoOver++;
|
||||||
|
}
|
||||||
|
if (rxstat & VT_DESC_RX_FAE) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Rx frames not align\n");
|
||||||
|
#endif
|
||||||
|
pdev->vt_stat.ets_frameAll++;
|
||||||
|
}
|
||||||
|
if (rxstat & VT_DESC_RX_CRCE) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Rx CRC error\n");
|
||||||
|
#endif
|
||||||
|
pdev->vt_stat.ets_CRCerr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Normal packet */
|
||||||
|
if ((rxstat & VT_DESC_RX_PACK) == VT_DESC_RX_PACK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Other packet */
|
||||||
|
if (index == VT_RX_DESC_NUM - 1) {
|
||||||
|
desc->status = VT_DESC_OWN |
|
||||||
|
((VT_RX_BUF_SIZE << 16) & VT_DESC_RX_LENMASK);
|
||||||
|
index = 0;
|
||||||
|
desc = pdev->vt_rx_desc;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
desc->status = VT_DESC_OWN |
|
||||||
|
((VT_RX_BUF_SIZE << 16) & VT_DESC_RX_LENMASK);
|
||||||
|
index++;
|
||||||
|
desc++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get data length */
|
||||||
|
totlen = (rxstat & VT_DESC_RX_LENMASK) >> 16;
|
||||||
|
if (totlen < 8 || totlen > 2 * ETH_MAX_PACK_SIZE) {
|
||||||
|
printf("VT6105: Bad data length: %d\n", totlen);
|
||||||
|
panic(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Substract CRC to get packet */
|
||||||
|
packlen = totlen - ETH_CRC_SIZE;
|
||||||
|
if (packlen > max)
|
||||||
|
packlen = max;
|
||||||
|
|
||||||
|
/* Copy data to user */
|
||||||
|
netdriver_copyout(data, 0, pdev->vt_rx[index].buf, packlen);
|
||||||
|
pdev->vt_stat.ets_packetR++;
|
||||||
|
|
||||||
|
/* Set Rx descriptor status */
|
||||||
|
if (index == VT_RX_DESC_NUM - 1) {
|
||||||
|
desc->status = VT_DESC_OWN |
|
||||||
|
((VT_RX_BUF_SIZE << 16) & VT_DESC_RX_LENMASK);
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
desc->status = VT_DESC_OWN |
|
||||||
|
((VT_RX_BUF_SIZE << 16) & VT_DESC_RX_LENMASK);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
pdev->vt_rx_head = index;
|
||||||
|
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Successfully receive a packet, length = %d\n", packlen);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return packlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transmit data */
|
||||||
|
static int vt_send(struct netdriver_data *data, size_t size) {
|
||||||
|
vt_driver *pdev = &g_driver;
|
||||||
|
vt_desc *desc;
|
||||||
|
int tx_head, i;
|
||||||
|
u8_t db;
|
||||||
|
u16_t base = pdev->vt_base_addr;
|
||||||
|
|
||||||
|
tx_head = pdev->vt_tx_head;
|
||||||
|
desc = pdev->vt_tx_desc;
|
||||||
|
desc += tx_head;
|
||||||
|
|
||||||
|
if (pdev->vt_tx[tx_head].busy)
|
||||||
|
return SUSPEND;
|
||||||
|
|
||||||
|
/* Copy data from user */
|
||||||
|
netdriver_copyin(data, 0, pdev->vt_tx[tx_head].buf, size);
|
||||||
|
|
||||||
|
/* Set busy */
|
||||||
|
pdev->vt_tx[tx_head].busy = TRUE;
|
||||||
|
pdev->vt_tx_busy_num++;
|
||||||
|
|
||||||
|
/* Set Tx descriptor status */
|
||||||
|
desc->status = VT_DESC_OWN | VT_DESC_FIRST | VT_DESC_LAST;
|
||||||
|
desc->length = 0x00e08000 | (size >= 60 ? size : 60);
|
||||||
|
if (tx_head == VT_TX_DESC_NUM - 1)
|
||||||
|
tx_head = 0;
|
||||||
|
else
|
||||||
|
tx_head++;
|
||||||
|
pdev->vt_tx_head = tx_head;
|
||||||
|
|
||||||
|
/* Wake up transmit channel */
|
||||||
|
db = vt_inb(base, VT_REG_CR);
|
||||||
|
db |= VT_CMD_TX_DEMAND;
|
||||||
|
vt_outb(base, VT_REG_CR, db);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle Interrupt */
|
||||||
|
static void vt_intr(unsigned int mask) {
|
||||||
|
int s;
|
||||||
|
|
||||||
|
/* Run interrupt handler at driver level */
|
||||||
|
vt_handler(&g_driver);
|
||||||
|
|
||||||
|
/* Reenable interrupts for this hook */
|
||||||
|
if ((s = sys_irqenable(&g_driver.vt_hook)) != OK)
|
||||||
|
printf("VT6105: Cannot enable interrupts: %d\n", s);
|
||||||
|
|
||||||
|
/* Perform tasks based on the flagged conditions */
|
||||||
|
vt_check_ints(&g_driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Real handler interrupt */
|
||||||
|
static void vt_handler(vt_driver *pdev) {
|
||||||
|
u16_t base = pdev->vt_base_addr;
|
||||||
|
int intr_status;
|
||||||
|
u8_t db;
|
||||||
|
u16_t dw;
|
||||||
|
u32_t dl, txstat;
|
||||||
|
int flag = 0, tx_head, tx_tail;
|
||||||
|
vt_desc *desc;
|
||||||
|
|
||||||
|
/* Get interrupt status */
|
||||||
|
intr_status = vt_inw(base, VT_REG_ISR);
|
||||||
|
|
||||||
|
/* Clear interrupt */
|
||||||
|
dw = intr_status & ~(VT_INTR_PCI_ERR | VT_INTR_PORT_CHANGE);
|
||||||
|
vt_outw(base, VT_REG_ISR, dw);
|
||||||
|
|
||||||
|
/* Check link status */
|
||||||
|
if (intr_status & VT_INTR_PORT_CHANGE)
|
||||||
|
printf("VT6105: Port state change!\n");
|
||||||
|
|
||||||
|
/* Check interrupt status */
|
||||||
|
if (intr_status & VT_INTR_RX_DONE) {
|
||||||
|
pdev->vt_recv_flag = TRUE;
|
||||||
|
flag++;
|
||||||
|
|
||||||
|
if (intr_status & VT_INTR_RX_ERR) {
|
||||||
|
pdev->vt_stat.ets_recvErr++;
|
||||||
|
printf("VT6105: Rx error in interrupt: 0x%04x\n", intr_status);
|
||||||
|
}
|
||||||
|
if (intr_status & VT_INTR_RX_NOBUF)
|
||||||
|
printf("VT6105: Rx no buffer in interrupt: 0x%04x\n", intr_status);
|
||||||
|
if (intr_status & VT_INTR_RX_EMPTY)
|
||||||
|
printf("VT6105: Rx buffer empty in interrupt: 0x%04x\n", intr_status);
|
||||||
|
if (intr_status & VT_INTR_RX_OVERFLOW)
|
||||||
|
printf("VT6105: Rx buffer overflow in interrupt: 0x%04x\n", intr_status);
|
||||||
|
if (intr_status & VT_INTR_RX_DROPPED)
|
||||||
|
printf("VT6105: Rx buffer dropped in interrupt: 0x%04x\n", intr_status);
|
||||||
|
}
|
||||||
|
if (intr_status & VT_INTR_TX_DONE) {
|
||||||
|
pdev->vt_send_flag = TRUE;
|
||||||
|
flag++;
|
||||||
|
|
||||||
|
if (intr_status & VT_INTR_TX_ERR) {
|
||||||
|
pdev->vt_stat.ets_sendErr++;
|
||||||
|
printf("VT6105: Tx error in interrupt: 0x%04x\n", intr_status);
|
||||||
|
}
|
||||||
|
if (intr_status & VT_INTR_TX_UNDER_RUN)
|
||||||
|
printf("VT6105: Tx buffer underflow in interrupt: 0x%04x\n", intr_status);
|
||||||
|
if (intr_status & VT_INTR_TX_ABORT)
|
||||||
|
printf("VT6105: Tx abort in interrupt: 0x%04x\n", intr_status);
|
||||||
|
|
||||||
|
/* Manage Tx Buffer */
|
||||||
|
tx_head = pdev->vt_tx_head;
|
||||||
|
tx_tail = pdev->vt_tx_tail;
|
||||||
|
while (tx_tail != tx_head) {
|
||||||
|
desc = pdev->vt_tx_desc;
|
||||||
|
desc += tx_tail;
|
||||||
|
if (!pdev->vt_tx[tx_tail].busy)
|
||||||
|
printf("VT6105: Strange, buffer not busy?\n");
|
||||||
|
txstat = desc->status;
|
||||||
|
|
||||||
|
/* Check whether the buffer is ready */
|
||||||
|
if (txstat & VT_DESC_OWN) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (txstat & VT_DESC_TX_ERR) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Tx error: 0x%08x\n", txstat);
|
||||||
|
#endif
|
||||||
|
if (txstat & VT_DESC_TX_UDF) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Tx buffer underflow\n");
|
||||||
|
#endif
|
||||||
|
pdev->vt_stat.ets_fifoUnder++;
|
||||||
|
}
|
||||||
|
if (txstat & VT_DESC_TX_CRS) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Tx carrier sense lost\n");
|
||||||
|
#endif
|
||||||
|
pdev->vt_stat.ets_carrSense++;
|
||||||
|
}
|
||||||
|
if (txstat & VT_DESC_TX_CDH) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Tx collision detect\n");
|
||||||
|
#endif
|
||||||
|
pdev->vt_stat.ets_collision++;
|
||||||
|
}
|
||||||
|
if (txstat & VT_DESC_TX_OWC) {
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Tx buffer out of winidow\n");
|
||||||
|
#endif
|
||||||
|
pdev->vt_stat.ets_OWC++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pdev->vt_stat.ets_packetT++;
|
||||||
|
pdev->vt_tx[tx_tail].busy = FALSE;
|
||||||
|
pdev->vt_tx_busy_num--;
|
||||||
|
|
||||||
|
if (++tx_tail >= VT_TX_DESC_NUM)
|
||||||
|
tx_tail = 0;
|
||||||
|
|
||||||
|
pdev->vt_send_flag = TRUE;
|
||||||
|
pdev->vt_recv_flag = TRUE;
|
||||||
|
pdev->vt_tx_alive = TRUE;
|
||||||
|
|
||||||
|
#ifdef VT6105_DEBUG
|
||||||
|
printf("VT6105: Successfully send a packet\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
pdev->vt_tx_tail = tx_tail;
|
||||||
|
}
|
||||||
|
if (!flag) {
|
||||||
|
printf("VT6105: Unknown error in interrupt: 0x%04x\n", intr_status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform tasks based on the flagged condition */
|
||||||
|
vt_check_ints(pdev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check interrupt and perform */
|
||||||
|
static void vt_check_ints(vt_driver *pdev) {
|
||||||
|
if (!pdev->vt_recv_flag)
|
||||||
|
return;
|
||||||
|
pdev->vt_recv_flag = FALSE;
|
||||||
|
|
||||||
|
/* Handle data receive */
|
||||||
|
netdriver_recv();
|
||||||
|
|
||||||
|
/* Handle data transmit */
|
||||||
|
if (pdev->vt_send_flag) {
|
||||||
|
pdev->vt_send_flag = FALSE;
|
||||||
|
netdriver_send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vt_stat(eth_stat_t *stat) {
|
||||||
|
memcpy(stat, &g_driver.vt_stat, sizeof(*stat));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vt_alarm(clock_t stamp) {
|
||||||
|
vt_driver *pdev = &g_driver;
|
||||||
|
|
||||||
|
/* Use a synchronous alarm instead of a watchdog timer */
|
||||||
|
sys_setalarm(sys_hz(), 0);
|
||||||
|
|
||||||
|
/* Assume the an idle system is alive */
|
||||||
|
if (!pdev->vt_tx_busy_num) {
|
||||||
|
pdev->vt_tx_alive = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pdev->vt_tx_alive) {
|
||||||
|
pdev->vt_tx_alive = FALSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("VT6105: Resetting the driver\n");
|
||||||
|
vt_reset_hw(pdev);
|
||||||
|
pdev->vt_recv_flag = TRUE;
|
||||||
|
|
||||||
|
vt_check_ints(pdev);
|
||||||
|
}
|
||||||
16
minix/drivers/net/vt6105/vt6105.conf
Executable file
16
minix/drivers/net/vt6105/vt6105.conf
Executable file
|
|
@ -0,0 +1,16 @@
|
||||||
|
service vt6105
|
||||||
|
{
|
||||||
|
type net;
|
||||||
|
descr "VIA Technology 6105/6106S Ethernet Card";
|
||||||
|
system
|
||||||
|
UMAP # 14
|
||||||
|
IRQCTL # 19
|
||||||
|
DEVIO # 21
|
||||||
|
;
|
||||||
|
pci device 1106:3053;
|
||||||
|
pci device 1106:3106;
|
||||||
|
ipc
|
||||||
|
SYSTEM pm rs log tty ds vm
|
||||||
|
pci inet lwip amddev
|
||||||
|
;
|
||||||
|
};
|
||||||
194
minix/drivers/net/vt6105/vt6105.h
Normal file
194
minix/drivers/net/vt6105/vt6105.h
Normal file
|
|
@ -0,0 +1,194 @@
|
||||||
|
#include <minix/drivers.h>
|
||||||
|
#include <minix/netdriver.h>
|
||||||
|
#include <machine/pci.h>
|
||||||
|
#include <minix/ds.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
/* PCI Register */
|
||||||
|
#define VT_PCI_VID 0x00 /* Vendor ID */
|
||||||
|
#define VT_PCI_DID 0x02 /* Device ID */
|
||||||
|
#define VT_PCI_CMD 0x04 /* Command */
|
||||||
|
#define VT_PCI_STS 0x06 /* Status */
|
||||||
|
#define VT_PCI_RID 0x08 /* Revision ID */
|
||||||
|
#define VT_PCI_CC 0x09 /* Class Code */
|
||||||
|
#define VT_PCI_CLS 0x0c /* Cache Line Size */
|
||||||
|
#define VT_PCI_LT 0x0d /* Latency Timer */
|
||||||
|
#define VT_PCI_HT 0x0e /* Header Type */
|
||||||
|
|
||||||
|
/* Internal Register */
|
||||||
|
#define VT_REG_ADDR 0x00 /* Ethernet Address */
|
||||||
|
#define VT_REG_RCR 0x06 /* Receive Configure Request */
|
||||||
|
#define VT_REG_TCR 0x07 /* Transmit Configure Request */
|
||||||
|
#define VT_REG_CR 0x08 /* Control 0 */
|
||||||
|
#define VT_REG_ISR 0x0c /* Interrupt Status */
|
||||||
|
#define VT_REG_IMR 0x0e /* Interrupt Mask */
|
||||||
|
#define VT_REG_MAR0 0x10 /* Multicast Address 0 */
|
||||||
|
#define VT_REG_MAR1 0x14 /* Multicast Address 1 */
|
||||||
|
#define VT_REG_RD_BASE 0x18 /* Receive Descriptor Base Address */
|
||||||
|
#define VT_REG_TD_BASE 0x1c /* Transmit Descriptor Base Address */
|
||||||
|
#define VT_REG_MII_CFG 0x6c /* MII Configuration */
|
||||||
|
#define VT_REG_MII_STS 0x6d /* MII Status */
|
||||||
|
#define VT_REG_BCR0 0x6e /* Bus Control 0 */
|
||||||
|
#define VT_REG_BCR1 0x6f /* Bus Control 1 */
|
||||||
|
#define VT_REG_MII_CR 0x70 /* MII Control */
|
||||||
|
#define VT_REG_MII_ADDR 0x71 /* MII Interface Address*/
|
||||||
|
#define VT_REG_MII_DATA 0x72 /* MII Data Port */
|
||||||
|
#define VT_REG_EECSR 0x74 /* EEPROM Control/Status */
|
||||||
|
#define VT_REG_CFG_A 0x78 /* Chip Configuration A */
|
||||||
|
#define VT_REG_CFG_B 0x79 /* Chip Configuration B */
|
||||||
|
#define VT_REG_CFG_C 0x7a /* Chip Configuration C */
|
||||||
|
#define VT_REG_CFG_D 0x7b /* Chip Configuration D */
|
||||||
|
#define VT_REG_MCR0 0x80 /* Miscellaneous Control 0 */
|
||||||
|
#define VT_REG_MCR1 0x81 /* Miscellaneous Control 1 */
|
||||||
|
#define VT_REG_STICK 0x83 /* Sticky Hardware Control */
|
||||||
|
#define VT_REG_MISR 0x84 /* MII Interrupt Status */
|
||||||
|
#define VT_REG_MIMR 0x86 /* MII Interrupt Mask */
|
||||||
|
#define VT_REG_FCR0 0x98 /* Flow Control 0 */
|
||||||
|
#define VT_REG_FCR1 0x99 /* Flow Control 1 */
|
||||||
|
#define VT_REG_WOL_SET 0xA4 /* Wake On LAN Set */
|
||||||
|
#define VT_REG_WOL_CLR 0xA0 /* Wake On LAN Clear */
|
||||||
|
#define VT_REG_PCS_CLR 0xA5 /* Power Configuration Set */
|
||||||
|
#define VT_REG_PCS_SET 0xA1 /* Power Configuration Clear */
|
||||||
|
#define VT_REG_WOLC_SET 0xA7 /* WOL Configuration Set */
|
||||||
|
#define VT_REG_WOLC_CLR 0xA3 /* WOL Configuration Clear */
|
||||||
|
#define VT_REG_WOLS_SET 0xA8 /* WOL Status Clear */
|
||||||
|
#define VT_REG_WOLS_CLR 0xAC /* WOL Status Set */
|
||||||
|
|
||||||
|
/* Interrupt Status/Mask Register */
|
||||||
|
#define VT_INTR_RX_DONE 0x0001
|
||||||
|
#define VT_INTR_TX_DONE 0x0002
|
||||||
|
#define VT_INTR_RX_ERR 0x0004
|
||||||
|
#define VT_INTR_TX_ERR 0x0008
|
||||||
|
#define VT_INTR_RX_EMPTY 0x0020
|
||||||
|
#define VT_INTR_PCI_ERR 0x0040
|
||||||
|
#define VT_INTR_STS_MAX 0x0080
|
||||||
|
#define VT_INTR_RX_EARLY 0x0100
|
||||||
|
#define VT_INTR_TX_UNDER_RUN 0x0210
|
||||||
|
#define VT_INTR_RX_OVERFLOW 0x0400
|
||||||
|
#define VT_INTR_RX_DROPPED 0x0800
|
||||||
|
#define VT_INTR_RX_NOBUF 0x1000
|
||||||
|
#define VT_INTR_TX_ABORT 0x2000
|
||||||
|
#define VT_INTR_PORT_CHANGE 0x4000
|
||||||
|
#define VT_INTR_RX_WAKE_UP 0x8000
|
||||||
|
|
||||||
|
/* Control Register Command */
|
||||||
|
#define VT_CMD_START 0x0002
|
||||||
|
#define VT_CMD_STOP 0x0004
|
||||||
|
#define VT_CMD_RX_ON 0x0008
|
||||||
|
#define VT_CMD_TX_ON 0x0010
|
||||||
|
#define VT_CMD_TX_DEMAND 0x0020
|
||||||
|
#define VT_CMD_RX_DEMAND 0x0040
|
||||||
|
#define VT_CMD_EARLY_RX 0x0100
|
||||||
|
#define VT_CMD_EARLY_TX 0x0200
|
||||||
|
#define VT_CMD_FDUPLEX 0x0400
|
||||||
|
#define VT_CMD_NO_POLL 0x0800
|
||||||
|
#define VT_CMD_RESET 0x8000
|
||||||
|
|
||||||
|
/* Receive Configure Mode */
|
||||||
|
#define VT_RCR_AP 0x10
|
||||||
|
#define VT_RCR_AB 0x08
|
||||||
|
#define VT_RCR_AM 0x04
|
||||||
|
#define VT_RCR_AR 0x02
|
||||||
|
#define VT_RCR_AE 0x01
|
||||||
|
|
||||||
|
/* General Descriptor Flag */
|
||||||
|
#define VT_DESC_OWN 0x80000000 /* Ownership */
|
||||||
|
#define VT_DESC_FIRST 0x00000200 /* First Descriptor */
|
||||||
|
#define VT_DESC_LAST 0x00000100 /* Last Descriptor */
|
||||||
|
|
||||||
|
/* Rx Descriptor Flag */
|
||||||
|
#define VT_DESC_RX_LENMASK 0x7fff0000 /* Receive Frame Length Mask */
|
||||||
|
#define VT_DESC_RX_OK 0x00008000 /* Receive OK */
|
||||||
|
#define VT_DESC_RX_MAR 0x00002000 /* Multicast Address Received */
|
||||||
|
#define VT_DESC_RX_BAR 0x00001000 /* Broadcast Address Received */
|
||||||
|
#define VT_DESC_RX_PHY 0x00000800 /* Physical Address Received */
|
||||||
|
#define VT_DESC_RX_LINK_ERR 0x00000080 /* Descriptor Link Structure Error */
|
||||||
|
#define VT_DESC_RX_RUNT 0x00000020 /* Runt Packet */
|
||||||
|
#define VT_DESC_RX_LONG 0x00000010 /* Long Packet */
|
||||||
|
#define VT_DESC_RX_FOV 0x00000008 /* FIFO Overflow */
|
||||||
|
#define VT_DESC_RX_FAE 0x00000004 /* Frame Align Error */
|
||||||
|
#define VT_DESC_RX_CRCE 0x00000002 /* CRC Error */
|
||||||
|
#define VT_DESC_RX_ERR 0x00000001 /* Receive Error */
|
||||||
|
#define VT_DESC_RX_ALL_ERR (VT_DESC_RX_LINK_ERR | VT_DESC_RX_RUNT | \
|
||||||
|
VT_DESC_RX_LONG | VT_DESC_RX_FOV | \
|
||||||
|
VT_DESC_RX_FAE | VT_DESC_RX_CRCE | VT_DESC_RX_ERR)
|
||||||
|
#define VT_DESC_RX_PACK (VT_DESC_FIRST | VT_DESC_LAST)
|
||||||
|
|
||||||
|
/* Tx Descriptor Flag */
|
||||||
|
#define VT_DESC_TX_ERR 0x00008000 /* Transmit Error */
|
||||||
|
#define VT_DESC_TX_UDF 0x00000800 /* FIFO Underflow */
|
||||||
|
#define VT_DESC_TX_CRS 0x00000400 /* Carrier Sense Lost Detect */
|
||||||
|
#define VT_DESC_TX_OWC 0x00000200 /* Out of Window Collision */
|
||||||
|
#define VT_DESC_TX_ABT 0x00000100 /* Excessive Collision Abort */
|
||||||
|
#define VT_DESC_TX_CDH 0x00000010 /* Collision Detect */
|
||||||
|
|
||||||
|
/* WOL status */
|
||||||
|
#define VT_WOL_UCAST 0x10
|
||||||
|
#define VT_WOL_MAGIC 0x20
|
||||||
|
#define VT_WOL_MCAST 0x30
|
||||||
|
#define VT_WOL_LINK_UP 0x40
|
||||||
|
#define VT_WOL_LINK_DOWN 0x80
|
||||||
|
|
||||||
|
/* Link status */
|
||||||
|
#define VT_LINK_UP 1
|
||||||
|
#define VT_LINK_DOWN 0
|
||||||
|
#define VT_LINK_UNKNOWN -1
|
||||||
|
|
||||||
|
#define VT_RX_BUF_SIZE 1536
|
||||||
|
#define VT_TX_BUF_SIZE 1536
|
||||||
|
#define VT_RX_DESC_NUM 64
|
||||||
|
#define VT_TX_DESC_NUM 64
|
||||||
|
|
||||||
|
/* #define VT6105_DEBUG */
|
||||||
|
|
||||||
|
/* Data Descriptor */
|
||||||
|
typedef struct vt_desc {
|
||||||
|
u32_t status; /* command/status */
|
||||||
|
u32_t length; /* Buffer/Frame length */
|
||||||
|
u32_t addr; /* DMA buffer address */
|
||||||
|
u32_t next_desc; /* Next descriptor */
|
||||||
|
} vt_desc;
|
||||||
|
|
||||||
|
/* Driver Data Structure */
|
||||||
|
typedef struct vt_driver {
|
||||||
|
u16_t vt_base_addr; /* Base address */
|
||||||
|
int vt_revision; /* Revision ID */
|
||||||
|
int vt_irq; /* IRQ number */
|
||||||
|
int vt_mode;
|
||||||
|
int vt_link; /* Whether link-up */
|
||||||
|
int vt_recv_flag; /* Receive flag */
|
||||||
|
int vt_send_flag; /* Send flag */
|
||||||
|
int vt_report_link;
|
||||||
|
int vt_tx_alive;
|
||||||
|
int vt_tx_busy;
|
||||||
|
|
||||||
|
/* Buffer */
|
||||||
|
size_t vt_buf_size;
|
||||||
|
char *vt_buf;
|
||||||
|
|
||||||
|
/* Rx data */
|
||||||
|
int vt_rx_head;
|
||||||
|
struct {
|
||||||
|
phys_bytes buf_dma;
|
||||||
|
char *buf;
|
||||||
|
} vt_rx[VT_RX_DESC_NUM];
|
||||||
|
vt_desc *vt_rx_desc; /* Rx descriptor buffer */
|
||||||
|
phys_bytes vt_rx_desc_dma; /* Rx descriptor DMA buffer */
|
||||||
|
|
||||||
|
/* Tx data */
|
||||||
|
int vt_tx_head;
|
||||||
|
int vt_tx_tail;
|
||||||
|
struct {
|
||||||
|
int busy;
|
||||||
|
phys_bytes buf_dma;
|
||||||
|
char *buf;
|
||||||
|
} vt_tx[VT_TX_DESC_NUM];
|
||||||
|
vt_desc *vt_tx_desc; /* Tx descriptor buffer */
|
||||||
|
phys_bytes vt_tx_desc_dma; /* Tx descriptor DMA buffer */
|
||||||
|
int vt_tx_busy_num; /* Number of busy Tx descriptors */
|
||||||
|
|
||||||
|
int vt_hook; /* IRQ hook id at kernel */
|
||||||
|
eth_stat_t vt_stat;
|
||||||
|
|
||||||
|
char vt_name[20];
|
||||||
|
} vt_driver;
|
||||||
|
|
@ -73,6 +73,7 @@ service_get_policies(struct policies * pol, index_t slot)
|
||||||
{ .label = "rtl8169", .policy_str = "reset" },
|
{ .label = "rtl8169", .policy_str = "reset" },
|
||||||
{ .label = "uds", .policy_str = "reset" },
|
{ .label = "uds", .policy_str = "reset" },
|
||||||
{ .label = "virtio_net", .policy_str = "reset" },
|
{ .label = "virtio_net", .policy_str = "reset" },
|
||||||
|
{ .label = "vt6105", .policy_str = "reset" },
|
||||||
/* power */
|
/* power */
|
||||||
{ .label = "acpi", .policy_str = "" },
|
{ .label = "acpi", .policy_str = "" },
|
||||||
{ .label = "tps65217", .policy_str = "" },
|
{ .label = "tps65217", .policy_str = "" },
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <minix/ipc.h>
|
#include <minix/ipc.h>
|
||||||
|
|
||||||
#define ACPI_REQ_GET_IRQ 1
|
#define ACPI_REQ_GET_IRQ 1
|
||||||
#define ACPI_REQ_MAP_BRIDGE 2
|
#define ACPI_REQ_MAP_BRIDGE 2
|
||||||
|
|
||||||
struct acpi_request_hdr {
|
struct acpi_request_hdr {
|
||||||
endpoint_t m_source; /* message header */
|
endpoint_t m_source; /* message header */
|
||||||
|
|
@ -42,3 +42,7 @@ struct acpi_map_bridge_resp {
|
||||||
int err;
|
int err;
|
||||||
u32_t __padding[7];
|
u32_t __padding[7];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int acpi_init(void);
|
||||||
|
int acpi_get_irq(unsigned bus, unsigned dev, unsigned pin);
|
||||||
|
void acpi_map_bridge(unsigned int pbnr, unsigned int dev, unsigned int sbnr);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,12 @@
|
||||||
|
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The maximum number of I/O vector elements that can be passed to the
|
||||||
|
* rmib_vcopyout function.
|
||||||
|
*/
|
||||||
|
#define RMIB_IOV_MAX SCPVEC_NR
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This structure contains a number of less heavily used parameters for handler
|
* This structure contains a number of less heavily used parameters for handler
|
||||||
* functions, mainly to provide extensibility while limiting argument clutter.
|
* functions, mainly to provide extensibility while limiting argument clutter.
|
||||||
|
|
@ -145,6 +151,8 @@ int rmib_inrange(struct rmib_oldp *, size_t);
|
||||||
size_t rmib_getoldlen(struct rmib_oldp *);
|
size_t rmib_getoldlen(struct rmib_oldp *);
|
||||||
ssize_t rmib_copyout(struct rmib_oldp *, size_t, const void * __restrict,
|
ssize_t rmib_copyout(struct rmib_oldp *, size_t, const void * __restrict,
|
||||||
size_t);
|
size_t);
|
||||||
|
ssize_t rmib_vcopyout(struct rmib_oldp *, size_t, const iovec_t *,
|
||||||
|
unsigned int);
|
||||||
int rmib_copyin(struct rmib_newp * __restrict, void * __restrict, size_t);
|
int rmib_copyin(struct rmib_newp * __restrict, void * __restrict, size_t);
|
||||||
ssize_t rmib_readwrite(struct rmib_call *, struct rmib_node *,
|
ssize_t rmib_readwrite(struct rmib_call *, struct rmib_node *,
|
||||||
struct rmib_oldp *, struct rmib_newp *);
|
struct rmib_oldp *, struct rmib_newp *);
|
||||||
|
|
|
||||||
|
|
@ -26,21 +26,21 @@ static struct omap_serial omap_serial = {
|
||||||
static kern_phys_map serial_phys_map;
|
static kern_phys_map serial_phys_map;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In kernel serial for the omap. The serial driver like most other
|
* In kernel serial for the omap. The serial driver, like most other
|
||||||
* drivers needs to be started early and even before the MMU is turned on.
|
* drivers, needs to be started early and even before the MMU is turned on.
|
||||||
* We start by directly accessing the hardware memory address. Later on
|
* We start by directly accessing the hardware memory address. Later on
|
||||||
* a when the MMU is turned on we still use a 1:1 mapping for these addresses.
|
* when the MMU is turned on we still use a 1:1 mapping for these addresses.
|
||||||
*
|
*
|
||||||
* Pretty soon we are going to remap these addresses at later stage. And this
|
* Pretty soon we are going to remap these addresses at a later stage. And this
|
||||||
* requires us to use a dynamic base address. The idea is to receive a callback
|
* requires us to use a dynamic base address. The idea is to receive a callback
|
||||||
* from VM with the new address to use.
|
* from VM with the new address to use.
|
||||||
*
|
*
|
||||||
* We also anticipate on the beaglebone port an try to keep the differences between
|
* We also try on the BeagleBone port to keep the differences between the
|
||||||
* the drivers to a minimum by initializing a struct here and not using (to much)
|
* drivers to a minimum by initializing a struct here and not using (too many)
|
||||||
* constants in the code.
|
* constants in the code.
|
||||||
*
|
*
|
||||||
* The serial driver also gets used in the "pre_init" stage before the kernel is loaded
|
* The serial driver also gets used in the "pre_init" stage before the kernel is loaded
|
||||||
* in high memory so keep in mind there are two copies of this code in the kernel.
|
* in high memory, so keep in mind there are two copies of this code in the kernel.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
bsp_ser_init(void)
|
bsp_ser_init(void)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ SUBDIR+= libnetsock
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.if (${MACHINE_ARCH} == "i386")
|
.if (${MACHINE_ARCH} == "i386")
|
||||||
|
SUBDIR+= libacpi
|
||||||
SUBDIR+= libhgfs
|
SUBDIR+= libhgfs
|
||||||
SUBDIR+= libvassert
|
SUBDIR+= libvassert
|
||||||
SUBDIR+= libvboxfs
|
SUBDIR+= libvboxfs
|
||||||
|
|
|
||||||
9
minix/lib/libacpi/Makefile
Normal file
9
minix/lib/libacpi/Makefile
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Makefile for libacpi
|
||||||
|
|
||||||
|
CPPFLAGS+= -D_MINIX_SYSTEM
|
||||||
|
|
||||||
|
LIB = acpi
|
||||||
|
|
||||||
|
SRCS = acpi.c
|
||||||
|
|
||||||
|
.include <bsd.lib.mk>
|
||||||
85
minix/lib/libacpi/acpi.c
Normal file
85
minix/lib/libacpi/acpi.c
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
#define _SYSTEM
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <minix/acpi.h>
|
||||||
|
#include <minix/com.h>
|
||||||
|
#include <minix/ds.h>
|
||||||
|
#include <minix/ipc.h>
|
||||||
|
#include <minix/log.h>
|
||||||
|
#include <minix/sysutil.h>
|
||||||
|
|
||||||
|
static struct log log =
|
||||||
|
{ .name = "libacpi", .log_level = LEVEL_TRACE, .log_func = default_log };
|
||||||
|
|
||||||
|
static endpoint_t acpi_ep = NONE;
|
||||||
|
|
||||||
|
int
|
||||||
|
acpi_init(void)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
res = ds_retrieve_label_endpt("acpi", &acpi_ep);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===========================================================================*
|
||||||
|
* IRQ handling *
|
||||||
|
*===========================================================================*/
|
||||||
|
int
|
||||||
|
acpi_get_irq(unsigned bus, unsigned dev, unsigned pin)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
message m;
|
||||||
|
|
||||||
|
if (acpi_ep == NONE) {
|
||||||
|
err = acpi_init();
|
||||||
|
if (OK != err) {
|
||||||
|
panic("libacpi: ds_retrieve_label_endpt failed for 'acpi': %d", err);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log_info(&log, "resolved acpi to endpoint: %d\n", acpi_ep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
((struct acpi_get_irq_req *)&m)->hdr.request = ACPI_REQ_GET_IRQ;
|
||||||
|
((struct acpi_get_irq_req *)&m)->bus = bus;
|
||||||
|
((struct acpi_get_irq_req *)&m)->dev = dev;
|
||||||
|
((struct acpi_get_irq_req *)&m)->pin = pin;
|
||||||
|
|
||||||
|
if ((err = ipc_sendrec(acpi_ep, &m)) != OK)
|
||||||
|
panic("libacpi: error %d while receiving from ACPI\n", err);
|
||||||
|
|
||||||
|
return ((struct acpi_get_irq_resp *)&m)->irq;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* tells acpi which two busses are connected by this bridge. The primary bus
|
||||||
|
* (pbnr) must be already known to acpi and it must map dev as the connection to
|
||||||
|
* the secondary (sbnr) bus
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
acpi_map_bridge(unsigned int pbnr, unsigned int dev, unsigned int sbnr)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
message m;
|
||||||
|
|
||||||
|
if (acpi_ep == NONE) {
|
||||||
|
err = acpi_init();
|
||||||
|
if (OK != err) {
|
||||||
|
panic("libacpi: ds_retrieve_label_endpt failed for 'acpi': %d", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
((struct acpi_map_bridge_req *)&m)->hdr.request = ACPI_REQ_MAP_BRIDGE;
|
||||||
|
((struct acpi_map_bridge_req *)&m)->primary_bus = pbnr;
|
||||||
|
((struct acpi_map_bridge_req *)&m)->secondary_bus = sbnr;
|
||||||
|
((struct acpi_map_bridge_req *)&m)->device = dev;
|
||||||
|
|
||||||
|
if ((err = ipc_sendrec(acpi_ep, &m)) != OK)
|
||||||
|
panic("libacpi: error %d while receiving from ACPI\n", err);
|
||||||
|
|
||||||
|
if (((struct acpi_map_bridge_resp *)&m)->err != OK)
|
||||||
|
printf("libacpi: acpi failed to map pci (%d) to pci (%d) bridge\n",
|
||||||
|
pbnr, sbnr);
|
||||||
|
}
|
||||||
|
|
@ -57,6 +57,7 @@ poll(struct pollfd *p, nfds_t nfds, int timout)
|
||||||
|
|
||||||
highfd = -1;
|
highfd = -1;
|
||||||
for (i = 0; i < nfds; i++) {
|
for (i = 0; i < nfds; i++) {
|
||||||
|
p[i].revents = 0;
|
||||||
if (p[i].fd < 0)
|
if (p[i].fd < 0)
|
||||||
continue;
|
continue;
|
||||||
if (p[i].fd >= FD_SETSIZE) {
|
if (p[i].fd >= FD_SETSIZE) {
|
||||||
|
|
@ -83,7 +84,8 @@ poll(struct pollfd *p, nfds_t nfds, int timout)
|
||||||
|
|
||||||
rval = 0;
|
rval = 0;
|
||||||
for (i = 0; i < nfds; i++) {
|
for (i = 0; i < nfds; i++) {
|
||||||
p[i].revents = 0;
|
if (p[i].fd < 0)
|
||||||
|
continue;
|
||||||
if (FD_ISSET(p[i].fd, &rd))
|
if (FD_ISSET(p[i].fd, &rd))
|
||||||
p[i].revents |= POLLIN|POLLRDNORM|POLLRDBAND|POLLPRI;
|
p[i].revents |= POLLIN|POLLRDNORM|POLLRDBAND|POLLPRI;
|
||||||
if (FD_ISSET(p[i].fd, &wr))
|
if (FD_ISSET(p[i].fd, &wr))
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,60 @@ rmib_copyout(struct rmib_oldp * __restrict oldp, size_t off,
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy out (partial) data to the user, from a vector of up to RMIB_IOV_MAX
|
||||||
|
* local buffers. The copy is automatically limited to the range of data
|
||||||
|
* requested by the user. Return the total requested length on success or an
|
||||||
|
* error code on failure.
|
||||||
|
*/
|
||||||
|
ssize_t
|
||||||
|
rmib_vcopyout(struct rmib_oldp * oldp, size_t off, const iovec_t * iov,
|
||||||
|
unsigned int iovcnt)
|
||||||
|
{
|
||||||
|
static struct vscp_vec vec[RMIB_IOV_MAX];
|
||||||
|
size_t size, chunk;
|
||||||
|
unsigned int i;
|
||||||
|
ssize_t r;
|
||||||
|
|
||||||
|
assert(iov != NULL);
|
||||||
|
assert(iovcnt <= __arraycount(vec));
|
||||||
|
|
||||||
|
/* Take a shortcut for single-vector elements, saving a kernel copy. */
|
||||||
|
if (iovcnt == 1)
|
||||||
|
return rmib_copyout(oldp, off, (const void *)iov->iov_addr,
|
||||||
|
iov->iov_size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Iterate through the full vector even if we cannot copy out all of
|
||||||
|
* it, because we need to compute the total length.
|
||||||
|
*/
|
||||||
|
for (size = i = 0; iovcnt > 0; iov++, iovcnt--) {
|
||||||
|
if (oldp != NULL && off < oldp->oldp_len) {
|
||||||
|
chunk = oldp->oldp_len - off;
|
||||||
|
if (chunk > iov->iov_size)
|
||||||
|
chunk = iov->iov_size;
|
||||||
|
|
||||||
|
vec[i].v_from = SELF;
|
||||||
|
vec[i].v_to = MIB_PROC_NR;
|
||||||
|
vec[i].v_gid = oldp->oldp_grant;
|
||||||
|
vec[i].v_offset = off;
|
||||||
|
vec[i].v_addr = iov->iov_addr;
|
||||||
|
vec[i].v_bytes = chunk;
|
||||||
|
|
||||||
|
off += chunk;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
size += iov->iov_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform the copy, if there is anything to copy, that is. */
|
||||||
|
if (i > 0 && (r = sys_vsafecopy(vec, i)) != OK)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy in data from the user. The given length must match exactly the length
|
* Copy in data from the user. The given length must match exactly the length
|
||||||
* given by the user. Return OK or an error code.
|
* given by the user. Return OK or an error code.
|
||||||
|
|
|
||||||
|
|
@ -26,32 +26,6 @@
|
||||||
|
|
||||||
static const char padbuf[RT_ROUNDUP(0)] = { 0 };
|
static const char padbuf[RT_ROUNDUP(0)] = { 0 };
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy out a vector of data to the sysctl(2) caller. TODO: decide what to do
|
|
||||||
* with this. We could implement this as a vectored-safecopy operation in
|
|
||||||
* RMIB. We could also copy everything into a single buffer first. The
|
|
||||||
* current implementation is probably the worst among the possibilities.
|
|
||||||
*/
|
|
||||||
static ssize_t
|
|
||||||
rmib_vcopyout(struct rmib_oldp * oldp, size_t off, const iovec_t * iov,
|
|
||||||
unsigned int iovcnt)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
ssize_t r, len;
|
|
||||||
|
|
||||||
len = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < iovcnt; i++) {
|
|
||||||
if ((r = rmib_copyout(oldp, off + len,
|
|
||||||
(const void *)iov[i].iov_addr, iov[i].iov_size)) < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
len += r;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the length for, and possibly copy out, an interface information or
|
* Compute the length for, and possibly copy out, an interface information or
|
||||||
* interface address record with an associated set of zero or more routing
|
* interface address record with an associated set of zero or more routing
|
||||||
|
|
|
||||||
|
|
@ -23,32 +23,6 @@
|
||||||
|
|
||||||
static const char padbuf[RT_ROUNDUP(0)] = { 0 };
|
static const char padbuf[RT_ROUNDUP(0)] = { 0 };
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy out a vector of data to the sysctl(2) caller. TODO: decide what to do
|
|
||||||
* with this. We could implement this as a vectored-safecopy operation in
|
|
||||||
* RMIB. We could also copy everything into a single buffer first. The
|
|
||||||
* current implementation is probably the worst among the possibilities.
|
|
||||||
*/
|
|
||||||
static ssize_t
|
|
||||||
rmib_vcopyout(struct rmib_oldp * oldp, size_t off, const iovec_t * iov,
|
|
||||||
unsigned int iovcnt)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
ssize_t r, len;
|
|
||||||
|
|
||||||
len = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < iovcnt; i++) {
|
|
||||||
if ((r = rmib_copyout(oldp, off + len,
|
|
||||||
(const void *)iov[i].iov_addr, iov[i].iov_size)) < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
len += r;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the length for, and possibly copy out, an interface information or
|
* Compute the length for, and possibly copy out, an interface information or
|
||||||
* interface address record with an associated set of zero or more routing
|
* interface address record with an associated set of zero or more routing
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ struct hook_entry {
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* map_unmap_keys *
|
* map_unmap_keys *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void map_unmap_fkeys(map)
|
void
|
||||||
int map;
|
map_unmap_fkeys(int map)
|
||||||
{
|
{
|
||||||
int fkeys, sfkeys;
|
int fkeys, sfkeys;
|
||||||
int h, s;
|
int h, s;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
|
|
||||||
static struct data_store noxfer_ds_store[NR_DS_KEYS];
|
static struct data_store noxfer_ds_store[NR_DS_KEYS];
|
||||||
|
|
||||||
void data_store_dmp()
|
void
|
||||||
|
data_store_dmp(void)
|
||||||
{
|
{
|
||||||
struct data_store *p;
|
struct data_store *p;
|
||||||
static int prev_i = 0;
|
static int prev_i = 0;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@ struct dmap dmap[NR_DEVICES];
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* fproc_dmp *
|
* fproc_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void fproc_dmp()
|
void
|
||||||
|
fproc_dmp(void)
|
||||||
{
|
{
|
||||||
struct fproc *fp;
|
struct fproc *fp;
|
||||||
int i, j, nfds, n=0;
|
int i, j, nfds, n=0;
|
||||||
|
|
@ -61,7 +62,8 @@ void fproc_dmp()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* dtab_dmp *
|
* dtab_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void dtab_dmp()
|
void
|
||||||
|
dtab_dmp(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@ struct boot_image image[NR_BOOT_PROCS];
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* kmessages_dmp *
|
* kmessages_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void kmessages_dmp()
|
void
|
||||||
|
kmessages_dmp(void)
|
||||||
{
|
{
|
||||||
struct kmessages *kmess; /* get copy of kernel messages */
|
struct kmessages *kmess; /* get copy of kernel messages */
|
||||||
static char print_buf[_KMESS_BUF_SIZE+1]; /* this one is used to print */
|
static char print_buf[_KMESS_BUF_SIZE+1]; /* this one is used to print */
|
||||||
|
|
@ -89,7 +90,8 @@ void kmessages_dmp()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* monparams_dmp *
|
* monparams_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void monparams_dmp()
|
void
|
||||||
|
monparams_dmp(void)
|
||||||
{
|
{
|
||||||
char val[MULTIBOOT_PARAM_BUF_SIZE];
|
char val[MULTIBOOT_PARAM_BUF_SIZE];
|
||||||
char *e;
|
char *e;
|
||||||
|
|
@ -116,7 +118,8 @@ void monparams_dmp()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* irqtab_dmp *
|
* irqtab_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void irqtab_dmp()
|
void
|
||||||
|
irqtab_dmp(void)
|
||||||
{
|
{
|
||||||
int i,r;
|
int i,r;
|
||||||
struct irq_hook irq_hooks[NR_IRQ_HOOKS];
|
struct irq_hook irq_hooks[NR_IRQ_HOOKS];
|
||||||
|
|
@ -162,7 +165,8 @@ void irqtab_dmp()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* image_dmp *
|
* image_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void image_dmp()
|
void
|
||||||
|
image_dmp(void)
|
||||||
{
|
{
|
||||||
int m, r;
|
int m, r;
|
||||||
struct boot_image *ip;
|
struct boot_image *ip;
|
||||||
|
|
@ -184,7 +188,8 @@ void image_dmp()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* kenv_dmp *
|
* kenv_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void kenv_dmp()
|
void
|
||||||
|
kenv_dmp(void)
|
||||||
{
|
{
|
||||||
struct kinfo kinfo;
|
struct kinfo kinfo;
|
||||||
struct machine machine;
|
struct machine machine;
|
||||||
|
|
@ -244,7 +249,8 @@ static char *s_traps_str(int flags)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* privileges_dmp *
|
* privileges_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void privileges_dmp()
|
void
|
||||||
|
privileges_dmp(void)
|
||||||
{
|
{
|
||||||
register struct proc *rp;
|
register struct proc *rp;
|
||||||
static struct proc *oldrp = BEG_PROC_ADDR;
|
static struct proc *oldrp = BEG_PROC_ADDR;
|
||||||
|
|
@ -349,7 +355,8 @@ void proctab_dmp(void)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* procstack_dmp *
|
* procstack_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void procstack_dmp()
|
void
|
||||||
|
procstack_dmp(void)
|
||||||
{
|
{
|
||||||
/* Proc table dump, with stack */
|
/* Proc table dump, with stack */
|
||||||
|
|
||||||
|
|
@ -375,8 +382,8 @@ void procstack_dmp()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* proc_name *
|
* proc_name *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static char *proc_name(proc_nr)
|
static char *
|
||||||
int proc_nr;
|
proc_name(int proc_nr)
|
||||||
{
|
{
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
if (proc_nr == ANY) return "ANY";
|
if (proc_nr == ANY) return "ANY";
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ static char *flags_str(int flags)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mproc_dmp()
|
void
|
||||||
|
mproc_dmp(void)
|
||||||
{
|
{
|
||||||
struct mproc *mp;
|
struct mproc *mp;
|
||||||
int i, n=0;
|
int i, n=0;
|
||||||
|
|
@ -70,7 +71,8 @@ void mproc_dmp()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* sigaction_dmp *
|
* sigaction_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void sigaction_dmp()
|
void
|
||||||
|
sigaction_dmp(void)
|
||||||
{
|
{
|
||||||
struct mproc *mp;
|
struct mproc *mp;
|
||||||
int i, n=0;
|
int i, n=0;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ static char *s_flags_str(int flags, int sys_flags);
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* rproc_dmp *
|
* rproc_dmp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void rproc_dmp()
|
void
|
||||||
|
rproc_dmp(void)
|
||||||
{
|
{
|
||||||
struct rproc *rp;
|
struct rproc *rp;
|
||||||
struct rprocpub *rpub;
|
struct rprocpub *rpub;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ static void print_region(struct vm_region_info *vri, int *n)
|
||||||
(*n)++;
|
(*n)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vm_dmp()
|
void
|
||||||
|
vm_dmp(void)
|
||||||
{
|
{
|
||||||
static struct proc proc[NR_TASKS + NR_PROCS];
|
static struct proc proc[NR_TASKS + NR_PROCS];
|
||||||
static struct vm_region_info vri[LINES];
|
static struct vm_region_info vri[LINES];
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,8 @@ int main(int argc, char **argv)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* sef_local_startup *
|
* sef_local_startup *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static void sef_local_startup()
|
static void
|
||||||
|
sef_local_startup(void)
|
||||||
{
|
{
|
||||||
/* Register init callbacks. */
|
/* Register init callbacks. */
|
||||||
sef_setcb_init_fresh(sef_cb_init_fresh);
|
sef_setcb_init_fresh(sef_cb_init_fresh);
|
||||||
|
|
@ -117,7 +118,8 @@ static void sef_cb_signal_handler(int signo)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* get_work *
|
* get_work *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static void get_work()
|
static void
|
||||||
|
get_work(void)
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
status = sef_receive(ANY, &m_in); /* this blocks until message arrives */
|
status = sef_receive(ANY, &m_in); /* this blocks until message arrives */
|
||||||
|
|
@ -130,9 +132,11 @@ static void get_work()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* reply *
|
* reply *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static void reply(who, result)
|
static void
|
||||||
int who; /* destination */
|
reply(
|
||||||
int result; /* report result to replyee */
|
int who, /* destination */
|
||||||
|
int result /* report result to replyee */
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int send_status;
|
int send_status;
|
||||||
m_out.m_type = result; /* build reply message */
|
m_out.m_type = result; /* build reply message */
|
||||||
|
|
|
||||||
|
|
@ -338,5 +338,7 @@ cause_sigalrm(int arg)
|
||||||
set_alarm(rmp, rmp->mp_interval[ITIMER_REAL]);
|
set_alarm(rmp, rmp->mp_interval[ITIMER_REAL]);
|
||||||
else rmp->mp_flags &= ~ALARM_ON;
|
else rmp->mp_flags &= ~ALARM_ON;
|
||||||
|
|
||||||
|
mp = &mproc[0]; /* pretend the signal comes from PM */
|
||||||
|
|
||||||
check_sig(rmp->mp_pid, SIGALRM, FALSE /* ksig */);
|
check_sig(rmp->mp_pid, SIGALRM, FALSE /* ksig */);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,9 +137,11 @@ int get_fd(struct fproc *rfp, int start, mode_t bits, int *k, struct filp **fpt)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* get_filp *
|
* get_filp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
struct filp *get_filp(fild, locktype)
|
struct filp *
|
||||||
int fild; /* file descriptor */
|
get_filp(
|
||||||
tll_access_t locktype;
|
int fild, /* file descriptor */
|
||||||
|
tll_access_t locktype
|
||||||
|
)
|
||||||
{
|
{
|
||||||
/* See if 'fild' refers to a valid file descr. If so, return its filp ptr. */
|
/* See if 'fild' refers to a valid file descr. If so, return its filp ptr. */
|
||||||
|
|
||||||
|
|
@ -150,10 +152,12 @@ tll_access_t locktype;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* get_filp2 *
|
* get_filp2 *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
struct filp *get_filp2(rfp, fild, locktype)
|
struct filp *
|
||||||
register struct fproc *rfp;
|
get_filp2(
|
||||||
int fild; /* file descriptor */
|
register struct fproc *rfp,
|
||||||
tll_access_t locktype;
|
int fild, /* file descriptor */
|
||||||
|
tll_access_t locktype
|
||||||
|
)
|
||||||
{
|
{
|
||||||
/* See if 'fild' refers to a valid file descr. If so, return its filp ptr. */
|
/* See if 'fild' refers to a valid file descr. If so, return its filp ptr. */
|
||||||
struct filp *filp;
|
struct filp *filp;
|
||||||
|
|
@ -242,9 +246,8 @@ void invalidate_filp_by_endpt(endpoint_t proc_e)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* lock_filp *
|
* lock_filp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void lock_filp(filp, locktype)
|
void
|
||||||
struct filp *filp;
|
lock_filp(struct filp *filp, tll_access_t locktype)
|
||||||
tll_access_t locktype;
|
|
||||||
{
|
{
|
||||||
struct worker_thread *org_self;
|
struct worker_thread *org_self;
|
||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
|
|
@ -287,8 +290,8 @@ tll_access_t locktype;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* unlock_filp *
|
* unlock_filp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void unlock_filp(filp)
|
void
|
||||||
struct filp *filp;
|
unlock_filp(struct filp *filp)
|
||||||
{
|
{
|
||||||
/* If this filp holds a soft lock on the vnode, we must be the owner */
|
/* If this filp holds a soft lock on the vnode, we must be the owner */
|
||||||
if (filp->filp_softlock != NULL)
|
if (filp->filp_softlock != NULL)
|
||||||
|
|
@ -312,9 +315,8 @@ struct filp *filp;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* unlock_filps *
|
* unlock_filps *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void unlock_filps(filp1, filp2)
|
void
|
||||||
struct filp *filp1;
|
unlock_filps(struct filp *filp1, struct filp *filp2)
|
||||||
struct filp *filp2;
|
|
||||||
{
|
{
|
||||||
/* Unlock two filps that are tied to the same vnode. As a thread can lock a
|
/* Unlock two filps that are tied to the same vnode. As a thread can lock a
|
||||||
* vnode only once, unlocking the vnode twice would result in an error. */
|
* vnode only once, unlocking the vnode twice would result in an error. */
|
||||||
|
|
@ -344,8 +346,8 @@ struct filp *filp2;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* close_filp *
|
* close_filp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void close_filp(f)
|
void
|
||||||
struct filp *f;
|
close_filp(struct filp *f)
|
||||||
{
|
{
|
||||||
/* Close a file. Will also unlock filp when done */
|
/* Close a file. Will also unlock filp when done */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -362,9 +362,8 @@ int do_ftruncate(void)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* truncate_vnode *
|
* truncate_vnode *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int truncate_vnode(vp, newsize)
|
int
|
||||||
struct vnode *vp;
|
truncate_vnode(struct vnode *vp, off_t newsize)
|
||||||
off_t newsize;
|
|
||||||
{
|
{
|
||||||
/* Truncate a regular file or a pipe */
|
/* Truncate a regular file or a pipe */
|
||||||
int r;
|
int r;
|
||||||
|
|
@ -427,10 +426,12 @@ int do_slink(void)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* rdlink_direct *
|
* rdlink_direct *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int rdlink_direct(orig_path, link_path, rfp)
|
int
|
||||||
char *orig_path;
|
rdlink_direct(
|
||||||
char link_path[PATH_MAX]; /* should have length PATH_MAX */
|
char *orig_path,
|
||||||
struct fproc *rfp;
|
char link_path[PATH_MAX], /* should have length PATH_MAX */
|
||||||
|
struct fproc *rfp
|
||||||
|
)
|
||||||
{
|
{
|
||||||
/* Perform a readlink()-like call from within the VFS */
|
/* Perform a readlink()-like call from within the VFS */
|
||||||
int r;
|
int r;
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,8 @@ int lock_op(int fd, int req, vir_bytes arg)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* lock_revive *
|
* lock_revive *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void lock_revive()
|
void
|
||||||
|
lock_revive(void)
|
||||||
{
|
{
|
||||||
/* Go find all the processes that are waiting for any kind of lock and
|
/* Go find all the processes that are waiting for any kind of lock and
|
||||||
* revive them all. The ones that are still blocked will block again when
|
* revive them all. The ones that are still blocked will block again when
|
||||||
|
|
|
||||||
|
|
@ -915,8 +915,8 @@ static void service_pm(void)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* unblock *
|
* unblock *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static int unblock(rfp)
|
static int
|
||||||
struct fproc *rfp;
|
unblock(struct fproc *rfp)
|
||||||
{
|
{
|
||||||
/* Unblock a process that was previously blocked on a pipe or a lock. This is
|
/* Unblock a process that was previously blocked on a pipe or a lock. This is
|
||||||
* done by reconstructing the original request and continuing/repeating it.
|
* done by reconstructing the original request and continuing/repeating it.
|
||||||
|
|
|
||||||
|
|
@ -496,7 +496,8 @@ reqdone:
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* pm_reboot *
|
* pm_reboot *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void pm_reboot()
|
void
|
||||||
|
pm_reboot(void)
|
||||||
{
|
{
|
||||||
/* Perform the VFS side of the reboot call. This call is performed from the PM
|
/* Perform the VFS side of the reboot call. This call is performed from the PM
|
||||||
* process context.
|
* process context.
|
||||||
|
|
@ -709,10 +710,8 @@ void pm_exit(void)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* pm_setgid *
|
* pm_setgid *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void pm_setgid(proc_e, egid, rgid)
|
void
|
||||||
endpoint_t proc_e;
|
pm_setgid(endpoint_t proc_e, int egid, int rgid)
|
||||||
int egid;
|
|
||||||
int rgid;
|
|
||||||
{
|
{
|
||||||
register struct fproc *tfp;
|
register struct fproc *tfp;
|
||||||
int slot;
|
int slot;
|
||||||
|
|
@ -728,10 +727,8 @@ int rgid;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* pm_setgroups *
|
* pm_setgroups *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void pm_setgroups(proc_e, ngroups, groups)
|
void
|
||||||
endpoint_t proc_e;
|
pm_setgroups(endpoint_t proc_e, int ngroups, gid_t *groups)
|
||||||
int ngroups;
|
|
||||||
gid_t *groups;
|
|
||||||
{
|
{
|
||||||
struct fproc *rfp;
|
struct fproc *rfp;
|
||||||
int slot;
|
int slot;
|
||||||
|
|
@ -751,10 +748,8 @@ gid_t *groups;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* pm_setuid *
|
* pm_setuid *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void pm_setuid(proc_e, euid, ruid)
|
void
|
||||||
endpoint_t proc_e;
|
pm_setuid(endpoint_t proc_e, int euid, int ruid)
|
||||||
int euid;
|
|
||||||
int ruid;
|
|
||||||
{
|
{
|
||||||
struct fproc *tfp;
|
struct fproc *tfp;
|
||||||
int slot;
|
int slot;
|
||||||
|
|
|
||||||
|
|
@ -682,9 +682,8 @@ int do_close(void)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* close_fd *
|
* close_fd *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int close_fd(rfp, fd_nr)
|
int
|
||||||
struct fproc *rfp;
|
close_fd(struct fproc *rfp, int fd_nr)
|
||||||
int fd_nr;
|
|
||||||
{
|
{
|
||||||
/* Perform the close(fd) system call. */
|
/* Perform the close(fd) system call. */
|
||||||
register struct filp *rfilp;
|
register struct filp *rfilp;
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,8 @@ static int check_perms(endpoint_t ep, cp_grant_id_t io_gr, size_t
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* advance *
|
* advance *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
struct vnode *advance(dirp, resolve, rfp)
|
struct vnode *
|
||||||
struct vnode *dirp;
|
advance(struct vnode *dirp, struct lookup *resolve, struct fproc *rfp)
|
||||||
struct lookup *resolve;
|
|
||||||
struct fproc *rfp;
|
|
||||||
{
|
{
|
||||||
/* Resolve a path name starting at dirp to a vnode. */
|
/* Resolve a path name starting at dirp to a vnode. */
|
||||||
int r;
|
int r;
|
||||||
|
|
@ -134,9 +132,8 @@ struct fproc *rfp;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* eat_path *
|
* eat_path *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
struct vnode *eat_path(resolve, rfp)
|
struct vnode *
|
||||||
struct lookup *resolve;
|
eat_path(struct lookup *resolve, struct fproc *rfp)
|
||||||
struct fproc *rfp;
|
|
||||||
{
|
{
|
||||||
/* Resolve path to a vnode. advance does the actual work. */
|
/* Resolve path to a vnode. advance does the actual work. */
|
||||||
struct vnode *start_dir;
|
struct vnode *start_dir;
|
||||||
|
|
@ -148,9 +145,8 @@ struct fproc *rfp;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* last_dir *
|
* last_dir *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
struct vnode *last_dir(resolve, rfp)
|
struct vnode *
|
||||||
struct lookup *resolve;
|
last_dir(struct lookup *resolve, struct fproc *rfp)
|
||||||
struct fproc *rfp;
|
|
||||||
{
|
{
|
||||||
/* Parse a path, as far as the last directory, fetch the vnode
|
/* Parse a path, as far as the last directory, fetch the vnode
|
||||||
* for the last directory into the vnode table, and return a pointer to the
|
* for the last directory into the vnode table, and return a pointer to the
|
||||||
|
|
@ -387,11 +383,8 @@ struct fproc *rfp;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* lookup *
|
* lookup *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static int lookup(start_node, resolve, result_node, rfp)
|
static int
|
||||||
struct vnode *start_node;
|
lookup(struct vnode *start_node, struct lookup *resolve, node_details_t *result_node, struct fproc *rfp)
|
||||||
struct lookup *resolve;
|
|
||||||
node_details_t *result_node;
|
|
||||||
struct fproc *rfp;
|
|
||||||
{
|
{
|
||||||
/* Resolve a path name relative to start_node. */
|
/* Resolve a path name relative to start_node. */
|
||||||
|
|
||||||
|
|
@ -581,12 +574,8 @@ struct fproc *rfp;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* lookup_init *
|
* lookup_init *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void lookup_init(resolve, path, flags, vmp, vp)
|
void
|
||||||
struct lookup *resolve;
|
lookup_init(struct lookup *resolve, char *path, int flags, struct vmnt **vmp, struct vnode **vp)
|
||||||
char *path;
|
|
||||||
int flags;
|
|
||||||
struct vmnt **vmp;
|
|
||||||
struct vnode **vp;
|
|
||||||
{
|
{
|
||||||
assert(vmp != NULL);
|
assert(vmp != NULL);
|
||||||
assert(vp != NULL);
|
assert(vp != NULL);
|
||||||
|
|
@ -604,10 +593,8 @@ struct vnode **vp;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* get_name *
|
* get_name *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int get_name(dirp, entry, ename)
|
int
|
||||||
struct vnode *dirp;
|
get_name(struct vnode *dirp, struct vnode *entry, char ename[NAME_MAX + 1])
|
||||||
struct vnode *entry;
|
|
||||||
char ename[NAME_MAX + 1];
|
|
||||||
{
|
{
|
||||||
#define DIR_ENTRIES 8
|
#define DIR_ENTRIES 8
|
||||||
#define DIR_ENTRY_SIZE (sizeof(struct dirent) + NAME_MAX)
|
#define DIR_ENTRY_SIZE (sizeof(struct dirent) + NAME_MAX)
|
||||||
|
|
@ -660,9 +647,8 @@ char ename[NAME_MAX + 1];
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* canonical_path *
|
* canonical_path *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int canonical_path(orig_path, rfp)
|
int
|
||||||
char orig_path[PATH_MAX];
|
canonical_path(char orig_path[PATH_MAX], struct fproc *rfp)
|
||||||
struct fproc *rfp;
|
|
||||||
{
|
{
|
||||||
/* Find canonical path of a given path */
|
/* Find canonical path of a given path */
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
|
||||||
|
|
@ -147,9 +147,8 @@ static int create_pipe(int fil_des[2], int flags)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* map_vnode *
|
* map_vnode *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int map_vnode(vp, map_to_fs_e)
|
int
|
||||||
struct vnode *vp;
|
map_vnode(struct vnode *vp, endpoint_t map_to_fs_e)
|
||||||
endpoint_t map_to_fs_e;
|
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
struct vmnt *vmp;
|
struct vmnt *vmp;
|
||||||
|
|
|
||||||
|
|
@ -289,8 +289,10 @@ int forbidden(struct fproc *rfp, struct vnode *vp, mode_t access_desired)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* read_only *
|
* read_only *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int read_only(vp)
|
int
|
||||||
struct vnode *vp; /* ptr to inode whose file sys is to be cked */
|
read_only(
|
||||||
|
struct vnode *vp /* ptr to inode whose file sys is to be cked */
|
||||||
|
)
|
||||||
{
|
{
|
||||||
/* Check to see if the file system on which the inode 'ip' resides is mounted
|
/* Check to see if the file system on which the inode 'ip' resides is mounted
|
||||||
* read only. If so, return EROFS, else return OK.
|
* read only. If so, return EROFS, else return OK.
|
||||||
|
|
|
||||||
|
|
@ -696,10 +696,8 @@ int req_newdriver(
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* req_putnode *
|
* req_putnode *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int req_putnode(fs_e, inode_nr, count)
|
int
|
||||||
int fs_e;
|
req_putnode(int fs_e, ino_t inode_nr, int count)
|
||||||
ino_t inode_nr;
|
|
||||||
int count;
|
|
||||||
{
|
{
|
||||||
message m;
|
message m;
|
||||||
|
|
||||||
|
|
@ -925,12 +923,8 @@ int req_peek(endpoint_t fs_e, ino_t inode_nr, off_t pos, unsigned int bytes)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* req_rename *
|
* req_rename *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int req_rename(fs_e, old_dir, old_name, new_dir, new_name)
|
int
|
||||||
endpoint_t fs_e;
|
req_rename(endpoint_t fs_e, ino_t old_dir, char *old_name, ino_t new_dir, char *new_name)
|
||||||
ino_t old_dir;
|
|
||||||
char *old_name;
|
|
||||||
ino_t new_dir;
|
|
||||||
char *new_name;
|
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
cp_grant_id_t gid_old, gid_new;
|
cp_grant_id_t gid_old, gid_new;
|
||||||
|
|
@ -969,10 +963,8 @@ char *new_name;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* req_rmdir *
|
* req_rmdir *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int req_rmdir(fs_e, inode_nr, lastc)
|
int
|
||||||
endpoint_t fs_e;
|
req_rmdir(endpoint_t fs_e, ino_t inode_nr, char *lastc)
|
||||||
ino_t inode_nr;
|
|
||||||
char *lastc;
|
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
cp_grant_id_t grant_id;
|
cp_grant_id_t grant_id;
|
||||||
|
|
@ -1138,8 +1130,8 @@ int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e,
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* req_sync *
|
* req_sync *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int req_sync(fs_e)
|
int
|
||||||
endpoint_t fs_e;
|
req_sync(endpoint_t fs_e)
|
||||||
{
|
{
|
||||||
message m;
|
message m;
|
||||||
|
|
||||||
|
|
@ -1154,10 +1146,8 @@ endpoint_t fs_e;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* req_unlink *
|
* req_unlink *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int req_unlink(fs_e, inode_nr, lastc)
|
int
|
||||||
endpoint_t fs_e;
|
req_unlink(endpoint_t fs_e, ino_t inode_nr, char *lastc)
|
||||||
ino_t inode_nr;
|
|
||||||
char *lastc;
|
|
||||||
{
|
{
|
||||||
cp_grant_id_t grant_id;
|
cp_grant_id_t grant_id;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
@ -1186,8 +1176,8 @@ char *lastc;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* req_unmount *
|
* req_unmount *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int req_unmount(fs_e)
|
int
|
||||||
endpoint_t fs_e;
|
req_unmount(endpoint_t fs_e)
|
||||||
{
|
{
|
||||||
message m;
|
message m;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1034,9 +1034,8 @@ static void select_restart_filps(void)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* filp_status *
|
* filp_status *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static void filp_status(f, status)
|
static void
|
||||||
struct filp *f;
|
filp_status(struct filp *f, int status)
|
||||||
int status;
|
|
||||||
{
|
{
|
||||||
/* Tell processes that need to know about the status of this filp. This
|
/* Tell processes that need to know about the status of this filp. This
|
||||||
* function MUST NOT block its calling thread.
|
* function MUST NOT block its calling thread.
|
||||||
|
|
@ -1065,8 +1064,8 @@ int status;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* restart_proc *
|
* restart_proc *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static void restart_proc(se)
|
static void
|
||||||
struct selectentry *se;
|
restart_proc(struct selectentry *se)
|
||||||
{
|
{
|
||||||
/* Tell process about select results (if any) unless there are still results
|
/* Tell process about select results (if any) unless there are still results
|
||||||
* pending. This function MUST NOT block its calling thread.
|
* pending. This function MUST NOT block its calling thread.
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ void check_vmnt_locks_by_me(struct fproc *rfp)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* check_vmnt_locks *
|
* check_vmnt_locks *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void check_vmnt_locks()
|
void
|
||||||
|
check_vmnt_locks(void)
|
||||||
{
|
{
|
||||||
struct vmnt *vmp;
|
struct vmnt *vmp;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ void check_vnode_locks_by_me(struct fproc *rfp)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* check_vnode_locks *
|
* check_vnode_locks *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void check_vnode_locks()
|
void
|
||||||
|
check_vnode_locks(void)
|
||||||
{
|
{
|
||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
@ -80,7 +81,8 @@ void check_vnode_locks()
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* get_free_vnode *
|
* get_free_vnode *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
struct vnode *get_free_vnode()
|
struct vnode *
|
||||||
|
get_free_vnode(void)
|
||||||
{
|
{
|
||||||
/* Find a free vnode slot in the vnode table (it's not actually allocated) */
|
/* Find a free vnode slot in the vnode table (it's not actually allocated) */
|
||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ fetch_and_build_grub()
|
||||||
git clone git://git.savannah.gnu.org/grub.git ${RELEASETOOLSDIR}/grub
|
git clone git://git.savannah.gnu.org/grub.git ${RELEASETOOLSDIR}/grub
|
||||||
pushd ${RELEASETOOLSDIR}/grub
|
pushd ${RELEASETOOLSDIR}/grub
|
||||||
# most recent known working commit at the time of writing
|
# most recent known working commit at the time of writing
|
||||||
git clone b524fa27f56381bb0efa4944e36f50265113aee5
|
git checkout a0bf403f66dbaca4edd8e667bfc397dd91c8d71c
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
./configure --with-platform=efi --target=i386
|
./configure --with-platform=efi --target=i386
|
||||||
make clean
|
make clean
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ INCSDIR= /usr/include/net
|
||||||
|
|
||||||
INCS= bpf.h bpfdesc.h bpfjit.h dlt.h ethertypes.h if.h if_arp.h \
|
INCS= bpf.h bpfdesc.h bpfjit.h dlt.h ethertypes.h if.h if_arp.h \
|
||||||
if_dl.h if_ether.h \
|
if_dl.h if_ether.h \
|
||||||
if_media.h \
|
if_ieee1394.h if_media.h \
|
||||||
if_pflog.h \
|
if_pflog.h \
|
||||||
if_types.h \
|
if_types.h \
|
||||||
pfil.h pfkeyv2.h pfvar.h radix.h \
|
pfil.h pfkeyv2.h pfvar.h radix.h \
|
||||||
|
|
|
||||||
120
sys/net/if_ieee1394.h
Normal file
120
sys/net/if_ieee1394.h
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
/* $NetBSD: if_ieee1394.h,v 1.9 2008/04/28 20:24:09 martin Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Atsushi Onoe.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _NET_IF_IEEE1394_H_
|
||||||
|
#define _NET_IF_IEEE1394_H_
|
||||||
|
|
||||||
|
/* hardware address information for arp / nd */
|
||||||
|
struct ieee1394_hwaddr {
|
||||||
|
uint8_t iha_uid[8]; /* node unique ID */
|
||||||
|
uint8_t iha_maxrec; /* max_rec in the config ROM */
|
||||||
|
uint8_t iha_speed; /* min of link/PHY speed */
|
||||||
|
uint8_t iha_offset[6]; /* unicast FIFO address */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BPF wants to see one of these.
|
||||||
|
*/
|
||||||
|
struct ieee1394_bpfhdr {
|
||||||
|
uint8_t ibh_dhost[8];
|
||||||
|
uint8_t ibh_shost[8];
|
||||||
|
uint16_t ibh_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef _KERNEL
|
||||||
|
|
||||||
|
/* pseudo header */
|
||||||
|
struct ieee1394_header {
|
||||||
|
uint8_t ih_uid[8]; /* dst/src uid */
|
||||||
|
uint8_t ih_maxrec; /* dst maxrec for tx */
|
||||||
|
uint8_t ih_speed; /* speed */
|
||||||
|
uint8_t ih_offset[6]; /* dst offset */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* unfragment encapsulation header */
|
||||||
|
struct ieee1394_unfraghdr {
|
||||||
|
uint16_t iuh_ft; /* fragment type == 0 */
|
||||||
|
uint16_t iuh_etype; /* ether_type */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* fragmented encapsulation header */
|
||||||
|
struct ieee1394_fraghdr {
|
||||||
|
uint16_t ifh_ft_size; /* fragment type, data size-1 */
|
||||||
|
uint16_t ifh_etype_off; /* etype for first fragment */
|
||||||
|
/* offset for subseq frag */
|
||||||
|
uint16_t ifh_dgl; /* datagram label */
|
||||||
|
uint16_t ifh_reserved;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define IEEE1394_FT_SUBSEQ 0x8000
|
||||||
|
#define IEEE1394_FT_MORE 0x4000
|
||||||
|
|
||||||
|
#define IEEE1394MTU 1500
|
||||||
|
|
||||||
|
#define IEEE1394_GASP_LEN 8 /* GASP header for Stream */
|
||||||
|
#define IEEE1394_ADDR_LEN 8
|
||||||
|
#define IEEE1394_CRC_LEN 4
|
||||||
|
|
||||||
|
struct ieee1394_reass_pkt {
|
||||||
|
LIST_ENTRY(ieee1394_reass_pkt) rp_next;
|
||||||
|
struct mbuf *rp_m;
|
||||||
|
uint16_t rp_size;
|
||||||
|
uint16_t rp_etype;
|
||||||
|
uint16_t rp_off;
|
||||||
|
uint16_t rp_dgl;
|
||||||
|
uint16_t rp_len;
|
||||||
|
uint16_t rp_ttl;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ieee1394_reassq {
|
||||||
|
LIST_ENTRY(ieee1394_reassq) rq_node;
|
||||||
|
LIST_HEAD(, ieee1394_reass_pkt) rq_pkt;
|
||||||
|
uint32_t fr_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ieee1394com {
|
||||||
|
struct ifnet fc_if;
|
||||||
|
struct ieee1394_hwaddr ic_hwaddr;
|
||||||
|
uint16_t ic_dgl;
|
||||||
|
LIST_HEAD(, ieee1394_reassq) ic_reassq;
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *ieee1394_sprintf(const uint8_t *);
|
||||||
|
void ieee1394_input(struct ifnet *, struct mbuf *, uint16_t);
|
||||||
|
void ieee1394_ifattach(struct ifnet *, const struct ieee1394_hwaddr *);
|
||||||
|
void ieee1394_ifdetach(struct ifnet *);
|
||||||
|
int ieee1394_ioctl(struct ifnet *, u_long, void *);
|
||||||
|
struct mbuf * ieee1394_fragment(struct ifnet *, struct mbuf *, int, uint16_t);
|
||||||
|
void ieee1394_drain(struct ifnet *);
|
||||||
|
void ieee1394_watchdog(struct ifnet *);
|
||||||
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
|
#endif /* !_NET_IF_IEEE1394_H_ */
|
||||||
Loading…
Reference in New Issue
Block a user