Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* $NetBSD: pcd.c,v 0.01 2014/06/23 05:20:28 wjones Exp $ */
- /*
- * Copyright (c) 2014 William D. Jones. 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Charles M. Hannum.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * Copyright 2014 by William D. Jones (data part)
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This software was developed by Holger Veit and Brian Moore
- * for use with "386BSD" and similar operating systems.
- * "Similar operating systems" includes mainly non-profit oriented
- * systems for research and education, including but not restricted to
- * "NetBSD", "FreeBSD", "Mach" (by CMU).
- * 4. Neither the name of the developer(s) nor the name "386BSD"
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(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 DEVELOPER(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.
- */
- #include <sys/cdefs.h>
- __KERNEL_RCSID(0, "$NetBSD: pcd.c,v 0.9 2014/06/23 05:20:28 wjones Exp $");
- #include <sys/param.h>
- #include <sys/systm.h>
- #include <sys/kernel.h>
- #include <sys/errno.h>
- #include <sys/device.h>
- #include <sys/malloc.h>
- #include <sys/uio.h>
- #include <sys/proc.h>
- #include <sys/ioctl.h>
- #include <sys/conf.h>
- #include <sys/bus.h>
- static int pcd_match(device_t parent, cfdata_t match, void *aux);
- static void pcd_attach(device_t parent, device_t self, void *aux);
- static int pcd_activate(device_t self, enum devact act);
- struct pcd_softc {
- device_t sc_dev; /* generic device info */
- /* device-specific state */
- };
- //CFATTACH_DECL does not work, per ftp://ftp.netbsd.org/pub/NetBSD/misc/ddwg/NetBSD-driver_writing-1.0.1e.pdf
- CFATTACH_DECL_NEW(pcd, sizeof(struct pcd_softc), pcd_match, pcd_attach, NULL, pcd_activate);
- dev_type_open(pcdopen);
- dev_type_close(pcdclose);
- dev_type_read(pcdread);
- dev_type_write(pcdwrite);
- dev_type_ioctl(pcdioctl);
- dev_type_strategy(pcdstrategy);
- dev_type_dump(pcddump);
- dev_type_size(pcdsize);
- //Need to include more than just the 3 header files that driver(9) specifies.
- const struct bdevsw pcd_bdevsw = {
- .d_open = pcdopen,
- .d_close = pcdclose,
- .d_strategy = pcdstrategy,
- .d_ioctl = pcdioctl,
- .d_dump = pcddump,
- .d_psize = pcdsize,
- .d_flag = D_DISK
- };
- const struct cdevsw pcd_cdevsw = {
- .d_open = pcdopen,
- .d_close = pcdclose,
- .d_read = pcdread,
- .d_write = pcdwrite,
- .d_ioctl = pcdioctl,
- .d_stop = nostop,
- .d_tty = notty,
- .d_poll = nopoll,
- .d_mmap = nommap,
- .d_kqfilter = nokqfilter,
- .d_flag = D_DISK
- };
- /* driver(9) says return EOPNOTSUPP if activation is not supported. */
- int
- pcd_activate(device_t self, enum devact act)
- {
- return EOPNOTSUPP;
- }
- int
- pcd_match(device_t parent, cfdata_t match, void *aux)
- {
- return 0;
- }
- void
- pcd_attach(device_t parent, device_t self, void *aux)
- {
- //struct isa_attach_args *ia = aux;
- return;
- }
- /* I can't find the man page which discusses the paramater variable naming
- convention, so I'm just using what I see every other driver do! */
- int
- pcdopen(dev_t dev, int flags, int mode, struct lwp *l)
- {
- return 0;
- }
- int
- pcdclose(dev_t dev, int flags, int mode, struct lwp *l)
- {
- return 0;
- }
- int
- pcdread(dev_t dev, struct uio *uio, int flags)
- {
- return 0;
- }
- int
- pcdwrite(dev_t dev, struct uio *uio, int flags)
- {
- return 0;
- }
- int
- pcdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
- {
- return 0;
- }
- void
- pcdstrategy(struct buf *bp)
- {
- return;
- }
- int
- pcddump(dev_t dev, daddr_t blkno, void *va, size_t size)
- {
- return 0;
- }
- int
- pcdsize(dev_t dev)
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement