remove all trailing whitespace
This commit is contained in:
parent
d2d4966571
commit
b39f9d20a9
222 changed files with 3286 additions and 3286 deletions
|
@ -168,7 +168,7 @@ grub_freebsd_add_mmap (void)
|
|||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
||||
grub_uint32_t type)
|
||||
{
|
||||
/* FreeBSD assumes that first 64KiB are available.
|
||||
/* FreeBSD assumes that first 64KiB are available.
|
||||
Not always true but try to prevent panic somehow. */
|
||||
if (isfirstrun && addr != 0)
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ grub_freebsd_add_mmap (void)
|
|||
mmap++;
|
||||
}
|
||||
else
|
||||
len += sizeof (struct grub_e820_mmap);
|
||||
len += sizeof (struct grub_e820_mmap);
|
||||
}
|
||||
isfirstrun = 0;
|
||||
if (mmap)
|
||||
|
@ -242,9 +242,9 @@ grub_freebsd_add_mmap (void)
|
|||
for (i = 0; i < mmap - mmap_buf; i++)
|
||||
grub_dprintf ("bsd", "smap %d, %d:%llx - %llx\n", i,
|
||||
mmap_buf[i].type,
|
||||
(unsigned long long) mmap_buf[i].addr,
|
||||
(unsigned long long) mmap_buf[i].addr,
|
||||
(unsigned long long) mmap_buf[i].size);
|
||||
|
||||
|
||||
grub_dprintf ("bsd", "%d entries in smap\n", mmap - mmap_buf);
|
||||
grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA |
|
||||
FREEBSD_MODINFOMD_SMAP, mmap_buf, len);
|
||||
|
@ -286,12 +286,12 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv,
|
|||
|
||||
if (is_64bit)
|
||||
{
|
||||
grub_uint64_t addr64 = addr, size64 = size;
|
||||
grub_uint64_t addr64 = addr, size64 = size;
|
||||
if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type,
|
||||
grub_strlen (type) + 1)) ||
|
||||
(grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr64,
|
||||
(grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr64,
|
||||
sizeof (addr64))) ||
|
||||
(grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size64,
|
||||
(grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size64,
|
||||
sizeof (size64))))
|
||||
return grub_errno;
|
||||
}
|
||||
|
@ -299,9 +299,9 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv,
|
|||
{
|
||||
if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type,
|
||||
grub_strlen (type) + 1)) ||
|
||||
(grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr,
|
||||
(grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr,
|
||||
sizeof (addr))) ||
|
||||
(grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size,
|
||||
(grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size,
|
||||
sizeof (size))))
|
||||
return grub_errno;
|
||||
}
|
||||
|
@ -502,22 +502,22 @@ grub_freebsd_boot (void)
|
|||
gdtdesc->base = gdt;
|
||||
|
||||
/* Prepare trampoline. */
|
||||
trampoline = (grub_uint8_t *) (kern_end - 4096 + 24
|
||||
trampoline = (grub_uint8_t *) (kern_end - 4096 + 24
|
||||
+ sizeof (struct gdt_descriptor));
|
||||
launch_trampoline = (void __attribute__ ((cdecl, regparm (0)))
|
||||
launch_trampoline = (void __attribute__ ((cdecl, regparm (0)))
|
||||
(*) (grub_addr_t entry, ...)) trampoline;
|
||||
grub_bsd64_trampoline_gdt = (grub_uint32_t) gdtdesc;
|
||||
grub_bsd64_trampoline_selfjump
|
||||
grub_bsd64_trampoline_selfjump
|
||||
= (grub_uint32_t) (trampoline + 6
|
||||
+ ((grub_uint8_t *) &grub_bsd64_trampoline_selfjump
|
||||
+ ((grub_uint8_t *) &grub_bsd64_trampoline_selfjump
|
||||
- &grub_bsd64_trampoline_start));
|
||||
|
||||
/* Copy trampoline. */
|
||||
grub_memcpy (trampoline, &grub_bsd64_trampoline_start,
|
||||
grub_memcpy (trampoline, &grub_bsd64_trampoline_start,
|
||||
&grub_bsd64_trampoline_end - &grub_bsd64_trampoline_start);
|
||||
|
||||
/* Launch trampoline. */
|
||||
launch_trampoline (entry, entry_hi, pagetable, bi.bi_modulep,
|
||||
launch_trampoline (entry, entry_hi, pagetable, bi.bi_modulep,
|
||||
kern_end);
|
||||
}
|
||||
else
|
||||
|
@ -547,7 +547,7 @@ grub_openbsd_boot (void)
|
|||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
||||
pm->type = OPENBSD_MMAP_AVAILABLE;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
pm->type = OPENBSD_MMAP_RESERVED;
|
||||
break;
|
||||
|
@ -574,7 +574,7 @@ grub_openbsd_boot (void)
|
|||
(part << OPENBSD_B_PARTSHIFT));
|
||||
|
||||
grub_unix_real_boot (entry, bootflags, bootdev, OPENBSD_BOOTARG_APIVER,
|
||||
0, grub_mmap_get_upper () >> 10,
|
||||
0, grub_mmap_get_upper () >> 10,
|
||||
grub_mmap_get_lower () >> 10,
|
||||
(char *) pa - buf, buf);
|
||||
|
||||
|
@ -603,7 +603,7 @@ grub_netbsd_boot (void)
|
|||
bootinfo->bi_data[0] = rootdev;
|
||||
|
||||
grub_unix_real_boot (entry, bootflags, 0, bootinfo,
|
||||
0, grub_mmap_get_upper () >> 10,
|
||||
0, grub_mmap_get_upper () >> 10,
|
||||
grub_mmap_get_lower () >> 10);
|
||||
|
||||
/* Not reached. */
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
|
||||
.p2align 2
|
||||
|
||||
|
||||
|
||||
.code32
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Based on the code from FreeBSD originally distributed under the
|
||||
/* Based on the code from FreeBSD originally distributed under the
|
||||
following terms: */
|
||||
|
||||
/*-
|
||||
|
@ -63,12 +63,12 @@ fill_bsd64_pagetable (grub_uint8_t *target)
|
|||
pt4 = (grub_uint64_t *) target;
|
||||
pt3 = (grub_uint64_t *) (target + 4096);
|
||||
pt2 = (grub_uint64_t *) (target + 8192);
|
||||
|
||||
|
||||
grub_memset ((char *) target, 0, 4096 * 3);
|
||||
|
||||
/*
|
||||
* This is kinda brutal, but every single 1GB VM memory segment points to
|
||||
* the same first 1GB of physical memory. But it is how BSD expects
|
||||
* the same first 1GB of physical memory. But it is how BSD expects
|
||||
* it to be.
|
||||
*/
|
||||
for (i = 0; i < 512; i++)
|
||||
|
@ -80,7 +80,7 @@ fill_bsd64_pagetable (grub_uint8_t *target)
|
|||
/* Each slot of the level 3 pages points to the same level 2 page */
|
||||
pt3[i] = (grub_addr_t) &pt2[0];
|
||||
pt3[i] |= PG_V | PG_RW | PG_U;
|
||||
|
||||
|
||||
/* The level 2 page slots are mapped with 2MB pages for 1GB. */
|
||||
pt2[i] = i * (2 * 1024 * 1024);
|
||||
pt2[i] |= PG_V | PG_RW | PG_PS | PG_U;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Based on the code from FreeBSD originally distributed under the
|
||||
/* Based on the code from FreeBSD originally distributed under the
|
||||
following terms: */
|
||||
|
||||
/*-
|
||||
|
@ -48,7 +48,7 @@
|
|||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define MSR_EFER 0xc0000080
|
||||
#define EFER_LME 0x00000100
|
||||
#define CR4_PAE 0x00000020
|
||||
|
@ -58,10 +58,10 @@
|
|||
#include <grub/symbol.h>
|
||||
|
||||
.p2align 2
|
||||
|
||||
.code32
|
||||
|
||||
|
||||
.code32
|
||||
|
||||
|
||||
VARIABLE(grub_bsd64_trampoline_start)
|
||||
|
||||
/* Discard `grub_unix_real_boot' return address. */
|
||||
|
@ -105,7 +105,7 @@ VARIABLE(grub_bsd64_trampoline_start)
|
|||
.byte 0x15
|
||||
VARIABLE (grub_bsd64_trampoline_gdt)
|
||||
.long 0x0
|
||||
|
||||
|
||||
/* ljmp */
|
||||
.byte 0xea
|
||||
VARIABLE (grub_bsd64_trampoline_selfjump)
|
||||
|
|
|
@ -103,21 +103,21 @@ find_mmap_size (void)
|
|||
|
||||
if (mmap_size != 0)
|
||||
return mmap_size;
|
||||
|
||||
|
||||
mmap_size = (1 << 12);
|
||||
while (1)
|
||||
{
|
||||
int ret;
|
||||
grub_efi_memory_descriptor_t *mmap;
|
||||
grub_efi_uintn_t desc_size;
|
||||
|
||||
|
||||
mmap = grub_malloc (mmap_size);
|
||||
if (! mmap)
|
||||
return 0;
|
||||
|
||||
ret = grub_efi_get_memory_map (&mmap_size, mmap, 0, &desc_size, 0);
|
||||
grub_free (mmap);
|
||||
|
||||
|
||||
if (ret < 0)
|
||||
grub_fatal ("cannot get memory map");
|
||||
else if (ret > 0)
|
||||
|
@ -147,7 +147,7 @@ free_pages (void)
|
|||
grub_efi_free_pages ((grub_addr_t) prot_mode_mem, prot_mode_pages);
|
||||
prot_mode_mem = 0;
|
||||
}
|
||||
|
||||
|
||||
if (initrd_mem)
|
||||
{
|
||||
grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages);
|
||||
|
@ -165,7 +165,7 @@ allocate_pages (grub_size_t prot_size)
|
|||
grub_efi_uintn_t mmap_size, tmp_mmap_size;
|
||||
grub_efi_memory_descriptor_t *desc;
|
||||
grub_size_t real_size;
|
||||
|
||||
|
||||
/* Make sure that each size is aligned to a page boundary. */
|
||||
real_size = GRUB_LINUX_CL_END_OFFSET;
|
||||
prot_size = page_align (prot_size);
|
||||
|
@ -173,16 +173,16 @@ allocate_pages (grub_size_t prot_size)
|
|||
|
||||
grub_dprintf ("linux", "real_size = %x, prot_size = %x, mmap_size = %x\n",
|
||||
(unsigned) real_size, (unsigned) prot_size, (unsigned) mmap_size);
|
||||
|
||||
|
||||
/* Calculate the number of pages; Combine the real mode code with
|
||||
the memory map buffer for simplicity. */
|
||||
real_mode_pages = ((real_size + mmap_size) >> 12);
|
||||
prot_mode_pages = (prot_size >> 12);
|
||||
|
||||
|
||||
/* Initialize the memory pointers with NULL for convenience. */
|
||||
real_mode_mem = 0;
|
||||
prot_mode_mem = 0;
|
||||
|
||||
|
||||
/* Read the memory map temporarily, to find free space. */
|
||||
mmap = grub_malloc (mmap_size);
|
||||
if (! mmap)
|
||||
|
@ -193,7 +193,7 @@ allocate_pages (grub_size_t prot_size)
|
|||
grub_fatal ("cannot get memory map");
|
||||
|
||||
mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap, tmp_mmap_size);
|
||||
|
||||
|
||||
/* First, find free pages for the real mode code
|
||||
and the memory map buffer. */
|
||||
for (desc = mmap;
|
||||
|
@ -208,7 +208,7 @@ allocate_pages (grub_size_t prot_size)
|
|||
{
|
||||
grub_efi_physical_address_t physical_end;
|
||||
grub_efi_physical_address_t addr;
|
||||
|
||||
|
||||
physical_end = desc->physical_start + (desc->num_pages << 12);
|
||||
if (physical_end > 0x90000)
|
||||
physical_end = 0x90000;
|
||||
|
@ -225,7 +225,7 @@ allocate_pages (grub_size_t prot_size)
|
|||
real_mode_mem = grub_efi_allocate_pages (addr, real_mode_pages);
|
||||
if (! real_mode_mem)
|
||||
grub_fatal ("cannot allocate pages");
|
||||
|
||||
|
||||
desc->num_pages -= real_mode_pages;
|
||||
break;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ allocate_pages (grub_size_t prot_size)
|
|||
}
|
||||
|
||||
mmap_buf = (void *) ((char *) real_mode_mem + real_size);
|
||||
|
||||
|
||||
/* Next, find free pages for the protected mode code. */
|
||||
/* XXX what happens if anything is using this address? */
|
||||
prot_mode_mem = grub_efi_allocate_pages (0x100000, prot_mode_pages + 1);
|
||||
|
@ -299,7 +299,7 @@ grub_linux_boot (void)
|
|||
grub_efi_uintn_t desc_size;
|
||||
grub_efi_uint32_t desc_version;
|
||||
int e820_num;
|
||||
|
||||
|
||||
params = real_mode_mem;
|
||||
|
||||
grub_dprintf ("linux", "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n",
|
||||
|
@ -382,12 +382,12 @@ grub_linux_boot (void)
|
|||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
grub_memcpy ((char *) prot_mode_mem + (prot_mode_pages << 12),
|
||||
grub_linux_trampoline_start,
|
||||
|
||||
grub_memcpy ((char *) prot_mode_mem + (prot_mode_pages << 12),
|
||||
grub_linux_trampoline_start,
|
||||
grub_linux_trampoline_end - grub_linux_trampoline_start);
|
||||
|
||||
((void (*) (unsigned long, void *)) ((char *) prot_mode_mem
|
||||
|
||||
((void (*) (unsigned long, void *)) ((char *) prot_mode_mem
|
||||
+ (prot_mode_pages << 12)))
|
||||
(params->code32_start, real_mode_mem);
|
||||
|
||||
|
@ -395,7 +395,7 @@ grub_linux_boot (void)
|
|||
|
||||
/* Hardware interrupts are not safe any longer. */
|
||||
asm volatile ("cli" : : );
|
||||
|
||||
|
||||
/* Load the IDT and the GDT for the bootstrap. */
|
||||
asm volatile ("lidt %0" : : "m" (idt_desc));
|
||||
asm volatile ("lgdt %0" : : "m" (gdt_desc));
|
||||
|
@ -408,7 +408,7 @@ grub_linux_boot (void)
|
|||
|
||||
/* Enter Linux. */
|
||||
asm volatile ("jmp *%%ecx" : : );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* Never reach here. */
|
||||
|
@ -605,7 +605,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
char *dest;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
|
||||
|
@ -650,17 +650,17 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
setup_sects = lh.setup_sects;
|
||||
|
||||
|
||||
/* If SETUP_SECTS is not set, set it to the default (4). */
|
||||
if (! setup_sects)
|
||||
setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS;
|
||||
|
||||
real_size = setup_sects << GRUB_DISK_SECTOR_BITS;
|
||||
prot_size = grub_file_size (file) - real_size - GRUB_DISK_SECTOR_SIZE;
|
||||
|
||||
|
||||
if (! allocate_pages (prot_size))
|
||||
goto fail;
|
||||
|
||||
|
||||
params = (struct linux_kernel_params *) real_mode_mem;
|
||||
grub_memset (params, 0, GRUB_LINUX_CL_END_OFFSET);
|
||||
grub_memcpy (¶ms->setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1);
|
||||
|
@ -691,7 +691,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
space. */
|
||||
params->ext_mem = ((32 * 0x100000) >> 10);
|
||||
params->alt_mem = ((32 * 0x100000) >> 10);
|
||||
|
||||
|
||||
params->video_cursor_x = grub_getxy () >> 8;
|
||||
params->video_cursor_y = grub_getxy () & 0xff;
|
||||
params->video_page = 0; /* ??? */
|
||||
|
@ -778,7 +778,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_memset (params->padding7, 0, sizeof (params->padding7));
|
||||
grub_memset (params->padding8, 0, sizeof (params->padding8));
|
||||
grub_memset (params->padding9, 0, sizeof (params->padding9));
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* The other EFI parameters are filled when booting. */
|
||||
|
@ -797,9 +797,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (grub_memcmp (argv[i], "mem=", 4) == 0)
|
||||
{
|
||||
char *val = argv[i] + 4;
|
||||
|
||||
|
||||
linux_mem_size = grub_strtoul (val, &val, 0);
|
||||
|
||||
|
||||
if (grub_errno)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -808,7 +808,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
else
|
||||
{
|
||||
int shift = 0;
|
||||
|
||||
|
||||
switch (grub_tolower (val[0]))
|
||||
{
|
||||
case 'g':
|
||||
|
@ -838,7 +838,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
dest = grub_stpcpy ((char *) real_mode_mem + GRUB_LINUX_CL_OFFSET,
|
||||
"BOOT_IMAGE=");
|
||||
dest = grub_stpcpy (dest, argv[0]);
|
||||
|
||||
|
||||
/* Copy kernel parameters. */
|
||||
for (i = 1;
|
||||
i < argc
|
||||
|
@ -861,7 +861,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
fail:
|
||||
|
||||
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
|
@ -886,13 +886,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_efi_memory_descriptor_t *desc;
|
||||
grub_efi_uintn_t desc_size;
|
||||
struct linux_kernel_header *lh;
|
||||
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (! loaded)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first.");
|
||||
|
@ -907,11 +907,11 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
initrd_pages = (page_align (size) >> 12);
|
||||
|
||||
lh = (struct linux_kernel_header *) real_mode_mem;
|
||||
|
||||
|
||||
addr_max = (grub_cpu_to_le32 (lh->initrd_addr_max) << 10);
|
||||
if (linux_mem_size != 0 && linux_mem_size < addr_max)
|
||||
addr_max = linux_mem_size;
|
||||
|
||||
|
||||
/* Linux 2.3.xx has a bug in the memory range check, so avoid
|
||||
the last page.
|
||||
Linux 2.2.xx has a bug in the memory range check, which is
|
||||
|
@ -921,7 +921,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
/* Usually, the compression ratio is about 50%. */
|
||||
addr_min = (grub_addr_t) prot_mode_mem + ((prot_mode_pages * 3) << 12)
|
||||
+ page_align (size);
|
||||
|
||||
|
||||
/* Find the highest address to put the initrd. */
|
||||
mmap_size = find_mmap_size ();
|
||||
if (grub_efi_get_memory_map (&mmap_size, mmap_buf, 0, &desc_size, 0) <= 0)
|
||||
|
@ -936,7 +936,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
&& desc->num_pages >= initrd_pages)
|
||||
{
|
||||
grub_efi_physical_address_t physical_end;
|
||||
|
||||
|
||||
physical_end = desc->physical_start + (desc->num_pages << 12);
|
||||
if (physical_end > addr_max)
|
||||
physical_end = addr_max;
|
||||
|
@ -958,11 +958,11 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_error (GRUB_ERR_OUT_OF_MEMORY, "no free pages available");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
initrd_mem = grub_efi_allocate_pages (addr, initrd_pages);
|
||||
if (! initrd_mem)
|
||||
grub_fatal ("cannot allocate pages");
|
||||
|
||||
|
||||
if (grub_file_read (file, initrd_mem, size) != size)
|
||||
{
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file");
|
||||
|
@ -971,11 +971,11 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
grub_printf (" [Initrd, addr=0x%x, size=0x%x]\n",
|
||||
(unsigned) addr, (unsigned) size);
|
||||
|
||||
|
||||
lh->ramdisk_image = addr;
|
||||
lh->ramdisk_size = size;
|
||||
lh->root_dev = 0x0100; /* XXX */
|
||||
|
||||
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
|
|
@ -285,15 +285,15 @@ find_mmap_size (void)
|
|||
count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
grub_mmap_iterate (hook);
|
||||
|
||||
|
||||
mmap_size = count * sizeof (struct grub_e820_mmap);
|
||||
|
||||
/* Increase the size a bit for safety, because GRUB allocates more on
|
||||
later. */
|
||||
mmap_size += (1 << 12);
|
||||
|
||||
|
||||
return page_align (mmap_size);
|
||||
}
|
||||
|
||||
|
@ -317,15 +317,15 @@ allocate_pages (grub_size_t prot_size)
|
|||
|
||||
grub_dprintf ("linux", "real_size = %x, prot_size = %x, mmap_size = %x\n",
|
||||
(unsigned) real_size, (unsigned) prot_size, (unsigned) mmap_size);
|
||||
|
||||
|
||||
/* Calculate the number of pages; Combine the real mode code with
|
||||
the memory map buffer for simplicity. */
|
||||
real_mode_pages = ((real_size + mmap_size) >> 12);
|
||||
prot_mode_pages = (prot_size >> 12);
|
||||
|
||||
|
||||
/* Initialize the memory pointers with NULL for convenience. */
|
||||
free_pages ();
|
||||
|
||||
|
||||
/* FIXME: Should request low memory from the heap when this feature is
|
||||
implemented. */
|
||||
|
||||
|
@ -451,11 +451,11 @@ grub_linux_boot (void)
|
|||
|
||||
modevar = grub_env_get ("gfxpayload");
|
||||
|
||||
/* Now all graphical modes are acceptable.
|
||||
/* Now all graphical modes are acceptable.
|
||||
May change in future if we have modes without framebuffer. */
|
||||
if (modevar && *modevar != 0)
|
||||
{
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
+ sizeof (DEFAULT_VIDEO_MODE) + 1);
|
||||
if (! tmp)
|
||||
return grub_errno;
|
||||
|
@ -485,7 +485,7 @@ grub_linux_boot (void)
|
|||
params->video_width = 80;
|
||||
params->video_height = 25;
|
||||
}
|
||||
|
||||
|
||||
grub_dprintf ("linux", "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n",
|
||||
(unsigned) params->code32_start,
|
||||
(unsigned long) &(idt_desc.limit),
|
||||
|
@ -538,18 +538,18 @@ grub_linux_boot (void)
|
|||
|
||||
#ifdef __x86_64__
|
||||
|
||||
grub_memcpy ((char *) prot_mode_mem + (prot_mode_pages << 12),
|
||||
grub_linux_trampoline_start,
|
||||
grub_memcpy ((char *) prot_mode_mem + (prot_mode_pages << 12),
|
||||
grub_linux_trampoline_start,
|
||||
grub_linux_trampoline_end - grub_linux_trampoline_start);
|
||||
|
||||
((void (*) (unsigned long, void *)) ((char *) prot_mode_mem
|
||||
|
||||
((void (*) (unsigned long, void *)) ((char *) prot_mode_mem
|
||||
+ (prot_mode_pages << 12)))
|
||||
(params->code32_start, real_mode_mem);
|
||||
#else
|
||||
|
||||
/* Hardware interrupts are not safe any longer. */
|
||||
asm volatile ("cli" : : );
|
||||
|
||||
|
||||
/* Load the IDT and the GDT for the bootstrap. */
|
||||
asm volatile ("lidt %0" : : "m" (idt_desc));
|
||||
asm volatile ("lgdt %0" : : "m" (gdt_desc));
|
||||
|
@ -562,7 +562,7 @@ grub_linux_boot (void)
|
|||
|
||||
/* Enter Linux. */
|
||||
asm volatile ("jmp *%%ecx" : : );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* Never reach here. */
|
||||
|
@ -591,7 +591,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
char *dest;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
|
||||
|
@ -644,17 +644,17 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
setup_sects = lh.setup_sects;
|
||||
|
||||
|
||||
/* If SETUP_SECTS is not set, set it to the default (4). */
|
||||
if (! setup_sects)
|
||||
setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS;
|
||||
|
||||
real_size = setup_sects << GRUB_DISK_SECTOR_BITS;
|
||||
prot_size = grub_file_size (file) - real_size - GRUB_DISK_SECTOR_SIZE;
|
||||
|
||||
|
||||
if (! allocate_pages (prot_size))
|
||||
goto fail;
|
||||
|
||||
|
||||
params = (struct linux_kernel_params *) real_mode_mem;
|
||||
grub_memset (params, 0, GRUB_LINUX_CL_END_OFFSET);
|
||||
grub_memcpy (¶ms->setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1);
|
||||
|
@ -684,7 +684,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
space. */
|
||||
params->ext_mem = ((32 * 0x100000) >> 10);
|
||||
params->alt_mem = ((32 * 0x100000) >> 10);
|
||||
|
||||
|
||||
params->video_page = 0; /* ??? */
|
||||
params->video_mode = 0;
|
||||
params->video_ega_bx = 0;
|
||||
|
@ -734,8 +734,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_env_set ("gfxpayload", "text");
|
||||
grub_printf ("%s is deprecated. "
|
||||
"Use set gfxpayload=text before "
|
||||
"linux command instead.\n",
|
||||
argv[i]);
|
||||
"linux command instead.\n",
|
||||
argv[i]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
@ -744,8 +744,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_env_set ("gfxpayload", "text");
|
||||
grub_printf ("%s is deprecated. "
|
||||
"Use set gfxpayload=text before "
|
||||
"linux command instead.\n",
|
||||
argv[i]);
|
||||
"linux command instead.\n",
|
||||
argv[i]);
|
||||
break;
|
||||
default:
|
||||
/* Ignore invalid values. */
|
||||
|
@ -756,19 +756,19 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_env_set ("gfxpayload", "text");
|
||||
grub_printf ("%s is deprecated. Mode %d isn't recognized. "
|
||||
"Use set gfxpayload=WIDTHxHEIGHT[xDEPTH] before "
|
||||
"linux command instead.\n",
|
||||
argv[i], vid_mode);
|
||||
"linux command instead.\n",
|
||||
argv[i], vid_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
buf = grub_malloc (sizeof ("WWWWxHHHHxDD;WWWWxHHHH"));
|
||||
if (! buf)
|
||||
goto fail;
|
||||
|
||||
linux_mode
|
||||
|
||||
linux_mode
|
||||
= &linux_vesafb_modes[vid_mode - GRUB_LINUX_VID_MODE_VESA_START];
|
||||
|
||||
grub_sprintf (buf, "%ux%ux%u;%ux%u",
|
||||
|
||||
grub_sprintf (buf, "%ux%ux%u;%ux%u",
|
||||
linux_vesafb_res[linux_mode->res_index].width,
|
||||
linux_vesafb_res[linux_mode->res_index].height,
|
||||
linux_mode->depth,
|
||||
|
@ -776,8 +776,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
linux_vesafb_res[linux_mode->res_index].height);
|
||||
grub_printf ("%s is deprecated. "
|
||||
"Use set gfxpayload=%s before "
|
||||
"linux command instead.\n",
|
||||
argv[i], buf);
|
||||
"linux command instead.\n",
|
||||
argv[i], buf);
|
||||
err = grub_env_set ("gfxpayload", buf);
|
||||
grub_free (buf);
|
||||
if (err)
|
||||
|
@ -789,9 +789,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (grub_memcmp (argv[i], "mem=", 4) == 0)
|
||||
{
|
||||
char *val = argv[i] + 4;
|
||||
|
||||
|
||||
linux_mem_size = grub_strtoul (val, &val, 0);
|
||||
|
||||
|
||||
if (grub_errno)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -800,7 +800,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
else
|
||||
{
|
||||
int shift = 0;
|
||||
|
||||
|
||||
switch (grub_tolower (val[0]))
|
||||
{
|
||||
case 'g':
|
||||
|
@ -820,12 +820,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
linux_mem_size <<= shift;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Specify the boot file. */
|
||||
dest = grub_stpcpy ((char *) real_mode_mem + GRUB_LINUX_CL_OFFSET,
|
||||
"BOOT_IMAGE=");
|
||||
dest = grub_stpcpy (dest, argv[0]);
|
||||
|
||||
|
||||
/* Copy kernel parameters. */
|
||||
for (i = 1;
|
||||
i < argc
|
||||
|
@ -849,7 +849,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
fail:
|
||||
|
||||
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
|
@ -871,13 +871,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_addr_t addr_min, addr_max;
|
||||
grub_addr_t addr;
|
||||
struct linux_kernel_header *lh;
|
||||
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (! loaded)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first.");
|
||||
|
@ -906,10 +906,10 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
else
|
||||
addr_max = GRUB_LINUX_INITRD_MAX_ADDRESS;
|
||||
|
||||
|
||||
if (linux_mem_size != 0 && linux_mem_size < addr_max)
|
||||
addr_max = linux_mem_size;
|
||||
|
||||
|
||||
/* Linux 2.3.xx has a bug in the memory range check, so avoid
|
||||
the last page.
|
||||
Linux 2.2.xx has a bug in the memory range check, which is
|
||||
|
@ -919,7 +919,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
/* Usually, the compression ratio is about 50%. */
|
||||
addr_min = (grub_addr_t) prot_mode_mem + ((prot_mode_pages * 3) << 12)
|
||||
+ page_align (size);
|
||||
|
||||
|
||||
if (addr_max > grub_os_area_addr + grub_os_area_size)
|
||||
addr_max = grub_os_area_addr + grub_os_area_size;
|
||||
|
||||
|
@ -931,9 +931,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_error (GRUB_ERR_OUT_OF_RANGE, "The initrd is too big");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
initrd_mem = (void *) addr;
|
||||
|
||||
|
||||
if (grub_file_read (file, initrd_mem, size) != size)
|
||||
{
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file");
|
||||
|
@ -942,11 +942,11 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
grub_printf (" [Initrd, addr=0x%x, size=0x%x]\n",
|
||||
(unsigned) addr, (unsigned) size);
|
||||
|
||||
|
||||
lh->ramdisk_image = addr;
|
||||
lh->ramdisk_size = size;
|
||||
lh->root_dev = 0x0100; /* XXX */
|
||||
|
||||
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
|
||||
|
||||
.p2align 4 /* force 16-byte alignment */
|
||||
VARIABLE(grub_linux_trampoline_start)
|
||||
|
@ -26,23 +26,23 @@ VARIABLE(grub_linux_trampoline_start)
|
|||
contains real memory start. */
|
||||
|
||||
mov %rsi, %rbx
|
||||
|
||||
|
||||
call base
|
||||
base:
|
||||
base:
|
||||
pop %rsi
|
||||
|
||||
#ifdef APPLE_CC
|
||||
#ifdef APPLE_CC
|
||||
lea (cont1 - base) (%esi, 1), %rax
|
||||
mov %eax, (jump_vector - base) (%esi, 1)
|
||||
|
||||
lea (gdt - base) (%esi, 1), %rax
|
||||
mov %rax, (gdtaddr - base) (%esi, 1)
|
||||
|
||||
|
||||
/* Switch to compatibility mode. */
|
||||
|
||||
lidt (idtdesc - base) (%esi, 1)
|
||||
lgdt (gdtdesc - base) (%esi, 1)
|
||||
|
||||
|
||||
/* Update %cs. Thanks to David Miller for pointing this mistake out. */
|
||||
ljmp *(jump_vector - base) (%esi, 1)
|
||||
#else
|
||||
|
@ -51,22 +51,22 @@ base:
|
|||
|
||||
lea (gdt - base) (%rsi, 1), %rax
|
||||
mov %rax, (gdtaddr - base) (%rsi, 1)
|
||||
|
||||
|
||||
/* Switch to compatibility mode. */
|
||||
|
||||
lidt (idtdesc - base) (%rsi, 1)
|
||||
lgdt (gdtdesc - base) (%rsi, 1)
|
||||
|
||||
|
||||
/* Update %cs. Thanks to David Miller for pointing this mistake out. */
|
||||
ljmp *(jump_vector - base) (%rsi, 1)
|
||||
#endif
|
||||
|
||||
|
||||
cont1:
|
||||
.code32
|
||||
|
||||
/* Update other registers. */
|
||||
mov $0x18, %eax
|
||||
mov %eax, %ds
|
||||
mov %eax, %ds
|
||||
mov %eax, %es
|
||||
mov %eax, %fs
|
||||
mov %eax, %gs
|
||||
|
@ -89,41 +89,41 @@ cont1:
|
|||
mov %eax, %cr4
|
||||
|
||||
jmp cont2
|
||||
cont2:
|
||||
cont2:
|
||||
.code32
|
||||
|
||||
|
||||
mov %ebx, %esi
|
||||
|
||||
jmp *%edi
|
||||
|
||||
/* GDT. */
|
||||
.p2align 4
|
||||
gdt:
|
||||
gdt:
|
||||
/* NULL. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
|
||||
/* Reserved. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
|
||||
/* Code segment. */
|
||||
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
|
||||
|
||||
|
||||
/* Data segment. */
|
||||
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
|
||||
|
||||
gdtdesc:
|
||||
gdtdesc:
|
||||
.word 31
|
||||
gdtaddr:
|
||||
gdtaddr:
|
||||
.quad gdt
|
||||
|
||||
idtdesc:
|
||||
idtdesc:
|
||||
.word 0
|
||||
idtaddr:
|
||||
idtaddr:
|
||||
.quad 0
|
||||
|
||||
.p2align 4
|
||||
jump_vector:
|
||||
/* Jump location. Is filled by the code */
|
||||
.long 0
|
||||
.long 0x10
|
||||
.long 0x10
|
||||
VARIABLE(grub_linux_trampoline_end)
|
||||
|
|
|
@ -76,7 +76,7 @@ grub_multiboot_unload (void)
|
|||
grub_free ((void *) mbi->cmdline);
|
||||
grub_free (mbi);
|
||||
}
|
||||
|
||||
|
||||
mbi = 0;
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
|
@ -98,9 +98,9 @@ grub_get_multiboot_mmap_len (void)
|
|||
count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
grub_mmap_iterate (hook);
|
||||
|
||||
|
||||
return count * sizeof (struct grub_multiboot_mmap_entry);
|
||||
}
|
||||
|
||||
|
@ -297,11 +297,11 @@ grub_multiboot (int argc, char *argv[])
|
|||
grub_file_read (file, (void *) grub_multiboot_payload_orig, load_size);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
|
||||
|
||||
if (header->bss_end_addr)
|
||||
grub_memset ((void *) (grub_multiboot_payload_orig + load_size), 0,
|
||||
header->bss_end_addr - header->load_addr - load_size);
|
||||
|
||||
|
||||
grub_multiboot_payload_entry_offset = header->entry_addr - header->load_addr;
|
||||
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ grub_multiboot (int argc, char *argv[])
|
|||
mbi_dest = mbi_addr (grub_multiboot_payload_dest);
|
||||
grub_memset (mbi, 0, sizeof (struct grub_multiboot_info));
|
||||
mbi->mmap_length = mmap_length;
|
||||
|
||||
|
||||
grub_fill_multiboot_mmap (mmap_addr (grub_multiboot_payload_orig));
|
||||
|
||||
/* FIXME: grub_uint32_t will break for addresses above 4 GiB, but is mandated
|
||||
|
@ -334,7 +334,7 @@ grub_multiboot (int argc, char *argv[])
|
|||
&grub_multiboot_backward_relocator, RELOCATOR_SIZEOF(backward));
|
||||
entry = (grub_addr_t) grub_multiboot_payload_orig + grub_multiboot_payload_size;
|
||||
}
|
||||
|
||||
|
||||
grub_dprintf ("multiboot_loader", "dest=%p, size=0x%x, entry_offset=0x%x\n",
|
||||
(void *) grub_multiboot_payload_dest,
|
||||
grub_multiboot_payload_size,
|
||||
|
@ -360,8 +360,8 @@ grub_multiboot (int argc, char *argv[])
|
|||
|
||||
mbi->flags |= MULTIBOOT_INFO_CMDLINE;
|
||||
mbi->cmdline = (grub_uint32_t) cmdline_addr (grub_multiboot_payload_dest);
|
||||
|
||||
|
||||
|
||||
|
||||
grub_strcpy (boot_loader_name_addr (grub_multiboot_payload_orig), PACKAGE_STRING);
|
||||
mbi->flags |= MULTIBOOT_INFO_BOOT_LOADER_NAME;
|
||||
mbi->boot_loader_name = (grub_uint32_t) boot_loader_name_addr (grub_multiboot_payload_dest);
|
||||
|
|
|
@ -63,10 +63,10 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
|
|||
|| ehdr->e_ident[EI_DATA] != ELFDATA2LSB
|
||||
|| ehdr->e_machine != E_MACHINE)
|
||||
return grub_error(GRUB_ERR_UNKNOWN_OS, "no valid ELF header found");
|
||||
|
||||
|
||||
if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_OS, "invalid ELF file type");
|
||||
|
||||
|
||||
/* FIXME: Should we support program headers at strange locations? */
|
||||
if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset");
|
||||
|
@ -84,7 +84,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
|
|||
if (phdr(i)->p_type == PT_LOAD && phdr(i)->p_filesz != 0)
|
||||
{
|
||||
/* Beware that segment 0 isn't necessarily loadable */
|
||||
if (lowest_segment == -1
|
||||
if (lowest_segment == -1
|
||||
|| phdr(i)->p_paddr < phdr(lowest_segment)->p_paddr)
|
||||
lowest_segment = i;
|
||||
if (highest_segment == -1
|
||||
|
@ -132,7 +132,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
|
|||
}
|
||||
|
||||
for (i = 0; i < ehdr->e_phnum; i++)
|
||||
if (phdr(i)->p_vaddr <= ehdr->e_entry
|
||||
if (phdr(i)->p_vaddr <= ehdr->e_entry
|
||||
&& phdr(i)->p_vaddr + phdr(i)->p_memsz > ehdr->e_entry)
|
||||
{
|
||||
grub_multiboot_payload_entry_offset = (ehdr->e_entry - phdr(i)->p_vaddr)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <grub/symbol.h>
|
||||
#include <multiboot.h>
|
||||
#include <multiboot2.h>
|
||||
|
||||
|
||||
.p2align 2 /* force 4-byte alignment */
|
||||
|
||||
/*
|
||||
|
@ -91,7 +91,7 @@ FUNCTION(grub_multiboot_real_boot)
|
|||
|
||||
/* Move the magic value into eax. */
|
||||
movl $MULTIBOOT_MAGIC2, %eax
|
||||
|
||||
|
||||
/* Jump to the relocator. */
|
||||
popl %ebp
|
||||
jmp *%ebp
|
||||
|
|
|
@ -62,7 +62,7 @@ grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags)
|
|||
void *part_addr = 0;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
|
||||
file = grub_file_open (filename);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
@ -93,11 +93,11 @@ grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags)
|
|||
if (dev)
|
||||
{
|
||||
grub_disk_t disk = dev->disk;
|
||||
|
||||
|
||||
if (disk)
|
||||
{
|
||||
grub_partition_t p = disk->partition;
|
||||
|
||||
|
||||
/* In i386-pc, the id is equal to the BIOS drive number. */
|
||||
drive = (int) disk->id;
|
||||
|
||||
|
@ -112,21 +112,21 @@ grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags)
|
|||
|
||||
grub_device_close (dev);
|
||||
}
|
||||
|
||||
|
||||
/* Ignore errors. Perhaps it's not fatal. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
boot_drive = drive;
|
||||
boot_part_addr = part_addr;
|
||||
|
||||
|
||||
grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 1);
|
||||
return;
|
||||
|
||||
|
||||
fail:
|
||||
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
|
|||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
|
||||
else
|
||||
|
|
|
@ -60,7 +60,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
char *dest;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
|
||||
|
@ -100,27 +100,27 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_linux_is_bzimage = 0;
|
||||
setup_sects = lh.setup_sects;
|
||||
linux_mem_size = 0;
|
||||
|
||||
|
||||
if (lh.header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)
|
||||
&& grub_le_to_cpu16 (lh.version) >= 0x0200)
|
||||
{
|
||||
grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
|
||||
lh.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;
|
||||
|
||||
|
||||
/* Put the real mode part at as a high location as possible. */
|
||||
grub_linux_real_addr
|
||||
grub_linux_real_addr
|
||||
= (char *) UINT_TO_PTR (grub_mmap_get_lower ()
|
||||
- GRUB_LINUX_SETUP_MOVE_SIZE);
|
||||
/* But it must not exceed the traditional area. */
|
||||
if (grub_linux_real_addr > (char *) GRUB_LINUX_OLD_REAL_MODE_ADDR)
|
||||
grub_linux_real_addr = (char *) GRUB_LINUX_OLD_REAL_MODE_ADDR;
|
||||
|
||||
|
||||
if (grub_le_to_cpu16 (lh.version) >= 0x0201)
|
||||
{
|
||||
lh.heap_end_ptr = grub_cpu_to_le16 (GRUB_LINUX_HEAP_END_OFFSET);
|
||||
lh.loadflags |= GRUB_LINUX_FLAG_CAN_USE_HEAP;
|
||||
}
|
||||
|
||||
|
||||
if (grub_le_to_cpu16 (lh.version) >= 0x0202)
|
||||
lh.cmd_line_ptr = grub_linux_real_addr + GRUB_LINUX_CL_OFFSET;
|
||||
else
|
||||
|
@ -135,19 +135,19 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
/* Your kernel is quite old... */
|
||||
lh.cl_magic = grub_cpu_to_le16 (GRUB_LINUX_CL_MAGIC);
|
||||
lh.cl_offset = grub_cpu_to_le16 (GRUB_LINUX_CL_OFFSET);
|
||||
|
||||
|
||||
setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS;
|
||||
|
||||
|
||||
grub_linux_real_addr = (char *) GRUB_LINUX_OLD_REAL_MODE_ADDR;
|
||||
}
|
||||
|
||||
|
||||
/* If SETUP_SECTS is not set, set it to the default (4). */
|
||||
if (! setup_sects)
|
||||
setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS;
|
||||
|
||||
|
||||
real_size = setup_sects << GRUB_DISK_SECTOR_BITS;
|
||||
prot_size = grub_file_size (file) - real_size - GRUB_DISK_SECTOR_SIZE;
|
||||
|
||||
|
||||
grub_linux_tmp_addr = (char *) GRUB_LINUX_BZIMAGE_ADDR + prot_size;
|
||||
|
||||
if (! grub_linux_is_bzimage
|
||||
|
@ -158,7 +158,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
(grub_size_t) grub_linux_real_addr);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (grub_linux_real_addr + GRUB_LINUX_SETUP_MOVE_SIZE
|
||||
> (char *) UINT_TO_PTR (grub_mmap_get_lower ()))
|
||||
{
|
||||
|
@ -196,9 +196,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
else if (grub_memcmp (argv[i], "mem=", 4) == 0)
|
||||
{
|
||||
char *val = argv[i] + 4;
|
||||
|
||||
|
||||
linux_mem_size = grub_strtoul (val, &val, 0);
|
||||
|
||||
|
||||
if (grub_errno)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -207,7 +207,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
else
|
||||
{
|
||||
int shift = 0;
|
||||
|
||||
|
||||
switch (grub_tolower (val[0]))
|
||||
{
|
||||
case 'g':
|
||||
|
@ -251,7 +251,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
dest = grub_stpcpy (grub_linux_tmp_addr + GRUB_LINUX_CL_OFFSET,
|
||||
"BOOT_IMAGE=");
|
||||
dest = grub_stpcpy (dest, argv[0]);
|
||||
|
||||
|
||||
/* Copy kernel parameters. */
|
||||
for (i = 1;
|
||||
i < argc
|
||||
|
@ -266,7 +266,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
len = prot_size;
|
||||
if (grub_file_read (file, (char *) GRUB_LINUX_BZIMAGE_ADDR, len) != len)
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file");
|
||||
|
||||
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
{
|
||||
grub_linux_prot_size = prot_size;
|
||||
|
@ -275,7 +275,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
fail:
|
||||
|
||||
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
|
@ -302,7 +302,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (!loaded)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first.");
|
||||
|
@ -369,7 +369,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
lh->ramdisk_image = addr;
|
||||
lh->ramdisk_size = size;
|
||||
|
||||
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
|
|
@ -33,7 +33,7 @@ grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, UNUSED grub_addr_t *addr)
|
|||
|
||||
if ((paddr < grub_os_area_addr)
|
||||
|| (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size))
|
||||
return grub_error(GRUB_ERR_OUT_OF_RANGE,"Address 0x%x is out of range",
|
||||
return grub_error(GRUB_ERR_OUT_OF_RANGE,"Address 0x%x is out of range",
|
||||
paddr);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
@ -82,7 +82,7 @@ void
|
|||
grub_mb2_arch_unload (struct multiboot_tag_header *tags)
|
||||
{
|
||||
struct multiboot_tag_header *tag;
|
||||
|
||||
|
||||
/* Free all module memory in the tag list. */
|
||||
for_each_tag (tag, tags)
|
||||
{
|
||||
|
|
|
@ -54,10 +54,10 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE, video_hook);
|
||||
else
|
||||
{
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
+ sizeof (DEFAULT_VIDEO_MODE) + 1);
|
||||
if (! tmp)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't allocate temporary storag");
|
||||
grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar);
|
||||
err = grub_video_set_mode (tmp, video_hook);
|
||||
|
@ -86,9 +86,9 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|||
y > 0 ? y : 0,
|
||||
x < 0 ? -x : 0,
|
||||
y < 0 ? -y : 0,
|
||||
min (grub_xnu_bitmap->mode_info.width,
|
||||
mode_info.width),
|
||||
min (grub_xnu_bitmap->mode_info.height,
|
||||
min (grub_xnu_bitmap->mode_info.width,
|
||||
mode_info.width),
|
||||
min (grub_xnu_bitmap->mode_info.height,
|
||||
mode_info.height));
|
||||
if (err)
|
||||
{
|
||||
|
@ -103,8 +103,8 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|||
params->lfb_line_len = mode_info.pitch;
|
||||
|
||||
params->lfb_base = PTR_TO_UINT32 (render_target->data);
|
||||
params->lfb_mode = grub_xnu_bitmap
|
||||
? GRUB_XNU_VIDEO_SPLASH : GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
|
||||
params->lfb_mode = grub_xnu_bitmap
|
||||
? GRUB_XNU_VIDEO_SPLASH : GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
|
|
@ -44,10 +44,10 @@ struct tbl_alias table_aliases[] =
|
|||
{GRUB_EFI_ACPI_TABLE_GUID, "ACPI"},
|
||||
};
|
||||
|
||||
/* The following function is used to be able to debug xnu loader
|
||||
/* The following function is used to be able to debug xnu loader
|
||||
with grub-emu. */
|
||||
#ifdef GRUB_UTIL
|
||||
static grub_err_t
|
||||
static grub_err_t
|
||||
grub_xnu_launch (void)
|
||||
{
|
||||
grub_printf ("Fake launch %x:%p:%p", grub_xnu_entry_point, grub_xnu_arg1,
|
||||
|
@ -78,7 +78,7 @@ readfrequency (const char *str)
|
|||
while (*str)
|
||||
{
|
||||
unsigned long digit;
|
||||
|
||||
|
||||
digit = grub_tolower (*str) - '0';
|
||||
if (digit > 9)
|
||||
break;
|
||||
|
@ -95,7 +95,7 @@ readfrequency (const char *str)
|
|||
while (*str)
|
||||
{
|
||||
unsigned long digit;
|
||||
|
||||
|
||||
digit = grub_tolower (*str) - '0';
|
||||
if (digit > 9)
|
||||
break;
|
||||
|
@ -125,7 +125,7 @@ guessfsb (void)
|
|||
|
||||
if (! grub_cpu_is_cpuid_supported ())
|
||||
return sane_value;
|
||||
|
||||
|
||||
#ifdef APPLE_CC
|
||||
asm volatile ("movl $0, %%eax\n"
|
||||
#ifdef __x86_64__
|
||||
|
@ -138,18 +138,18 @@ guessfsb (void)
|
|||
"pop %%rbx\n"
|
||||
#else
|
||||
"pop %%ebx\n"
|
||||
#endif
|
||||
: "=a" (max_cpuid),
|
||||
#endif
|
||||
: "=a" (max_cpuid),
|
||||
"=d" (manufacturer[1]), "=c" (manufacturer[2]));
|
||||
|
||||
|
||||
/* Only Intel for now is done. */
|
||||
if (grub_memcmp (manufacturer + 1, "ineIntel", 12) != 0)
|
||||
return sane_value;
|
||||
|
||||
|
||||
#else
|
||||
asm volatile ("movl $0, %%eax\n"
|
||||
"cpuid"
|
||||
: "=a" (max_cpuid), "=b" (manufacturer[0]),
|
||||
: "=a" (max_cpuid), "=b" (manufacturer[0]),
|
||||
"=d" (manufacturer[1]), "=c" (manufacturer[2]));
|
||||
|
||||
/* Only Intel for now is done. */
|
||||
|
@ -167,7 +167,7 @@ guessfsb (void)
|
|||
"push %%rbx\n"
|
||||
#else
|
||||
"push %%ebx\n"
|
||||
#endif
|
||||
#endif
|
||||
"cpuid\n"
|
||||
#ifdef __x86_64__
|
||||
"pop %%rbx\n"
|
||||
|
@ -175,7 +175,7 @@ guessfsb (void)
|
|||
"pop %%ebx\n"
|
||||
#endif
|
||||
: "=c" (capabilities):
|
||||
: "%rax", "%rdx");
|
||||
: "%rax", "%rdx");
|
||||
#else
|
||||
asm volatile ("movl $1, %%eax\n"
|
||||
"cpuid"
|
||||
|
@ -201,7 +201,7 @@ guessfsb (void)
|
|||
:
|
||||
: "%ecx", "%eax");
|
||||
|
||||
return grub_divmod64 (2000 * tsc_ticks_per_ms,
|
||||
return grub_divmod64 (2000 * tsc_ticks_per_ms,
|
||||
((msrlow >> 7) & 0x3e) + ((msrlow >> 14) & 1), 0);
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
curval = grub_xnu_create_value (&(efikey->first_child), "firmware-vendor");
|
||||
if (! curval)
|
||||
return grub_errno;
|
||||
curval->datasize =
|
||||
curval->datasize =
|
||||
2 * (utf16_strlen (SYSTEM_TABLE_PTR (firmware_vendor)) + 1);
|
||||
curval->data = grub_malloc (curval->datasize);
|
||||
if (! curval->data)
|
||||
|
@ -275,7 +275,7 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
grub_memcpy (curval->data, "EFI64", curval->datasize);
|
||||
|
||||
/* The key "platform". */
|
||||
platformkey = grub_xnu_create_key (&(efikey->first_child),
|
||||
platformkey = grub_xnu_create_key (&(efikey->first_child),
|
||||
"platform");
|
||||
if (! platformkey)
|
||||
return grub_errno;
|
||||
|
@ -292,16 +292,16 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
/* First see if user supplies the value. */
|
||||
char *fsbvar = grub_env_get ("fsb");
|
||||
if (! fsbvar)
|
||||
*((grub_uint64_t *) curval->data) = 0;
|
||||
*((grub_uint64_t *) curval->data) = 0;
|
||||
else
|
||||
*((grub_uint64_t *) curval->data) = readfrequency (fsbvar);
|
||||
/* Try autodetect. */
|
||||
if (! *((grub_uint64_t *) curval->data))
|
||||
*((grub_uint64_t *) curval->data) = guessfsb ();
|
||||
grub_dprintf ("xnu", "fsb autodetected as %llu\n",
|
||||
*((grub_uint64_t *) curval->data) = guessfsb ();
|
||||
grub_dprintf ("xnu", "fsb autodetected as %llu\n",
|
||||
(unsigned long long) *((grub_uint64_t *) curval->data));
|
||||
|
||||
cfgtablekey = grub_xnu_create_key (&(efikey->first_child),
|
||||
cfgtablekey = grub_xnu_create_key (&(efikey->first_child),
|
||||
"configuration-table");
|
||||
if (!cfgtablekey)
|
||||
return grub_errno;
|
||||
|
@ -317,11 +317,11 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
/* Retrieve current key. */
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
{
|
||||
ptr = (void *)
|
||||
ptr = (void *)
|
||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
guid = grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
if (SIZEOF_OF_UINTN == 4)
|
||||
{
|
||||
ptr = UINT_TO_PTR (((grub_efiemu_configuration_table32_t *)
|
||||
|
@ -336,7 +336,7 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
ptr = UINT_TO_PTR (((grub_efiemu_configuration_table64_t *)
|
||||
SYSTEM_TABLE_PTR (configuration_table))[i]
|
||||
.vendor_table);
|
||||
guid =
|
||||
guid =
|
||||
((grub_efiemu_configuration_table64_t *)
|
||||
SYSTEM_TABLE_PTR (configuration_table))[i].vendor_guid;
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
curval->datasize = sizeof (guid);
|
||||
curval->data = grub_malloc (curval->datasize);
|
||||
if (! curval->data)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't create device tree");
|
||||
grub_memcpy (curval->data, &guid, curval->datasize);
|
||||
|
||||
|
@ -373,7 +373,7 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
curval->datasize = SIZEOF_OF_UINTN;
|
||||
curval->data = grub_malloc (curval->datasize);
|
||||
if (! curval->data)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't create device tree");
|
||||
if (SIZEOF_OF_UINTN == 4)
|
||||
*((grub_uint32_t *)curval->data) = PTR_TO_UINT32 (ptr);
|
||||
|
@ -392,14 +392,14 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
curval->datasize = grub_strlen (table_aliases[j].name) + 1;
|
||||
curval->data = grub_malloc (curval->datasize);
|
||||
if (!curval->data)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't create device tree");
|
||||
grub_memcpy (curval->data, table_aliases[j].name, curval->datasize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Create and fill "runtime-services" key. */
|
||||
runtimesrvkey = grub_xnu_create_key (&(efikey->first_child),
|
||||
runtimesrvkey = grub_xnu_create_key (&(efikey->first_child),
|
||||
"runtime-services");
|
||||
if (! runtimesrvkey)
|
||||
return grub_errno;
|
||||
|
@ -409,20 +409,20 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
curval->datasize = SIZEOF_OF_UINTN;
|
||||
curval->data = grub_malloc (curval->datasize);
|
||||
if (! curval->data)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't create device tree");
|
||||
if (SIZEOF_OF_UINTN == 4)
|
||||
*((grub_uint32_t *) curval->data)
|
||||
*((grub_uint32_t *) curval->data)
|
||||
= PTR_TO_UINT32 (SYSTEM_TABLE_PTR (runtime_services));
|
||||
else
|
||||
*((grub_uint64_t *) curval->data)
|
||||
*((grub_uint64_t *) curval->data)
|
||||
= PTR_TO_UINT64 (SYSTEM_TABLE_PTR (runtime_services));
|
||||
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Boot xnu. */
|
||||
grub_err_t
|
||||
grub_err_t
|
||||
grub_xnu_boot (void)
|
||||
{
|
||||
struct grub_xnu_boot_params *bootparams_relloc;
|
||||
|
@ -464,17 +464,17 @@ grub_xnu_boot (void)
|
|||
&map_key, &descriptor_size,
|
||||
&descriptor_version) <= 0)
|
||||
return grub_errno;
|
||||
mmap_relloc_off = (grub_uint8_t *) memory_map
|
||||
mmap_relloc_off = (grub_uint8_t *) memory_map
|
||||
- (grub_uint8_t *) grub_xnu_heap_start;
|
||||
|
||||
firstruntimeaddr = (grub_uint64_t) (-1);
|
||||
firstruntimeaddr = (grub_uint64_t) (-1);
|
||||
lastruntimeaddr = 0;
|
||||
for (i = 0; (unsigned) i < memory_map_size / descriptor_size; i++)
|
||||
{
|
||||
grub_efi_memory_descriptor_t *curdesc = (grub_efi_memory_descriptor_t *)
|
||||
grub_efi_memory_descriptor_t *curdesc = (grub_efi_memory_descriptor_t *)
|
||||
((char *) memory_map + descriptor_size * i);
|
||||
|
||||
/* Some EFI implementations set physical_start to 0 which
|
||||
/* Some EFI implementations set physical_start to 0 which
|
||||
causes XNU crash. */
|
||||
curdesc->virtual_start = curdesc->physical_start;
|
||||
|
||||
|
@ -494,7 +494,7 @@ grub_xnu_boot (void)
|
|||
bootparams_relloc = grub_xnu_heap_malloc (sizeof (*bootparams_relloc));
|
||||
if (! bootparams_relloc)
|
||||
return grub_errno;
|
||||
bootparams_relloc_off = (grub_uint8_t *) bootparams_relloc
|
||||
bootparams_relloc_off = (grub_uint8_t *) bootparams_relloc
|
||||
- (grub_uint8_t *) grub_xnu_heap_start;
|
||||
err = grub_xnu_writetree_toheap (&devtree, &devtreelen);
|
||||
if (err)
|
||||
|
@ -502,10 +502,10 @@ grub_xnu_boot (void)
|
|||
bootparams_relloc = (struct grub_xnu_boot_params *)
|
||||
(bootparams_relloc_off + (grub_uint8_t *) grub_xnu_heap_start);
|
||||
|
||||
grub_memcpy (bootparams_relloc->cmdline, grub_xnu_cmdline,
|
||||
grub_memcpy (bootparams_relloc->cmdline, grub_xnu_cmdline,
|
||||
sizeof (bootparams_relloc->cmdline));
|
||||
|
||||
bootparams_relloc->devtree = ((char *) devtree - grub_xnu_heap_start)
|
||||
bootparams_relloc->devtree = ((char *) devtree - grub_xnu_heap_start)
|
||||
+ grub_xnu_heap_will_be_at;
|
||||
bootparams_relloc->devtreelen = devtreelen;
|
||||
|
||||
|
@ -513,41 +513,41 @@ grub_xnu_boot (void)
|
|||
bootparams_relloc->heap_size = grub_xnu_heap_size;
|
||||
|
||||
bootparams_relloc->efi_mmap = grub_xnu_heap_will_be_at + mmap_relloc_off;
|
||||
bootparams_relloc->efi_mmap_size = memory_map_size;
|
||||
bootparams_relloc->efi_mem_desc_size = descriptor_size;
|
||||
bootparams_relloc->efi_mem_desc_version = descriptor_version;
|
||||
bootparams_relloc->efi_mmap_size = memory_map_size;
|
||||
bootparams_relloc->efi_mem_desc_size = descriptor_size;
|
||||
bootparams_relloc->efi_mem_desc_version = descriptor_version;
|
||||
|
||||
bootparams_relloc->efi_runtime_first_page = firstruntimeaddr
|
||||
bootparams_relloc->efi_runtime_first_page = firstruntimeaddr
|
||||
/ GRUB_XNU_PAGESIZE;
|
||||
bootparams_relloc->efi_runtime_npages
|
||||
= ((lastruntimeaddr + GRUB_XNU_PAGESIZE - 1) / GRUB_XNU_PAGESIZE)
|
||||
bootparams_relloc->efi_runtime_npages
|
||||
= ((lastruntimeaddr + GRUB_XNU_PAGESIZE - 1) / GRUB_XNU_PAGESIZE)
|
||||
- (firstruntimeaddr / GRUB_XNU_PAGESIZE);
|
||||
bootparams_relloc->efi_uintnbits = SIZEOF_OF_UINTN * 8;
|
||||
bootparams_relloc->efi_system_table
|
||||
bootparams_relloc->efi_system_table
|
||||
= PTR_TO_UINT32 (grub_autoefi_system_table);
|
||||
|
||||
bootparams_relloc->verminor = GRUB_XNU_BOOTARGS_VERMINOR;
|
||||
bootparams_relloc->verminor = GRUB_XNU_BOOTARGS_VERMINOR;
|
||||
bootparams_relloc->vermajor = GRUB_XNU_BOOTARGS_VERMAJOR;
|
||||
|
||||
/* Parameters for asm helper. */
|
||||
grub_xnu_stack = bootparams_relloc->heap_start
|
||||
grub_xnu_stack = bootparams_relloc->heap_start
|
||||
+ bootparams_relloc->heap_size + GRUB_XNU_PAGESIZE;
|
||||
grub_xnu_arg1 = bootparams_relloc_off + grub_xnu_heap_will_be_at;
|
||||
#ifndef GRUB_UTIL
|
||||
grub_xnu_launch = (void (*) (void))
|
||||
grub_xnu_launch = (void (*) (void))
|
||||
(grub_xnu_heap_start + grub_xnu_heap_size);
|
||||
#endif
|
||||
grub_dprintf ("xnu", "eip=%x\n", grub_xnu_entry_point);
|
||||
grub_dprintf ("xnu", "launch=%p\n", grub_xnu_launch);
|
||||
|
||||
const char *debug = grub_env_get ("debug");
|
||||
|
||||
|
||||
if (debug && (grub_strword (debug, "all") || grub_strword (debug, "xnu")))
|
||||
{
|
||||
grub_printf ("Press any key to launch xnu\n");
|
||||
grub_getkey ();
|
||||
}
|
||||
|
||||
|
||||
/* Set video. */
|
||||
err = grub_xnu_set_video (bootparams_relloc);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
|
@ -564,8 +564,8 @@ grub_xnu_boot (void)
|
|||
bootparams_relloc->lfb_base = 0;
|
||||
}
|
||||
|
||||
grub_memcpy (grub_xnu_heap_start + grub_xnu_heap_size,
|
||||
grub_xnu_launcher_start,
|
||||
grub_memcpy (grub_xnu_heap_start + grub_xnu_heap_size,
|
||||
grub_xnu_launcher_start,
|
||||
grub_xnu_launcher_end - grub_xnu_launcher_start);
|
||||
|
||||
|
||||
|
|
|
@ -17,27 +17,27 @@
|
|||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
|
||||
|
||||
.p2align 4 /* force 16-byte alignment */
|
||||
|
||||
VARIABLE(grub_xnu_launcher_start)
|
||||
base:
|
||||
base:
|
||||
cli
|
||||
|
||||
|
||||
#ifndef __x86_64__
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
VARIABLE(grub_xnu_heap_will_be_at)
|
||||
.long 0
|
||||
mov %eax, %edi
|
||||
|
||||
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
VARIABLE(grub_xnu_heap_start)
|
||||
.long 0
|
||||
mov %eax, %esi
|
||||
|
||||
|
||||
/* mov imm32, %ecx */
|
||||
.byte 0xb9
|
||||
VARIABLE(grub_xnu_heap_size)
|
||||
|
@ -57,16 +57,16 @@ VARIABLE(grub_xnu_heap_size)
|
|||
mov %eax, %esi
|
||||
add $(cont0-base), %eax
|
||||
jmp *%eax
|
||||
cont0:
|
||||
cont0:
|
||||
#else
|
||||
xorq %rax, %rax
|
||||
|
||||
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
VARIABLE(grub_xnu_heap_will_be_at)
|
||||
.long 0
|
||||
mov %rax, %rdi
|
||||
|
||||
|
||||
/* mov imm32, %rax */
|
||||
.byte 0x48
|
||||
.byte 0xb8
|
||||
|
@ -74,7 +74,7 @@ VARIABLE(grub_xnu_heap_start)
|
|||
.long 0
|
||||
.long 0
|
||||
mov %rax, %rsi
|
||||
|
||||
|
||||
/* mov imm32, %rcx */
|
||||
.byte 0x48
|
||||
.byte 0xb9
|
||||
|
@ -101,18 +101,18 @@ VARIABLE(grub_xnu_heap_size)
|
|||
#endif
|
||||
jmp *%rax
|
||||
|
||||
cont0:
|
||||
cont0:
|
||||
#ifdef APPLE_CC
|
||||
lea (cont1 - base) (%esi, 1), %eax
|
||||
mov %eax, (jump_vector - base) (%esi, 1)
|
||||
|
||||
lea (gdt - base) (%esi, 1), %eax
|
||||
mov %eax, (gdt_addr - base) (%esi, 1)
|
||||
|
||||
|
||||
/* Switch to compatibility mode. */
|
||||
|
||||
lgdt (gdtdesc - base) (%esi, 1)
|
||||
|
||||
|
||||
/* Update %cs. Thanks to David Miller for pointing this mistake out. */
|
||||
ljmp *(jump_vector - base) (%esi,1)
|
||||
#else
|
||||
|
@ -121,21 +121,21 @@ cont0:
|
|||
|
||||
lea (gdt - base) (%rsi, 1), %rax
|
||||
mov %rax, (gdt_addr - base) (%rsi, 1)
|
||||
|
||||
|
||||
/* Switch to compatibility mode. */
|
||||
|
||||
lgdt (gdtdesc - base) (%rsi, 1)
|
||||
|
||||
|
||||
/* Update %cs. Thanks to David Miller for pointing this mistake out. */
|
||||
ljmp *(jump_vector - base) (%rsi, 1)
|
||||
#endif
|
||||
|
||||
|
||||
cont1:
|
||||
.code32
|
||||
|
||||
/* Update other registers. */
|
||||
mov $0x18, %eax
|
||||
mov %eax, %ds
|
||||
mov %eax, %ds
|
||||
mov %eax, %es
|
||||
mov %eax, %fs
|
||||
mov %eax, %gs
|
||||
|
@ -158,10 +158,10 @@ cont1:
|
|||
mov %eax, %cr4
|
||||
|
||||
jmp cont2
|
||||
cont2:
|
||||
cont2:
|
||||
#endif
|
||||
.code32
|
||||
|
||||
|
||||
/* Registers on XNU boot: eip, esp and eax. */
|
||||
/* mov imm32, %ecx */
|
||||
.byte 0xb9
|
||||
|
@ -183,29 +183,29 @@ VARIABLE (grub_xnu_stack)
|
|||
#ifdef __x86_64__
|
||||
/* GDT. Copied from loader/i386/linux.c. */
|
||||
.p2align 4
|
||||
gdt:
|
||||
gdt:
|
||||
/* NULL. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
|
||||
/* Reserved. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
|
||||
/* Code segment. */
|
||||
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
|
||||
|
||||
|
||||
/* Data segment. */
|
||||
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
|
||||
|
||||
gdtdesc:
|
||||
gdtdesc:
|
||||
.word 31
|
||||
gdt_addr:
|
||||
gdt_addr:
|
||||
/* Filled by the code. */
|
||||
.quad 0
|
||||
|
||||
|
||||
.p2align 4
|
||||
jump_vector:
|
||||
/* Jump location. Is filled by the code */
|
||||
.long 0
|
||||
.long 0x10
|
||||
.long 0x10
|
||||
#endif
|
||||
VARIABLE(grub_xnu_launcher_end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue