Changeset 8f5b4d44 in mainline for uspace/drv/bus/usb/ohci/pci.c
- Timestamp:
- 2011-12-09T22:30:13Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 89e061d
- Parents:
- 9c986d3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/pci.c
r9c986d3 r8f5b4d44 42 42 #include <ddi.h> 43 43 #include <libarch/ddi.h> 44 #include <device/hw_res .h>44 #include <device/hw_res_parsed.h> 45 45 46 46 #include <usb/debug.h> … … 61 61 { 62 62 assert(dev); 63 assert(mem_reg_address);64 assert(mem_reg_size);65 assert(irq_no);66 63 67 64 async_sess_t *parent_sess = … … 71 68 return ENOMEM; 72 69 73 hw_resource_list_t hw_resources; 74 int rc = hw_res_get_resource_list(parent_sess, &hw_resources); 70 hw_res_list_parsed_t hw_res; 71 hw_res_list_parsed_init(&hw_res); 72 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 75 73 async_hangup(parent_sess); 76 if (r c!= EOK) {77 return r c;74 if (ret != EOK) { 75 return ret; 78 76 } 79 77 80 uintptr_t mem_address = 0; 81 size_t mem_size = 0; 82 bool mem_found = false; 78 /* We want one irq and one mem range. */ 79 if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) { 80 hw_res_list_parsed_clean(&hw_res); 81 return EINVAL; 82 } 83 83 84 int irq = 0; 85 bool irq_found = false; 84 if (mem_reg_address) 85 *mem_reg_address = hw_res.mem_ranges.ranges[0].address; 86 if (mem_reg_size) 87 *mem_reg_size = hw_res.mem_ranges.ranges[0].size; 88 if (irq_no) 89 *irq_no = hw_res.irqs.irqs[0]; 86 90 87 for (size_t i = 0; i < hw_resources.count; i++) { 88 hw_resource_t *res = &hw_resources.resources[i]; 89 switch (res->type) { 90 case INTERRUPT: 91 irq = res->res.interrupt.irq; 92 irq_found = true; 93 usb_log_debug2("Found interrupt: %d.\n", irq); 94 break; 95 case MEM_RANGE: 96 if (res->res.mem_range.address != 0 97 && res->res.mem_range.size != 0 ) { 98 mem_address = res->res.mem_range.address; 99 mem_size = res->res.mem_range.size; 100 usb_log_debug2("Found mem: %p %zu.\n", 101 (void *) mem_address, mem_size); 102 mem_found = true; 103 } 104 default: 105 break; 106 } 107 } 108 free(hw_resources.resources); 109 110 if (mem_found && irq_found) { 111 *mem_reg_address = mem_address; 112 *mem_reg_size = mem_size; 113 *irq_no = irq; 114 return EOK; 115 } 116 return ENOENT; 91 hw_res_list_parsed_clean(&hw_res); 92 return EOK; 117 93 } 118 94
Note:
See TracChangeset
for help on using the changeset viewer.