Changeset b8d453ec in mainline
- Timestamp:
- 2011-03-25T17:18:46Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9a2923d
- Parents:
- da3dafc (diff), 095b2017 (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:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/as.c
rda3dafc rb8d453ec 1949 1949 sysarg_t sys_as_area_create(uintptr_t address, size_t size, unsigned int flags) 1950 1950 { 1951 if (as_area_create(AS, flags | AS_AREA_CACHEABLE, size, address,1951 if (as_area_create(AS, flags, size, address, 1952 1952 AS_AREA_ATTR_NONE, &anon_backend, NULL)) 1953 1953 return (sysarg_t) address; -
uspace/drv/uhci-hcd/Makefile
rda3dafc rb8d453ec 40 40 root_hub.c \ 41 41 hw_struct/transfer_descriptor.c \ 42 utils/slab.c \ 42 43 pci.c \ 43 44 batch.c -
uspace/drv/uhci-hcd/hc.c
rda3dafc rb8d453ec 223 223 ret = instance ? EOK : ENOMEM; 224 224 CHECK_RET_DEST_CMDS_RETURN(ret, "Failed to get frame list page.\n"); 225 usb_log_debug("Initialized frame list .\n");225 usb_log_debug("Initialized frame list at %p.\n", instance->frame_list); 226 226 227 227 /* Set all frames to point to the first queue head */ … … 336 336 instance->transfers[batch->speed][batch->transfer_type]; 337 337 assert(list); 338 if (batch->transfer_type == USB_TRANSFER_CONTROL) { 339 usb_device_keeper_use_control( 340 &instance->manager, batch->target.address); 341 } 338 342 transfer_list_add_batch(list, batch); 339 343 … … 357 361 /* Lower 2 bits are transaction error and transaction complete */ 358 362 if (status & 0x3) { 359 transfer_list_remove_finished(&instance->transfers_interrupt); 360 transfer_list_remove_finished(&instance->transfers_control_slow); 361 transfer_list_remove_finished(&instance->transfers_control_full); 362 transfer_list_remove_finished(&instance->transfers_bulk_full); 363 LIST_INITIALIZE(done); 364 transfer_list_remove_finished( 365 &instance->transfers_interrupt, &done); 366 transfer_list_remove_finished( 367 &instance->transfers_control_slow, &done); 368 transfer_list_remove_finished( 369 &instance->transfers_control_full, &done); 370 transfer_list_remove_finished( 371 &instance->transfers_bulk_full, &done); 372 373 while (!list_empty(&done)) { 374 link_t *item = done.next; 375 list_remove(item); 376 usb_transfer_batch_t *batch = 377 list_get_instance(item, usb_transfer_batch_t, link); 378 if (batch->transfer_type == USB_TRANSFER_CONTROL) { 379 usb_device_keeper_release_control( 380 &instance->manager, batch->target.address); 381 } 382 batch->next_step(batch); 383 } 363 384 } 364 385 /* bits 4 and 5 indicate hc error */ -
uspace/drv/uhci-hcd/transfer_list.c
rda3dafc rb8d453ec 58 58 } 59 59 instance->queue_head_pa = addr_to_phys(instance->queue_head); 60 usb_log_debug2("Transfer list %s setup with QH: %p(%p).\n", 61 name, instance->queue_head, instance->queue_head_pa); 60 62 61 63 qh_init(instance->queue_head); … … 118 120 qh_set_next_qh(last_qh, pa); 119 121 122 asm volatile ("": : :"memory"); 123 120 124 /* Add to the driver list */ 121 125 list_append(&batch->link, &instance->batch_list); … … 137 141 * this transfer list leading to the deadlock if its done inline. 138 142 */ 139 void transfer_list_remove_finished(transfer_list_t *instance) 140 { 141 assert(instance); 142 143 LIST_INITIALIZE(done); 143 void transfer_list_remove_finished(transfer_list_t *instance, link_t *done) 144 { 145 assert(instance); 146 assert(done); 144 147 145 148 fibril_mutex_lock(&instance->guard); … … 153 156 /* Save for post-processing */ 154 157 transfer_list_remove_batch(instance, batch); 155 list_append(current, &done);158 list_append(current, done); 156 159 } 157 160 current = next; … … 159 162 fibril_mutex_unlock(&instance->guard); 160 163 161 while (!list_empty(&done)) {162 link_t *item = done.next;163 list_remove(item);164 usb_transfer_batch_t *batch =165 list_get_instance(item, usb_transfer_batch_t, link);166 batch->next_step(batch);167 }168 164 } 169 165 /*----------------------------------------------------------------------------*/ … … 222 218 qpos = "NOT FIRST"; 223 219 } 220 asm volatile ("": : :"memory"); 224 221 /* Remove from the batch list */ 225 222 list_remove(&batch->link); -
uspace/drv/uhci-hcd/transfer_list.h
rda3dafc rb8d453ec 67 67 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch); 68 68 69 void transfer_list_remove_finished(transfer_list_t *instance );69 void transfer_list_remove_finished(transfer_list_t *instance, link_t *done); 70 70 71 71 void transfer_list_abort_all(transfer_list_t *instance); -
uspace/drv/uhci-hcd/utils/malloc32.h
rda3dafc rb8d453ec 40 40 #include <as.h> 41 41 42 #include "slab.h" 43 42 44 #define UHCI_STRCUTURES_ALIGNMENT 16 43 45 #define UHCI_REQUIRED_PAGE_SIZE 4096 46 44 47 45 48 /** Get physical address translation … … 54 57 55 58 uintptr_t result; 56 int ret = as_get_physical_mapping(addr, &result); 59 const int ret = as_get_physical_mapping(addr, &result); 60 assert(ret == EOK); 57 61 58 62 if (ret != EOK) … … 66 70 * @return Address of the alligned and big enough memory place, NULL on failure. 67 71 */ 68 static inline void * malloc32(size_t size) 69 { return memalign(UHCI_STRCUTURES_ALIGNMENT, size); } 72 static inline void * malloc32(size_t size) { 73 if (size <= SLAB_ELEMENT_SIZE) 74 return slab_malloc_g(); 75 assert(false); 76 return memalign(UHCI_STRCUTURES_ALIGNMENT, size); 77 } 70 78 /*----------------------------------------------------------------------------*/ 71 79 /** Physical mallocator simulator … … 73 81 * @param[in] addr Address of the place allocated by malloc32 74 82 */ 75 static inline void free32(void *addr) 76 { if (addr) free(addr); } 83 static inline void free32(void *addr) { 84 if (!addr) 85 return; 86 if (slab_in_range_g(addr)) 87 return slab_free_g(addr); 88 free(addr); 89 } 77 90 /*----------------------------------------------------------------------------*/ 78 91 /** Create 4KB page mapping … … 82 95 static inline void * get_page(void) 83 96 { 84 void * 85 assert(free_address); 97 void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 98 assert(free_address); /* TODO: remove this assert */ 86 99 if (free_address == 0) 87 100 return NULL; 88 void* ret = 89 as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE, 101 void *ret = as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE, 90 102 AS_AREA_READ | AS_AREA_WRITE); 91 103 if (ret != free_address) -
uspace/lib/c/generic/malloc.c
rda3dafc rb8d453ec 240 240 size_t asize = ALIGN_UP(size, PAGE_SIZE); 241 241 242 astart = as_area_create(astart, asize, AS_AREA_WRITE | AS_AREA_READ );242 astart = as_area_create(astart, asize, AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE); 243 243 if (astart == (void *) -1) 244 244 return false; -
uspace/lib/usb/include/usb/host/device_keeper.h
rda3dafc rb8d453ec 51 51 usb_speed_t speed; 52 52 bool occupied; 53 bool control_used; 53 54 uint16_t toggle_status[2]; 54 55 devman_handle_t handle; … … 61 62 struct usb_device_info devices[USB_ADDRESS_COUNT]; 62 63 fibril_mutex_t guard; 63 fibril_condvar_t default_address_occupied;64 fibril_condvar_t change; 64 65 usb_address_t last_address; 65 66 } usb_device_keeper_t; … … 97 98 usb_address_t address); 98 99 100 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 101 usb_address_t address); 102 103 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 104 usb_address_t address); 105 99 106 #endif 100 107 /** -
uspace/lib/usb/src/host/device_keeper.c
rda3dafc rb8d453ec 49 49 assert(instance); 50 50 fibril_mutex_initialize(&instance->guard); 51 fibril_condvar_initialize(&instance-> default_address_occupied);51 fibril_condvar_initialize(&instance->change); 52 52 instance->last_address = 0; 53 53 unsigned i = 0; 54 54 for (; i < USB_ADDRESS_COUNT; ++i) { 55 55 instance->devices[i].occupied = false; 56 instance->devices[i].control_used = false; 56 57 instance->devices[i].handle = 0; 57 58 instance->devices[i].toggle_status[0] = 0; … … 71 72 fibril_mutex_lock(&instance->guard); 72 73 while (instance->devices[USB_ADDRESS_DEFAULT].occupied) { 73 fibril_condvar_wait(&instance->default_address_occupied, 74 &instance->guard); 74 fibril_condvar_wait(&instance->change, &instance->guard); 75 75 } 76 76 instance->devices[USB_ADDRESS_DEFAULT].occupied = true; … … 90 90 instance->devices[USB_ADDRESS_DEFAULT].occupied = false; 91 91 fibril_mutex_unlock(&instance->guard); 92 fibril_condvar_signal(&instance-> default_address_occupied);92 fibril_condvar_signal(&instance->change); 93 93 } 94 94 /*----------------------------------------------------------------------------*/ … … 309 309 return instance->devices[address].speed; 310 310 } 311 311 /*----------------------------------------------------------------------------*/ 312 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 313 usb_address_t address) 314 { 315 assert(instance); 316 fibril_mutex_lock(&instance->guard); 317 while (instance->devices[address].control_used) { 318 fibril_condvar_wait(&instance->change, &instance->guard); 319 } 320 instance->devices[address].control_used = true; 321 fibril_mutex_unlock(&instance->guard); 322 } 323 /*----------------------------------------------------------------------------*/ 324 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 325 usb_address_t address) 326 { 327 assert(instance); 328 fibril_mutex_lock(&instance->guard); 329 instance->devices[address].control_used = false; 330 fibril_mutex_unlock(&instance->guard); 331 fibril_condvar_signal(&instance->change); 332 } 312 333 /** 313 334 * @}
Note:
See TracChangeset
for help on using the changeset viewer.