puffs_priv.h revision 1.2 1 /* $NetBSD: puffs_priv.h,v 1.2 2006/12/29 15:28:11 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 /* call context */
41
42 struct puffs_cc {
43 struct puffs_usermount *pcc_pu;
44 struct puffs_req *pcc_preq;
45
46 ucontext_t pcc_uc; /* "continue" */
47 ucontext_t pcc_uc_ret; /* "yield" */
48 void *pcc_stack;
49
50 int pcc_flags;
51
52 /* these are for threading information to the implementation */
53 void *pcc_priv;
54 int pcc_rv;
55
56 TAILQ_ENTRY(puffs_cc) entries;
57 };
58 #define PCC_ONCE 0x01
59 #define PCC_REALCC 0x02
60 #define PCC_FREEPRIV 0x04
61 #define PCC_PREQ_NOCOPY 0x08
62 #define PCC_DONE 0x10
63
64 #define PCC_CALL_NONE 0x10000
65 #define PCC_CALL_IN 0x20000
66 #define PCC_CALL_OUT 0x40000
67 #define PCC_CALL_MASK 0x70000
68
69 #define pcc_callstat(a) (a->pcc_flags & PCC_CALL_MASK)
70 #define pcc_callset(a, b) (a->pcc_flags = (a->pcc_flags & ~PCC_CALL_MASK) | b)
71
72 #define pcc_init_local(ap) \
73 do { \
74 memset(ap, 0, sizeof(*ap)); \
75 (ap)->pcc_flags = PCC_ONCE; \
76 } while (/*CONSTCOND*/0)
77
78 /*
79 * Reqs
80 */
81
82 struct puffs_getreq {
83 struct puffs_usermount *pgr_pu;
84
85 struct puffs_reqh_get pgr_phg;
86 struct puffs_reqh_get pgr_phg_orig;
87
88 struct puffs_req *pgr_nextpreq;
89 size_t pgr_advance;
90
91 /* diagnostics */
92 int pgr_nppr;
93 };
94
95 struct puffs_putreq {
96 struct puffs_usermount *ppr_pu;
97
98 struct puffs_reqh_put ppr_php;
99
100 /* to adjust next request info */
101 void **ppr_buf;
102 size_t *ppr_buflen;
103 uint64_t *ppr_id;
104
105 /* for delayed action freeing of preq's */
106 TAILQ_HEAD(, puffs_cc) ppr_pccq;
107
108 /* diagnostics */
109 struct puffs_getreq *ppr_pgr;
110 };
111
112 __BEGIN_DECLS
113 struct puffs_cc *puffs_cc_create(struct puffs_usermount *,
114 struct puffs_req *);
115 void puffs_cc_destroy(struct puffs_cc *);
116
117 void puffs_calldispatcher(struct puffs_cc *);
118 __END_DECLS
119
120 #endif /* _PUFFS_PRIVATE_H_ */
121