Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1ISzoX-0000Ec-53 for mharc-grub-devel@gnu.org; Wed, 05 Sep 2007 14:41:21 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ISzoV-0000Ce-Bi for grub-devel@gnu.org; Wed, 05 Sep 2007 14:41:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ISzoT-0000AJ-S8 for grub-devel@gnu.org; Wed, 05 Sep 2007 14:41:18 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ISzoT-0000A5-8z for grub-devel@gnu.org; Wed, 05 Sep 2007 14:41:17 -0400 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1ISzoS-0008V1-SY for grub-devel@gnu.org; Wed, 05 Sep 2007 14:41:17 -0400 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1ISzoP-0001bJ-VO for grub-devel@gnu.org; Wed, 05 Sep 2007 20:41:14 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1ISzoL-0007st-3m for grub-devel@gnu.org; Wed, 05 Sep 2007 20:41:09 +0200 Date: Wed, 5 Sep 2007 20:41:09 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20070905184109.GA30281@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Dxnq1zWXvFF0Q93v" Content-Disposition: inline Organization: free as in freedom X-Message-Flag: Microsoft discourages use of Outlook. X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-Detected-Kernel: Genre and OS details not recognized. Subject: detecting other versions of SmartFirmware X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2007 18:41:19 -0000 --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 2007-09-05 Robert Millan * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_test_flag): Detect SmartFirmware version updates (as released by Sven Luther), and avoid setting GRUB_IEEE1275_FLAG_NO_PARTITION_0 or GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS unless the running version is known broken. -- Robert Millan I know my rights; I want my phone call! What use is a phone call, if you are unable to speak? (as seen on /.) --Dxnq1zWXvFF0Q93v Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pegasos.diff" 2007-09-05 Robert Millan * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_test_flag): Detect SmartFirmware version updates (as released by Sven Luther), and avoid setting GRUB_IEEE1275_FLAG_NO_PARTITION_0 or GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS unless the running version is known broken. diff -ur grub2/kern/powerpc/ieee1275/cmain.c grub2.pegasos/kern/powerpc/ieee1275/cmain.c --- grub2/kern/powerpc/ieee1275/cmain.c 2007-07-22 11:16:51.000000000 +0200 +++ grub2.pegasos/kern/powerpc/ieee1275/cmain.c 2007-09-05 20:07:00.000000000 +0200 @@ -30,9 +30,9 @@ grub_ieee1275_phandle_t grub_ieee1275_chosen; static grub_uint32_t grub_ieee1275_flags; - + int grub_ieee1275_test_flag (enum grub_ieee1275_flag flag) { @@ -52,6 +52,8 @@ grub_ieee1275_phandle_t openprom; int rc; int realmode = 0; + char tmp[32]; + int is_smartfirmware = 0; grub_ieee1275_finddevice ("/options", &options); rc = grub_ieee1275_get_property (options, "real-mode?", &realmode, @@ -60,12 +62,42 @@ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE); grub_ieee1275_finddevice ("/openprom", &openprom); - rc = grub_ieee1275_get_property (openprom, "SmartFirmware-version", 0, 0, 0); - if (rc >= 0) + + rc = grub_ieee1275_get_property (openprom, "CodeGen-copyright", + tmp, sizeof (tmp), 0); +#define SF "SmartFirmware(tm)" + if (rc >= 0 && !grub_strncmp (tmp, SF, sizeof (SF) - 1)) + is_smartfirmware = 1; + + if (is_smartfirmware) { - grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); - grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); + /* Broken in all versions */ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + + /* There are two incompatible ways of checking the version number. Try + both. */ + rc = grub_ieee1275_get_property (openprom, "SmartFirmware-version", + tmp, sizeof (tmp), 0); + if (rc < 0) + rc = grub_ieee1275_get_property (openprom, "firmware-version", + tmp, sizeof (tmp), 0); + if (rc >= 0) + { + /* It is tempting to implement a version parser to fail for e.g. anything + below 1.3. However, there's a special situation here. 3rd party + updates which fix the partition bugs are common, and for some reason + their fixes aren't being merged into trunk. So for example we know + that 1.2 and 1.3 are broken, but there's 1.2.99 and 1.3.99 which are + known good (and appliing this workaround would cause breakage). */ + if (!grub_strcmp (tmp, "1.0") + || !grub_strcmp (tmp, "1.1") + || !grub_strcmp (tmp, "1.2") + || !grub_strcmp (tmp, "1.3")) + { + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); + } + } } } --Dxnq1zWXvFF0Q93v--