Changeset d70765d in mainline
- Timestamp:
- 2011-03-26T00:15:35Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cd1e6b62, ea696998
- Parents:
- b3f655f (diff), 9a2923d (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. - Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
rb3f655f rd70765d 554 554 % Polling UHCI & OHCI (no interrupts) 555 555 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (y/n) 556 557 % Run devman in kconsole (not recommended) 558 ! CONFIG_DEVMAN_EARLY_LAUNCH (n/y) 559 -
uspace/app/init/init.c
rb3f655f rd70765d 288 288 289 289 spawn("/srv/clip"); 290 291 #ifdef CONFIG_DEVMAN_EARLY_LAUNCH 292 spawn("/srv/devman"); 293 #endif 290 294 291 295 /* … … 313 317 getterm("term/vc5", "/app/bdsh", false); 314 318 getterm("term/vc6", "/app/klog", false); 319 320 #ifndef CONFIG_DEVMAN_EARLY_LAUNCH 315 321 getterm("term/vc7", "/srv/devman", false); 316 322 #endif 323 317 324 return 0; 318 325 } -
uspace/app/klog/klog.c
rb3f655f rd70765d 44 44 #include <io/klog.h> 45 45 #include <sysinfo.h> 46 #include <fibril_synch.h> 46 47 47 48 #define NAME "klog" … … 54 55 static FILE *log; 55 56 57 /* Serialize the output a bit. This will not avoid messed-up log completely 58 but chances for are pretty high (experimentally confirmed). */ 59 static FIBRIL_MUTEX_INITIALIZE(log_mutex); 60 56 61 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call) 57 62 { 63 fibril_mutex_lock(&log_mutex); 64 58 65 size_t klog_start = (size_t) IPC_GET_ARG1(*call); 59 66 size_t klog_len = (size_t) IPC_GET_ARG2(*call); … … 74 81 fsync(fileno(log)); 75 82 } 83 84 fibril_mutex_unlock(&log_mutex); 76 85 } 77 86 -
uspace/drv/usbmid/explore.c
rb3f655f rd70765d 40 40 #include <usb/request.h> 41 41 #include <usb/dp.h> 42 #include <usb/ddfiface.h> 42 43 #include "usbmid.h" 44 45 /** Operations of the device itself. */ 46 static ddf_dev_ops_t mid_device_ops = { 47 .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl 48 }; 43 49 44 50 /** Find starting indexes of all interface descriptors in a configuration. … … 105 111 * @return Whether to accept this device from devman. 106 112 */ 107 bool usbmid_explore_device(usb mid_device_t *dev)113 bool usbmid_explore_device(usb_device_t *dev) 108 114 { 109 usb_standard_device_descriptor_t device_descriptor; 110 int rc = usb_request_get_device_descriptor(&dev->ctrl_pipe, 111 &device_descriptor); 112 if (rc != EOK) { 113 usb_log_error("Getting device descriptor failed: %s.\n", 114 str_error(rc)); 115 return false; 116 } 117 118 if (device_descriptor.device_class != USB_CLASS_USE_INTERFACE) { 115 int rc; 116 117 int dev_class = dev->descriptors.device.device_class; 118 if (dev_class != USB_CLASS_USE_INTERFACE) { 119 119 usb_log_warning( 120 120 "Device class: %d (%s), but expected class 0.\n", 121 device_descriptor.device_class, 122 usb_str_class(device_descriptor.device_class)); 121 dev_class, usb_str_class(dev_class)); 123 122 usb_log_error("Not multi interface device, refusing.\n"); 124 123 return false; 125 124 } 126 125 127 size_t config_descriptor_size; 128 uint8_t *config_descriptor_raw = NULL; 129 rc = usb_request_get_full_configuration_descriptor_alloc( 130 &dev->ctrl_pipe, 0, 131 (void **) &config_descriptor_raw, &config_descriptor_size); 132 if (rc != EOK) { 133 usb_log_error("Failed getting full config descriptor: %s.\n", 134 str_error(rc)); 135 return false; 136 } 137 138 usb_standard_configuration_descriptor_t *config_descriptor 139 = (usb_standard_configuration_descriptor_t *) config_descriptor_raw; 126 /* Short cuts to save on typing ;-). */ 127 uint8_t *config_descriptor_raw = dev->descriptors.configuration; 128 size_t config_descriptor_size = dev->descriptors.configuration_size; 129 usb_standard_configuration_descriptor_t *config_descriptor = 130 (usb_standard_configuration_descriptor_t *) config_descriptor_raw; 140 131 141 132 size_t *interface_descriptors … … 154 145 if (interface_descriptors_count == (size_t) -1) { 155 146 usb_log_error("Problem parsing configuration descriptor.\n"); 156 free(config_descriptor_raw);157 147 free(interface_descriptors); 158 148 return false; … … 165 155 usb_log_error("Failed to set device configuration: %s.\n", 166 156 str_error(rc)); 167 free(config_descriptor_raw);168 157 free(interface_descriptors); 169 158 return false; … … 172 161 173 162 /* Create control function */ 174 ddf_fun_t *ctl_fun = ddf_fun_create(dev->d ev, fun_exposed, "ctl");163 ddf_fun_t *ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl"); 175 164 if (ctl_fun == NULL) { 176 165 usb_log_error("Failed to create control function.\n"); 177 free(config_descriptor_raw); 178 free(interface_descriptors); 179 return false; 180 } 166 free(interface_descriptors); 167 return false; 168 } 169 170 ctl_fun->ops = &mid_device_ops; 171 181 172 rc = ddf_fun_bind(ctl_fun); 182 173 if (rc != EOK) { 183 174 usb_log_error("Failed to bind control function: %s.\n", 184 175 str_error(rc)); 185 free(config_descriptor_raw);186 176 free(interface_descriptors); 187 177 return false; … … 199 189 (int) interface->interface_number, 200 190 usb_str_class(interface->interface_class)); 201 rc = usbmid_spawn_interface_child(dev, &dev ice_descriptor,191 rc = usbmid_spawn_interface_child(dev, &dev->descriptors.device, 202 192 interface); 203 193 if (rc != EOK) { … … 207 197 } 208 198 209 free(config_descriptor_raw);210 211 199 return true; 212 200 } -
uspace/drv/usbmid/main.c
rb3f655f rd70765d 49 49 * @return Error code. 50 50 */ 51 static int usbmid_add_device( ddf_dev_t *gen_dev)51 static int usbmid_add_device(usb_device_t *dev) 52 52 { 53 usbmid_device_t *dev = usbmid_device_create(gen_dev); 54 if (dev == NULL) { 55 return ENOMEM; 56 } 57 58 usb_log_info("Taking care of new MID: addr %d (HC %zu)\n", 59 dev->wire.address, dev->wire.hc_handle); 53 usb_log_info("Taking care of new MID `%s'.\n", dev->ddf_dev->name); 60 54 61 55 int rc; … … 65 59 usb_log_error("Failed to start session on control pipe: %s.\n", 66 60 str_error(rc)); 67 goto error_leave;61 return rc; 68 62 } 69 63 … … 77 71 78 72 if (!accept) { 79 rc = ENOTSUP; 80 goto error_leave; 73 return ENOTSUP; 81 74 } 82 75 83 gen_dev->driver_data = dev;84 85 76 return EOK; 86 87 88 error_leave:89 free(dev);90 return rc;91 77 } 92 78 93 79 /** USB MID driver ops. */ 94 static driver_ops_t mid_driver_ops = {80 static usb_driver_ops_t mid_driver_ops = { 95 81 .add_device = usbmid_add_device, 96 82 }; 97 83 98 84 /** USB MID driver. */ 99 static driver_t mid_driver = {85 static usb_driver_t mid_driver = { 100 86 .name = NAME, 101 .driver_ops = &mid_driver_ops 87 .ops = &mid_driver_ops, 88 .endpoints = NULL 102 89 }; 103 90 … … 107 94 108 95 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 109 return ddf_driver_main(&mid_driver); 96 97 return usb_driver_main(&mid_driver); 110 98 } 111 99 -
uspace/drv/usbmid/usbmid.c
rb3f655f rd70765d 79 79 }; 80 80 81 /** Operations of the device itself. */82 static ddf_dev_ops_t mid_device_ops = {83 .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl84 };85 86 /** Create new USB multi interface device.87 *88 * @param dev Backing generic DDF device.89 * @return New USB MID device.90 * @retval NULL Error occured.91 */92 usbmid_device_t *usbmid_device_create(ddf_dev_t *dev)93 {94 usbmid_device_t *mid = malloc(sizeof(usbmid_device_t));95 if (mid == NULL) {96 usb_log_error("Out of memory (wanted %zu bytes).\n",97 sizeof(usbmid_device_t));98 return NULL;99 }100 101 int rc;102 rc = usb_device_connection_initialize_from_device(&mid->wire, dev);103 if (rc != EOK) {104 usb_log_error("Failed to initialize `USB wire': %s.\n",105 str_error(rc));106 free(mid);107 return NULL;108 }109 110 rc = usb_pipe_initialize_default_control(&mid->ctrl_pipe,111 &mid->wire);112 if (rc != EOK) {113 usb_log_error("Failed to initialize control pipe: %s.\n",114 str_error(rc));115 free(mid);116 return NULL;117 }118 rc = usb_pipe_probe_default_control(&mid->ctrl_pipe);119 if (rc != EOK) {120 usb_log_error("Probing default control pipe failed: %s.\n",121 str_error(rc));122 free(mid);123 return NULL;124 }125 126 mid->dev = dev;127 (void) &mid_device_ops;128 129 return mid;130 }131 132 81 /** Create new interface for USB MID device. 133 82 * … … 160 109 * @return Error code. 161 110 */ 162 int usbmid_spawn_interface_child(usb mid_device_t *parent,111 int usbmid_spawn_interface_child(usb_device_t *parent, 163 112 const usb_standard_device_descriptor_t *device_descriptor, 164 113 const usb_standard_interface_descriptor_t *interface_descriptor) … … 182 131 183 132 /* Create the device. */ 184 child = ddf_fun_create(parent->d ev, fun_inner, child_name);133 child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name); 185 134 if (child == NULL) { 186 135 rc = ENOMEM; -
uspace/drv/usbmid/usbmid.h
rb3f655f rd70765d 41 41 #include <usb/pipes.h> 42 42 #include <usb/debug.h> 43 #include <usb/devdrv.h> 43 44 44 45 #define NAME "usbmid" 45 46 /** USB MID device container. */47 typedef struct {48 /** Device container. */49 ddf_dev_t *dev;50 51 /** Representation of USB wire. */52 usb_device_connection_t wire;53 /** Default control pipe. */54 usb_pipe_t ctrl_pipe;55 } usbmid_device_t;56 57 46 58 47 /** Container for single interface in a MID device. */ … … 65 54 } usbmid_interface_t; 66 55 67 usbmid_device_t *usbmid_device_create(ddf_dev_t *);68 56 usbmid_interface_t *usbmid_interface_create(ddf_fun_t *, int); 69 bool usbmid_explore_device(usb mid_device_t *);70 int usbmid_spawn_interface_child(usb mid_device_t *,57 bool usbmid_explore_device(usb_device_t *); 58 int usbmid_spawn_interface_child(usb_device_t *, 71 59 const usb_standard_device_descriptor_t *, 72 60 const usb_standard_interface_descriptor_t *);
Note:
See TracChangeset
for help on using the changeset viewer.