Module Name: src
Committed By: nonaka
Date: Sat Feb 11 10:13:46 UTC 2017
Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot efiboot.c efiboot.h
efimemory.c
Log Message:
efiboot: pass memory map after ExitBootService is called to kernel.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/efiboot.c \
src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/efimemory.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.6 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.7
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.6 Mon Feb 6 10:32:35 2017
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot Sat Feb 11 10:13:46 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.6 2017/02/06 10:32:35 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.7 2017/02/11 10:13:46 nonaka Exp $
S= ${.CURDIR}/../../../../..
@@ -61,7 +61,6 @@ CPPFLAGS+= -DSUPPORT_CD9660
CPPFLAGS+= -DSUPPORT_DOSFS
CPPFLAGS+= -DSUPPORT_EXT2FS
CPPFLAGS+= -DPASS_BIOSGEOM
-CPPFLAGS+= -DPASS_MEMMAP
CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
EFIDIR= ${S}/external/bsd/gnu-efi/dist
Index: src/sys/arch/i386/stand/efiboot/efiboot.c
diff -u src/sys/arch/i386/stand/efiboot/efiboot.c:1.1 src/sys/arch/i386/stand/efiboot/efiboot.c:1.2
--- src/sys/arch/i386/stand/efiboot/efiboot.c:1.1 Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/efiboot.c Sat Feb 11 10:13:46 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $ */
+/* $NetBSD: efiboot.c,v 1.2 2017/02/11 10:13:46 nonaka Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <[email protected]>
@@ -97,6 +97,8 @@ efi_cleanup(void)
EFI_MEMORY_DESCRIPTOR *desc;
UINTN NoEntries, MapKey, DescriptorSize;
UINT32 DescriptorVersion;
+ struct btinfo_efimemmap *bim;
+ size_t allocsz;
clearit();
@@ -108,17 +110,26 @@ efi_cleanup(void)
BI_ADD(&btinfo_efi, BTINFO_EFI, sizeof(btinfo_efi));
NoEntries = 0;
- desc = LibMemoryMap(&NoEntries, &MapKey, &DescriptorSize,
- &DescriptorVersion);
+ desc = efi_memory_get_map(&NoEntries, &MapKey, &DescriptorSize,
+ &DescriptorVersion, true);
status = uefi_call_wrapper(BS->ExitBootServices, 2, IH, MapKey);
if (EFI_ERROR(status)) {
FreePool(desc);
- desc = LibMemoryMap(&NoEntries, &MapKey, &DescriptorSize,
- &DescriptorVersion);
+ desc = efi_memory_get_map(&NoEntries, &MapKey, &DescriptorSize,
+ &DescriptorVersion, true);
status = uefi_call_wrapper(BS->ExitBootServices, 2, IH, MapKey);
if (EFI_ERROR(status))
Panic(L"ExitBootServices failed");
}
+
+ allocsz = sizeof(struct btinfo_efimemmap) - 1
+ + NoEntries * DescriptorSize;
+ bim = alloc(allocsz);
+ bim->num = NoEntries;
+ bim->version = DescriptorVersion;
+ bim->size = DescriptorSize;
+ memcpy(bim->memmap, desc, NoEntries * DescriptorSize);
+ BI_ADD(bim, BTINFO_EFIMEMMAP, allocsz);
}
static void
Index: src/sys/arch/i386/stand/efiboot/efiboot.h
diff -u src/sys/arch/i386/stand/efiboot/efiboot.h:1.1 src/sys/arch/i386/stand/efiboot/efiboot.h:1.2
--- src/sys/arch/i386/stand/efiboot/efiboot.h:1.1 Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/efiboot.h Sat Feb 11 10:13:46 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.h,v 1.1 2017/01/24 11:09:14 nonaka Exp $ */
+/* $NetBSD: efiboot.h,v 1.2 2017/02/11 10:13:46 nonaka Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <[email protected]>
@@ -61,6 +61,8 @@ void efi_disk_probe(void);
/* efimemory.c */
void efi_memory_probe(void);
void efi_memory_show_map(bool);
+EFI_MEMORY_DESCRIPTOR *efi_memory_get_map(UINTN *, UINTN *, UINTN *, UINT32 *,
+ bool);
/* panic.c */
__dead VOID Panic(IN CHAR16 *, ...);
Index: src/sys/arch/i386/stand/efiboot/efimemory.c
diff -u src/sys/arch/i386/stand/efiboot/efimemory.c:1.2 src/sys/arch/i386/stand/efiboot/efimemory.c:1.3
--- src/sys/arch/i386/stand/efiboot/efimemory.c:1.2 Fri Feb 3 16:42:26 2017
+++ src/sys/arch/i386/stand/efiboot/efimemory.c Sat Feb 11 10:13:46 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: efimemory.c,v 1.2 2017/02/03 16:42:26 roy Exp $ */
+/* $NetBSD: efimemory.c,v 1.3 2017/02/11 10:13:46 nonaka Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <[email protected]>
@@ -87,9 +87,9 @@ getmemtype(EFI_MEMORY_DESCRIPTOR *md)
return BIM_Reserved;
}
-static EFI_MEMORY_DESCRIPTOR *
-GetMemoryMap(OUT UINTN *NoEntries, OUT UINTN *MapKey, OUT UINTN *DescriptorSize,
- OUT UINT32 *DescriptorVersion, bool sorted)
+EFI_MEMORY_DESCRIPTOR *
+efi_memory_get_map(UINTN *NoEntries, UINTN *MapKey, UINTN *DescriptorSize,
+ UINT32 *DescriptorVersion, bool sorted)
{
EFI_MEMORY_DESCRIPTOR *desc, *md, *next, *target, tmp;
UINTN i, j;
@@ -98,7 +98,7 @@ GetMemoryMap(OUT UINTN *NoEntries, OUT U
desc = LibMemoryMap(NoEntries, MapKey, DescriptorSize,
DescriptorVersion);
if (desc == NULL)
- Panic(L"LibMemoryMap failed");
+ Panic(L"efi_memory_get_map failed");
if (!sorted)
return desc;
@@ -128,7 +128,7 @@ getbasemem(void)
UINT32 DescriptorVersion;
EFI_PHYSICAL_ADDRESS basemem = 0, epa;
- mdtop = GetMemoryMap(&NoEntries, &MapKey, &DescriptorSize,
+ mdtop = efi_memory_get_map(&NoEntries, &MapKey, &DescriptorSize,
&DescriptorVersion, true);
for (i = 0, md = mdtop; i < NoEntries; i++, md = next) {
@@ -167,7 +167,7 @@ getextmemx(void)
bool first16m = true, first4g = true;
int extmem;
- mdtop = GetMemoryMap(&NoEntries, &MapKey, &DescriptorSize,
+ mdtop = efi_memory_get_map(&NoEntries, &MapKey, &DescriptorSize,
&DescriptorVersion, true);
for (i = 0, md = mdtop; i < NoEntries; i++, md = next) {
@@ -223,7 +223,7 @@ efi_memory_probe(void)
UINT32 DescriptorVersion;
int memtype;
- mdtop = GetMemoryMap(&NoEntries, &MapKey, &DescriptorSize,
+ mdtop = efi_memory_get_map(&NoEntries, &MapKey, &DescriptorSize,
&DescriptorVersion, false);
Print(L" mem[");
@@ -266,7 +266,7 @@ efi_memory_show_map(bool sorted)
else
rows -= 2;
- mdtop = GetMemoryMap(&NoEntries, &MapKey, &DescriptorSize,
+ mdtop = efi_memory_get_map(&NoEntries, &MapKey, &DescriptorSize,
&DescriptorVersion, sorted);
for (i = 0, md = mdtop; i < NoEntries; i++, md = next) {
@@ -300,32 +300,6 @@ efi_memory_show_map(bool sorted)
}
void
-bi_getmemmap(void)
-{
- EFI_MEMORY_DESCRIPTOR *md;
- UINTN NoEntries, MapKey, DescriptorSize;
- UINT32 DescriptorVersion;
- struct btinfo_efimemmap *bim;
- size_t allocsz;
-
- md = GetMemoryMap(&NoEntries, &MapKey, &DescriptorSize,
- &DescriptorVersion, true);
-
- allocsz = sizeof(struct btinfo_efimemmap) - 1
- + NoEntries * DescriptorSize;
- bim = alloc(allocsz);
-
- bim->num = NoEntries;
- bim->version = DescriptorVersion;
- bim->size = DescriptorSize;
- memcpy(bim->memmap, md, NoEntries * DescriptorSize);
-
- FreePool(md);
-
- BI_ADD(bim, BTINFO_EFIMEMMAP, allocsz);
-}
-
-void
vpbcopy(const void *va, void *pa, size_t n)
{
memmove(pa, va, n);