[gPXE-devel] [PATCHv2 1/4] [ioapi] Move get_memmap() to the I/O API group

Piotr Jaroszyński p.jaroszynski at gmail.com
Thu Aug 19 10:16:15 EDT 2010


pcbios specific get_memmap() is used by the b44 driver making
all-drivers builds fail on other platforms.  Move it to the I/O API
group and provide a dummy implementation on EFI.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski at gmail.com>
Signed-off-by: Michael Brown <mcb30 at ipxe.org>
---
 src/arch/i386/core/relocate.c                   |    1 -
 src/arch/i386/firmware/pcbios/hidemem.c         |    2 +-
 src/arch/i386/firmware/pcbios/memmap.c          |    6 ++-
 src/arch/i386/image/com32.c                     |    2 +-
 src/arch/i386/image/multiboot.c                 |    2 +-
 src/arch/i386/interface/pcbios/int13.c          |    2 +-
 src/arch/i386/interface/pcbios/memtop_umalloc.c |    2 +-
 src/drivers/net/b44.c                           |    3 +-
 src/image/segment.c                             |    2 +-
 src/include/gpxe/io.h                           |   26 ++++++++++++++++
 src/include/gpxe/memmap.h                       |   36 -----------------------
 src/interface/efi/efi_io.c                      |   12 +++++++
 src/tests/umalloc_test.c                        |    2 +-
 13 files changed, 51 insertions(+), 47 deletions(-)
 delete mode 100644 src/include/gpxe/memmap.h

diff --git a/src/arch/i386/core/relocate.c b/src/arch/i386/core/relocate.c
index 3f6c617..cc99fd7 100644
--- a/src/arch/i386/core/relocate.c
+++ b/src/arch/i386/core/relocate.c
@@ -1,6 +1,5 @@
 #include <gpxe/io.h>
 #include <registers.h>
-#include <gpxe/memmap.h>
 
 /*
  * Originally by Eric Biederman
diff --git a/src/arch/i386/firmware/pcbios/hidemem.c b/src/arch/i386/firmware/pcbios/hidemem.c
index 17082c3..300b76f 100644
--- a/src/arch/i386/firmware/pcbios/hidemem.c
+++ b/src/arch/i386/firmware/pcbios/hidemem.c
@@ -23,7 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <basemem.h>
 #include <fakee820.h>
 #include <gpxe/init.h>
-#include <gpxe/memmap.h>
+#include <gpxe/io.h>
 #include <gpxe/hidemem.h>
 
 /** Set to true if you want to test a fake E820 map */
diff --git a/src/arch/i386/firmware/pcbios/memmap.c b/src/arch/i386/firmware/pcbios/memmap.c
index fcb501d..75646f4 100644
--- a/src/arch/i386/firmware/pcbios/memmap.c
+++ b/src/arch/i386/firmware/pcbios/memmap.c
@@ -23,7 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <realmode.h>
 #include <bios.h>
 #include <memsizes.h>
-#include <gpxe/memmap.h>
+#include <gpxe/io.h>
 
 /**
  * @file
@@ -282,7 +282,7 @@ static int meme820 ( struct memory_map *memmap ) {
  *
  * @v memmap		Memory map to fill in
  */
