Changeset 0b749a3 in mainline for uspace/drv/vhc/hcd.c
- Timestamp:
- 2010-11-22T15:39:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eddb76, aae339e9
- Parents:
- 9a1d8ab (diff), 8cd1aa5e (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hcd.c
r9a1d8ab r0b749a3 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2010 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup net29 /** @addtogroup usb 30 30 * @{ 31 */ 32 /** @file 33 * @brief Virtual host controller driver. 31 34 */ 32 35 33 /** @file 34 * 35 * Start the networking subsystem. 36 * Perform networking self-test if executed 37 * with the -s argument. 38 * 39 */ 36 #include <devmap.h> 37 #include <ipc/ipc.h> 38 #include <async.h> 39 #include <unistd.h> 40 #include <stdlib.h> 41 #include <sysinfo.h> 42 #include <stdio.h> 43 #include <errno.h> 44 #include <str_error.h> 45 #include <driver.h> 40 46 41 #define NAME "netstart" 47 #include <usb/usb.h> 48 #include "vhcd.h" 49 #include "hc.h" 50 #include "devices.h" 51 #include "hub.h" 52 #include "conn.h" 42 53 43 #include <async.h>44 #include <stdio.h>45 #include <task.h>46 #include <str_error.h>47 #include <ipc/ipc.h>48 #include <ipc/services.h>49 54 50 #include <net_err.h> 51 #include <net_modules.h> 52 #include <net_net_messages.h> 55 static int vhc_count = 0; 56 static int vhc_add_device(usb_hc_device_t *dev) 57 { 58 /* 59 * Currently, we know how to simulate only single HC. 60 */ 61 if (vhc_count > 0) { 62 return ELIMIT; 63 } 53 64 54 #include "self_test.h" 65 vhc_count++; 55 66 56 /** Start a module. 57 * 58 * @param[in] desc The module description 59 * @param[in] path The module absolute path. 60 * 61 * @returns true on succesful spanwning 62 * @returns false on failure 63 * 64 */ 65 static bool spawn(const char *desc, const char *path) 66 { 67 printf("%s: Spawning %s (%s)\n", NAME, desc, path); 68 69 const char *argv[2]; 70 71 argv[0] = path; 72 argv[1] = NULL; 73 74 int err; 75 if (task_spawn(path, argv, &err) == 0) { 76 fprintf(stderr, "%s: Error spawning %s (%s)\n", NAME, path, 77 str_error(err)); 78 return false; 79 } 80 81 return true; 82 } 67 dev->transfer_ops = &vhc_transfer_ops; 68 dev->generic->ops->default_handler = default_connection_handler; 83 69 84 int main(int argc, char *argv[]) 85 { 86 ERROR_DECLARE; 87 88 /* Run self-tests */ 89 if ((argc > 1) && (str_cmp(argv[1], "-s") == 0)) 90 ERROR_PROPAGATE(self_test()); 91 92 if (!spawn("networking service", "/srv/net")) 93 return EINVAL; 94 95 printf("%s: Initializing networking\n", NAME); 96 97 int net_phone = connect_to_service(SERVICE_NETWORKING); 98 if (ERROR_OCCURRED(ipc_call_sync_0_0(net_phone, NET_NET_STARTUP))) { 99 fprintf(stderr, "%s: Startup error %d\n", NAME, ERROR_CODE); 100 return ERROR_CODE; 101 } 102 70 /* 71 * Initialize our hub and announce its presence. 72 */ 73 hub_init(); 74 usb_hcd_add_root_hub(dev); 75 76 printf("%s: virtual USB host controller ready.\n", NAME); 77 103 78 return EOK; 104 79 } 105 80 106 /** @} 81 static usb_hc_driver_t vhc_driver = { 82 .name = NAME, 83 .add_hc = &vhc_add_device 84 }; 85 86 /** Fibril wrapper for HC transaction manager. 87 * 88 * @param arg Not used. 89 * @return Nothing, return argument is unreachable. 107 90 */ 91 static int hc_manager_fibril(void *arg) 92 { 93 hc_manager(); 94 return EOK; 95 } 96 97 int main(int argc, char * argv[]) 98 { 99 printf("%s: virtual USB host controller driver.\n", NAME); 100 101 debug_level = 10; 102 103 fid_t fid = fibril_create(hc_manager_fibril, NULL); 104 if (fid == 0) { 105 printf("%s: failed to start HC manager fibril\n", NAME); 106 return ENOMEM; 107 } 108 fibril_add_ready(fid); 109 110 /* 111 * Temporary workaround. Wait a little bit to be the last driver 112 * in devman output. 113 */ 114 sleep(4); 115 116 return usb_hcd_main(&vhc_driver); 117 } 118 119 120 /** 121 * @} 122 */
Note:
See TracChangeset
for help on using the changeset viewer.