Subversion Repositories Kolibri OS

Rev

Rev 8037 | Details | Compare with Previous | Last modification | View Log | RSS feed

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