xencomm.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. *
  16. * Copyright (C) IBM Corp. 2006
  17. *
  18. * Authors: Hollis Blanchard <hollisb@us.ibm.com>
  19. * Jerone Young <jyoung5@us.ibm.com>
  20. */
  21. #ifndef _LINUX_XENCOMM_H_
  22. #define _LINUX_XENCOMM_H_
  23. #include <xen/interface/xencomm.h>
  24. #define XENCOMM_MINI_ADDRS 3
  25. struct xencomm_mini {
  26. struct xencomm_desc _desc;
  27. uint64_t address[XENCOMM_MINI_ADDRS];
  28. };
  29. /* To avoid additionnal virt to phys conversion, an opaque structure is
  30. presented. */
  31. struct xencomm_handle;
  32. extern void xencomm_free(struct xencomm_handle *desc);
  33. extern struct xencomm_handle *xencomm_map(void *ptr, unsigned long bytes);
  34. extern struct xencomm_handle *__xencomm_map_no_alloc(void *ptr,
  35. unsigned long bytes, struct xencomm_mini *xc_area);
  36. #if 0
  37. #define XENCOMM_MINI_ALIGNED(xc_desc, n) \
  38. struct xencomm_mini xc_desc ## _base[(n)] \
  39. __attribute__((__aligned__(sizeof(struct xencomm_mini)))); \
  40. struct xencomm_mini *xc_desc = &xc_desc ## _base[0];
  41. #else
  42. /*
  43. * gcc bug workaround:
  44. * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660
  45. * gcc doesn't handle properly stack variable with
  46. * __attribute__((__align__(sizeof(struct xencomm_mini))))
  47. */
  48. #define XENCOMM_MINI_ALIGNED(xc_desc, n) \
  49. unsigned char xc_desc ## _base[((n) + 1 ) * \
  50. sizeof(struct xencomm_mini)]; \
  51. struct xencomm_mini *xc_desc = (struct xencomm_mini *) \
  52. ((unsigned long)xc_desc ## _base + \
  53. (sizeof(struct xencomm_mini) - \
  54. ((unsigned long)xc_desc ## _base) % \
  55. sizeof(struct xencomm_mini)));
  56. #endif
  57. #define xencomm_map_no_alloc(ptr, bytes) \
  58. ({ XENCOMM_MINI_ALIGNED(xc_desc, 1); \
  59. __xencomm_map_no_alloc(ptr, bytes, xc_desc); })
  60. /* provided by architecture code: */
  61. extern unsigned long xencomm_vtop(unsigned long vaddr);
  62. static inline void *xencomm_pa(void *ptr)
  63. {
  64. return (void *)xencomm_vtop((unsigned long)ptr);
  65. }
  66. #define xen_guest_handle(hnd) ((hnd).p)
  67. #endif /* _LINUX_XENCOMM_H_ */