Index: stable/6/share/man/man9/VFS_LOCK_GIANT.9 =================================================================== --- stable/6/share/man/man9/VFS_LOCK_GIANT.9 (nonexistent) +++ stable/6/share/man/man9/VFS_LOCK_GIANT.9 (revision 150433) @@ -0,0 +1,90 @@ +.\" +.\" Copyright (c) 2005 Robert N. M. Watson +.\" 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(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. +.\" +.\" $FreeBSD$ +.\" +.Dd September 21, 2005 +.Dt VFS_LOCK_GIANT 9 +.Os +.Sh NAME +.Nm VFS_LOCK_GIANT , +.Nm VFS_UNLOCK_GIANT +.Nd "Conditionally lock and unlock Giant around entry into VFS" +.Sh SYNOPSIS +.In sys/param.h +.In sys/vnode.h +.Ft int +.Fn VFS_LOCK_GIANT "struct mount *mp" +.Ft void +.Fn VFS_UNLOCK_GIANT "int vfslocked" +.Sh DESCRIPTION +.Fn VFS_LOCK_GIANT +will conditionally acquire the +.Dv Giant +lock if the file system referenced by +.Fa mp +is marked as MPSAFE or not, returning a flag indicating whether Giant was +set, which may later be passed to +.Fn VFS_UNLOCK_GIANT . +The value of +.Fa mp +will typically be derived from the mount pointer in a +.Xr vnode +on which a VFS operation will be performed. +.Pp +.Fn VFS_UNLOCK_GIANT +conditionally releases the +.Va Giant +lock if the passed +.Fa vfslocked +argument is non-zero. +It is expected that the argument will be derived from the return values of +.Vn VFS_LOCK_GIANT +or +.Xr NDHASGIANT 9 . +.Sh RETURN VALUES +.Fn VFS_LOCK_GIANT +returns a boolean indicating whether or not +.Va Giant +was acquired. +.Sh SEE ALSO +.Xr mutex 9 , +.Xr NDHASGIANT 9 , +.Xr vnode 9 +.Sh AUTHORS +MPSAFE VFS support for +.Fx +was implemented by +.An Jeff Roberson . +.Pp +This manual page was written by +.An Robert Watson . +.Sh BUGS +.Pp +Non-MPSAFE file systems exist, requiring callers conditional locking and +unlocking of +.Va Giant . Property changes on: stable/6/share/man/man9/VFS_LOCK_GIANT.9 ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: stable/6/sys/dev/pccard/pccard_device.c =================================================================== --- stable/6/sys/dev/pccard/pccard_device.c (nonexistent) +++ stable/6/sys/dev/pccard/pccard_device.c (revision 150433) @@ -0,0 +1,173 @@ +/*- + * Copyright (c) 2005, M. Warner Losh + * 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 unmodified, 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +static d_open_t pccard_open; +static d_close_t pccard_close; +static d_read_t pccard_read; +static d_ioctl_t pccard_ioctl; + +static struct cdevsw pccard_cdevsw = { + .d_version = D_VERSION, + .d_open = pccard_open, + .d_close = pccard_close, + .d_read = pccard_read, + .d_ioctl = pccard_ioctl, + .d_name = "pccard" +}; + +int +pccard_device_create(struct pccard_softc *sc) +{ + uint32_t minor; + + minor = device_get_unit(sc->dev) << 16; + sc->cisdev = make_dev(&pccard_cdevsw, minor, 0, 0, 0666, + "pccard%u.cis", device_get_unit(sc->dev)); + sc->cisdev->si_drv1 = sc; + return (0); +} + +int +pccard_device_destroy(struct pccard_softc *sc) +{ + if (sc->cisdev) + destroy_dev(sc->cisdev); + return (0); +} + +static int +pccard_build_cis(const struct pccard_tuple *tuple, void *argp) +{ + struct cis_buffer *cis; + int i; + uint8_t ch; + + cis = (struct cis_buffer *)argp; + /* + * CISTPL_END is a special case, it has no length field. + */ + if (tuple->code == CISTPL_END) { + if (cis->len + 1 > sizeof(cis->buffer)) + return (ENOSPC); + cis->buffer[cis->len++] = tuple->code; + return (0); + } + if (cis->len + 2 + tuple->length > sizeof(cis->buffer)) + return (ENOSPC); + cis->buffer[cis->len++] = tuple->code; + cis->buffer[cis->len++] = tuple->length; + for (i = 0; i < tuple->length; i++) { + ch = pccard_tuple_read_1(tuple, i); + cis->buffer[cis->len++] = ch; + } + return (0); +} + +static int +pccard_open(struct cdev *dev, int oflags, int devtype, struct thread *td) +{ + device_t parent, child; + device_t *kids; + int cnt, err; + struct pccard_softc *sc; + + sc = dev->si_drv1; + if (sc->cis_open) + return (EBUSY); + parent = sc->dev; + err = device_get_children(parent, &kids, &cnt); + if (err) + return err; + if (cnt == 0) { + free(kids, M_TEMP); + sc->cis_open++; + sc->cis = NULL; + return (0); + } + child = kids[0]; + free(kids, M_TEMP); + sc->cis = malloc(sizeof(*sc->cis), M_TEMP, M_ZERO | M_WAITOK); + err = pccard_scan_cis(parent, child, pccard_build_cis, sc->cis); + if (err) { + free(sc->cis, M_TEMP); + sc->cis = NULL; + return (err); + } + sc->cis_open++; + return (0); +} + +static int +pccard_close(struct cdev *dev, int fflags, int devtype, struct thread *td) +{ + struct pccard_softc *sc; + + sc = dev->si_drv1; + free(sc->cis, M_TEMP); + sc->cis = NULL; + sc->cis_open = 0; + return (0); +} + +static int +pccard_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, + struct thread *td) +{ + return (ENOTTY); +} + +static int +pccard_read(struct cdev *dev, struct uio *uio, int ioflag) +{ + struct pccard_softc *sc; + + sc = dev->si_drv1; + /* EOF */ + if (sc->cis == NULL || uio->uio_offset > sc->cis->len) + return (0); + return (uiomove(sc->cis->buffer + uio->uio_offset, + MIN(uio->uio_resid, sc->cis->len - uio->uio_offset), uio)); +} Property changes on: stable/6/sys/dev/pccard/pccard_device.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: stable/6/sys/dev/pccard/pccardvarp.h =================================================================== --- stable/6/sys/dev/pccard/pccardvarp.h (nonexistent) +++ stable/6/sys/dev/pccard/pccardvarp.h (revision 150433) @@ -0,0 +1,192 @@ +/*- + * Copyright (c) 2005, M. Warner Losh + * 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 unmodified, 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. + * + * $FreeBSD$ + */ + +#ifndef _PCCARD_PCCARDVARP_H +#define _PCCARD_PCCARDVARP_H + +/* pccard itself */ + +#define PCCARD_MEM_PAGE_SIZE 4096 + +#define PCCARD_CFE_MWAIT_REQUIRED 0x0001 +#define PCCARD_CFE_RDYBSY_ACTIVE 0x0002 +#define PCCARD_CFE_WP_ACTIVE 0x0004 +#define PCCARD_CFE_BVD_ACTIVE 0x0008 +#define PCCARD_CFE_IO8 0x0010 +#define PCCARD_CFE_IO16 0x0020 +#define PCCARD_CFE_IRQSHARE 0x0040 +#define PCCARD_CFE_IRQPULSE 0x0080 +#define PCCARD_CFE_IRQLEVEL 0x0100 +#define PCCARD_CFE_POWERDOWN 0x0200 +#define PCCARD_CFE_READONLY 0x0400 +#define PCCARD_CFE_AUDIO 0x0800 + +struct pccard_config_entry { + int number; + uint32_t flags; + int iftype; + int num_iospace; + + /* + * The card will only decode this mask in any case, so we can + * do dynamic allocation with this in mind, in case the suggestions + * below are no good. + */ + u_long iomask; + struct { + u_long length; + u_long start; + } iospace[4]; /* XXX this could be as high as 16 */ + uint16_t irqmask; + int num_memspace; + struct { + u_long length; + u_long cardaddr; + u_long hostaddr; + } memspace[2]; /* XXX this could be as high as 8 */ + int maxtwins; + STAILQ_ENTRY(pccard_config_entry) cfe_list; +}; + +struct pccard_funce_disk { + int pfd_interface; +}; + +struct pccard_funce_lan { + int pfl_nidlen; + uint8_t pfl_nid[8]; +}; + +union pccard_funce { + struct pccard_funce_disk pfv_disk; + struct pccard_funce_lan pfv_lan; +}; + +struct pccard_function { + /* read off the card */ + int number; + int function; + int last_config_index; + uint32_t ccr_base; /* Offset with card's memory */ + uint32_t ccr_mask; + struct resource *ccr_res; + int ccr_rid; + STAILQ_HEAD(, pccard_config_entry) cfe_head; + STAILQ_ENTRY(pccard_function) pf_list; + /* run-time state */ + struct pccard_softc *sc; + struct pccard_config_entry *cfe; + struct pccard_mem_handle pf_pcmh; + device_t dev; +#define pf_ccrt pf_pcmh.memt +#define pf_ccrh pf_pcmh.memh +#define pf_ccr_realsize pf_pcmh.realsize + uint32_t pf_ccr_offset; /* Offset from ccr_base of CIS */ + int pf_ccr_window; + bus_addr_t pf_mfc_iobase; + bus_addr_t pf_mfc_iomax; + int pf_flags; + driver_intr_t *intr_handler; + void *intr_handler_arg; + void *intr_handler_cookie; + + union pccard_funce pf_funce; /* CISTPL_FUNCE */ +#define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface +#define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid +#define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen +}; + +/* pf_flags */ +#define PFF_ENABLED 0x0001 /* function is enabled */ + +struct pccard_card { + int cis1_major; + int cis1_minor; + /* XXX waste of space? */ + char cis1_info_buf[256]; + char *cis1_info[4]; + /* + * Use int32_t for manufacturer and product so that they can + * hold the id value found in card CIS and special value that + * indicates no id was found. + */ + int32_t manufacturer; +#define PCMCIA_VENDOR_INVALID -1 + int32_t product; +#define PCMCIA_PRODUCT_INVALID -1 + int16_t prodext; + uint16_t error; +#define PCMCIA_CIS_INVALID { NULL, NULL, NULL, NULL } + STAILQ_HEAD(, pccard_function) pf_head; +}; + +/* More later? */ +struct pccard_ivar { + struct resource_list resources; + struct pccard_function *pf; +}; + +struct cis_buffer +{ + size_t len; /* Actual length of the CIS */ + uint8_t buffer[2040]; /* small enough to be 2k */ +}; + +struct pccard_softc { + device_t dev; + /* this stuff is for the socket */ + + /* this stuff is for the card */ + struct pccard_card card; + int sc_enabled_count; /* num functions enabled */ + struct cdev *cisdev; + int cis_open; + struct cis_buffer *cis; +}; + +struct pccard_cis_quirk { + int32_t manufacturer; + int32_t product; + char *cis1_info[4]; + struct pccard_function *pf; + struct pccard_config_entry *cfe; +}; + +void pccard_read_cis(struct pccard_softc *); +void pccard_check_cis_quirks(device_t); +void pccard_print_cis(device_t); +int pccard_scan_cis(device_t, device_t, pccard_scan_t, void *); + +int pccard_device_create(struct pccard_softc *); +int pccard_device_destroy(struct pccard_softc *); + +#define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d) +#define PCCARD_IVAR(d) (struct pccard_ivar *) device_get_ivars(d) + +#endif /* _PCCARD_PCCARDVARP_H */ Property changes on: stable/6/sys/dev/pccard/pccardvarp.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: stable/6/tools/tools/nanobsd/FlashDevice.sub =================================================================== --- stable/6/tools/tools/nanobsd/FlashDevice.sub (nonexistent) +++ stable/6/tools/tools/nanobsd/FlashDevice.sub (revision 150433) @@ -0,0 +1,117 @@ +#!/bin/sh +# +# Copyright (c) 2005 Poul-Henning Kamp. +# 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. +# +# $FreeBSD$ +# +# Convenience function for commonly used Flash devices. +# +# There is a hook over in nanobsd.sh which allows you to call into +# this function simply with a line like: +# +# FlashDevice Sandisk 256 +# +# This file will then set NANO_MEDIASIZE, NANO_HEADS and NANO_SECTS for you. +# + +sub_FlashDevice () { + case $1 in + [Ss][Aa][Nn][Dd][Ii][Ss][Kk]) + # Source: + # SanDisk CompactFlash Memory Card + # Product Manual + # Version 10.9 + # Document No. 20-10-00038 + # April 2005 + # Table 2-7 + # NB: notice math error in SDCFJ-4096-388 line. + # + case $2 in + 32|32MB) + NANO_MEDIASIZE=`expr 32112640 / 512` + NANO_HEADS=4 + NANO_SECTS=32 + ;; + 64|64MB) + NANO_MEDIASIZE=`expr 64225280 / 512` + NANO_HEADS=8 + NANO_SECTS=32 + ;; + 128|128MB) + NANO_MEDIASIZE=`expr 128450560 / 512` + NANO_HEADS=8 + NANO_SECTS=32 + ;; + 256|256MB) + NANO_MEDIASIZE=`expr 256901120 / 512` + NANO_HEADS=16 + NANO_SECTS=32 + ;; + 512|512MB) + NANO_MEDIASIZE=`expr 512483328 / 512` + NANO_HEADS=16 + NANO_SECTS=63 + ;; + 1024|1024MB|1G) + NANO_MEDIASIZE=`expr 1024966656 / 512` + NANO_HEADS=16 + NANO_SECTS=63 + ;; + 2048|2048MB|2G) + NANO_MEDIASIZE=`expr 2048901120 / 512` + NANO_HEADS=16 + NANO_SECTS=63 + ;; + 4096|4096MB|4G) + NANO_MEDIASIZE=`expr 4097802240 / 512` + NANO_HEADS=16 + NANO_SECTS=63 + ;; + *) + echo "Unknown Sandisk Flash capacity" + exit 2 + ;; + esac + ;; + [Ss][Oo][Ee][Kk][Rr][Ii][Ss]) + case $2 in + [Nn][Ee][Tt]4526 | 4526 | [Nn][Ee][Tt]4826 | 4826 | 64 | 64MB) + NANO_MEDIASIZE=125056 + NANO_HEADS=4 + NANO_SECTS=32 + ;; + *) + echo "Unknown Soekris Flash capacity" + exit 2 + ;; + esac + ;; + *) + echo "Unknown Flash manufacturer" + exit 2 + ;; + esac +} + Property changes on: stable/6/tools/tools/nanobsd/FlashDevice.sub ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property