Index: conf/majors =========================================================================== --- conf/majors 2003/06/11 23:19:28 #50 +++ conf/majors 2003/06/11 23:19:28 @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/majors,v 1.175 2003/06/11 18:34:50 tmm Exp $ +# $FreeBSD: src/sys/conf/majors,v 1.174 2003/05/11 06:18:33 scottl Exp $ # # This list is semi-obsoleted by DEVFS, but for now it still contains # the current allocation of device major numbers. @@ -170,6 +170,7 @@ 173 *devctl Devd control device 174 pciwd Berkshire Watchdog PCI 175 ips IBM/Adaptec ServeRAID (control device) +177 *openfirm OpenFirmware control device 178 raidctl RAIDframe (control device) 179 raid RAIDframe (disk device) 180 nvidia NVIDIA (nvidiaN/nvidiactl) Index: dev/ofw/openfirmio.c =========================================================================== --- dev/ofw/openfirmio.c 2003/06/11 23:19:28 #5 +++ dev/ofw/openfirmio.c 2003/06/11 23:19:28 @@ -43,7 +43,7 @@ * * @(#)openfirm.c 8.1 (Berkeley) 6/11/93 * - * $FreeBSD: src/sys/dev/ofw/openfirmio.c,v 1.5 2003/06/11 18:33:03 tmm Exp $ + * $FreeBSD: src/sys/dev/ofw/openfirmio.c,v 1.4 2003/03/03 12:15:44 phk Exp $ */ #include @@ -62,6 +62,7 @@ static d_ioctl_t openfirm_ioctl; +#define CDEV_MAJOR 177 #define OPENFIRM_MINOR 0 static struct cdevsw openfirm_cdevsw = { @@ -69,6 +70,7 @@ .d_close = nullclose, .d_ioctl = openfirm_ioctl, .d_name = "openfirm", + .d_maj = CDEV_MAJOR, }; static phandle_t lastnode; /* speed hack */ @@ -122,9 +124,6 @@ char *name, *value; char newname[32]; - if ((flags & FREAD) == 0) - return (EBADF); - of = (struct ofiocdesc *)data; switch (cmd) { case OFIOCGETOPTNODE: @@ -136,7 +135,6 @@ #endif case OFIOCNEXTPROP: case OFIOCFINDDEVICE: - case OFIOCGETPROPLEN: node = of->of_nodeid; break; case OFIOCGETNEXT: @@ -144,7 +142,7 @@ node = *(phandle_t *)data; break; default: - return (ENOIOCTL); + return (ENOTTY); } if (node != 0 && node != lastnode) { @@ -160,17 +158,14 @@ switch (cmd) { case OFIOCGET: - case OFIOCGETPROPLEN: + if ((flags & FREAD) == 0) + return (EBADF); if (node == 0) return (EINVAL); error = openfirm_getstr(of->of_namelen, of->of_name, &name); if (error) break; len = OF_getproplen(node, name); - if (cmd == OFIOCGETPROPLEN) { - of->of_buflen = len; - break; - } if (len > of->of_buflen) { error = ENOMEM; break; @@ -207,6 +202,8 @@ #endif case OFIOCNEXTPROP: + if ((flags & FREAD) == 0) + return (EBADF); if (node == 0 || of->of_buflen < 0) return (EINVAL); if (of->of_namelen != 0) { @@ -233,11 +230,15 @@ break; case OFIOCGETNEXT: + if ((flags & FREAD) == 0) + return (EBADF); node = OF_peer(node); *(phandle_t *)data = lastnode = node; break; case OFIOCGETCHILD: + if ((flags & FREAD) == 0) + return (EBADF); if (node == 0) return (EINVAL); node = OF_child(node); @@ -245,6 +246,8 @@ break; case OFIOCFINDDEVICE: + if ((flags & FREAD) == 0) + return (EBADF); error = openfirm_getstr(of->of_namelen, of->of_name, &name); if (error) break; Index: dev/ofw/openfirmio.h =========================================================================== --- dev/ofw/openfirmio.h 2003/06/11 23:19:28 #2 +++ dev/ofw/openfirmio.h 2003/06/11 23:19:28 @@ -43,7 +43,7 @@ * * @(#)openpromio.h 8.1 (Berkeley) 6/11/93 * - * $FreeBSD: src/sys/dev/ofw/openfirmio.h,v 1.2 2003/06/11 18:33:03 tmm Exp $ + * $FreeBSD: src/sys/dev/ofw/openfirmio.h,v 1.1 2002/10/18 15:23:43 tmm Exp $ */ #ifndef _DEV_OFW_OPENFIRMIO_H_ @@ -77,7 +77,5 @@ #define OFIOCGETCHILD _IOWR(OFIOC_BASE, 6, phandle_t) /* Find a specific device. */ #define OFIOCFINDDEVICE _IOWR(OFIOC_BASE, 7, struct ofiocdesc) -/* Retrieve the size of a property. */ -#define OFIOCGETPROPLEN _IOWR(OFIOC_BASE, 8, struct ofiocdesc) #endif /* _DEV_OFW_OPENFIRMIO_H_ */ Index: dev/pccard/pccarddevs =========================================================================== --- dev/pccard/pccarddevs 2003/06/11 23:19:28 #39 +++ dev/pccard/pccarddevs 2003/06/11 23:19:28 @@ -1,4 +1,4 @@ -$FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.52 2003/06/11 16:53:26 imp Exp $ +$FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.51 2003/06/03 01:29:01 imp Exp $ /* $NetBSD: pcmciadevs,v 1.182 2003/04/09 02:09:55 christos Exp $ */ /* $OpenBSD: pcmciadevs,v 1.93 2002/06/21 08:31:10 henning Exp $ */ @@ -88,7 +88,6 @@ vendor NOKIA 0x023d Nokia Communications vendor SAMSUNG 0x0250 Samsung vendor HWN 0x0261 Home Wireless Networks -vendor ARTEM 0x0268 ARtem vendor SYMBOL 0x026c Symbol vendor BUFFALO 0x026f BUFFALO (Melco Corporation) vendor LINKSYS2 0x0274 The Linksys Group @@ -155,9 +154,6 @@ /* Archos */ product ARCHOS ARC_ATAPI 0x0043 MiniCD -/* ARtem */ -product ARTEM ONAIR 0x0001 ARtem OnAir - /* Bay Networks */ product BAY STACK_650 0x0804 BayStack 650 Wireless LAN product BAY SURFER_PRO 0x0806 AirSurfer Pro Wireless LAN Index: dev/pccard/pccarddevs.h =========================================================================== --- dev/pccard/pccarddevs.h 2003/06/11 23:19:28 #39 +++ dev/pccard/pccarddevs.h 2003/06/11 23:19:28 @@ -1,10 +1,10 @@ -/* $FreeBSD: src/sys/dev/pccard/pccarddevs.h,v 1.52 2003/06/11 16:53:47 imp Exp $ */ +/* $FreeBSD: src/sys/dev/pccard/pccarddevs.h,v 1.51 2003/06/03 01:29:58 imp Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.52 2003/06/11 16:53:26 imp Exp + * FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.51 2003/06/03 01:29:01 imp Exp */ /* $NetBSD: pcmciadevs,v 1.182 2003/04/09 02:09:55 christos Exp $ */ /* $OpenBSD: pcmciadevs,v 1.93 2002/06/21 08:31:10 henning Exp $ */ @@ -95,7 +95,6 @@ #define PCMCIA_VENDOR_NOKIA 0x023d /* Nokia Communications */ #define PCMCIA_VENDOR_SAMSUNG 0x0250 /* Samsung */ #define PCMCIA_VENDOR_HWN 0x0261 /* Home Wireless Networks */ -#define PCMCIA_VENDOR_ARTEM 0x0268 /* ARtem */ #define PCMCIA_VENDOR_SYMBOL 0x026c /* Symbol */ #define PCMCIA_VENDOR_BUFFALO 0x026f /* BUFFALO (Melco Corporation) */ #define PCMCIA_VENDOR_LINKSYS2 0x0274 /* The Linksys Group */ @@ -200,11 +199,6 @@ #define PCMCIA_PRODUCT_ARCHOS_ARC_ATAPI 0x0043 #define PCMCIA_STR_ARCHOS_ARC_ATAPI "MiniCD" -/* ARtem */ -#define PCMCIA_CIS_ARTEM_ONAIR { NULL, NULL, NULL, NULL } -#define PCMCIA_PRODUCT_ARTEM_ONAIR 0x0001 -#define PCMCIA_STR_ARTEM_ONAIR "ARtem OnAir" - /* Bay Networks */ #define PCMCIA_CIS_BAY_STACK_650 { NULL, NULL, NULL, NULL } #define PCMCIA_PRODUCT_BAY_STACK_650 0x0804 Index: dev/wi/if_wi.c =========================================================================== --- dev/wi/if_wi.c 2003/06/11 23:19:28 #87 +++ dev/wi/if_wi.c 2003/06/11 23:19:28 @@ -62,7 +62,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/wi/if_wi.c,v 1.141 2003/06/11 16:51:27 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/wi/if_wi.c,v 1.140 2003/04/29 03:22:39 imp Exp $"); #define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */ #define WI_HERMES_STATS_WAR /* Work around stats counter bug. */ @@ -2153,8 +2153,9 @@ /* wait for the busy bit to clear */ for (i = 500; i > 0; i--) { /* 5s */ - if (!(CSR_READ_2(sc, WI_COMMAND) & WI_CMD_BUSY)) + if (!(CSR_READ_2(sc, WI_COMMAND) & WI_CMD_BUSY)) { break; + } DELAY(10*1000); /* 10 m sec */ } if (i == 0) { @@ -2170,7 +2171,7 @@ if (cmd == WI_CMD_INI) { /* XXX: should sleep here. */ - DELAY(100*1000); /* 100ms delay for init */ + DELAY(100*1000); } for (i = 0; i < WI_TIMEOUT; i++) { /* @@ -2182,6 +2183,10 @@ /* Ack the event and read result code. */ s = CSR_READ_2(sc, WI_STATUS); CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_CMD); +#ifdef foo + if ((s & WI_CMD_CODE_MASK) != (cmd & WI_CMD_CODE_MASK)) + return(EIO); +#endif if (s & WI_STAT_CMD_RESULT) { count--; return(EIO); Index: dev/wi/if_wi_pccard.c =========================================================================== --- dev/wi/if_wi_pccard.c 2003/06/11 23:19:28 #27 +++ dev/wi/if_wi_pccard.c 2003/06/11 23:19:28 @@ -39,7 +39,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/wi/if_wi_pccard.c,v 1.27 2003/06/11 16:56:02 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/wi/if_wi_pccard.c,v 1.25 2003/04/27 03:34:05 imp Exp $"); #include "opt_wi.h" @@ -127,7 +127,6 @@ PCMCIA_CARD(ACTIONTEC, PRISM, 0), PCMCIA_CARD(ADDTRON, AWP100, 0), PCMCIA_CARD(ALLIEDTELESIS, WR211PCM, 0), - PCMCIA_CARD(ARTEM, ONAIR, 0), PCMCIA_CARD(BAY, EMOBILITY_11B, 0), PCMCIA_CARD(BUFFALO, WLI_PCM_S11, 0), PCMCIA_CARD(BUFFALO, WLI_CF_S11G, 0), @@ -211,7 +210,6 @@ int error; uint32_t vendor; uint32_t product; - int retval; sc = device_get_softc(dev); @@ -239,13 +237,10 @@ #else device_printf(dev, "Symbol LA4100 needs 'option WI_SYMBOL_FIRMWARE'\n"); - wi_free(dev); return (ENXIO); #endif } #endif - retval = wi_attach(dev); - if (retval != 0) - wi_free(dev); - return (retval); + + return (wi_attach(dev)); } Index: dev/wi/if_wi_pci.c =========================================================================== --- dev/wi/if_wi_pci.c 2003/06/11 23:19:28 #15 +++ dev/wi/if_wi_pci.c 2003/06/11 23:19:28 @@ -29,7 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/wi/if_wi_pci.c,v 1.15 2003/06/11 16:41:07 imp Exp $ + * $FreeBSD: src/sys/dev/wi/if_wi_pci.c,v 1.14 2003/04/15 06:37:28 mdodd Exp $ */ /* @@ -235,8 +235,9 @@ error = wi_attach(dev); if (error != 0) - wi_free(dev); - return (error); + return (error); + + return (0); } static int Index: fritz/README =========================================================================== *** /dev/null Wed Jun 11 23:19:12 2003 --- fritz/README Wed Jun 11 23:19:33 2003 *************** *** 0 **** --- 1,43 ---- + The Fritz Kernel HTTPD Server. + + This is a small http server used for demonstration + purposes, and not meant for production systems. It + should support the following modes in future: + + - Standalone (listen) mode + - Accept filter (pass it up) mode. + + STANDALONE MODE + --------------- + + The server will listen on the designated port (80 by default) + and serve static http requets, and return ``Permission Denied'' + for dynamic requests, such as CGI stuff. To use the standalone + version, then you need to compile the server as + `make -DFRITZ_STANDALONE` + + ACCEPT FILTER MODE + ------------------ + + Run as an accept filter, where static http requests will be + served by the http processing engine, and dynamic requests + will be upcalled to a userland http server. To use the + Accept Filter version, then you need to compile the server + as `make -DFRITZ_ACCEPT_FILTER`. + + WHY NOT SUPPORT DYNAMIC REQUESTS? + --------------------------------- + + I am not up for it. Take this or leave it. 8-) + + STATUS + ------ + + The server is not done, and this is just the barebone code. + Currently, it only binds to a port and sits there and listens. + I will soon have some code for processing the requests. + Designing the Accept Filter version of the code is much simpler + than the standalone version, because of the select()/kqueue() + issues etc. + + -- Hiten (hmp@FreeBSD.ORG) Index: fritz/f_accf.c =========================================================================== *** /dev/null Wed Jun 11 23:19:12 2003 --- fritz/f_accf.c Wed Jun 11 23:19:34 2003 *************** *** 0 **** --- 1,352 ---- + /*- + * Copyright (c) 2003 Hiten M. Pandya. All rights reserved. + * Copyright (c) 2000 Paycounter, Inc. + * Author: Alfred Perlstein , + * All rights reserved. + * + * Redistribution and use in source and binary forms with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistribution of source code must retain the above copyright + * notice immediately at the beginning of the file, without + * modification, this list of conditions, and the following + * disclaimer. + * + * 2. Absolutely no warranty of function or purpose is made by the + * author Hiten M. Pandya, or The FreeBSD Project. + * + */ + #define ACCEPT_FILTER_MOD + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #include /* for fritz.h */ + #include + + /* check for GET/HEAD */ + static void sohashttpget(struct socket *so, void *arg, int waitflag); + /* check for HTTP/1.0 or HTTP/1.1 */ + static void soparsehttpvers(struct socket *so, void *arg, int waitflag); + /* check for end of HTTP/1.x request */ + static void soishttpconnected(struct socket *so, void *arg, int waitflag); + /* strcmp on an mbuf chain */ + static int mbufstrcmp(struct mbuf *m, struct mbuf *npkt, int offset, char *cmp); + /* strncmp on an mbuf chain */ + static int mbufstrncmp(struct mbuf *m, struct mbuf *npkt, int offset, + int max, char *cmp); + /* socketbuffer is full */ + static int sbfull(struct sockbuf *sb); + + static struct accept_filter f_accf_filter = { + "f", + sohashttpget, + NULL, + NULL + }; + #if 0 + static moduledata_t f_accf_mod = { + "f_mod", + accept_filt_generic_mod_event, + &f_accf_filter + }; + + /* + * We need to do this seperately because it is + * an accept filter. + */ + DECLARE_MODULE(f_accf, f_accf_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); + #endif + + static int parse_http_version = 1; + + #ifdef ACCF_HTTP_DEBUG + #define DPRINT(fmt, args...) \ + do { \ + printf("%s:%d: " fmt "\n", __func__, __LINE__ , ##args); \ + } while (0) + #else + #define DPRINT(fmt, args...) + #endif + + static __inline int + sbfull(struct sockbuf *sb) + { + + DPRINT("sbfull, cc(%ld) >= hiwat(%ld): %d, mbcnt(%ld) >= mbmax(%ld): %d", + sb->sb_cc, sb->sb_hiwat, sb->sb_cc >= sb->sb_hiwat, + sb->sb_mbcnt, sb->sb_mbmax, sb->sb_mbcnt >= sb->sb_mbmax); + return(sb->sb_cc >= sb->sb_hiwat || sb->sb_mbcnt >= sb->sb_mbmax); + } + + /* + * start at mbuf m, (must provide npkt if exists) + * starting at offset in m compare characters in mbuf chain for 'cmp' + */ + static int + mbufstrcmp(struct mbuf *m, struct mbuf *npkt, int offset, char *cmp) + { + struct mbuf *n; + + for (;m != NULL; m = n) { + n = npkt; + if (npkt) + npkt = npkt->m_nextpkt; + for (; m; m = m->m_next) { + for (; offset < m->m_len; offset++, cmp++) { + if (*cmp == '\0') { + return (1); + } else if (*cmp != *(mtod(m, char *) + offset)) { + return (0); + } + } + offset = 0; + } + } + return (0); + } + + /* + * start at mbuf m, (must provide npkt if exists) + * starting at offset in m compare characters in mbuf chain for 'cmp' + * stop at 'max' characters + */ + static int + mbufstrncmp(struct mbuf *m, struct mbuf *npkt, int offset, int max, char *cmp) + { + struct mbuf *n; + + for (;m != NULL; m = n) { + n = npkt; + if (npkt) + npkt = npkt->m_nextpkt; + for (; m; m = m->m_next) { + for (; offset < m->m_len; offset++, cmp++, max--) { + if (max == 0 || *cmp == '\0') { + return (1); + } else if (*cmp != *(mtod(m, char *) + offset)) { + return (0); + } + } + offset = 0; + } + } + return (0); + } + + #define STRSETUP(sptr, slen, str) \ + do { \ + sptr = str; \ + slen = sizeof(str) - 1; \ + } while(0) + + static void + sohashttpget(struct socket *so, void *arg, int waitflag) + { + + if ((so->so_state & SS_CANTRCVMORE) == 0 && !sbfull(&so->so_rcv)) { + struct mbuf *m; + char *cmp; + int cmplen, cc; + + m = so->so_rcv.sb_mb; + cc = so->so_rcv.sb_cc - 1; + if (cc < 1) + return; + switch (*mtod(m, char *)) { + case 'G': + STRSETUP(cmp, cmplen, "ET "); + break; + case 'H': + STRSETUP(cmp, cmplen, "EAD "); + break; + default: + goto fallout; + } + if (cc < cmplen) { + if (mbufstrncmp(m, m->m_nextpkt, 1, cc, cmp) == 1) { + DPRINT("short cc (%d) but mbufstrncmp ok", cc); + return; + } else { + DPRINT("short cc (%d) mbufstrncmp failed", cc); + goto fallout; + } + } + if (mbufstrcmp(m, m->m_nextpkt, 1, cmp) == 1) { + DPRINT("mbufstrcmp ok"); + if (parse_http_version == 0) + soishttpconnected(so, arg, waitflag); + else + soparsehttpvers(so, arg, waitflag); + return; + } + DPRINT("mbufstrcmp bad"); + } + + fallout: + DPRINT("fallout"); + so->so_upcall = NULL; + so->so_rcv.sb_flags &= ~SB_UPCALL; + soisconnected(so); + return; + } + + static void + soparsehttpvers(struct socket *so, void *arg, int waitflag) + { + struct mbuf *m, *n; + int i, cc, spaces, inspaces; + + if ((so->so_state & SS_CANTRCVMORE) != 0 || sbfull(&so->so_rcv)) + goto fallout; + + m = so->so_rcv.sb_mb; + cc = so->so_rcv.sb_cc; + inspaces = spaces = 0; + for (m = so->so_rcv.sb_mb; m; m = n) { + n = m->m_nextpkt; + for (; m; m = m->m_next) { + for (i = 0; i < m->m_len; i++, cc--) { + switch (*(mtod(m, char *) + i)) { + case ' ': + if (!inspaces) { + spaces++; + inspaces = 1; + } + break; + case '\r': + case '\n': + DPRINT("newline"); + goto fallout; + default: + if (spaces == 2) { + /* make sure we have enough data left */ + if (cc < sizeof("HTTP/1.0") - 1) { + if (mbufstrncmp(m, n, i, cc, "HTTP/1.") == 1) { + DPRINT("mbufstrncmp ok"); + goto readmore; + } else { + DPRINT("mbufstrncmp bad"); + goto fallout; + } + } else if (mbufstrcmp(m, n, i, "HTTP/1.0") == 1 || + mbufstrcmp(m, n, i, "HTTP/1.1") == 1) { + DPRINT("mbufstrcmp ok"); + soishttpconnected(so, arg, waitflag); + return; + } else { + DPRINT("mbufstrcmp bad"); + goto fallout; + } + } + inspaces = 0; + break; + } + } + } + } + readmore: + DPRINT("readmore"); + /* + * if we hit here we haven't hit something + * we don't understand or a newline, so try again + */ + so->so_upcall = soparsehttpvers; + so->so_rcv.sb_flags |= SB_UPCALL; + return; + + fallout: + DPRINT("fallout"); + so->so_upcall = NULL; + so->so_rcv.sb_flags &= ~SB_UPCALL; + soisconnected(so); + return; + } + + + #define NCHRS 3 + + static void + soishttpconnected(struct socket *so, void *arg, int waitflag) + { + char a, b, c; + struct f_softc *fsc = NULL; + struct mbuf *m, *n; + int ccleft, copied; + + DPRINT("start"); + if ((so->so_state & SS_CANTRCVMORE) != 0 || sbfull(&so->so_rcv)) + goto gotit; + + /* + * Walk the socketbuffer and copy the last NCHRS (3) into a, b, and c + * copied - how much we've copied so far + * ccleft - how many bytes remaining in the socketbuffer + * just loop over the mbufs subtracting from 'ccleft' until we only + * have NCHRS left + */ + copied = 0; + ccleft = so->so_rcv.sb_cc; + if (ccleft < NCHRS) + goto readmore; + a = b = c = '\0'; + for (m = so->so_rcv.sb_mb; m; m = n) { + n = m->m_nextpkt; + for (; m; m = m->m_next) { + ccleft -= m->m_len; + if (ccleft <= NCHRS) { + char *src; + int tocopy; + + tocopy = (NCHRS - ccleft) - copied; + src = mtod(m, char *) + (m->m_len - tocopy); + + while (tocopy--) { + switch (copied++) { + case 0: + a = *src++; + break; + case 1: + b = *src++; + break; + case 2: + c = *src++; + break; + } + } + } + } + } + if (c == '\n' && (b == '\n' || (b == '\r' && a == '\n'))) { + /* we have all request headers */ + goto gotit; + } + + readmore: + so->so_upcall = soishttpconnected; + so->so_rcv.sb_flags |= SB_UPCALL; + return; + + gotit: + so->so_upcall = NULL; + so->so_rcv.sb_flags &= ~SB_UPCALL; + f_enqueue(so, fsc); + return; + } Index: fritz/f_httpd.c =========================================================================== *** /dev/null Wed Jun 11 23:19:12 2003 --- fritz/f_httpd.c Wed Jun 11 23:19:36 2003 *************** *** 0 **** --- 1,206 ---- + /*- + * Copyright (c) 2003 Hiten M. Pandya. All rights reserved. + * + * Redistribution and use in source and binary forms with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistribution of source code must retain the above copyright + * notice immediately at the beginning of the file, without + * modification, this list of conditions, and the following + * disclaimer. + * + * 2. Absolutely no warranty of function or purpose is made by the + * author Hiten M. Pandya, or The FreeBSD Project. + * + * $Id: f_httpd.c,v 1.1 2003/04/18 10:49:07 hiten Exp $ + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + + /* + * just pure evilness of doing things in the kernel... + */ + + #define LISTENQUEUE 10 /* default: # of maximum pending connections. */ + #define LISTENPORT 80 /* default: port number to listen on for connections. */ + + #ifdef MALLOC_DECLARE + MALLOC_DECLARE(M_FRITZ); + #endif + MALLOC_DEFINE(M_FRITZ, "fritz", "fritz soft context data"); + + static struct f_softc { + struct socket *lso; /* listen socket for connections. */ + struct socket *aso; /* accept socket for new connections. */ + } *fsc; + + static int init_server(void); + static void uninit_server(void); + + /* + * sysctl stuff. + * ... also make them tunables so preset can be done. + */ + static int f_listen_queue = 80; + static int f_listen_port = 10; + static char f_inet_iface[IFNAMSIZ] = "0"; + SYSCTL_NODE(_net, OID_AUTO, fritz, CTLFLAG_RW, 0, "Fritz"); + SYSCTL_INT(_net_fritz, OID_AUTO, queue_size, CTLFLAG_RW, &f_listen_queue, 0, + "Maximum listen() queue size"); + SYSCTL_INT(_net_fritz, OID_AUTO, port, CTLFLAG_RW, &f_listen_port, 0, + "Server port number"); + SYSCTL_STRING(_net_fritz, OID_AUTO, ip_address, CTLFLAG_RW, &f_inet_iface, 0, + "INET interface for binding"); + + /* + * SYSINIT dynamic callback functionlity + * put to test. + * It loads my network server bit. + */ + static void + init_myserver(void *dummy) + { + int error; + struct thread *td = curthread; /* this will change with kthread. */ + + /* + * allocate memory for the softc. + */ + fsc = (struct f_softc *) malloc(sizeof (struct f_softc), M_FRITZ, M_NOWAIT); + if (fsc == NULL) { + panic("Memory allocation failed for Fritz (ENOMEM)"); + } + + /* + * create listen socket. (use pru_* interface in future.) + */ + error = socreate(AF_INET, &fsc->lso, SOCK_STREAM, IPPROTO_TCP, td->td_ucred, td); + if (error != 0) + panic("socreate returned: %d\n", error); + + log(LOG_KERN, "Fritz has successfully initialized."); + } + SYSINIT(fritz, SI_SUB_DRIVERS, SI_ORDER_ANY, init_myserver, NULL); + + static int + init_server(void) + { + + int error; + struct thread *td = curthread; + struct ifnet *bindifp; /* interface we will be binding on. */ + struct in_ifaddr *ifa; /* socket address structure from interface. */ + struct sockaddr_in sa; /* socket address */ + #if 0 + struct socket *conso; /* we will receive connections on this. */ + #endif + + /* + * bind to the local interface, as this saves + * us the headache of doing the various interface + * find crap. + */ + bindifp = ifunit("lo0"); + if (bindifp != NULL) { + IFP_TO_IA(bindifp, ifa); + sa = (struct sockaddr_in) ifa->ia_addr; + if (sa.sin_family != AF_INET) + printf("We just hit a roadblock [!AF_INET]\n"); + } else { + printf("fatal: could not acquire local interface.\n"); + return -1; + } + + /* + * Call the internal socket bind interface. + */ + sa.sin_port = htons(LISTENPORT); + sa.sin_len = sizeof (struct sockaddr_in); + printf("Listen IP address: %s\n", inet_ntoa(sa.sin_addr)); + bzero(&(sa.sin_zero), 8); /* zero the rest */ + + error = sobind((fsc->lso), sintosa(&sa), td); + if (error != 0) { + printf("sobind returned: %d\n", error); + goto bad; + } + + /* + * Start our listen request. + */ + error = solisten(fsc->lso, LISTENQUEUE, td); + if (error != 0) { + printf("solisten returned: %d\n", error); + return (error); + } + + return (0); + bad: + soshutdown(fsc->lso, SHUT_RDWR); + soclose(fsc->lso); + return (error); + } + + /* + * Resource deallocation, and shutdown of server. + */ + static void + uninit_server(void) + { + soshutdown(fsc->lso, SHUT_RDWR); + soclose(fsc->lso); /* this routine also performs de-allocation. */ + } + + /* + * The function called at load/unload. + */ + + static int + load (struct module *module, int cmd, void *arg) + { + int error, s; + error = s = 0; + + switch (cmd) { + case MOD_LOAD : + s = init_server(); + if (s != 0) + return(s); + break; + case MOD_UNLOAD : + printf("unloading server... "); + uninit_server(); + printf ("done.\n"); + break; + default : + error = EINVAL; + break; + } + return error; + } + + static moduledata_t mod_data = { + "fritz", + load, + 0 + }; + + DECLARE_MODULE(fritz, mod_data, SI_SUB_DRIVERS, SI_ORDER_ANY); Index: fritz/fritz.h =========================================================================== *** /dev/null Wed Jun 11 23:19:12 2003 --- fritz/fritz.h Wed Jun 11 23:19:37 2003 *************** *** 0 **** --- 1,50 ---- + /*- + * Copyright (c) 2003 Hiten M. Pandya. All rights reserved. + * + * Redistribution and use in source and binary forms with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistribution of source code must retain the above copyright + * notice immediately at the beginning of the file, without + * modification, this list of conditions, and the following + * disclaimer. + * + * 2. Absolutely no warranty of function or purpose is made by the + * author Hiten M. Pandya, or The FreeBSD Project. + */ + + #define F_HTTP_BANNER "fritz/1.0" /* http banner */ + #define F_BUFFSIZE 1024 /* buffer size */ + #define F_MAXSESSIONS 1024 /* max sessions */ + #define F_PORT 80 /* default port */ + + /* Error defines */ + #define E_F_MAXQUEUE "Max limit of connections reached" + #define E_F_MAXSESSION "Max session limit reached" + + /* Bastardized version of the DPRINT() macro from f_accf.c */ + #define F_DPRINT(err) \ + printf("[FRITZ] %s: " err "\n\n", __func__); + + struct f_softc { + char buffer[F_BUFFSIZE]; /* Buffer size */ + struct proc *kproc; /* proc structure */ + TAILQ_HEAD(, socket) *so_kcomp; /* complete list */ + }; + + struct fritzstat { + u_long fcs_compreq; /* completed requests */ + u_long fcs_incompreq; /* failed reqeuests */ + u_long fcs_falloc; /* failed allocations */ + }; + + extern struct fritzstat fritzstat; + + #ifdef MALLOC_DECLARE + MALLOC_DECLARE(M_FRITZ); + #endif + + void f_enqueue(struct socket *, struct f_softc *); + void f_thread(void *); + int f_srvinit(struct sockaddr_in *, struct proc *); Index: fritz/mhttpd.c =========================================================================== *** /dev/null Wed Jun 11 23:19:12 2003 --- fritz/mhttpd.c Wed Jun 11 23:19:38 2003 *************** *** 0 **** --- 1,188 ---- + /* + * micro_httpd - really small HTTP server * + * + * Copyright © 1999 by Jef Poskanzer . All rights reserved. * + * + * 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 AUTHOR 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 AUTHOR 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. + */ + + #include + #include + #include + #include + #include + #include + #include + + #define SERVER_NAME "micro_httpd" + #define SERVER_URL "http://www.acme.com/software/micro_httpd/" + #define PROTOCOL "HTTP/1.0" + #define RFC1123FMT "%a, %d %b %Y %H:%M:%S GMT" + + /* Forwards. */ + static void send_error(int status, char *title, char *extra_header, char *text); + static void send_headers(int status, char *title, char *extra_header, char *mime_type, off_t length, time_t mod); + static char *get_mime_type(char *name); + + int + main(int argc, char **argv) + { + char line[10000], method[10000], path[10000], protocol[10000], idx[20000], + location[20000], command[20000]; + char *file; + size_t len; + int ich; + struct stat sb; + FILE *fp; + + if (argc != 2) + send_error(500, "Internal Error", NULL, "Config error - no dir specified."); + if (chdir(argv[1]) < 0) + send_error(500, "Internal Error", NULL, "Config error - couldn't chdir()."); + if (fgets(line, sizeof(line), stdin) == NULL) + send_error(400, "Bad Request", NULL, "No request found."); + if (sscanf(line, "%[^ ] %[^ ] %[^ ]", method, path, protocol) != 3) + send_error(400, "Bad Request", NULL, "Can't parse request."); + while (fgets(line, sizeof(line), stdin) != NULL) { + if (strcmp(line, "\n") == 0 || strcmp(line, "\r\n") == 0) + break; + } + if (strcasecmp(method, "get") != 0) + send_error(501, "Not Implemented", NULL, "That method is not implemented."); + if (path[0] != '/') + send_error(400, "Bad Request", NULL, "Bad filename."); + file = &(path[1]); + if (file[0] == '\0') + file = "./"; + len = strlen(file); + if (file[0] == '/' || strcmp(file, "..") == 0 || strncmp(file, "../", 3) == 0 || strstr(file, "/../") != NULL || strcmp(&(file[len - 3]), "/..") == 0) + send_error(400, "Bad Request", NULL, "Illegal filename."); + if (stat(file, &sb) < 0) + send_error(404, "Not Found", NULL, "File not found."); + if (S_ISDIR(sb.st_mode)) { + if (file[len - 1] != '/') { + (void)snprintf( + location, sizeof(location), "Location: %s/", path); + send_error(302, "Found", location, "Directories must end with a slash."); + } + (void)snprintf(idx, sizeof(idx), "%sindex.html", file); + if (stat(idx, &sb) >= 0) { + file = idx; + goto do_file; + } + send_headers(200, "Ok", NULL, "text/html", -1, sb.st_mtime); + (void)printf("Index of %s\n

