/* * hwgraph_mk_dir - Creates a directory entry with devfs. * Note that a directory entry in devfs can have children * but it cannot be a char|block special file. */ vertex_hdl_t hwgraph_mk_dir(vertex_hdl_t de, const char *name, unsigned int namelen, void *info) { int rv; labelcl_info_t *labelcl_info = NULL; vertex_hdl_t new_devfs_handle = NULL; vertex_hdl_t parent = NULL; /* * Create the device info structure for hwgraph compatiblity support. */ labelcl_info = labelcl_info_create(); if (!labelcl_info) return(NULL); /* * Create a devfs entry. */ new_devfs_handle = devfs_mk_dir(de, name, (void *)labelcl_info); if (!new_devfs_handle) { labelcl_info_destroy(labelcl_info); return(NULL); } /* * Get the parent handle. */ parent = devfs_get_parent (new_devfs_handle); /* * To provide the same semantics as the hwgraph, set the connect point. */ rv = hwgraph_connectpt_set(new_devfs_handle, parent); if (!rv) { /* * We need to clean up! */ } /* * If the caller provides a private data pointer, save it in the * labelcl info structure(fastinfo). This can be retrieved via * hwgraph_fastinfo_get() */ if (info) hwgraph_fastinfo_set(new_devfs_handle, (arbitrary_info_t)info); return(new_devfs_handle); }
void pciio_info_set(vertex_hdl_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); }
void xwidget_info_set(vertex_hdl_t xwidget, xwidget_info_t widget_info) { if (widget_info != NULL) widget_info->w_fingerprint = widget_info_fingerprint; hwgraph_fastinfo_set(xwidget, (arbitrary_info_t) widget_info); /* Also, mark this vertex as an xwidget, * and use the widget_info, so xwidget_info_chk * can work (and be fairly efficient). */ hwgraph_info_add_LBL(xwidget, INFO_LBL_XWIDGET, (arbitrary_info_t) widget_info); }
void __init klhwg_add_all_modules(vertex_hdl_t hwgraph_root) { cmoduleid_t cm; char name[128]; vertex_hdl_t vhdl; vertex_hdl_t module_vhdl; int rc; char buffer[16]; /* Add devices under each module */ for (cm = 0; cm < nummodules; cm++) { /* Use module as module vertex fastinfo */ memset(buffer, 0, 16); format_module_id(buffer, sn_modules[cm]->id, MODULE_FORMAT_BRIEF); sprintf(name, EDGE_LBL_MODULE "/%s", buffer); rc = hwgraph_path_add(hwgraph_root, name, &module_vhdl); ASSERT(rc == GRAPH_SUCCESS); rc = rc; HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, module_vhdl, NULL, "Created module path.\n"); hwgraph_fastinfo_set(module_vhdl, (arbitrary_info_t) sn_modules[cm]); /* Add system controller */ sprintf(name, EDGE_LBL_MODULE "/%s/" EDGE_LBL_L1, buffer); rc = hwgraph_path_add(hwgraph_root, name, &vhdl); ASSERT_ALWAYS(rc == GRAPH_SUCCESS); rc = rc; HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, vhdl, NULL, "Created L1 path.\n"); hwgraph_info_add_LBL(vhdl, INFO_LBL_ELSC, (arbitrary_info_t)1); } }
/* * hwgraph_mk_symlink - Create a symbolic link. */ int hwgraph_mk_symlink(vertex_hdl_t de, const char *name, unsigned int namelen, unsigned int flags, const char *link, unsigned int linklen, vertex_hdl_t *handle, void *info) { void *labelcl_info = NULL; int status = 0; vertex_hdl_t new_devfs_handle = NULL; /* * Create the labelcl info structure for hwgraph compatiblity support. */ labelcl_info = labelcl_info_create(); if (!labelcl_info) return(-1); /* * Create a symbolic link devfs entry. */ status = devfs_mk_symlink(de, name, flags, link, &new_devfs_handle, labelcl_info); if ( (!new_devfs_handle) || (!status) ){ labelcl_info_destroy((labelcl_info_t *)labelcl_info); return(-1); } /* * If the caller provides a private data pointer, save it in the * labelcl info structure(fastinfo). This can be retrieved via * hwgraph_fastinfo_get() */ if (info) hwgraph_fastinfo_set(new_devfs_handle, (arbitrary_info_t)info); *handle = new_devfs_handle; return(0); }
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); }
/* * Disassociate a set of xtalk_provider functions with a vertex. */ void xtalk_provider_unregister(vertex_hdl_t provider) { hwgraph_fastinfo_set(provider, (arbitrary_info_t)NULL); }
/* * Associate a set of xtalk_provider functions with a vertex. */ void xtalk_provider_register(vertex_hdl_t provider, xtalk_provider_t *xtalk_fns) { hwgraph_fastinfo_set(provider, (arbitrary_info_t) xtalk_fns); }