Bläddra i källkod

[ioapi] Move get_memmap() to the I/O API group

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@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Piotr Jaroszyński 14 år sedan
förälder
incheckning
5bbad9c8f0

+ 0
- 1
src/arch/i386/core/relocate.c Visa fil

@@ -1,6 +1,5 @@
1 1
 #include <ipxe/io.h>
2 2
 #include <registers.h>
3
-#include <ipxe/memmap.h>
4 3
 
5 4
 /*
6 5
  * Originally by Eric Biederman

+ 1
- 1
src/arch/i386/firmware/pcbios/hidemem.c Visa fil

@@ -23,7 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
23 23
 #include <basemem.h>
24 24
 #include <fakee820.h>
25 25
 #include <ipxe/init.h>
26
-#include <ipxe/memmap.h>
26
+#include <ipxe/io.h>
27 27
 #include <ipxe/hidemem.h>
28 28
 
29 29
 /** Set to true if you want to test a fake E820 map */

+ 4
- 2
src/arch/i386/firmware/pcbios/memmap.c Visa fil

@@ -23,7 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
23 23
 #include <realmode.h>
24 24
 #include <bios.h>
25 25
 #include <memsizes.h>
26
-#include <ipxe/memmap.h>
26
+#include <ipxe/io.h>
27 27
 
28 28
 /**
29 29
  * @file
@@ -282,7 +282,7 @@ static int meme820 ( struct memory_map *memmap ) {
282 282
  *
283 283
  * @v memmap		Memory map to fill in
284 284
  */
