ctvmem.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
  3. *
  4. * This source file is released under GPL v2 license (no other versions).
  5. * See the COPYING file included in the main directory of this source
  6. * distribution for the license terms and conditions.
  7. *
  8. * @File ctvmem.h
  9. *
  10. * @Brief
  11. * This file contains the definition of virtual memory management object
  12. * for card device.
  13. *
  14. * @Author Liu Chun
  15. * @Date Mar 28 2008
  16. */
  17. #ifndef CTVMEM_H
  18. #define CTVMEM_H
  19. #define CT_PTP_NUM 1 /* num of device page table pages */
  20. #include <linux/mutex.h>
  21. #include <linux/list.h>
  22. struct ct_vm_block {
  23. unsigned int addr; /* starting logical addr of this block */
  24. unsigned int size; /* size of this device virtual mem block */
  25. struct list_head list;
  26. };
  27. /* Virtual memory management object for card device */
  28. struct ct_vm {
  29. void *ptp[CT_PTP_NUM]; /* Device page table pages */
  30. unsigned int size; /* Available addr space in bytes */
  31. struct list_head unused; /* List of unused blocks */
  32. struct list_head used; /* List of used blocks */
  33. struct mutex lock;
  34. /* Map host addr (kmalloced/vmalloced) to device logical addr. */
  35. struct ct_vm_block *(*map)(struct ct_vm *, void *host_addr, int size);
  36. /* Unmap device logical addr area. */
  37. void (*unmap)(struct ct_vm *, struct ct_vm_block *block);
  38. void *(*get_ptp_virt)(struct ct_vm *vm, int index);
  39. };
  40. int ct_vm_create(struct ct_vm **rvm);
  41. void ct_vm_destroy(struct ct_vm *vm);
  42. #endif /* CTVMEM_H */