2009-10-09 17:50:31 +00:00
|
|
|
#include <grub/kernel.h>
|
|
|
|
#include <grub/misc.h>
|
|
|
|
#include <grub/env.h>
|
|
|
|
#include <grub/time.h>
|
|
|
|
#include <grub/types.h>
|
|
|
|
#include <grub/misc.h>
|
2009-10-10 11:30:14 +00:00
|
|
|
#include <grub/mm.h>
|
2009-10-11 00:07:52 +00:00
|
|
|
#include <grub/time.h>
|
2009-10-10 11:30:14 +00:00
|
|
|
#include <grub/machine/memory.h>
|
2011-07-05 21:46:15 +00:00
|
|
|
#include <grub/machine/kernel.h>
|
2012-02-26 23:28:45 +00:00
|
|
|
#include <grub/machine/console.h>
|
2011-05-17 12:02:18 +00:00
|
|
|
#include <grub/cpu/memory.h>
|
2011-01-14 16:37:11 +00:00
|
|
|
#include <grub/memory.h>
|
2012-02-26 23:28:45 +00:00
|
|
|
#include <grub/video.h>
|
|
|
|
#include <grub/terminfo.h>
|
|
|
|
#include <grub/keyboard_layouts.h>
|
|
|
|
#include <grub/serial.h>
|
|
|
|
#include <grub/loader.h>
|
|
|
|
#include <grub/at_keyboard.h>
|
2009-10-09 17:50:31 +00:00
|
|
|
|
2011-07-05 19:42:36 +00:00
|
|
|
static inline int
|
|
|
|
probe_mem (grub_addr_t addr)
|
|
|
|
{
|
|
|
|
volatile grub_uint8_t *ptr = (grub_uint8_t *) (0xa0000000 | addr);
|
|
|
|
grub_uint8_t c = *ptr;
|
|
|
|
*ptr = 0xAA;
|
|
|
|
if (*ptr != 0xAA)
|
|
|
|
return 0;
|
|
|
|
*ptr = 0x55;
|
|
|
|
if (*ptr != 0x55)
|
|
|
|
return 0;
|
|
|
|
*ptr = c;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-10-09 17:50:31 +00:00
|
|
|
void
|
|
|
|
grub_machine_init (void)
|
|
|
|
{
|
2011-05-17 12:02:18 +00:00
|
|
|
grub_addr_t modend;
|
|
|
|
|
2011-07-05 19:42:36 +00:00
|
|
|
if (grub_arch_memsize == 0)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 27; i >= 0; i--)
|
|
|
|
if (probe_mem (grub_arch_memsize | (1 << i)))
|
|
|
|
grub_arch_memsize |= (1 << i);
|
|
|
|
grub_arch_memsize++;
|
|
|
|
}
|
|
|
|
|
2011-05-17 12:02:18 +00:00
|
|
|
/* FIXME: measure this. */
|
|
|
|
grub_arch_cpuclock = 64000000;
|
|
|
|
|
|
|
|
modend = grub_modules_get_end ();
|
2011-05-17 17:32:51 +00:00
|
|
|
grub_mm_init_region ((void *) modend, grub_arch_memsize
|
2011-05-17 12:02:18 +00:00
|
|
|
- (modend - GRUB_ARCH_LOWMEMVSTART));
|
|
|
|
|
2009-10-10 18:52:15 +00:00
|
|
|
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
2011-05-17 12:02:18 +00:00
|
|
|
|
2011-07-05 19:00:01 +00:00
|
|
|
grub_font_init ();
|
|
|
|
|
|
|
|
grub_keylayouts_init ();
|
|
|
|
grub_at_keyboard_init ();
|
|
|
|
|
2011-07-05 21:46:15 +00:00
|
|
|
grub_qemu_init_cirrus ();
|
|
|
|
grub_vga_text_init ();
|
|
|
|
|
2011-05-17 12:02:18 +00:00
|
|
|
grub_terminfo_init ();
|
|
|
|
grub_serial_init ();
|
2011-07-05 19:00:01 +00:00
|
|
|
|
|
|
|
grub_boot_init ();
|
2009-10-09 17:50:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
grub_machine_fini (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
grub_exit (void)
|
|
|
|
{
|
2012-06-06 10:28:25 +00:00
|
|
|
grub_halt ();
|
2009-10-09 17:50:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
grub_halt (void)
|
|
|
|
{
|
2012-06-06 10:28:25 +00:00
|
|
|
grub_outl (42, 0xbfbf0004);
|
2009-10-09 17:50:31 +00:00
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
2009-10-10 11:30:14 +00:00
|
|
|
grub_err_t
|
2013-01-15 12:02:35 +00:00
|
|
|
grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
2009-10-10 11:30:14 +00:00
|
|
|
{
|
2013-01-15 12:02:35 +00:00
|
|
|
hook (0, grub_arch_memsize, GRUB_MEMORY_AVAILABLE, hook_data);
|
2009-10-10 11:30:14 +00:00
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
2011-05-17 19:15:54 +00:00
|
|
|
|
2013-04-27 17:12:11 +00:00
|
|
|
void
|
|
|
|
grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
|
|
|
char **path __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-05-17 19:15:54 +00:00
|
|
|
extern char _end[];
|
2011-10-16 13:23:29 +00:00
|
|
|
grub_addr_t grub_modbase = (grub_addr_t) _end;
|
2011-05-17 19:15:54 +00:00
|
|
|
|