/*static*/ status_t
VMAddressSpace::Init()
{
	rw_lock_init(&sAddressSpaceTableLock, "address spaces table");

	// create the area and address space hash tables
	{
		new(&sAddressSpaceTable) AddressSpaceTable;
		status_t error = sAddressSpaceTable.Init(ASPACE_HASH_TABLE_SIZE);
		if (error != B_OK)
			panic("vm_init: error creating aspace hash table\n");
	}

	// create the initial kernel address space
	if (Create(B_SYSTEM_TEAM, KERNEL_BASE, KERNEL_SIZE, true,
			&sKernelAddressSpace) != B_OK) {
		panic("vm_init: error creating kernel address space!\n");
	}

	add_debugger_command("aspaces", &_DumpListCommand,
		"Dump a list of all address spaces");
	add_debugger_command("aspace", &_DumpCommand,
		"Dump info about a particular address space");

	return B_OK;
}
static status_t
socket_std_ops(int32 op, ...)
{
	switch (op) {
		case B_MODULE_INIT:
		{
			new (&sSocketList) SocketList;
			mutex_init(&sSocketLock, "socket list");

#if ENABLE_DEBUGGER_COMMANDS
			add_debugger_command("sockets", dump_sockets, "lists all sockets");
			add_debugger_command("socket", dump_socket, "dumps a socket");
#endif
			return B_OK;
		}
		case B_MODULE_UNINIT:
			ASSERT(sSocketList.IsEmpty());
			mutex_destroy(&sSocketLock);

#if ENABLE_DEBUGGER_COMMANDS
			remove_debugger_command("socket", dump_socket);
			remove_debugger_command("sockets", dump_sockets);
#endif
			return B_OK;

		default:
			return B_ERROR;
	}
}
Beispiel #3
0
void
slab_init_post_area()
{
	MemoryManager::InitPostArea();

	add_debugger_command("slabs", dump_slabs, "list all object caches");
	add_debugger_command("slab_cache", dump_cache_info,
		"dump information about a specific object cache");
	add_debugger_command("slab_depot", dump_object_depot,
		"dump contents of an object depot");
	add_debugger_command("slab_magazine", dump_depot_magazine,
		"dump contents of a depot magazine");
}
Beispiel #4
0
static status_t
tcp_init()
{
	rw_lock_init(&sEndpointManagersLock, "endpoint managers");

	status_t status = gStackModule->register_domain_protocols(AF_INET,
		SOCK_STREAM, 0,
		"network/protocols/tcp/v1",
		"network/protocols/ipv4/v1",
		NULL);
	if (status < B_OK)
		return status;
	status = gStackModule->register_domain_protocols(AF_INET6,
		SOCK_STREAM, 0,
		"network/protocols/tcp/v1",
		"network/protocols/ipv6/v1",
		NULL);
	if (status < B_OK)
		return status;

	status = gStackModule->register_domain_protocols(AF_INET, SOCK_STREAM,
		IPPROTO_TCP,
		"network/protocols/tcp/v1",
		"network/protocols/ipv4/v1",
		NULL);
	if (status < B_OK)
		return status;
	status = gStackModule->register_domain_protocols(AF_INET6, SOCK_STREAM,
		IPPROTO_TCP,
		"network/protocols/tcp/v1",
		"network/protocols/ipv6/v1",
		NULL);
	if (status < B_OK)
		return status;

	status = gStackModule->register_domain_receiving_protocol(AF_INET,
		IPPROTO_TCP, "network/protocols/tcp/v1");
	if (status < B_OK)
		return status;
	status = gStackModule->register_domain_receiving_protocol(AF_INET6,
		IPPROTO_TCP, "network/protocols/tcp/v1");
	if (status < B_OK)
		return status;

	add_debugger_command("tcp_endpoints", dump_endpoints,
		"lists all open TCP endpoints");
	add_debugger_command("tcp_endpoint", dump_endpoint,
		"dumps a TCP endpoint internal state");

	return B_OK;
}
Beispiel #5
0
// AddDebuggerCommands
void
KernelDebug::AddDebuggerCommands()
{
	if (atomic_add(&sCommandsAdded, 1) > 0)
		return;
	PRINT(("KernelDebug::AddDebuggerCommands(): adding debugger commands\n"));
	add_debugger_command("ufs", DebugUFS, "prints general info about "
		"userland FS");
	add_debugger_command("ufs_portpool", DebugPortPool,
		"ufs_portpool <port pool pointer> - prints info about a "
		"userland FS port pool");
	add_debugger_command("ufs_port", DebugPort,
		"ufs_port <port pointer> - prints info about a userland FS port");
}
Beispiel #6
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;
}
Beispiel #7
0
status_t
image_init(void)
{
	sImageTable = new(std::nothrow) ImageTable;
	if (sImageTable == NULL) {
		panic("image_init(): Failed to allocate image table!");
		return B_NO_MEMORY;
	}

	status_t error = sImageTable->Init();
	if (error != B_OK) {
		panic("image_init(): Failed to init image table: %s", strerror(error));
		return error;
	}

	new(&sNotificationService) ImageNotificationService();

	sNotificationService.Register();

#ifdef ADD_DEBUGGER_COMMANDS
	add_debugger_command("team_images", &dump_images_list, "Dump all registered images from the current team");
#endif

	return B_OK;
}
Beispiel #8
0
status_t
int_init_post_vm(kernel_args *args)
{
	int i;

	/* initialize the vector list */
	for (i = 0; i < NUM_IO_VECTORS; i++) {
		B_INITIALIZE_SPINLOCK(&sVectors[i].vector_lock);
		sVectors[i].enable_count = 0;
		sVectors[i].no_lock_vector = false;
#if DEBUG_INTERRUPTS
		sVectors[i].handled_count = 0;
		sVectors[i].unhandled_count = 0;
		sVectors[i].trigger_count = 0;
		sVectors[i].ignored_count = 0;
#endif
		sVectors[i].handler_list = NULL;
	}

#if DEBUG_INTERRUPTS
	add_debugger_command("ints", &dump_int_statistics,
		"list interrupt statistics");
#endif

	return arch_int_init_post_vm(args);
}
Beispiel #9
0
status_t
ps2_service_init(void)
{
	TRACE("ps2: ps2_service_init\n");
	sServiceCmdBuffer = create_packet_buffer(sizeof(ps2_service_cmd) * 50);
	if (sServiceCmdBuffer == NULL)
		goto err1;
	sServiceSem = create_sem(0, "ps2 service");
	if (sServiceSem < B_OK)
		goto err2;
	sServiceThread = spawn_kernel_thread(ps2_service_thread, "ps2 service", 20, NULL);
	if (sServiceThread < B_OK)
		goto err3;
	sServiceTerminate = false;
	resume_thread(sServiceThread);

#ifdef DEBUG_PUBLISHING
	add_debugger_command("ps2republish", &ps2_republish, "republish a ps2 device (0-3 mouse, 4 keyb (default))");
#endif

	TRACE("ps2: ps2_service_init done\n");
	return B_OK;

err3:
	delete_sem(sServiceSem);
err2:
	delete_packet_buffer(sServiceCmdBuffer);
err1:
	TRACE("ps2: ps2_service_init failed\n");
	return B_ERROR;
}
Beispiel #10
0
status_t
system_info_init(struct kernel_args *args)
{
	add_debugger_command("info", &dump_info, "System info");

	return arch_system_info_init(args);
}
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;
}
Beispiel #12
0
status_t
int_init_post_vm(kernel_args* args)
{
    int i;

    /* initialize the vector list */
    for (i = 0; i < NUM_IO_VECTORS; i++) {
        B_INITIALIZE_SPINLOCK(&sVectors[i].vector_lock);
        sVectors[i].enable_count = 0;
        sVectors[i].no_lock_vector = false;
        sVectors[i].type = INTERRUPT_TYPE_UNKNOWN;

        B_INITIALIZE_SPINLOCK(&sVectors[i].load_lock);
        sVectors[i].last_measure_time = 0;
        sVectors[i].last_measure_active = 0;
        sVectors[i].load = 0;

#if DEBUG_INTERRUPTS
        sVectors[i].handled_count = 0;
        sVectors[i].unhandled_count = 0;
        sVectors[i].trigger_count = 0;
        sVectors[i].ignored_count = 0;
#endif
        sVectors[i].handler_list = NULL;

        sVectorCPUAssignments[i].irq = i;
        sVectorCPUAssignments[i].count = 1;
        sVectorCPUAssignments[i].handlers_count = 0;
        sVectorCPUAssignments[i].load = 0;
        sVectorCPUAssignments[i].cpu = -1;
    }

#if DEBUG_INTERRUPTS
    add_debugger_command("ints", &dump_int_statistics,
                         "list interrupt statistics");
#endif

    add_debugger_command("int_load", &dump_int_load,
                         "list interrupt usage statistics");

    return arch_int_init_post_vm(args);
}
status_t
rtc_init(kernel_args *args)
{
	sRealTimeData = (struct real_time_data*)allocate_commpage_entry(
		COMMPAGE_ENTRY_REAL_TIME_DATA, sizeof(struct real_time_data));

	arch_rtc_init(args, sRealTimeData);
	rtc_hw_to_system();

	add_debugger_command("rtc", &rtc_debug, "Set and test the real-time clock");
	return B_OK;
}
Beispiel #14
0
status_t
init_interfaces()
{
	recursive_lock_init(&sLock, "net interfaces");
	mutex_init(&sHashLock, "net local addresses");

	new (&sInterfaces) InterfaceList;
	new (&sAddressTable) AddressTable;
		// static C++ objects are not initialized in the module startup

#if ENABLE_DEBUGGER_COMMANDS
	add_debugger_command("net_interface", &dump_interface,
		"Dump the given network interface");
	add_debugger_command("net_interfaces", &dump_interfaces,
		"Dump all network interfaces");
	add_debugger_command("net_local", &dump_local,
		"Dump all local interface addresses");
	add_debugger_command("net_route", &dump_route,
		"Dump the given network route");
#endif
	return B_OK;
}
Beispiel #15
0
status_t
init_domains()
{
	mutex_init(&sDomainLock, "net domains");

	new (&sDomains) DomainList;
		// static C++ objects are not initialized in the module startup

#if ENABLE_DEBUGGER_COMMANDS
	add_debugger_command("net_domains", &dump_domains,
		"Dump network domains");
#endif
	return B_OK;
}
status_t
low_resource_manager_init_post_thread(void)
{
	sLowResourceWaitSem = create_sem(0, "low resource wait");
	if (sLowResourceWaitSem < B_OK)
		return sLowResourceWaitSem;

	thread_id thread = spawn_kernel_thread(&low_resource_manager,
		"low resource manager", B_LOW_PRIORITY, NULL);
	send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);

	add_debugger_command("low_resource", &dump_handlers,
		"Dump list of low resource handlers");
	return B_OK;
}
Beispiel #17
0
status_t
blue_screen_init(void)
{
	extern console_module_info gFrameBufferConsoleModule;

	// we can't use get_module() here, since it's too early in the boot process

	if (!frame_buffer_console_available())
		return B_ERROR;

	sModule = &gFrameBufferConsoleModule;
	sScreen.paging = true;
	sScreen.paging_timeout = false;

	add_debugger_command("paging", set_paging, "Enable or disable paging");
	return B_OK;
}
Beispiel #18
0
static status_t
device_open(const char *name, uint32 /*flags*/, void **_cookie)
{
	TRACE((DEVICE_NAME ": open(name = %s)\n", name));
	int32 id;

	// find accessed device
	{
		char *thisName;

		// search for device name
		for (id = 0; (thisName = gDeviceNames[id]) != NULL; id++) {
			if (!strcmp(name, thisName))
				break;
		}
		if (!thisName)
			return B_BAD_VALUE;
	}

	intel_info *info = gDeviceInfo[id];

	mutex_lock(&gLock);

	if (info->open_count == 0) {
		// this device has been opened for the first time, so
		// we allocate needed resources and initialize the structure
		info->init_status = intel_extreme_init(*info);
		if (info->init_status == B_OK) {
#ifdef DEBUG_COMMANDS
			add_debugger_command("ie_reg", getset_register,
				"dumps or sets the specified intel_extreme register");
#endif

			info->open_count++;
		}
	}

	mutex_unlock(&gLock);

	if (info->init_status == B_OK)
		*_cookie = info;

	return info->init_status;
}
Beispiel #19
0
status_t
blue_screen_init(void)
{
	extern console_module_info gFrameBufferConsoleModule;

	// we can't use get_module() here, since it's too early in the boot process

	if (!frame_buffer_console_available())
		return B_ERROR;

	sModule = &gFrameBufferConsoleModule;
#ifdef _BOOT_MODE
	sScreen.paging = false;
#else
	sScreen.paging = !get_safemode_boolean(
		"disable_onscreen_paging", false);
	sScreen.paging_timeout = false;

	add_debugger_command("paging", set_paging, "Enable or disable paging");
#endif
	return B_OK;
}
Beispiel #20
0
status_t init_driver(void) {
    /* get a handle for the pci bus */
    if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK)
        return B_ERROR;

    /* driver private data */
    pd = (DeviceData *)calloc(1, sizeof(DeviceData));
    if (!pd) {
        put_module(B_PCI_MODULE_NAME);
        return B_ERROR;
    }
    /* initialize the benaphore */
    INIT_BEN(pd->kernel);

    /* find all of our supported devices */
    et6000ProbeDevices();

