Move common BIOS/coreboot memory map declarations to

include/grub/i386/memory_raw.h and eliminate duplicate declarations.
This commit is contained in:
Vladimir Serbinenko 2013-11-23 12:39:21 +01:00
parent f65e14dc3a
commit 1bba40f578
11 changed files with 74 additions and 89 deletions

View file

@ -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.

View 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>

View 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>

View 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. */

View 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>

View 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

View file

@ -28,14 +28,8 @@
#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

View 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

View file

@ -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

View file

@ -28,32 +28,10 @@
#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
@ -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

View 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 */