Index of %s

\n
\n", file, file);
+ 		if (strchr(file, '\'') == NULL) {
+ 			(void)snprintf(command, sizeof(command),
+ 			    "ls -lgF '%s' | tail +2 | sed -e 's/^\\([^ ][^ ]*\\)\\(  *[^ ][^ ]*  *[^ ][^ ]*  *[^ ][^ ]*\\)\\(  *[^ ][^ ]*\\)  *\\([^ ][^ ]*  *[^ ][^ ]*  *[^ ][^ ]*\\)  *\\(.*\\)$/\\1 \\3  \\4  |\\5/' -e '/ -> /!s,|\\([^*]*\\)$,|\\1,' -e '/ -> /!s,|\\(.*\\)\\([*]\\)$,|\\1\\2,' -e '/ -> /s,|\\([^@]*\\)\\(@* -> \\),|\\1\\2,' -e 's/|//'",
+ 			    file);
+ 			(void)fflush(stdout);
+ 			system(command);
+ 		}
+ 		(void)printf("
\n
\n
%s
\n\n", SERVER_URL, SERVER_NAME); + } else { + do_file: + fp = fopen(file, "r"); + if (fp == (FILE *) 0) + send_error(403, "Forbidden", NULL, "File is protected."); + send_headers(200, "Ok", NULL, get_mime_type(file), sb.st_size, sb.st_mtime); + while ((ich = getc(fp)) != EOF) + putchar(ich); + } + + (void)fflush(stdout); + exit(0); + } + + static void + send_error(int status, char *title, char *extra_header, char *text) + { + send_headers(status, title, extra_header, "text/html", -1, -1); + (void)printf("%d %s\n

%d %s

\n", status, title, status, title); + (void)printf("%s\n", text); + (void)printf("
\n
%s
\n\n", SERVER_URL, SERVER_NAME); + (void)fflush(stdout); + exit(1); + } + + static void + send_headers(int status, char *title, char *extra_header, char *mime_type, off_t length, time_t mod) + { + time_t now; + char timebuf[100]; + + (void)printf("%s %d %s\r\n", PROTOCOL, status, title); + (void)printf("Server: %s\r\n", SERVER_NAME); + now = time((time_t *) 0); + (void)strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&now)); + (void)printf("Date: %s\r\n", timebuf); + if (extra_header != NULL) + (void)printf("%s\r\n", extra_header); + if (mime_type != NULL) + (void)printf("Content-Type: %s\r\n", mime_type); + if (length >= 0) + (void)printf("Content-Length: %lld\r\n", (int64_t) length); + if (mod != (time_t) - 1) { + (void)strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&mod)); + (void)printf("Last-Modified: %s\r\n", timebuf); + } + (void)printf("Connection: close\r\n"); + (void)printf("\r\n"); + } + + static char * + get_mime_type(char *name) + { + char *dot; + + dot = strrchr(name, '.'); + if (dot == NULL) + return "text/plain; charset=iso-8859-1"; + if (strcmp(dot, ".html") == 0 || strcmp(dot, ".htm") == 0) + return "text/html; charset=iso-8859-1"; + if (strcmp(dot, ".jpg") == 0 || strcmp(dot, ".jpeg") == 0) + return "image/jpeg"; + if (strcmp(dot, ".gif") == 0) + return "image/gif"; + if (strcmp(dot, ".png") == 0) + return "image/png"; + if (strcmp(dot, ".css") == 0) + return "text/css"; + if (strcmp(dot, ".au") == 0) + return "audio/basic"; + if (strcmp(dot, ".wav") == 0) + return "audio/wav"; + if (strcmp(dot, ".avi") == 0) + return "video/x-msvideo"; + if (strcmp(dot, ".mov") == 0 || strcmp(dot, ".qt") == 0) + return "video/quicktime"; + if (strcmp(dot, ".mpeg") == 0 || strcmp(dot, ".mpe") == 0) + return "video/mpeg"; + if (strcmp(dot, ".vrml") == 0 || strcmp(dot, ".wrl") == 0) + return "model/vrml"; + if (strcmp(dot, ".midi") == 0 || strcmp(dot, ".mid") == 0) + return "audio/midi"; + if (strcmp(dot, ".mp3") == 0) + return "audio/mpeg"; + if (strcmp(dot, ".pac") == 0) + return "application/x-ns-proxy-autoconfig"; + return "text/plain; charset=iso-8859-1"; + } Index: fs/hpfs/hpfs_vfsops.c =========================================================================== --- fs/hpfs/hpfs_vfsops.c 2003/06/11 23:19:28 #19 +++ fs/hpfs/hpfs_vfsops.c 2003/06/11 23:19:28 @@ -55,19 +55,18 @@ struct sockaddr; -static int hpfs_root(struct mount *, struct vnode **); -static int hpfs_statfs(struct mount *, struct statfs *, struct thread *); -static int hpfs_unmount(struct mount *, int, struct thread *); -static int hpfs_vget(struct mount *mp, ino_t ino, int flags, - struct vnode **vpp); static int hpfs_mountfs(register struct vnode *, struct mount *, struct hpfs_args *, struct thread *); -static int hpfs_vptofh(struct vnode *, struct fid *); -static int hpfs_fhtovp(struct mount *, struct fid *, struct vnode **); -static int hpfs_mount(struct mount *, char *, caddr_t, - struct nameidata *, struct thread *); -static int hpfs_init(struct vfsconf *); -static int hpfs_uninit(struct vfsconf *); + +static vfs_init_t hpfs_init; +static vfs_uninit_t hpfs_uninit; +static vfs_fhtovp_t hpfs_fhtovp; +static vfs_vget_t hpfs_vget; +static vfs_mount_t hpfs_mount; +static vfs_root_t hpfs_root; +static vfs_statfs_t hpfs_statfs; +static vfs_unmount_t hpfs_unmount; +static vfs_vptofh_t hpfs_vptofh; static int hpfs_init ( Index: fs/ntfs/ntfs_vfsops.c =========================================================================== --- fs/ntfs/ntfs_vfsops.c 2003/06/11 23:19:28 #22 +++ fs/ntfs/ntfs_vfsops.c 2003/06/11 23:19:28 @@ -64,18 +64,18 @@ struct sockaddr; -static int ntfs_root(struct mount *, struct vnode **); -static int ntfs_statfs(struct mount *, struct statfs *, struct thread *); -static int ntfs_unmount(struct mount *, int, struct thread *); -static int ntfs_vget(struct mount *mp, ino_t ino, int lkflags, - struct vnode **vpp); static int ntfs_mountfs(register struct vnode *, struct mount *, struct ntfs_args *, struct thread *); -static int ntfs_vptofh(struct vnode *, struct fid *); -static int ntfs_fhtovp(struct mount *, struct fid *, struct vnode **); -static int ntfs_mount(struct mount *, char *, caddr_t, - struct nameidata *, struct thread *); -static int ntfs_init(struct vfsconf *); + +static vfs_init_t ntfs_init; +static vfs_uninit_t ntfs_uninit; +static vfs_vget_t ntfs_vget; +static vfs_fhtovp_t ntfs_fhtovp; +static vfs_mount_t ntfs_mount; +static vfs_root_t ntfs_root; +static vfs_statfs_t ntfs_statfs; +static vfs_unmount_t ntfs_unmount; +static vfs_vptofh_t ntfs_vptofh; static int ntfs_init ( Index: fs/nullfs/null_vfsops.c =========================================================================== --- fs/nullfs/null_vfsops.c 2003/06/11 23:19:28 #10 +++ fs/nullfs/null_vfsops.c 2003/06/11 23:19:28 @@ -430,3 +430,4 @@ }; VFS_SET(null_vfsops, nullfs, VFCF_LOOPBACK); +MODULE_VERSION(nullfs, 1); Index: fs/smbfs/smbfs_vfsops.c =========================================================================== --- fs/smbfs/smbfs_vfsops.c 2003/06/11 23:19:28 #17 +++ fs/smbfs/smbfs_vfsops.c 2003/06/11 23:19:28 @@ -77,15 +77,14 @@ static MALLOC_DEFINE(M_SMBFSHASH, "SMBFS hash", "SMBFS hash table"); -static int smbfs_mount(struct mount *, char *, caddr_t, - struct nameidata *, struct thread *); -static int smbfs_quotactl(struct mount *, int, uid_t, caddr_t, struct thread *); -static int smbfs_root(struct mount *, struct vnode **); -static int smbfs_start(struct mount *, int, struct thread *); -static int smbfs_statfs(struct mount *, struct statfs *, struct thread *); -static int smbfs_unmount(struct mount *, int, struct thread *); -static int smbfs_init(struct vfsconf *vfsp); -static int smbfs_uninit(struct vfsconf *vfsp); +static vfs_init_t smbfs_init; +static vfs_uninit_t smbfs_uninit; +static vfs_mount_t smbfs_mount; +static vfs_start_t smbfs_start; +static vfs_root_t smbfs_root; +static vfs_quotactl_t smbfs_quotactl; +static vfs_statfs_t smbfs_statfs; +static vfs_unmount_t smbfs_unmount; static struct vfsops smbfs_vfsops = { smbfs_mount, Index: fs/umapfs/umap_vfsops.c =========================================================================== --- fs/umapfs/umap_vfsops.c 2003/06/11 23:19:28 #15 +++ fs/umapfs/umap_vfsops.c 2003/06/11 23:19:28 @@ -456,3 +456,4 @@ }; VFS_SET(umap_vfsops, umapfs, VFCF_LOOPBACK); +MODULE_DEPEND(umapfs, nullfs, 1, 1, 1); Index: i386/conf/HEMPBSD =========================================================================== *** /dev/null Wed Jun 11 23:19:12 2003 --- i386/conf/HEMPBSD Wed Jun 11 23:19:40 2003 *************** *** 0 **** --- 1,95 ---- + machine i386 + cpu I686_CPU + ident HEMPBSD + maxusers 0 + + #To statically compile in device wiring instead of /boot/device.hints + #hints "GENERIC.hints" #Default places to look for devices. + + makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols + makeoptions CONF_CFLAGS=-fno-builtin + + options CPU_ENABLE_SSE + options ZERO_COPY_SOCKETS + options SCHED_4BSD + #options SCHED_ULE + options MATH_EMULATE + options INET #InterNETworking + options FFS #Berkeley Fast Filesystem + options SOFTUPDATES #Enable FFS soft updates support + options UFS_ACL #Support for access control lists + options UFS_DIRHASH #Improve performance on big directories + options MD_ROOT #MD is a potential root device + options NFSCLIENT #Network Filesystem Client + options NFSSERVER #Network Filesystem Server + #options NFS_ROOT #NFS usable as root device, requires NFSCLIENT + options MSDOSFS #MSDOS Filesystem + options CD9660 #ISO 9660 Filesystem + options PROCFS #Process filesystem (requires PSEUDOFS) + options PSEUDOFS #Pseudo-filesystem framework + options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] + options COMPAT_FREEBSD4 #Compatible with FreeBSD4 + options KTRACE #ktrace(1) support + options SYSVSHM #SYSV-style shared memory + options SYSVMSG #SYSV-style message queues + options SYSVSEM #SYSV-style semaphores + options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions + options KBD_INSTALL_CDEV # install a CDEV entry in /dev + + # Debugging for use in -current + options DDB #Enable the kernel debugger + options DDB_TRACE #Enable DDB trace printing + options WITNESS #Enable checks to detect deadlocks + options WITNESS_SKIPSPIN #Don't run witness on spinlocks + #options MUTEX_DEBUG + + device isa + device eisa + device pci + + options DEVICE_POLLING + #options SMP + #options APIC_IO + + # Floppy drives + device fdc + + # ATA and ATAPI devices + device ata + device atadisk # ATA disk drives + device atapicd # ATAPI CDROM drives + device atapifd # ATAPI floppy drives + options ATA_STATIC_ID # Static device numbering + + # atkbdc0 controls both the keyboard and the PS/2 mouse + device atkbdc # AT keyboard controller + device atkbd # AT keyboard + device psm # PS/2 mouse + device vga # VGA video card driver + device splash # Splash screen and screen saver support + device sc + device agp # support several AGP chipsets + + device npx + # Add suspend/resume support for the i8254. + device pmtimer + + # Serial (COM) ports + device sio # 8250, 16[45]50 based serial ports + + # PCI Ethernet NICs. + device miibus # MII bus support + device fxp # Intel EtherExpress PRO/100B (82557, 82558) + #device pcn # AMD Am79C97x PCI 10/100 + #device rl # RealTek 8129/8139 + #device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') + + # Pseudo devices - the number indicates how many units to allocate. + device random # Entropy device + device loop # Network loopback + device ether # Ethernet support + device pty # Pseudo-ttys (telnet etc) + device md # Memory "disks" + device bpf # Berkeley packet filter + + options DONTPROBE_1284 Index: kern/uipc_jumbo.c =========================================================================== --- kern/uipc_jumbo.c 2003/06/11 23:19:28 #9 +++ kern/uipc_jumbo.c 2003/06/11 23:19:28 @@ -37,7 +37,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/uipc_jumbo.c,v 1.9 2003/06/11 21:23:04 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_jumbo.c,v 1.8 2003/06/11 00:56:58 obrien Exp $"); #include #include @@ -222,7 +222,6 @@ paddr = pmap_kextract((vm_offset_t)addr); pg = PHYS_TO_VM_PAGE(paddr); - VM_OBJECT_LOCK(jumbo_vm_object); if (pg->object != jumbo_vm_object) { jumbo_vmuiomove_pgs_freed++; /* if(vm_page_lookup(jumbo_vm_object, atop(addr - jumbo_basekva))) @@ -236,7 +235,6 @@ vm_page_free(pg); vm_page_unlock_queues(); } - VM_OBJECT_UNLOCK(jumbo_vm_object); mtx_lock(&jumbo_mutex); Index: kern/uipc_syscalls.c =========================================================================== --- kern/uipc_syscalls.c 2003/06/11 23:19:28 #54 +++ kern/uipc_syscalls.c 2003/06/11 23:19:28 @@ -37,7 +37,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/uipc_syscalls.c,v 1.149 2003/06/11 21:23:04 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_syscalls.c,v 1.148 2003/06/11 00:56:58 obrien Exp $"); #include "opt_compat.h" #include "opt_ktrace.h" @@ -1926,8 +1926,6 @@ IO_VMIO | ((MAXBSIZE / bsize) << 16), td->td_ucred, NOCRED, &resid, td); VOP_UNLOCK(vp, 0, td); - if (error) - VM_OBJECT_LOCK(obj); vm_page_lock_queues(); vm_page_flag_clear(pg, PG_ZERO); vm_page_io_finish(pg); @@ -1944,7 +1942,6 @@ vm_page_free(pg); } vm_page_unlock_queues(); - VM_OBJECT_UNLOCK(obj); sbunlock(&so->so_snd); goto done; } Index: kern/vfs_bio.c =========================================================================== --- kern/vfs_bio.c 2003/06/11 23:19:28 #109 +++ kern/vfs_bio.c 2003/06/11 23:19:28 @@ -26,7 +26,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/vfs_bio.c,v 1.393 2003/06/11 16:37:33 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/vfs_bio.c,v 1.392 2003/06/11 00:56:58 obrien Exp $"); #include #include @@ -1548,8 +1548,6 @@ vm_page_t m; GIANT_REQUIRED; - if (bp->b_object != NULL) - VM_OBJECT_LOCK(bp->b_object); vm_page_lock_queues(); for (i = 0; i < bp->b_npages; i++) { m = bp->b_pages[i]; @@ -1587,8 +1585,6 @@ } } vm_page_unlock_queues(); - if (bp->b_object != NULL) - VM_OBJECT_UNLOCK(bp->b_object); pmap_qremove(trunc_page((vm_offset_t) bp->b_data), bp->b_npages); if (bp->b_bufsize) { @@ -3592,8 +3588,6 @@ to = round_page(to); newnpages = index = (from - trunc_page((vm_offset_t)bp->b_data)) >> PAGE_SHIFT; - if (bp->b_object != NULL) - VM_OBJECT_LOCK(bp->b_object); for (pg = from; pg < to; pg += PAGE_SIZE, index++) { p = bp->b_pages[index]; if (p && (index < bp->b_npages)) { @@ -3612,8 +3606,6 @@ vm_page_unlock_queues(); } } - if (bp->b_object != NULL) - VM_OBJECT_UNLOCK(bp->b_object); bp->b_npages = newnpages; } Index: kern/vfs_cache.c =========================================================================== --- kern/vfs_cache.c 2003/06/11 23:19:28 #26 +++ kern/vfs_cache.c 2003/06/11 23:19:28 @@ -55,6 +55,8 @@ #include #include +#include + /* * This structure describes the elements in the cache of recent * names looked up by namei. @@ -111,6 +113,20 @@ #endif struct nchstats nchstats; /* cache effectiveness statistics */ +/* + * UMA zones for the VFS cache. + * + * Small cache is used for entries where their pathlen + * is within 64 chars, or we use the bigger pre-alloc'ed + * zone for storing the namecache structs. + */ +uma_zone_t cache_zone_small; +uma_zone_t cache_zone_large; + +#define CACHE_PATH_LEN 32 /* or should it be 64?! */ +#define CACHE_ZONE_SMALL (sizeof(struct namecache) + CACHE_PATH_LEN) +#define CACHE_ZONE_LARGE (sizeof(struct namecache) + NAME_MAX) + static int doingcache = 1; /* 1 => enable the cache */ SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0, ""); @@ -230,6 +246,44 @@ SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD, 0, 0, sysctl_debug_hashstat_nchash, "I", "nchash chain lengths"); +static __inline int +cache_alloc(struct namecache **ncp, u_char len) +{ + uma_zone_t zone = NULL; + + if (len <= CACHE_PATH_LEN) + zone = cache_zone_small; + else if (len > CACHE_PATH_LEN && len <= NAME_MAX) + zone = cache_zone_large; + else + return (EFBIG); + + *ncp = uma_zalloc(zone, M_NOWAIT); + if (*ncp == NULL) + return ENOMEM; + + return 0; +} + +static __inline int +cache_free(struct namecache *ncp) +{ + uma_zone_t zone = NULL; + + if (ncp->nc_nlen <= CACHE_PATH_LEN) { + zone = cache_zone_small; + } else { + zone = cache_zone_large; + } + + if (ncp != NULL) + uma_zfree(zone, ncp); + else + return EINVAL; + + return 0; +} + /* * cache_zap(): * @@ -253,7 +307,8 @@ numneg--; } numcache--; - free(ncp, M_VFSCACHE); + if(cache_free(ncp)) + return; } /* @@ -417,10 +472,10 @@ return; } } + + if (cache_alloc(&ncp, cnp->cn_namelen)) + return; - ncp = (struct namecache *) - malloc(sizeof *ncp + cnp->cn_namelen, M_VFSCACHE, M_WAITOK); - bzero((char *)ncp, sizeof *ncp); numcache++; if (!vp) { numneg++; @@ -472,6 +527,17 @@ { TAILQ_INIT(&ncneg); + + /* + * Initialise the cache zones. Two zones are used for allocation, + * because storing all components in NAME_MAX sized zones will be + * a space waste (just think about vfs.cache.numcache * 255!) + */ + cache_zone_small = uma_zcreate("CACHESMALL", CACHE_ZONE_SMALL, NULL, + NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT); + cache_zone_large = uma_zcreate("CACHELARGE", CACHE_ZONE_LARGE, NULL, + NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT); + nchashtbl = hashinit(desiredvnodes * 2, M_VFSCACHE, &nchash); } SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nchinit, NULL) Index: modules/fritz/Makefile =========================================================================== *** /dev/null Wed Jun 11 23:19:12 2003 --- modules/fritz/Makefile Wed Jun 11 23:19:41 2003 *************** *** 0 **** --- 1,8 ---- + # $FreeBSD$ + + .PATH: ${.CURDIR}/../../fritz + + KMOD= fritz + SRCS= f_httpd.c + + .include Index: netinet/igmp_var.h =========================================================================== --- netinet/igmp_var.h 2003/06/11 23:19:28 #3 +++ netinet/igmp_var.h 2003/06/11 23:19:28 @@ -92,7 +92,9 @@ void igmp_fasttimo(void); void igmp_slowtimo(void); +#ifdef SYSCTL_DECL SYSCTL_DECL(_net_inet_igmp); +#endif #endif Index: sparc64/include/iommuvar.h =========================================================================== --- sparc64/include/iommuvar.h 2003/06/11 23:19:28 #12 +++ sparc64/include/iommuvar.h 2003/06/11 23:19:28 @@ -27,7 +27,7 @@ * * from: NetBSD: iommuvar.h,v 1.9 2001/07/20 00:07:13 eeh Exp * - * $FreeBSD: src/sys/sparc64/include/iommuvar.h,v 1.12 2003/06/11 20:30:52 tmm Exp $ + * $FreeBSD: src/sys/sparc64/include/iommuvar.h,v 1.11 2003/05/26 04:00:52 scottl Exp $ */ #ifndef _MACHINE_IOMMUVAR_H_ @@ -81,18 +81,23 @@ void iommu_remove(struct iommu_state *, vm_offset_t, size_t); void iommu_decode_fault(struct iommu_state *, vm_offset_t); -int iommu_dvmamap_create(bus_dma_tag_t, bus_dma_tag_t, int, bus_dmamap_t *); -int iommu_dvmamap_destroy(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); -int iommu_dvmamap_load(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, void *, - bus_size_t, bus_dmamap_callback_t *, void *, int); -int iommu_dvmamap_load_mbuf(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, - struct mbuf *, bus_dmamap_callback2_t *, void *, int); -int iommu_dvmamap_load_uio(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, - struct uio *, bus_dmamap_callback2_t *, void *, int); -void iommu_dvmamap_unload(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); -void iommu_dvmamap_sync(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, int); -int iommu_dvmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, void **, int, - bus_dmamap_t *); -void iommu_dvmamem_free(bus_dma_tag_t, bus_dma_tag_t, void *, bus_dmamap_t); +int iommu_dvmamap_create(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + int, bus_dmamap_t *); +int iommu_dvmamap_destroy(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + bus_dmamap_t); +int iommu_dvmamap_load(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + bus_dmamap_t, void *, bus_size_t, bus_dmamap_callback_t *, void *, int); +int iommu_dvmamap_load_mbuf(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + bus_dmamap_t, struct mbuf *, bus_dmamap_callback2_t *, void *, int); +int iommu_dvmamap_load_uio(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + bus_dmamap_t, struct uio *, bus_dmamap_callback2_t *, void *, int); +void iommu_dvmamap_unload(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + bus_dmamap_t); +void iommu_dvmamap_sync(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + bus_dmamap_t, int); +int iommu_dvmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + void **, int, bus_dmamap_t *); +void iommu_dvmamem_free(bus_dma_tag_t, bus_dma_tag_t, struct iommu_state *, + void *, bus_dmamap_t); #endif /* !_MACHINE_IOMMUVAR_H_ */ Index: sparc64/pci/psycho.c =========================================================================== --- sparc64/pci/psycho.c 2003/06/11 23:19:28 #36 +++ sparc64/pci/psycho.c 2003/06/11 23:19:28 @@ -28,7 +28,7 @@ * * from: NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp * - * $FreeBSD: src/sys/sparc64/pci/psycho.c,v 1.36 2003/06/11 20:30:52 tmm Exp $ + * $FreeBSD: src/sys/sparc64/pci/psycho.c,v 1.35 2003/05/30 20:48:05 tmm Exp $ */ /* @@ -98,6 +98,27 @@ static ofw_pci_binit_t psycho_binit; /* + * bus space and bus dma support for UltraSPARC `psycho'. note that most + * of the bus dma support is provided by the iommu dvma controller. + */ +static int psycho_dmamap_create(bus_dma_tag_t, bus_dma_tag_t, int, + bus_dmamap_t *); +static int psycho_dmamap_destroy(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); +static int psycho_dmamap_load(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, + void *, bus_size_t, bus_dmamap_callback_t *, void *, int); +static int psycho_dmamap_load_mbuf(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, + struct mbuf *, bus_dmamap_callback2_t *, void *, int); +static int psycho_dmamap_load_uio(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, + struct uio *, bus_dmamap_callback2_t *, void *, int); +static void psycho_dmamap_unload(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); +static void psycho_dmamap_sync(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, + bus_dmasync_op_t); +static int psycho_dmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, void **, int, + bus_dmamap_t *); +static void psycho_dmamem_free(bus_dma_tag_t, bus_dma_tag_t, void *, + bus_dmamap_t); + +/* * autoconfiguration */ static int psycho_probe(device_t); @@ -471,12 +492,33 @@ panic("psycho_attach: range %d missing", n); } + /* allocate our tags */ + sc->sc_memt = psycho_alloc_bus_tag(sc, PCI_MEMORY_BUS_SPACE); + sc->sc_iot = psycho_alloc_bus_tag(sc, PCI_IO_BUS_SPACE); + sc->sc_cfgt = psycho_alloc_bus_tag(sc, PCI_CONFIG_BUS_SPACE); + if (bus_dma_tag_create(sc->sc_dmatag, 8, 1, 0, 0x3ffffffff, NULL, NULL, + 0x3ffffffff, 0xff, 0xffffffff, 0, &sc->sc_dmat) != 0) + panic("psycho_attach: bus_dma_tag_create failed"); + /* Customize the tag */ + sc->sc_dmat->dt_cookie = sc; + sc->sc_dmat->dt_dmamap_create = psycho_dmamap_create; + sc->sc_dmat->dt_dmamap_destroy = psycho_dmamap_destroy; + sc->sc_dmat->dt_dmamap_load = psycho_dmamap_load; + sc->sc_dmat->dt_dmamap_load_mbuf = psycho_dmamap_load_mbuf; + sc->sc_dmat->dt_dmamap_load_uio = psycho_dmamap_load_uio; + sc->sc_dmat->dt_dmamap_unload = psycho_dmamap_unload; + sc->sc_dmat->dt_dmamap_sync = psycho_dmamap_sync; + sc->sc_dmat->dt_dmamem_alloc = psycho_dmamem_alloc; + sc->sc_dmat->dt_dmamem_free = psycho_dmamem_free; + /* XXX: register as root dma tag (kluge). */ + sparc64_root_dma_tag = sc->sc_dmat; + /* Register the softc, this is needed for paired psychos. */ SLIST_INSERT_HEAD(&psycho_softcs, sc, sc_link); /* - * If we're a sabre or the first of a pair of psycho's to arrive here, - * start up the IOMMU. + * And finally, if we're a sabre or the first of a pair of psycho's to + * arrive here, start up the IOMMU and get a config space tag. */ if (osc == NULL) { /* @@ -543,27 +585,6 @@ iommu_reset(sc->sc_is); } - /* Allocate our tags. */ - sc->sc_memt = psycho_alloc_bus_tag(sc, PCI_MEMORY_BUS_SPACE); - sc->sc_iot = psycho_alloc_bus_tag(sc, PCI_IO_BUS_SPACE); - sc->sc_cfgt = psycho_alloc_bus_tag(sc, PCI_CONFIG_BUS_SPACE); - if (bus_dma_tag_create(sc->sc_dmatag, 8, 1, 0, 0x3ffffffff, NULL, NULL, - 0x3ffffffff, 0xff, 0xffffffff, 0, &sc->sc_dmat) != 0) - panic("psycho_attach: bus_dma_tag_create failed"); - /* Customize the tag. */ - sc->sc_dmat->dt_cookie = sc->sc_is; - sc->sc_dmat->dt_dmamap_create = iommu_dvmamap_create; - sc->sc_dmat->dt_dmamap_destroy = iommu_dvmamap_destroy; - sc->sc_dmat->dt_dmamap_load = iommu_dvmamap_load; - sc->sc_dmat->dt_dmamap_load_mbuf = iommu_dvmamap_load_mbuf; - sc->sc_dmat->dt_dmamap_load_uio = iommu_dvmamap_load_uio; - sc->sc_dmat->dt_dmamap_unload = iommu_dvmamap_unload; - sc->sc_dmat->dt_dmamap_sync = iommu_dvmamap_sync; - sc->sc_dmat->dt_dmamem_alloc = iommu_dvmamem_alloc; - sc->sc_dmat->dt_dmamem_free = iommu_dvmamem_free; - /* XXX: register as root dma tag (kludge). */ - sparc64_root_dma_tag = sc->sc_dmat; - /* * Enable all interrupts, clear all interrupt states, and install an * interrupt handler for OBIO interrupts, which can be ISA ones @@ -1324,3 +1345,103 @@ bt->bst_type = type; return (bt); } + +/* + * hooks into the iommu dvma calls. + */ +static int +psycho_dmamem_alloc(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, void **vaddr, + int flags, bus_dmamap_t *mapp) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + return (iommu_dvmamem_alloc(pdmat, ddmat, sc->sc_is, vaddr, flags, + mapp)); +} + +static void +psycho_dmamem_free(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, void *vaddr, + bus_dmamap_t map) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + iommu_dvmamem_free(pdmat, ddmat, sc->sc_is, vaddr, map); +} + +static int +psycho_dmamap_create(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, int flags, + bus_dmamap_t *mapp) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + return (iommu_dvmamap_create(pdmat, ddmat, sc->sc_is, flags, mapp)); + +} + +static int +psycho_dmamap_destroy(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, + bus_dmamap_t map) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + return (iommu_dvmamap_destroy(pdmat, ddmat, sc->sc_is, map)); +} + +static int +psycho_dmamap_load(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, bus_dmamap_t map, + void *buf, bus_size_t buflen, bus_dmamap_callback_t *callback, + void *callback_arg, int flags) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + return (iommu_dvmamap_load(pdmat, ddmat, sc->sc_is, map, buf, buflen, + callback, callback_arg, flags)); +} + +static int +psycho_dmamap_load_mbuf(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, + bus_dmamap_t map, struct mbuf *m, bus_dmamap_callback2_t *callback, + void *callback_arg, int flags) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + return (iommu_dvmamap_load_mbuf(pdmat, ddmat, sc->sc_is, map, m, + callback, callback_arg, flags)); +} + +static int +psycho_dmamap_load_uio(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, + bus_dmamap_t map, struct uio *uio, bus_dmamap_callback2_t *callback, + void *callback_arg, int flags) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + return (iommu_dvmamap_load_uio(pdmat, ddmat, sc->sc_is, map, uio, + callback, callback_arg, flags)); +} + +static void +psycho_dmamap_unload(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, bus_dmamap_t map) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + iommu_dvmamap_unload(pdmat, ddmat, sc->sc_is, map); +} + +static void +psycho_dmamap_sync(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, bus_dmamap_t map, + bus_dmasync_op_t op) +{ + struct psycho_softc *sc; + + sc = (struct psycho_softc *)pdmat->dt_cookie; + iommu_dvmamap_sync(pdmat, ddmat, sc->sc_is, map, op); +} Index: sparc64/sbus/sbus.c =========================================================================== --- sparc64/sbus/sbus.c 2003/06/11 23:19:28 #20 +++ sparc64/sbus/sbus.c 2003/06/11 23:19:28 @@ -100,7 +100,7 @@ * from: @(#)sbus.c 8.1 (Berkeley) 6/11/93 * from: NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp * - * $FreeBSD: src/sys/sparc64/sbus/sbus.c,v 1.20 2003/06/11 20:30:52 tmm Exp $ + * $FreeBSD: src/sys/sparc64/sbus/sbus.c,v 1.19 2003/05/27 04:59:59 scottl Exp $ */ /* @@ -229,6 +229,26 @@ static void sbus_overtemp(void *); static void sbus_pwrfail(void *); +/* + * DVMA routines + */ +static int sbus_dmamap_create(bus_dma_tag_t, bus_dma_tag_t, int, + bus_dmamap_t *); +static int sbus_dmamap_destroy(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); +static int sbus_dmamap_load(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, void *, + bus_size_t, bus_dmamap_callback_t *, void *, int); +static int sbus_dmamap_load_mbuf(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, + struct mbuf *, bus_dmamap_callback2_t *, void *, int); +static int sbus_dmamap_load_uio(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, + struct uio *, bus_dmamap_callback2_t *, void *, int); +static void sbus_dmamap_unload(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); +static void sbus_dmamap_sync(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, + bus_dmasync_op_t); +static int sbus_dmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, void **, int, + bus_dmamap_t *); +static void sbus_dmamem_free(bus_dma_tag_t, bus_dma_tag_t, void *, + bus_dmamap_t); + static device_method_t sbus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, sbus_probe), @@ -316,6 +336,24 @@ clock /= 1000; device_printf(dev, "clock %d.%03d MHz\n", clock / 1000, clock % 1000); + sc->sc_dmatag = nexus_get_dmatag(dev); + if (bus_dma_tag_create(sc->sc_dmatag, 8, 1, 0, 0x3ffffffff, NULL, NULL, + 0x3ffffffff, 0xff, 0xffffffff, 0, &sc->sc_cdmatag) != 0) + panic("bus_dma_tag_create failed"); + /* Customize the tag */ + sc->sc_cdmatag->dt_cookie = sc; + sc->sc_cdmatag->dt_dmamap_create = sbus_dmamap_create; + sc->sc_cdmatag->dt_dmamap_destroy = sbus_dmamap_destroy; + sc->sc_cdmatag->dt_dmamap_load = sbus_dmamap_load; + sc->sc_cdmatag->dt_dmamap_load_mbuf = sbus_dmamap_load_mbuf; + sc->sc_cdmatag->dt_dmamap_load_uio = sbus_dmamap_load_uio; + sc->sc_cdmatag->dt_dmamap_unload = sbus_dmamap_unload; + sc->sc_cdmatag->dt_dmamap_sync = sbus_dmamap_sync; + sc->sc_cdmatag->dt_dmamem_alloc = sbus_dmamem_alloc; + sc->sc_cdmatag->dt_dmamem_free = sbus_dmamem_free; + /* XXX: register as root dma tag (kluge). */ + sparc64_root_dma_tag = sc->sc_cdmatag; + /* * Collect address translations from the OBP. */ @@ -389,25 +427,6 @@ */ iommu_init(name, &sc->sc_is, 3, -1, 1); - /* Create the DMA tag. */ - sc->sc_dmatag = nexus_get_dmatag(dev); - if (bus_dma_tag_create(sc->sc_dmatag, 8, 1, 0, 0x3ffffffff, NULL, NULL, - 0x3ffffffff, 0xff, 0xffffffff, 0, &sc->sc_cdmatag) != 0) - panic("bus_dma_tag_create failed"); - /* Customize the tag. */ - sc->sc_cdmatag->dt_cookie = &sc->sc_is; - sc->sc_cdmatag->dt_dmamap_create = iommu_dvmamap_create; - sc->sc_cdmatag->dt_dmamap_destroy = iommu_dvmamap_destroy; - sc->sc_cdmatag->dt_dmamap_load = iommu_dvmamap_load; - sc->sc_cdmatag->dt_dmamap_load_mbuf = iommu_dvmamap_load_mbuf; - sc->sc_cdmatag->dt_dmamap_load_uio = iommu_dvmamap_load_uio; - sc->sc_cdmatag->dt_dmamap_unload = iommu_dvmamap_unload; - sc->sc_cdmatag->dt_dmamap_sync = iommu_dvmamap_sync; - sc->sc_cdmatag->dt_dmamem_alloc = iommu_dvmamem_alloc; - sc->sc_cdmatag->dt_dmamem_free = iommu_dvmamem_free; - /* XXX: register as root dma tag (kludge). */ - sparc64_root_dma_tag = sc->sc_cdmatag; - /* Enable the over-temperature and power-fail intrrupts. */ rid = 0; mr = SYSIO_READ8(sc, SBR_THERM_INT_MAP); @@ -899,3 +918,90 @@ sbt->bst_type = SBUS_BUS_SPACE; return (sbt); } + +static int +sbus_dmamap_create(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, int flags, + bus_dmamap_t *mapp) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + return (iommu_dvmamap_create(pdmat, ddmat, &sc->sc_is, flags, mapp)); + +} + +static int +sbus_dmamap_destroy(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, bus_dmamap_t map) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + return (iommu_dvmamap_destroy(pdmat, ddmat, &sc->sc_is, map)); +} + +static int +sbus_dmamap_load(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, bus_dmamap_t map, + void *buf, bus_size_t buflen, bus_dmamap_callback_t *callback, + void *callback_arg, int flags) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + return (iommu_dvmamap_load(pdmat, ddmat, &sc->sc_is, map, buf, buflen, + callback, callback_arg, flags)); +} + +static int +sbus_dmamap_load_mbuf(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, + bus_dmamap_t map, struct mbuf *m, bus_dmamap_callback2_t *callback, + void *callback_arg, int flags) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + return (iommu_dvmamap_load_mbuf(pdmat, ddmat, &sc->sc_is, map, m, + callback, callback_arg, flags)); +} + +static int +sbus_dmamap_load_uio(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, + bus_dmamap_t map, struct uio *uio, bus_dmamap_callback2_t *callback, + void *callback_arg, int flags) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + return (iommu_dvmamap_load_uio(pdmat, ddmat, &sc->sc_is, map, uio, + callback, callback_arg, flags)); +} + +static void +sbus_dmamap_unload(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, bus_dmamap_t map) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + iommu_dvmamap_unload(pdmat, ddmat, &sc->sc_is, map); +} + +static void +sbus_dmamap_sync(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, bus_dmamap_t map, + bus_dmasync_op_t op) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + iommu_dvmamap_sync(pdmat, ddmat, &sc->sc_is, map, op); +} + +static int +sbus_dmamem_alloc(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, void **vaddr, + int flags, bus_dmamap_t *mapp) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + return (iommu_dvmamem_alloc(pdmat, ddmat, &sc->sc_is, vaddr, flags, + mapp)); +} + +static void +sbus_dmamem_free(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, void *vaddr, + bus_dmamap_t map) +{ + struct sbus_softc *sc = (struct sbus_softc *)pdmat->dt_cookie; + + iommu_dvmamem_free(pdmat, ddmat, &sc->sc_is, vaddr, map); +} Index: sparc64/sparc64/iommu.c =========================================================================== --- sparc64/sparc64/iommu.c 2003/06/11 23:19:28 #29 +++ sparc64/sparc64/iommu.c 2003/06/11 23:19:28 @@ -106,7 +106,7 @@ * from: @(#)sbus.c 8.1 (Berkeley) 6/11/93 * from: NetBSD: iommu.c,v 1.42 2001/08/06 22:02:58 eeh Exp * - * $FreeBSD: src/sys/sparc64/sparc64/iommu.c,v 1.29 2003/06/11 20:30:52 tmm Exp $ + * $FreeBSD: src/sys/sparc64/sparc64/iommu.c,v 1.28 2003/05/27 04:59:59 scottl Exp $ */ /* @@ -668,10 +668,9 @@ } int -iommu_dvmamem_alloc(bus_dma_tag_t pt, bus_dma_tag_t dt, void **vaddr, - int flags, bus_dmamap_t *mapp) +iommu_dvmamem_alloc(bus_dma_tag_t pt, bus_dma_tag_t dt, struct iommu_state *is, + void **vaddr, int flags, bus_dmamap_t *mapp) { - struct iommu_state *is = pt->dt_cookie; int error; /* @@ -696,10 +695,9 @@ } void -iommu_dvmamem_free(bus_dma_tag_t pt, bus_dma_tag_t dt, void *vaddr, - bus_dmamap_t map) +iommu_dvmamem_free(bus_dma_tag_t pt, bus_dma_tag_t dt, struct iommu_state *is, + void *vaddr, bus_dmamap_t map) { - struct iommu_state *is = pt->dt_cookie; iommu_dvma_vfree(is, map); sparc64_dmamem_free_map(dt, map); @@ -707,10 +705,9 @@ } int -iommu_dvmamap_create(bus_dma_tag_t pt, bus_dma_tag_t dt, int flags, - bus_dmamap_t *mapp) +iommu_dvmamap_create(bus_dma_tag_t pt, bus_dma_tag_t dt, struct iommu_state *is, + int flags, bus_dmamap_t *mapp) { - struct iommu_state *is = pt->dt_cookie; bus_size_t totsz, presz, currsz; int error, i, maxpre; @@ -752,9 +749,9 @@ } int -iommu_dvmamap_destroy(bus_dma_tag_t pt, bus_dma_tag_t dt, bus_dmamap_t map) +iommu_dvmamap_destroy(bus_dma_tag_t pt, bus_dma_tag_t dt, + struct iommu_state *is, bus_dmamap_t map) { - struct iommu_state *is = pt->dt_cookie; iommu_dvma_vfree(is, map); return (sparc64_dmamap_destroy(pt->dt_parent, dt, map)); @@ -843,11 +840,10 @@ } int -iommu_dvmamap_load(bus_dma_tag_t pt, bus_dma_tag_t dt, bus_dmamap_t map, - void *buf, bus_size_t buflen, bus_dmamap_callback_t *cb, void *cba, - int flags) +iommu_dvmamap_load(bus_dma_tag_t pt, bus_dma_tag_t dt, struct iommu_state *is, + bus_dmamap_t map, void *buf, bus_size_t buflen, bus_dmamap_callback_t *cb, + void *cba, int flags) { - struct iommu_state *is = pt->dt_cookie; #ifdef __GNUC__ bus_dma_segment_t sgs[dt->dt_nsegments]; #else @@ -879,10 +875,10 @@ } int -iommu_dvmamap_load_mbuf(bus_dma_tag_t pt, bus_dma_tag_t dt, bus_dmamap_t map, - struct mbuf *m0, bus_dmamap_callback2_t *cb, void *cba, int flags) +iommu_dvmamap_load_mbuf(bus_dma_tag_t pt, bus_dma_tag_t dt, + struct iommu_state *is, bus_dmamap_t map, struct mbuf *m0, + bus_dmamap_callback2_t *cb, void *cba, int flags) { - struct iommu_state *is = pt->dt_cookie; #ifdef __GNUC__ bus_dma_segment_t sgs[dt->dt_nsegments]; #else @@ -924,10 +920,10 @@ } int -iommu_dvmamap_load_uio(bus_dma_tag_t pt, bus_dma_tag_t dt, bus_dmamap_t map, - struct uio *uio, bus_dmamap_callback2_t *cb, void *cba, int flags) +iommu_dvmamap_load_uio(bus_dma_tag_t pt, bus_dma_tag_t dt, + struct iommu_state *is, bus_dmamap_t map, struct uio *uio, + bus_dmamap_callback2_t *cb, void *cba, int flags) { - struct iommu_state *is = pt->dt_cookie; #ifdef __GNUC__ bus_dma_segment_t sgs[dt->dt_nsegments]; #else @@ -983,9 +979,9 @@ } void -iommu_dvmamap_unload(bus_dma_tag_t pt, bus_dma_tag_t dt, bus_dmamap_t map) +iommu_dvmamap_unload(bus_dma_tag_t pt, bus_dma_tag_t dt, struct iommu_state *is, + bus_dmamap_t map) { - struct iommu_state *is = pt->dt_cookie; if (map->dm_loaded == 0) return; @@ -995,10 +991,9 @@ } void -iommu_dvmamap_sync(bus_dma_tag_t pt, bus_dma_tag_t dt, bus_dmamap_t map, - bus_dmasync_op_t op) +iommu_dvmamap_sync(bus_dma_tag_t pt, bus_dma_tag_t dt, struct iommu_state *is, + bus_dmamap_t map, bus_dmasync_op_t op) { - struct iommu_state *is = pt->dt_cookie; struct bus_dmamap_res *r; vm_offset_t va; vm_size_t len; Index: vm/uma_core.c =========================================================================== --- vm/uma_core.c 2003/06/11 23:19:28 #57 +++ vm/uma_core.c 2003/06/11 23:19:28 @@ -1673,6 +1673,9 @@ int bflags; int cpu; + if (zone == NULL) + panic("Umm, PLZ NOT TO PASS NULL @zone K THX!"); + /* This is the fast path free */ #ifdef UMA_DEBUG_ALLOC_1 printf("Freeing item %p to %s(%p)\n", item, zone->uz_name, zone); Index: vm/vm_mmap.c =========================================================================== --- vm/vm_mmap.c 2003/06/11 23:19:28 #36 +++ vm/vm_mmap.c 2003/06/11 23:19:28 @@ -1158,6 +1158,17 @@ return(ENOMEM); } +#if 0 + /* + * If the pages can be executed, then set the vnode + * flag as VTEXT for immutability. XXX + */ + vp = (struct vnode *) handle; + if (vp && vp->v_type == VREG) + if (prot == PROT_EXEC) + vp->v_vflag = VV_TEXT; +#endif + /* * We currently can only deal with page aligned file offsets. * The check is here rather than in the syscall because the