Skip to content

Commit

Permalink
* split the putter header into a kernel version and a userland version
Browse files Browse the repository at this point in the history
  + install latter to /usr/include/dev/putter
* remove last dependencies to puffs from putter, it's completely
  independent now
  • Loading branch information
pooka committed Nov 12, 2007
1 parent bdbd076 commit c6ced86
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 112 deletions.
3 changes: 2 additions & 1 deletion distrib/sets/lists/base/mi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.729 2007/11/12 15:02:58 jmmv Exp $
# $NetBSD: mi,v 1.730 2007/11/12 16:39:36 pooka Exp $
. base-sys-root
./altroot base-sys-root
./bin base-sys-root
Expand Down Expand Up @@ -775,6 +775,7 @@
./usr/include/dev/pci base-c-usr
./usr/include/dev/pckbc base-c-usr
./usr/include/dev/pcmcia base-c-usr
./usr/include/dev/putter base-c-usr
./usr/include/dev/raidframe base-c-usr
./usr/include/dev/rcons base-obsolete obsolete
./usr/include/dev/sbus base-c-usr
Expand Down
3 changes: 2 additions & 1 deletion distrib/sets/lists/comp/mi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1082 2007/11/12 15:05:15 jmmv Exp $
# $NetBSD: mi,v 1.1083 2007/11/12 16:39:37 pooka Exp $
./etc/mtree/set.comp comp-sys-root
./usr/bin/addr2line comp-debug-bin bfd
./usr/bin/ar comp-util-bin bfd
Expand Down Expand Up @@ -448,6 +448,7 @@
./usr/include/dev/pcmcia/pcmciachip.h comp-obsolete obsolete
./usr/include/dev/pcmcia/pcmciareg.h comp-obsolete obsolete
./usr/include/dev/pcmcia/pcmciavar.h comp-obsolete obsolete
./usr/include/dev/putter/putter.h comp-c-include
./usr/include/dev/raidframe/raidframeio.h comp-c-include
./usr/include/dev/raidframe/raidframevar.h comp-c-include
./usr/include/dev/ramdisk.h comp-obsolete obsolete
Expand Down
8 changes: 4 additions & 4 deletions lib/libpuffs/flush.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: flush.c,v 1.12 2007/10/11 19:41:14 pooka Exp $ */
/* $NetBSD: flush.c,v 1.13 2007/11/12 16:39:35 pooka Exp $ */

/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
Expand Down Expand Up @@ -27,7 +27,7 @@

#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: flush.c,v 1.12 2007/10/11 19:41:14 pooka Exp $");
__RCSID("$NetBSD: flush.c,v 1.13 2007/11/12 16:39:35 pooka Exp $");
#endif /* !lint */

/*
Expand Down Expand Up @@ -62,8 +62,8 @@ doflush(struct puffs_usermount *pu, void *cookie, int op,
struct puffs_flush pf;
ssize_t n;

pf.pf_frhdr.pfr_len = sizeof(struct puffs_flush);
pf.pf_frhdr.pfr_type = PUFFSOP_FLUSH;
pf.pf_req.preq_pth.pth_framelen = sizeof(struct puffs_flush);
pf.pf_req.preq_opclass = PUFFSOP_FLUSH;

pf.pf_op = op;
pf.pf_cookie = cookie;
Expand Down
23 changes: 12 additions & 11 deletions lib/libpuffs/requests.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: requests.c,v 1.15 2007/10/31 16:09:09 pooka Exp $ */
/* $NetBSD: requests.c,v 1.16 2007/11/12 16:39:35 pooka Exp $ */

/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
Expand Down Expand Up @@ -27,7 +27,7 @@

#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: requests.c,v 1.15 2007/10/31 16:09:09 pooka Exp $");
__RCSID("$NetBSD: requests.c,v 1.16 2007/11/12 16:39:35 pooka Exp $");
#endif /* !lint */