285
-void get_memmap ( struct memory_map *memmap ) {
285
+void x86_get_memmap ( struct memory_map *memmap ) {
286 286
 	unsigned int basemem, extmem;
287 287
 	int rc;
288 288
 
@@ -310,3 +310,5 @@ void get_memmap ( struct memory_map *memmap ) {
310 310
 	memmap->regions[1].end = 0x100000 + ( extmem * 1024 );
311 311
 	memmap->count = 2;
312 312
 }
313
+
314
+PROVIDE_IOAPI ( x86, get_memmap, x86_get_memmap );

+ 1
- 1
src/arch/i386/image/com32.c Visa fil

@@ -38,7 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
38 38
 #include <ipxe/image.h>
39 39
 #include <ipxe/segment.h>
40 40
 #include <ipxe/init.h>
41
-#include <ipxe/memmap.h>
41
+#include <ipxe/io.h>
42 42
 
43 43
 struct image_type com32_image_type __image_type ( PROBE_NORMAL );
44 44
 

+ 1
- 1
src/arch/i386/image/multiboot.c Visa fil

@@ -33,7 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
33 33
 #include <ipxe/uaccess.h>
34 34
 #include <ipxe/image.h>
35 35
 #include <ipxe/segment.h>
36
-#include <ipxe/memmap.h>
36
+#include <ipxe/io.h>
37 37
 #include <ipxe/elf.h>
38 38
 #include <ipxe/init.h>
39 39
 #include <ipxe/features.h>

+ 1
- 1
src/arch/i386/interface/pcbios/int13.c Visa fil

@@ -25,7 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
25 25
 #include <assert.h>
26 26
 #include <ipxe/list.h>
27 27
 #include <ipxe/blockdev.h>
28
-#include <ipxe/memmap.h>
28
+#include <ipxe/io.h>
29 29
 #include <realmode.h>
30 30
 #include <bios.h>
31 31
 #include <biosint.h>

+ 1
- 1
src/arch/i386/interface/pcbios/memtop_umalloc.c Visa fil

@@ -29,7 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
29 29
 #include <errno.h>
30 30
 #include <ipxe/uaccess.h>
31 31
 #include <ipxe/hidemem.h>
32
-#include <ipxe/memmap.h>
32
+#include <ipxe/io.h>
33 33
 #include <ipxe/umalloc.h>
34 34
 
35 35
 /** Alignment of external allocated memory */

+ 2
- 1
src/drivers/net/b44.c Visa fil

@@ -43,7 +43,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
43 43
 #include <ipxe/netdevice.h>
44 44
 #include <ipxe/ethernet.h>
45 45
 #include <ipxe/if_ether.h>
46
-#include <ipxe/memmap.h>
47 46
 #include "b44.h"
48 47
 
49 48
 
@@ -89,6 +88,8 @@ int phys_ram_within_limit(u64 limit)
89 88
 	struct memory_region *highest = NULL;
90 89
 	get_memmap(&memmap);
91 90
 
91
+	if (memmap.count == 0)
92
+		return 0;
92 93
 	highest = &memmap.regions[memmap.count - 1];
93 94
 
94 95
 	return (highest->end < limit);

+ 1
- 1
src/image/segment.c Visa fil

@@ -27,7 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
27 27
 
28 28
 #include <errno.h>
29 29
 #include <ipxe/uaccess.h>
30
-#include <ipxe/memmap.h>
30
+#include <ipxe/io.h>
31 31
 #include <ipxe/errortab.h>
32 32
 #include <ipxe/segment.h>
33 33
 

+ 26
- 0
src/include/ipxe/io.h Visa fil

@@ -503,4 +503,30 @@ void mb ( void );
503 503
 #define rmb()	mb()
504 504
 #define wmb()	mb()
505 505
 
506
+/** A usable memory region */
507
+struct memory_region {
508
+	/** Physical start address */
509
+	uint64_t start;
510
+	/** Physical end address */
511
+	uint64_t end;
512
+};
513
+
514
+/** Maximum number of memory regions we expect to encounter */
515
+#define MAX_MEMORY_REGIONS 8
516
+
517
+/** A memory map */
518
+struct memory_map {
519
+	/** Memory regions */
520
+	struct memory_region regions[MAX_MEMORY_REGIONS];
521
+	/** Number of used regions */
522
+	unsigned int count;
523
+};
524
+
525
+/**
526
+ * Get memory map
527
+ *
528
+ * @v memmap		Memory map to fill in
529
+ */
530
+void get_memmap ( struct memory_map *memmap );
531
+
506 532
 #endif /* _IPXE_IO_H */

+ 0
- 36
src/include/ipxe/memmap.h Visa fil

@@ -1,36 +0,0 @@
1
-#ifndef _IPXE_MEMMAP_H
2
-#define _IPXE_MEMMAP_H
3
-
4
-#include <stdint.h>
5
-
6
-/**
7
- * @file
8
- *
9
- * Memory mapping
10
- *
11
- */
12
-
13
-FILE_LICENCE ( GPL2_OR_LATER );
14
-
15
-/** A usable memory region */
16
-struct memory_region {
17
-	/** Physical start address */
18
-	uint64_t start;
19
-	/** Physical end address */
20
-	uint64_t end;
21
-};
22
-
23
-/** Maximum number of memory regions we expect to encounter */
24
-#define MAX_MEMORY_REGIONS 8
25
-
26
-/** A memory map */
27
-struct memory_map {
28
-	/** Memory regions */
29
-	struct memory_region regions[MAX_MEMORY_REGIONS];
30
-	/** Number of used regions */
31
-	unsigned int count;
32
-};
33
-
34
-extern void get_memmap ( struct memory_map *memmap );
35
-
36
-#endif /* _IPXE_MEMMAP_H */

+ 12
- 0
src/interface/efi/efi_io.c Visa fil

@@ -176,6 +176,17 @@ static void efi_iodelay ( void ) {
176 176
 	outb ( 0, 0x80 );
177 177
 }
178 178
 
179
+/**
180
+ * Get memory map
181
+ *
182
+ * Can't be done on EFI so return an empty map
183
+ *
184
+ * @v memmap		Memory map to fill in
185
+ */
186
+static void efi_get_memmap ( struct memory_map *memmap ) {
187
+	memmap->count = 0;
188
+}
189
+
179 190
 PROVIDE_IOAPI_INLINE ( efi, phys_to_bus );
180 191
 PROVIDE_IOAPI_INLINE ( efi, bus_to_phys );
181 192
 PROVIDE_IOAPI_INLINE ( efi, ioremap );
@@ -203,3 +214,4 @@ PROVIDE_IOAPI_INLINE ( efi, outsw );
203 214
 PROVIDE_IOAPI_INLINE ( efi, outsl );
204 215
 PROVIDE_IOAPI ( efi, iodelay, efi_iodelay );
205 216
 PROVIDE_IOAPI_INLINE ( efi, mb );
217
+PROVIDE_IOAPI ( efi, get_memmap, efi_get_memmap );

+ 1
- 1
src/tests/umalloc_test.c Visa fil

@@ -1,7 +1,7 @@
1 1
 #include <stdio.h>
2 2
 #include <ipxe/uaccess.h>
3 3
 #include <ipxe/umalloc.h>
4
-#include <ipxe/memmap.h>
4
+#include <ipxe/io.h>
5 5
 
6 6
 void umalloc_test ( void ) {
7 7
 	struct memory_map memmap;

Laddar…
Avbryt
Spara