xen.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2007-2011 Free Software Foundation
  3. *
  4. * This program is free software ; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation ; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY ; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with the program ; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <sys/types.h>
  19. #include <string.h>
  20. #include <mach/xen.h>
  21. #include <machine/xen.h>
  22. #include <machine/ipl.h>
  23. #include <xen/block.h>
  24. #include <xen/console.h>
  25. #include <xen/grant.h>
  26. #include <xen/net.h>
  27. #include <xen/store.h>
  28. #include <xen/time.h>
  29. #include "xen.h"
  30. #include "evt.h"
  31. void hyp_debug()
  32. {
  33. panic("debug");
  34. }
  35. void hyp_init(void)
  36. {
  37. hyp_grant_init();
  38. hyp_store_init();
  39. evtchn_port_t port = hyp_event_channel_bind_virq(VIRQ_DEBUG, 0);
  40. hyp_evt_handler(port, hyp_debug, 0, SPL7);
  41. }
  42. void hyp_dev_init(void)
  43. {
  44. /* these depend on hyp_init() and working threads */
  45. hyp_block_init();
  46. hyp_net_init();
  47. }
  48. void _hyp_halt(void)
  49. {
  50. hyp_halt();
  51. }
  52. void _hyp_todo(unsigned long from)
  53. {
  54. printf("TODO: at %lx\n",from);
  55. hyp_halt();
  56. }
  57. extern int int_mask[];
  58. void hyp_idle(void)
  59. {
  60. int cpu = 0;
  61. hyp_shared_info.vcpu_info[cpu].evtchn_upcall_mask = 0xff;
  62. barrier();
  63. /* Avoid blocking if there are pending events */
  64. if (!hyp_shared_info.vcpu_info[cpu].evtchn_upcall_pending &&
  65. !hyp_shared_info.evtchn_pending[cpu])
  66. hyp_block();
  67. while (1) {
  68. hyp_shared_info.vcpu_info[cpu].evtchn_upcall_mask = 0x00;
  69. barrier();
  70. if (!hyp_shared_info.vcpu_info[cpu].evtchn_upcall_pending &&
  71. !hyp_shared_info.evtchn_pending[cpu])
  72. /* Didn't miss any event, can return to threads. */
  73. break;
  74. hyp_shared_info.vcpu_info[cpu].evtchn_upcall_mask = 0xff;
  75. hyp_c_callback(NULL,NULL);
  76. }
  77. }