2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2009,2010 Free Software Foundation, Inc.
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.
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.
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/>.
19 #include <grub/kernel.h>
20 #include <grub/misc.h>
22 #include <grub/time.h>
23 #include <grub/types.h>
24 #include <grub/misc.h>
26 #include <grub/time.h>
27 #include <grub/machine/kernel.h>
28 #include <grub/machine/memory.h>
29 #include <grub/cpu/kernel.h>
31 extern void grub_video_sm712_init (void);
32 extern void grub_video_video_init (void);
33 extern void grub_video_bitmap_init (void);
34 extern void grub_font_manager_init (void);
35 extern void grub_term_gfxterm_init (void);
36 extern void grub_at_keyboard_init (void);
38 /* FIXME: use interrupt to count high. */
42 static grub_uint32_t high
= 0;
43 static grub_uint32_t last
= 0;
46 asm volatile ("mfc0 %0, $9": "=r" (low
));
51 return (((grub_uint64_t
) high
) << 32) | low
;
55 grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook
) (grub_uint64_t
,
59 hook (GRUB_ARCH_LOWMEMPSTART
, grub_arch_memsize
<< 20,
60 GRUB_MACHINE_MEMORY_AVAILABLE
);
61 hook (GRUB_ARCH_HIGHMEMPSTART
, grub_arch_highmemsize
<< 20,
62 GRUB_MACHINE_MEMORY_AVAILABLE
);
68 get_modules_end (void)
70 struct grub_module_info
*modinfo
;
71 struct grub_module_header
*header
;
74 modbase
= grub_arch_modules_addr ();
75 modinfo
= (struct grub_module_info
*) modbase
;
77 /* Check if there are any modules. */
78 if ((modinfo
== 0) || modinfo
->magic
!= GRUB_MODULE_MAGIC
)
81 for (header
= (struct grub_module_header
*) (modbase
+ modinfo
->offset
);
82 header
< (struct grub_module_header
*) (modbase
+ modinfo
->size
);
83 header
= (struct grub_module_header
*) ((char *) header
+ header
->size
));
89 grub_machine_init (void)
92 modend
= get_modules_end ();
93 grub_mm_init_region (modend
, (grub_arch_memsize
<< 20)
94 - (((grub_addr_t
) modend
) - GRUB_ARCH_LOWMEMVSTART
));
95 /* FIXME: use upper memory as well. */
96 grub_install_get_time_ms (grub_rtc_get_time_ms
);
98 /* Initialize output terminal (can't be done earlier, as gfxterm
99 relies on a working heap. */
100 grub_video_sm712_init ();
101 grub_video_video_init ();
102 grub_video_bitmap_init ();
103 grub_font_manager_init ();
104 grub_term_gfxterm_init ();
106 grub_at_keyboard_init ();
110 grub_machine_fini (void)