All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: Sven Luther <sven@powerlinux.fr>
Cc: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] efika memory issues
Date: Mon, 30 Jul 2007 22:11:38 +0200	[thread overview]
Message-ID: <20070730201138.GA27359@aragorn> (raw)
In-Reply-To: <20070729193011.GA7033@aragorn>

[-- Attachment #1: Type: text/plain, Size: 1185 bytes --]

On Sun, Jul 29, 2007 at 09:30:11PM +0200, Robert Millan wrote:
> 
> Hi Sven,
> 
> I have a pair of questions about the memory issue..
> 
> [...]

Ok, after some discussion on IRC, and invaluable help by Sven in documenting
smartfirmware behaviour, I came up with this patch.

Please let me know what you think.  If there are no objections I'll check it
in in a few days.

2007-07-30  Robert Millan  <rmh@aybabtu.com>

	* include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): Add
	GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag.
	* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options): Set
	GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag when running
	on an Efika (SmartFirmware).
	* kern/powerpc/ieee1275/init.c (grub_claim_heap): Fail gracefuly when
	addr > heaplimit.
	Use grub_printf instead of grub_error for error reporting, since
	grub_error doesn't work at this point of execution.
	When GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION was set,
	release hardcoded 0x4000:0xffc000 region.

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.

[-- Attachment #2: efika.diff --]
[-- Type: text/x-diff, Size: 3653 bytes --]


2007-07-30  Robert Millan  <rmh@aybabtu.com>

	* include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): Add
	GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag.
	* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options): Set
	GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag when running
	on an Efika (SmartFirmware).
	* kern/powerpc/ieee1275/init.c (grub_claim_heap): Fail gracefuly when
	addr > heaplimit.
	Use grub_printf instead of grub_error for error reporting, since
	grub_error doesn't work at this point of execution.
	When GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION was set,
	release hardcoded 0x4000:0xffc000 region.

Index: include/grub/ieee1275/ieee1275.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/ieee1275/ieee1275.h,v
retrieving revision 1.7
diff -u -r1.7 ieee1275.h
--- include/grub/ieee1275/ieee1275.h	22 Jul 2007 09:05:10 -0000	1.7
+++ include/grub/ieee1275/ieee1275.h	30 Jul 2007 19:52:32 -0000
@@ -82,6 +82,10 @@
 
   /* CodeGen firmware does not correctly implement "output-device output" */
   GRUB_IEEE1275_FLAG_BROKEN_OUTPUT,
+
+  /* Efika version of CodeGen firmware has an available memory region that
+     is not represented in /memory/available.  */
+  GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION,
 };
 
 extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);
Index: kern/powerpc/ieee1275/cmain.c
===================================================================
RCS file: /sources/grub/grub2/kern/powerpc/ieee1275/cmain.c,v
retrieving revision 1.9
diff -u -r1.9 cmain.c
--- kern/powerpc/ieee1275/cmain.c	22 Jul 2007 09:16:51 -0000	1.9
+++ kern/powerpc/ieee1275/cmain.c	30 Jul 2007 19:52:32 -0000
@@ -63,9 +63,14 @@
   rc = grub_ieee1275_get_property (openprom, "SmartFirmware-version", 0, 0, 0);
   if (rc >= 0)
     {
+      char model[32];
       grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
       grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS);
       grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT);
+
+      rc = grub_ieee1275_get_property (openprom, "model", &model, sizeof model, 0);
+      if ((rc >= 0) && !grub_strncmp (model, "EFIKA", 5))
+	grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION);
     }
 }
 
Index: kern/powerpc/ieee1275/init.c
===================================================================
RCS file: /sources/grub/grub2/kern/powerpc/ieee1275/init.c,v
retrieving revision 1.31
diff -u -r1.31 init.c
--- kern/powerpc/ieee1275/init.c	21 Jul 2007 23:32:27 -0000	1.31
+++ kern/powerpc/ieee1275/init.c	30 Jul 2007 19:52:32 -0000
@@ -121,6 +121,12 @@
     len -= 1; /* Required for some firmware.  */
 
     /* Don't claim anything above `heaplimit'.  */
+    if (addr > heaplimit)
+      {
+        grub_printf ("Cannot claim heap above limit (0x%llx > 0x%lx)\n", addr, heaplimit);
+        return GRUB_ERR_OUT_OF_MEMORY;
+      }
+
     if (addr + len > heaplimit)
       len = heaplimit - addr;
 
@@ -128,15 +134,19 @@
       {
 	/* Claim and use it.  */
 	if (grub_claimmap (addr, len) < 0)
-	  return grub_error (GRUB_ERR_OUT_OF_MEMORY,
-			     "Failed to claim heap at 0x%llx, len 0x%llx\n",
-			     addr, len);
+	  {
+	    grub_printf ("Failed to claim heap at 0x%llx, len 0x%llx\n", addr, len);
+	    return GRUB_ERR_OUT_OF_MEMORY;
+	  }
 	grub_mm_init_region ((void *) (grub_addr_t) addr, len);
       }
 
     return 0;
   }
 
+  if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION));
+    grub_ieee1275_release (0x4000, 0xffc000);
+
   grub_available_iterate (heap_init);
 }
 

  reply	other threads:[~2007-07-30 20:08 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-02 18:16 another regression on Efika Robert Millan
2007-07-02 21:14 ` Robert Millan
2007-07-04 16:18 ` Hollis Blanchard
2007-07-10 10:04   ` Jordi Mallach
2007-07-10 14:08     ` memory management issue (Re: another regression on Efika) Robert Millan
2007-07-10 20:32       ` Hollis Blanchard
2007-07-13 22:08         ` Robert Millan
2007-07-24 19:59           ` Robert Millan
2007-07-25 17:51             ` Hollis Blanchard
2007-07-25 20:08               ` Robert Millan
2007-07-25 23:25                 ` Hollis Blanchard
2007-07-27  8:05                   ` Robert Millan
     [not found]                     ` <20070727103310.GA1539@powerlinux.fr>
2007-07-27 19:15                       ` Robert Millan
2007-07-29 19:30                         ` Robert Millan
2007-07-30 20:11                           ` Robert Millan [this message]
2007-07-30 22:35                             ` [PATCH] efika memory issues Hollis Blanchard
2007-07-31 14:38                               ` Robert Millan
2007-07-31 15:55                                 ` Hollis Blanchard
2007-07-31 19:42                                   ` Robert Millan
2007-08-01 17:34                                     ` Hollis Blanchard
2007-08-01 18:27                                       ` Robert Millan
2007-09-30 20:10                                         ` [PATCH] fix memory management on efika/pegasos Robert Millan
2007-10-01 18:18                                           ` Marcin Kurek
2007-10-01 22:25                                           ` Marcin Kurek
2007-10-02 19:42                                             ` Robert Millan
2007-10-03 23:38                                               ` Marcin Kurek
2007-10-04 20:47                                                 ` Robert Millan
2007-07-10 14:10     ` OF disk naming scheme (Re: another regression on Efika) Robert Millan
2007-07-10 19:26       ` Jordi Mallach
2007-07-13 22:16         ` Robert Millan
2007-07-22  9:33           ` Robert Millan
2007-07-22 14:37             ` Marco Gerards
2007-07-22 20:25               ` Robert Millan
2007-08-12 14:56                 ` proposed solution using "ofpathname -a" (Re: OF disk naming scheme) Robert Millan
2007-08-05 10:03 ` updated regression diff (Re: another regression on Efika) Robert Millan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070730201138.GA27359@aragorn \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    --cc=sven@powerlinux.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.