init.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2009,2010 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <grub/kernel.h>
  19. #include <grub/misc.h>
  20. #include <grub/env.h>
  21. #include <grub/time.h>
  22. #include <grub/types.h>
  23. #include <grub/misc.h>
  24. #include <grub/mm.h>
  25. #include <grub/time.h>
  26. #include <grub/machine/kernel.h>
  27. #include <grub/machine/memory.h>
  28. #include <grub/cpu/kernel.h>
  29. extern void grub_video_sm712_init (void);
  30. extern void grub_video_init (void);
  31. extern void grub_bitmap_init (void);
  32. extern void grub_font_init (void);
  33. extern void grub_gfxterm_init (void);
  34. extern void grub_at_keyboard_init (void);
  35. /* FIXME: use interrupt to count high. */
  36. grub_uint64_t
  37. grub_get_rtc (void)
  38. {
  39. static grub_uint32_t high = 0;
  40. static grub_uint32_t last = 0;
  41. grub_uint32_t low;
  42. asm volatile ("mfc0 %0, $9": "=r" (low));
  43. if (low < last)
  44. high++;
  45. last = low;
  46. return (((grub_uint64_t) high) << 32) | low;
  47. }
  48. grub_err_t
  49. grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
  50. grub_uint64_t,
  51. grub_uint32_t))
  52. {
  53. hook (GRUB_ARCH_LOWMEMPSTART, grub_arch_memsize << 20,
  54. GRUB_MACHINE_MEMORY_AVAILABLE);
  55. hook (GRUB_ARCH_HIGHMEMPSTART, grub_arch_highmemsize << 20,
  56. GRUB_MACHINE_MEMORY_AVAILABLE);
  57. return GRUB_ERR_NONE;
  58. }
  59. void
  60. grub_machine_init (void)
  61. {
  62. grub_addr_t modend;
  63. modend = grub_modules_get_end ();
  64. grub_mm_init_region ((void *) modend, (grub_arch_memsize << 20)
  65. - (modend - GRUB_ARCH_LOWMEMVSTART));
  66. /* FIXME: use upper memory as well. */
  67. grub_install_get_time_ms (grub_rtc_get_time_ms);
  68. /* Initialize output terminal (can't be done earlier, as gfxterm
  69. relies on a working heap. */
  70. grub_video_sm712_init ();
  71. grub_video_init ();
  72. grub_bitmap_init ();
  73. grub_font_init ();
  74. grub_gfxterm_init ();
  75. grub_at_keyboard_init ();
  76. }
  77. void
  78. grub_machine_fini (void)
  79. {
  80. }
  81. void
  82. grub_exit (void)
  83. {
  84. while (1);
  85. }
  86. void
  87. grub_halt (void)
  88. {
  89. while (1);
  90. }
  91. void
  92. grub_reboot (void)
  93. {
  94. while (1);
  95. }