pciio_info_t pciio_info_get(devfs_handle_t pciio) { pciio_info_t pciio_info; pciio_info = (pciio_info_t) hwgraph_fastinfo_get(pciio); #ifdef DEBUG_PCIIO { int pos; char dname[256]; pos = devfs_generate_path(pciio, dname, 256); printk("%s : path= %s\n", __FUNCTION__, &dname[pos]); } #endif /* DEBUG_PCIIO */ #ifdef BRINGUP if ((pciio_info != NULL) && (pciio_info->c_fingerprint != pciio_info_fingerprint) && (pciio_info->c_fingerprint != NULL)) { #else if ((pciio_info != NULL) && (pciio_info->c_fingerprint != pciio_info_fingerprint)) { #endif /* BRINGUP */ return((pciio_info_t)-1); /* Should panic .. */ } return pciio_info; } void pciio_info_set(devfs_handle_t pciio, pciio_info_t pciio_info) { if (pciio_info != NULL) pciio_info->c_fingerprint = pciio_info_fingerprint; hwgraph_fastinfo_set(pciio, (arbitrary_info_t) pciio_info); /* Also, mark this vertex as a PCI slot * and use the pciio_info, so pciio_info_chk * can work (and be fairly efficient). */ hwgraph_info_add_LBL(pciio, INFO_LBL_PCIIO, (arbitrary_info_t) pciio_info); } devfs_handle_t pciio_info_dev_get(pciio_info_t pciio_info) { return (pciio_info->c_vertex); } /*ARGSUSED*/ pciio_bus_t pciio_info_bus_get(pciio_info_t pciio_info) { /* XXX for now O2 always gets back bus 0 */ return (pciio_bus_t)0; } pciio_slot_t pciio_info_slot_get(pciio_info_t pciio_info) { return (pciio_info->c_slot); } pciio_function_t pciio_info_function_get(pciio_info_t pciio_info) { return (pciio_info->c_func); } pciio_vendor_id_t pciio_info_vendor_id_get(pciio_info_t pciio_info) { return (pciio_info->c_vendor); } pciio_device_id_t pciio_info_device_id_get(pciio_info_t pciio_info) { return (pciio_info->c_device); } devfs_handle_t pciio_info_master_get(pciio_info_t pciio_info) { return (pciio_info->c_master); } arbitrary_info_t pciio_info_mfast_get(pciio_info_t pciio_info) { return (pciio_info->c_mfast); } pciio_provider_t * pciio_info_pops_get(pciio_info_t pciio_info) { return (pciio_info->c_pops); } error_handler_f * pciio_info_efunc_get(pciio_info_t pciio_info) { return (pciio_info->c_efunc); } error_handler_arg_t * pciio_info_einfo_get(pciio_info_t pciio_info) { return (pciio_info->c_einfo); } pciio_space_t pciio_info_bar_space_get(pciio_info_t info, int win) { return info->c_window[win].w_space; } iopaddr_t pciio_info_bar_base_get(pciio_info_t info, int win) { return info->c_window[win].w_base; } size_t pciio_info_bar_size_get(pciio_info_t info, int win) { return info->c_window[win].w_size; } iopaddr_t pciio_info_rom_base_get(pciio_info_t info) { return info->c_rbase; } size_t pciio_info_rom_size_get(pciio_info_t info) { return info->c_rsize; } /* ===================================================================== * GENERIC PCI INITIALIZATION FUNCTIONS */ /* * pciioinit: called once during device driver * initializtion if this driver is configured into * the system. */ void pciio_init(void) { cdl_p cp; #if DEBUG && ATTACH_DEBUG printf("pciio_init\n"); #endif /* Allocate the registry. * We might already have one. * If we don't, go get one. * MPness: someone might have * set one up for us while we * were not looking; use an atomic * compare-and-swap to commit to * using the new registry if and * only if nobody else did first. * If someone did get there first, * toss the one we allocated back * into the pool. */ if (pciio_registry == NULL) { cp = cdl_new(EDGE_LBL_PCI, "vendor", "device"); if (!compare_and_swap_ptr((void **) &pciio_registry, NULL, (void *) cp)) { cdl_del(cp); } } ASSERT(pciio_registry != NULL); }
int main(int argc, char *argv[]) { struct dlist *node, list, *trav; struct list list2; cat_time_t ct; int arr1[] = { 10, 15, 5, 7, 12, 2, 7 }, arr2[] = { 9, 1, 6, 10, 6 }, s1 = sizeof(arr1) / sizeof(arr1[0]), s2 = sizeof(arr2) / sizeof(arr1[0]), i, j = 0; printf("Initial: "); for ( i = 0 ; i < s1 ; ++i ) printf("%u/%u ", ++j, arr1[i]); printf(" | "); for ( i = 0 ; i < s2 ; ++i ) printf("%u/%u ", ++j, arr2[i]); printf("\n"); j=0; dl_init(&list, tm_zero); for ( i = 0 ; i < s1 ; ++i ) { ++j; node = cdl_new(tm_lset(arr1[i], 0), int2ptr(j)); dl_ins(&list, node); } dl_first(&list, &ct); printf("The first is at %u\n", (uint)tm_sec(ct)); node = dl_deq(&list); printf("The first was %u at %u\n\n", (uint)ptr2uint(cdl_data(node)), (uint)tm_sec(node->ttl)); cdl_free(node); printf("Nodes from advance 10: "); l_init(&list2); dl_adv(&list, tm_lset(10, 0), &list2); while ( ! l_isempty(&list2) ) { trav = container(l_head(&list2), struct dlist, entry); printf("%u/%u ", (uint)ptr2uint(cdl_data(trav)), (uint)tm_sec(trav->ttl)); l_rem(&trav->entry); cdl_free(trav); } printf("\n\n"); for ( i = 0 ; i < s2 ; ++i ) { ++j; node = cdl_new(tm_lset(arr2[i], 0), int2ptr(j)); dl_ins(&list, node); } printf("After inserting arr2 array is :\n\t"); while ( node = dl_deq(&list) ) { printf("%u/", (uint)ptr2uint(cdl_data(node))); printf("%u ", (uint)tm_sec(node->ttl)); cdl_free(node); } printf("\n"); return 0; }