Changeset 3094804b in mainline
- Timestamp:
- 2011-04-03T19:34:11Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c4e0b47, df40775
- Parents:
- 0cec844 (diff), baa9d5d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/pciintel/pci.c
r0cec844 r3094804b 107 107 } 108 108 109 size_t i; 110 for (i = 0; i < dev_data->hw_resources.count; i++) { 111 if (dev_data->hw_resources.resources[i].type == INTERRUPT) { 112 int irq = dev_data->hw_resources.resources[i].res.interrupt.irq; 113 int rc = async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq); 109 size_t i = 0; 110 hw_resource_list_t *res = &dev_data->hw_resources; 111 for (; i < res->count; i++) { 112 if (res->resources[i].type == INTERRUPT) { 113 const int irq = res->resources[i].res.interrupt.irq; 114 const int rc = 115 async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq); 114 116 if (rc != EOK) { 115 117 async_hangup(irc_phone); -
uspace/drv/uhci-rhd/main.c
r0cec844 r3094804b 44 44 45 45 #define NAME "uhci-rhd" 46 46 47 static int hc_get_my_registers(ddf_dev_t *dev, 47 48 uintptr_t *io_reg_address, size_t *io_reg_size); 48 #if 049 49 /*----------------------------------------------------------------------------*/ 50 static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle) 51 { 52 assert(fun); 53 assert(fun->driver_data); 54 assert(handle); 55 56 *handle = ((uhci_root_hub_t*)fun->driver_data)->hc_handle; 57 58 return EOK; 59 } 60 /*----------------------------------------------------------------------------*/ 61 static usb_iface_t uhci_rh_usb_iface = { 62 .get_hc_handle = usb_iface_get_hc_handle, 63 .get_address = usb_iface_get_address_hub_impl 64 }; 65 /*----------------------------------------------------------------------------*/ 66 static ddf_dev_ops_t uhci_rh_ops = { 67 .interfaces[USB_DEV_IFACE] = &uhci_rh_usb_iface, 68 }; 69 #endif 70 /*----------------------------------------------------------------------------*/ 71 /** Initialize a new ddf driver instance of UHCI root hub. 72 * 73 * @param[in] device DDF instance of the device to initialize. 74 * @return Error code. 75 */ 76 static int uhci_rh_add_device(ddf_dev_t *device) 77 { 78 if (!device) 79 return ENOTSUP; 80 81 usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle); 82 83 //device->ops = &uhci_rh_ops; 84 uintptr_t io_regs = 0; 85 size_t io_size = 0; 86 87 int ret = hc_get_my_registers(device, &io_regs, &io_size); 88 if (ret != EOK) { 89 usb_log_error("Failed to get registers from parent HC: %s.\n", 90 str_error(ret)); 91 } 92 usb_log_debug("I/O regs at %#X (size %zu).\n", io_regs, io_size); 93 94 uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t)); 95 if (!rh) { 96 usb_log_error("Failed to allocate driver instance.\n"); 97 return ENOMEM; 98 } 99 100 ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device); 101 if (ret != EOK) { 102 usb_log_error("Failed to initialize driver instance: %s.\n", 103 str_error(ret)); 104 free(rh); 105 return ret; 106 } 107 108 device->driver_data = rh; 109 usb_log_info("Controlling root hub `%s' (%llu).\n", 110 device->name, device->handle); 111 return EOK; 112 } 50 static int uhci_rh_add_device(ddf_dev_t *device); 113 51 /*----------------------------------------------------------------------------*/ 114 52 static driver_ops_t uhci_rh_driver_ops = { … … 132 70 { 133 71 printf(NAME ": HelenOS UHCI root hub driver.\n"); 72 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 73 return ddf_driver_main(&uhci_rh_driver); 74 } 75 /*----------------------------------------------------------------------------*/ 76 /** Initialize a new ddf driver instance of UHCI root hub. 77 * 78 * @param[in] device DDF instance of the device to initialize. 79 * @return Error code. 80 */ 81 static int uhci_rh_add_device(ddf_dev_t *device) 82 { 83 if (!device) 84 return EINVAL; 134 85 135 usb_log_ enable(USB_LOG_LEVEL_DEFAULT, NAME);86 usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle); 136 87 137 return ddf_driver_main(&uhci_rh_driver); 88 uintptr_t io_regs = 0; 89 size_t io_size = 0; 90 uhci_root_hub_t *rh = NULL; 91 int ret = EOK; 92 93 #define CHECK_RET_FREE_RH_RETURN(ret, message...) \ 94 if (ret != EOK) { \ 95 usb_log_error(message); \ 96 if (rh) \ 97 free(rh); \ 98 return ret; \ 99 } else (void)0 100 101 ret = hc_get_my_registers(device, &io_regs, &io_size); 102 CHECK_RET_FREE_RH_RETURN(ret, 103 "Failed(%d) to get registers from HC: %s.\n", ret, str_error(ret)); 104 usb_log_debug("I/O regs at %#x (size %zu).\n", io_regs, io_size); 105 106 rh = malloc(sizeof(uhci_root_hub_t)); 107 ret = (rh == NULL) ? ENOMEM : EOK; 108 CHECK_RET_FREE_RH_RETURN(ret, 109 "Failed to allocate rh driver instance.\n"); 110 111 ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device); 112 CHECK_RET_FREE_RH_RETURN(ret, 113 "Failed(%d) to initialize rh driver instance: %s.\n", 114 ret, str_error(ret)); 115 116 device->driver_data = rh; 117 usb_log_info("Controlling root hub '%s' (%llu).\n", 118 device->name, device->handle); 119 return EOK; 138 120 } 139 121 /*----------------------------------------------------------------------------*/ … … 156 138 } 157 139 158 int rc;159 160 140 hw_resource_list_t hw_resources; 161 rc = hw_res_get_resource_list(parent_phone, &hw_resources); 162 if (rc != EOK) { 163 goto leave; 141 int ret = hw_res_get_resource_list(parent_phone, &hw_resources); 142 if (ret != EOK) { 143 async_hangup(parent_phone); 144 return ret; 164 145 } 165 146 … … 168 149 bool io_found = false; 169 150 170 size_t i ;171 for ( i = 0; i < hw_resources.count; i++) {151 size_t i = 0; 152 for (; i < hw_resources.count; i++) { 172 153 hw_resource_t *res = &hw_resources.resources[i]; 173 switch (res->type) 174 { 175 case IO_RANGE: 176 io_address = (uintptr_t) res->res.io_range.address; 154 if (res->type == IO_RANGE) { 155 io_address = res->res.io_range.address; 177 156 io_size = res->res.io_range.size; 178 157 io_found = true; 179 180 default:181 break;182 158 } 183 159 } 160 async_hangup(parent_phone); 184 161 185 162 if (!io_found) { 186 rc = ENOENT; 187 goto leave; 163 return ENOENT; 188 164 } 189 190 165 if (io_reg_address != NULL) { 191 166 *io_reg_address = io_address; … … 194 169 *io_reg_size = io_size; 195 170 } 196 rc = EOK; 197 198 leave: 199 async_hangup(parent_phone); 200 return rc; 171 return EOK; 201 172 } 202 173 /** -
uspace/drv/uhci-rhd/port.c
r0cec844 r3094804b 43 43 #include "port.h" 44 44 45 static int uhci_port_check(void *port); 46 static int uhci_port_reset_enable(int portno, void *arg); 45 47 static int uhci_port_new_device(uhci_port_t *port, usb_speed_t speed); 46 48 static int uhci_port_remove_device(uhci_port_t *port); 47 49 static int uhci_port_set_enabled(uhci_port_t *port, bool enabled); 48 static int uhci_port_check(void *port);49 static int uhci_port_reset_enable(int portno, void *arg);50 50 static void uhci_port_print_status( 51 51 uhci_port_t *port, const port_status_t value); … … 74 74 pio_write_16(port->address, value); 75 75 } 76 77 76 /*----------------------------------------------------------------------------*/ 78 77 /** Initialize UHCI root hub port instance. … … 259 258 260 259 usb_address_t dev_addr; 261 int r c= usb_hc_new_device_wrapper(port->rh, &port->hc_connection,260 int ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection, 262 261 speed, uhci_port_reset_enable, port->number, port, 263 262 &dev_addr, &port->attached_device, NULL, NULL, NULL); 264 263 265 if (r c!= EOK) {264 if (ret != EOK) { 266 265 usb_log_error("%s: Failed(%d) to add device: %s.\n", 267 port->id_string, r c, str_error(rc));266 port->id_string, ret, str_error(ret)); 268 267 uhci_port_set_enabled(port, false); 269 return r c;268 return ret; 270 269 } 271 270 … … 287 286 int uhci_port_remove_device(uhci_port_t *port) 288 287 { 289 usb_log_error("%s: Don't know how to remove device % d.\n",290 port->id_string, (unsigned int)port->attached_device);291 return E OK;288 usb_log_error("%s: Don't know how to remove device %llu.\n", 289 port->id_string, port->attached_device); 290 return ENOTSUP; 292 291 } 293 292 /*----------------------------------------------------------------------------*/ … … 341 340 (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "", 342 341 (value & STATUS_CONNECTED) ? " CONNECTED," : "", 343 (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERR OR: NO ALWAYS ONE"342 (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERR: NO ALWAYS ONE" 344 343 ); 345 344 } -
uspace/drv/uhci-rhd/root_hub.c
r0cec844 r3094804b 51 51 assert(instance); 52 52 assert(rh); 53 int ret;54 53 55 54 /* Allow access to root hub port registers */ 56 55 assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT <= size); 57 56 port_status_t *regs; 58 ret = pio_enable(addr, size, (void**)®s);57 int ret = pio_enable(addr, size, (void**)®s); 59 58 if (ret < 0) { 60 59 usb_log_error( … … 84 83 * 85 84 * @param[in] instance Root hub structure to use. 86 * @return Error code.87 85 */ 88 intuhci_root_hub_fini(uhci_root_hub_t* instance)86 void uhci_root_hub_fini(uhci_root_hub_t* instance) 89 87 { 90 88 assert(instance); … … 93 91 uhci_port_fini(&instance->ports[i]); 94 92 } 95 return EOK;96 93 } 97 94 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-rhd/root_hub.h
r0cec844 r3094804b 50 50 uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh); 51 51 52 intuhci_root_hub_fini(uhci_root_hub_t *instance);52 void uhci_root_hub_fini(uhci_root_hub_t *instance); 53 53 #endif 54 54 /** -
uspace/srv/hw/irc/apic/apic.c
r0cec844 r3094804b 87 87 async_answer_0(callid, EOK); 88 88 break; 89 case IPC_M_PHONE_HUNGUP: 90 /* The other side has hung up. */ 91 async_answer_0(callid, EOK); 92 return; 89 93 default: 90 94 async_answer_0(callid, EINVAL); -
uspace/srv/hw/irc/i8259/i8259.c
r0cec844 r3094804b 121 121 async_answer_0(callid, EOK); 122 122 break; 123 case IPC_M_PHONE_HUNGUP: 124 /* The other side has hung up. */ 125 async_answer_0(callid, EOK); 126 return; 123 127 default: 124 128 async_answer_0(callid, EINVAL);
Note:
See TracChangeset
for help on using the changeset viewer.