Changeset 6c741e1d in mainline for uspace/srv/hw/bus/usb/hcd/virtual/hub.c
- Timestamp:
- 2010-10-20T23:15:48Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
- Children:
- 34586183
- Parents:
- b8507a1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/bus/usb/hcd/virtual/hub.c
rb8507a1 r6c741e1d 140 140 .descriptors = &descriptors, 141 141 }; 142 142 143 143 hub_device_t hub_dev; 144 144 … … 147 147 size_t i; 148 148 for (i = 0; i < HUB_PORT_COUNT; i++) { 149 hub_dev.ports[i].device = NULL; 150 hub_dev.ports[i].state = HUB_PORT_STATE_NOT_CONFIGURED; 151 } 152 hub_dev.status_change_bitmap = 0; 149 hub_port_t *port = &hub_dev.ports[i]; 150 151 port->device = NULL; 152 port->state = HUB_PORT_STATE_NOT_CONFIGURED; 153 port->status_change = 0; 154 } 153 155 154 156 usbvirt_connect_local(&virthub_dev); … … 161 163 size_t i; 162 164 for (i = 0; i < HUB_PORT_COUNT; i++) { 163 if (hub_dev.ports[i].device != NULL) { 165 hub_port_t *port = &hub_dev.ports[i]; 166 167 if (port->device != NULL) { 164 168 continue; 165 169 } 166 hub_dev.ports[i].device = device; 167 // TODO - notify the host about change 168 // bad, bad but it will work somehow at least 169 hub_dev.ports[i].state = HUB_PORT_STATE_ENABLED; 170 hub_dev.status_change_bitmap |= (1 << (i+1)); 170 171 port->device = device; 172 173 /* 174 * TODO: 175 * If the hub was configured, we can normally 176 * announce the plug-in. 177 * Otherwise, we will wait until hub is configured 178 * and announce changes in single burst. 179 */ 180 //if (port->state == HUB_PORT_STATE_DISCONNECTED) { 181 port->state = HUB_PORT_STATE_DISABLED; 182 set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION); 183 //} 184 171 185 return i; 172 186 } … … 180 194 size_t i; 181 195 for (i = 0; i < HUB_PORT_COUNT; i++) { 182 if (hub_dev.ports[i].device != device) { 196 hub_port_t *port = &hub_dev.ports[i]; 197 198 if (port->device != device) { 183 199 continue; 184 200 } 185 hub_dev.ports[i].device = NULL; 186 hub_dev.ports[i].state = HUB_PORT_STATE_DISCONNECTED; 187 hub_dev.status_change_bitmap |= (1 << (i+1)); 188 // TODO - notify the host of the removal 201 202 port->device = NULL; 203 port->state = HUB_PORT_STATE_DISCONNECTED; 204 205 set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION); 189 206 } 190 207 } … … 202 219 } 203 220 221 void hub_check_port_changes(void) 222 { 223 /* FIXME - what if HUB_PORT_COUNT is greater than 8. */ 224 uint8_t change_map = 0; 225 226 size_t i; 227 for (i = 0; i < HUB_PORT_COUNT; i++) { 228 hub_port_t *port = &hub_dev.ports[i]; 229 230 if (port->status_change != 0) { 231 change_map |= (1 << (i + 1)); 232 } 233 } 234 235 /* FIXME - do not send when it has not changed since previous run. */ 236 if (change_map != 0) { 237 virthub_dev.send_data(&virthub_dev, HUB_STATUS_CHANGE_PIPE, 238 &change_map, 1); 239 } 240 } 204 241 205 242 /**
Note:
See TracChangeset
for help on using the changeset viewer.