示例#1
0
static status_t
read_keyboard_packet(at_kbd_io *packet)
{
	status_t status;

	TRACE("ps2: read_keyboard_packet: enter\n");

	status = acquire_sem_etc(sKeyboardSem, 1, B_CAN_INTERRUPT, 0);
	if (status < B_OK)
		return status;

	if (!ps2_device[PS2_DEVICE_KEYB].active) {
		TRACE("ps2: read_keyboard_packet, Error device no longer active\n");
		return B_ERROR;
	}

	if (packet_buffer_read(sKeyBuffer, (uint8 *)packet, sizeof(*packet)) == 0) {
		TRACE("ps2: read_keyboard_packet, Error reading packet: %s\n",
			strerror(status));
		return B_ERROR;
	}

	TRACE("ps2: read_keyboard_packet: scancode: %x, keydown: %s\n",
		packet->scancode, packet->is_keydown ? "true" : "false");

	return B_OK;
}
示例#2
0
static int32
ps2_service_thread(void *arg)
{
	TRACE("ps2: ps2_service_thread started\n");

	for (;;) {
		status_t status;
		status = acquire_sem_etc(sServiceSem, 1, B_CAN_INTERRUPT, 0);
		if (sServiceTerminate)
			break;
		if (status == B_OK) {

			// process service commands
			ps2_service_cmd cmd;
			packet_buffer_read(sServiceCmdBuffer, (uint8 *)&cmd, sizeof(cmd));
			switch (cmd.id) {
				case PS2_SERVICE_NOTIFY_DEVICE_ADDED:
					snooze(1000000); // for better testing of possible input server race condition
					TRACE("ps2: PS2_SERVICE_NOTIFY_DEVICE_ADDED %s\n", cmd.dev->name);
					ps2_dev_publish(cmd.dev);
					break;

				case PS2_SERVICE_NOTIFY_DEVICE_REPUBLISH:
					TRACE("ps2: PS2_SERVICE_NOTIFY_DEVICE_REPUBLISH %s\n", cmd.dev->name);
					ps2_dev_unpublish(cmd.dev);
					snooze(2500000);
					ps2_dev_publish(cmd.dev);
					break;

				case PS2_SERVICE_NOTIFY_DEVICE_REMOVED:
					TRACE("ps2: PS2_SERVICE_NOTIFY_DEVICE_REMOVED %s\n", cmd.dev->name);
					ps2_dev_unpublish(cmd.dev);
					break;

				default:
					TRACE("ps2: PS2_SERVICE: unknown id %lu\n", cmd.id);
					break;
			}
		} else {
			INFO("ps2: ps2_service_thread: Error, status 0x%08lx, terminating\n", status);
			break;
		}
	}
	return 0;
}
示例#3
0
static status_t
read_keyboard_packet(raw_key_info *packet, bool isDebugger)
{
	status_t status;

	TRACE("ps2: read_keyboard_packet: enter\n");

	while (true) {
		status = acquire_sem_etc(sKeyboardSem, 1, B_CAN_INTERRUPT, 0);
		if (status != B_OK)
			return status;

		if (!ps2_device[PS2_DEVICE_KEYB].active) {
			TRACE("ps2: read_keyboard_packet, Error device no longer active\n");
			return B_ERROR;
		}

		if (isDebugger || !sHasDebugReader)
			break;

		// Give the debugger a chance to read this packet
		release_sem(sKeyboardSem);
		snooze(100000);
	}

	if (packet_buffer_read(sKeyBuffer, (uint8 *)packet, sizeof(*packet)) == 0) {
		TRACE("ps2: read_keyboard_packet, Error reading packet: %s\n",
			strerror(status));
		return B_ERROR;
	}

	TRACE("ps2: read_keyboard_packet: keycode: %" B_PRIx32 ", keydown: %s\n",
		packet->keycode, packet->is_keydown ? "true" : "false");

	return B_OK;
}