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