]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Move common BIOS/coreboot memory map declarations to
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 23 Nov 2013 11:39:21 +0000 (12:39 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 23 Nov 2013 11:39:21 +0000 (12:39 +0100)
include/grub/i386/memory_raw.h and eliminate duplicate declarations.

ChangeLog
grub-core/boot/i386/qemu/boot.S
grub-core/kern/i386/coreboot/startup.S
grub-core/kern/i386/pc/init.c
grub-core/kern/i386/qemu/startup.S
grub-core/kern/i386/realmode.S
include/grub/i386/coreboot/memory.h
include/grub/i386/memory.h
include/grub/i386/memory_raw.h [new file with mode: 0644]
include/grub/i386/pc/memory.h
include/grub/i386/qemu/memory.h

index fe9bc8d8387a7acbaaa72871ef0e546242394177..0c87f158c86aa2a4871b524b05905a3b60d1719f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-23  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Move common BIOS/coreboot memory map declarations to
+       include/grub/i386/memory_raw.h and eliminate duplicate declarations.
+
 2013-11-22  Andrey Borzenkov <arvidjaar@gmail.com>
 
        * Makefile.am: Add util/garbage-gen.c to EXTRA_DIST.
index ebbfe8828fd613a3dfbe85ab592682652c35fb97..d99e2dde4ab458caf0901fe66e4727ed719da73c 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <config.h>
 #include <grub/symbol.h>
-#include <grub/i386/pc/memory.h>
 #include <grub/machine/memory.h>
 #include <grub/machine/boot.h>
 #include <grub/machine/kernel.h>
index dc2c62a25f4a5ce9bea8367b4fe1366fef9b1515..eb3dd946038c7b4e46c46d150317cd85e1d36ca4 100644 (file)
@@ -17,8 +17,6 @@
  */
 
 #include <grub/symbol.h>
-/* For stack parameters.  */
-#include <grub/i386/pc/memory.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
 #include <grub/offsets.h>
index 2319adf12794ad55074a224e3addc41b2aff6eb8..3c8160aab13050844177449b4dbb3826441c2131 100644 (file)
@@ -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.  */
index 0761807edf71dce78838ded70a53df2b5d3a2c00..3d47d1e4f5e8157bef4c673bf1971d81ca553e3e 100644 (file)
@@ -19,7 +19,6 @@
 #include <config.h>
 #include <grub/symbol.h>
 
-#include <grub/i386/pc/memory.h>
 #include <grub/machine/memory.h>
 #include <grub/machine/kernel.h>
 
index 6403b96992e1aa8a94bdcdef1631b764cbb49e8d..541cedc87bb09a1e9c279cae1d4715db58f248ea 100644 (file)
@@ -16,7 +16,7 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <grub/i386/pc/memory.h>
+#include <grub/machine/memory.h>
 
 /*
  * Note: These functions defined in this file may be called from C.
@@ -196,8 +196,6 @@ protcseg:
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <grub/i386/pc/memory.h>
-
 prot_to_real:
        /* just in case, set GDT */
        lgdt    gdtdesc
index 2859b1d7c7fcd044430709d6ffa0a8fc2b1c28b9..1501772ac302cb0b315bc55b0a7560b5fb37ec49 100644 (file)
 #include <grub/memory.h>
 #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 <grub/i386/memory.h>
+#include <grub/i386/memory_raw.h>
 
 #ifndef ASM_FILE
 
index 582226eedeb410f04dd745f114c0fe0739444801..c9b13288fb25cd982521de4de3cd758183a68bac 100644 (file)
@@ -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 (file)
index 0000000..1292ba7
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+
+#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
index 095c6525d00d35c99300571cef649f1bb9b48b63..d0c5c202e70abece0955b6a9f3e929dd6a079b79 100644 (file)
 #endif
 
 #include <grub/i386/memory.h>
+#include <grub/i386/memory_raw.h>
 
 #include <grub/offsets.h>
 
-/* 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
 
 /* 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
index f152cd782dc7f50a45f1b708b408528a08b28b51..8dd6f7c8cf2f0f002f142feb9adcea940beff267 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _GRUB_MEMORY_MACHINE_HEADER
-#define _GRUB_MEMORY_MACHINE_HEADER      1
-
-#include <grub/symbol.h>
 #include <grub/i386/coreboot/memory.h>
-
-#ifndef ASM_FILE
-#include <grub/err.h>
-#include <grub/types.h>
-#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 */