Changeset 72af8da in mainline for uspace/drv/uhci-rhd/main.c
- Timestamp:
- 2011-03-16T18:50:17Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42a3a57
- Parents:
- 3e7b7cd (diff), fcf07e6 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-rhd/main.c
r3e7b7cd r72af8da 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbuhcirh 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver32 * @brief UHCI root hub initialization routines 33 33 */ 34 34 #include <ddf/driver.h> 35 35 #include <devman.h> 36 36 #include <device/hw_res.h> 37 #include <errno.h> 37 38 #include <usb_iface.h> 38 39 #include <usb/ddfiface.h> 39 40 #include <errno.h>41 42 40 #include <usb/debug.h> 43 41 … … 47 45 static int hc_get_my_registers(ddf_dev_t *dev, 48 46 uintptr_t *io_reg_address, size_t *io_reg_size); 49 47 #if 0 48 /*----------------------------------------------------------------------------*/ 50 49 static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle) 51 50 { … … 58 57 return EOK; 59 58 } 60 59 /*----------------------------------------------------------------------------*/ 61 60 static usb_iface_t uhci_rh_usb_iface = { 62 61 .get_hc_handle = usb_iface_get_hc_handle, 63 62 .get_address = usb_iface_get_address_hub_impl 64 63 }; 65 64 /*----------------------------------------------------------------------------*/ 66 65 static ddf_dev_ops_t uhci_rh_ops = { 67 66 .interfaces[USB_DEV_IFACE] = &uhci_rh_usb_iface, 68 67 }; 69 68 #endif 69 /*----------------------------------------------------------------------------*/ 70 /** Initialize a new ddf driver instance of UHCI root hub. 71 * 72 * @param[in] device DDF instance of the device to initialize. 73 * @return Error code. 74 */ 70 75 static int uhci_rh_add_device(ddf_dev_t *device) 71 76 { … … 76 81 77 82 //device->ops = &uhci_rh_ops; 78 (void) uhci_rh_ops;79 80 uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));81 if (!rh) {82 usb_log_error("Failed to allocate memory for driver instance.\n");83 return ENOMEM;84 }85 86 83 uintptr_t io_regs = 0; 87 84 size_t io_size = 0; 88 85 89 86 int ret = hc_get_my_registers(device, &io_regs, &io_size); 90 assert(ret == EOK); 87 if (ret != EOK) { 88 usb_log_error("Failed(%d) to get registers from parent hc.", 89 ret); 90 } 91 usb_log_info("I/O regs at %#X (size %zu).\n", io_regs, io_size); 91 92 92 /* TODO: verify values from hc */ 93 usb_log_info("I/O regs at 0x%X (size %zu).\n", io_regs, io_size); 93 uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t)); 94 if (!rh) { 95 usb_log_error("Failed to allocate driver instance.\n"); 96 return ENOMEM; 97 } 98 94 99 ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device); 95 100 if (ret != EOK) { … … 104 109 return EOK; 105 110 } 106 111 /*----------------------------------------------------------------------------*/ 107 112 static driver_ops_t uhci_rh_driver_ops = { 108 113 .add_device = uhci_rh_add_device, 109 114 }; 110 115 /*----------------------------------------------------------------------------*/ 111 116 static driver_t uhci_rh_driver = { 112 117 .name = NAME, … … 114 119 }; 115 120 /*----------------------------------------------------------------------------*/ 121 /** Initialize global driver structures (NONE). 122 * 123 * @param[in] argc Nmber of arguments in argv vector (ignored). 124 * @param[in] argv Cmdline argument vector (ignored). 125 * @return Error code. 126 * 127 * Driver debug level is set here. 128 */ 116 129 int main(int argc, char *argv[]) 117 130 { … … 120 133 } 121 134 /*----------------------------------------------------------------------------*/ 122 int hc_get_my_registers(ddf_dev_t *dev, 123 uintptr_t *io_reg_address, size_t *io_reg_size) 135 /** Get address of I/O registers. 136 * 137 * @param[in] dev Device asking for the addresses. 138 * @param[out] io_reg_address Base address of the memory range. 139 * @param[out] io_reg_size Size of the memory range. 140 * @return Error code. 141 */ 142 int hc_get_my_registers( 143 ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size) 124 144 { 125 145 assert(dev != NULL); … … 146 166 for (i = 0; i < hw_resources.count; i++) { 147 167 hw_resource_t *res = &hw_resources.resources[i]; 148 switch (res->type) {149 case IO_RANGE:150 io_address = (uintptr_t)151 152 153 154 break; 155 156 168 switch (res->type) 169 { 170 case IO_RANGE: 171 io_address = (uintptr_t) res->res.io_range.address; 172 io_size = res->res.io_range.size; 173 io_found = true; 174 175 default: 176 break; 157 177 } 158 178 } … … 170 190 } 171 191 rc = EOK; 192 172 193 leave: 173 194 async_hangup(parent_phone); 174 175 195 return rc; 176 196 }
Note:
See TracChangeset
for help on using the changeset viewer.