hv_driver.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. *
  14. * This header defines a wrapper interface for managing hypervisor
  15. * device calls that will result in an interrupt at some later time.
  16. * In particular, this provides wrappers for hv_preada() and
  17. * hv_pwritea().
  18. */
  19. #ifndef _ASM_TILE_HV_DRIVER_H
  20. #define _ASM_TILE_HV_DRIVER_H
  21. #include <hv/hypervisor.h>
  22. struct hv_driver_cb;
  23. /* A callback to be invoked when an operation completes. */
  24. typedef void hv_driver_callback_t(struct hv_driver_cb *cb, __hv32 result);
  25. /*
  26. * A structure to hold information about an outstanding call.
  27. * The driver must allocate a separate structure for each call.
  28. */
  29. struct hv_driver_cb {
  30. hv_driver_callback_t *callback; /* Function to call on interrupt. */
  31. void *dev; /* Driver-specific state variable. */
  32. };
  33. /* Wrapper for invoking hv_dev_preada(). */
  34. static inline int
  35. tile_hv_dev_preada(int devhdl, __hv32 flags, __hv32 sgl_len,
  36. HV_SGL sgl[/* sgl_len */], __hv64 offset,
  37. struct hv_driver_cb *callback)
  38. {
  39. return hv_dev_preada(devhdl, flags, sgl_len, sgl,
  40. offset, (HV_IntArg)callback);
  41. }
  42. /* Wrapper for invoking hv_dev_pwritea(). */
  43. static inline int
  44. tile_hv_dev_pwritea(int devhdl, __hv32 flags, __hv32 sgl_len,
  45. HV_SGL sgl[/* sgl_len */], __hv64 offset,
  46. struct hv_driver_cb *callback)
  47. {
  48. return hv_dev_pwritea(devhdl, flags, sgl_len, sgl,
  49. offset, (HV_IntArg)callback);
  50. }
  51. #endif /* _ASM_TILE_HV_DRIVER_H */