/*===========================================================================* * select_unsuspend_by_endpt * *===========================================================================*/ void select_unsuspend_by_endpt(endpoint_t proc_e) { /* Revive blocked processes when a driver has disappeared */ int fd, s, major; struct selectentry *se; struct filp *f; for (s = 0; s < MAXSELECTS; s++) { int wakehim = 0; se = &selecttab[s]; if (se->requestor == NULL) continue; if (se->requestor->fp_endpoint == proc_e) { assert(se->requestor->fp_flags & FP_EXITING); select_cancel_all(se); continue; } for (fd = 0; fd < se->nfds; fd++) { if ((f = se->filps[fd]) == NULL || f->filp_vno == NULL) continue; major = major(f->filp_vno->v_sdev); if (dmap_driver_match(proc_e, major)) { se->filps[fd] = NULL; se->error = EINTR; select_cancel_filp(f); wakehim = 1; } } if (wakehim && !is_deferred(se)) select_return(se); } }
/*===========================================================================* * get_dmap * *===========================================================================*/ struct dmap *get_dmap(endpoint_t proc_e) { /* See if 'proc_e' endpoint belongs to a valid dmap entry. If so, return a * pointer */ devmajor_t major; for (major = 0; major < NR_DEVICES; major++) if (dmap_driver_match(proc_e, major)) return(&dmap[major]); return(NULL); }
/*===========================================================================* * dmap_unmap_by_endpt * *===========================================================================*/ void dmap_unmap_by_endpt(endpoint_t proc_e) { /* Lookup driver in dmap table by endpoint and unmap it */ devmajor_t major; int r; for (major = 0; major < NR_DEVICES; major++) { if (dmap_driver_match(proc_e, major)) { /* Found driver; overwrite it with a NULL entry */ if ((r = map_driver(NULL, major, NONE)) != OK) { printf("VFS: unmapping driver %d for major %d failed:" " %d\n", proc_e, major, r); } } } }
/*===========================================================================* * dev_status * *===========================================================================*/ void dev_status(endpoint_t drv_e) { /* A device sent us a notification it has something for us. Retrieve it. */ message st; int major, get_more = 1; endpoint_t endpt; for (major = 0; major < NR_DEVICES; major++) if (dmap_driver_match(drv_e, major)) break; /* 'major' is the device that sent the message */ if (major >= NR_DEVICES) /* Device endpoint not found; nothing to do */ return; if (dev_style_asyn(dmap[major].dmap_style)) { printf("VFS: not doing dev_status for async driver %d\n", drv_e); return; } /* Continuously send DEV_STATUS messages until the device has nothing to * say to us anymore. */ do { int r; st.m_type = DEV_STATUS; r = drv_sendrec(drv_e, &st); if (r == OK && st.REP_STATUS == ERESTART) r = EDEADEPT; if (r != OK) { printf("VFS: DEV_STATUS failed to %d: %d\n", drv_e, r); if (r == EDEADSRCDST || r == EDEADEPT) return; panic("VFS: couldn't sendrec for DEV_STATUS: %d", r); } switch(st.m_type) { case DEV_REVIVE: /* We've got results for a read/write/ioctl call to a * synchronous character driver */ endpt = st.REP_ENDPT; if (endpt == VFS_PROC_NR) { endpt = find_suspended_ep(drv_e, st.REP_IO_GRANT); if (endpt == NONE) { printf("VFS: proc with grant %d from %d not found\n", st.REP_IO_GRANT, st.m_source); continue; } } revive(endpt, st.REP_STATUS); break; case DEV_IO_READY: /* Reply to a select request: driver is ready for I/O */ select_reply2(st.m_source, st.DEV_MINOR, st.DEV_SEL_OPS); break; default: printf("VFS: unrecognized reply %d to DEV_STATUS\n",st.m_type); /* Fall through. */ case DEV_NO_STATUS: get_more = 0; break; } } while(get_more); }