mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-25 00:29:23 +00:00
efi: mm: make MAX_USABLE_ADDRESS platform-specific
This commit is contained in:
1 parent
3f1423e789
commit
16c8f78513
7 files changed
+42
-12
No files matched your search
@@ -1,3 +1,8 @@
|
|||||||
|
2013-12-10 Leif Lindholm <leif.lindholm@linaro.org>
|
||||||
|
|
||||||
|
* make MAX_USABLE_ADDRESS platform-specific
|
||||||
|
* grub-core/kern/efi/mm.c: add Vladimir's new BYTES_TO_PAGES_DOWN macro.
|
||||||
|
|
||||||
2013-12-10 Leif Lindholm <leif.lindholm@linaro.org>
|
2013-12-10 Leif Lindholm <leif.lindholm@linaro.org>
|
||||||
|
|
||||||
* grub-core/lib/fdt.c: change memcpy => grub_memcpy
|
* grub-core/lib/fdt.c: change memcpy => grub_memcpy
|
||||||
|
|||||||
+8
-12
@@ -21,6 +21,7 @@
|
|||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/efi/api.h>
|
#include <grub/efi/api.h>
|
||||||
#include <grub/efi/efi.h>
|
#include <grub/efi/efi.h>
|
||||||
|
#include <grub/cpu/efi/memory.h>
|
||||||
|
|
||||||
#if defined (__i386__) || defined (__x86_64__)
|
#if defined (__i386__) || defined (__x86_64__)
|
||||||
#include <grub/pci.h>
|
#include <grub/pci.h>
|
||||||
@@ -30,14 +31,9 @@
|
|||||||
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
|
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
|
||||||
|
|
||||||
#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12)
|
#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12)
|
||||||
|
#define BYTES_TO_PAGES_DOWN(bytes) ((bytes) >> 12)
|
||||||
#define PAGES_TO_BYTES(pages) ((pages) << 12)
|
#define PAGES_TO_BYTES(pages) ((pages) << 12)
|
||||||
|
|
||||||
#if defined (__code_model_large__) || !defined (__x86_64__)
|
|
||||||
#define MAX_USABLE_ADDRESS 0xffffffff
|
|
||||||
#else
|
|
||||||
#define MAX_USABLE_ADDRESS 0x7fffffff
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The size of a memory map obtained from the firmware. This must be
|
/* The size of a memory map obtained from the firmware. This must be
|
||||||
a multiplier of 4KB. */
|
a multiplier of 4KB. */
|
||||||
#define MEMORY_MAP_SIZE 0x3000
|
#define MEMORY_MAP_SIZE 0x3000
|
||||||
@@ -64,7 +60,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
|||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
/* Limit the memory access to less than 4GB for 32-bit platforms. */
|
/* Limit the memory access to less than 4GB for 32-bit platforms. */
|
||||||
if (address > MAX_USABLE_ADDRESS)
|
if (address > GRUB_EFI_MAX_USABLE_ADDRESS)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -72,7 +68,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
|||||||
if (address == 0)
|
if (address == 0)
|
||||||
{
|
{
|
||||||
type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
|
type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
|
||||||
address = MAX_USABLE_ADDRESS;
|
address = GRUB_EFI_MAX_USABLE_ADDRESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
type = GRUB_EFI_ALLOCATE_ADDRESS;
|
type = GRUB_EFI_ALLOCATE_ADDRESS;
|
||||||
@@ -92,7 +88,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
|||||||
{
|
{
|
||||||
/* Uggh, the address 0 was allocated... This is too annoying,
|
/* Uggh, the address 0 was allocated... This is too annoying,
|
||||||
so reallocate another one. */
|
so reallocate another one. */
|
||||||
address = MAX_USABLE_ADDRESS;
|
address = GRUB_EFI_MAX_USABLE_ADDRESS;
|
||||||
status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
|
status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
|
||||||
grub_efi_free_pages (0, pages);
|
grub_efi_free_pages (0, pages);
|
||||||
if (status != GRUB_EFI_SUCCESS)
|
if (status != GRUB_EFI_SUCCESS)
|
||||||
@@ -325,7 +321,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|||||||
{
|
{
|
||||||
if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
|
if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
|
||||||
#if 1
|
#if 1
|
||||||
&& desc->physical_start <= MAX_USABLE_ADDRESS
|
&& desc->physical_start <= GRUB_EFI_MAX_USABLE_ADDRESS
|
||||||
#endif
|
#endif
|
||||||
&& desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
|
&& desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
|
||||||
&& desc->num_pages != 0)
|
&& desc->num_pages != 0)
|
||||||
@@ -343,9 +339,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|||||||
#if 1
|
#if 1
|
||||||
if (BYTES_TO_PAGES (filtered_desc->physical_start)
|
if (BYTES_TO_PAGES (filtered_desc->physical_start)
|
||||||
+ filtered_desc->num_pages
|
+ filtered_desc->num_pages
|
||||||
> BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL))
|
> BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS))
|
||||||
filtered_desc->num_pages
|
filtered_desc->num_pages
|
||||||
= (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL)
|
= (BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS)
|
||||||
- BYTES_TO_PAGES (filtered_desc->physical_start));
|
- BYTES_TO_PAGES (filtered_desc->physical_start));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
|
#ifndef GRUB_MEMORY_CPU_HEADER
|
||||||
#include <grub/efi/memory.h>
|
#include <grub/efi/memory.h>
|
||||||
|
|
||||||
|
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||||
|
|
||||||
|
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||||
@@ -1 +1,6 @@
|
|||||||
|
#ifndef GRUB_MEMORY_CPU_HEADER
|
||||||
#include <grub/efi/memory.h>
|
#include <grub/efi/memory.h>
|
||||||
|
|
||||||
|
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL
|
||||||
|
|
||||||
|
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||||
@@ -1 +1,6 @@
|
|||||||
|
#ifndef GRUB_MEMORY_CPU_HEADER
|
||||||
#include <grub/efi/memory.h>
|
#include <grub/efi/memory.h>
|
||||||
|
|
||||||
|
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||||
|
|
||||||
|
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||||
@@ -1 +1,6 @@
|
|||||||
|
#ifndef GRUB_MEMORY_CPU_HEADER
|
||||||
#include <grub/efi/memory.h>
|
#include <grub/efi/memory.h>
|
||||||
|
|
||||||
|
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||||
|
|
||||||
|
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||||
@@ -1 +1,10 @@
|
|||||||
|
#ifndef GRUB_MEMORY_CPU_HEADER
|
||||||
#include <grub/efi/memory.h>
|
#include <grub/efi/memory.h>
|
||||||
|
|
||||||
|
#if defined (__code_model_large__)
|
||||||
|
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||||
|
#else
|
||||||
|
#define GRUB_EFI_MAX_USABLE_ADDRESS 0x7fffffff
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||||
Reference in new issue
Block a user