Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / grub-core / kern / i386 / coreboot / init.c
blob52fbba4e811bf7e29d0968e182bf67a4a8e1f9f6
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 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/mm.h>
21 #include <grub/machine/time.h>
22 #include <grub/machine/memory.h>
23 #include <grub/machine/console.h>
24 #include <grub/offsets.h>
25 #include <grub/types.h>
26 #include <grub/err.h>
27 #include <grub/dl.h>
28 #include <grub/misc.h>
29 #include <grub/loader.h>
30 #include <grub/env.h>
31 #include <grub/cache.h>
32 #include <grub/time.h>
33 #include <grub/symbol.h>
34 #include <grub/cpu/io.h>
35 #include <grub/cpu/floppy.h>
36 #include <grub/cpu/tsc.h>
37 #ifdef GRUB_MACHINE_QEMU
38 #include <grub/machine/kernel.h>
39 #endif
41 extern grub_uint8_t _start[];
42 extern grub_uint8_t _end[];
43 extern grub_uint8_t _edata[];
45 void __attribute__ ((noreturn))
46 grub_exit (void)
48 /* We can't use grub_fatal() in this function. This would create an infinite
49 loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
50 while (1)
51 grub_cpu_idle ();
54 #ifdef GRUB_MACHINE_QEMU
55 grub_addr_t grub_modbase;
56 #else
57 grub_addr_t grub_modbase = ALIGN_UP((grub_addr_t) _end, GRUB_KERNEL_MACHINE_MOD_ALIGN);
58 #endif
60 void
61 grub_machine_init (void)
63 #ifdef GRUB_MACHINE_QEMU
64 grub_modbase = grub_core_entry_addr + (_edata - _start);
66 grub_qemu_init_cirrus ();
67 #endif
68 /* Initialize the console as early as possible. */
69 grub_vga_text_init ();
71 auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t, grub_uint64_t,
72 grub_memory_type_t);
73 int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t size,
74 grub_memory_type_t type)
76 #if GRUB_CPU_SIZEOF_VOID_P == 4
77 /* Restrict ourselves to 32-bit memory space. */
78 if (addr > GRUB_ULONG_MAX)
79 return 0;
80 if (addr + size > GRUB_ULONG_MAX)
81 size = GRUB_ULONG_MAX - addr;
82 #endif
84 if (type != GRUB_MEMORY_AVAILABLE)
85 return 0;
87 /* Avoid the lower memory. */
88 if (addr < GRUB_MEMORY_MACHINE_LOWER_SIZE)
90 if (addr + size <= GRUB_MEMORY_MACHINE_LOWER_SIZE)
91 return 0;
92 else
94 size -= GRUB_MEMORY_MACHINE_LOWER_SIZE - addr;
95 addr = GRUB_MEMORY_MACHINE_LOWER_SIZE;
99 grub_mm_init_region ((void *) (grub_addr_t) addr, (grub_size_t) size);
101 return 0;
104 #if defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
105 grub_machine_mmap_init ();
106 #endif
107 grub_machine_mmap_iterate (heap_init);
109 grub_tsc_init ();
112 void
113 grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
114 char **path __attribute__ ((unused)))
118 void
119 grub_machine_fini (void)
121 grub_vga_text_fini ();
122 grub_stop_floppy ();