All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch committed to the klibc repository: sparc64-specific option
@ 2006-05-25  5:47 H. Peter Anvin
  2006-05-26  5:38 ` Patch committed to the klibc repository: sparc32-specific option H. Peter Anvin
  0 siblings, 1 reply; 2+ messages in thread
From: H. Peter Anvin @ 2006-05-25  5:47 UTC (permalink / raw)
  To: sparclinux

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

I just committed this patch to the klibc repository.  Posting here as an 
FYI and for review.

	-hpa

[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 4551 bytes --]

[klibc] sparc64: transmit arch-specific options to kinit via /arch.cmd

Sparc64 has support for a bunch of architecture-specific options
taken from the PROM.  Convert them to kernel command line form and
write the file /arch.cmd in the rootfs, which can be recovered by
kinit and processed.  The kinit support has already been committed.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>

---
commit 7f62266b726e0d8ca2063af798d8ae8f7059b150
tree 0705b26828dd2feaa09a6c75d15e8da750c4aa88
parent b4f5e719b4f48bf5a4f30c5deb5ee776dc714671
author H. Peter Anvin <hpa@zytor.com> Wed, 24 May 2006 22:44:55 -0700
committer H. Peter Anvin <hpa@zytor.com> Wed, 24 May 2006 22:44:55 -0700

 arch/sparc64/kernel/setup.c |   92 +++++++++++++++++++++++++++++--------------
 1 files changed, 61 insertions(+), 31 deletions(-)

diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index 005167f..b3ee853 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -32,6 +32,7 @@
 #include <linux/interrupt.h>
 #include <linux/cpu.h>
 #include <linux/initrd.h>
+#include <linux/fcntl.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -102,7 +103,7 @@ int obp_system_intr(void)
 	return 0;
 }
 
-/* 
+/*
  * Process kernel command line switches that are specific to the
  * SPARC or that require special low-level processing.
  */
@@ -214,8 +215,6 @@ extern unsigned short ram_flags;
 #define RAMDISK_PROMPT_FLAG		0x8000
 #define RAMDISK_LOAD_FLAG		0x4000
 
-extern int root_mountflags;
-
 char reboot_command[COMMAND_LINE_SIZE];
 
 static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
@@ -315,6 +314,64 @@ static void __init sun4v_patch(void)
 	}
 }
 
+/*
+ * Platform-specific configuration commands which don't come from
+ * the actual kernel command line.  Write them into a file in rootfs
+ * so kinit can pick them up.
+ */
+static int __init set_arch_init_commands(void)
+{
+	int fd = sys_open("/arch.cmd", O_WRONLY|O_CREAT|O_APPEND, 0666);
+	int chosen;
+	u32 cl, sv, gw;
+	char buffer[256];
+	int len = 0;
+
+	if (fd < 0)
+		return fd;
+
+	buffer[0] = 'r';
+	buffer[1] = root_flags ? 'o' : 'w';
+	buffer[2] = '\n';
+	len = 3;
+
+#ifdef CONFIG_BLK_DEV_RAM
+	len += min((int)(sizeof buffer - 1 - len),
+		   snprintf(buffer+len, sizeof buffer - len,
+			    "ramdisk_start=%u\n"
+			    "prompt_ramdisk=%d\n"
+			    "load_ramdisk=%d\n",
+			    ram_flags & RAMDISK_IMAGE_START_MASK,
+			    !!(ram_flags & RAMDISK_PROMPT_FLAG),
+			    !!(ram_flags & RAMDISK_LOAD_FLAG)));
+#endif
+
+	chosen = prom_finddevice("/chosen");
+	cl = prom_getintdefault(chosen, "client-ip", 0);
+	sv = prom_getintdefault(chosen, "server-ip", 0);
+	gw = prom_getintdefault(chosen, "gateway-ip", 0);
+
+	if (cl && sv) {
+		len += min((int)(sizeof buffer - 1 - len),
+			   snprintf(buffer+len, sizeof buffer - len,
+				    "ip=%u.%u.%u.%u:%u.%u.%u.%u:"
+				    "%u.%u.%u.%u\n",
+				    (u8)(cl >> 24), (u8)(cl >> 16),
+				    (u8)(cl >> 8), (u8)cl,
+				    (u8)(sv >> 24), (u8)(sv >> 16),
+				    (u8)(sv >> 8), (u8)sv,
+				    (u8)(gw >> 24), (u8)(gw >> 16),
+				    (u8)(gw >> 8), (u8)gw));
+	}
+
+	sys_write(fd, buffer, len);
+	sys_close(fd);
+
+	return 0;
+}
+
+late_initcall(set_arch_init_commands);
+
 void __init setup_arch(char **cmdline_p)
 {
 	/* Initialize PROM console and command line. */
@@ -346,37 +403,10 @@ void __init setup_arch(char **cmdline_p)
 
 	idprom_init();
 
-	if (!root_flags)
-		root_mountflags &= ~MS_RDONLY;
 	ROOT_DEV = old_decode_dev(root_dev);
-#ifdef CONFIG_BLK_DEV_RAM
-	rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
-	rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
-	rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);	
-#endif
 
 	task_thread_info(&init_task)->kregs = &fake_swapper_regs;
 
-#ifdef CONFIG_IP_PNP
-	if (!ic_set_manually) {
-		int chosen = prom_finddevice ("/chosen");
-		u32 cl, sv, gw;
-		
-		cl = prom_getintdefault (chosen, "client-ip", 0);
-		sv = prom_getintdefault (chosen, "server-ip", 0);
-		gw = prom_getintdefault (chosen, "gateway-ip", 0);
-		if (cl && sv) {
-			ic_myaddr = cl;
-			ic_servaddr = sv;
-			if (gw)
-				ic_gateway = gw;
-#if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
-			ic_proto_enabled = 0;
-#endif
-		}
-	}
-#endif
-
 	smp_setup_cpu_possible_map();
 
 	/* Get boot processor trap_block[] setup.  */
@@ -439,7 +469,7 @@ static int ncpus_probed;
 
 static int show_cpuinfo(struct seq_file *m, void *__unused)
 {
-	seq_printf(m, 
+	seq_printf(m,
 		   "cpu\t\t: %s\n"
 		   "fpu\t\t: %s\n"
 		   "prom\t\t: %s\n"

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Patch committed to the klibc repository: sparc32-specific option
  2006-05-25  5:47 Patch committed to the klibc repository: sparc64-specific option H. Peter Anvin
@ 2006-05-26  5:38 ` H. Peter Anvin
  0 siblings, 0 replies; 2+ messages in thread
