Пример #1
0
/** Initialize a new ddf driver instance of i8042 driver
 *
 * @param[in] device DDF instance of the device to initialize.
 *
 * @return Error code.
 *
 */
static int i8042_dev_add(ddf_dev_t *device)
{
	if (!device)
		return EINVAL;
	
	uintptr_t io_regs = 0;
	size_t io_size = 0;
	int kbd = 0;
	int mouse = 0;
	
	int ret = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse);
	CHECK_RET_RETURN(ret, "Failed to get registers: %s.",
	    str_error(ret));
	ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.",
	    (void *) io_regs, io_size, kbd, mouse);
	
	i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t));
	ret = (i8042 == NULL) ? ENOMEM : EOK;
	CHECK_RET_RETURN(ret, "Failed to allocate i8042 driver instance.");
	
	ret = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device);
	CHECK_RET_RETURN(ret, "Failed to initialize i8042 driver: %s.",
	    str_error(ret));
	
	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
	return EOK;
}
Пример #2
0
int main(int argc, char** argv)
{
	struct kms_driver *kms;
	int ret, fd, i;

	for (i = 0, fd = -1; fd < 0 && drivers[i]; i++)
		fd = drmOpen(drivers[i], NULL);
	CHECK_RET_RETURN(fd, "Could not open device");

	ret = kms_create(fd, &kms);
	CHECK_RET_RETURN(ret, "Failed to create kms driver");

	ret = test_bo(kms);
	if (ret)
		goto err;

	printf("%s: All ok!\n", __func__);

	kms_destroy(&kms);
	return 0;

err:
	kms_destroy(&kms);
	return ret;
}
Пример #3
0
/** Initialize UHCI hc driver structure
 *
 * @param[in] instance Memory place to initialize.
 * @param[in] regs Address of I/O control registers.
 * @param[in] reg_size Size of I/O control registers.
 * @param[in] interrupts True if hw interrupts should be used.
 * @return Error code.
 * @note Should be called only once on any structure.
 *
 * Initializes memory structures, starts up hw, and launches debugger and
 * interrupt fibrils.
 */
int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts)
{
	assert(reg_size >= sizeof(uhci_regs_t));
	int ret;

#define CHECK_RET_RETURN(ret, message...) \
	if (ret != EOK) { \
		usb_log_error(message); \
		return ret; \
	} else (void) 0

	instance->hw_interrupts = interrupts;
	instance->hw_failures = 0;

	/* allow access to hc control registers */
	uhci_regs_t *io;
	ret = pio_enable(regs, reg_size, (void **)&io);
	CHECK_RET_RETURN(ret, "Failed to gain access to registers at %p: %s.\n",
	    io, str_error(ret));
	instance->registers = io;
	usb_log_debug(
	    "Device registers at %p (%zuB) accessible.\n", io, reg_size);

	ret = hc_init_mem_structures(instance);
	CHECK_RET_RETURN(ret,
	    "Failed to initialize UHCI memory structures: %s.\n",
	    str_error(ret));

#undef CHECK_RET_RETURN

	hcd_init(&instance->generic, USB_SPEED_FULL,
	    BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);

	instance->generic.private_data = instance;
	instance->generic.schedule = hc_schedule;
	instance->generic.ep_add_hook = NULL;

	hc_init_hw(instance);
	if (!interrupts) {
		instance->interrupt_emulator =
		    fibril_create(hc_interrupt_emulator, instance);
		fibril_add_ready(instance->interrupt_emulator);
	}
	(void)hc_debug_checker;

	return EOK;
}
Пример #4
0
/** Initialize a new ddf driver instance
 *
 * @param[in] device DDF instance of the device to initialize.
 * @return Error code.
 */
static int mouse_add(ddf_dev_t *device)
{
	if (!device)
		return EINVAL;

#define CHECK_RET_RETURN(ret, message...) \
if (ret != EOK) { \
	ddf_msg(LVL_ERROR, message); \
	return ret; \
} else (void)0

	ps2_mouse_t *mouse = ddf_dev_data_alloc(device, sizeof(ps2_mouse_t));
	int ret = (mouse == NULL) ? ENOMEM : EOK;
	CHECK_RET_RETURN(ret, "Failed to allocate mouse driver instance.");

	ret = ps2_mouse_init(mouse, device);
	CHECK_RET_RETURN(ret,
	    "Failed to initialize mouse driver: %s.", str_error(ret));

	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
	    device->name, device->handle);
	return EOK;
}
Пример #5
0
/** Initialize a new ddf driver instance of the driver
 *
 * @param[in] device DDF instance of the device to initialize.
 * @return Error code.
 */
static int xt_kbd_add(ddf_dev_t *device)
{
	if (!device)
		return EINVAL;

#define CHECK_RET_RETURN(ret, message...) \
if (ret != EOK) { \
	ddf_msg(LVL_ERROR, message); \
	return ret; \
} else (void)0

	xt_kbd_t *kbd = ddf_dev_data_alloc(device, sizeof(xt_kbd_t));
	int ret = (kbd == NULL) ? ENOMEM : EOK;
	CHECK_RET_RETURN(ret, "Failed to allocate XT/KBD driver instance.");

	ret = xt_kbd_init(kbd, device);
	CHECK_RET_RETURN(ret,
	    "Failed to initialize XT_KBD driver: %s.", str_error(ret));

	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
	return EOK;
}
Пример #6
0
int test_bo(struct kms_driver *kms)
{
	struct kms_bo *bo;
	int ret;
	unsigned attrs[7] = {
		KMS_WIDTH, 1024,
		KMS_HEIGHT, 768,
		KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT_X8R8G8B8,
		KMS_TERMINATE_PROP_LIST,
	};

	ret = kms_bo_create(kms, attrs, &bo);
	CHECK_RET_RETURN(ret, "Could not create bo");

	kms_bo_destroy(&bo);

	return 0;
}