コード例 #1
0
ファイル: ps2_service.c プロジェクト: mmanley/Antares
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;
}
コード例 #2
0
static status_t
keyboard_open(const char *name, uint32 flags, void **_cookie)
{
	TRACE("ps2: keyboard_open %s\n", name);

	keyboard_cookie* cookie = new(std::nothrow) keyboard_cookie();
	if (cookie == NULL)
		return B_NO_MEMORY;

	cookie->is_reader = false;
	cookie->is_debugger = false;

	MutexLocker locker(sInitializeLock);

	if (atomic_get(&sKeyboardOpenCount) == 0) {
		status_t status = probe_keyboard();
		if (status != B_OK) {
			INFO("ps2: keyboard probing failed\n");
			ps2_service_notify_device_removed(&ps2_device[PS2_DEVICE_KEYB]);
			delete cookie;
			return status;
		}

		INFO("ps2: keyboard found\n");

		sKeyboardSem = create_sem(0, "keyboard_sem");
		if (sKeyboardSem < 0) {
			delete cookie;
			return sKeyboardSem;
		}

		sKeyBuffer
			= create_packet_buffer(KEY_BUFFER_SIZE * sizeof(raw_key_info));
		if (sKeyBuffer == NULL) {
			delete_sem(sKeyboardSem);
			delete cookie;
			return B_NO_MEMORY;
		}

		ps2_device[PS2_DEVICE_KEYB].disconnect = &ps2_keyboard_disconnect;
		ps2_device[PS2_DEVICE_KEYB].handle_int = &keyboard_handle_int;

		atomic_or(&ps2_device[PS2_DEVICE_KEYB].flags, PS2_FLAG_ENABLED);
	}

	atomic_add(&sKeyboardOpenCount, 1);
	*_cookie = cookie;

	TRACE("ps2: keyboard_open %s success\n", name);
	return B_OK;
}
コード例 #3
0
ファイル: ps2_keyboard.c プロジェクト: mmanley/Antares
static status_t
keyboard_open(const char *name, uint32 flags, void **_cookie)
{
	status_t status;

	TRACE("ps2: keyboard_open %s\n", name);

	if (atomic_or(&sKeyboardOpenMask, 1) != 0)
		return B_BUSY;

	status = probe_keyboard();
	if (status != B_OK) {
		INFO("ps2: keyboard probing failed\n");
		ps2_service_notify_device_removed(&ps2_device[PS2_DEVICE_KEYB]);
		goto err1;
	}

	INFO("ps2: keyboard found\n");

	sKeyboardSem = create_sem(0, "keyboard_sem");
	if (sKeyboardSem < 0) {
		status = sKeyboardSem;
		goto err1;
	}

	sKeyBuffer = create_packet_buffer(KEY_BUFFER_SIZE * sizeof(at_kbd_io));
	if (sKeyBuffer == NULL) {
		status = B_NO_MEMORY;
		goto err2;
	}

	*_cookie = NULL;
	ps2_device[PS2_DEVICE_KEYB].disconnect = &ps2_keyboard_disconnect;
	ps2_device[PS2_DEVICE_KEYB].handle_int = &keyboard_handle_int;

	atomic_or(&ps2_device[PS2_DEVICE_KEYB].flags, PS2_FLAG_ENABLED);

	TRACE("ps2: keyboard_open %s success\n", name);
	return B_OK;

err2:
	delete_sem(sKeyboardSem);
err1:
	atomic_and(&sKeyboardOpenMask, 0);

	TRACE("ps2: keyboard_open %s failed\n", name);
	return status;
}