Home | History | Annotate | Line # | Download | only in libpuffs
puffs_priv.h revision 1.8
      1 /*	$NetBSD: puffs_priv.h,v 1.8 2007/05/10 12:26:28 pooka Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2006 Antti Kantee.  All Rights Reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. The name of the company nor the name of the author may be used to
     15  *    endorse or promote products derived from this software without specific
     16  *    prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     21  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  */
     30 
     31 #ifndef _PUFFS_PRIVATE_H_
     32 #define _PUFFS_PRIVATE_H_
     33 
     34 #include <sys/types.h>
     35 #include <fs/puffs/puffs_msgif.h>
     36 
     37 #include <puffs.h>
     38 #include <ucontext.h>
     39 
     40 #define PU_CMAP(pu, c)	(pu->pu_cmap ? pu->pu_cmap(c) : (struct puffs_node *)c)
     41 
     42 struct puffs_framectrl;
     43 
     44 /*
     45  * usermount: describes one file system instance
     46  */
     47 struct puffs_usermount {
     48 	struct puffs_ops	pu_ops;
     49 	struct puffs_kargs	pu_kargs;
     50 
     51 	uint32_t		pu_flags;
     52 	size_t			pu_cc_stacksize;
     53 
     54 	int			pu_state;
     55 
     56 	struct puffs_node	*pu_pn_root;
     57 
     58 	LIST_HEAD(, puffs_node)	pu_pnodelst;
     59 
     60 	struct puffs_node	*(*pu_cmap)(void *);
     61 
     62 	pu_pathbuild_fn		pu_pathbuild;
     63 	pu_pathtransform_fn	pu_pathtransform;
     64 	pu_pathcmp_fn		pu_pathcmp;
     65 	pu_pathfree_fn		pu_pathfree;
     66 	pu_namemod_fn		pu_namemod;
     67 
     68 	struct puffs_framectrl	*pu_framectrl;
     69 
     70 	void	*pu_privdata;
     71 };
     72 
     73 /* call context */
     74 
     75 struct puffs_cc {
     76 	struct puffs_usermount	*pcc_pu;
     77 	struct puffs_req	*pcc_preq;
     78 
     79 	ucontext_t		pcc_uc;		/* "continue" 		*/
     80 	ucontext_t		pcc_uc_ret;	/* "yield" 		*/
     81 	void			*pcc_stack;
     82 
     83 	int			pcc_flags;
     84 
     85 	/* these are for threading information to the implementation	*/
     86 	void			*pcc_priv;
     87 	int			pcc_rv;
     88 
     89 	TAILQ_ENTRY(puffs_cc)	entries;
     90 };
     91 #define PCC_FAKECC	0x01
     92 #define PCC_REALCC	0x02
     93 #define PCC_FREEPRIV	0x04
     94 #define PCC_PREQ_NOCOPY	0x08
     95 #define PCC_DONE	0x10
     96 
     97 #define PCC_CALL_NONE	0x10000
     98 #define PCC_CALL_IN	0x20000
     99 #define PCC_CALL_OUT	0x40000
    100 #define PCC_CALL_MASK	0x70000
    101 
    102 #define pcc_callstat(a)	   (a->pcc_flags & PCC_CALL_MASK)
    103 #define pcc_callset(a, b)  (a->pcc_flags = (a->pcc_flags & ~PCC_CALL_MASK) | b)
    104 
    105 #define pcc_init_local(ap)   						\
    106 do {									\
    107 	memset(ap, 0, sizeof(*ap));					\
    108 	(ap)->pcc_flags = PCC_FAKECC;					\
    109 } while (/*CONSTCOND*/0)
    110 
    111 /*
    112  * Reqs
    113  */
    114 
    115 struct puffs_getreq {
    116 	struct puffs_usermount	*pgr_pu;
    117 
    118 	struct puffs_reqh_get	pgr_phg;
    119 	struct puffs_reqh_get	pgr_phg_orig;
    120 
    121 	struct puffs_req	*pgr_nextpreq;
    122 	size_t			pgr_advance;
    123 
    124 	/* diagnostics */
    125 	int			pgr_nppr;
    126 };
    127 
    128 struct puffs_putreq {
    129 	struct puffs_usermount *ppr_pu;
    130 
    131 	struct puffs_reqh_put	ppr_php;
    132 
    133 	/* to adjust next request info */
    134 	void			**ppr_buf;
    135 	size_t			*ppr_buflen;
    136 	uint64_t 		*ppr_id;
    137 
    138 	/* for delayed action freeing of preq's */
    139 	TAILQ_HEAD(, puffs_cc)	ppr_pccq;
    140 
    141 	/* diagnostics */
    142 	struct puffs_getreq	*ppr_pgr;
    143 };
    144 
    145 __BEGIN_DECLS
    146 
    147 void	puffs_calldispatcher(struct puffs_cc *);
    148 
    149 __END_DECLS
    150 
    151 #endif /* _PUFFS_PRIVATE_H_ */
    152