diff options
author | Thomas Schwinge <tschwinge@gnu.org> | 2006-03-19 19:31:16 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-06-18 00:26:36 +0200 |
commit | b80e893edaa066af2a0c5c725c0c394e7c7c20e0 (patch) | |
tree | 7cb2014a52bdace2aa84e6d5a6ee87513b025eea | |
parent | ac066e39f2dab1c3d01fadce2de0e3dbd19dcb73 (diff) |
2006-03-19 Thomas Schwinge <tschwinge@gnu.org>
* DEVELOPMENT: Document the FIPC removal.
2006-03-19 Leonardo Lopes Pereira <leonardolopespereira@gmail.com>
Remove unused and unsuported code. Consult the file `DEVELOPMENT'
for details.
* ipc/fipc.c: Remove file.
* ipc/fipc.h: Likewise.
* Makefile.in (ipc-cfiles): Remove `fipc.c'.
(ipc-files): Remove `fipc.h'.
* device/device_init.c [FIPC]: Remove code.
* device/net_io.c [FIPC]: Likewise.
* include/mach/syscall_sw.h [FIPC]: Likewise.
* kern/syscall_sw.c [FIPC]: Likewise.
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | DEVELOPMENT | 11 | ||||
-rw-r--r-- | Makefile.in | 4 | ||||
-rw-r--r-- | device/device_init.c | 6 | ||||
-rw-r--r-- | device/net_io.c | 57 | ||||
-rw-r--r-- | include/mach/syscall_sw.h | 5 | ||||
-rw-r--r-- | ipc/fipc.c | 795 | ||||
-rw-r--r-- | ipc/fipc.h | 95 | ||||
-rw-r--r-- | kern/syscall_sw.c | 10 |
9 files changed, 28 insertions, 973 deletions
@@ -1,3 +1,21 @@ +2006-03-19 Thomas Schwinge <tschwinge@gnu.org> + + * DEVELOPMENT: Document the FIPC removal. + +2006-03-19 Leonardo Lopes Pereira <leonardolopespereira@gmail.com> + + Remove unused and unsuported code. Consult the file `DEVELOPMENT' + for details. + + * ipc/fipc.c: Remove file. + * ipc/fipc.h: Likewise. + * Makefile.in (ipc-cfiles): Remove `fipc.c'. + (ipc-files): Remove `fipc.h'. + * device/device_init.c [FIPC]: Remove code. + * device/net_io.c [FIPC]: Likewise. + * include/mach/syscall_sw.h [FIPC]: Likewise. + * kern/syscall_sw.c [FIPC]: Likewise. + 2006-03-15 Thomas Schwinge <tschwinge@gnu.org> * configure.in: Check for strip and gzip. diff --git a/DEVELOPMENT b/DEVELOPMENT index 94e0567..ddebfda 100644 --- a/DEVELOPMENT +++ b/DEVELOPMENT @@ -3,6 +3,11 @@ `gnumach-1-branch-before_removing_unused_and_unsupported_code' was tagged on 2006-02-20. After creating that tag, code for unused and unsupported device driver for ISA cards and a good deal of i386 dependent, also -unused and unsupported code was removed. Be sure to check the ChangeLog -and have a look at the repository at that tag's state if you want to work -on the i386 dependent parts of GNU Mach. +unused and unsupported code was removed. + +On 2006-03-19, support was removed for FIPC, which only ever was used +within the native Mach NE2000 NIC device driver, see +<URL:http://www.cs.utah.edu/flux/mach4-i386/html/mach4-UK22.html#FIPC>. + +Be sure to check the ChangeLog and have a look at the repository at that +tag's state if you want to work on those parts of GNU Mach. diff --git a/Makefile.in b/Makefile.in index 2ec9968..fbe1679 100644 --- a/Makefile.in +++ b/Makefile.in @@ -106,11 +106,11 @@ device-files = blkio.c chario.c cirbuf.c cons.c dev_lookup.c dev_name.c \ # IPC implementation ipc-cfiles = $(addprefix ipc_,$(ipc-names)) \ - mach_msg.c mach_port.c mach_rpc.c mach_debug.c fipc.c + mach_msg.c mach_port.c mach_rpc.c mach_debug.c ipc-names = entry.c hash.c init.c kmsg.c marequest.c mqueue.c \ notify.c object.c port.c pset.c right.c space.c splay.c \ table.c target.c thread.c -ipc-files = $(ipc-cfiles) mach_port.srv fipc.h port.h mach_msg.h \ +ipc-files = $(ipc-cfiles) mach_port.srv port.h mach_msg.h \ $(patsubst %,ipc_%.h, \ entry hash init kmsg kmsg_queue machdep marequest mqueue notify \ object port pset right space splay table target thread types) diff --git a/device/device_init.c b/device/device_init.c index 4eef63d..292de92 100644 --- a/device/device_init.c +++ b/device/device_init.c @@ -43,9 +43,6 @@ extern void dev_lookup_init(); extern void net_io_init(); extern void device_pager_init(); extern void chario_init(void); -#ifdef FIPC -extern void fipc_init(); -#endif extern void io_done_thread(); extern void net_thread(); @@ -64,9 +61,6 @@ device_service_create() net_io_init(); device_pager_init(); chario_init(); -#ifdef FIPC - fipc_init(); -#endif (void) kernel_thread(kernel_task, io_done_thread, 0); (void) kernel_thread(kernel_task, net_thread, 0); diff --git a/device/net_io.c b/device/net_io.c index 5762c88..a98523b 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -1432,63 +1432,6 @@ net_write(ifp, start, ior) return (D_IO_QUEUED); } -#ifdef FIPC -/* This gets called by nefoutput for dev_ops->d_port_death ... */ - -io_return_t -net_fwrite(ifp, start, ior) - register struct ifnet *ifp; - int (*start)(); - io_req_t ior; -{ - spl_t s; - kern_return_t rc; - boolean_t wait; - - /* - * Reject the write if the interface is down. - */ - if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) - return (D_DEVICE_DOWN); - - /* - * Reject the write if the packet is too large or too small. - */ - if (ior->io_count < ifp->if_header_size || - ior->io_count > ifp->if_header_size + ifp->if_mtu) - return (D_INVALID_SIZE); - - /* - * DON'T Wire down the memory. - */ -#if 0 - rc = device_write_get(ior, &wait); - if (rc != KERN_SUCCESS) - return (rc); -#endif - /* - * Network interfaces can't cope with VM continuations. - * If wait is set, just panic. - */ - /* I'll have to figure out who was setting wait...*/ -#if 0 - if (wait) { - panic("net_write: VM continuation"); - } -#endif - /* - * Queue the packet on the output queue, and - * start the device. - */ - s = splimp(); - IF_ENQUEUE(&ifp->if_snd, ior); - (*start)(ifp->if_unit); - splx(s); - - return (D_IO_QUEUED); -} -#endif /* FIPC */ - /* * Initialize the whole package. */ diff --git a/include/mach/syscall_sw.h b/include/mach/syscall_sw.h index 03527a5..df5515c 100644 --- a/include/mach/syscall_sw.h +++ b/include/mach/syscall_sw.h @@ -132,9 +132,4 @@ kernel_trap(host_self,-55,0) #endif /* MACH_IPC_COMPAT */ -#ifdef FIPC -kernel_trap(fipc_send,-96,4) -kernel_trap(fipc_recv,-97,5) -#endif - #endif /* _MACH_SYSCALL_SW_H_ */ diff --git a/ipc/fipc.c b/ipc/fipc.c deleted file mode 100644 index ebab640..0000000 --- a/ipc/fipc.c +++ /dev/null @@ -1,795 +0,0 @@ -/* - * Copyright (c) 1996-1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: fipc.c 1.1 96/2/29$ - * Author: Linus Kamb - */ - -#ifdef FIPC - -#include <mach/kern_return.h> - -#include <device/device_types.h> -#include <device/device.h> -#include <device/dev_hdr.h> -#include <device/device_port.h> -#include <device/io_req.h> -#include <device/if_ether.h> -#include <net_io.h> -#include <spl.h> -#include <kern/lock.h> - -#include "fipc.h" - -void fipc_packet(); -void allocate_fipc_buffers(boolean_t); -int fipc_lookup(unsigned short port); -int fipc_lookup_table_enter(unsigned short port); -int fipc_lookup_table_remove(unsigned short port); -int f_lookup_hash(unsigned short port); -int fipc_done(io_req_t ior); - - -/********************************************************************/ -/* fipc variables -/********************************************************************/ - -fipc_port_t fports[N_MAX_OPEN_FIPC_PORTS]; -fipc_lookup_table_ent fipc_lookup_table[N_MAX_OPEN_FIPC_PORTS]; - -int n_free_recv_bufs = 0; -int n_free_send_bufs = 0; -int n_fipc_recv_ports_used = 0; - -int fipc_sends = 0; -int fipc_recvs =0; - -fipc_stat_t fipc_stats; - -char *fipc_recv_free_list = NULL; -char *fipc_recv_free_list_tail = NULL; -char *fipc_send_free_list = NULL; -char *fipc_send_free_list_tail = NULL; - -/* fipc locks */ -decl_simple_lock_data(, fipc_lock); -decl_simple_lock_data(, fipc_buf_q_lock); - - -/* - * Routine: fipc_init(): initializes the fipc data structures. - */ - -void fipc_init(void) -{ - int i; - - allocate_fipc_buffers(TRUE); /* recv buffers */ - allocate_fipc_buffers(FALSE); /* send buffers */ - - fipc_stats.dropped_msgs = 0; - - bzero (&fports, sizeof(fports)); - for (i=0; i<N_MAX_OPEN_FIPC_PORTS; i++) - { - simple_lock_init(&(fports[i].lock)); - fipc_lookup_table[i].fpt_num = INVALID; - fipc_lookup_table[i].fipc_port = INVALID; - } -} - - -/* - * Routine: allocate_fipc_buffers(): allocate more buffers - * Currently we are only allocating 1500 byte (ETHERMTU) buffers. - * We use the first word in the buffer as the pointer to the next. - */ - -void allocate_fipc_buffers(boolean_t r_buf) -{ - char *new_pg; - char **free_list, **free_list_tail; - int *free_count, min_count, max_count; - int total_buffer_size; - - if (r_buf) - { - free_count = &n_free_recv_bufs; - min_count = N_MIN_RECV_BUFS; - max_count = N_MAX_RECV_BUFS; - free_list = &fipc_recv_free_list; - free_list_tail = &fipc_recv_free_list_tail; - total_buffer_size = (N_MAX_RECV_BUFS * FIPC_BUFFER_SIZE); - total_buffer_size = round_page(total_buffer_size); - } - else - { - free_count = &n_free_send_bufs; - min_count = N_MIN_SEND_BUFS; - max_count = N_MAX_SEND_BUFS; - free_list = &fipc_send_free_list; - free_list_tail = &fipc_send_free_list_tail; - total_buffer_size = (N_MAX_SEND_BUFS * FIPC_BUFFER_SIZE); - total_buffer_size = round_page(total_buffer_size); - } - - if (!(*free_count)) /* empty buffer pool */ - { -#ifdef FI_DEBUG - printf ("Allocating new fipc "); - if (r_buf) - printf ("recv buffer pool.\n"); - else - printf ("send buffer pool.\n"); -#endif - *free_list = (char*)kalloc (total_buffer_size); - if (!*free_list) /* bummer */ - panic("allocate_fipc_buffers: no memory"); - *free_list_tail = *free_list; - for (*free_count=1; *free_count<max_count; (*free_count)++) - { - *(char**)*free_list_tail = *free_list_tail + FIPC_BUFFER_SIZE; - *free_list_tail += FIPC_BUFFER_SIZE; - } - *(char**)*free_list_tail = NULL; - } - else /* Request to grow the buffer pool. */ - { -#ifdef FI_DEBUG - printf ("Growing fipc "); - if (r_buf) - printf ("recv buffer pool.\n"); - else - printf ("send buffer pool.\n"); -#endif - -#define GROW_SIZE 8192 - new_pg = (char*)kalloc (round_page(GROW_SIZE)); - if (new_pg) - { - int new_cnt, n_new = GROW_SIZE / FIPC_BUFFER_SIZE; - - if (*free_list_tail != NULL) - *(char**)*free_list_tail = new_pg; - for ( new_cnt =0; new_cnt<n_new; new_cnt++) - { - *(char**)*free_list_tail = *free_list_tail + FIPC_BUFFER_SIZE; - *free_list_tail += FIPC_BUFFER_SIZE; - } - *(char**)*free_list_tail = NULL; - *free_count +=new_cnt; - } -#ifdef FI_DEBUG - else - printf ("### kalloc failed in allocate_fipc_buffers()\n"); -#endif - - } -} - - -/* - * Routine: get_fipc_buffer (): returns a free buffer - * Takes a size (currently not used), a boolean flag to tell if it is a - * receive buffer, and a boolean flag if the request is coming at interrupt - * level. - */ - -inline -char* get_fipc_buffer(int size, boolean_t r_buf, boolean_t at_int_lvl) -{ - /* we currently don't care about size, since there is only one - * buffer pool. */ - - char* head; - char **free_list; - int *free_count, min_count; - - if (r_buf) - { - free_count = &n_free_recv_bufs; - free_list = &fipc_recv_free_list; - min_count = N_MIN_RECV_BUFS; - } - else - { - free_count = &n_free_send_bufs; - free_list = &fipc_send_free_list; - min_count = N_MIN_SEND_BUFS; - } - - /* - * Since we currently allocate a full complement of receive buffers, - * there is no need to allocate more receive buffers. But that is likely - * to change, I'm sure. - */ - - if (*free_count < min_count) - { - if (!at_int_lvl) - allocate_fipc_buffers(r_buf); - } - - if (*free_count) - { - head = *free_list; - *free_list = *(char**)*free_list; - (*free_count)--; - return head; - } - else - return NULL; -} - - -/* - * Routine: return_fipc_buffer (): puts a used buffer back in the pool. - */ - -inline -void return_fipc_buffer(char* buf, int size, - boolean_t r_buf, boolean_t at_int_lvl) -{ - /* return the buffer to the free pool */ - char **free_list, **free_list_tail; - int *free_count, min_count; - - if (r_buf) - { - free_count = &n_free_recv_bufs; - free_list = &fipc_recv_free_list; - free_list_tail = &fipc_recv_free_list_tail; - min_count = N_MIN_RECV_BUFS; - } - else - { - free_count = &n_free_send_bufs; - free_list = &fipc_send_free_list; - free_list_tail = &fipc_send_free_list_tail; - min_count = N_MIN_SEND_BUFS; - } - -#ifdef FI_SECURE - bzero(buf, FIPC_BUFFER_SIZE); -#endif - - if (*free_list_tail != NULL) - *(char**)*free_list_tail = buf; - *free_list_tail = buf; - (*free_count)++; - *(char**)buf = NULL; - - if (!at_int_lvl) - if (*free_count < min_count) - allocate_fipc_buffers(r_buf); - - return; -} - -inline -int f_lookup_hash(unsigned short port) -{ - /* Ok, so it's not really a hash function */ - int bail=0; - int chk=0; - - if (n_fipc_recv_ports_used == N_MAX_OPEN_FIPC_PORTS || - port > MAX_FIPC_PORT_NUM) - return INVALID; - - while (fipc_lookup_table[chk].fipc_port != port && - fipc_lookup_table[chk].fpt_num != INVALID && - bail < N_MAX_OPEN_FIPC_PORTS) - { - chk = (chk+1) % N_MAX_OPEN_FIPC_PORTS; - bail++; - } - - /* This is redundent, but better safe then sorry */ - if (bail<N_MAX_OPEN_FIPC_PORTS) - return chk; - else - return INVALID; -} - -inline -int fipc_lookup_table_enter(unsigned short port) -{ - int cfpn = n_fipc_recv_ports_used; - int lu_tbl_num = f_lookup_hash(port); - - if (lu_tbl_num == INVALID) - return INVALID; - - fipc_lookup_table[lu_tbl_num].fipc_port = port; - fipc_lookup_table[lu_tbl_num].fpt_num = cfpn; - n_fipc_recv_ports_used += 1; - return cfpn; -} - -inline -int fipc_lookup(unsigned short port) -{ - int chk = f_lookup_hash(port); - - if (chk == INVALID) - return INVALID; - - if (fipc_lookup_table[chk].fpt_num == INVALID) - return fipc_lookup_table_enter(port); - else - return fipc_lookup_table[chk].fpt_num; -} - -inline -int fipc_lookup_table_remove(unsigned short port) -{ - int chk = f_lookup_hash(port); - - if (chk == INVALID) - return 0; - - if (fipc_lookup_table[chk].fipc_port == port) - { - fports[fipc_lookup_table[chk].fpt_num].valid_msg = 0; - fports[fipc_lookup_table[chk].fpt_num].bound = FALSE; - fipc_lookup_table[chk].fpt_num = INVALID; - fipc_lookup_table[chk].fipc_port = INVALID; - n_fipc_recv_ports_used -=1; - return 1; - } - return 0; -} - -/* - * Routine: fipc_packet(): handles incoming fipc packets. - * does some simple packet handling and wakes up receiving thread, if any. - * called by device controller (currently, nerecv only.) - * called at interrupt level and splimp. - * Messages are dropped if the recv queue is full. - */ - - void fipc_packet( char* msg_buf, struct ether_header sender) - { - int to_port = ((fipc_header_t*)msg_buf)->dest_port; - int from_port = ((fipc_header_t*)msg_buf)->send_port; - int f_tbl_num; - fipc_port_t *cfp; - fipc_buffer_q_ent *crqe; - int *tail; - -#ifdef FI_DEBUG - printf ("fipc_packet :(0x%x) %s", msg_buf, - msg_buf+sizeof(fipc_header_t)); -#endif - - f_tbl_num = fipc_lookup(to_port); - if (f_tbl_num == INVALID) - { -#ifdef FI_DEBUG - printf ("Lookup failed.\n"); -#endif - fipc_stats.dropped_msgs += 1; - return_fipc_buffer (msg_buf, FIPC_BUFFER_SIZE, TRUE, TRUE); - return; - } - - cfp = &fports[f_tbl_num]; - tail = &cfp->rq_tail; - crqe = &cfp->recv_q[*tail]; - - if (cfp->valid_msg == FIPC_RECV_Q_SIZE) - { - /* Queue full. - * Drop packet, return buffer, and return. */ -#ifdef FI_DEBUG - printf ("Port %d queue is full: valid_msg count: %d\n", - to_port, cfp->valid_msg); -#endif - fipc_stats.dropped_msgs += 1; - return_fipc_buffer (msg_buf, FIPC_BUFFER_SIZE, TRUE, TRUE); - return; - } - - /* "enqueue" at "tail" */ - crqe->buffer = msg_buf; - crqe->size = ((fipc_header_t*)msg_buf)->msg_size; - /* This could certainly be done faster... */ - bcopy(&(sender.ether_shost), &(crqe->sender.hwaddr), ETHER_HWADDR_SIZE); - /* This is actually useless, since there _is_ no sender port.. duh. */ - crqe->sender.port = from_port; - - *tail = ((*tail)+1) % FIPC_RECV_Q_SIZE; - - if (cfp->bound) - thread_wakeup(&(cfp->valid_msg)); - cfp->valid_msg++; -#ifdef FI_DEBUG - printf ("valid_msg: %d\n", cfp->valid_msg); -#endif - - return; - } - - -/* - * loopback(): for fipc_sends to the local host. - */ - -inline -kern_return_t loopback(char *packet) -{ - fipc_packet(packet+sizeof(struct ether_header), - *(struct ether_header*)packet); - return KERN_SUCCESS; -} - - -/********************************************************************/ -/* Routine: fipc_send -/********************************************************************/ - -kern_return_t syscall_fipc_send(fipc_endpoint_t dest, - char *user_buffer, int len) -{ -#ifdef i386 - static mach_device_t eth_device = 0; -#else - static device_t eth_device = 0; -#endif - static unsigned char hwaddr[ETHER_HWADDR_SIZE+2]; - - io_return_t rc; - kern_return_t open_res, kr; - dev_mode_t mode = D_WRITE; - /* register */ io_req_t ior = NULL; - struct ether_header *ehdr; - fipc_header_t *fhdr; - int *d_addr; - int data_count; - char *fipc_buf, *data_buffer; -#ifdef FIPC_LOOPBACK - boolean_t local_send = FALSE; -#endif - -#ifdef FI_DEBUG - printf("fipc_send(dest: %s, port:%d, len:%d, buf:x%x) !!!\n", - ether_sprintf(dest.hwaddr), dest.port, len, user_buffer); -#endif - - if (dest.port > MAX_FIPC_PORT_NUM || - len > FIPC_MSG_SIZE) - { -#ifdef FI_DEBUG - printf ("len: %d, dest.port: %u\n", len, dest.port); -#endif - return KERN_INVALID_ARGUMENT; - } - - /* We should only need to probe the device once. */ - - if (!eth_device) - { - unsigned char net_hwaddr[ETHER_HWADDR_SIZE+2]; - int stat_count = sizeof(net_hwaddr)/sizeof(int); - - /* XXX Automatic lookup for ne0 or ne1 was failing... */ - eth_device = device_lookup(ETHER_DEVICE_NAME); -#ifdef i386 - if (eth_device == (mach_device_t) DEVICE_NULL || - eth_device == (mach_device_t)D_NO_SUCH_DEVICE) -#else - if (eth_device == DEVICE_NULL || - eth_device == (device_t)D_NO_SUCH_DEVICE) -#endif - { -#ifdef FI_DEBUG - printf ("FIPC: Couldn't find ethernet device %s.\n", - ETHER_DEVICE_NAME); -#endif - return (KERN_FAILURE); - } - - /* The device should be open! */ - if (eth_device->state != DEV_STATE_OPEN) - { -#ifdef FI_DEBUG - printf ("Opening ethernet device.\n"); -#endif - - io_req_alloc (ior, 0); - - io_req_alloc (ior, 0); - - ior->io_device = eth_device; - ior->io_unit = eth_device->dev_number; - ior->io_op = IO_OPEN | IO_CALL; - ior->io_mode = mode; - ior->io_error = 0; - ior->io_done = 0; - ior->io_reply_port = MACH_PORT_NULL; - ior->io_reply_port_type = 0; - - /* open the device */ - open_res = - (*eth_device->dev_ops->d_open) - (eth_device->dev_number, - (int)mode, ior); - if (ior->io_error != D_SUCCESS) - { -#ifdef FI_DEBUG - printf ("Failed to open device ne0\n"); -#endif - return open_res; - } - } -#ifdef i386 - rc = mach_device_get_status(eth_device, NET_ADDRESS, - net_hwaddr, &stat_count); -#else - rc = ds_device_get_status(eth_device, NET_ADDRESS, net_hwaddr, - &stat_count); -#endif - if (rc != D_SUCCESS) - { -#ifdef FI_DEBUG - printf("FIPC: Couldn't determine hardware ethernet address: %d\n", - rc); -#endif - return KERN_FAILURE; - } - *(int*)hwaddr = ntohl(*(int*)net_hwaddr); - *(int*)(hwaddr+4) = ntohl(*(int*)(net_hwaddr+4)); -#ifdef FI_DEBUG - printf ("host: %s\n", ether_sprintf(hwaddr)); -#endif - } - -#ifdef FIPC_LOOPBACK - if (!memcmp(dest.hwaddr, hwaddr, ETHER_HWADDR_SIZE)) -/* - if ((*(int*)dest.hwaddr == *(int*)hwaddr) && - ((*(int*)(((char*)dest.hwaddr+4) >> 16)) == - ((*(int*)(((char*)hwaddr+4) >> 16))))) -*/ - { - local_send = TRUE; -#ifdef FI_DEBUG - printf ("loopback: \n"); - printf ("host: %s, ", ether_sprintf(hwaddr)); - printf ("dest: %s\n", ether_sprintf(dest.hwaddr)); -#endif - } -#endif - - data_count = len + sizeof (struct ether_header) - + sizeof (fipc_header_t); - -#ifdef FIPC_LOOPBACK - fipc_buf = get_fipc_buffer(data_count, local_send, FALSE) ; -#else - fipc_buf = get_fipc_buffer(data_count, FALSE, FALSE) ; -#endif - - if (fipc_buf == NULL) - return KERN_RESOURCE_SHORTAGE; - - ehdr = (struct ether_header *)fipc_buf; - d_addr = (int *)ehdr->ether_dhost; - - *(int *)ehdr->ether_dhost = *(int*)dest.hwaddr; - *(int *)(ehdr->ether_dhost+4) = *(int*)(dest.hwaddr+4); - *(int *)ehdr->ether_shost = *(int *)hwaddr; - *(int *)(ehdr->ether_shost+4) = *(int *)(hwaddr+4); - ehdr->ether_type = 0x1234; /* Yep. */ - -#ifdef FIPC_LOOPBACK - if (!local_send) - { -#endif - if (!ior) - io_req_alloc (ior, 0); - - /* Set up the device information. */ - ior->io_device = eth_device; - ior->io_unit = eth_device->dev_number; - ior->io_op = IO_WRITE | IO_INBAND | IO_INTERNAL; - ior->io_mode = D_WRITE; - ior->io_recnum = 0; - ior->io_data = fipc_buf; - ior->io_count = data_count; - ior->io_total = data_count; - ior->io_alloc_size = 0; - ior->io_residual = 0; - ior->io_error = 0; - ior->io_done = fipc_done; - ior->io_reply_port = MACH_PORT_NULL; - ior->io_reply_port_type = 0; - ior->io_copy = VM_MAP_COPY_NULL; -#ifdef FIPC_LOOPBACK - } -#endif - -#ifdef FI_DEBUG - printf("sending from %s ", ether_sprintf(ehdr->ether_shost)); - printf("to %s, type x%x, user_port x%x\n", - ether_sprintf(ehdr->ether_dhost), - (int)ehdr->ether_type, - (int)dest.port); -#endif - - if (len <= FIPC_MSG_SIZE) - { - fhdr = (fipc_header_t*)(fipc_buf+sizeof(struct ether_header)); - fhdr->dest_port = dest.port; - fhdr->msg_size = len; - data_buffer = (char*)fhdr+sizeof(fipc_header_t); - - copyin (user_buffer, data_buffer, - min (FIPC_BUFFER_SIZE-sizeof(fipc_header_t), len)); - -#ifdef FIPC_LOOPBACK - /* - * Sending to same node. Queue on dest.port of this node. - * We just call fipc_packet after setting up the necessary info - * and return. fipc_packet queues the packet on the receive - * queue for the destination port. - */ - if (local_send) - return (loopback(fipc_buf)); -#endif - - /* Now write to the device */ - /* d_port_death has been co-opted for fipc stuff. - * It maps to nefoutput(). */ - - rc = (*eth_device->dev_ops->d_port_death) /* that's the one */ - (eth_device->dev_number, ior); - } -#ifdef FI_DEBUG - else /* len > ETHERMTU: multi-packet request */ - printf ("### multi-packet messages are not supported.\n"); -#endif - - if (rc == D_IO_QUEUED) - return KERN_SUCCESS; - else - return KERN_FAILURE; -} - -#ifdef FIPC_LOOPBACK - if (!local_send) - { -#endif - if (!ior) - io_req_alloc (ior, 0); - - /* Set up the device information. */ - ior->io_device = eth_device; - ior->io_unit = eth_device->dev_number; - ior->io_op = IO_WRITE | IO_INBAND | IO_INTERNAL; - ior->io_mode = D_WRITE; - ior->io_recnum = 0; - ior->io_data = fipc_buf; - ior->io_count = data_count; - ior->io_total = data_count; - ior->io_alloc_size = 0; - ior->io_residual = 0; - ior->io_error = 0; - ior->io_done = fipc_done; - ior->io_reply_port = MACH_PORT_NULL; - ior->io_reply_port_type = 0; - ior->io_copy = VM_MAP_COPY_NULL; -#ifdef FIPC_LOOPBACK - } -#endif - -/******************************************************************** -/* syscall_fipc_recv() -/* -/********************************************************************/ - -kern_return_t syscall_fipc_recv(unsigned short user_port, - char *user_buffer, int *user_size, fipc_endpoint_t *user_sender) -{ - char* f_buffer; - fipc_port_t *cfp; - fipc_buffer_q_ent *crqe; - int *head; - int msg_size; - int fport_num = fipc_lookup(user_port); - spl_t spl; - -#ifdef FI_DEBUG - printf("fipc_recv(0x%x, 0x%x) !!!\n", user_port, user_buffer); -#endif - - if (user_port > MAX_FIPC_PORT_NUM) - { -#ifdef FI_DEBUG - printf ("Invalid FIPC port: %u\n", user_port); -#endif - return KERN_INVALID_ARGUMENT; - } - - if (fport_num == INVALID) - return KERN_RESOURCE_SHORTAGE; - - cfp = &fports[fport_num]; - head = &cfp->rq_head; - crqe = &cfp->recv_q[*head]; - - if (cfp->bound != FALSE) - { -#ifdef FI_DEBUG - printf ("FIPC Port %u is currently bound.\n", user_port); -#endif - return KERN_RESOURCE_SHORTAGE; - } - - copyin(user_size, &msg_size, sizeof(int)); - - spl = splimp(); - - cfp->bound = TRUE; - while (!(cfp->valid_msg)) - { - assert_wait(&(cfp->valid_msg), TRUE); - splx(spl); - thread_block ((void(*)())0); - if (current_thread()->wait_result != THREAD_AWAKENED) - { - cfp->bound = FALSE; - return KERN_FAILURE; - } - spl = splimp(); - } - - cfp->valid_msg--; - f_buffer = crqe->buffer; - msg_size = min (crqe->size, msg_size); - - crqe->buffer = NULL; - crqe->size = 0; - *head = ((*head)+1) % FIPC_RECV_Q_SIZE; - cfp->bound = FALSE; - - splx(spl); - - copyout(f_buffer+sizeof(fipc_header_t), user_buffer, msg_size); - copyout(&(crqe->sender), user_sender, sizeof(fipc_endpoint_t)); - copyout(&msg_size, user_size, sizeof(msg_size)); - - return_fipc_buffer(f_buffer, FIPC_BUFFER_SIZE, TRUE, FALSE); - - return KERN_SUCCESS; -} - - -/* - * Final clean-up after the packet has been sent off. - */ -int fipc_done(io_req_t ior) -{ - return_fipc_buffer(ior->io_data, FIPC_BUFFER_SIZE, FALSE, FALSE); - - return 1; -} - -#endif /* FIPC */ diff --git a/ipc/fipc.h b/ipc/fipc.h deleted file mode 100644 index 2b545c4..0000000 --- a/ipc/fipc.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1996-1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: fipc.h 1.1 96/2/29$ - * Author: Linus Kamb - */ - -#include <kern/lock.h> -#include <device/if_ether.h> - - -#define N_MAX_OPEN_FIPC_PORTS 32 /* In practice, - * this should be much larger */ -#define MAX_FIPC_PORT_NUM 4095 /* ditto */ - -#define FIPC_MSG_TYPE 0x1234 - -#define FIPC_BUFFER_SIZE ETHERMTU -#define FIPC_MSG_SIZE (FIPC_BUFFER_SIZE - sizeof(fipc_header_t)) - -#define FIPC_RECV_Q_SIZE 4 -#define N_MIN_RECV_BUFS 5 /* 2 pages worth */ -#define N_MAX_RECV_BUFS (N_MAX_OPEN_FIPC_PORTS * FIPC_RECV_Q_SIZE) -#define N_MIN_SEND_BUFS 2 -#define N_MAX_SEND_BUFS 5 - -#define INVALID -1 - -#define ETHER_HWADDR_SIZE 6 -#define ETHER_DEVICE_NAME "ne0" - -typedef struct fipc_endpoint_structure -{ - unsigned char hwaddr[ETHER_HWADDR_SIZE]; - unsigned short port; -} fipc_endpoint_t; - -typedef struct fipc_buffer_structure -{ - char *buffer; - unsigned short size; - fipc_endpoint_t sender; -} fipc_buffer_q_ent; - -typedef struct fipc_port_structure -{ - simple_lock_data_t lock; - boolean_t bound; - int valid_msg; - fipc_buffer_q_ent recv_q[FIPC_RECV_Q_SIZE]; - int rq_head, rq_tail; -} fipc_port_t; - -typedef struct fipc_header_structure -{ - unsigned short dest_port; - unsigned short send_port; - unsigned int msg_size; -} fipc_header_t; - -typedef struct fipc_lookup_table_ent_structure -{ - int fipc_port; - int fpt_num; /* f_ports[] entry number */ -} fipc_lookup_table_ent; - -typedef struct fipc_stat_structure -{ - int dropped_msgs; -} fipc_stat_t; - -#define min(a,b) (((a)<=(b)?(a):(b))) - -char* get_fipc_buffer(int, boolean_t, boolean_t); -void fipc_packet(char*, struct ether_header); - -extern int fipc_sends; -extern int fipc_recvs; - diff --git a/kern/syscall_sw.c b/kern/syscall_sw.c index e922b5f..64a5d0d 100644 --- a/kern/syscall_sw.c +++ b/kern/syscall_sw.c @@ -91,11 +91,6 @@ extern kern_return_t evc_wait_clear(); extern kern_return_t syscall_device_write_request(); extern kern_return_t syscall_device_writev_request(); -#ifdef FIPC -extern kern_return_t syscall_fipc_send(); -extern kern_return_t syscall_fipc_recv(); -#endif /* FIPC */ - mach_trap_t mach_trap_table[] = { MACH_TRAP(kern_invalid, 0), /* 0 */ /* Unix */ MACH_TRAP(kern_invalid, 0), /* 1 */ /* Unix */ @@ -220,13 +215,8 @@ mach_trap_t mach_trap_table[] = { MACH_TRAP(kern_invalid, 0), /* 94 */ MACH_TRAP(kern_invalid, 0), /* 95 */ -#ifdef FIPC - MACH_TRAP(syscall_fipc_send, 4), /* 96 */ - MACH_TRAP(syscall_fipc_recv, 5), /* 97 */ -#else MACH_TRAP(kern_invalid, 0), /* 96 */ MACH_TRAP(kern_invalid, 0), /* 97 */ -#endif /* FIPC */ MACH_TRAP(kern_invalid, 0), /* 98 */ MACH_TRAP(kern_invalid, 0), /* 99 */ |