Changeset 7ce0fe3 in mainline
- Timestamp:
- 2011-02-01T22:02:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- afcd86e
- Parents:
- 993a1e1
- Location:
- uspace/drv/uhci-rhd
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-rhd/main.c
r993a1e1 r7ce0fe3 28 28 #include <driver.h> 29 29 #include <errno.h> 30 #include <str_error.h> 30 31 31 #include <usb_iface.h> 32 #include <usb/debug.h> 32 33 33 #include "debug.h"34 //#include "iface.h"35 34 #include "root_hub.h" 35 36 #define NAME "uhci-rhd" 36 37 37 38 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle) 38 39 { 39 /* This shall be called only for the UHCI itself. */40 40 assert(dev); 41 41 assert(dev->driver_data); 42 assert(handle); 43 42 44 *handle = ((uhci_root_hub_t*)dev->driver_data)->hc_handle; 45 usb_log_debug("Answering HC handle: %d.\n", *handle); 43 46 44 47 return EOK; … … 58 61 return ENOTSUP; 59 62 60 u hci_print_info("%s called device %d\n", __FUNCTION__, device->handle);63 usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle); 61 64 device->ops = &uhci_rh_ops; 62 65 63 66 uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t)); 64 67 if (!rh) { 68 usb_log_error("Failed to allocate memory for driver instance.\n"); 65 69 return ENOMEM; 66 70 } 71 72 /* TODO: get register values from hc */ 67 73 int ret = uhci_root_hub_init(rh, (void*)0xc030, 4, device); 68 74 if (ret != EOK) { 75 usb_log_error("Failed(%d) to initialize driver instance.\n", ret); 69 76 free(rh); 70 77 return ret; 71 78 } 79 72 80 device->driver_data = rh; 81 usb_log_info("Sucessfully initialized driver isntance for device:%d.\n", 82 device->handle); 73 83 return EOK; 74 84 } … … 85 95 int main(int argc, char *argv[]) 86 96 { 87 /* 88 * Do some global initializations. 89 */ 90 usb_dprintf_enable(NAME, DEBUG_LEVEL_INFO); 91 97 usb_log_enable(USB_LOG_LEVEL_INFO, NAME); 92 98 return driver_main(&uhci_rh_driver); 93 99 } -
uspace/drv/uhci-rhd/port.c
r993a1e1 r7ce0fe3 1 1 2 2 #include <errno.h> 3 3 4 #include <usb/usb.h> /* usb_address_t */ 4 5 #include <usb/usbdrv.h> /* usb_drv_* */ 6 #include <usb/debug.h> 5 7 6 #include "debug.h"7 8 #include "port.h" 8 9 #include "port_status.h" … … 27 28 port->checker = fibril_create(uhci_port_check, port); 28 29 if (port->checker == 0) { 29 u hci_print_error(": failed to launch root hub fibril.");30 usb_log_error(": failed to launch root hub fibril."); 30 31 return ENOMEM; 31 32 } 32 33 fibril_add_ready(port->checker); 33 u hci_print_verbose(34 usb_log_debug( 34 35 "Added fibril for port %d: %p.\n", number, port->checker); 35 36 return EOK; … … 49 50 50 51 while (1) { 51 u hci_print_verbose("Port(%d) status address %p:\n",52 usb_log_debug("Port(%d) status address %p:\n", 52 53 port_instance->number, port_instance->address); 53 54 … … 57 58 58 59 /* debug print */ 59 u hci_print_info("Port(%d) status %#.4x\n",60 usb_log_info("Port(%d) status %#.4x\n", 60 61 port_instance->number, port_status); 61 62 print_port_status(port_status); … … 79 80 assert(port->hc_phone); 80 81 81 u hci_print_info("Adding new device on port %d.\n", port->number);82 usb_log_info("Adding new device on port %d.\n", port->number); 82 83 83 84 … … 85 86 int ret = usb_drv_reserve_default_address(port->hc_phone); 86 87 if (ret != EOK) { 87 u hci_print_error("Failed to reserve default address.\n");88 usb_log_error("Failed to reserve default address.\n"); 88 89 return ret; 89 90 } … … 92 93 93 94 if (usb_address <= 0) { 94 u hci_print_error("Recieved invalid address(%d).\n", usb_address);95 usb_log_error("Recieved invalid address(%d).\n", usb_address); 95 96 return usb_address; 96 97 } … … 122 123 123 124 if (ret != EOK) { /* address assigning went wrong */ 124 u hci_print_error("Failed(%d) to assign address to the device.\n", ret);125 usb_log_error("Failed(%d) to assign address to the device.\n", ret); 125 126 uhci_port_set_enabled(port, false); 126 127 int release = usb_drv_release_default_address(port->hc_phone); 127 128 if (release != EOK) { 128 u hci_print_fatal("Failed to release default address.\n");129 usb_log_error("Failed to release default address.\n"); 129 130 return release; 130 131 } … … 135 136 ret = usb_drv_release_default_address(port->hc_phone); 136 137 if (ret != EOK) { 137 u hci_print_fatal("Failed to release default address.\n");138 usb_log_error("Failed to release default address.\n"); 138 139 return ret; 139 140 } … … 146 147 147 148 if (ret != EOK) { /* something went wrong */ 148 u hci_print_error("Failed(%d) in usb_drv_register_child.\n", ret);149 usb_log_error("Failed(%d) in usb_drv_register_child.\n", ret); 149 150 uhci_port_set_enabled(port, false); 150 151 return ENOMEM; 151 152 } 152 u hci_print_info("Sucessfully added device on port(%d) address(%d).\n",153 usb_log_info("Sucessfully added device on port(%d) address(%d).\n", 153 154 port->number, usb_address); 154 155 … … 160 161 static int uhci_port_remove_device(uhci_port_t *port) 161 162 { 162 u hci_print_error("Don't know how to remove device %#x.\n",163 usb_log_error("Don't know how to remove device %#x.\n", 163 164 (unsigned int)port->attached_device); 164 165 uhci_port_set_enabled(port, false); … … 182 183 port_status_write(port->address, port_status); 183 184 184 u hci_print_info("%s port %d.\n",185 usb_log_info("%s port %d.\n", 185 186 enabled ? "Enabled" : "Disabled", port->number); 186 187 return EOK; -
uspace/drv/uhci-rhd/port_status.c
r993a1e1 r7ce0fe3 2 2 #include <stdio.h> 3 3 4 #include "debug.h" 4 #include <usb/debug.h> 5 5 6 #include "port_status.h" 6 7 … … 30 31 unsigned i = 0; 31 32 for (;i < sizeof(flags)/sizeof(struct flag_name); ++i) { 32 u hci_print_verbose("\t%s status: %s.\n", flags[i].name,33 usb_log_debug("\t%s status: %s.\n", flags[i].name, 33 34 value & flags[i].flag ? "YES" : "NO"); 34 35 } -
uspace/drv/uhci-rhd/port_status.h
r993a1e1 r7ce0fe3 35 35 #define DRV_UHCI_TD_PORT_STATUS_H 36 36 37 #include <libarch/ddi.h> 37 #include <libarch/ddi.h> /* pio_read and pio_write */ 38 38 39 #include <stdint.h> 39 40 … … 59 60 60 61 static inline void port_status_write( 61 port_status_t * 62 port_status_t *address, port_status_t value) 62 63 { pio_write_16(address, value); } 63 64 -
uspace/drv/uhci-rhd/root_hub.c
r993a1e1 r7ce0fe3 6 6 7 7 #include <usb/usbdrv.h> 8 #include <usb/debug.h> 8 9 9 #include "debug.h"10 10 #include "root_hub.h" 11 11 … … 18 18 int ret; 19 19 ret = usb_drv_find_hc(rh, &instance->hc_handle); 20 u hci_print_info("rh found(%d) hc handle: %d.\n", ret, instance->hc_handle);20 usb_log_info("rh found(%d) hc handle: %d.\n", ret, instance->hc_handle); 21 21 if (ret != EOK) { 22 22 return ret; … … 27 27 //usb_drv_hc_connect(rh, instance->hc_handle, 0); 28 28 if (rh->parent_phone < 0) { 29 u hci_print_error("Failed to connect to the HC device.\n");29 usb_log_error("Failed to connect to the HC device.\n"); 30 30 return rh->parent_phone; 31 31 } … … 38 38 39 39 if (ret < 0) { 40 u hci_print_error(":Failed to gain access to port registers at %p\n", regs);40 usb_log_error("Failed to gain access to port registers at %p\n", regs); 41 41 return ret; 42 42 } -
uspace/drv/uhci-rhd/root_hub.h
r993a1e1 r7ce0fe3 52 52 uhci_root_hub_t *instance, void *addr, size_t size, device_t *rh); 53 53 54 int uhci_root_hub_fini(uhci_root_hub_t *instance);54 int uhci_root_hub_fini(uhci_root_hub_t *instance); 55 55 #endif 56 56 /**
Note:
See TracChangeset
for help on using the changeset viewer.