From: H. Peter Anvin @ 2006-05-26  5:38 UTC (permalink / raw)
  To: sparclinux

Followup to:  <447544D9.3080702@zytor.com>
By author:    "H. Peter Anvin" <hpa@zytor.com>
In newsgroup: linux.dev.sparclinux
> 
> I just committed this patch to the klibc repository.  Posting here as an 
> FYI and for review.
> 

This is the equivalent for sparc32.  Also committed to the klibc repository.

[klibc] sparc32: transfer arch-specific options to /arch.cmd

Boot options which have been obtained in an architecture-specific
fashion have to be copied to /arch.cmd in the rootfs.  This implements
that functionality for sparc32; the code is identical to sparc64 minus
the openprom support for obtaining nfsroot options.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>

---
commit a998ece20df2928c3bb197bbb9a96ca575d94861
tree 9a85a44945872c18c43031b2d0289111137d252f
parent dd851ddaac9ce9e634c1a062bae13033ccb6fc9f
author H. Peter Anvin <hpa@zytor.com> Thu, 25 May 2006 22:34:47 -0700
committer H. Peter Anvin <hpa@zytor.com> Thu, 25 May 2006 22:34:47 -0700

 arch/sparc/kernel/setup.c |   47 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 3509e43..ae8f283 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -240,8 +240,6 @@ extern unsigned short ram_flags;
 #define RAMDISK_PROMPT_FLAG		0x8000
 #define RAMDISK_LOAD_FLAG		0x4000
 
-extern int root_mountflags;
-
 char reboot_command[COMMAND_LINE_SIZE];
 enum sparc_cpu sparc_cpu_model;
 
@@ -328,14 +326,7 @@ void __init setup_arch(char **cmdline_p)
 	}
 	pfn_base = phys_base >> PAGE_SHIFT;
 
-	if (!root_flags)
-		root_mountflags &= ~MS_RDONLY;
 	ROOT_DEV = old_decode_dev(root_dev);
-#ifdef CONFIG_BLK_DEV_INITRD
-	rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
-	rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
-	rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);	
-#endif
 
 	prom_setsync(prom_sync_me);
 
@@ -386,6 +377,44 @@ static int __init set_preferred_console(
 }
 console_initcall(set_preferred_console);
 
+/*
+ * Platform-specific configuration commands which don't come from
+ * the actual kernel command line.  Write them into a file in rootfs
+ * so kinit can pick them up.
+ */
+static int __init set_arch_init_commands(void)
+{
+	int fd = sys_open("/arch.cmd", O_WRONLY|O_CREAT|O_APPEND, 0666);
+	char buffer[256];
+	int len = 0;
+
+	if (fd < 0)
+		return fd;
+
+	buffer[0] = 'r';
+	buffer[1] = root_flags ? 'o' : 'w';
+	buffer[2] = '\n';
+	len = 3;
+
+#ifdef CONFIG_BLK_DEV_RAM
+	len += min((int)(sizeof buffer - 1 - len),
+		   snprintf(buffer+len, sizeof buffer - len,
+			    "ramdisk_start=%u\n"
+			    "prompt_ramdisk=%d\n"
+			    "load_ramdisk=%d\n",
+			    ram_flags & RAMDISK_IMAGE_START_MASK,
+			    !!(ram_flags & RAMDISK_PROMPT_FLAG),
+			    !!(ram_flags & RAMDISK_LOAD_FLAG)));
+#endif
+
+	sys_write(fd, buffer, len);
+	sys_close(fd);
+
+	return 0;
+}
+
+late_initcall(set_arch_init_commands);
+
 extern char *sparc_cpu_type;
 extern char *sparc_fpu_type;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-26  5:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-25  5:47 Patch committed to the klibc repository: sparc64-specific option H. Peter Anvin
2006-05-26  5:38 ` Patch committed to the klibc repository: sparc32-specific option H. Peter Anvin

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.