Changes in / [c9256c5:fcbcaae9] in mainline
- Location:
- uspace/drv
- Files:
-
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/hc.c
rc9256c5 rfcbcaae9 565 565 bzero(&instance->rh, sizeof(instance->rh)); 566 566 /* Init queues */ 567 hc_init_transfer_lists(instance); 567 const int ret = hc_init_transfer_lists(instance); 568 if (ret != EOK) { 569 return ret; 570 } 568 571 569 572 /*Init HCCA */ -
uspace/drv/uhci-hcd/batch.h
rc9256c5 rfcbcaae9 35 35 #define DRV_UHCI_BATCH_H 36 36 37 #include <usbhc_iface.h>38 #include <usb/usb.h>39 #include <usb/host/device_keeper.h>40 #include <usb/host/endpoint.h>41 37 #include <usb/host/batch.h> 42 38 -
uspace/drv/uhci-hcd/hc.c
rc9256c5 rfcbcaae9 39 39 #include <usb/debug.h> 40 40 #include <usb/usb.h> 41 #include <usb/ddfiface.h>42 #include <usb_iface.h>43 41 44 42 #include "hc.h" … … 85 83 /* allow access to hc control registers */ 86 84 regs_t *io; 87 ret = pio_enable(regs, reg_size, (void **)&io);85 ret = pio_enable(regs, reg_size, (void **)&io); 88 86 CHECK_RET_RETURN(ret, 89 87 "Failed(%d) to gain access to registers at %p: %s.\n", … … 143 141 } 144 142 145 uint16_t status = pio_read_16(®isters->usbcmd);143 const uint16_t status = pio_read_16(®isters->usbcmd); 146 144 if (status != 0) 147 145 usb_log_warning("Previous command value: %x.\n", status); … … 212 210 /* Init USB frame list page*/ 213 211 instance->frame_list = get_page(); 214 ret = instance ? EOK : ENOMEM;212 ret = instance->frame_list ? EOK : ENOMEM; 215 213 CHECK_RET_RETURN(ret, "Failed to get frame list page.\n"); 216 214 usb_log_debug("Initialized frame list at %p.\n", instance->frame_list); … … 277 275 &instance->transfers_control_slow); 278 276 279 /*FSBR*/ 277 /*FSBR, This feature is not needed (adds no benefit) and is supposedly 278 * buggy on certain hw, enable at your own risk. */ 280 279 #ifdef FSBR 281 280 transfer_list_set_next(&instance->transfers_bulk_full, … … 428 427 } 429 428 430 uintptr_t frame_list =429 const uintptr_t frame_list = 431 430 pio_read_32(&instance->registers->flbaseadd) & ~0xfff; 432 431 if (frame_list != addr_to_phys(instance->frame_list)) { -
uspace/drv/uhci-hcd/hc.h
rc9256c5 rfcbcaae9 37 37 38 38 #include <fibril.h> 39 #include <fibril_synch.h>40 #include <adt/list.h>41 39 #include <ddi.h> 42 40 43 #include <usbhc_iface.h>44 41 #include <usb/host/device_keeper.h> 45 42 #include <usb/host/usb_endpoint_manager.h> 43 #include <usb/host/batch.h> 46 44 47 #include "batch.h"48 45 #include "transfer_list.h" 49 46 … … 154 151 */ 155 152 static inline hc_t * fun_to_hc(ddf_fun_t *fun) 156 { return (hc_t*)fun->driver_data; } 153 { 154 assert(fun); 155 return fun->driver_data; 156 } 157 157 #endif 158 158 /** -
uspace/drv/uhci-hcd/iface.c
rc9256c5 rfcbcaae9 39 39 40 40 #include "iface.h" 41 #include "batch.h" 41 42 #include "hc.h" 42 43 … … 122 123 return EOK; 123 124 } 124 125 /*----------------------------------------------------------------------------*/ 125 126 /** Find device handle by address interface function. 126 127 * … … 136 137 hc_t *hc = fun_to_hc(fun); 137 138 assert(hc); 138 bool found =139 const bool found = 139 140 usb_device_keeper_find_by_address(&hc->manager, address, handle); 140 141 return found ? EOK : ENOENT; 141 142 } 142 143 143 /*----------------------------------------------------------------------------*/ 144 144 /** Release address interface function … … 164 164 size_t max_packet_size, unsigned int interval) 165 165 { 166 assert(fun); 166 167 hc_t *hc = fun_to_hc(fun); 167 168 assert(hc); … … 183 184 usb_endpoint_t endpoint, usb_direction_t direction) 184 185 { 186 assert(fun); 185 187 hc_t *hc = fun_to_hc(fun); 186 188 assert(hc); … … 211 213 if (ret != EOK) 212 214 return ret; 215 assert(batch); 216 assert(hc); 213 217 batch_interrupt_out(batch); 214 218 ret = hc_schedule(hc, batch); … … 239 243 if (ret != EOK) 240 244 return ret; 245 assert(batch); 246 assert(hc); 241 247 batch_interrupt_in(batch); 242 248 ret = hc_schedule(hc, batch); … … 267 273 if (ret != EOK) 268 274 return ret; 275 assert(batch); 276 assert(hc); 269 277 batch_bulk_out(batch); 270 278 ret = hc_schedule(hc, batch); … … 295 303 if (ret != EOK) 296 304 return ret; 305 assert(batch); 306 assert(hc); 297 307 batch_bulk_in(batch); 298 308 ret = hc_schedule(hc, batch); … … 327 337 if (ret != EOK) 328 338 return ret; 339 assert(batch); 340 assert(hc); 329 341 usb_endpoint_manager_reset_if_need(&hc->ep_manager, target, setup_data); 330 342 batch_control_write(batch); … … 360 372 if (ret != EOK) 361 373 return ret; 374 assert(batch); 375 assert(hc); 362 376 batch_control_read(batch); 363 377 ret = hc_schedule(hc, batch); -
uspace/drv/uhci-hcd/pci.c
rc9256c5 rfcbcaae9 52 52 * @return Error code. 53 53 */ 54 int pci_get_my_registers( ddf_dev_t *dev,54 int pci_get_my_registers(const ddf_dev_t *dev, 55 55 uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no) 56 56 { 57 assert(dev != NULL); 57 assert(dev); 58 assert(io_reg_address); 59 assert(io_reg_size); 60 assert(irq_no); 58 61 59 62 int parent_phone = … … 66 69 int rc = hw_res_get_resource_list(parent_phone, &hw_resources); 67 70 if (rc != EOK) { 68 goto leave; 71 async_hangup(parent_phone); 72 return rc; 69 73 } 70 74 … … 78 82 size_t i; 79 83 for (i = 0; i < hw_resources.count; i++) { 80 hw_resource_t *res = &hw_resources.resources[i];84 const hw_resource_t *res = &hw_resources.resources[i]; 81 85 switch (res->type) 82 86 { … … 99 103 } 100 104 } 105 async_hangup(parent_phone); 101 106 102 if (!io_found || !irq_found) { 103 rc = ENOENT; 104 goto leave; 105 } 107 if (!io_found || !irq_found) 108 return ENOENT; 106 109 107 110 *io_reg_address = io_address; … … 109 112 *irq_no = irq; 110 113 111 rc = EOK; 112 leave: 113 async_hangup(parent_phone); 114 return rc; 114 return EOK; 115 115 } 116 116 /*----------------------------------------------------------------------------*/ … … 120 120 * @return Error code. 121 121 */ 122 int pci_enable_interrupts( ddf_dev_t *device)122 int pci_enable_interrupts(const ddf_dev_t *device) 123 123 { 124 int parent_phone = devman_parent_device_connect(device->handle, 125 IPC_FLAG_BLOCKING); 126 bool enabled = hw_res_enable_interrupt(parent_phone); 124 const int parent_phone = 125 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 126 if (parent_phone < 0) { 127 return parent_phone; 128 } 129 const bool enabled = hw_res_enable_interrupt(parent_phone); 127 130 async_hangup(parent_phone); 128 131 return enabled ? EOK : EIO; … … 134 137 * @return Error code. 135 138 */ 136 int pci_disable_legacy( ddf_dev_t *device)139 int pci_disable_legacy(const ddf_dev_t *device) 137 140 { 138 141 assert(device); 139 int parent_phone =142 const int parent_phone = 140 143 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 141 144 if (parent_phone < 0) { … … 145 148 /* See UHCI design guide for these values p.45, 146 149 * write all WC bits in USB legacy register */ 147 sysarg_t address = 0xc0;148 sysarg_t value = 0xaf00;150 const sysarg_t address = 0xc0; 151 const sysarg_t value = 0xaf00; 149 152 150 int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),153 const int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), 151 154 IPC_M_CONFIG_SPACE_WRITE_16, address, value); 152 155 async_hangup(parent_phone); -
uspace/drv/uhci-hcd/pci.h
rc9256c5 rfcbcaae9 38 38 #include <ddf/driver.h> 39 39 40 int pci_get_my_registers( ddf_dev_t *, uintptr_t *, size_t *, int *);41 int pci_enable_interrupts( ddf_dev_t *);42 int pci_disable_legacy( ddf_dev_t *);40 int pci_get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *); 41 int pci_enable_interrupts(const ddf_dev_t *); 42 int pci_disable_legacy(const ddf_dev_t *); 43 43 44 44 #endif -
uspace/drv/uhci-hcd/root_hub.c
rc9256c5 rfcbcaae9 60 60 return ret; 61 61 } 62 assert(match_str); 62 63 63 64 ret = ddf_fun_add_match_id(fun, match_str, 100); -
uspace/drv/uhci-hcd/root_hub.h
rc9256c5 rfcbcaae9 43 43 /** List of resources available to the root hub. */ 44 44 hw_resource_list_t resource_list; 45 /** The only resource in the above list */45 /** The only resource in the RH resource list */ 46 46 hw_resource_t io_regs; 47 47 } rh_t; -
uspace/drv/uhci-hcd/transfer_list.c
rc9256c5 rfcbcaae9 36 36 #include <arch/barrier.h> 37 37 38 38 39 #include "transfer_list.h" 40 #include "batch.h" 39 41 40 42 static void transfer_list_remove_batch( … … 58 60 return ENOMEM; 59 61 } 60 uint32_t queue_head_pa = addr_to_phys(instance->queue_head);62 const uint32_t queue_head_pa = addr_to_phys(instance->queue_head); 61 63 usb_log_debug2("Transfer list %s setup with QH: %p (%#" PRIx32" ).\n", 62 64 name, instance->queue_head, queue_head_pa); … … 90 92 { 91 93 assert(instance); 94 assert(instance->queue_head); 92 95 assert(next); 93 if (!instance->queue_head)94 return;95 96 /* Set queue_head.next to point to the follower */ 96 97 qh_set_next_qh(instance->queue_head, next->queue_head); … … 137 138 write_barrier(); 138 139 139 /* Add to the driver list */140 /* Add to the driver's list */ 140 141 list_append(&batch->link, &instance->batch_list); 141 142 … … 160 161 link_t *current = instance->batch_list.next; 161 162 while (current != &instance->batch_list) { 162 link_t * next = current->next;163 link_t * const next = current->next; 163 164 usb_transfer_batch_t *batch = 164 165 usb_transfer_batch_from_link(current); … … 182 183 fibril_mutex_lock(&instance->guard); 183 184 while (!list_empty(&instance->batch_list)) { 184 link_t * current = instance->batch_list.next;185 link_t * const current = instance->batch_list.next; 185 186 usb_transfer_batch_t *batch = 186 187 usb_transfer_batch_from_link(current); -
uspace/drv/uhci-hcd/transfer_list.h
rc9256c5 rfcbcaae9 36 36 37 37 #include <fibril_synch.h> 38 #include <usb/host/batch.h> 38 39 39 #include "batch.h"40 40 #include "hw_struct/queue_head.h" 41 41 -
uspace/drv/uhci-hcd/uhci.c
rc9256c5 rfcbcaae9 77 77 { 78 78 assert(dev); 79 hc_t *hc = &((uhci_t*)dev->driver_data)->hc; 79 uhci_t *uhci = dev->driver_data; 80 assert(uhci); 81 hc_t *hc = &uhci->hc; 80 82 uint16_t status = IPC_GET_ARG1(*call); 81 83 assert(hc); … … 144 146 { 145 147 assert(fun); 146 return &((rh_t*)fun->driver_data)->resource_list; 148 rh_t *rh = fun->driver_data; 149 assert(rh); 150 return &rh->resource_list; 147 151 } 148 152 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-hcd/uhci.h
rc9256c5 rfcbcaae9 35 35 #ifndef DRV_UHCI_UHCI_H 36 36 #define DRV_UHCI_UHCI_H 37 #include <ddi.h>38 37 #include <ddf/driver.h> 39 38 -
uspace/drv/uhci-hcd/utils/malloc32.h
rc9256c5 rfcbcaae9 59 59 uintptr_t result; 60 60 const int ret = as_get_physical_mapping(addr, &result); 61 assert(ret == EOK);62 63 61 if (ret != EOK) 64 62 return 0; … … 98 96 { 99 97 void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 100 assert(free_address); /* TODO: remove this assert */101 98 if (free_address == 0) 102 99 return NULL; -
uspace/drv/uhci-rhd/main.c
rc9256c5 rfcbcaae9 37 37 #include <errno.h> 38 38 #include <str_error.h> 39 39 40 #include <usb_iface.h> 40 41 #include <usb/ddfiface.h> … … 45 46 #define NAME "uhci-rhd" 46 47 47 static int hc_get_my_registers( ddf_dev_t *dev,48 static int hc_get_my_registers(const ddf_dev_t *dev, 48 49 uintptr_t *io_reg_address, size_t *io_reg_size); 49 50 /*----------------------------------------------------------------------------*/ … … 130 131 */ 131 132 int hc_get_my_registers( 132 ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)133 const ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size) 133 134 { 134 assert(dev != NULL);135 assert(dev); 135 136 136 int parent_phone = devman_parent_device_connect(dev->handle,137 const int parent_phone = devman_parent_device_connect(dev->handle, 137 138 IPC_FLAG_BLOCKING); 138 139 if (parent_phone < 0) { … … 141 142 142 143 hw_resource_list_t hw_resources; 143 int ret = hw_res_get_resource_list(parent_phone, &hw_resources);144 const int ret = hw_res_get_resource_list(parent_phone, &hw_resources); 144 145 if (ret != EOK) { 145 146 async_hangup(parent_phone); -
uspace/drv/uhci-rhd/port.c
rc9256c5 rfcbcaae9 36 36 #include <errno.h> 37 37 #include <str_error.h> 38 #include <time.h>39 38 #include <async.h> 40 39 … … 82 81 * @param[in] number Port number. 83 82 * @param[in] usec Polling interval. 84 * @param[in] rh Pointer to ddf instance fothe root hub driver.83 * @param[in] rh Pointer to ddf instance of the root hub driver. 85 84 * @return Error code. 86 85 * … … 91 90 { 92 91 assert(port); 93 asprintf(&port->id_string, "Port (%p - %u)", port, number); 94 if (port->id_string == NULL) { 92 char *id_string; 93 asprintf(&id_string, "Port (%p - %u)", port, number); 94 if (id_string == NULL) { 95 95 return ENOMEM; 96 96 } 97 97 98 port->id_string = id_string; 98 99 port->address = address; 99 100 port->number = number; … … 105 106 usb_hc_connection_initialize_from_device(&port->hc_connection, rh); 106 107 if (ret != EOK) { 107 usb_log_error("Failed to initialize connection to HC."); 108 usb_log_error("%s: failed to initialize connection to HC.", 109 port->id_string); 110 free(id_string); 108 111 return ret; 109 112 } … … 113 116 usb_log_error("%s: failed to create polling fibril.", 114 117 port->id_string); 118 free(id_string); 115 119 return ENOMEM; 116 120 } … … 132 136 assert(port); 133 137 free(port->id_string); 134 / * TODO: Kill fibril here */138 // TODO: Kill fibril here 135 139 return; 136 140 } … … 150 154 151 155 /* Read register value */ 152 port_status_t port_status = uhci_port_read_status(instance); 156 const port_status_t port_status = 157 uhci_port_read_status(instance); 153 158 154 159 /* Print the value if it's interesting */ … … 161 166 usb_log_debug("%s: Connected change detected: %x.\n", 162 167 instance->id_string, port_status); 163 164 int rc =165 usb_hc_connection_open(&instance->hc_connection);166 if (rc != EOK) {167 usb_log_error("%s: Failed to connect to HC.",168 instance->id_string);169 continue;170 }171 168 172 169 /* Remove any old device */ … … 175 172 instance->id_string); 176 173 uhci_port_remove_device(instance); 174 } 175 176 int ret = 177 usb_hc_connection_open(&instance->hc_connection); 178 if (ret != EOK) { 179 usb_log_error("%s: Failed to connect to HC.", 180 instance->id_string); 181 continue; 177 182 } 178 183 … … 190 195 } 191 196 192 r c= usb_hc_connection_close(&instance->hc_connection);193 if (r c!= EOK) {197 ret = usb_hc_connection_close(&instance->hc_connection); 198 if (ret != EOK) { 194 199 usb_log_error("%s: Failed to disconnect.", 195 200 instance->id_string); … … 209 214 int uhci_port_reset_enable(int portno, void *arg) 210 215 { 211 uhci_port_t *port = (uhci_port_t *) arg; 216 uhci_port_t *port = arg; 217 assert(port); 212 218 213 219 usb_log_debug2("%s: new_device_enable_port.\n", port->id_string); … … 283 289 usb_log_error("%s: Don't know how to remove device %" PRIun ".\n", 284 290 port->id_string, port->attached_device); 291 port->attached_device = 0; 285 292 return ENOTSUP; 286 293 } -
uspace/drv/uhci-rhd/port.h
rc9256c5 rfcbcaae9 57 57 typedef struct uhci_port 58 58 { 59 c har *id_string;59 const char *id_string; 60 60 port_status_t *address; 61 61 unsigned number;
Note:
See TracChangeset
for help on using the changeset viewer.