2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#include <grub/kernel.h>
2N/A#include <grub/mm.h>
2N/A#include <grub/machine/time.h>
2N/A#include <grub/machine/memory.h>
2N/A#include <grub/machine/console.h>
2N/A#include <grub/offsets.h>
2N/A#include <grub/types.h>
2N/A#include <grub/err.h>
2N/A#include <grub/dl.h>
2N/A#include <grub/misc.h>
2N/A#include <grub/loader.h>
2N/A#include <grub/env.h>
2N/A#include <grub/cache.h>
2N/A#include <grub/time.h>
2N/A#include <grub/symbol.h>
2N/A#include <grub/cpu/io.h>
2N/A#include <grub/cpu/floppy.h>
2N/A#include <grub/cpu/tsc.h>
2N/A#ifdef GRUB_MACHINE_QEMU
2N/A#include <grub/machine/kernel.h>
2N/A#endif
2N/A
2N/Aextern grub_uint8_t _start[];
2N/Aextern grub_uint8_t _end[];
2N/Aextern grub_uint8_t _edata[];
2N/A
2N/Agrub_uint32_t
2N/Agrub_get_rtc (void)
2N/A{
2N/A grub_fatal ("grub_get_rtc() is not implemented.\n");
2N/A}
2N/A
2N/Avoid
2N/Agrub_exit (void)
2N/A{
2N/A /* We can't use grub_fatal() in this function. This would create an infinite
2N/A loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
2N/A while (1)
2N/A grub_cpu_idle ();
2N/A}
2N/A
2N/A#ifdef GRUB_MACHINE_QEMU
2N/Agrub_addr_t grub_modbase;
2N/A#else
2N/Agrub_addr_t grub_modbase = ALIGN_UP((grub_addr_t) _end, GRUB_KERNEL_MACHINE_MOD_ALIGN);
2N/A#endif
2N/A
2N/Avoid
2N/Agrub_machine_init (void)
2N/A{
2N/A#ifdef GRUB_MACHINE_QEMU
2N/A grub_modbase = grub_core_entry_addr + (_edata - _start);
2N/A
2N/A grub_qemu_init_cirrus ();
2N/A#endif
2N/A /* Initialize the console as early as possible. */
2N/A grub_vga_text_init ();
2N/A
2N/A auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t, grub_uint64_t,
2N/A grub_memory_type_t);
2N/A int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t size,
2N/A grub_memory_type_t type)
2N/A {
2N/A#if GRUB_CPU_SIZEOF_VOID_P == 4
2N/A /* Restrict ourselves to 32-bit memory space. */
2N/A if (addr > GRUB_ULONG_MAX)
2N/A return 0;
2N/A if (addr + size > GRUB_ULONG_MAX)
2N/A size = GRUB_ULONG_MAX - addr;
2N/A#endif
2N/A
2N/A if (type != GRUB_MEMORY_AVAILABLE)
2N/A return 0;
2N/A
2N/A /* Avoid the lower memory. */
2N/A if (addr < GRUB_MEMORY_MACHINE_LOWER_SIZE)
2N/A {
2N/A if (addr + size <= GRUB_MEMORY_MACHINE_LOWER_SIZE)
2N/A return 0;
2N/A else
2N/A {
2N/A size -= GRUB_MEMORY_MACHINE_LOWER_SIZE - addr;
2N/A addr = GRUB_MEMORY_MACHINE_LOWER_SIZE;
2N/A }
2N/A }
2N/A
2N/A grub_mm_init_region ((void *) (grub_addr_t) addr, (grub_size_t) size);
2N/A
2N/A return 0;
2N/A }
2N/A
2N/A#if defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
2N/A grub_machine_mmap_init ();
2N/A#endif
2N/A grub_machine_mmap_iterate (heap_init);
2N/A
2N/A grub_tsc_init ();
2N/A}
2N/A
2N/Avoid
2N/Agrub_machine_get_bootlocation (char **device __attribute__ ((unused)),
2N/A char **path __attribute__ ((unused)))
2N/A{
2N/A}
2N/A
2N/Avoid
2N/Agrub_machine_fini (void)
2N/A{
2N/A grub_vga_text_fini ();
2N/A grub_stop_floppy ();
2N/A}