diff options
-rw-r--r-- | dde_e100/Makefile | 2 | ||||
-rw-r--r-- | dde_e100/main.c | 6 | ||||
-rw-r--r-- | dde_e1000/Makefile | 2 | ||||
-rw-r--r-- | dde_e1000/main.c | 6 | ||||
-rw-r--r-- | dde_ne2k_pci/Makefile | 2 | ||||
-rw-r--r-- | dde_ne2k_pci/main.c | 6 | ||||
-rw-r--r-- | dde_pcnet32/Makefile | 2 | ||||
-rw-r--r-- | dde_pcnet32/main.c | 6 | ||||
-rw-r--r-- | dde_rtl8139/Makefile | 2 | ||||
-rw-r--r-- | dde_rtl8139/main.c | 6 | ||||
-rw-r--r-- | libmachdev/Makefile | 3 | ||||
-rw-r--r-- | libmachdev/device_emul.h | 2 | ||||
-rw-r--r-- | libmachdev/ds_routines.c | 14 | ||||
-rw-r--r-- | libmachdev/machdev.h | 32 | ||||
-rw-r--r-- | libmachdev/net.c | 25 |
15 files changed, 79 insertions, 37 deletions
diff --git a/dde_e100/Makefile b/dde_e100/Makefile index fb1ed61e..27504068 100644 --- a/dde_e100/Makefile +++ b/dde_e100/Makefile @@ -10,7 +10,7 @@ TARGET = dde_e100 SRC_C = main.c e100.c LIBS += ../libmachdev/libmachdev.a -ldde_linux26.o -ldde_linux26_net ../libddekit/libddekit.a -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports -lhurd-slab -CFLAGS += -g +CFLAGS += -g -I/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_e100/main.c b/dde_e100/main.c index 8f04bfeb..98f4452a 100644 --- a/dde_e100/main.c +++ b/dde_e100/main.c @@ -6,13 +6,12 @@ #include <linux/init.h> // initcall() #include <linux/delay.h> // msleep() -int using_std = 1; +#include <hurd/machdev.h> -void netif_rx_handle (char *data, int len, struct net_device *dev); +int using_std = 1; int main(int argc, char **argv) { - extern void ds_server(void); l4dde26_init(); l4dde26_process_init(); l4dde26_softirq_init(); @@ -22,6 +21,7 @@ int main(int argc, char **argv) l4dde26_do_initcalls(); + register_net(); mach_device_init(); trivfs_init(); diff --git a/dde_e1000/Makefile b/dde_e1000/Makefile index bfe7dbaf..ffdc17ab 100644 --- a/dde_e1000/Makefile +++ b/dde_e1000/Makefile @@ -10,7 +10,7 @@ TARGET = dde_e1000 SRC_C = main.c e1000_ethtool.c e1000_hw.c e1000_main.c e1000_param.c LIBS += ../libmachdev/libmachdev.a -ldde_linux26.o -ldde_linux26_net ../libddekit/libddekit.a -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports -lhurd-slab -CFLAGS += -g +CFLAGS += -g -I/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_e1000/main.c b/dde_e1000/main.c index 8f04bfeb..98f4452a 100644 --- a/dde_e1000/main.c +++ b/dde_e1000/main.c @@ -6,13 +6,12 @@ #include <linux/init.h> // initcall() #include <linux/delay.h> // msleep() -int using_std = 1; +#include <hurd/machdev.h> -void netif_rx_handle (char *data, int len, struct net_device *dev); +int using_std = 1; int main(int argc, char **argv) { - extern void ds_server(void); l4dde26_init(); l4dde26_process_init(); l4dde26_softirq_init(); @@ -22,6 +21,7 @@ int main(int argc, char **argv) l4dde26_do_initcalls(); + register_net(); mach_device_init(); trivfs_init(); diff --git a/dde_ne2k_pci/Makefile b/dde_ne2k_pci/Makefile index 6cc27279..879904e1 100644 --- a/dde_ne2k_pci/Makefile +++ b/dde_ne2k_pci/Makefile @@ -10,7 +10,7 @@ TARGET = dde_ne2k_pci SRC_C = main.c ne2k-pci.c 8390.c LIBS += ../libmachdev/libmachdev.a -ldde_linux26.o -ldde_linux26_net ../libddekit/libddekit.a -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports -lhurd-slab -CFLAGS += -g +CFLAGS += -g -I/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_ne2k_pci/main.c b/dde_ne2k_pci/main.c index 8f04bfeb..98f4452a 100644 --- a/dde_ne2k_pci/main.c +++ b/dde_ne2k_pci/main.c @@ -6,13 +6,12 @@ #include <linux/init.h> // initcall() #include <linux/delay.h> // msleep() -int using_std = 1; +#include <hurd/machdev.h> -void netif_rx_handle (char *data, int len, struct net_device *dev); +int using_std = 1; int main(int argc, char **argv) { - extern void ds_server(void); l4dde26_init(); l4dde26_process_init(); l4dde26_softirq_init(); @@ -22,6 +21,7 @@ int main(int argc, char **argv) l4dde26_do_initcalls(); + register_net(); mach_device_init(); trivfs_init(); diff --git a/dde_pcnet32/Makefile b/dde_pcnet32/Makefile index 89e67efd..ebbb271e 100644 --- a/dde_pcnet32/Makefile +++ b/dde_pcnet32/Makefile @@ -10,7 +10,7 @@ TARGET = dde_pcnet32 SRC_C = main.c pcnet32.c LIBS += ../libmachdev/libmachdev.a -ldde_linux26.o -ldde_linux26_net ../libddekit/libddekit.a -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports -lhurd-slab -CFLAGS += -g +CFLAGS += -g -I/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_pcnet32/main.c b/dde_pcnet32/main.c index 8f04bfeb..98f4452a 100644 --- a/dde_pcnet32/main.c +++ b/dde_pcnet32/main.c @@ -6,13 +6,12 @@ #include <linux/init.h> // initcall() #include <linux/delay.h> // msleep() -int using_std = 1; +#include <hurd/machdev.h> -void netif_rx_handle (char *data, int len, struct net_device *dev); +int using_std = 1; int main(int argc, char **argv) { - extern void ds_server(void); l4dde26_init(); l4dde26_process_init(); l4dde26_softirq_init(); @@ -22,6 +21,7 @@ int main(int argc, char **argv) l4dde26_do_initcalls(); + register_net(); mach_device_init(); trivfs_init(); diff --git a/dde_rtl8139/Makefile b/dde_rtl8139/Makefile index dcc4a4f1..1af8e179 100644 --- a/dde_rtl8139/Makefile +++ b/dde_rtl8139/Makefile @@ -10,7 +10,7 @@ TARGET = dde_rtl8139 SRC_C = main.c 8139cp.c LIBS += ../libmachdev/libmachdev.a -ldde_linux26.o -ldde_linux26_net ../libddekit/libddekit.a -lfshelp -ltrivfs -lpciaccess -lthreads -lshouldbeinlibc -lports -lhurd-slab -CFLAGS += -g +CFLAGS += -g -I/include # DDE configuration include $(L4DIR)/Makeconf diff --git a/dde_rtl8139/main.c b/dde_rtl8139/main.c index 8f04bfeb..98f4452a 100644 --- a/dde_rtl8139/main.c +++ b/dde_rtl8139/main.c @@ -6,13 +6,12 @@ #include <linux/init.h> // initcall() #include <linux/delay.h> // msleep() -int using_std = 1; +#include <hurd/machdev.h> -void netif_rx_handle (char *data, int len, struct net_device *dev); +int using_std = 1; int main(int argc, char **argv) { - extern void ds_server(void); l4dde26_init(); l4dde26_process_init(); l4dde26_softirq_init(); @@ -22,6 +21,7 @@ int main(int argc, char **argv) l4dde26_do_initcalls(); + register_net(); mach_device_init(); trivfs_init(); diff --git a/libmachdev/Makefile b/libmachdev/Makefile index daf13a82..f64e281a 100644 --- a/libmachdev/Makefile +++ b/libmachdev/Makefile @@ -22,7 +22,8 @@ libname = libmachdev SRCS = deviceUser.c machUser.c net.c ds_routines.c queue.c trivfs_server.c \ device_replyUser.c deviceServer.c notifyServer.c LCLHDRS = dev_hdr.h device_emul.h ds_routines.h vm_param.h \ - util.h queue.h io_req.h if_ether.h + util.h queue.h io_req.h if_ether.h machdev.h +installhdrs = machdev.h device_emul.h HURDLIBS = ports threads trivfs OBJS = $(SRCS:.c=.o) $(MIGSTUBS) diff --git a/libmachdev/device_emul.h b/libmachdev/device_emul.h index edcf6d07..a5bc4f77 100644 --- a/libmachdev/device_emul.h +++ b/libmachdev/device_emul.h @@ -31,7 +31,7 @@ /* Each emulation layer provides these operations. */ struct device_emulation_ops { - void (*init) (); + void (*init) (void); void (*reference) (void *); void (*dealloc) (void *); mach_port_t (*dev_to_port) (void *); diff --git a/libmachdev/ds_routines.c b/libmachdev/ds_routines.c index 1961a2f3..f6a8e76c 100644 --- a/libmachdev/ds_routines.c +++ b/libmachdev/ds_routines.c @@ -73,13 +73,12 @@ static struct port_class *dev_class; extern struct device_emulation_ops linux_net_emulation_ops; -#define NUM_EMULATION (sizeof (emulation_list) / sizeof (emulation_list[0])) +#define NUM_EMULATION num_emul +#define MAX_NUM_EMULATION 32 /* List of emulations. */ -static struct device_emulation_ops *emulation_list[] = -{ - &linux_net_emulation_ops, -}; +static struct device_emulation_ops *emulation_list[MAX_NUM_EMULATION]; +static int num_emul; boolean_t is_master_device (mach_port_t port); @@ -447,6 +446,11 @@ demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) return ret; } +void reg_dev_emul (struct device_emulation_ops *ops) +{ + emulation_list[num_emul++] = ops; +} + void ds_server() { /* Launch. */ diff --git a/libmachdev/machdev.h b/libmachdev/machdev.h new file mode 100644 index 00000000..27c488a5 --- /dev/null +++ b/libmachdev/machdev.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2010 Free Software Foundation, Inc. + Written by Zheng Da. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This file declares interfaces used by driver programs. */ + +#ifndef __MACHDEV_H__ +#define __MACHDEV_H__ + +void ds_server(void); +void mach_device_init(void); +void register_net(void); +void trivfs_server(void); +int trivfs_init(void); + +#endif diff --git a/libmachdev/net.c b/libmachdev/net.c index ca6bca63..e785a5c8 100644 --- a/libmachdev/net.c +++ b/libmachdev/net.c @@ -102,7 +102,6 @@ struct skb_reply struct sk_buff; void skb_done_queue(struct sk_buff *skb); struct sk_buff *skb_done_dequeue(); -void linux_net_emulation_init (); void *skb_reply(struct sk_buff *skb); int netdev_flags(struct net_device *dev); char *netdev_addr(struct net_device *dev); @@ -116,7 +115,7 @@ int dev_open(struct net_device *dev); void *l4dde26_register_rx_callback(void *cb); void skb_done_head_init(); -struct net_data *nd_head; +static struct net_data *nd_head; /* Forward declarations. */ @@ -124,7 +123,7 @@ extern struct device_emulation_ops linux_net_emulation_ops; static int print_packet_size = 1; -mach_msg_type_t header_type = +static mach_msg_type_t header_type = { MACH_MSG_TYPE_BYTE, 8, @@ -135,7 +134,7 @@ mach_msg_type_t header_type = 0 }; -mach_msg_type_t packet_type = +static mach_msg_type_t packet_type = { MACH_MSG_TYPE_BYTE, /* name */ 8, /* size */ @@ -145,7 +144,7 @@ mach_msg_type_t packet_type = FALSE /* deallocate */ }; -struct net_data *search_nd (struct net_device *dev) +static struct net_data *search_nd (struct net_device *dev) { struct net_data *nd = nd_head; @@ -163,7 +162,7 @@ struct net_data *search_nd (struct net_device *dev) /* actions before freeing the sk_buff SKB. * If it returns 1, the packet will be deallocated later. */ -int +static int pre_kfree_skb (struct sk_buff *skb, void *data) { struct skb_reply *reply = data; @@ -190,7 +189,7 @@ pre_kfree_skb (struct sk_buff *skb, void *data) * Deliver the message to all right pfinet servers that * connects to the virtual network interface. */ -int +static int deliver_msg(mach_port_t dest, struct net_rcv_msg *msg) { mach_msg_return_t err; @@ -217,7 +216,7 @@ deliver_msg(mach_port_t dest, struct net_rcv_msg *msg) } /* Accept packet SKB received on an interface. */ -void +static void netif_rx_handle (char *data, int len, struct net_device *dev) { int pack_size; @@ -438,7 +437,7 @@ device_write (void *d, mach_port_t reply_port, /* * Other network operations */ -io_return_t +static io_return_t net_getstat(dev, flavor, status, count) struct net_device *dev; dev_flavor_t flavor; @@ -641,7 +640,7 @@ device_set_filter (void *d, mach_port_t port, int priority, } /* Do any initialization required for network devices. */ -void linux_net_emulation_init () +static void linux_net_emulation_init () { skb_done_head_init(); l4dde26_register_rx_callback(netif_rx_handle); @@ -667,3 +666,9 @@ struct device_emulation_ops linux_net_emulation_ops = NULL, NULL }; + +void register_net() +{ + extern void reg_dev_emul (struct device_emulation_ops *ops); + reg_dev_emul (&linux_net_emulation_ops); +} |