Home | History | Annotate | Download | only in libpuffs

Lines Matching defs:pcc

74 puffs_cc_yield(struct puffs_cc *pcc)
81 if ((~pcc->pcc_flags & (PCC_BORROWED|PCC_DONE)) == 0) {
82 pcc->pcc_flags &= ~(PCC_BORROWED|PCC_DONE);
86 puffs__cc_destroy(pcc, 1);
87 setcontext(&pcc->pcc_uc_ret);
89 pcc->pcc_flags &= ~PCC_BORROWED;
93 if ((pcc->pcc_flags & PCC_MLCONT) == 0) {
94 DPRINTF(("no mlcont, pcc %p\n", pcc));
95 swapcontext(&pcc->pcc_uc, &pcc->pcc_uc_ret);
97 DPRINTF(("mlcont, pcc %p\n", pcc));
98 pcc->pcc_flags &= ~PCC_MLCONT;
99 rv = puffs__cc_create(pcc->pcc_pu, puffs__theloop, &jumpcc);
102 swapcontext(&pcc->pcc_uc, &jumpcc->pcc_uc);
103 DPRINTF(("puffs_cc_yield: post swap pcc %p\n", pcc));
110 * indicated pcc.
113 puffs__cc_cont(struct puffs_cc *pcc)
117 mycc = puffs_cc_getcc(pcc->pcc_pu);
118 DPRINTF(("puffs__cc_cont: pcc %p, mycc %p\n", pcc, mycc));
125 pcc->pcc_flags |= PCC_MLCONT;
126 setcontext(&pcc->pcc_uc);
130 puffs_cc_continue(struct puffs_cc *pcc)
134 DPRINTF(("puffs_cc_continue: pcc %p\n", pcc));
136 pcc->pcc_func(pcc->pcc_farg);
138 swapcontext(&pcc->pcc_uc_ret, &pcc->pcc_uc);
143 * "Borrows" pcc, *NOT* called from pcc owner. Acts like continue.
146 * from after the op dispatching is complete (or if the pcc decides to
159 puffs_cc_schedule(struct puffs_cc *pcc)
161 struct puffs_usermount *pu = pcc->pcc_pu;
164 TAILQ_INSERT_TAIL(&pu->pu_sched, pcc, pcc_schedent);
168 puffs_cc_getcaller(struct puffs_cc *pcc, pid_t *pid, lwpid_t *lid)
171 if ((pcc->pcc_flags & PCC_HASCALLER) == 0) {
177 *pid = pcc->pcc_pid;
179 *lid = pcc->pcc_lid;
188 struct puffs_cc *volatile pcc;
201 pcc = sp;
202 memset(pcc, 0, sizeof(struct puffs_cc));
211 if (getcontext(&pcc->pcc_uc) == -1) {
212 munmap(pcc, stacksize);
215 if (getcontext(&pcc->pcc_uc_ret) == -1) {
216 munmap(pcc, stacksize);
220 return pcc;
227 struct puffs_cc *pcc;
233 pcc = slowccalloc(pu);
234 if (pcc == NULL)
236 pcc->pcc_pu = pu;
237 DPRINTF(("puffs__cc_create: allocated pcc %p\n", pcc));
239 pcc = LIST_FIRST(&pu->pu_ccmagazin);
240 assert(pcc != NULL);
242 LIST_REMOVE(pcc, pcc_rope);
244 DPRINTF(("puffs__cc_create: magazin pcc %p\n", pcc));
246 assert(pcc->pcc_pu == pu);
249 pcc->pcc_func = func;
250 pcc->pcc_farg = pcc;
255 pcc->pcc_uc.uc_link = &pcc->pcc_uc_ret;
262 st = &pcc->pcc_uc.uc_stack;
263 st->ss_sp = ((uint8_t *)(void *)pcc) + psize;
276 makecontext(&pcc->pcc_uc, (void *)func, 1, (uintptr_t)pcc);
279 *pccp = pcc;
284 puffs__cc_setcaller(struct puffs_cc *pcc, pid_t pid, lwpid_t lid)
287 pcc->pcc_pid = pid;
288 pcc->pcc_lid = lid;
289 pcc->pcc_flags |= PCC_HASCALLER;
293 cc_free(struct puffs_cc *pcc)
295 struct puffs_usermount *pu = pcc->pcc_pu;
298 DPRINTF(("invalidating pcc %p\n", pcc));
300 munmap(pcc, stacksize);
304 puffs__cc_destroy(struct puffs_cc *pcc, int nonuke)
306 struct puffs_usermount *pu = pcc->pcc_pu;
308 pcc->pcc_flags &= ~PCC_HASCALLER;
309 assert(pcc->pcc_flags == 0);
314 pcc->pcc_pb = NULL;
315 DPRINTF(("puffs__cc_destroy: storing pcc %p\n", pcc));
316 LIST_INSERT_HEAD(&pu->pu_ccmagazin, pcc, pcc_rope);
319 cc_free(pcc);
326 struct puffs_cc *pcc;
328 while ((pcc = LIST_FIRST(&pu->pu_ccmagazin)) != NULL) {
329 LIST_REMOVE(pcc, pcc_rope);
330 cc_free(pcc);