Lines Matching +full:pm +full:- +full:api
1 /*-
37 /*------------------------------------------------------------------------*
38 * Implementation of busdma API
39 *------------------------------------------------------------------------*/
53 ret->alignment = alignment; in bus_dma_tag_create()
54 ret->maxsize = maxsize; in bus_dma_tag_create()
67 addr = malloc(dmat->maxsize + dmat->alignment, XXX, XXX); in bus_dmamem_alloc()
72 addr = (void*)(((uintptr_t)addr + dmat->alignment - 1) & ~(dmat->alignment - 1)); in bus_dmamem_alloc()
115 /*------------------------------------------------------------------------*
116 * Implementation of resource management API
117 *------------------------------------------------------------------------*/
129 res->__r_i = malloc(sizeof(struct resource_i), XXX, XXX); in bus_alloc_resource_any()
130 if (res->__r_i == NULL) { in bus_alloc_resource_any()
140 free(res->__r_i, XXX); in bus_alloc_resource_any()
151 for (i = 0; rs[i].type != -1; i++) in bus_alloc_resources()
153 for (i = 0; rs[i].type != -1; i++) { in bus_alloc_resources()
170 for (i = 0; rs[i].type != -1; i++) in bus_release_resources()
183 dev->dev_irq_filter = filter; in bus_setup_intr()
184 dev->dev_irq_fn = handler; in bus_setup_intr()
185 dev->dev_irq_arg = arg; in bus_setup_intr()
194 dev->dev_irq_filter = NULL; in bus_teardown_intr()
195 dev->dev_irq_fn = NULL; in bus_teardown_intr()
196 dev->dev_irq_arg = NULL; in bus_teardown_intr()
213 TAILQ_FOREACH(child, &dev->dev_children, dev_link) { in bus_generic_attach()
224 return (r->r_bustag); in rman_get_bustag()
231 return (r->r_bushandle); in rman_get_bushandle()
238 return (r->__r_i->r_end - r->__r_i->r_start + 1); in rman_get_size()
259 /*------------------------------------------------------------------------*
260 * Implementation of mutex API
261 *------------------------------------------------------------------------*/
275 mtx->owned = 0; in mtx_init()
276 mtx->parent = mtx; in mtx_init()
282 mtx = mtx->parent; in mtx_lock()
283 mtx->owned++; in mtx_lock()
289 mtx = mtx->parent; in mtx_unlock()
290 mtx->owned--; in mtx_unlock()
296 mtx = mtx->parent; in mtx_owned()
297 return (mtx->owned != 0); in mtx_owned()
306 /*------------------------------------------------------------------------*
307 * Implementation of shared/exclusive mutex API
308 *------------------------------------------------------------------------*/
313 sx->owned = 0; in sx_init_flags()
325 sx->owned++; in sx_xlock()
331 sx->owned--; in sx_xunlock()
337 return (sx->owned != 0); in sx_xlocked()
340 /*------------------------------------------------------------------------*
341 * Implementaiton of condition variable API
342 *------------------------------------------------------------------------*/
347 cv->sleeping = 0; in cv_init()
359 cv_timedwait(cv, mtx, -1); in cv_wait()
369 if (cv->sleeping) in cv_timedwait()
372 cv->sleeping = 1; in cv_timedwait()
374 while (cv->sleeping) { in cv_timedwait()
376 delta = ticks - start; in cv_timedwait()
395 if (cv->sleeping) { in cv_timedwait()
396 cv->sleeping = 0; in cv_timedwait()
405 cv->sleeping = 0; in cv_signal()
411 cv->sleeping = 0; in cv_broadcast()
414 /*------------------------------------------------------------------------*
415 * Implementation of callout API
416 *------------------------------------------------------------------------*/
430 mtx_init(&mtx_callout, "callout-mtx", NULL, MTX_DEF | MTX_RECURSE); in callout_system_init()
440 mtx_lock(c->mtx); in callout_callback()
443 if (c->entry.le_prev != NULL) { in callout_callback()
445 c->entry.le_prev = NULL; in callout_callback()
449 if (c->c_func != NULL) in callout_callback()
450 (c->c_func) (c->c_arg); in callout_callback()
452 if (!(c->flags & CALLOUT_RETURNUNLOCKED)) in callout_callback()
453 mtx_unlock(c->mtx); in callout_callback()
474 delta = c->timeout - ticks; in callout_proc_msg()
494 c->mtx = mtx; in callout_init_mtx()
495 c->flags = (flags & CALLOUT_RETURNUNLOCKED); in callout_init_mtx()
504 c->c_func = func; in callout_reset()
505 c->c_arg = arg; in callout_reset()
506 c->timeout = ticks + to_ticks; in callout_reset()
518 if (c->entry.le_prev != NULL) { in callout_stop()
520 c->entry.le_prev = NULL; in callout_stop()
524 c->c_func = NULL; in callout_stop()
525 c->c_arg = NULL; in callout_stop()
531 if (c->mtx == NULL) in callout_drain()
534 mtx_lock(c->mtx); in callout_drain()
536 mtx_unlock(c->mtx); in callout_drain()
545 retval = (c->entry.le_prev != NULL); in callout_pending()
551 /*------------------------------------------------------------------------*
552 * Implementation of device API
553 *------------------------------------------------------------------------*/
614 return (dev ? dev->dev_parent : NULL); in device_get_parent()
621 dev->dev_irq_filter = filter; in device_set_interrupt()
622 dev->dev_irq_fn = fn; in device_set_interrupt()
623 dev->dev_irq_arg = arg; in device_set_interrupt()
634 TAILQ_FOREACH(child, &parent->dev_children, dev_link) { in device_run_interrupts()
636 if (child->dev_irq_filter != NULL) in device_run_interrupts()
637 status = child->dev_irq_filter(child->dev_irq_arg); in device_run_interrupts()
642 if (child->dev_irq_fn != NULL) in device_run_interrupts()
643 (child->dev_irq_fn) (child->dev_irq_arg); in device_run_interrupts()
651 dev->dev_aux = ivars; in device_set_ivars()
657 return (dev ? dev->dev_aux : NULL); in device_get_ivars()
663 return (dev ? dev->dev_unit : 0); in device_get_unit()
672 if (!dev->dev_attached) in bus_generic_detach()
675 TAILQ_FOREACH(child, &dev->dev_children, dev_link) { in bus_generic_detach()
685 if (dev && dev->dev_nameunit[0]) in device_get_nameunit()
686 return (dev->dev_nameunit); in device_get_nameunit()
714 if (devclass_equal(mod->mod_name, classname)) { in devclass_find_create()
715 if (devclass_create(mod->devclass_pp)) { in devclass_find_create()
731 pp_dev = mod->devclass_pp[0]->dev_list; in devclass_add_device()
738 dev->dev_unit = unit; in devclass_add_device()
739 dev->dev_module = mod; in devclass_add_device()
740 snprintf(dev->dev_nameunit, in devclass_add_device()
741 sizeof(dev->dev_nameunit), in devclass_add_device()
758 mod->devclass_pp[0]->dev_list[dev->dev_unit] = NULL; in devclass_delete_device()
759 dev->dev_module = NULL; in devclass_delete_device()
787 dev->dev_parent = parent; in make_device()
788 TAILQ_INIT(&dev->dev_children); in make_device()
791 dev->dev_fixed_class = 1; in make_device()
811 if (unit != -1) { in device_add_child()
812 device_printf(dev, "Unit is not -1\n"); in device_add_child()
823 TAILQ_INSERT_TAIL(&dev->dev_children, child, dev_link); in device_add_child()
840 while ((grandchild = TAILQ_FIRST(&child->dev_children))) { in device_delete_child()
848 devclass_delete_device(child->dev_module, child); in device_delete_child()
852 TAILQ_REMOVE(&dev->dev_children, child, dev_link); in device_delete_child()
866 while ((child = TAILQ_FIRST(&dev->dev_children))) { in device_delete_children()
879 dev->dev_quiet = 1; in device_quiet()
886 return &(dev->dev_desc[0]); in device_get_desc()
903 mtod = dev->dev_module->driver->methods; in device_get_method()
904 while (mtod->func != NULL) { in device_get_method()
905 if (devclass_equal(mtod->desc, what)) { in device_get_method()
906 return (mtod->func); in device_get_method()
919 return (dev->dev_module->driver->name); in device_get_name()
927 mod = dev->dev_module; in device_allocate_softc()
929 if ((dev->dev_softc_alloc == 0) && in device_allocate_softc()
930 (mod->driver->size != 0)) { in device_allocate_softc()
931 dev->dev_sc = malloc(mod->driver->size, in device_allocate_softc()
934 if (dev->dev_sc == NULL) in device_allocate_softc()
937 dev->dev_softc_alloc = 1; in device_allocate_softc()
950 if (dev->dev_attached) in device_probe_and_attach()
951 return (0); /* fail-safe */ in device_probe_and_attach()
953 if (dev->dev_fixed_class) { in device_probe_and_attach()
955 mod = dev->dev_module; in device_probe_and_attach()
963 dev->dev_attached = 1; in device_probe_and_attach()
977 if (devclass_equal(mod->bus_name, bus_name_parent)) { in device_probe_and_attach()
978 if (devclass_create(mod->devclass_pp)) { in device_probe_and_attach()
990 dev->dev_attached = 1; in device_probe_and_attach()
1008 const struct module_data *mod = dev->dev_module; in device_detach()
1011 if (dev->dev_attached) { in device_detach()
1017 dev->dev_attached = 0; in device_detach()
1021 if (dev->dev_fixed_class == 0) in device_detach()
1030 if (dev->dev_softc_alloc) { in device_set_softc()
1031 free(dev->dev_sc, M_DEVBUF); in device_set_softc()
1032 dev->dev_sc = NULL; in device_set_softc()
1034 dev->dev_sc = softc; in device_set_softc()
1035 dev->dev_softc_alloc = 0; in device_set_softc()
1044 return (dev->dev_sc); in device_get_softc()
1050 return (dev->dev_attached); in device_is_attached()
1056 snprintf(dev->dev_desc, sizeof(dev->dev_desc), "%s", desc); in device_set_desc()
1078 while (max_unit--) { in devclass_get_maxunit()
1079 if (dc->dev_list[max_unit]) { in devclass_get_maxunit()
1092 NULL : dc->dev_list[unit]); in devclass_get_device()
1101 if (devclass_equal(mod->driver->name, classname)) in devclass_find()
1102 return (mod->devclass_pp[0]); in devclass_find()
1115 /*------------------------------------------------------------------------*
1117 *------------------------------------------------------------------------*/
1125 (psys->func) (psys->data); in sysinit_run()
1130 /*------------------------------------------------------------------------*
1131 * USB process API
1132 *------------------------------------------------------------------------*/
1135 static int usb_proc_level = -1;
1175 TAILQ_INIT(&up->up_qhead); in usb_process_init_sub()
1177 cv_init(&up->up_cv, "-"); in usb_process_init_sub()
1178 cv_init(&up->up_drain, "usbdrain"); in usb_process_init_sub()
1180 up->up_mtx = &usb_proc_mtx; in usb_process_init_sub()
1188 mtx_init(&usb_proc_mtx, "usb-proc-mtx", NULL, MTX_DEF | MTX_RECURSE); in usb_process_init()
1199 struct usb_proc_msg *pm; in usb_do_process() local
1205 pm = TAILQ_FIRST(&up->up_qhead); in usb_do_process()
1207 if (pm != NULL) { in usb_do_process()
1211 (pm->pm_callback) (pm); in usb_do_process()
1213 if (pm == TAILQ_FIRST(&up->up_qhead)) { in usb_do_process()
1215 TAILQ_REMOVE(&up->up_qhead, pm, pm_qentry); in usb_do_process()
1216 pm->pm_qentry.tqe_prev = NULL; in usb_do_process()
1236 if (pm0->pm_qentry.tqe_prev) { in usb_proc_msignal()
1239 if (pm1->pm_qentry.tqe_prev) { in usb_proc_msignal()
1250 if (pm0->pm_num == up->up_msg_num) { in usb_proc_msignal()
1251 up->up_msg_num++; in usb_proc_msignal()
1256 if (pm1->pm_num == up->up_msg_num) { in usb_proc_msignal()
1257 up->up_msg_num++; in usb_proc_msignal()
1262 * Both entries are queued. Re-queue the entry closest to in usb_proc_msignal()
1265 d = (pm1->pm_num - pm0->pm_num); in usb_proc_msignal()
1274 TAILQ_REMOVE(&up->up_qhead, pm2, pm_qentry); in usb_proc_msignal()
1276 pm2 = NULL; /* panic - should not happen */ in usb_proc_msignal()
1281 pm2->pm_num = up->up_msg_num; in usb_proc_msignal()
1282 TAILQ_INSERT_TAIL(&up->up_qhead, pm2, pm_qentry); in usb_proc_msignal()
1287 /*------------------------------------------------------------------------*
1293 *------------------------------------------------------------------------*/
1300 /*------------------------------------------------------------------------*
1304 * by "pm" is no longer on a queue. This function must be called
1306 *------------------------------------------------------------------------*/
1314 if (pm0->pm_qentry.tqe_prev) { in usb_proc_mwait()
1315 TAILQ_REMOVE(&up->up_qhead, pm0, pm_qentry); in usb_proc_mwait()
1316 pm0->pm_qentry.tqe_prev = NULL; in usb_proc_mwait()
1318 if (pm1->pm_qentry.tqe_prev) { in usb_proc_mwait()
1319 TAILQ_REMOVE(&up->up_qhead, pm1, pm_qentry); in usb_proc_mwait()
1320 pm1->pm_qentry.tqe_prev = NULL; in usb_proc_mwait()
1324 /*------------------------------------------------------------------------*
1326 *------------------------------------------------------------------------*/
1355 usb_pci_root = device_add_child(NULL, "pci", -1); in usb_pci_mod_load()
1360 usb_pci_dev[x] = device_add_child(usb_pci_root, usb_pci_devices[x], -1); in usb_pci_mod_load()
1388 /*------------------------------------------------------------------------*
1389 * MALLOC API
1390 *------------------------------------------------------------------------*/
1412 size = (size + USB_POOL_ALIGN - 1) & ~(USB_POOL_ALIGN - 1); in usb_malloc()
1416 if (hdr->size == size) in usb_malloc()
1425 memset(hdr + 1, 0, hdr->size - sizeof(*hdr)); in usb_malloc()
1429 hdr = (void *)(usb_pool + USB_POOL_SIZE - usb_pool_rem); in usb_malloc()
1430 hdr->size = size; in usb_malloc()
1432 usb_pool_rem -= size; in usb_malloc()
1438 memset(hdr + 1, 0, hdr->size - sizeof(*hdr)); in usb_malloc()
1453 hdr--; in usb_free()