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