diff --git a/ChangeLog b/ChangeLog index fe9bc8d83..0c87f158c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-11-23 Vladimir Serbinenko + + Move common BIOS/coreboot memory map declarations to + include/grub/i386/memory_raw.h and eliminate duplicate declarations. + 2013-11-22 Andrey Borzenkov * Makefile.am: Add util/garbage-gen.c to EXTRA_DIST. diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index ebbfe8828..d99e2dde4 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/grub-core/kern/i386/coreboot/startup.S b/grub-core/kern/i386/coreboot/startup.S index dc2c62a25..eb3dd9460 100644 --- a/grub-core/kern/i386/coreboot/startup.S +++ b/grub-core/kern/i386/coreboot/startup.S @@ -17,8 +17,6 @@ */ #include -/* For stack parameters. */ -#include #include #include #include diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c index 2319adf12..3c8160aab 100644 --- a/grub-core/kern/i386/pc/init.c +++ b/grub-core/kern/i386/pc/init.c @@ -161,13 +161,13 @@ mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size, void *data __attribute__ ((unused))) { /* Avoid the lower memory. */ - if (addr < 0x100000) + if (addr < GRUB_MEMORY_MACHINE_UPPER_START) { - if (size <= 0x100000 - addr) + if (size <= GRUB_MEMORY_MACHINE_UPPER_START - addr) return 0; - size -= 0x100000 - addr; - addr = 0x100000; + size -= GRUB_MEMORY_MACHINE_UPPER_START - addr; + addr = GRUB_MEMORY_MACHINE_UPPER_START; } /* Ignore >4GB. */ diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S index 0761807ed..3d47d1e4f 100644 --- a/grub-core/kern/i386/qemu/startup.S +++ b/grub-core/kern/i386/qemu/startup.S @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S index 6403b9699..541cedc87 100644 --- a/grub-core/kern/i386/realmode.S +++ b/grub-core/kern/i386/realmode.S @@ -16,7 +16,7 @@ * along with GRUB. If not, see . */ -#include +#include /* * Note: These functions defined in this file may be called from C. @@ -196,8 +196,6 @@ protcseg: * along with GRUB. If not, see . */ -#include - prot_to_real: /* just in case, set GDT */ lgdt gdtdesc diff --git a/include/grub/i386/coreboot/memory.h b/include/grub/i386/coreboot/memory.h index 2859b1d7c..1501772ac 100644 --- a/include/grub/i386/coreboot/memory.h +++ b/include/grub/i386/coreboot/memory.h @@ -28,14 +28,8 @@ #include #endif -#define GRUB_MEMORY_MACHINE_SCRATCH_ADDR 0x68000 -#define GRUB_MEMORY_MACHINE_SCRATCH_SEG (GRUB_MEMORY_MACHINE_SCRATCH_ADDR >> 4) -#define GRUB_MEMORY_MACHINE_SCRATCH_SIZE 0x10000 - -#define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */ - -#define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */ -#define GRUB_MEMORY_MACHINE_LOWER_SIZE GRUB_MEMORY_MACHINE_UPPER_START +#include +#include #ifndef ASM_FILE diff --git a/include/grub/i386/memory.h b/include/grub/i386/memory.h index 582226eed..c9b13288f 100644 --- a/include/grub/i386/memory.h +++ b/include/grub/i386/memory.h @@ -28,6 +28,9 @@ #define GRUB_MEMORY_CPU_AMD64_MSR 0xc0000080 #define GRUB_MEMORY_CPU_AMD64_MSR_ON 0x00000100 +#define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */ +#define GRUB_MEMORY_MACHINE_LOWER_SIZE GRUB_MEMORY_MACHINE_UPPER_START + #ifndef ASM_FILE #define GRUB_MMAP_MALLOC_LOW 1 diff --git a/include/grub/i386/memory_raw.h b/include/grub/i386/memory_raw.h new file mode 100644 index 000000000..1292ba7db --- /dev/null +++ b/include/grub/i386/memory_raw.h @@ -0,0 +1,58 @@ +/* memory_raw.h - describe the memory map on qemu/coreboot/multiboot/pc */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2007,2008,2009,2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_MEMORY_CPU_RAW_HEADER +#define GRUB_MEMORY_CPU_RAW_HEADER 1 + +/* The scratch buffer used in real mode code. */ +#define GRUB_MEMORY_MACHINE_SCRATCH_ADDR 0x68000 +#define GRUB_MEMORY_MACHINE_SCRATCH_SEG (GRUB_MEMORY_MACHINE_SCRATCH_ADDR >> 4) +#define GRUB_MEMORY_MACHINE_SCRATCH_SIZE 0x9000 + +/* The real mode stack. */ +#define GRUB_MEMORY_MACHINE_REAL_STACK (0x2000 - 0x10) + +/* The size of the protect mode stack. */ +#define GRUB_MEMORY_MACHINE_PROT_STACK_SIZE 0xf000 + +/* The protected mode stack. */ +#define GRUB_MEMORY_MACHINE_PROT_STACK \ + (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + GRUB_MEMORY_MACHINE_SCRATCH_SIZE \ + + GRUB_MEMORY_MACHINE_PROT_STACK_SIZE - 0x10) + +/* The memory area where GRUB uses its own purpose. This part is not added + into free memory for dynamic allocations. */ +#define GRUB_MEMORY_MACHINE_RESERVED_START \ + GRUB_MEMORY_MACHINE_SCRATCH_ADDR +#define GRUB_MEMORY_MACHINE_RESERVED_END \ + (GRUB_MEMORY_MACHINE_PROT_STACK + 0x10) + +/* The code segment of the protected mode. */ +#define GRUB_MEMORY_MACHINE_PROT_MODE_CSEG 0x8 + +/* The data segment of the protected mode. */ +#define GRUB_MEMORY_MACHINE_PROT_MODE_DSEG 0x10 + +/* The code segment of the pseudo real mode. */ +#define GRUB_MEMORY_MACHINE_PSEUDO_REAL_CSEG 0x18 + +/* The data segment of the pseudo real mode. */ +#define GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20 + +#endif diff --git a/include/grub/i386/pc/memory.h b/include/grub/i386/pc/memory.h index 095c6525d..d0c5c202e 100644 --- a/include/grub/i386/pc/memory.h +++ b/include/grub/i386/pc/memory.h @@ -28,32 +28,10 @@ #endif #include +#include #include -/* The scratch buffer used in real mode code. */ -#define GRUB_MEMORY_MACHINE_SCRATCH_ADDR 0x68000 -#define GRUB_MEMORY_MACHINE_SCRATCH_SEG (GRUB_MEMORY_MACHINE_SCRATCH_ADDR >> 4) -#define GRUB_MEMORY_MACHINE_SCRATCH_SIZE 0x9000 - -/* The real mode stack. */ -#define GRUB_MEMORY_MACHINE_REAL_STACK (0x2000 - 0x10) - -/* The size of the protect mode stack. */ -#define GRUB_MEMORY_MACHINE_PROT_STACK_SIZE 0xf000 - -/* The protected mode stack. */ -#define GRUB_MEMORY_MACHINE_PROT_STACK \ - (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + GRUB_MEMORY_MACHINE_SCRATCH_SIZE \ - + GRUB_MEMORY_MACHINE_PROT_STACK_SIZE - 0x10) - -/* The memory area where GRUB uses its own purpose. This part is not added - into free memory for dynamic allocations. */ -#define GRUB_MEMORY_MACHINE_RESERVED_START \ - GRUB_MEMORY_MACHINE_SCRATCH_ADDR -#define GRUB_MEMORY_MACHINE_RESERVED_END \ - (GRUB_MEMORY_MACHINE_PROT_STACK + 0x10) - /* The area where GRUB is decompressed at early startup. */ #define GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR 0x100000 @@ -63,18 +41,6 @@ /* The address where another boot loader is loaded. */ #define GRUB_MEMORY_MACHINE_BOOT_LOADER_ADDR 0x7c00 -/* The code segment of the protected mode. */ -#define GRUB_MEMORY_MACHINE_PROT_MODE_CSEG 0x8 - -/* The data segment of the protected mode. */ -#define GRUB_MEMORY_MACHINE_PROT_MODE_DSEG 0x10 - -/* The code segment of the pseudo real mode. */ -#define GRUB_MEMORY_MACHINE_PSEUDO_REAL_CSEG 0x18 - -/* The data segment of the pseudo real mode. */ -#define GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20 - #define GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR 0x400 #ifndef ASM_FILE diff --git a/include/grub/i386/qemu/memory.h b/include/grub/i386/qemu/memory.h index f152cd782..8dd6f7c8c 100644 --- a/include/grub/i386/qemu/memory.h +++ b/include/grub/i386/qemu/memory.h @@ -1,36 +1 @@ -/* memory.h - describe the memory map */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2007 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#ifndef _GRUB_MEMORY_MACHINE_HEADER -#define _GRUB_MEMORY_MACHINE_HEADER 1 - -#include #include - -#ifndef ASM_FILE -#include -#include -#endif - -#define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */ - -#define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */ -#define GRUB_MEMORY_MACHINE_LOWER_SIZE GRUB_MEMORY_MACHINE_UPPER_START - -#endif /* ! _GRUB_MEMORY_MACHINE_HEADER */