#if DEBUG > 0
    add_debugger_command("et6000dump", et6000dump, "dump ET6000 kernel driver persistant data");
#endif

    return B_OK;
}
Beispiel #21
0
// called each time the driver is loaded by the kernel
status_t
init_driver(void)
{
	CALLED();
	int j;

	if (get_module(BT_CORE_DATA_MODULE_NAME,
		(module_info**)&btCoreData) != B_OK) {
		ERROR("%s: cannot get module '%s'\n", __func__,
			BT_CORE_DATA_MODULE_NAME);
		return B_ERROR;
	}

	// BT devices MODULE INITS
	if (get_module(btDevices_name, (module_info**)&btDevices) != B_OK) {
		ERROR("%s: cannot get module '%s'\n", __func__, btDevices_name);
		goto err_release3;
	}

	// HCI MODULE INITS
	if (get_module(hci_name, (module_info**)&hci) != B_OK) {
		ERROR("%s: cannot get module '%s'\n", __func__, hci_name);
#ifndef BT_SURVIVE_WITHOUT_HCI
		goto err_release2;
#endif
	}

	// USB MODULE INITS
	if (get_module(usb_name, (module_info**)&usb) != B_OK) {
		ERROR("%s: cannot get module '%s'\n", __func__, usb_name);
		goto err_release1;
	}

	if (get_module(NET_BUFFER_MODULE_NAME, (module_info**)&nb) != B_OK) {
		ERROR("%s: cannot get module '%s'\n", __func__,
			NET_BUFFER_MODULE_NAME);
#ifndef BT_SURVIVE_WITHOUT_NET_BUFFERS
		goto err_release;
#endif
	}

	// GENERAL INITS
	dev_table_sem = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "dev_table_lock");
	if (dev_table_sem < 0) {
		goto err;
	}

	for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) {
		bt_usb_devices[j] = NULL;
	}

	// Note: After here device_added and publish devices hooks are called
	usb->register_driver(BLUETOOTH_DEVICE_DEVFS_NAME, supported_devices, 1, NULL);
	usb->install_notify(BLUETOOTH_DEVICE_DEVFS_NAME, &notify_hooks);

	add_debugger_command("bth2generic", &dump_driver,
		"Lists H2 Transport device info");

	return B_OK;

err:	// Releasing
	put_module(NET_BUFFER_MODULE_NAME);
err_release:
	put_module(usb_name);
err_release1:
	put_module(hci_name);
#ifndef BT_SURVIVE_WITHOUT_HCI
err_release2:
#endif
	put_module(btDevices_name);
err_release3:
	put_module(BT_CORE_DATA_MODULE_NAME);

	return B_ERROR;
}
Beispiel #22
0
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;
}