Changes in uspace/drv/char/i8042/main.c [2df6f6fe:ca4730a5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/i8042/main.c
r2df6f6fe rca4730a5 36 36 37 37 #include <libarch/inttypes.h> 38 #include <libarch/config.h> 38 39 #include <ddf/driver.h> 39 #include <devman.h>40 40 #include <device/hw_res_parsed.h> 41 41 #include <errno.h> … … 43 43 #include <ddf/log.h> 44 44 #include <stdio.h> 45 #include <async.h> 45 46 #include "i8042.h" 46 47 #define CHECK_RET_RETURN(ret, message...) \48 do { \49 if (ret != EOK) { \50 ddf_msg(LVL_ERROR, message); \51 return ret; \52 } \53 } while (0)54 47 55 48 /** Get address of I/O registers. … … 64 57 * 65 58 */ 66 static int get_my_registers( constddf_dev_t *dev, uintptr_t *io_reg_address,59 static int get_my_registers(ddf_dev_t *dev, uintptr_t *io_reg_address, 67 60 size_t *io_reg_size, int *kbd_irq, int *mouse_irq) 68 61 { 69 62 assert(dev); 70 63 71 async_sess_t *parent_sess = 72 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, 73 IPC_FLAG_BLOCKING); 74 if (!parent_sess) 64 async_sess_t *parent_sess = ddf_dev_parent_sess_create( 65 dev, EXCHANGE_SERIALIZE); 66 if (parent_sess == NULL) 75 67 return ENOMEM; 76 68 … … 78 70 hw_res_list_parsed_init(&hw_resources); 79 71 const int ret = hw_res_get_list_parsed(parent_sess, &hw_resources, 0); 80 async_hangup(parent_sess);81 72 if (ret != EOK) 82 73 return ret; … … 113 104 static int i8042_dev_add(ddf_dev_t *device) 114 105 { 115 if (!device)116 return EINVAL;117 118 106 uintptr_t io_regs = 0; 119 107 size_t io_size = 0; 120 108 int kbd = 0; 121 109 int mouse = 0; 110 int rc; 122 111 123 int ret = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse); 124 CHECK_RET_RETURN(ret, "Failed to get registers: %s.", 125 str_error(ret)); 112 if (!device) 113 return EINVAL; 114 115 rc = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse); 116 if (rc != EOK) { 117 ddf_msg(LVL_ERROR, "Failed to get registers: %s.", 118 str_error(rc)); 119 return rc; 120 } 121 126 122 ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.", 127 123 (void *) io_regs, io_size, kbd, mouse); 128 124 129 125 i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t)); 130 ret = (i8042 == NULL) ? ENOMEM : EOK; 131 CHECK_RET_RETURN(ret, "Failed to allocate i8042 driver instance."); 126 if (i8042 == NULL) { 127 ddf_msg(LVL_ERROR, "Out of memory."); 128 return ENOMEM; 129 } 132 130 133 ret = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device); 134 CHECK_RET_RETURN(ret, "Failed to initialize i8042 driver: %s.", 135 str_error(ret)); 131 rc = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device); 132 if (rc != EOK) { 133 ddf_msg(LVL_ERROR, "Failed to initialize i8042 driver: %s.", 134 str_error(rc)); 135 return rc; 136 } 136 137 137 138 ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").", 138 d evice->name, device->handle);139 ddf_dev_get_name(device), ddf_dev_get_handle(device)); 139 140 return EOK; 140 141 } … … 154 155 { 155 156 printf("%s: HelenOS PS/2 driver.\n", NAME); 156 ddf_log_init(NAME, LVL_NOTE); 157 ddf_log_init(NAME); 158 159 /* 160 * Alleviate the virtual memory / page table pressure caused by 161 * interrupt storms when the default large stacks are used. 162 */ 163 async_set_interrupt_handler_stack_size(PAGE_SIZE); 164 157 165 return ddf_driver_main(&i8042_driver); 158 166 }
Note:
See TracChangeset
for help on using the changeset viewer.