linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [1/5][POWERPC] boot: prepare for zImage.kexec
@ 2006-06-29 13:25 Milton Miller
  0 siblings, 0 replies; 3+ messages in thread
From: Milton Miller @ 2006-06-29 13:25 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras

This patch moves the initializations of prom variables to boot/prom.c
to allow it to be replaced for kexec.   Kexec does not care about
the stdout handle, but will care about the location of the device
tree and will search for RTAS.

It also checks if we stop trying to claim so that we print an error
instead of storing to address -1.

Signed-off-by: Milton Miller <miltonm@bga.com>

Index: kernel/arch/powerpc/boot/main.c
===================================================================
--- kernel.orig/arch/powerpc/boot/main.c	2006-06-29 02:14:51.347560058 -0500
+++ kernel/arch/powerpc/boot/main.c	2006-06-29 02:14:57.344543429 -0500
@@ -17,14 +17,12 @@
 #include "prom.h"
 #include "zlib.h"
 
-extern void flush_cache(void *, unsigned long);
-
-
 /* Value picked to match that used by yaboot */
 #define PROG_START	0x01400000	/* only used on 64-bit systems */
-#define RAM_END		(512<<20)	/* Fixme: use OF */
 #define	ONE_MB		0x100000
 
+unsigned long ram_end;		/* end of usable memory, set by init_prom */
+
 extern char _start[];
 extern char __bss_start[];
 extern char _end[];
