From 0bf74728de338eb74962d41234e9cbc7a9a82db2 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 20 Jan 2008 14:08:54 +0000 Subject: [PATCH] 2008-01-20 Robert Millan Fix detection of "real mode" when /options/real-mode? doesn't exist. * include/grub/ieee1275/ieee1275.h (grub_ieee1275_mmu): New variable declaration. * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_mmu): New variable. (grub_ieee1275_find_options): If `grub_ieee1275_mmu' is 0, set `GRUB_IEEE1275_FLAG_REAL_MODE'. (cmain): Intialize `grub_ieee1275_mmu' (using /chosen/mmu integer property). * kern/powerpc/ieee1275/openfw.c (grub_map): Rely on pre-initialized `grub_ieee1275_mmu' rather than obtaining a handler on every call. --- ChangeLog | 14 ++++++++++++++ include/grub/ieee1275/ieee1275.h | 1 + kern/powerpc/ieee1275/cmain.c | 7 ++++++- kern/powerpc/ieee1275/openfw.c | 9 +-------- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c9bc34bc..a4b7d2854 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-01-20 Robert Millan + + Fix detection of "real mode" when /options/real-mode? doesn't exist. + + * include/grub/ieee1275/ieee1275.h (grub_ieee1275_mmu): New variable + declaration. + * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_mmu): New variable. + (grub_ieee1275_find_options): If `grub_ieee1275_mmu' is 0, set + `GRUB_IEEE1275_FLAG_REAL_MODE'. + (cmain): Intialize `grub_ieee1275_mmu' (using /chosen/mmu integer + property). + * kern/powerpc/ieee1275/openfw.c (grub_map): Rely on pre-initialized + `grub_ieee1275_mmu' rather than obtaining a handler on every call. + 2008-01-19 Robert Millan Get rid of confusing function (superceeded by diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 94e8151f8..4ca81a160 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -64,6 +64,7 @@ typedef grub_ieee1275_cell_t grub_ieee1275_ihandle_t; typedef grub_ieee1275_cell_t grub_ieee1275_phandle_t; extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen); +extern grub_ieee1275_ihandle_t EXPORT_VAR(grub_ieee1275_mmu); extern int (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *); enum grub_ieee1275_flag diff --git a/kern/powerpc/ieee1275/cmain.c b/kern/powerpc/ieee1275/cmain.c index 115a16f5f..91e22b374 100644 --- a/kern/powerpc/ieee1275/cmain.c +++ b/kern/powerpc/ieee1275/cmain.c @@ -28,6 +28,7 @@ int (*grub_ieee1275_entry_fn) (void *); grub_ieee1275_phandle_t grub_ieee1275_chosen; +grub_ieee1275_ihandle_t grub_ieee1275_mmu; static grub_uint32_t grub_ieee1275_flags; @@ -58,7 +59,7 @@ grub_ieee1275_find_options (void) grub_ieee1275_finddevice ("/options", &options); rc = grub_ieee1275_get_integer_property (options, "real-mode?", &realmode, sizeof realmode, 0); - if ((rc >= 0) && realmode) + if (((rc >= 0) && realmode) || (grub_ieee1275_mmu == 0)) grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE); grub_ieee1275_finddevice ("/openprom", &openprom); @@ -108,6 +109,10 @@ cmain (void) { grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen); + if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "mmu", &grub_ieee1275_mmu, + sizeof grub_ieee1275_mmu, 0) < 0) + grub_ieee1275_mmu = 0; + grub_ieee1275_find_options (); /* Now invoke the main function. */ diff --git a/kern/powerpc/ieee1275/openfw.c b/kern/powerpc/ieee1275/openfw.c index c9e801355..146c2d800 100644 --- a/kern/powerpc/ieee1275/openfw.c +++ b/kern/powerpc/ieee1275/openfw.c @@ -200,17 +200,10 @@ grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size, grub_uint32_t phys; int catch_result; } args; - grub_ieee1275_ihandle_t mmu; - int len; - - grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "mmu", &mmu, sizeof mmu, - &len); - if (len != sizeof mmu) - return -1; INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1); args.method = "map"; - args.ihandle = mmu; + args.ihandle = grub_ieee1275_mmu; args.phys = phys; args.virt = virt; args.size = size;