You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xen.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef _IPXE_XEN_H
  2. #define _IPXE_XEN_H
  3. /** @file
  4. *
  5. * Xen interface
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. /* Define Xen interface version before including any Xen header files */
  10. #define __XEN_INTERFACE_VERSION__ 0x00040400
  11. #include <stdint.h>
  12. #include <ipxe/bitops.h>
  13. #include <ipxe/uaccess.h>
  14. #include <xen/xen.h>
  15. #include <xen/event_channel.h>
  16. /* Memory barrier macros used by ring.h */
  17. #define xen_mb() mb()
  18. #define xen_rmb() rmb()
  19. #define xen_wmb() wmb()
  20. struct xen_hypercall;
  21. /** A Xen grant table */
  22. struct xen_grant {
  23. /** Grant table entries */
  24. struct grant_entry_v1 *table;
  25. /** Total grant table length */
  26. size_t len;
  27. /** Entry size shift (for later version tables) */
  28. unsigned int shift;
  29. /** Number of grant table entries in use */
  30. unsigned int used;
  31. /** Most recently used grant reference */
  32. unsigned int ref;
  33. };
  34. /** A XenStore */
  35. struct xen_store {
  36. /** XenStore domain interface */
  37. struct xenstore_domain_interface *intf;
  38. /** Event channel */
  39. evtchn_port_t port;
  40. };
  41. /** A Xen hypervisor */
  42. struct xen_hypervisor {
  43. /** Hypercall table */
  44. struct xen_hypercall *hypercall;
  45. /** Shared info page */
  46. struct shared_info *shared;
  47. /** Grant table */
  48. struct xen_grant grant;
  49. /** XenStore */
  50. struct xen_store store;
  51. };
  52. /**
  53. * Test and clear pending event
  54. *
  55. * @v xen Xen hypervisor
  56. * @v port Event channel port
  57. * @ret pending Event was pending
  58. */
  59. static inline __attribute__ (( always_inline )) int
  60. xenevent_pending ( struct xen_hypervisor *xen, evtchn_port_t port ) {
  61. return test_and_clear_bit ( port, xen->shared->evtchn_pending );
  62. }
  63. #include <bits/xen.h>
  64. /**
  65. * Convert a Xen status code to an iPXE status code
  66. *
  67. * @v xenrc Xen status code (negated)
  68. * @ret rc iPXE status code (before negation)
  69. *
  70. * Xen status codes are defined in the file include/xen/errno.h in the
  71. * Xen repository. They happen to match the Linux error codes, some
  72. * of which can be found in our include/ipxe/errno/linux.h.
  73. */
  74. #define EXEN( xenrc ) EPLATFORM ( EINFO_EPLATFORM, -(xenrc) )
  75. #endif /* _IPXE_XEN_H */