Changes in uspace/drv/char/i8042/main.c [b4df8db:7de1988c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/i8042/main.c
rb4df8db r7de1988c 46 46 #include "i8042.h" 47 47 48 #define CHECK_RET_RETURN(ret, message...) \49 do { \50 if (ret != EOK) { \51 ddf_msg(LVL_ERROR, message); \52 return ret; \53 } \54 } while (0)55 56 48 /** Get address of I/O registers. 57 49 * 58 50 * @param[in] dev Device asking for the addresses. 59 * @param[out] io_reg_address Base address of the memory range. 60 * @param[out] io_reg_size Size of the memory range. 51 * @param[out] p_io_reg Pointer to register range. 61 52 * @param[out] kbd_irq Primary port IRQ. 62 53 * @param[out] mouse_irq Auxiliary port IRQ. … … 65 56 * 66 57 */ 67 static int get_my_registers(ddf_dev_t *dev, uintptr_t *io_reg_address,68 size_t *io_reg_size,int *kbd_irq, int *mouse_irq)58 static int get_my_registers(ddf_dev_t *dev, addr_range_t *p_io_reg, 59 int *kbd_irq, int *mouse_irq) 69 60 { 70 61 assert(dev); … … 87 78 } 88 79 89 if (io_reg_address) 90 *io_reg_address = hw_resources.io_ranges.ranges[0].address; 91 92 if (io_reg_size) 93 *io_reg_size = hw_resources.io_ranges.ranges[0].size; 80 if (p_io_reg) 81 *p_io_reg = hw_resources.io_ranges.ranges[0]; 94 82 95 83 if (kbd_irq) … … 112 100 static int i8042_dev_add(ddf_dev_t *device) 113 101 { 102 addr_range_t io_regs; 103 int kbd = 0; 104 int mouse = 0; 105 int rc; 106 114 107 if (!device) 115 108 return EINVAL; 116 109 117 uintptr_t io_regs = 0; 118 size_t io_size = 0; 119 int kbd = 0; 120 int mouse = 0; 110 rc = get_my_registers(device, &io_regs, &kbd, &mouse); 111 if (rc != EOK) { 112 ddf_msg(LVL_ERROR, "Failed to get registers: %s.", 113 str_error(rc)); 114 return rc; 115 } 121 116 122 int ret = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse); 123 CHECK_RET_RETURN(ret, "Failed to get registers: %s.", 124 str_error(ret)); 125 ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.", 126 (void *) io_regs, io_size, kbd, mouse); 117 ddf_msg(LVL_DEBUG, 118 "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.", 119 RNGABSPTR(io_regs), RNGSZ(io_regs), kbd, mouse); 127 120 128 121 i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t)); 129 ret = (i8042 == NULL) ? ENOMEM : EOK; 130 CHECK_RET_RETURN(ret, "Failed to allocate i8042 driver instance."); 122 if (i8042 == NULL) { 123 ddf_msg(LVL_ERROR, "Out of memory."); 124 return ENOMEM; 125 } 131 126 132 ret = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device); 133 CHECK_RET_RETURN(ret, "Failed to initialize i8042 driver: %s.", 134 str_error(ret)); 127 rc = i8042_init(i8042, &io_regs, kbd, mouse, device); 128 if (rc != EOK) { 129 ddf_msg(LVL_ERROR, "Failed to initialize i8042 driver: %s.", 130 str_error(rc)); 131 return rc; 132 } 135 133 136 134 ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
Note:
See TracChangeset
for help on using the changeset viewer.