Harmonize ieee1275's grub_available_iterate() with the generic

grub_machine_mmap_iterate() interface (fixes a recently-introduced
        build problem on i386-ieee1275):
        * kern/ieee1275/openfw.c (grub_available_iterate): Moved from here ...
        * kern/ieee1275/mmap.c (grub_machine_mmap_iterate): ... here.  Add third
        parameter `type'.  Update all users of this function.
        * conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Add
        `kern/ieee1275/mmap.c'.
        * kern/ieee1275/init.c
        * include/grub/ieee1275/ieee1275.h (grub_available_iterate): Replace
        with ...
        (grub_machine_mmap_iterate): ... this.
        * include/grub/i386/pc/memory.h (grub_machine_mmap_iterate): Change
        return type to `grub_err_t'.  Update all implementations of this
        function prototype.
        * include/grub/i386/coreboot/memory.h (grub_machine_mmap_iterate):
        Likewise.
This commit is contained in:
robertmh 2008-11-20 20:30:24 +00:00
parent 40f9faa4de
commit 79d29fd7b8
12 changed files with 124 additions and 67 deletions

View file

@ -12,6 +12,24 @@
* loader/i386/linux.c (allocate_pages): Fix a warning. * loader/i386/linux.c (allocate_pages): Fix a warning.
Move comment text to `#error' stanza. Move comment text to `#error' stanza.
Harmonize ieee1275's grub_available_iterate() with the generic
grub_machine_mmap_iterate() interface (fixes a recently-introduced
build problem on i386-ieee1275):
* kern/ieee1275/openfw.c (grub_available_iterate): Moved from here ...
* kern/ieee1275/mmap.c (grub_machine_mmap_iterate): ... here. Add third
parameter `type'. Update all users of this function.
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Add
`kern/ieee1275/mmap.c'.
* kern/ieee1275/init.c
* include/grub/ieee1275/ieee1275.h (grub_available_iterate): Replace
with ...
(grub_machine_mmap_iterate): ... this.
* include/grub/i386/pc/memory.h (grub_machine_mmap_iterate): Change
return type to `grub_err_t'. Update all implementations of this
function prototype.
* include/grub/i386/coreboot/memory.h (grub_machine_mmap_iterate):
Likewise.
2008-11-19 Robert Millan <rmh@aybabtu.com> 2008-11-19 Robert Millan <rmh@aybabtu.com>
* loader/i386/pc/linux.c (grub_rescue_cmd_initrd): Fix a typo. * loader/i386/pc/linux.c (grub_rescue_cmd_initrd): Fix a typo.

View file

@ -334,6 +334,7 @@ kern/i386/pc/startup.S
kern/ieee1275/cmain.c kern/ieee1275/cmain.c
kern/ieee1275/ieee1275.c kern/ieee1275/ieee1275.c
kern/ieee1275/init.c kern/ieee1275/init.c
kern/ieee1275/mmap.c
kern/ieee1275/openfw.c kern/ieee1275/openfw.c
kern/powerpc/cache.S kern/powerpc/cache.S
kern/powerpc/dl.c kern/powerpc/dl.c

View file

@ -14,6 +14,7 @@ pkglib_PROGRAMS = kernel.elf
# For kernel.elf. # For kernel.elf.
kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \ kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \
kern/ieee1275/init.c \ kern/ieee1275/init.c \
kern/ieee1275/mmap.c \
kern/ieee1275/cmain.c kern/ieee1275/openfw.c \ kern/ieee1275/cmain.c kern/ieee1275/openfw.c \
kern/main.c kern/device.c \ kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
@ -26,11 +27,11 @@ kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \
term/ieee1275/ofconsole.c \ term/ieee1275/ofconsole.c \
disk/ieee1275/ofdisk.c \ disk/ieee1275/ofdisk.c \
symlist.c symlist.c
CLEANFILES += kernel.elf kernel_elf-kern_i386_ieee1275_startup.o kernel_elf-kern_i386_ieee1275_init.o kernel_elf-kern_ieee1275_init.o kernel_elf-kern_ieee1275_cmain.o kernel_elf-kern_ieee1275_openfw.o kernel_elf-kern_main.o kernel_elf-kern_device.o kernel_elf-kern_disk.o kernel_elf-kern_dl.o kernel_elf-kern_file.o kernel_elf-kern_fs.o kernel_elf-kern_err.o kernel_elf-kern_misc.o kernel_elf-kern_mm.o kernel_elf-kern_loader.o kernel_elf-kern_rescue.o kernel_elf-kern_term.o kernel_elf-kern_i386_dl.o kernel_elf-kern_parser.o kernel_elf-kern_partition.o kernel_elf-kern_env.o kernel_elf-kern_time.o kernel_elf-kern_generic_millisleep.o kernel_elf-kern_ieee1275_ieee1275.o kernel_elf-term_ieee1275_ofconsole.o kernel_elf-disk_ieee1275_ofdisk.o kernel_elf-symlist.o CLEANFILES += kernel.elf kernel_elf-kern_i386_ieee1275_startup.o kernel_elf-kern_i386_ieee1275_init.o kernel_elf-kern_ieee1275_init.o kernel_elf-kern_ieee1275_mmap.o kernel_elf-kern_ieee1275_cmain.o kernel_elf-kern_ieee1275_openfw.o kernel_elf-kern_main.o kernel_elf-kern_device.o kernel_elf-kern_disk.o kernel_elf-kern_dl.o kernel_elf-kern_file.o kernel_elf-kern_fs.o kernel_elf-kern_err.o kernel_elf-kern_misc.o kernel_elf-kern_mm.o kernel_elf-kern_loader.o kernel_elf-kern_rescue.o kernel_elf-kern_term.o kernel_elf-kern_i386_dl.o kernel_elf-kern_parser.o kernel_elf-kern_partition.o kernel_elf-kern_env.o kernel_elf-kern_time.o kernel_elf-kern_generic_millisleep.o kernel_elf-kern_ieee1275_ieee1275.o kernel_elf-term_ieee1275_ofconsole.o kernel_elf-disk_ieee1275_ofdisk.o kernel_elf-symlist.o
MOSTLYCLEANFILES += kernel_elf-kern_i386_ieee1275_startup.d kernel_elf-kern_i386_ieee1275_init.d kernel_elf-kern_ieee1275_init.d kernel_elf-kern_ieee1275_cmain.d kernel_elf-kern_ieee1275_openfw.d kernel_elf-kern_main.d kernel_elf-kern_device.d kernel_elf-kern_disk.d kernel_elf-kern_dl.d kernel_elf-kern_file.d kernel_elf-kern_fs.d kernel_elf-kern_err.d kernel_elf-kern_misc.d kernel_elf-kern_mm.d kernel_elf-kern_loader.d kernel_elf-kern_rescue.d kernel_elf-kern_term.d kernel_elf-kern_i386_dl.d kernel_elf-kern_parser.d kernel_elf-kern_partition.d kernel_elf-kern_env.d kernel_elf-kern_time.d kernel_elf-kern_generic_millisleep.d kernel_elf-kern_ieee1275_ieee1275.d kernel_elf-term_ieee1275_ofconsole.d kernel_elf-disk_ieee1275_ofdisk.d kernel_elf-symlist.d MOSTLYCLEANFILES += kernel_elf-kern_i386_ieee1275_startup.d kernel_elf-kern_i386_ieee1275_init.d kernel_elf-kern_ieee1275_init.d kernel_elf-kern_ieee1275_mmap.d kernel_elf-kern_ieee1275_cmain.d kernel_elf-kern_ieee1275_openfw.d kernel_elf-kern_main.d kernel_elf-kern_device.d kernel_elf-kern_disk.d kernel_elf-kern_dl.d kernel_elf-kern_file.d kernel_elf-kern_fs.d kernel_elf-kern_err.d kernel_elf-kern_misc.d kernel_elf-kern_mm.d kernel_elf-kern_loader.d kernel_elf-kern_rescue.d kernel_elf-kern_term.d kernel_elf-kern_i386_dl.d kernel_elf-kern_parser.d kernel_elf-kern_partition.d kernel_elf-kern_env.d kernel_elf-kern_time.d kernel_elf-kern_generic_millisleep.d kernel_elf-kern_ieee1275_ieee1275.d kernel_elf-term_ieee1275_ofconsole.d kernel_elf-disk_ieee1275_ofdisk.d kernel_elf-symlist.d
kernel.elf: $(kernel_elf_DEPENDENCIES) kernel_elf-kern_i386_ieee1275_startup.o kernel_elf-kern_i386_ieee1275_init.o kernel_elf-kern_ieee1275_init.o kernel_elf-kern_ieee1275_cmain.o kernel_elf-kern_ieee1275_openfw.o kernel_elf-kern_main.o kernel_elf-kern_device.o kernel_elf-kern_disk.o kernel_elf-kern_dl.o kernel_elf-kern_file.o kernel_elf-kern_fs.o kernel_elf-kern_err.o kernel_elf-kern_misc.o kernel_elf-kern_mm.o kernel_elf-kern_loader.o kernel_elf-kern_rescue.o kernel_elf-kern_term.o kernel_elf-kern_i386_dl.o kernel_elf-kern_parser.o kernel_elf-kern_partition.o kernel_elf-kern_env.o kernel_elf-kern_time.o kernel_elf-kern_generic_millisleep.o kernel_elf-kern_ieee1275_ieee1275.o kernel_elf-term_ieee1275_ofconsole.o kernel_elf-disk_ieee1275_ofdisk.o kernel_elf-symlist.o kernel.elf: $(kernel_elf_DEPENDENCIES) kernel_elf-kern_i386_ieee1275_startup.o kernel_elf-kern_i386_ieee1275_init.o kernel_elf-kern_ieee1275_init.o kernel_elf-kern_ieee1275_mmap.o kernel_elf-kern_ieee1275_cmain.o kernel_elf-kern_ieee1275_openfw.o kernel_elf-kern_main.o kernel_elf-kern_device.o kernel_elf-kern_disk.o kernel_elf-kern_dl.o kernel_elf-kern_file.o kernel_elf-kern_fs.o kernel_elf-kern_err.o kernel_elf-kern_misc.o kernel_elf-kern_mm.o kernel_elf-kern_loader.o kernel_elf-kern_rescue.o kernel_elf-kern_term.o kernel_elf-kern_i386_dl.o kernel_elf-kern_parser.o kernel_elf-kern_partition.o kernel_elf-kern_env.o kernel_elf-kern_time.o kernel_elf-kern_generic_millisleep.o kernel_elf-kern_ieee1275_ieee1275.o kernel_elf-term_ieee1275_ofconsole.o kernel_elf-disk_ieee1275_ofdisk.o kernel_elf-symlist.o
$(TARGET_CC) -o $@ kernel_elf-kern_i386_ieee1275_startup.o kernel_elf-kern_i386_ieee1275_init.o kernel_elf-kern_ieee1275_init.o kernel_elf-kern_ieee1275_cmain.o kernel_elf-kern_ieee1275_openfw.o kernel_elf-kern_main.o kernel_elf-kern_device.o kernel_elf-kern_disk.o kernel_elf-kern_dl.o kernel_elf-kern_file.o kernel_elf-kern_fs.o kernel_elf-kern_err.o kernel_elf-kern_misc.o kernel_elf-kern_mm.o kernel_elf-kern_loader.o kernel_elf-kern_rescue.o kernel_elf-kern_term.o kernel_elf-kern_i386_dl.o kernel_elf-kern_parser.o kernel_elf-kern_partition.o kernel_elf-kern_env.o kernel_elf-kern_time.o kernel_elf-kern_generic_millisleep.o kernel_elf-kern_ieee1275_ieee1275.o kernel_elf-term_ieee1275_ofconsole.o kernel_elf-disk_ieee1275_ofdisk.o kernel_elf-symlist.o $(TARGET_LDFLAGS) $(kernel_elf_LDFLAGS) $(TARGET_CC) -o $@ kernel_elf-kern_i386_ieee1275_startup.o kernel_elf-kern_i386_ieee1275_init.o kernel_elf-kern_ieee1275_init.o kernel_elf-kern_ieee1275_mmap.o kernel_elf-kern_ieee1275_cmain.o kernel_elf-kern_ieee1275_openfw.o kernel_elf-kern_main.o kernel_elf-kern_device.o kernel_elf-kern_disk.o kernel_elf-kern_dl.o kernel_elf-kern_file.o kernel_elf-kern_fs.o kernel_elf-kern_err.o kernel_elf-kern_misc.o kernel_elf-kern_mm.o kernel_elf-kern_loader.o kernel_elf-kern_rescue.o kernel_elf-kern_term.o kernel_elf-kern_i386_dl.o kernel_elf-kern_parser.o kernel_elf-kern_partition.o kernel_elf-kern_env.o kernel_elf-kern_time.o kernel_elf-kern_generic_millisleep.o kernel_elf-kern_ieee1275_ieee1275.o kernel_elf-term_ieee1275_ofconsole.o kernel_elf-disk_ieee1275_ofdisk.o kernel_elf-symlist.o $(TARGET_LDFLAGS) $(kernel_elf_LDFLAGS)
kernel_elf-kern_i386_ieee1275_startup.o: kern/i386/ieee1275/startup.S $(kern/i386/ieee1275/startup.S_DEPENDENCIES) kernel_elf-kern_i386_ieee1275_startup.o: kern/i386/ieee1275/startup.S $(kern/i386/ieee1275/startup.S_DEPENDENCIES)
$(TARGET_CC) -Ikern/i386/ieee1275 -I$(srcdir)/kern/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(kernel_elf_CFLAGS) -MD -c -o $@ $< $(TARGET_CC) -Ikern/i386/ieee1275 -I$(srcdir)/kern/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(kernel_elf_CFLAGS) -MD -c -o $@ $<
@ -44,6 +45,10 @@ kernel_elf-kern_ieee1275_init.o: kern/ieee1275/init.c $(kern/ieee1275/init.c_DEP
$(TARGET_CC) -Ikern/ieee1275 -I$(srcdir)/kern/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(kernel_elf_CFLAGS) -MD -c -o $@ $< $(TARGET_CC) -Ikern/ieee1275 -I$(srcdir)/kern/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(kernel_elf_CFLAGS) -MD -c -o $@ $<
-include kernel_elf-kern_ieee1275_init.d -include kernel_elf-kern_ieee1275_init.d
kernel_elf-kern_ieee1275_mmap.o: kern/ieee1275/mmap.c $(kern/ieee1275/mmap.c_DEPENDENCIES)
$(TARGET_CC) -Ikern/ieee1275 -I$(srcdir)/kern/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(kernel_elf_CFLAGS) -MD -c -o $@ $<
-include kernel_elf-kern_ieee1275_mmap.d
kernel_elf-kern_ieee1275_cmain.o: kern/ieee1275/cmain.c $(kern/ieee1275/cmain.c_DEPENDENCIES) kernel_elf-kern_ieee1275_cmain.o: kern/ieee1275/cmain.c $(kern/ieee1275/cmain.c_DEPENDENCIES)
$(TARGET_CC) -Ikern/ieee1275 -I$(srcdir)/kern/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(kernel_elf_CFLAGS) -MD -c -o $@ $< $(TARGET_CC) -Ikern/ieee1275 -I$(srcdir)/kern/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(kernel_elf_CFLAGS) -MD -c -o $@ $<
-include kernel_elf-kern_ieee1275_cmain.d -include kernel_elf-kern_ieee1275_cmain.d

View file

@ -13,6 +13,7 @@ pkglib_PROGRAMS = kernel.elf
# For kernel.elf. # For kernel.elf.
kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \ kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \
kern/ieee1275/init.c \ kern/ieee1275/init.c \
kern/ieee1275/mmap.c \
kern/ieee1275/cmain.c kern/ieee1275/openfw.c \ kern/ieee1275/cmain.c kern/ieee1275/openfw.c \
kern/main.c kern/device.c \ kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \

View file

@ -24,6 +24,7 @@
#include <grub/i386/pc/memory.h> #include <grub/i386/pc/memory.h>
#ifndef ASM_FILE #ifndef ASM_FILE
#include <grub/err.h>
#include <grub/types.h> #include <grub/types.h>
#endif #endif
@ -61,7 +62,7 @@ typedef struct grub_linuxbios_mem_region *mem_region_t;
void grub_machine_mmap_init (void); void grub_machine_mmap_init (void);
void EXPORT_FUNC(grub_machine_mmap_iterate) grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)); (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
#endif #endif

View file

@ -24,6 +24,7 @@
#include <grub/machine/machine.h> #include <grub/machine/machine.h>
#ifndef ASM_FILE #ifndef ASM_FILE
#include <grub/types.h> #include <grub/types.h>
#include <grub/err.h>
#endif #endif
/* The scratch buffer used in real mode code. */ /* The scratch buffer used in real mode code. */
@ -94,7 +95,7 @@ struct grub_machine_mmap_entry
grub_uint32_t type; grub_uint32_t type;
} __attribute__((packed)); } __attribute__((packed));
void EXPORT_FUNC(grub_machine_mmap_iterate) grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)); (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
#endif #endif

View file

@ -167,8 +167,8 @@ grub_err_t EXPORT_FUNC(grub_devalias_iterate)
(int (*hook) (struct grub_ieee1275_devalias *alias)); (int (*hook) (struct grub_ieee1275_devalias *alias));
grub_err_t EXPORT_FUNC(grub_children_iterate) (char *devpath, grub_err_t EXPORT_FUNC(grub_children_iterate) (char *devpath,
int (*hook) (struct grub_ieee1275_devalias *alias)); int (*hook) (struct grub_ieee1275_devalias *alias));
grub_err_t EXPORT_FUNC(grub_available_iterate) grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t)); (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size); int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path); char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path);

View file

@ -69,7 +69,7 @@ grub_machine_mmap_init ()
} }
} }
void grub_err_t
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)) grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
{ {
struct grub_multiboot_mmap_entry *entry = (void *) kern_multiboot_info.mmap_addr; struct grub_multiboot_mmap_entry *entry = (void *) kern_multiboot_info.mmap_addr;
@ -81,4 +81,6 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
entry = (void *) ((grub_addr_t) entry + entry->size + sizeof (entry->size)); entry = (void *) ((grub_addr_t) entry + entry->size + sizeof (entry->size));
} }
return 0;
} }

View file

@ -18,9 +18,10 @@
#include <grub/machine/init.h> #include <grub/machine/init.h>
#include <grub/machine/memory.h> #include <grub/machine/memory.h>
#include <grub/err.h>
#include <grub/types.h> #include <grub/types.h>
void grub_err_t
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)) grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
{ {
grub_uint32_t cont; grub_uint32_t cont;
@ -57,4 +58,6 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
else else
hook (0x100000, grub_get_memsize (1) << 10, GRUB_MACHINE_MEMORY_AVAILABLE); hook (0x100000, grub_get_memsize (1) << 10, GRUB_MACHINE_MEMORY_AVAILABLE);
} }
return 0;
} }

View file

@ -130,9 +130,12 @@ static void grub_claim_heap (void)
{ {
unsigned long total = 0; unsigned long total = 0;
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len); auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type);
int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len) int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type)
{ {
if (type != 1)
return 0;
len -= 1; /* Required for some firmware. */ len -= 1; /* Required for some firmware. */
/* Never exceed HEAP_MAX_SIZE */ /* Never exceed HEAP_MAX_SIZE */
@ -174,9 +177,9 @@ static void grub_claim_heap (void)
} }
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET)) if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET))
heap_init (HEAP_MAX_ADDR - HEAP_MIN_SIZE, HEAP_MIN_SIZE); heap_init (HEAP_MAX_ADDR - HEAP_MIN_SIZE, HEAP_MIN_SIZE, 1);
else else
grub_available_iterate (heap_init); grub_machine_mmap_iterate (heap_init);
} }
#ifdef __i386__ #ifdef __i386__
@ -187,10 +190,10 @@ grub_uint32_t grub_upper_mem;
static void static void
grub_get_extended_memory (void) grub_get_extended_memory (void)
{ {
auto int NESTED_FUNC_ATTR find_ext_mem (grub_uint64_t addr, grub_uint64_t len); auto int NESTED_FUNC_ATTR find_ext_mem (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type);
int NESTED_FUNC_ATTR find_ext_mem (grub_uint64_t addr, grub_uint64_t len) int NESTED_FUNC_ATTR find_ext_mem (grub_uint64_t addr, grub_uint64_t len, grub_uint32_t type)
{ {
if (addr == 0x100000) if (type == 1 && addr == 0x100000)
{ {
grub_upper_mem = len; grub_upper_mem = len;
return 1; return 1;
@ -199,7 +202,7 @@ grub_get_extended_memory (void)
return 0; return 0;
} }
grub_available_iterate (find_ext_mem); grub_machine_mmap_iterate (find_ext_mem);
} }
#endif #endif

71
kern/ieee1275/mmap.c Normal file
View file

@ -0,0 +1,71 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/machine/memory.h>
#include <grub/ieee1275/ieee1275.h>
#include <grub/types.h>
grub_err_t
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
{
grub_ieee1275_phandle_t root;
grub_ieee1275_phandle_t memory;
grub_uint32_t available[32];
grub_ssize_t available_size;
grub_uint32_t address_cells = 1;
grub_uint32_t size_cells = 1;
int i;
/* Determine the format of each entry in `available'. */
grub_ieee1275_finddevice ("/", &root);
grub_ieee1275_get_integer_property (root, "#address-cells", &address_cells,
sizeof address_cells, 0);
grub_ieee1275_get_integer_property (root, "#size-cells", &size_cells,
sizeof size_cells, 0);
/* Load `/memory/available'. */
if (grub_ieee1275_finddevice ("/memory", &memory))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"Couldn't find /memory node");
if (grub_ieee1275_get_integer_property (memory, "available", available,
sizeof available, &available_size))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"Couldn't examine /memory/available property");
/* Decode each entry and call `hook'. */
i = 0;
available_size /= sizeof (grub_uint32_t);
while (i < available_size)
{
grub_uint64_t address;
grub_uint64_t size;
address = available[i++];
if (address_cells == 2)
address = (address << 32) | available[i++];
size = available[i++];
if (size_cells == 2)
size = (size << 32) | available[i++];
if (hook (address, size, GRUB_MACHINE_MEMORY_AVAILABLE))
break;
}
return grub_errno;
}

