Subversion Repositories Kolibri OS

Rev

Rev 5363 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2013-2015. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 8037 $
  9.  
  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.
  16. ; Thus, hardware layer uses the system slab allocator.
  17.  
  18. ; Helper procedure: translate physical address in ecx
  19. ; of some transfer descriptor to linear address.
  20. ; in: eax = address of first page
  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
  44.