#include <sys/types.h>
Expand Down Expand Up @@ -66,24 +66,25 @@ puffs_req_makeget(struct puffs_usermount *pu, size_t buflen, int maxops)
int
puffs_req_loadget(struct puffs_getreq *pgr)
{
struct puffs_frame pfr;
struct putter_hdr pth;
uint8_t *buf;
size_t rlen;
int fd = pgr->pgr_pu->pu_fd;

assert(pgr->pgr_buf == NULL);

if (read(fd, &pfr, sizeof(struct puffs_frame)) == -1) {
if (read(fd, &pth, sizeof(struct putter_hdr)) == -1) {
if (errno == EWOULDBLOCK)
return 0;
return -1;
}
buf = malloc(pfr.pfr_alloclen);
buf = malloc(PUFFS_MSG_MAXSIZE); /* XXX */
assert(buf != NULL); /* XXX: a bit more grace here, thanks */
memcpy(buf, &pfr, sizeof(pfr));
memcpy(buf, &pth, sizeof(pth));

rlen = pfr.pfr_len - sizeof(pfr);
if (read(fd, buf + sizeof(pfr), rlen) != rlen) { /* XXX */
/* LINTED */
rlen = pth.pth_framelen - sizeof(pth);
if (read(fd, buf + sizeof(pth), rlen) != rlen) { /* XXX */
free(buf);
return -1;
}
Expand Down Expand Up @@ -149,9 +150,9 @@ puffs_req_put(struct puffs_putreq *ppr, struct puffs_req *preq)
ssize_t n;

/* LINTED conversion is benign, says author; may revisit */
preq->preq_frhdr.pfr_len = preq->preq_buflen;
n = write(ppr->ppr_pu->pu_fd, preq, preq->preq_frhdr.pfr_len);
assert(n == preq->preq_frhdr.pfr_len);
preq->preq_pth.pth_framelen = preq->preq_buflen;
n = write(ppr->ppr_pu->pu_fd, preq, preq->preq_pth.pth_framelen);
assert(n == preq->preq_pth.pth_framelen);
}

/*
Expand Down
16 changes: 9 additions & 7 deletions lib/libpuffs/suspend.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: suspend.c,v 1.6 2007/10/11 19:41:15 pooka Exp $ */
/* $NetBSD: suspend.c,v 1.7 2007/11/12 16:39:35 pooka Exp $ */

/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
Expand Down Expand Up @@ -27,7 +27,7 @@

#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: suspend.c,v 1.6 2007/10/11 19:41:15 pooka Exp $");
__RCSID("$NetBSD: suspend.c,v 1.7 2007/11/12 16:39:35 pooka Exp $");
#endif /* !lint */

/*
Expand All @@ -36,6 +36,8 @@ __RCSID("$NetBSD: suspend.c,v 1.6 2007/10/11 19:41:15 pooka Exp $");

#include <sys/types.h>

#include <dev/puttervar.h>

#include <assert.h>
#include <errno.h>
#include <puffs.h>
Expand All @@ -48,15 +50,15 @@ __RCSID("$NetBSD: suspend.c,v 1.6 2007/10/11 19:41:15 pooka Exp $");
int
puffs_fs_suspend(struct puffs_usermount *pu)
{
struct puffs_frame pfr;
struct puffs_req preq;
size_t n;

pfr.pfr_len = sizeof(struct puffs_frame);
pfr.pfr_type = PUFFSOP_SUSPEND;
preq.preq_pth.pth_framelen = sizeof(struct putter_hdr);
preq.preq_opclass = PUFFSOP_SUSPEND;

n = write(pu->pu_fd, &pfr, sizeof(pfr));
n = write(pu->pu_fd, &preq, sizeof(preq));

/* XXX */
assert(n == sizeof(pfr));
assert(n == sizeof(preq));
return 0;
}
4 changes: 2 additions & 2 deletions sys/dev/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.25 2007/05/01 17:18:55 bouyer Exp $
# $NetBSD: Makefile,v 1.26 2007/11/12 16:39:32 pooka Exp $

SUBDIR= apm ata bluetooth dec dmover hpc i2o ic ieee1394 ir isa microcode ofw \
pci pckbport pcmcia raidframe sbus scsipi sun tc usb vme wscons
pci pckbport pcmcia putter raidframe sbus scsipi sun tc usb vme wscons

INCSDIR= /usr/include/dev

Expand Down
8 changes: 8 additions & 0 deletions sys/dev/putter/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2007/11/12 16:39:32 pooka Exp $
#

INCSDIR=/usr/include/dev/putter

INCS= putter.h

.include <bsd.kinc.mk>
36 changes: 18 additions & 18 deletions sys/dev/putter/putter.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: putter.c,v 1.1 2007/11/12 14:30:56 pooka Exp $ */
/* $NetBSD: putter.c,v 1.2 2007/11/12 16:39:33 pooka Exp $ */

/*
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
Expand Down Expand Up @@ -35,7 +35,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.1 2007/11/12 14:30:56 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.2 2007/11/12 16:39:33 pooka Exp $");

#include <sys/param.h>
#include <sys/conf.h>
Expand All @@ -45,9 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.1 2007/11/12 14:30:56 pooka Exp $");
#include <sys/poll.h>
#include <sys/socketvar.h>

#include <dev/putter/puttervar.h>

#include <fs/puffs/puffs_msgif.h> /* XXX: for frame headers, goes away soon */
#include <dev/putter/putter_sys.h>

/*
* putter instance structures. these are always allocated and freed
Expand Down Expand Up @@ -91,6 +89,8 @@ static int putterdebug = 0;
#define DPRINTF_VERBOSE(x)
#endif

#define PUTTER_CLONER 0x7ffff

/*
* public init / deinit
*/
Expand Down Expand Up @@ -185,42 +185,42 @@ putter_fop_write(struct file *fp, off_t *off, struct uio *uio,
kauth_cred_t cred, int flags)
{
struct putter_instance *pi = fp->f_data;
struct puffs_frame pfr;
struct putter_hdr pth;
uint8_t *buf;
size_t frsize;
int error;

DPRINTF(("puffs_fop_write (%p): writing response, resid %zu\n",
DPRINTF(("putter_fop_write (%p): writing response, resid %zu\n",
pi->pi_private, uio->uio_resid));

if (pi->pi_private == PUTTER_EMBRYO || pi->pi_private == PUTTER_DEAD) {
printf("putter_fop_write: putter %d not inited\n", pi->pi_idx);
return ENOENT;
}

error = uiomove(&pfr, sizeof(struct puffs_frame), uio);
error = uiomove(&pth, sizeof(struct putter_hdr), uio);
if (error)
return error;

/* Sorry mate, the kernel doesn't buffer. */
frsize = pfr.pfr_len - sizeof(struct puffs_frame);
frsize = pth.pth_framelen - sizeof(struct putter_hdr);
if (uio->uio_resid < frsize)
return EINVAL;

buf = kmem_alloc(frsize + sizeof(struct puffs_frame), KM_SLEEP);
memcpy(buf, &pfr, sizeof(pfr));
error = uiomove(buf+sizeof(struct puffs_frame), frsize, uio);
buf = kmem_alloc(frsize + sizeof(struct putter_hdr), KM_SLEEP);
memcpy(buf, &pth, sizeof(pth));
error = uiomove(buf+sizeof(struct putter_hdr), frsize, uio);
if (error == 0) {
pi->pi_pop->pop_dispatch(pi->pi_private, buf);
}
kmem_free(buf, frsize + sizeof(struct puffs_frame));
kmem_free(buf, frsize + sizeof(struct putter_hdr));

return error;
}

/*
* Poll query interface. The question is only if an event
* can be read from us (and by read I mean ioctl... ugh).
* can be read from us.
*/
#define PUTTERPOLL_EVSET (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)
static int
Expand Down Expand Up @@ -406,7 +406,7 @@ puttercdopen(dev_t dev, int flags, int fmt, struct lwp *l)
* XXX: decide on some security model and check permissions
*/

if (minor(dev) != PUFFS_CLONER)
if (minor(dev) != PUTTER_CLONER)
return ENXIO;

if ((error = falloc(l, &fp, &fd)) != 0)
Expand All @@ -416,7 +416,7 @@ puttercdopen(dev_t dev, int flags, int fmt, struct lwp *l)

mutex_enter(&pi_mtx);
idx = get_pi_idx(pi);
if (idx == PUFFS_CLONER) {
if (idx == PUTTER_CLONER) {
mutex_exit(&pi_mtx);
kmem_free(pi, sizeof(struct putter_instance));
FILE_UNUSE(fp, l);
Expand Down Expand Up @@ -511,8 +511,8 @@ get_pi_idx(struct putter_instance *pi_i)

i = 0;
TAILQ_FOREACH(pi, &putter_ilist, pi_entries) {
if (i == PUFFS_CLONER)
return PUFFS_CLONER;
if (i == PUTTER_CLONER)
return PUTTER_CLONER;
if (i != pi->pi_idx)
break;
i++;
Expand Down
40 changes: 40 additions & 0 deletions sys/dev/putter/putter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* $NetBSD: putter.h,v 1.1 2007/11/12 16:39:33 pooka Exp $ */

/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
*
* Development of this software was supported by the
* Research Foundation of Helsinki University of Technology
*
* 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 ``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.
*/

#ifndef _DEV_PUTTER_PUTTER_H_
#define _DEV_PUTTER_PUTTER_H_

#include <sys/types.h>

struct putter_hdr {
uint64_t pth_framelen;
};

#endif /* _SYS_PUTTER_PUTTER_H_ */
16 changes: 7 additions & 9 deletions sys/dev/putter/puttervar.h → sys/dev/putter/putter_sys.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: puttervar.h,v 1.1 2007/11/12 14:30:56 pooka Exp $ */
/* $NetBSD: putter_sys.h,v 1.1 2007/11/12 16:39:33 pooka Exp $ */

/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
Expand Down Expand Up @@ -28,15 +28,13 @@
* SUCH DAMAGE.
*/

#ifndef _SYS_PUTTER_H_
#define _SYS_PUTTER_H_
#ifndef _DEV_PUTTER_PUTTERSYS_H_
#define _DEV_PUTTER_PUTTERSYS_H_

#include <sys/param.h>
#include <sys/select.h>
#include <sys/kauth.h>
#include <sys/mutex.h>
#include <sys/queue.h>
#include <sys/pool.h>
#include <sys/proc.h>

#include <dev/putter/putter.h>

struct putter_ops {
int (*pop_getout)(void *, size_t, int, uint8_t **,size_t *,void **);
Expand All @@ -52,4 +50,4 @@ struct putter_instance *putter_attach(pid_t, int, void *,
void putter_detach(struct putter_instance *);
void putter_notify(struct putter_instance *);

#endif /* _SYS_PUTTER_H_ */
#endif /* _DEV_PUTTER_PUTTERSYS_H_ */
Loading

0 comments on commit c6ced86

Please sign in to comment.