lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 19 Apr 2008 13:39:15 -0400
From:	Andres Salomon <dilinger@...ued.net>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Joseph Fannin <jfannin@...il.com>, linux-kernel@...r.kernel.org,
	Ingo Molnar <mingo@...e.hu>, jordan.crouse@....com,
	Mitch Bradley <wmb@...mworks.com>
Subject: [PATCH 2/2] OLPC: drop pre-OpenFirmware workarounds


Prior to including OFW kernel support, we had to work around the lack of
OFW.  Once OFW support is added, we can switch to using it.  This cleans
up some pre-OFW model detection and OFW signature detection.

Note: this should be a bit nicer to non-OLPC hardware.

Signed-off-by: Andres Salomon <dilinger@...ian.org>
---
 arch/x86/kernel/olpc.c |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c
index 11670be..3a05683 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/kernel/olpc.c
@@ -190,11 +190,11 @@ EXPORT_SYMBOL_GPL(olpc_ec_cmd);
 static void __init platform_detect(void)
 {
 	size_t propsize;
-	u32 rev;
+	uint32_t rev;
 
 	if (ofw("getprop", 4, 1, NULL, "board-revision-int", &rev, 4,
 			&propsize) || propsize != 4) {
-		printk(KERN_ERR "ofw: getprop call failed!\n");
+		printk(KERN_ERR "olpc:  ofw getprop call failed!\n");
 		rev = 0;
 	}
 	olpc_platform_info.boardrev = be32_to_cpu(rev);
@@ -207,26 +207,43 @@ static void __init platform_detect(void)
 }
 #endif
 
-static int __init olpc_init(void)
+static int __init ofw_detect(void)
 {
-	unsigned char *romsig;
+	size_t propsize;
+	char romsig[20];
+	ofw_phandle phandle;
 
-	spin_lock_init(&ec_lock);
+	/* Fetch /openprom/model */
+	if (ofw("finddevice", 1, 1, "/openprom", &phandle) || phandle == ~0)
+		return -ENODEV;
 
-	romsig = ioremap(0xffffffc0, 16);
-	if (!romsig)
-		return 0;
+	if (ofw("getprop", 4, 1, phandle, "model", &romsig, sizeof(romsig),
+			&propsize) || propsize < 7)
+		return -ENODEV;
 
+	/* String should look something like "CL1   Q2D08  Q2D" */
 	if (strncmp(romsig, "CL1   Q", 7))
-		goto unmap;
+		return -ENODEV;
 	if (strncmp(romsig+6, romsig+13, 3)) {
-		printk(KERN_INFO "OLPC BIOS signature looks invalid.  "
+		printk(KERN_INFO "olpc:  BIOS signature looks invalid.  "
 				"Assuming not OLPC\n");
-		goto unmap;
+		return -ENODEV;
 	}
 
-	printk(KERN_INFO "OLPC board with OpenFirmware %.16s\n", romsig);
+	/* Looks like we have OLPC's OFW */
 	olpc_platform_info.flags |= OLPC_F_PRESENT;
+	printk(KERN_INFO "olpc:  board with OpenFirmware %.16s\n", romsig);
+
+	return 0;
+}
+
+static int __init olpc_init(void)
+{
+	spin_lock_init(&ec_lock);
+
+	/* ensure OFW is available */
+	if (ofw_detect())
+		return 0;
 
 	/* get the platform revision */
 	platform_detect();
@@ -248,8 +265,6 @@ static int __init olpc_init(void)
 			olpc_platform_info.boardrev >> 4,
 			olpc_platform_info.ecver);
 
-unmap:
-	iounmap(romsig);
 	return 0;
 }
 
-- 
1.5.4.4



-- 
Need a kernel or Debian developer?  Contact me, I'm looking for contracts.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