@@ -119,7 +117,7 @@ static unsigned long try_claim(unsigned 
 {
 	unsigned long addr = 0;
 
-	for(; claim_base < RAM_END; claim_base += ONE_MB) {
+	for(; claim_base < ram_end; claim_base += ONE_MB) {
 #ifdef DEBUG
 		printf("    trying: 0x%08lx\n\r", claim_base);
 #endif
@@ -127,7 +125,7 @@ static unsigned long try_claim(unsigned 
 		if ((void *)addr != (void *)-1)
 			break;
 	}
-	if (addr == 0)
+	if ((addr == 0) || (void *)addr == (void *)-1)
 		return 0;
 	claim_base = PAGE_ALIGN(claim_base + size);
 	return addr;
@@ -211,12 +209,7 @@ void start(unsigned long a1, unsigned lo
 
 	memset(__bss_start, 0, _end - __bss_start);
 
-	prom = (int (*)(void *)) promptr;
-	chosen_handle = finddevice("/chosen");
-	if (chosen_handle == (void *) -1)
-		exit();
-	if (getprop(chosen_handle, "stdout", &stdout, sizeof(stdout)) != 4)
-		exit();
+	init_prom(a1, a2, promptr);
 
 	printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r", _start, sp);
 
@@ -297,6 +290,7 @@ void start(unsigned long a1, unsigned lo
 	vmlinux.addr += elfoffset;
 
 	flush_cache((void *)vmlinux.addr, vmlinux.size);
+	prom_smp_hook(vmlinux.addr);
 
 	kernel_entry = (kernel_entry_t)vmlinux.addr;
 #ifdef DEBUG
Index: kernel/arch/powerpc/boot/prom.c
===================================================================
--- kernel.orig/arch/powerpc/boot/prom.c	2006-06-29 02:14:51.379554992 -0500
+++ kernel/arch/powerpc/boot/prom.c	2006-06-29 02:48:30.069204787 -0500
@@ -16,6 +16,22 @@ int (*prom)(void *);
 phandle chosen_handle;
 ihandle stdout;
 
+void init_prom(unsigned long a1, unsigned long a2, void *p)
+{
+	prom = (int (*)(void *)) p;
+	chosen_handle = finddevice("/chosen");
+	if (chosen_handle == (void *) -1)
+		exit();
+	if (getprop(chosen_handle, "stdout", &stdout, sizeof(stdout)) != 4)
+		exit();
+	ram_end = (512<<20);	/* Fixme: use OF */
+}
+
+void prom_smp_hook(unsigned long kernel_start)
+{
+	return;
+}
+
 int call_prom(const char *service, int nargs, int nret, ...)
 {
 	int i;
Index: kernel/arch/powerpc/boot/prom.h
===================================================================
--- kernel.orig/arch/powerpc/boot/prom.h	2006-06-29 02:14:51.429547077 -0500
+++ kernel/arch/powerpc/boot/prom.h	2006-06-29 02:14:57.348542796 -0500
@@ -12,8 +12,10 @@ int	call_prom(const char *service, int n
 int	call_prom_ret(const char *service, int nargs, int nret,
 		      unsigned int *rets, ...);
 
-extern int write(void *handle, void *ptr, int nb);
-extern void *claim(unsigned long virt, unsigned long size, unsigned long aln);
+void init_prom(unsigned long a1, unsigned long a2, void *p);
+void prom_smp_hook(unsigned long kernel_start);
+int write(void *handle, void *ptr, int nb);
+void *claim(unsigned long virt, unsigned long size, unsigned long aln);
 
 static inline void exit(void)
 {
@@ -31,4 +33,9 @@ static inline int getprop(void *phandle,
 	return call_prom("getprop", 4, 1, phandle, name, buf, buflen);
 }
 
+
+extern unsigned long ram_end;		/* end of usable memory */
+
+extern void flush_cache(void *, unsigned long);
+
 #endif				/* _PPC_BOOT_PROM_H_ */

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [0/5][POWERPC] boot: create zImage.kexec #2
@ 2006-07-01 23:46 Milton Miller
  2006-07-01 23:46 ` [1/5][POWERPC] boot: prepare for zImage.kexec Milton Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Milton Miller @ 2006-07-01 23:46 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Sam Ravnborg

What follows is a series of 5 patches that take the existing zImge code
from the arch/powerpc/boot directory and add an alternative image that
will boot with a device tree struct but not with a prom interface
callback.

It searches the flat device tree (read-only) to find the
memory size, reserved ranges, and  rtas.  Messages are sent through
rtas to eiher the new for cell put-term-char or display-character
interfaces.


Status:  I changed more of the makefile to if_changed_dep.  I updated
the rules to not do if_changed and cmd when changing the same file.

Patches 4 and 5 have been rediffed and __ENTRY__ and __BASE__ are now
caps instead of lowercase in patch 5.

Unfornately I could not get my test and build machines talking due
to network problems, and thereefore was unable to regression test
the output.  Therefore the state is still 'it worked before I moved
code among the files' and 'display-character untested'.

Without [KBUILD] allow any PHONY in if_changed_dep it causes all
the files in boot to be built each time, unless we do some alternative,
either make COPYHEADERS a real dummy that we touch if it doesn't
exist, or just say rebuild all sources when any .h in the kernel
tree changes and collapse the dependency.

Its this fragment:

+$(obj-boot):  COPYHEADERS
+COPYHEADERS:	$(addprefix $(obj)/,$(linuxheader) $(zlibheader))
+PHONY	+= COPYHEADERS




 [1/5][POWERPC] boot: prepare for zImage.kexec
	I tried to keep the changes to main.c and prom.h minimal.  

 [2/5][POWERPC] boot: Add kexec callable zImage wrapper
	The actual code and crt0 for this method.

 [3/5][POWERPC] boot: use more Kbuild rules
	I had a bit of trouble with rebuilds.  This trys to get some
	rules more right.  

	It also renames zliblinuxheader to linuxheader as the next
	patch will add stringify.h to the list, and renames
	OBJCOPYFLAGS to allow usage of the $(objcopy) rule.

 [4/5][POWERPC] boot: Makefile and linker scripts for zImage.kexec
	Delta to above and inker scripts for the existing link.
	zImage.kexec is 32 bit, there is also altnernate link that
	pretends to be 64 bit which allows kexec-tools to load it
	without writing ompat code.

 [5/5][POWERPC] boot: generate lds file from lds.S
	An alterative file ploferations, generate the lds from .S using
	the Kbuild rule.  If you like this patch then I can avoid creating
	two files that are immediately removed.
milton

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

end of thread, other threads:[~2006-07-07 10:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-29 13:25 [1/5][POWERPC] boot: prepare for zImage.kexec Milton Miller
  -- strict thread matches above, loose matches on Subject: below --
2006-07-01 23:46 [0/5][POWERPC] boot: create zImage.kexec #2 Milton Miller
2006-07-01 23:46 ` [1/5][POWERPC] boot: prepare for zImage.kexec Milton Miller
2006-07-07 10:35   ` Paul Mackerras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).