Rev 5363 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4850 | mario79 | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5363 | yogev_ezra | 3 | ;; Copyright (C) KolibriOS team 2013-2015. All rights reserved. ;; |
4850 | mario79 | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
8 | $Revision: 8037 $ |
||
9 | |||
3520 | clevermous | 10 | ; Memory management for USB structures. |
11 | ; Protocol layer uses the common kernel heap malloc/free. |
||
12 | ; Hardware layer has special requirements: |
||
13 | ; * memory blocks should be properly aligned |
||
14 | ; * memory blocks should not cross page boundary |
||
15 | ; Hardware layer allocates fixed-size blocks. |
||
8037 | dunkaist | 16 | ; Thus, hardware layer uses the system slab allocator. |
3520 | clevermous | 17 | |
4418 | clevermous | 18 | ; Helper procedure: translate physical address in ecx |
3520 | clevermous | 19 | ; of some transfer descriptor to linear address. |
4418 | clevermous | 20 | ; in: eax = address of first page |
3520 | clevermous | 21 | proc usb_td_to_virt |
22 | ; Traverse all pages used for transfer descriptors, looking for the one |
||
23 | ; with physical address as in ecx. |
||
24 | @@: |
||
25 | test eax, eax |
||
26 | jz .zero |
||
27 | push eax |
||
28 | call get_pg_addr |
||
29 | sub eax, ecx |
||
30 | jz .found |
||
31 | cmp eax, -0x1000 |
||
32 | ja .found |
||
33 | pop eax |
||
34 | mov eax, [eax+0x1000-4] |
||
35 | jmp @b |
||
36 | .found: |
||
37 | ; When found, combine page address from eax with page offset from ecx. |
||
38 | pop eax |
||
39 | and ecx, 0xFFF |
||
40 | add eax, ecx |
||
41 | .zero: |
||
42 | ret |
||
43 | endp |