View file

@ -147,55 +147,6 @@ nextprop:
return 0; return 0;
} }
grub_err_t grub_available_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t))
{
grub_ieee1275_phandle_t root;
grub_ieee1275_phandle_t memory;
grub_uint32_t available[32];
grub_ssize_t available_size;
grub_uint32_t address_cells = 1;
grub_uint32_t size_cells = 1;
int i;
/* Determine the format of each entry in `available'. */
grub_ieee1275_finddevice ("/", &root);
grub_ieee1275_get_integer_property (root, "#address-cells", &address_cells,
sizeof address_cells, 0);
grub_ieee1275_get_integer_property (root, "#size-cells", &size_cells,
sizeof size_cells, 0);
/* Load `/memory/available'. */
if (grub_ieee1275_finddevice ("/memory", &memory))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"Couldn't find /memory node");
if (grub_ieee1275_get_integer_property (memory, "available", available,
sizeof available, &available_size))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"Couldn't examine /memory/available property");
/* Decode each entry and call `hook'. */
i = 0;
available_size /= sizeof (grub_uint32_t);
while (i < available_size)
{
grub_uint64_t address;
grub_uint64_t size;
address = available[i++];
if (address_cells == 2)
address = (address << 32) | available[i++];
size = available[i++];
if (size_cells == 2)
size = (size << 32) | available[i++];
if (hook (address, size))
break;
}
return grub_errno;
}
/* Call the "map" method of /chosen/mmu. */ /* Call the "map" method of /chosen/mmu. */
static int static int
grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size, grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size,