Pass-through unknown E820 types. It required reorganisation of mmap
module.
This commit is contained in:
parent
f8f3f15559
commit
6de9ee86bf
8 changed files with 111 additions and 139 deletions
|
@ -287,34 +287,15 @@ generate_e820_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
|
|||
|
||||
ctx->cur.addr = addr;
|
||||
ctx->cur.size = size;
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
ctx->cur.type = GRUB_E820_RAM;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_ACPI:
|
||||
ctx->cur.type = GRUB_E820_ACPI;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_NVS:
|
||||
ctx->cur.type = GRUB_E820_NVS;
|
||||
break;
|
||||
case GRUB_MEMORY_COREBOOT_TABLES:
|
||||
if (type == GRUB_MEMORY_COREBOOT_TABLES
|
||||
&& addr == 0)
|
||||
/* Nowadays the tables at 0 don't contain anything important but
|
||||
*BSD needs the memory at 0 for own needs.
|
||||
*/
|
||||
if (addr == 0)
|
||||
ctx->cur.type = GRUB_E820_RAM;
|
||||
else
|
||||
ctx->cur.type = GRUB_E820_COREBOOT_TABLES;
|
||||
break;
|
||||
default:
|
||||
case GRUB_MEMORY_CODE:
|
||||
case GRUB_MEMORY_RESERVED:
|
||||
ctx->cur.type = GRUB_E820_RESERVED;
|
||||
break;
|
||||
}
|
||||
type = GRUB_E820_RAM;
|
||||
|
||||
ctx->cur.type = type;
|
||||
|
||||
/* Merge regions if possible. */
|
||||
if (ctx->count && ctx->cur.type == ctx->prev.type
|
||||
|
|
|
@ -421,36 +421,15 @@ grub_linux_boot_mmap_find (grub_uint64_t addr, grub_uint64_t size,
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* GRUB types conveniently match E820 types. */
|
||||
static int
|
||||
grub_linux_boot_mmap_fill (grub_uint64_t addr, grub_uint64_t size,
|
||||
grub_memory_type_t type, void *data)
|
||||
{
|
||||
struct grub_linux_boot_ctx *ctx = data;
|
||||
|
||||
grub_uint32_t e820_type;
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
e820_type = GRUB_E820_RAM;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_ACPI:
|
||||
e820_type = GRUB_E820_ACPI;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_NVS:
|
||||
e820_type = GRUB_E820_NVS;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_BADRAM:
|
||||
e820_type = GRUB_E820_BADRAM;
|
||||
break;
|
||||
|
||||
default:
|
||||
e820_type = GRUB_E820_RESERVED;
|
||||
}
|
||||
if (grub_e820_add_region (ctx->params->e820_map, &ctx->e820_num,
|
||||
addr, size, e820_type))
|
||||
addr, size, type))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -233,28 +233,7 @@ grub_fill_multiboot_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
|
|||
|
||||
(*mmap_entry)->addr = addr;
|
||||
(*mmap_entry)->len = size;
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_ACPI:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_NVS:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_NVS;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_BADRAM:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_BADRAM;
|
||||
break;
|
||||
|
||||
default:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_RESERVED;
|
||||
break;
|
||||
}
|
||||
(*mmap_entry)->type = type;
|
||||
(*mmap_entry)->size = sizeof (struct multiboot_mmap_entry) - sizeof ((*mmap_entry)->size);
|
||||
(*mmap_entry)++;
|
||||
|
||||
|
|
|
@ -331,28 +331,7 @@ grub_fill_multiboot_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
|
|||
|
||||
(*mmap_entry)->addr = addr;
|
||||
(*mmap_entry)->len = size;
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MEMORY_AVAILABLE:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_ACPI:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_NVS:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_NVS;
|
||||
break;
|
||||
|
||||
case GRUB_MEMORY_BADRAM:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_BADRAM;
|
||||
break;
|
||||
|
||||
default:
|
||||
(*mmap_entry)->type = MULTIBOOT_MEMORY_RESERVED;
|
||||
break;
|
||||
}
|
||||
(*mmap_entry)->type = type;
|
||||
(*mmap_entry)++;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue