Changes in uspace/drv/char/i8042/main.c [ca4730a5:2df6f6fe] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/i8042/main.c
rca4730a5 r2df6f6fe 36 36 37 37 #include <libarch/inttypes.h> 38 #include <libarch/config.h>39 38 #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>46 45 #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) 47 54 48 55 /** Get address of I/O registers. … … 57 64 * 58 65 */ 59 static int get_my_registers( ddf_dev_t *dev, uintptr_t *io_reg_address,66 static int get_my_registers(const ddf_dev_t *dev, uintptr_t *io_reg_address, 60 67 size_t *io_reg_size, int *kbd_irq, int *mouse_irq) 61 68 { 62 69 assert(dev); 63 70 64 async_sess_t *parent_sess = ddf_dev_parent_sess_create( 65 dev, EXCHANGE_SERIALIZE); 66 if (parent_sess == NULL) 71 async_sess_t *parent_sess = 72 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, 73 IPC_FLAG_BLOCKING); 74 if (!parent_sess) 67 75 return ENOMEM; 68 76 … … 70 78 hw_res_list_parsed_init(&hw_resources); 71 79 const int ret = hw_res_get_list_parsed(parent_sess, &hw_resources, 0); 80 async_hangup(parent_sess); 72 81 if (ret != EOK) 73 82 return ret; … … 104 113 static int i8042_dev_add(ddf_dev_t *device) 105 114 { 115 if (!device) 116 return EINVAL; 117 106 118 uintptr_t io_regs = 0; 107 119 size_t io_size = 0; 108 120 int kbd = 0; 109 121 int mouse = 0; 110 int rc;111 122 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 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)); 122 126 ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.", 123 127 (void *) io_regs, io_size, kbd, mouse); 124 128 125 129 i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t)); 126 if (i8042 == NULL) { 127 ddf_msg(LVL_ERROR, "Out of memory."); 128 return ENOMEM; 129 } 130 ret = (i8042 == NULL) ? ENOMEM : EOK; 131 CHECK_RET_RETURN(ret, "Failed to allocate i8042 driver instance."); 130 132 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 } 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)); 137 136 138 137 ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").", 139 d df_dev_get_name(device), ddf_dev_get_handle(device));138 device->name, device->handle); 140 139 return EOK; 141 140 } … … 155 154 { 156 155 printf("%s: HelenOS PS/2 driver.\n", NAME); 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 156 ddf_log_init(NAME, LVL_NOTE); 165 157 return ddf_driver_main(&i8042_driver); 166 158 }
Note:
See TracChangeset
for help on using the changeset viewer.