Example #1
0
static status_t
find_graphics_card(addr_t frameBuffer, addr_t& base, size_t& size)
{
	// TODO: when we port this over to the new driver API, this mechanism can be
	// used to find the right device_node
	pci_module_info* pci;
	if (get_module(B_PCI_MODULE_NAME, (module_info**)&pci) != B_OK)
		return B_ERROR;

	pci_info info;
	for (int32 index = 0; pci->get_nth_pci_info(index, &info) == B_OK; index++) {
		if (info.class_base != PCI_display)
			continue;

		// check PCI BARs
		for (uint32 i = 0; i < 6; i++) {
			if (info.u.h0.base_registers[i] <= frameBuffer
				&& info.u.h0.base_registers[i] + info.u.h0.base_register_sizes[i]
					> frameBuffer) {
				// found it!
				base = info.u.h0.base_registers[i];
				size = info.u.h0.base_register_sizes[i];

				put_module(B_PCI_MODULE_NAME);
				return B_OK;
			}
		}
	}

	put_module(B_PCI_MODULE_NAME);
	return B_ENTRY_NOT_FOUND;
}
Example #2
0
status_t
init_driver(void)
{
	SHOW_FLOW0(3, "");

	if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK)
		return B_ERROR;

	/* get a handle for the agp bus if it exists */
	get_module(B_AGP_GART_MODULE_NAME, (module_info **)&sAGP);

	/* driver private data */
	devices = (radeon_devices *)calloc(1, sizeof(radeon_devices));
	if (devices == NULL) {
		put_module(B_PCI_MODULE_NAME);
		if (sAGP != NULL)
			put_module(B_AGP_GART_MODULE_NAME);
		return B_ERROR;
	}

	(void)INIT_BEN(devices->kernel, "Radeon Kernel");

	GetDriverSettings();
	Radeon_ProbeDevices();
	return B_OK;
}
Example #3
0
static status_t std_ops(int32 op, ...)
{
    switch(op) {
    case B_MODULE_INIT:
        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_buslogic()) {
            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;
    }
}
Example #4
0
// called just before the kernel unloads the driver
void
uninit_driver(void)
{
	CALLED();

	int32 j;

	for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) {

		if (publish_names[j] != NULL)
			free(publish_names[j]);

		if (bt_usb_devices[j] != NULL) {
			//	if (connected_dev != NULL) {
			//		debugf("Device %p still exists.\n",	connected_dev);
			//	}
			ERROR("%s: %s still present?\n", __func__, bt_usb_devices[j]->name);
			kill_device(bt_usb_devices[j]);
		}
	}

	usb->uninstall_notify(BLUETOOTH_DEVICE_DEVFS_NAME);

	remove_debugger_command("bth2generic", &dump_driver);

	// Releasing modules
	put_module(usb_name);
	put_module(hci_name);
	// TODO: netbuffers

	delete_sem(dev_table_sem);
}
Example #5
0
status_t
device_node::_FindBestDriver(const char* path, driver_module_info*& bestDriver,
	float& bestSupport, device_node* previous)
{
	if (bestDriver == NULL)
		bestSupport = previous != NULL ? previous->fSupportsParent : 0.0f;

	void* list = open_module_list_etc(path, "driver_v1");
	driver_module_info* driver;
	while (_GetNextDriver(list, driver) == B_OK) {
		if (previous != NULL && driver == previous->DriverModule()) {
			put_module(driver->info.name);
			continue;
		}

		float support = driver->supports_device(this);
		if (support > bestSupport) {
			if (bestDriver != NULL)
				put_module(bestDriver->info.name);

			bestDriver = driver;
			bestSupport = support;
			continue;
				// keep reference to best module around
		}

		put_module(driver->info.name);
	}
	close_module_list(list);

	return bestDriver != NULL ? B_OK : B_ENTRY_NOT_FOUND;
}
Example #6
0
File: 53c8xx.c Project: DonCN/haiku
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;
	}
}
Example #7
0
status_t
init_driver(void)
{
	int i = 0;
	status_t err;
	num_cards = 0;

	TRACE("@@init_driver()\n");

	if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci))
		return ENOSYS;

	if (get_module(B_MPU_401_MODULE_NAME, (module_info **) &mpu401)) {
		put_module(B_PCI_MODULE_NAME);
		return ENOSYS;
	}

	while ((*pci->get_nth_pci_info)(i, &cards[num_cards].info) == B_OK) {
		//TODO check other Vendor_ID and DEVICE_ID
		if ((cards[num_cards].info.vendor_id == ICE1712_VENDOR_ID)
			&& (cards[num_cards].info.device_id == ICE1712_DEVICE_ID)) {
			if (num_cards == NUM_CARDS) {
				TRACE("Too many ice1712 cards installed!\n");
				break;
			}

			if ((err = (*pci->reserve_device)(cards[num_cards].info.bus,
				cards[num_cards].info.device, cards[num_cards].info.function,
				DRIVER_NAME, &cards[num_cards])) < B_OK) {
				dprintf("%s: failed to reserve_device(%d, %d, %d,): %s\n",
					DRIVER_NAME, cards[num_cards].info.bus,
					cards[num_cards].info.device,
					cards[num_cards].info.function, strerror(err));
				continue;
			}
			if (ice1712_setup(&cards[num_cards]) != B_OK) {
			//Vendor_ID and Device_ID has been modified
				TRACE("Setup of ice1712 %d failed\n", (int)(num_cards + 1));
				(*pci->unreserve_device)(cards[num_cards].info.bus,
					cards[num_cards].info.device,
					cards[num_cards].info.function,
					DRIVER_NAME, &cards[num_cards]);
			} else {
				num_cards++;
			}
		}
		i++;
	}

	TRACE("Number of succesfully initialised card : %d\n", (int)num_cards);

	if (num_cards == 0) {
		put_module(B_PCI_MODULE_NAME);
		put_module(B_MPU_401_MODULE_NAME);
		return ENODEV;
	}
	return B_OK;
}
Example #8
0
void
uninit_driver(void)
{
	/* free the driver data */
	DELETE_BEN(pd->kernel);
	free(pd);
	pd = NULL;

	/* put the pci module away */
	put_module(B_PCI_MODULE_NAME);
	put_module(B_ISA_MODULE_NAME);
}
Example #9
0
void
uninit_driver(void)
{
	SHOW_FLOW0(3, "");
	DELETE_BEN(devices->kernel);

	free(devices);
	devices = NULL;

	put_module(B_PCI_MODULE_NAME);
	if (sAGP) 
		put_module(B_AGP_GART_MODULE_NAME);
}
Example #10
0
File: ds.c Project: mmanley/Antares
void
uninit_driver()
{
	int32 i = 0;
	for (i=0; i<devices_count; i++) {
		free (devices[i]);
	}
	free(devices);
	devices = NULL;

	put_module(DS_MODULE_NAME);
	put_module(CS_CLIENT_MODULE_NAME);
}
Example #11
0
void uninit_driver(void) {

	/* free the driver data */
	DELETE_BEN(pd->kernel);
	free(pd);
	pd = NULL;

	/* put the pci module away */
	put_module(B_PCI_MODULE_NAME);
	put_module(B_ISA_MODULE_NAME);

	/* put the agp module away if it's there */
	if (agp_bus) put_module(B_AGP_MODULE_NAME);
}
Example #12
0
File: driver.c Project: DonCN/haiku
status_t
init_driver(void)
{
	status_t ret = ENODEV;
	int i;

	TRACE("init_driver\n");

	if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPciBus) != B_OK) {
		ret = B_ERROR;
		goto done;
	}

	if (!(gPd = calloc(1, sizeof(DeviceData)))) {
		put_module(B_PCI_MODULE_NAME);
		ret = B_ERROR;
		goto done;
	}

	/* Remember the PCI information */
	for (i = 0; (*gPciBus->get_nth_pci_info)(i, &gPd->pcii) == B_OK; i++) 
		if (gPd->pcii.vendor_id == PCI_VENDOR_ID_VMWARE &&
			gPd->pcii.device_id == PCI_DEVICE_ID_VMWARE_SVGA2) {
			ret = B_OK;
			break;
		}

	if (ret != B_OK) {
		free(gPd);
		put_module(B_PCI_MODULE_NAME);
		goto done;
	}

	/* Create a benaphore for exclusive access in OpenHook/FreeHook */
	INIT_BEN(gPd->kernel);

	/* The device name */
	gPd->names[0] = strdup("graphics/vmware");
	gPd->names[1] = NULL;

	/* Usual initializations */
	gPd->isOpen = 0;
	gPd->sharedArea = -1;
	gPd->si = NULL;