-void get_memmap ( struct memory_map *memmap ) {
+void x86_get_memmap ( struct memory_map *memmap ) {
 	unsigned int basemem, extmem;
 	int rc;
 
@@ -310,3 +310,5 @@ void get_memmap ( struct memory_map *memmap ) {
 	memmap->regions[1].end = 0x100000 + ( extmem * 1024 );
 	memmap->count = 2;
 }
+
+PROVIDE_IOAPI ( x86, get_memmap, x86_get_memmap );
diff --git a/src/arch/i386/image/com32.c b/src/arch/i386/image/com32.c
index 5e65c0a..ae0e3e7 100644
--- a/src/arch/i386/image/com32.c
+++ b/src/arch/i386/image/com32.c
@@ -38,7 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <gpxe/image.h>
 #include <gpxe/segment.h>
 #include <gpxe/init.h>
-#include <gpxe/memmap.h>
+#include <gpxe/io.h>
 
 struct image_type com32_image_type __image_type ( PROBE_NORMAL );
 
diff --git a/src/arch/i386/image/multiboot.c b/src/arch/i386/image/multiboot.c
index 5b62095..0f5f9b9 100644
--- a/src/arch/i386/image/multiboot.c
+++ b/src/arch/i386/image/multiboot.c
@@ -33,7 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <gpxe/uaccess.h>
 #include <gpxe/image.h>
 #include <gpxe/segment.h>
-#include <gpxe/memmap.h>
+#include <gpxe/io.h>
 #include <gpxe/elf.h>
 #include <gpxe/init.h>
 #include <gpxe/features.h>
diff --git a/src/arch/i386/interface/pcbios/int13.c b/src/arch/i386/interface/pcbios/int13.c
index 87b613a..dfa3b69 100644
--- a/src/arch/i386/interface/pcbios/int13.c
+++ b/src/arch/i386/interface/pcbios/int13.c
@@ -25,7 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <assert.h>
 #include <gpxe/list.h>
 #include <gpxe/blockdev.h>
-#include <gpxe/memmap.h>
+#include <gpxe/io.h>
 #include <realmode.h>
 #include <bios.h>
 #include <biosint.h>
diff --git a/src/arch/i386/interface/pcbios/memtop_umalloc.c b/src/arch/i386/interface/pcbios/memtop_umalloc.c
index 0645fe6..3c93580 100644
--- a/src/arch/i386/interface/pcbios/memtop_umalloc.c
+++ b/src/arch/i386/interface/pcbios/memtop_umalloc.c
@@ -29,7 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <errno.h>
 #include <gpxe/uaccess.h>
 #include <gpxe/hidemem.h>
-#include <gpxe/memmap.h>
+#include <gpxe/io.h>
 #include <gpxe/umalloc.h>
 
 /** Alignment of external allocated memory */
diff --git a/src/drivers/net/b44.c b/src/drivers/net/b44.c
index c48b314..cc498f7 100644
--- a/src/drivers/net/b44.c
+++ b/src/drivers/net/b44.c
@@ -43,7 +43,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <gpxe/netdevice.h>
 #include <gpxe/ethernet.h>
 #include <gpxe/if_ether.h>
-#include <gpxe/memmap.h>
 #include "b44.h"
 
 
@@ -89,6 +88,8 @@ int phys_ram_within_limit(u64 limit)
 	struct memory_region *highest = NULL;
 	get_memmap(&memmap);
 
+	if (memmap.count == 0)
+		return 0;
 	highest = &memmap.regions[memmap.count - 1];
 
 	return (highest->end < limit);
diff --git a/src/image/segment.c b/src/image/segment.c
index 0f50fed..7508c29 100644
--- a/src/image/segment.c
+++ b/src/image/segment.c
@@ -27,7 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 
 #include <errno.h>
 #include <gpxe/uaccess.h>
-#include <gpxe/memmap.h>
+#include <gpxe/io.h>
 #include <gpxe/errortab.h>
 #include <gpxe/segment.h>
 
diff --git a/src/include/gpxe/io.h b/src/include/gpxe/io.h
index 919823d..2c707db 100644
--- a/src/include/gpxe/io.h
+++ b/src/include/gpxe/io.h
@@ -503,4 +503,30 @@ void mb ( void );
 #define rmb()	mb()
 #define wmb()	mb()
 
+/** A usable memory region */
+struct memory_region {
+	/** Physical start address */
+	uint64_t start;
+	/** Physical end address */
+	uint64_t end;
+};
+
+/** Maximum number of memory regions we expect to encounter */
+#define MAX_MEMORY_REGIONS 8
+
+/** A memory map */
+struct memory_map {
+	/** Memory regions */
+	struct memory_region regions[MAX_MEMORY_REGIONS];
+	/** Number of used regions */
+	unsigned int count;
+};
+
+/**
+ * Get memory map
+ *
+ * @v memmap		Memory map to fill in
+ */
+void get_memmap ( struct memory_map *memmap );
+
 #endif /* _GPXE_IO_H */
diff --git a/src/include/gpxe/memmap.h b/src/include/gpxe/memmap.h
deleted file mode 100644
index dc5bec3..0000000
--- a/src/include/gpxe/memmap.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _GPXE_MEMMAP_H
-#define _GPXE_MEMMAP_H
-
-#include <stdint.h>
-
-/**
- * @file
- *
- * Memory mapping
- *
- */
-
-FILE_LICENCE ( GPL2_OR_LATER );
-
-/** A usable memory region */
-struct memory_region {
-	/** Physical start address */
-	uint64_t start;
-	/** Physical end address */
-	uint64_t end;
-};
-
-/** Maximum number of memory regions we expect to encounter */
-#define MAX_MEMORY_REGIONS 8
-
-/** A memory map */
-struct memory_map {
-	/** Memory regions */
-	struct memory_region regions[MAX_MEMORY_REGIONS];
-	/** Number of used regions */
-	unsigned int count;
-};
-
-extern void get_memmap ( struct memory_map *memmap );
-
-#endif /* _GPXE_MEMMAP_H */
diff --git a/src/interface/efi/efi_io.c b/src/interface/efi/efi_io.c
index 0ba16f8..b04da4e 100644
--- a/src/interface/efi/efi_io.c
+++ b/src/interface/efi/efi_io.c
@@ -176,6 +176,17 @@ static void efi_iodelay ( void ) {
 	outb ( 0, 0x80 );
 }
 
+/**
+ * Get memory map
+ *
+ * Can't be done on EFI so return an empty map
+ *
+ * @v memmap		Memory map to fill in
+ */
+static void efi_get_memmap ( struct memory_map *memmap ) {
+	memmap->count = 0;
+}
+
 PROVIDE_IOAPI_INLINE ( efi, phys_to_bus );
 PROVIDE_IOAPI_INLINE ( efi, bus_to_phys );
 PROVIDE_IOAPI_INLINE ( efi, ioremap );
@@ -203,3 +214,4 @@ PROVIDE_IOAPI_INLINE ( efi, outsw );
 PROVIDE_IOAPI_INLINE ( efi, outsl );
 PROVIDE_IOAPI ( efi, iodelay, efi_iodelay );
 PROVIDE_IOAPI_INLINE ( efi, mb );
+PROVIDE_IOAPI ( efi, get_memmap, efi_get_memmap );
diff --git a/src/tests/umalloc_test.c b/src/tests/umalloc_test.c
index 7a36186..54552c3 100644
--- a/src/tests/umalloc_test.c
+++ b/src/tests/umalloc_test.c
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <gpxe/uaccess.h>
 #include <gpxe/umalloc.h>
-#include <gpxe/memmap.h>
+#include <gpxe/io.h>
 
 void umalloc_test ( void ) {
 	struct memory_map memmap;
-- 
1.7.2.1



More information about the gPXE-devel mailing list