static status_t std_ops(int32 op, ...) { switch(op) { case B_MODULE_INIT: #if DEBUG_SAFETY set_dprintf_enabled(true); #endif load_driver_symbols("53c8xx"); if (get_module(pci_name, (module_info **) &pci) != B_OK) return B_ERROR; if (get_module(cam_name, (module_info **) &cam) != B_OK) { put_module(pci_name); return B_ERROR; } if(sim_install_symbios()){ return B_OK; } put_module(pci_name); put_module(cam_name); return B_ERROR; case B_MODULE_UNINIT: put_module(pci_name); put_module(cam_name); return B_OK; default: return B_ERROR; } }
status_t init_driver(void) { DPRINTF_INFO("init_driver(), built %s %s\n", __DATE__, __TIME__); #if DEBUG_DRIVER if (load_driver_symbols(drivername) == B_OK) { DPRINTF_INFO("loaded symbols\n"); } else { DPRINTF_INFO("no symbols for you!\n"); } #endif if (get_module(B_USB_MODULE_NAME, (module_info**) &usb) != B_OK) { DPRINTF_INFO("cannot get module \"%s\"\n", B_USB_MODULE_NAME); return B_ERROR; } if ((gDeviceListLock = create_sem(1, "dev_list_lock")) < 0) { put_module(B_USB_MODULE_NAME); return gDeviceListLock; } usb->register_driver(kDriverName, supported_devices, sizeof(supported_devices)/sizeof(usb_support_descriptor), NULL); usb->install_notify(kDriverName, ¬ify_hooks); return B_OK; }
status_t init_driver(void) { struct pci_info *item; int index; int cards; #if defined(DEBUG) && !defined(__HAIKU__) set_dprintf_enabled(true); load_driver_symbols("cx23882"); #endif dprintf(INFO); item = (pci_info *)malloc(sizeof(pci_info)); if (!item) return B_NO_MEMORY; if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK) { free(item); return B_ERROR; } for (cards = 0, index = 0; gPci->get_nth_pci_info(index++, item) == B_OK; ) { const char *info = identify_device(sCardTable, item); if (info) { char name[64]; sprintf(name, "dvb/cx23882/%d", cards + 1); dprintf("cx23882: /dev/%s is a %s\n", name, info); sDevList[cards] = item; sDevNameList[cards] = strdup(name); sDevNameList[cards + 1] = NULL; cards++; item = (pci_info *)malloc(sizeof(pci_info)); if (!item) goto err_outofmem; if (cards == MAX_CARDS) break; } } free(item); if (!cards) goto err_cards; return B_OK; err_outofmem: TRACE("cx23882: err_outofmem\n"); for (index = 0; index < cards; index++) { free(sDevList[index]); free(sDevNameList[index]); } err_cards: put_module(B_PCI_MODULE_NAME); return B_ERROR; }
status_t init_driver() { status_t err; client_handle_t handle; uint32 i; #if DEBUG && !defined(__ANTARES__) load_driver_symbols("ds"); #endif if ((err = get_module(CS_CLIENT_MODULE_NAME, (module_info **)&gPcmciaCs))!=B_OK) return err; if ((err = get_module(DS_MODULE_NAME, (module_info **)&gPcmciaDs))!=B_OK) { put_module(CS_CLIENT_MODULE_NAME); return err; } devices_count = 0; while (get_handle(devices_count, &handle)==B_OK) { devices_count++; } if (devices_count <= 0) { put_module(CS_CLIENT_MODULE_NAME); put_module(DS_MODULE_NAME); return ENODEV; } devices = malloc(sizeof(char *) * (devices_count+1)); if (!devices) { put_module(CS_CLIENT_MODULE_NAME); put_module(DS_MODULE_NAME); return ENOMEM; } for (i=0; i<devices_count; i++) { devices[i] = strdup(sockname); sprintf(devices[i], sockname, i); } devices[devices_count] = NULL; return B_OK; }
static status_t wb840_open(const char *name, uint32 flags, void** cookie) { char *deviceName = NULL; int32 i; int32 mask; struct wb_device *data; status_t status; LOG((DEVICE_NAME ": open()\n")); for (i = 0; (deviceName = gDevNameList[i]) != NULL; i++) { if (!strcmp(name, deviceName)) break; } if (deviceName == NULL) { LOG(("invalid device name")); return EINVAL; } // There can be only one access at time mask = 1L << i; if (atomic_or(&sOpenMask, mask) & mask) return B_BUSY; // Allocate a wb_device structure if (!(data = (wb_device *)malloc(sizeof(wb_device)))) { sOpenMask &= ~(1L << i); return B_NO_MEMORY; } memset(data, 0, sizeof(wb_device)); *cookie = data; #ifdef DEBUG load_driver_symbols("wb840"); #endif data->devId = i; data->pciInfo = gDevList[i]; data->deviceName = gDevNameList[i]; data->blockFlag = 0; data->reg_base = data->pciInfo->u.h0.base_registers[0]; data->wb_cachesize = gPci->read_pci_config(data->pciInfo->bus, data->pciInfo->device, data->pciInfo->function, PCI_line_size, sizeof (PCI_line_size)) & 0xff; wb_read_eeprom(data, &data->MAC_Address, 0, 3, false); status = wb_create_semaphores(data); if (status < B_OK) { LOG((DEVICE_NAME ": Couldn't create semaphores\n")); goto err; } status = wb_stop(data); if (status < B_OK) { LOG((DEVICE_NAME": Can't stop device\n")); goto err1; } status = wb_initPHYs(data); if (status < B_OK) { LOG((DEVICE_NAME": Can't init PHYs\n")); goto err1; } wb_init(data); /* Setup interrupts */ data->irq = data->pciInfo->u.h0.interrupt_line; status = install_io_interrupt_handler(data->irq, wb_interrupt, data, 0); if (status < B_OK) { LOG((DEVICE_NAME " can't install interrupt handler: %s\n", strerror(status))); goto err1; } LOG(("Interrupts installed at irq line %x\n", data->irq)); status = wb_create_rings(data); if (status < B_OK) { LOG((DEVICE_NAME": can't create ring buffers\n")); goto err2; } wb_enable_interrupts(data); WB_SETBIT(data->reg_base + WB_NETCFG, WB_NETCFG_RX_ON); write32(data->reg_base + WB_RXSTART, 0xFFFFFFFF); WB_SETBIT(data->reg_base + WB_NETCFG, WB_NETCFG_TX_ON); add_timer(&data->timer, wb_tick, 1000000LL, B_PERIODIC_TIMER); return B_OK; // Everything after this line is an error err2: remove_io_interrupt_handler(data->irq, wb_interrupt, data); err1: wb_delete_semaphores(data); err: sOpenMask &= ~(1L << i); free(data); LOG(("wb840: Open Failed\n")); return status; }
status_t init_driver(void) { struct pci_info *item; int index; int cards; #ifdef DEBUG set_dprintf_enabled(true); load_driver_symbols("ipro1000"); #endif dprintf("ipro1000: " INFO "\n"); item = (pci_info *)malloc(sizeof(pci_info)); if (!item) return B_NO_MEMORY; if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK) { free(item); return B_ERROR; } for (cards = 0, index = 0; gPci->get_nth_pci_info(index++, item) == B_OK; ) { const char *info = identify_device(item); if (info) { char name[64]; sprintf(name, "net/ipro1000/%d", cards); dprintf("ipro1000: /dev/%s is a %s\n", name, info); gDevList[cards] = item; gDevNameList[cards] = strdup(name); gDevNameList[cards + 1] = NULL; cards++; item = (pci_info *)malloc(sizeof(pci_info)); if (!item) goto err_outofmem; if (cards == MAX_CARDS) break; } } free(item); if (!cards) goto err_cards; if (initialize_timer() != B_OK) { ERROROUT("timer init failed"); goto err_timer; } if (mempool_init(cards * 768) != B_OK) { ERROROUT("mempool init failed"); goto err_mempool; } return B_OK; err_mempool: terminate_timer(); err_timer: err_cards: err_outofmem: for (index = 0; index < cards; index++) { free(gDevList[index]); free(gDevNameList[index]); } put_module(B_PCI_MODULE_NAME); return B_ERROR; }
static int32 bus_std_ops(int32 op, ...) { switch (op) { case B_MODULE_INIT: { TRACE_MODULE("init\n"); if (gUSBStack) return B_OK; #ifdef HAIKU_TARGET_PLATFORM_BEOS // This code is to handle plain R5 (non-BONE) where the same module // gets loaded multiple times (once for each exported module // interface, the USB v2 and v3 API in our case). We don't want to // ever create multiple stacks however, so we "share" the same stack // for both modules by storing it's address in a shared area. void *address = NULL; area_id shared = find_area("shared usb stack"); if (shared >= B_OK && clone_area("usb stack clone", &address, B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA, shared) >= B_OK) { gUSBStack = *((Stack **)address); TRACE_MODULE("found shared stack at %p\n", gUSBStack); return B_OK; } #endif #ifdef TRACE_USB set_dprintf_enabled(true); #ifndef HAIKU_TARGET_PLATFORM_HAIKU load_driver_symbols("usb"); #endif #endif Stack *stack = new(std::nothrow) Stack(); TRACE_MODULE("usb_module: stack created %p\n", stack); if (!stack) return B_NO_MEMORY; if (stack->InitCheck() != B_OK) { delete stack; return ENODEV; } gUSBStack = stack; #ifdef HAIKU_TARGET_PLATFORM_HAIKU add_debugger_command("get_usb_pipe_for_id", &debug_get_pipe_for_id, "Gets the config for a USB pipe"); #elif HAIKU_TARGET_PLATFORM_BEOS // Plain R5 workaround, see comment above. shared = create_area("shared usb stack", &address, B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE, B_NO_LOCK, B_KERNEL_WRITE_AREA); if (shared >= B_OK) *((Stack **)address) = gUSBStack; #endif break; } case B_MODULE_UNINIT: TRACE_MODULE("uninit\n"); delete gUSBStack; gUSBStack = NULL; #ifdef HAIKU_TARGET_PLATFORM_HAIKU remove_debugger_command("get_usb_pipe_for_id", &debug_get_pipe_for_id); #endif break; default: return EINVAL; } return B_OK; }
status_t OHCI::AddTo(Stack *stack) { #ifdef TRACE_USB set_dprintf_enabled(true); #ifndef ANTARES_TARGET_PLATFORM_ANTARES load_driver_symbols("ohci"); #endif #endif if (!sPCIModule) { status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule); if (status < B_OK) { TRACE_MODULE_ERROR("getting pci module failed! 0x%08lx\n", status); return status; } } TRACE_MODULE("searching devices\n"); bool found = false; pci_info *item = new(std::nothrow) pci_info; if (!item) { sPCIModule = NULL; put_module(B_PCI_MODULE_NAME); return B_NO_MEMORY; } for (uint32 i = 0 ; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) { if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb && item->class_api == PCI_usb_ohci) { if (item->u.h0.interrupt_line == 0 || item->u.h0.interrupt_line == 0xFF) { TRACE_MODULE_ERROR("found device with invalid IRQ -" " check IRQ assignement\n"); continue; } TRACE_MODULE("found device at IRQ %u\n", item->u.h0.interrupt_line); OHCI *bus = new(std::nothrow) OHCI(item, stack); if (!bus) { delete item; sPCIModule = NULL; put_module(B_PCI_MODULE_NAME); return B_NO_MEMORY; } if (bus->InitCheck() < B_OK) { TRACE_MODULE_ERROR("bus failed init check\n"); delete bus; continue; } // the bus took it away item = new(std::nothrow) pci_info; bus->Start(); stack->AddBusManager(bus); found = true; } } if (!found) { TRACE_MODULE_ERROR("no devices found\n"); delete item; sPCIModule = NULL; put_module(B_PCI_MODULE_NAME); return ENODEV; } delete item; return B_OK; }