grant-table.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /******************************************************************************
  2. * arch/ia64/xen/grant-table.c
  3. *
  4. * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
  5. * VA Linux Systems Japan K.K.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #include <linux/module.h>
  23. #include <linux/vmalloc.h>
  24. #include <linux/slab.h>
  25. #include <linux/mm.h>
  26. #include <xen/interface/xen.h>
  27. #include <xen/interface/memory.h>
  28. #include <xen/grant_table.h>
  29. #include <asm/xen/hypervisor.h>
  30. /****************************************************************************
  31. * grant table hack
  32. * cmd: GNTTABOP_xxx
  33. */
  34. int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes,
  35. unsigned long max_nr_gframes,
  36. struct grant_entry **__shared)
  37. {
  38. *__shared = __va(frames[0] << PAGE_SHIFT);
  39. return 0;
  40. }
  41. void arch_gnttab_unmap_shared(struct grant_entry *shared,
  42. unsigned long nr_gframes)
  43. {
  44. /* nothing */
  45. }
  46. static void
  47. gnttab_map_grant_ref_pre(struct gnttab_map_grant_ref *uop)
  48. {
  49. uint32_t flags;
  50. flags = uop->flags;
  51. if (flags & GNTMAP_host_map) {
  52. if (flags & GNTMAP_application_map) {
  53. printk(KERN_DEBUG
  54. "GNTMAP_application_map is not supported yet: "
  55. "flags 0x%x\n", flags);
  56. BUG();
  57. }
  58. if (flags & GNTMAP_contains_pte) {
  59. printk(KERN_DEBUG
  60. "GNTMAP_contains_pte is not supported yet: "
  61. "flags 0x%x\n", flags);
  62. BUG();
  63. }
  64. } else if (flags & GNTMAP_device_map) {
  65. printk("GNTMAP_device_map is not supported yet 0x%x\n", flags);
  66. BUG(); /* not yet. actually this flag is not used. */
  67. } else {
  68. BUG();
  69. }
  70. }
  71. int
  72. HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count)
  73. {
  74. if (cmd == GNTTABOP_map_grant_ref) {
  75. unsigned int i;
  76. for (i = 0; i < count; i++) {
  77. gnttab_map_grant_ref_pre(
  78. (struct gnttab_map_grant_ref *)uop + i);
  79. }
  80. }
  81. return xencomm_hypercall_grant_table_op(cmd, uop, count);
  82. }
  83. EXPORT_SYMBOL(HYPERVISOR_grant_table_op);