lfn
serial
ticket/834-toolchain-update
topic/msim-upgrade
topic/simplify-dev-export
Last change
on this file since d03ade7 was d03ade7, checked in by Jan Vesely <jano.vesely@…>, 14 years ago |
Enqueue transfers
Fix malloc check in uhci_add_transfer()
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | #include <errno.h>
|
---|
2 |
|
---|
3 | #include "transfer_list.h"
|
---|
4 |
|
---|
5 | int transfer_list_init(transfer_list_t *instance, transfer_list_t *next)
|
---|
6 | {
|
---|
7 | assert(instance);
|
---|
8 | instance->first = NULL;
|
---|
9 | instance->last = NULL;
|
---|
10 | instance->queue_head = trans_malloc(sizeof(queue_head_t));
|
---|
11 | if (!instance->queue_head) {
|
---|
12 | uhci_print_error("Failed to allocate queue head.\n");
|
---|
13 | return ENOMEM;
|
---|
14 | }
|
---|
15 | instance->queue_head_pa = (uintptr_t)addr_to_phys(instance->queue_head);
|
---|
16 |
|
---|
17 | uint32_t next_pa = next ? next->queue_head_pa : 0;
|
---|
18 | queue_head_init(instance->queue_head, next_pa);
|
---|
19 | return EOK;
|
---|
20 | }
|
---|
21 | /*----------------------------------------------------------------------------*/
|
---|
22 | int transfer_list_append(
|
---|
23 | transfer_list_t *instance, transfer_descriptor_t *transfer)
|
---|
24 | {
|
---|
25 | assert(instance);
|
---|
26 | assert(transfer);
|
---|
27 |
|
---|
28 | uint32_t pa = (uintptr_t)addr_to_phys(transfer);
|
---|
29 | assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
|
---|
30 |
|
---|
31 | /* empty list */
|
---|
32 | if (instance->first == NULL) {
|
---|
33 | assert(instance->last == NULL);
|
---|
34 | instance->first = instance->last = transfer;
|
---|
35 | } else {
|
---|
36 | assert(instance->last);
|
---|
37 | instance->last->next_va = transfer;
|
---|
38 |
|
---|
39 | assert(instance->last->next & LINK_POINTER_TERMINATE_FLAG);
|
---|
40 | instance->last->next = (pa & LINK_POINTER_ADDRESS_MASK);
|
---|
41 | instance->last = transfer;
|
---|
42 | }
|
---|
43 |
|
---|
44 | assert(instance->queue_head);
|
---|
45 | if (instance->queue_head->element & LINK_POINTER_TERMINATE_FLAG) {
|
---|
46 | instance->queue_head->element = (pa & LINK_POINTER_ADDRESS_MASK);
|
---|
47 | }
|
---|
48 | uhci_print_info("Successfully added transfer to the hc queue.\n");
|
---|
49 | return EOK;
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.