Lines Matching refs:st

283 #define	DEVICES_FILES_CLEANABLE(st)	\
284 (((st)->command & DINFOSUBTREE) && ((st)->command & DINFOFORCE) && \
285 strcmp(DI_ALL_PTR(st)->root_path, "/") == 0)
292 struct di_state *st;
318 static void di_copymem(struct di_state *st, caddr_t buf, size_t bufsiz);
327 static int di_dip_find(struct di_state *st, dev_info_t *node, di_off_t *off_p);
329 static int cache_args_valid(struct di_state *st, int *error);
330 static int snapshot_is_cacheable(struct di_state *st);
331 static int di_cache_lookup(struct di_state *st);
332 static int di_cache_update(struct di_state *st);
336 static void di_hotplug_children(struct di_state *st);
558 struct di_state *st;
567 st = di_states[m];
568 ASSERT(m < di_max_opens && st != NULL);
570 di_freemem(st);
571 kmem_free(st, sizeof (struct di_state));
593 struct di_state *st;
605 st = di_states[m];
606 ASSERT(st != NULL);
672 if (di_setstate(st, IOC_COPY) == -1)
675 map_size = DI_ALL_PTR(st)->map_size;
677 (void) di_setstate(st, IOC_DONE);
696 dcp = st->memlist;
703 if (ddi_copyout(di_mem_addr(st, off),
705 (void) di_setstate(st, IOC_DONE);
714 di_freemem(st);
715 (void) di_setstate(st, IOC_IDLE);
728 st->command = cmd & DIIOC_MASK;
738 if (di_setstate(st, IOC_SNAP) == -1)
749 off = di_checkmem(st, 0, size);
750 all = DI_ALL_PTR(st);
754 all->command = st->command;
771 di_freemem(st);
772 (void) di_setstate(st, IOC_IDLE);
778 if ((st->command & DINFOCLEANUP) && !DEVICES_FILES_CLEANABLE(st)) {
779 di_freemem(st);
780 (void) di_setstate(st, IOC_IDLE);
785 if ((st->command & DINFOCACHE) && !cache_args_valid(st, &error)) {
786 di_freemem(st);
787 (void) di_setstate(st, IOC_IDLE);
795 if ((st->command & (DINFOPRIVDATA | DINFOFORCE)) != 0 &&
797 di_freemem(st);
798 (void) di_setstate(st, IOC_IDLE);
803 if (st->command & DINFOPRIVDATA) {
813 di_freemem(st);
814 (void) di_setstate(st, IOC_IDLE);
818 if ((off = di_copyformat(off, st, arg, mode)) == 0) {
819 di_freemem(st);
820 (void) di_setstate(st, IOC_IDLE);
826 if ((off = di_copyformat(off, st, arg, mode)) == 0) {
827 di_freemem(st);
828 (void) di_setstate(st, IOC_IDLE);
842 if (st->command & DINFOCACHE) {
843 *rvalp = di_cache_lookup(st);
844 } else if (snapshot_is_cacheable(st)) {
846 *rvalp = di_cache_update(st);
849 *rvalp = di_snapshot_and_clean(st);
852 DI_ALL_PTR(st)->map_size = *rvalp;
853 (void) di_setstate(st, IOC_DONE);
855 di_freemem(st);
856 (void) di_setstate(st, IOC_IDLE);
866 di_allocmem(struct di_state *st, size_t size)
872 * than st->mem_size, set it to st->mem_size (i.e.,
880 size = (tmp > st->mem_size) ? tmp : st->mem_size;
885 dcmn_err2((CE_CONT, "di_allocmem: mem_size=%x\n", st->mem_size));
887 if (st->mem_size == 0) { /* first chunk */
888 st->memlist = mem;
893 struct di_mem *dcp = st->memlist;
901 st->mem_size += size;
908 di_copymem(struct di_state *st, caddr_t buf, size_t bufsiz)
913 if (st->mem_size == 0) {
914 ASSERT(st->memlist == NULL);
919 for (dcp = st->memlist; dcp; dcp = dcp->next) {
942 di_freemem(struct di_state *st)
948 if (st->mem_size) {
949 dcp = st->memlist;
956 st->mem_size = 0;
957 st->memlist = NULL;
960 ASSERT(st->mem_size == 0);
961 ASSERT(st->memlist == NULL);
971 di_cache2mem(struct di_cache *cache, struct di_state *st)
975 ASSERT(st->mem_size == 0);
976 ASSERT(st->memlist == NULL);
988 di_allocmem(st, cache->cache_size);
990 pa = di_mem_addr(st, 0);
998 ASSERT(st->memlist != NULL);
999 ASSERT(st->memlist->next == NULL);
1012 di_mem2cache(struct di_state *st, struct di_cache *cache)
1021 if (st->mem_size == 0) {
1022 ASSERT(st->memlist == NULL);
1027 ASSERT(st->memlist);
1033 map_size = DI_ALL_PTR(st)->map_size;
1035 map_size > st->mem_size) {
1042 di_copymem(st, cache->cache_data, cache->cache_size);
1052 di_checkmem(struct di_state *st, di_off_t off, size_t size)
1069 if ((st->mem_size - off) < size) {
1070 off = st->mem_size;
1071 di_allocmem(st, size);
1084 di_copyformat(di_off_t off, struct di_state *st, intptr_t arg, int mode)
1088 struct di_all *all = DI_ALL_PTR(st);
1119 all->ppdata_format = off = di_checkmem(st, off, size);
1120 if (ddi_copyin(priv->parent, di_mem_addr(st, off), size,
1134 all->dpdata_format = off = di_checkmem(st, off, size);
1135 if (ddi_copyin(priv->driver, di_mem_addr(st, off), size,
1152 di_mem_addr(struct di_state *st, di_off_t off)
1154 struct di_mem *dcp = st->memlist;
1159 ASSERT(off < st->mem_size);
1299 di_copy_aliases(struct di_state *st, alias_pair_t *apair, di_off_t *offp)
1302 struct di_all *all = DI_ALL_PTR(st);
1313 if (di_dip_find(st, currdip, &curroff) != 0) {
1322 off = di_checkmem(st, off, size);
1323 di_alias = DI_ALIAS(di_mem_addr(st, off));
1340 di_snapshot(struct di_state *st)
1351 all = DI_ALL_PTR(st);
1397 "devinfo registered dips (statep=%p)", (void *)st);
1399 st->reg_dip_hash = mod_hash_create_extended(buf, 64,
1405 "devinfo registered pips (statep=%p)", (void *)st);
1407 st->reg_pip_hash = mod_hash_create_extended(buf, 64,
1411 if (DINFOHP & st->command) {
1412 list_create(&st->hp_list, sizeof (i_hp_t),
1419 off = di_copytree(DEVI(rootnode), &all->top_devinfo, st);
1421 if (DINFOPATH & st->command) {
1422 mdi_walk_vhcis(build_vhci_list, st);
1425 if (DINFOHP & st->command) {
1426 di_hotplug_children(st);
1435 off = di_copydevnm(&all->devnames, st);
1439 st->lnode_count = 0;
1440 st->link_count = 0;
1442 if (DINFOLYR & st->command) {
1443 off = di_getlink_data(off, st);
1451 di_copy_aliases(st, &(ddi_aliases.dali_alias_pairs[i]), &off);
1458 mod_hash_destroy_hash(st->reg_dip_hash);
1459 mod_hash_destroy_hash(st->reg_pip_hash);
1484 di_snapshot_and_clean(struct di_state *st)
1489 off = di_snapshot(st);
1490 if (off != 0 && (st->command & DINFOCLEANUP)) {
1491 ASSERT(DEVICES_FILES_CLEANABLE(st));
1520 struct di_state *st;
1529 st = (struct di_state *)arg;
1530 if (di_dip_find(st, vh_devinfo, &off) != 0) {
1535 dcmn_err3((CE_CONT, "st->mem_size: %d vh_devinfo off: 0x%x\n",
1536 st->mem_size, off));
1538 all = DI_ALL_PTR(st);
1542 me = DI_NODE(di_mem_addr(st, all->top_vhci_devinfo));
1545 me = DI_NODE(di_mem_addr(st, me->next_vhci));
1552 pwa.st = st;
1574 vh_di_node = DI_NODE(di_mem_addr(pwa->st, pwa->off));
1575 if (di_dip_find(pwa->st, ph_devinfo, &off) != 0) {
1588 me = DI_NODE(di_mem_addr(pwa->st, vh_di_node->top_phci));
1591 me = DI_NODE(di_mem_addr(pwa->st, me->next_phci));
1602 snap_driver_list(struct di_state *st, struct devnames *dnp, di_off_t *off_p)
1612 if (di_dip_find(st, (dev_info_t *)node, &off) != 0)
1616 me = DI_NODE(di_mem_addr(st, off));
1637 di_copydevnm(di_off_t *off_p, struct di_state *st)
1650 *off_p = off = di_checkmem(st, *off_p, size);
1651 dnp = DI_DEVNM(di_mem_addr(st, off));
1675 dnp[i].name = off = di_checkmem(st, off, size);
1676 (void) strcpy((char *)di_mem_addr(st, off),
1685 snap_driver_list(st, &devnamesp[i], &dnp[i].head);
1696 if ((DINFOPROP & st->command) &&
1701 &dnp[i].global_prop, st, NULL);
1731 di_copytree(struct dev_info *root, di_off_t *off_p, struct di_state *st)
1742 (st->command & DINFOSUBTREE) && (st->command & DINFOFORCE)) {
1763 off = di_copynode(node, dsp, st);
1780 di_copynode(struct dev_info *node, struct di_stack *dsp, struct di_state *st)
1794 *(TOP_OFFSET(dsp)) = off = di_checkmem(st, *(TOP_OFFSET(dsp)), size);
1795 me = DI_NODE(di_mem_addr(st, off));
1838 di_register_dip(st, (dev_info_t *)node, me->self);
1855 off = di_checkmem(st, off, size);
1857 bcopy(devid, di_mem_addr(st, off), size);
1866 me->node_name = off = di_checkmem(st, off, size);
1867 (void) strcpy(di_mem_addr(st, off), node->devi_node_name);
1873 me->compat_names = off = di_checkmem(st, off, size);
1875 bcopy(node->devi_compat_names, di_mem_addr(st, off), size);
1881 me->address = off = di_checkmem(st, off, size);
1882 (void) strcpy(di_mem_addr(st, off), node->devi_addr);
1888 me->bind_name = off = di_checkmem(st, off, size);
1889 (void) strcpy(di_mem_addr(st, off), node->devi_binding_name);
1909 if (!((DINFOMINOR | DINFOPROP | DINFOPATH | DINFOHP) & st->command)) {
1918 if (!(DINFOMINOR & st->command)) {
1926 me->self, st);
1930 if (!(DINFOPATH & st->command)) {
1942 me->self, st, 1);
1953 me->self, st, 0);
1961 if (!(DINFOPROP & st->command)) {
1968 &me->drv_prop, st, node);
1974 &me->sys_prop, st, node);
1980 &me->hw_prop, st, node);
1998 &me->glob_prop, st, node);
2003 if (!(DINFOHP & st->command)) {
2009 off = di_gethpdata(node->devi_hp_hdlp, &me->hp_data, st);
2013 if (!(DINFOPRIVDATA & st->command)) {
2019 off = di_getppdata(node, &me->parent_data, st);
2024 off = di_getdpdata(node, &me->driver_data, st);
2033 if (!(DINFOSUBTREE & st->command)) {
2072 me = DI_NODE(di_mem_addr(st, *(TOP_OFFSET(dsp))));
2189 struct di_state *st = (struct di_state *)arg;
2211 if (di_dip_find(st, ldi_usage->src_dip, &soff) != 0)
2213 if (di_dip_find(st, ldi_usage->tgt_dip, &toff) != 0)
2227 i_lnode->di_node = DI_NODE(di_mem_addr(st, soff));
2230 res = mod_hash_find(st->lnode_hash, i_lnode, &nodep);
2236 res = mod_hash_insert(st->lnode_hash, i_lnode, i_lnode);
2238 st->lnode_count++;
2250 i_lnode->di_node = DI_NODE(di_mem_addr(st, toff));
2253 res = mod_hash_find(st->lnode_hash, i_lnode, &nodep);
2259 res = mod_hash_insert(st->lnode_hash, i_lnode, i_lnode);
2261 st->lnode_count++;
2304 res = mod_hash_insert(st->link_hash, i_link, i_link);
2306 st->link_count++;
2312 struct di_state *st;
2336 ASSERT(data->lnode_count == data->st->lnode_count); /* lnodes done */
2337 ASSERT(data->link_count <= data->st->link_count);
2340 me = DI_LINK(di_mem_addr(data->st, i_link->self));
2358 melnode = DI_LNODE(di_mem_addr(data->st, me->src_lnode));
2365 melnode = DI_LNODE(di_mem_addr(data->st, me->tgt_lnode));
2408 ASSERT(data->lnode_count <= data->st->lnode_count);
2411 me = DI_LNODE(di_mem_addr(data->st, i_lnode->self));
2452 di_getlink_data(di_off_t off, struct di_state *st)
2459 st->lnode_hash = mod_hash_create_extended("di_lnode_hash", 32,
2463 st->link_hash = mod_hash_create_ptrhash("di_link_hash", 32,
2467 (void) ldi_usage_walker(st, di_ldi_callback);
2470 if (st->lnode_count == 0) {
2471 ASSERT(st->link_count == 0);
2475 ASSERT(st->link_count != 0);
2478 size = sizeof (struct di_lnode) * st->lnode_count;
2479 data.lnode_off = off = di_checkmem(st, off, size);
2483 size = sizeof (struct di_link) * st->link_count;
2484 data.link_off = off = di_checkmem(st, off, size);
2488 data.st = st;
2496 mod_hash_walk(st->lnode_hash, i_lnode_walker, (void *)&data);
2497 ASSERT(data.lnode_count == st->lnode_count);
2499 mod_hash_walk(st->link_hash, i_link_walker, (void *)&data);
2500 ASSERT(data.link_count == st->link_count);
2504 mod_hash_destroy_hash(st->lnode_hash);
2505 mod_hash_destroy_hash(st->link_hash);
2506 st->lnode_count = 0;
2507 st->link_count = 0;
2520 struct di_state *st)
2531 off = di_checkmem(st, *off_p, sizeof (struct di_minor));
2535 me = DI_MINOR(di_mem_addr(st, off));
2553 me->name = off = di_checkmem(st, off, size);
2554 (void) strcpy(di_mem_addr(st, off), mnode->ddm_name);
2560 me->node_type = off = di_checkmem(st, off, size);
2561 (void) strcpy(di_mem_addr(st, off),
2566 off = di_checkmem(st, off, sizeof (struct di_minor));
2583 di_register_dip(struct di_state *st, dev_info_t *dip, di_off_t off)
2600 if (mod_hash_insert(st->reg_dip_hash, (mod_hash_key_t)key,
2610 di_dip_find(struct di_state *st, dev_info_t *dip, di_off_t *off_p)
2622 ASSERT(st->reg_dip_hash);
2635 if (mod_hash_find(st->reg_dip_hash, (mod_hash_key_t)&key,
2652 di_register_pip(struct di_state *st, mdi_pathinfo_t *pip, di_off_t off)
2671 if (mod_hash_insert(st->reg_pip_hash, (mod_hash_key_t)key,
2683 di_pip_find(struct di_state *st, mdi_pathinfo_t *pip, di_off_t *off_p)
2695 ASSERT(st->reg_pip_hash);
2711 if (mod_hash_find(st->reg_pip_hash, (mod_hash_key_t)&key,
2721 path_state_convert(mdi_pathinfo_state_t st)
2723 switch (st) {
2753 struct di_state *st)
2769 off = di_checkmem(st, off, sizeof (struct di_path_prop));
2773 me = DI_PATHPROP(di_mem_addr(st, off));
2781 me->prop_name = off = di_checkmem(st, off, size);
2782 (void) strcpy(di_mem_addr(st, off), nvpair_name(prop));
2793 off = di_checkmem(st, off, size);
2795 (int32_t *)di_mem_addr(st, off));
2802 off = di_checkmem(st, off, size);
2804 (int64_t *)di_mem_addr(st, off));
2811 off = di_checkmem(st, off, size);
2812 (void) strcpy(di_mem_addr(st, off), str);
2826 off = di_checkmem(st, off, size);
2827 bcopy(buf, di_mem_addr(st, off), size);
2843 off = di_checkmem(st, off, sizeof (struct di_path_prop));
2880 struct di_state *st, int get_client)
2918 if (di_pip_find(st, pip, &stored_offset) != -1) {
2927 me = DI_PATH(di_mem_addr(st, stored_offset));
2950 *off_p = off = di_checkmem(st, off, size);
2951 me = DI_PATH(di_mem_addr(st, off));
2972 di_register_pip(st, pip, me->self);
2983 me->path_addr = off = di_checkmem(st, off, size);
2984 (void) strcpy(di_mem_addr(st, off), mdi_pi_get_addr(pip));
2991 if (DINFOPROP & st->command) {
2993 off = di_path_getprop(pip, &me->path_prop, st);
3041 di_getprop_add(int list, int dyn, struct di_state *st, struct dev_info *dip,
3121 **off_pp = off = di_checkmem(st, off, size);
3122 pp = DI_PROP(di_mem_addr(st, off));
3134 pp->prop_name = off = di_checkmem(st, off, size);
3135 (void) strcpy(di_mem_addr(st, off), name);
3146 pp->prop_data = off = di_checkmem(st, off, size);
3147 bcopy(val, di_mem_addr(st, off), size);
3169 struct di_state *st, struct dev_info *dip)
3185 ASSERT(st != NULL);
3232 off = di_getprop_add(list, 0, st, dip, prop_op, pl->pl_name,
3260 off = di_getprop_add(list, 1, st, dip, prop_op,
3266 off = di_getprop_add(list, 1, st, dip, prop_op,
3281 off = di_getprop_add(list, 1, st, dip, prop_op,
3287 off = di_getprop_add(list, 1, st, dip, prop_op,
3306 di_match_drv_name(struct dev_info *node, struct di_state *st, int match)
3339 all = DI_ALL_PTR(st);
3342 form = DI_PRIV_FORMAT(di_mem_addr(st, all->ppdata_format));
3345 form = DI_PRIV_FORMAT(di_mem_addr(st, all->dpdata_format));
3379 void *data, di_off_t *off_p, struct di_state *st)
3394 off = di_checkmem(st, *off_p, DI_MAX_PRIVDATA);
3403 bcopy(data, di_mem_addr(st, off), pdp->bytes);
3420 pa = di_mem_addr(st, off + pdp->ptr[i].offset);
3472 bcopy(ptr, di_mem_addr(st, off + off0), size);
3505 di_getppdata(struct dev_info *node, di_off_t *off_p, struct di_state *st)
3513 if ((ppdp = di_match_drv_name(node, st, DI_MATCH_PARENT)) == NULL) {
3520 ddi_get_parent_data((dev_info_t *)node), off_p, st));
3527 di_getdpdata(struct dev_info *node, di_off_t *off_p, struct di_state *st)
3535 if ((dpdp = di_match_drv_name(node, st, DI_MATCH_DRIVER)) == NULL) {
3542 ddi_get_driver_private((dev_info_t *)node), off_p, st));
3550 struct di_state *st)
3562 off = di_checkmem(st, *off_p, sizeof (struct di_hp));
3566 me = DI_HP(di_mem_addr(st, off));
3586 list_insert_tail(&st->hp_list, hp);
3593 me->hp_name = off = di_checkmem(st, off, size);
3594 (void) strcpy(di_mem_addr(st, off),
3602 me->hp_type_str = off = di_checkmem(st, off, size);
3603 (void) strcpy(di_mem_addr(st, off),
3613 off = di_checkmem(st, off, sizeof (struct di_hp));
3638 di_setstate(struct di_state *st, int new_state)
3648 if (st->di_iocstate != IOC_IDLE)
3652 if (st->di_iocstate != IOC_DONE)
3660 st->di_iocstate = new_state;
3663 st->di_iocstate, new_state);
4025 cache_args_valid(struct di_state *st, int *error)
4028 ASSERT(st->mem_size > 0);
4029 ASSERT(st->memlist != NULL);
4041 if (st->command != (DINFOCACHE & DIIOC_MASK)) {
4044 st->command));
4049 if (strcmp(DI_ALL_PTR(st)->root_path, "/") != 0) {
4052 DI_ALL_PTR(st)->root_path));
4057 CACHE_DEBUG((DI_INFO, "cache lookup args ok: 0x%x", st->command));
4065 snapshot_is_cacheable(struct di_state *st)
4067 ASSERT(st->mem_size > 0);
4068 ASSERT(st->memlist != NULL);
4070 if ((st->command & DI_CACHE_SNAPSHOT_FLAGS) !=
4074 st->command));
4078 if (strcmp(DI_ALL_PTR(st)->root_path, "/") != 0) {
4081 DI_ALL_PTR(st)->root_path));
4085 CACHE_DEBUG((DI_INFO, "cacheable snapshot request: 0x%x", st->command));
4091 di_cache_lookup(struct di_state *st)
4096 ASSERT(cache_args_valid(st, &cache_valid));
4127 di_freemem(st);
4130 if (di_cache2mem(&di_cache, st) > 0) {
4136 ASSERT(DI_ALL_PTR(st));
4137 rval = DI_ALL_PTR(st)->map_size;
4147 ASSERT(st->command == (DINFOCACHE & DIIOC_MASK));
4148 st->command = (DI_CACHE_SNAPSHOT_FLAGS & DIIOC_MASK);
4149 rval = di_cache_update(st);
4150 st->command = (DINFOCACHE & DIIOC_MASK);
4159 ASSERT(rval == 0 || strcmp(DI_ALL_PTR(st)->root_path, "/") == 0);
4172 di_cache_update(struct di_state *st)
4179 ASSERT(snapshot_is_cacheable(st));
4194 rval = di_snapshot_and_clean(st);
4201 DI_ALL_PTR(st)->map_size = rval;
4202 if (di_mem2cache(st, &di_cache) == 0) {
4258 di_hotplug_children(struct di_state *st)
4264 while (hp_list_node = (struct i_hp *)list_remove_head(&st->hp_list)) {
4267 (di_dip_find(st, hp_list_node->hp_child, &off) == 0)) {
4268 hp = DI_HP(di_mem_addr(st, hp_list_node->hp_off));
4275 list_destroy(&st->hp_list);