done:
	TRACE("init_driver: %ld\n", ret);
	return ret;
}
Example #13
0
status_t
init_hardware(void)
{
	long index = 0;
	pci_info pcii;
	bool found = false;

	/* choke if we can't find the PCI bus */
	if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK)
		return B_ERROR;

	/* choke if we can't find the ISA bus */
	if (get_module(B_ISA_MODULE_NAME, (module_info **)&isa_bus) != B_OK)
	{
		put_module(B_PCI_MODULE_NAME);
		return B_ERROR;
	}

	/* while there are more pci devices */
	while ((*pci_bus->get_nth_pci_info)(index, &pcii) == B_NO_ERROR) {
		int vendor = 0;

		/* if we match a supported vendor */
		while (SupportedDevices[vendor].vendor) {
			if (SupportedDevices[vendor].vendor == pcii.vendor_id) {
				uint16 *devices = SupportedDevices[vendor].devices;
				/* while there are more supported devices */
				while (*devices) {
					/* if we match a supported device */
					if (*devices == pcii.device_id ) {

						found = true;
						goto done;
					}
					/* next supported device */
					devices++;
				}
			}
			vendor++;
		}
		/* next pci_info struct, please */
		index++;
	}

done:
	/* put away the module manager */
	put_module(B_PCI_MODULE_NAME);
	return found ? B_OK : B_ERROR;
}
Example #14
0
status_t
ethernet_init(const char *name, net_device **_device)
{
	// make sure this is a device in /dev/net, but not the
	// networking (userland) stack driver
	if (strncmp(name, "/dev/net/", 9) || !strcmp(name, "/dev/net/stack")
		|| !strcmp(name, "/dev/net/userland_server"))
		return B_BAD_VALUE;

	status_t status = get_module(NET_BUFFER_MODULE_NAME, (module_info **)&gBufferModule);
	if (status < B_OK)
		return status;

	ethernet_device *device = new (std::nothrow) ethernet_device;
	if (device == NULL) {
		put_module(NET_BUFFER_MODULE_NAME);
		return B_NO_MEMORY;
	}

	memset(device, 0, sizeof(ethernet_device));

	strcpy(device->name, name);
	device->flags = IFF_BROADCAST | IFF_LINK;
	device->type = IFT_ETHER;
	device->mtu = 1500;
	device->media = IFM_ACTIVE | IFM_ETHER;
	device->header_length = ETHER_HEADER_LENGTH;
	device->fd = -1;

	*_device = device;
	return B_OK;
}
Example #15
0
extern "C" status_t
init_driver(void)
{
	TRACE((DEVICE_NAME ": init_driver()\n"));

	gDeviceInfo[0] = (vesa_info*)malloc(sizeof(vesa_info));
	if (gDeviceInfo[0] == NULL)
		return B_NO_MEMORY;

	memset(gDeviceInfo[0], 0, sizeof(vesa_info));

	status_t status = get_module(B_ISA_MODULE_NAME, (module_info**)&gISA);
	if (status != B_OK)
		goto err1;

	gDeviceNames[0] = strdup("graphics/vesa");
	if (gDeviceNames[0] == NULL) {
		status = B_NO_MEMORY;
		goto err2;
	}

	gDeviceNames[1] = NULL;

	mutex_init(&gLock, "vesa lock");
	return B_OK;

err2:
	put_module(B_ISA_MODULE_NAME);
err1:
	free(gDeviceInfo[0]);
	return status;
}
Example #16
0
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, &notify_hooks);

	return B_OK;
}
Example #17
0
Interface::~Interface()
{
	TRACE("Interface %p: destructor\n", this);

	put_device_interface(fDeviceInterface);

	// Uninitialize the domain datalink protocols

	DatalinkTable::Iterator iterator = fDatalinkTable.GetIterator();
	while (domain_datalink* datalink = iterator.Next()) {
		put_domain_datalink_protocols(this, datalink->domain);
	}

	// Free domain datalink objects

	domain_datalink* next = fDatalinkTable.Clear(true);
	while (next != NULL) {
		domain_datalink* datalink = next;
		next = next->hash_link;

		delete datalink;
	}

	recursive_lock_destroy(&fLock);

	// Release reference of the stack - at this point, our stack may be unloaded
	// if no other interfaces or sockets are left
	put_module(gNetStackInterfaceModule.info.name);
}
Example #18
0
/*!	\brief Returns parameters for partitioning a session.

	The partitioning system (module) identified by \a identifier is asked to
	return parameters for the session. If the session is already partitioned
	using this system, then the parameters describing the current layout will
	be returned, otherwise default values.

	If the supplied buffer is too small for the parameters, the function
	returns \c B_OK, but doesn't fill in the buffer; the required buffer
	size is returned in \a actualSize. If the buffer is large enough,
	\a actualSize is set to the actually used size. The size includes the
	terminating null.

	\param deviceFD The device the session to be partitioned resides on.
	\param sessionIndex The index of the session to be partitioned.
	\param identifier A string identifying the partitioning system to be used.
	\param buffer Pointer to a pre-allocated buffer of size \a bufferSize.
	\param bufferSize The size of \a buffer.
	\param actualSize Pointer to a pre-allocated size_t to be set to the
		   actually needed buffer size.
	\return
	- \c B_OK: The parameters could be retrieved or the buffer is too
	  small. \a actualSize has to be checked!
	- another error code, if something went wrong
*/
status_t
get_partitioning_parameters(int deviceFD, int32 sessionIndex,
							const char *identifier, char *buffer,
							size_t bufferSize, size_t *actualSize)
{
	status_t error = (identifier && buffer && actualSize ? B_OK : B_BAD_VALUE);
	disk_scanner_module_info *diskScanner = NULL;
	session_info sessionInfo;
	// get the disk scanner module
	if (error == B_OK) {
		error = get_module(DISK_SCANNER_MODULE_NAME,
						   (module_info**)&diskScanner);
	}
	// get the session info
	if (error == B_OK) {
		error = diskScanner->get_nth_session_info(deviceFD, sessionIndex,
												  &sessionInfo, NULL);
	}
	// get the parameters
	if (error == B_OK) {
		error = diskScanner->get_partitioning_params(deviceFD, &sessionInfo,
			identifier, buffer, bufferSize, actualSize);
	}
	// put the partition scanner module
	if (diskScanner)
		put_module(diskScanner->module.name);
	return error;
}
Example #19
0
status_t
init_driver()
{
	TRACE("init_driver() " __DATE__ " " __TIME__ "\n");
	if (get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule) != B_OK)
		return B_ERROR;

	gDeviceList = new(std::nothrow) DeviceList();
	if (gDeviceList == NULL) {
		put_module(B_USB_MODULE_NAME);
		return B_NO_MEMORY;
	}

	mutex_init(&sDriverLock, "usb hid driver lock");

	static usb_notify_hooks notifyHooks = {
		&usb_hid_device_added,
		&usb_hid_device_removed
	};

	static usb_support_descriptor supportDescriptor = {
		USB_INTERFACE_CLASS_HID, 0, 0, 0, 0
	};

	gUSBModule->register_driver(DRIVER_NAME, &supportDescriptor, 1, NULL);
	gUSBModule->install_notify(DRIVER_NAME, &notifyHooks);
	TRACE("init_driver() OK\n");
	return B_OK;
}
Example #20
0
static status_t
std_ops(int32 op, ...)
{
	void *handle;
	bool load = false;

	switch (op) {
	case B_MODULE_INIT:
		handle = load_driver_settings("kernel");
		if (handle) {
			load = get_driver_boolean_parameter(handle,
				"bochs_debug_output", load, true);
			unload_driver_settings(handle);
		}
		if (load) {
			if (get_module(B_ISA_MODULE_NAME, (module_info **)&sISAModule) < B_OK)
				return B_ERROR;
		}
		return load ? B_OK : B_ERROR;
	case B_MODULE_UNINIT:
		put_module(B_ISA_MODULE_NAME);
		return B_OK;
	}
	return B_BAD_VALUE;
}
Example #21
0
/*!	Registers any children that are identified via the B_DEVICE_FIXED_CHILD
	attribute.
	If any of these children cannot be registered, this call will fail (we
	don't remove children we already registered up to this point in this case).
*/
status_t
device_node::_RegisterFixed(uint32& registered)
{
	AttributeList::Iterator iterator = fAttributes.GetIterator();
	registered = 0;

	while (iterator.HasNext()) {
		device_attr_private* attr = iterator.Next();
		if (strcmp(attr->name, B_DEVICE_FIXED_CHILD))
			continue;

		driver_module_info* driver;
		status_t status = get_module(attr->value.string,
			(module_info**)&driver);
		if (status != B_OK) {
			TRACE(("register fixed child %s failed: %s\n", attr->value.string,
				strerror(status)));
			return status;
		}

		if (driver->register_device != NULL) {
			status = driver->register_device(this);
			if (status == B_OK)
				registered++;
		}

		put_module(attr->value.string);

		if (status != B_OK)
			return status;
	}

	return B_OK;
}
Example #22
0
static status_t
bcd_std_ops(int32 op, ...)
{
    status_t status;

    switch (op) {
    case B_MODULE_INIT:
        new (&sConnectionList) DoublyLinkedList<HciConnection>;
        add_debugger_command("btConnections", &DumpHciConnections,
                             "Lists Bluetooth Connections with RemoteDevices & channels");

        status = get_module(NET_BUFFER_MODULE_NAME,
                            (module_info **)&gBufferModule);
        if (status < B_OK)
            return status;

        return B_OK;

        break;

    case B_MODULE_UNINIT:

        remove_debugger_command("btConnections", &DumpHciConnections);
        put_module(NET_BUFFER_MODULE_NAME);

        return B_OK;
        break;
    }

    return B_ERROR;
}
Example #23
0
static void
scan_modules(const char* path)
{
	void* cookie = open_module_list(path);
	if (cookie == NULL)
		return;

	while (true) {
		char name[B_FILE_NAME_LENGTH];
		size_t length = sizeof(name);
		if (read_next_module_name(cookie, name, &length) != B_OK)
			break;

		TRACE(("scan %s\n", name));

		module_info* module;
		if (get_module(name, &module) == B_OK) {
			// we don't need the module right now, but we give it a chance
			// to register itself
			put_module(name);
		}
	}

	close_module_list(cookie);
}
Example #24
0
OHCI::~OHCI()
{
	int32 result = 0;
	fStopFinishThread = true;
	delete_sem(fFinishTransfersSem);
	wait_for_thread(fFinishThread, &result);

	_LockEndpoints();
	mutex_destroy(&fEndpointLock);

	if (fHccaArea >= B_OK)
		delete_area(fHccaArea);
	if (fRegisterArea >= B_OK)
		delete_area(fRegisterArea);

	_FreeEndpoint(fDummyControl);
	_FreeEndpoint(fDummyBulk);
	_FreeEndpoint(fDummyIsochronous);

	if (fInterruptEndpoints != NULL) {
		for (int i = 0; i < OHCI_STATIC_ENDPOINT_COUNT; i++)
			_FreeEndpoint(fInterruptEndpoints[i]);
	}

	delete [] fInterruptEndpoints;
	delete fRootHub;

	put_module(B_PCI_MODULE_NAME);
}
Example #25
0
static status_t
free_hook (void* cookie)
{
	dp83815_properties_t *data = (dp83815_properties_t *) cookie;

	TRACE(( kDevName " free_hook()\n" ));

	while ( data->Tx.Lock );				/*	wait for any current writes to finish	*/
	while ( data->Rx.Lock );				/*	wait for any current reads to finish	*/

	//Remove interrupt handler
	remove_io_interrupt_handler( data->pcii->u.h0.interrupt_line ,
	                             dp83815_interrupt_hook , cookie );

	m_openmask &= ~(1L << data->device_id);

	free_resources(data);					/*	unblock waiting threads		*/

	//Finally, free the cookie
	free( data );

	//Put the pci module
	put_module( B_PCI_MODULE_NAME );

	return B_OK;
}
Example #26
0
bool
device_node::UninitDriver()
{
	if (fInitialized-- > 1) {
		if (Parent() != NULL)
			Parent()->UninitDriver();
		Release();
		return false;
	}

	TRACE(("uninit driver for node %p\n", this));

	if (fDriver->uninit_driver != NULL)
		fDriver->uninit_driver(fDriverData);

	fDriver = NULL;
	fDriverData = NULL;

	put_module(ModuleName());

	if (Parent() != NULL)
		Parent()->UninitDriver();
	Release();

	return true;
}
Example #27
0
status_t
init_driver(void)
{
	int i = 0, j = 0, is_detected;
	pci_info dev_info;

	//debug_fd = open("/tmp/broadcom_traffic_log",O_RDWR | B_CREATE_FILE);

	if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci) != B_OK)
		return B_ERROR;

	while (pci->get_nth_pci_info(i++, &dev_info) == 0) {
		is_detected = 0;
		if ((dev_info.class_base == PCI_network) && (dev_info.class_sub == PCI_ethernet)) {
			for (j = 0; bcm5700_pci_tbl[j].vendor != 0; j++) {
				if ((dev_info.vendor_id == bcm5700_pci_tbl[j].vendor) && (dev_info.device_id == bcm5700_pci_tbl[j].device)) {
					is_detected = 1;
					break;
				}
			}
		}

		if (!is_detected)
			continue;

		if (cards_found >= 10)
			break;

		dev_list[cards_found] = (char *)malloc(16 /* net/bcm570x/xx */);
		sprintf(dev_list[cards_found],"net/bcm570x/%d",cards_found);
		be_b57_dev_cards[cards_found].pci_data = dev_info;
		be_b57_dev_cards[cards_found].packet_release_sem = create_sem(0,dev_list[cards_found]);
		be_b57_dev_cards[cards_found].mem_list_num = 0;
		be_b57_dev_cards[cards_found].lockmem_list_num = 0;
		be_b57_dev_cards[cards_found].opened = 0;
		be_b57_dev_cards[cards_found].block = 1;
		be_b57_dev_cards[cards_found].lock = 0;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
		be_b57_dev_cards[cards_found].linkChangeSem = -1;
#endif

		if (LM_GetAdapterInfo(&be_b57_dev_cards[cards_found].lm_dev) != LM_STATUS_SUCCESS) {
			for (j = 0; j < cards_found; j++) {
				free(dev_list[j]);
				delete_sem(be_b57_dev_cards[j].packet_release_sem);
			}
			put_module(B_PCI_MODULE_NAME);
			return ENODEV;
		}

		QQ_InitQueue(&be_b57_dev_cards[cards_found].RxPacketReadQ.Container,MAX_RX_PACKET_DESC_COUNT);

		cards_found++;
	}

 	mempool_init((MAX_RX_PACKET_DESC_COUNT+MAX_TX_PACKET_DESC_COUNT) * cards_found);
 	dev_list[cards_found] = NULL;

	return B_OK;
}
Example #28
0
/*!	\brief Partitions a specified session on a device using the paritioning
		   system identified by \a identifier and according to supplied
		   parameters.
	\param deviceFD The device the session to be partitioned resides on.
	\param sessionIndex The index of the session to be partitioned.
	\param identifier A string identifying the partitioning system to be used.
	\param parameters Parameters according to which the session shall be
		   partitioned. May be \c NULL, depending on the concerned partition
		   module.
	\return \c B_OK, if everything went fine, an error code otherwise.
*/
status_t
partition_session(int deviceFD, int32 sessionIndex, const char *identifier,
				  const char *parameters)
{
	status_t error = (identifier ? B_OK : B_BAD_VALUE);
	disk_scanner_module_info *diskScanner = NULL;
	session_info sessionInfo;
	// get the disk scanner module
	if (error == B_OK) {
		error = get_module(DISK_SCANNER_MODULE_NAME,
						   (module_info**)&diskScanner);
	}
	// get the session info
	if (error == B_OK) {
		error = diskScanner->get_nth_session_info(deviceFD, sessionIndex,
												  &sessionInfo, NULL);
	}
	// partition the session
	if (error == B_OK) {
		error = diskScanner->partition(deviceFD, &sessionInfo, identifier,
									   parameters);
	}
	// put the partition scanner module
	if (diskScanner)
		put_module(diskScanner->module.name);
	return error;
}
status_t
init_driver()
{
    status_t status = get_module(B_PCI_MODULE_NAME, (module_info**)&gPCIModule);
    if (status < B_OK) {
        return ENOSYS;
    }

    load_settings();

    TRACE_ALWAYS("%s\n", kVersion);

    pci_info info = {0};
    for (long i = 0; B_OK == (*gPCIModule->get_nth_pci_info)(i, &info); i++) {
        for (size_t idx = 0; idx < _countof(cardInfos); idx++) {
            if (info.vendor_id == cardInfos[idx].VendorId()
                    && info.device_id == cardInfos[idx].DeviceId())
            {
                TRACE_ALWAYS("Found:%s %#010x\n",
                             cardInfos[idx].Description(), cardInfos[idx].Id());

                if (numCards == MAX_DEVICES) {
                    break;
                }

                Device* device = new Device(cardInfos[idx], info);
                if (device == 0) {
                    return ENODEV;
                }

                status_t status = device->InitCheck();
                if (status < B_OK) {
                    delete device;
                    break;
                }

                status = device->SetupDevice();
                if (status < B_OK) {
                    delete device;
                    break;
                }

                char name[DEVNAME_LEN] = {0};
                sprintf(name, "net/%s/%ld", cardInfos[idx].Name(), numCards);
                gDeviceNames[numCards] = strdup(name);
                gDevices[numCards++] = device;
            }
        }
    }

    if (numCards == 0) {
        put_module(B_PCI_MODULE_NAME);
        return ENODEV;
    }

    add_debugger_command(DRIVER_NAME, SiS19X_DebuggerCommand,
                         "SiS190/191 Ethernet driver info");

    return B_OK;
}
Example #30
0
status_t
device_node::_GetNextDriver(void* list, driver_module_info*& driver)
{
	while (true) {
		char name[B_FILE_NAME_LENGTH];
		size_t nameLength = sizeof(name);

		status_t status = read_next_module_name(list, name, &nameLength);
		if (status != B_OK)
			return status;

		if (!strcmp(fModuleName, name))
			continue;

		if (get_module(name, (module_info**)&driver) != B_OK)
			continue;

		if (driver->supports_device == NULL
			|| driver->register_device == NULL) {
			put_module(name);
			continue;
		}

		return B_OK;
	}
}