2014-04-17 23:19:45 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2015-01-08 21:10:22 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2013-2015. All rights reserved. ;;
|
2014-04-17 23:19:45 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
2013-05-18 01:53:28 +02:00
|
|
|
; Memory management for USB structures.
|
|
|
|
; Protocol layer uses the common kernel heap malloc/free.
|
|
|
|
; Hardware layer has special requirements:
|
|
|
|
; * memory blocks should be properly aligned
|
|
|
|
; * memory blocks should not cross page boundary
|
|
|
|
; Hardware layer allocates fixed-size blocks.
|
2020-06-11 15:23:44 +02:00
|
|
|
; Thus, hardware layer uses the system slab allocator.
|
2013-05-18 01:53:28 +02:00
|
|
|
|
2013-12-30 12:18:33 +01:00
|
|
|
; Helper procedure: translate physical address in ecx
|
2013-05-18 01:53:28 +02:00
|
|
|
; of some transfer descriptor to linear address.
|
2013-12-30 12:18:33 +01:00
|
|
|
; in: eax = address of first page
|
2013-05-18 01:53:28 +02:00
|
|
|
proc usb_td_to_virt
|
|
|
|
; Traverse all pages used for transfer descriptors, looking for the one
|
|
|
|
; with physical address as in ecx.
|
|
|
|
@@:
|
|
|
|
test eax, eax
|
|
|
|
jz .zero
|
|
|
|
push eax
|
|
|
|
call get_pg_addr
|
|
|
|
sub eax, ecx
|
|
|
|
jz .found
|
|
|
|
cmp eax, -0x1000
|
|
|
|
ja .found
|
|
|
|
pop eax
|
|
|
|
mov eax, [eax+0x1000-4]
|
|
|
|
jmp @b
|
|
|
|
.found:
|
|
|
|
; When found, combine page address from eax with page offset from ecx.
|
|
|
|
pop eax
|
|
|
|
and ecx, 0xFFF
|
|
|
|
add eax, ecx
|
|
|
|
.zero:
|
|
|
|
ret
|
|
|
|
endp
|