* [1/5][POWERPC] boot: prepare for zImage.kexec
2006-07-01 23:46 ` [0/5][POWERPC] boot: create zImage.kexec #2 Milton Miller
@ 2006-07-01 23:46 ` Milton Miller
2006-07-07 10:35 ` Paul Mackerras
2006-07-01 23:46 ` [2/5][POWERPC] boot: Add kexec callable zImage wrapper Milton Miller
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Milton Miller @ 2006-07-01 23:46 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Sam Ravnborg
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] 8+ messages in thread
* [2/5][POWERPC] boot: Add kexec callable zImage wrapper
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-01 23:46 ` Milton Miller
2006-07-01 23:46 ` [3/5][POWERPC] boot: use more Kbuild rules Milton Miller
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Milton Miller @ 2006-07-01 23:46 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Sam Ravnborg
This code creates a 32 bit zImage wrapper for a 32 or 64 bit PowerPC
Linux kernel. It does not support initrd at present. What it does
give you is a compressed kernel image that is expanded when used.
Limitations:
The memory node off the root with a name starting with "memory" must
contain enough free memory (not in the reserved ranges) in the first
reg range to uncompress the the kenrel with padding.
The claim allocator does not record its handouts.
Signed-off-by: Milton Miller <miltonm@bga.com>
Index: kernel/arch/powerpc/boot/kexec.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/kexec.c 2006-06-29 03:47:06.865856735 -0500
@@ -0,0 +1,476 @@
+/*
+ * Copyright (C) 1997 Paul Mackerras 1997.
+ * Copyright (C) 2006 Milton Miller, IBM Corportation.
+ * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corportation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include <stdarg.h>
+#include <stddef.h>
+#include "string.h"
+#include "stdio.h"
+#include "prom.h"
+#include "page.h"
+#include "dt.h"
+#include "stringify.h"
+
+#define BUG_ON(x) if (x) { printf("zImage BUG %s\n\r", __stringify(x)); exit();}
+
+extern unsigned int gohere; /* slaves poll and branch when told */
+
+int (*prom)(void *);
+phandle chosen_handle;
+ihandle stdout;
+
+#define MAX_MEM 0x80000000
+static unsigned int memsize;
+static unsigned int na=2, ns=1;
+
+
+static struct boot_param_header *initial_boot_params;
+
+static int (*rtas)(void *, void *);
+static void *rtas_data;
+static int rtas_put_term_char;
+static int rtas_display_char;
+
+int call_rtas(int token, int nargs, int nret, ...)
+{
+ int i;
+ struct rtas_args {
+ int token;
+ int nargs;
+ int nret;
+ unsigned int args[12];
+ } args;
+ va_list list;
+
+ if (!rtas || !token)
+ return -1; /* Hardware error */
+ if (nargs + nret > 12)
+ return -1; /* Hardware error */
+
+ args.token = token;
+ args.nargs = nargs;
+ args.nret = nret;
+
+ va_start(list, nret);
+ for (i = 0; i < nargs; i++)
+ args.args[i] = va_arg(list, unsigned int);
+ va_end(list);
+
+ for (i = 0; i < nret; i++)
+ args.args[nargs+i] = 0;
+
+ rtas(&args, rtas_data);
+
+ return args.args[nargs];
+}
+
+
+int write(void *handle, void *ptr, int nb)
+{
+ int i=0;
+ int err;
+ char *p;
+
+ p = ptr;
+ err = 0;
+
+ if (rtas_put_term_char)
+ for (; i < nb && !err; i++)
+ err = call_rtas(rtas_put_term_char, 1, 1, p[i]);
+#if 0
+ /* not tested, doesn't check line limits, do we care? */
+ else if (rtas_display_char)
+ for (; i < nb && !err; i++)
+ err = call_rtas(rtas_put_term_char, 1, 1, p[i]);
+#endif
+
+ return i-1;
+}
+
+
+/* returns true if s2 is a prefix of s1 */
+static int string_match(const char *s1, const char *s2)
+{
+ for (; *s2; ++s2)
+ if (*s1++ != *s2)
+ return 0;
+ return 1;
+}
+
+
+/* return -1 on fail, address on success */
+void *claim(unsigned long virt, unsigned long size, unsigned long align)
+{
+
+ unsigned long al = align ? align : 1;
+ unsigned long try = _ALIGN_UP(virt, al);
+ unsigned int *r;
+
+#if 0 /* Debug */
+
+ printf("claim: request %lx size %lx align %lx, aligned %p ",
+ virt, size, align, (void *)try);
+
+
+#define BUSY(s) printf("%s\n\r", s), ((void *)(-1))
+#define RANGE_PRINT printf("range %08x %08x ",r[1], r[3]);
+#define RANGE_CLEAR printf("is clear\n\r");
+#else
+#define BUSY(s) ((void *)(-1))
+#define RANGE_PRINT do {} while(0)
+#define RANGE_CLEAR do {} while(0)
+#endif
+
+
+ if (try + size < try)
+ return BUSY("wraps");
+
+ if (memsize && try + size > memsize)
+ return BUSY("overflows");
+
+ for (r = (unsigned int *)(((unsigned long)initial_boot_params)
+ + initial_boot_params->off_mem_rsvmap);
+ r[2] || r[3]; r += 4) {
+
+ if (r[0] || r[1] > try + size)
+ continue; /* starts after */
+ if (r[2] || r[1]+r[3] < r[1])
+ return BUSY("BEYOND"); /* extends beyond */
+ if (r[1] + r[3] < try)
+ continue; /* contained before */
+
+ RANGE_PRINT;
+ return BUSY("overlaps"); /* overlaps */
+ }
+
+ /*
+ * XXX: Fixme: we should keep track here and not hand out the
+ * same address again.
+ */
+
+ RANGE_CLEAR;
+ return (void *)(try);
+}
+
+
+
+/* code lifted from arch/powerpc/kernel/prom.c */
+
+static inline char *find_flat_dt_string(u32 offset)
+{
+ return ((char *)initial_boot_params) +
+ initial_boot_params->off_dt_strings + offset;
+}
+
+/**
+ * This function is used to scan the flattened device-tree, it is
+ * used to extract the memory informations at boot before we can
+ * unflatten the tree
+ */
+int of_scan_flat_dt(int (*it)(unsigned long node,
+ const char *uname, int depth,
+ void *data),
+ void *data)
+{
+ unsigned long p = ((unsigned long)initial_boot_params) +
+ initial_boot_params->off_dt_struct;
+ int rc = 0;
+ int depth = -1;
+
+ do {
+ u32 tag = *((u32 *)p);
+ char *pathp;
+
+ p += 4;
+ if (tag == OF_DT_END_NODE) {
+ depth --;
+ continue;
+ }
+ if (tag == OF_DT_NOP)
+ continue;
+ if (tag == OF_DT_END)
+ break;
+ if (tag == OF_DT_PROP) {
+ u32 sz = *((u32 *)p);
+ p += 8;
+ if (initial_boot_params->version < 0x10)
+ p = _ALIGN(p, sz >= 8 ? 8 : 4);
+ p += sz;
+ p = _ALIGN(p, 4);
+ continue;
+ }
+ if (tag != OF_DT_BEGIN_NODE) {
+ printf("Invalid tag %x scanning flattened"
+ " device tree !\n\r", tag);
+ return -1;
+ }
+ depth++;
+ pathp = (char *)p;
+ p = _ALIGN(p + strlen(pathp) + 1, 4);
+ if ((*pathp) == '/') {
+ char *lp, *np;
+ for (lp = NULL, np = pathp; *np; np++)
+ if ((*np) == '/')
+ lp = np+1;
+ if (lp != NULL)
+ pathp = lp;
+ }
+ rc = it(p, pathp, depth, data);
+ if (rc != 0)
+ break;
+ } while(1);
+
+ return rc;
+}
+
+unsigned long of_get_flat_dt_root(void)
+{
+ unsigned long p = ((unsigned long)initial_boot_params) +
+ initial_boot_params->off_dt_struct;
+
+ while(*((u32 *)p) == OF_DT_NOP)
+ p += 4;
+ BUG_ON (*((u32 *)p) != OF_DT_BEGIN_NODE);
+ p += 4;
+ return _ALIGN(p + strlen((char *)p) + 1, 4);
+}
+
+/**
+ * This function can be used within scan_flattened_dt callback to get
+ * access to properties
+ */
+void* of_get_flat_dt_prop(unsigned long node, const char *name,
+ unsigned long *size)
+{
+ unsigned long p = node;
+
+ do {
+ u32 tag = *((u32 *)p);
+ u32 sz, noff;
+ const char *nstr;
+
+ p += 4;
+ if (tag == OF_DT_NOP)
+ continue;
+ if (tag != OF_DT_PROP)
+ return NULL;
+
+ sz = *((u32 *)p);
+ noff = *((u32 *)(p + 4));
+ p += 8;
+ if (initial_boot_params->version < 0x10)
+ p = _ALIGN(p, sz >= 8 ? 8 : 4);
+
+ nstr = find_flat_dt_string(noff);
+ if (nstr == NULL) {
+ printf("Can't find property index"
+ " name !\n\r");
+ return NULL;
+ }
+ if (strcmp(name, nstr) == 0) {
+ if (size)
+ *size = sz;
+ return (void *)p;
+ }
+ p += sz;
+ p = _ALIGN(p, 4);
+ } while(1);
+}
+
+/* end code lifted from arch/powerpc/kernel/prom.c */
+
+
+/* This only handles device nodes directly off of the root node
+ * and will return on any partial name match
+ */
+static int match_device_node(unsigned long node, const char *uname,
+ int depth, void *data)
+{
+ if (depth == 1 && string_match(uname, data))
+ return node;
+ return 0;
+}
+
+/* Find Real Memory (offset) region. The first reg, size pair of the
+ * memory node defines the memory that is accessable in real mode on
+ * PPC64 LPAR systems. Assume that will be enough everywhere.
+ */
+static int find_rmo(unsigned long node, const char *uname, int depth,
+ void *data)
+{
+ if (match_device_node(node, uname, depth, data)) {
+ unsigned long size;
+ unsigned int *reg;
+ int i;
+
+ reg = of_get_flat_dt_prop(node, "reg", &size);
+ if (!reg || (size < (na + ns)*4)) {
+ printf("Warning: Can't parse reg property on %s\n\r",
+ uname);
+ return 0;
+ }
+
+ /* ignore if not address 0 */
+ for (i=0; i < na; i++)
+ if (reg[i])
+ return 0;
+
+ /* if more than 1 cell then MAX_MEM */
+ for (i=0; i < ns-1; i++)
+ if (reg[na+i])
+ return MAX_MEM;
+
+ /* else return size of first reg */
+ return reg[na+i];
+ }
+
+ return 0;
+}
+
+/* dummy prom that recognises the services used by elsewhere */
+int call_prom(const char *service, int nargs, int nret, ...)
+{
+ va_list list;
+
+ if (string_match(service, "finddevice")) {
+ char *path;
+
+ if ((nargs != 1) || (nret != 1)) {
+ printf("finddevice: unexpected arg counts %d %d\n\r",
+ nargs, nret);
+ return -1;
+ }
+ va_start(list, nret);
+ path = (void *)va_arg(list, unsigned int);
+ va_end(list);
+
+ if (path[0] == '/')
+ path++;
+
+ return (int) of_scan_flat_dt(match_device_node, path);
+
+ } else if (string_match(service, "getprop")) {
+ unsigned long node;
+ char *prop;
+ char *buf;
+ unsigned int len;
+ va_list list;
+ char *ret;
+ unsigned long size;
+
+ if ((nargs != 4) || (nret != 1)) {
+ printf("getprop: unexpected arg counts %d %d\n\r",
+ nargs, nret);
+ return -1;
+ }
+
+ va_start(list, nret);
+ node = va_arg(list, unsigned int);
+ prop = (void *)va_arg(list, unsigned int);
+ buf = (void *)va_arg(list, unsigned int);
+ len = va_arg(list, unsigned int);
+ va_end(list);
+
+ ret = of_get_flat_dt_prop(node, prop, &size);
+ if (ret) {
+ memcpy(buf, ret, len < size ? len : size);
+ }
+ return size;
+ } else if (!string_match(service, "exit")) {
+ printf("Unimplemented prom service %s(%d, %d) called\n\r",
+ service, nargs, nret);
+ /* fall through */
+ }
+ for(;;)
+ ; /* Forever */
+}
+
+void init_prom(unsigned long a1, unsigned long a2, void *p)
+{
+ unsigned long node;
+
+ if (p) /* this version doesn't support a prom interface */
+ exit();
+
+ initial_boot_params = (void *) a1;
+
+ BUG_ON(initial_boot_params->magic != OF_DT_HEADER);
+ BUG_ON(initial_boot_params->last_comp_version > 0x10);
+
+ chosen_handle = finddevice("/chosen");
+ if (chosen_handle == (void *) -1)
+ exit();
+
+ node = of_scan_flat_dt(match_device_node, "rtas");
+
+ if (node) {
+ unsigned int *p;
+ p = of_get_flat_dt_prop(node,
+ "linux,rtas-base", NULL);
+ if (p)
+ rtas_data = (void *)*p;
+ p = of_get_flat_dt_prop(node,
+ "linux,rtas-entry", NULL);
+ if (p)
+ rtas = (void *)*p;
+ p = of_get_flat_dt_prop(node,
+ "put-term-char", NULL);
+ if (p)
+ rtas_put_term_char = *p;
+ p = of_get_flat_dt_prop(node,
+ "display-character", NULL);
+ if (p)
+ rtas_display_char = *p;
+ }
+
+ node = of_get_flat_dt_root();
+ if (node) {
+ unsigned long tmp;
+ void *p;
+
+ p = of_get_flat_dt_prop(node, "#addr-cells", &tmp);
+ if (tmp == 4)
+ na = *(int *)p;
+ else
+ printf("Warning, could't find or parse #addr-cells\n\r");
+ p = of_get_flat_dt_prop(node, "#size-cells", &tmp);
+ if (tmp == 4)
+ ns = *(int *)p;
+ else
+ printf("Warning, could't find or parse #size-cells\n\r");
+ }
+
+ memsize = of_scan_flat_dt(find_rmo, "memory");
+
+ if (!memsize)
+ BUG_ON("Couldn't find RMO memory size\n\r");
+
+ if (memsize > MAX_MEM)
+ memsize = MAX_MEM;
+
+ printf("Can use %x bytes of memory in RMO\n\r", memsize);
+
+ ram_end = memsize;
+}
+
+/*
+ * Kexec smp hook:
+ * copy 0x100 bytes from the kernel entry point down to address zero,
+ * flush, then tell any slaves to branch down to address 0x60.
+ */
+void prom_smp_hook(unsigned long kernel_start)
+{
+ char *kern = (char *)kernel_start;
+ char *zero = (char *)0;
+
+ memcpy(zero, kern, 0x100);
+ flush_cache(zero, 0x100);
+
+ gohere = 0x60;
+}
Index: kernel/arch/powerpc/boot/crt0_kexec.S
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/crt0_kexec.S 2006-06-29 03:47:06.868856261 -0500
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 1997 Paul Mackerras.
+ * Copyright (C) 2006 Milton Miller, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * NOTE: This code runs in 32 bit mode and is linked as ELF32.
+ * It will switch from 64 to 32 bit mode with some assumptions.
+ */
+
+#include "ppc_asm.h"
+
+ .text
+ /* This is the actual "entry" point as mentioned in the headers.
+ * It is this code that should be copied down to zero.
+ * This code must be loaded above 0x100 or the slaves will
+ * crash when we copy the kernels entry point down.
+ */
+ .globl master
+master:
+ /* Work out the offset between the address we were linked at
+ * and the address where we're running.
+ * Set 32 bit mode while we are at it.
+ */
+ bl set32
+1: mflr r0
+ lis r9,1b@ha
+ addi r9,r9,1b@l
+ subf. r0,r9,r0
+ beq 3f /* if running at same address as linked */
+
+ /* The .got2 section contains a list of addresses, so add
+ the address offset onto each entry. */
+ lis r9,__got2_start@ha
+ addi r9,r9,__got2_start@l
+ lis r8,__got2_end@ha
+ addi r8,r8,__got2_end@l
+ subf. r8,r9,r8
+ beq 3f
+ srwi. r8,r8,2
+ mtctr r8
+ add r9,r0,r9
+2: lwz r8,0(r9)
+ add r8,r8,r0
+ stw r8,0(r9)
+ addi r9,r9,4
+ bdnz 2b
+3:
+ b 3f
+
+
+
+
+ /* the slaves may be in 32 or 64 bit mode, we don't care */
+ .org master+0x60
+ .globl slave
+slave:
+ li 4,gohere-master /* read 0-relative */
+waiting:
+99: lwz r6,0(r4)
+ cmpwi 0,r6,0
+ beq 99b
+ mtctr r6
+ addi r4,r6,gohere-waiting /* read from gohere in image */
+ bctr
+
+ .global gohere
+gohere: .long 0 # when set the slave moves
+
+
+
+flushit:
+ /* Do a cache flush for our text, in case OF didn't */
+3: lis r9,_start@ha
+ addi r9,r9,_start@l
+ add r9,r0,r9
+ lis r8,_etext@ha
+ addi r8,r8,_etext@l
+ add r8,r0,r8
+4: dcbf r0,r9
+ icbi r0,r9
+ addi r9,r9,0x20
+ cmplw cr0,r9,r8
+ blt 4b
+ sync
+ isync
+
+ /* fill out a stack for c code */
+ lis r1,__stack_end@ha
+ addi r1,r1,__stack_end@l
+ add r1,r1,r0
+ stwu r5,-16(r1) /* r5 should be 0 */
+
+ /* tell slave to come to our copy */
+ lis r8,waiting@ha
+ addi r8,r8,waiting@l
+ add r8,r8,r0
+ stw r8,gohere-master(0)
+
+ mr r6,r1
+ b start
+
+
+ /*
+ * Check if the processor is running in 32 bit mode, using
+ * only 32 bit instructions which should be safe on 32 and
+ * 64 bit processors.
+ *
+ * The caller is assuming that the lr is used to return.
+ */
+set32: mfmsr r0 /* grab whole msr */
+ rlwinm r6,r0,0,0,31 /* extract bottom word */
+ subf. r6,r6,r0 /* subtract, same? */
+ beqlr /* yes: we are 32 bit mode */
+
+ /* Since the compare found other bits, we must be in 64 bit mode
+ * on a 64 bit processor. Since MSR[SF] is in the bits we masked
+ * off the compare will always fail in 64 bit mode, and will alway
+ * be equal in 32 bit mode (the size of the implicit compare).
+ *
+ * This program must run in 32 bit mode, so switch now.
+ * Assume we are actually running in low 32 bits of memory space,
+ * so we can just turn off MSR[SF] which is bit 0.
+ */
+ .machine push
+ .machine "ppc64"
+ rldicl r0,r0,0,1
+ sync
+ mtmsrd r0
+ isync
+ .machine pop
+ blr
+
+ .org master+0x100 /* make sure we don't go backwards */
+
+
+ /* this code needs a stack allocated in the image */
+ .section .stack,"aw",@nobits
+ .space 4096
+
+ .data
+
+ /* a procedure descriptor used when pretending to be elf64_powerpc */
+ .balign 8
+ .global _master64
+_master64:
+ .long 0, master /* big endian, supported reloc ppc32 */
+ .quad 0, 0, 0
+
+ /* a procedure descriptor used when booting this as a COFF file */
+ .global _master_opd
+_master_opd:
+ .long master, 0, 0, 0
Index: kernel/arch/powerpc/boot/dt.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/dt.h 2006-06-29 03:47:06.870855944 -0500
@@ -0,0 +1,46 @@
+#ifndef _PPC_BOOT_DT_H_
+#define _PPC_BOOT_DT_H_
+
+typedef unsigned int u32;
+
+/* Definitions used by the flattened device tree */
+#define OF_DT_HEADER 0xd00dfeed /* marker */
+#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
+#define OF_DT_END_NODE 0x2 /* End node */
+#define OF_DT_PROP 0x3 /* Property: name off, size,
+ * content */
+#define OF_DT_NOP 0x4 /* nop */
+#define OF_DT_END 0x9
+
+#define OF_DT_VERSION 0x10
+
+/*
+ * This is what gets passed to the kernel by prom_init or kexec
+ *
+ * The dt struct contains the device tree structure, full pathes and
+ * property contents. The dt strings contain a separate block with just
+ * the strings for the property names, and is fully page aligned and
+ * self contained in a page, so that it can be kept around by the kernel,
+ * each property name appears only once in this page (cheap compression)
+ *
+ * the mem_rsvmap contains a map of reserved ranges of physical memory,
+ * passing it here instead of in the device-tree itself greatly simplifies
+ * the job of everybody. It's just a list of u64 pairs (base/size) that
+ * ends when size is 0
+ */
+struct boot_param_header
+{
+ u32 magic; /* magic word OF_DT_HEADER */
+ u32 totalsize; /* total size of DT block */
+ u32 off_dt_struct; /* offset to structure */
+ u32 off_dt_strings; /* offset to strings */
+ u32 off_mem_rsvmap; /* offset to memory reserve map */
+ u32 version; /* format version */
+ u32 last_comp_version; /* last compatible version */
+ /* version 2 fields below */
+ u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
+ /* version 3 fields below */
+ u32 dt_strings_size; /* size of the DT strings block */
+};
+
+#endif /* _PPC_BOOT_DT_H_ */
^ permalink raw reply [flat|nested] 8+ messages in thread
* [3/5][POWERPC] boot: use more Kbuild rules
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-01 23:46 ` [2/5][POWERPC] boot: Add kexec callable zImage wrapper Milton Miller
@ 2006-07-01 23:46 ` Milton Miller
2006-07-01 23:46 ` [4/5][POWERPC] boot: Makefile and linker scripts for zImage.kexec Milton Miller
2006-07-01 23:47 ` [5/5][POWERPC] boot: generate lds file from lds.S Milton Miller
4 siblings, 0 replies; 8+ messages in thread
From: Milton Miller @ 2006-07-01 23:46 UTC (permalink / raw)
To: linuxppc-dev, Sam Ravnborg; +Cc: linux-kernel
Switch to if_changed_dep for bootcc, cmd for known rebuilds without deps,
and if_changed for other commands. Add FORCE for all if_changed rule uses.
Make sure targets includes all generated files.
Move clean-files to targets for if_changed files.
Rename OBJCOPYFLAGS to OBJCOPY_SEC_FLAGS so we can use $(objcopy) rule.
Rename zliblinuxheader to linuxheader
Change from explicit dependency of main and zlib files and zlib headers
to generate all headers before compiling the source. fixdep will give
us the exact headers, but not on a clean compile.
Note: the obj-sec .c files are created/touched when the content file changes.
Signed-off-by: Milton Miller <miltonm@bga.com>
Index: kernel/arch/powerpc/boot/Makefile
===================================================================
--- kernel.orig/arch/powerpc/boot/Makefile 2006-07-01 00:03:41.940189322 -0500
+++ kernel/arch/powerpc/boot/Makefile 2006-07-01 01:33:55.937370129 -0500
@@ -25,16 +25,13 @@ HOSTCC := gcc
BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \
$(shell $(CROSS32CC) -print-file-name=include) -fPIC
BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
-OBJCOPYFLAGS := contents,alloc,load,readonly,data
+OBJCOPY_SEC_FLAGS := contents,alloc,load,readonly,data
OBJCOPY_COFF_ARGS := -O aixcoff-rs6000 --set-start 0x500000
OBJCOPY_MIB_ARGS := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
zlib := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
zlibheader := infblock.h infcodes.h inffast.h inftrees.h infutil.h
-zliblinuxheader := zlib.h zconf.h zutil.h
-
-$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader))
-#$(addprefix $(obj)/,main.o): $(addprefix $(obj)/,zlib.h)
+linuxheader := zlib.h zconf.h zutil.h
src-boot := crt0.S string.S prom.c stdio.c main.c div64.S
src-boot += $(zlib)
@@ -48,20 +45,23 @@ quiet_cmd_copy_zlib = COPY $@
quiet_cmd_copy_zlibheader = COPY $@
cmd_copy_zlibheader = sed "s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
+
# stddef.h for NULL
-quiet_cmd_copy_zliblinuxheader = COPY $@
- cmd_copy_zliblinuxheader = sed "s@<linux/string.h>@\"string.h\"@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
+quiet_cmd_copy_linuxheader = COPY $@
+ cmd_copy_linuxheader = sed "s@<linux/string.h>@\"string.h\"@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
-$(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
- $(call cmd,copy_zlib)
+$(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/% FORCE
+ $(call if_changed,copy_zlib)
-$(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
- $(call cmd,copy_zlibheader)
+$(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/% \
+ FORCE
+ $(call if_changed,copy_zlibheader)
-$(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/%
- $(call cmd,copy_zliblinuxheader)
+$(addprefix $(obj)/,$(linuxheader)): $(obj)/%: $(srctree)/include/linux/% FORCE
+ $(call if_changed,copy_linuxheader)
-clean-files := $(zlib) $(zlibheader) $(zliblinuxheader)
+targets += $(zlib) $(zlibheader) $(linuxheader)
+targets += $(patsubst $(obj)/%,%, $(obj-boot))
quiet_cmd_bootcc = BOOTCC $@
@@ -73,11 +73,16 @@ quiet_cmd_bootas = BOOTAS $@
quiet_cmd_bootld = BOOTLD $@
cmd_bootld = $(CROSS32LD) -T $(srctree)/$(src)/$(3) -o $@ $(2)
-$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c
+$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
$(call if_changed_dep,bootcc)
-$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S
+
+$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
$(call if_changed_dep,bootas)
+$(obj-boot): COPYHEADERS
+COPYHEADERS: $(addprefix $(obj)/,$(linuxheader) $(zlibheader))
+PHONY += COPYHEADERS
+
#-----------------------------------------------------------
# ELF sections within the zImage bootloader/wrapper
#-----------------------------------------------------------
@@ -104,18 +109,20 @@ quiet_cmd_ramdisk = RAMDISK $@
quiet_cmd_stripvm = STRIP $@
cmd_stripvm = $(STRIP) -s -R .comment $< -o $@
-vmlinux.strip: vmlinux
+vmlinux.strip: vmlinux FORCE
$(call if_changed,stripvm)
-$(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk $(obj)/ramdisk.image.gz
+$(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk \
+ $(obj)/ramdisk.image.gz FORCE
$(call if_changed,ramdisk)
quiet_cmd_addsection = ADDSEC $@
cmd_addsection = $(CROSS32OBJCOPY) $@ \
--add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(patsubst %.o,%.gz, $@) \
- --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(OBJCOPYFLAGS)
+ --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(OBJCOPY_SEC_FLAGS)
quiet_cmd_addnote = ADDNOTE $@
- cmd_addnote = $(obj)/addnote $@
+ cmd_addnote = @cp -f $< $@ && \
+ $(obj)/addnote $@
quiet_cmd_gen-miboot = GEN $@
cmd_gen-miboot = $(OBJCOPY) $(OBJCOPY_MIB_ARGS) \
@@ -125,7 +132,19 @@ quiet_cmd_gencoff = COFF $@
cmd_gencoff = $(OBJCOPY) $(OBJCOPY_COFF_ARGS) $@ && \
$(obj)/hack-coff $@
-$(call gz-sec, $(required)): $(obj)/kernel-%.gz: %
+# a single rule so that we can do if_changed correctly
+define rule_ldcoff
+ $(call echo-cmd,bootld) $(cmd_bootld); \
+ $(call echo-cmd,gencoff) $(cmd_gencoff)
+endef
+
+# $(required) is built in $(objtree) not $(obj) so read cmd files manually
+cmd_files := $(wildcard $(foreach f,$(required),$(dir $(f)).$(notdir $(f)).cmd))
+ifneq ($(cmd_files),)
+ include $(cmd_files)
+endif
+
+$(call gz-sec, $(required)): $(obj)/kernel-%.gz: % FORCE
$(call if_changed,gzip)
$(obj)/kernel-initrd.gz: $(obj)/ramdisk.image.gz
@@ -135,16 +154,16 @@ $(call src-sec, $(required) $(initrd)):
@touch $@
$(call obj-sec, $(required) $(initrd)): $(obj)/kernel-%.o: $(obj)/kernel-%.c
- $(call if_changed_dep,bootcc)
+ $(call cmd,bootcc)
$(call cmd,addsection)
$(obj)/zImage.vmode $(obj)/zImage.coff: obj-boot += $(call obj-sec, $(required))
-$(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) $(srctree)/$(src)/zImage.lds
- $(call cmd,bootld,$(obj-boot),zImage.lds)
+$(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) $(srctree)/$(src)/zImage.lds FORCE
+ $(call if_changed,bootld,$(obj-boot),zImage.lds)
$(obj)/zImage.initrd.vmode $(obj)/zImage.initrd.coff: obj-boot += $(call obj-sec, $(required) $(initrd))
-$(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(srctree)/$(src)/zImage.lds
- $(call cmd,bootld,$(obj-boot),zImage.lds)
+$(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(srctree)/$(src)/zImage.lds FORCE
+ $(call if_changed,bootld,$(obj-boot),zImage.lds)
# For 32-bit powermacs, build the COFF and miboot images
# as well as the ELF images.
@@ -154,30 +173,29 @@ mibootimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PP
mibrdimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/miboot.initrd.image
$(obj)/zImage: $(obj)/zImage.vmode $(obj)/addnote $(coffimage-y-y) \
- $(mibootimg-y-y)
- @cp -f $< $@
+ $(mibootimg-y-y) FORCE
$(call if_changed,addnote)
+ @true
$(obj)/zImage.initrd: $(obj)/zImage.initrd.vmode $(obj)/addnote \
- $(coffrdimg-y-y) $(mibrdimg-y-y)
- @cp -f $< $@
+ $(coffrdimg-y-y) $(mibrdimg-y-y) FORCE
$(call if_changed,addnote)
+ @true
$(obj)/zImage.coff: $(call obj-sec, $(required)) $(obj-boot) \
- $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff
- $(call cmd,bootld,$(obj-boot),zImage.coff.lds)
- $(call cmd,gencoff)
+ $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff FORCE
+ $(call if_changed_rule,ldcoff,$(obj-boot),zImage.coff.lds)
$(obj)/zImage.initrd.coff: $(call obj-sec, $(required) $(initrd)) $(obj-boot) \
- $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff
- $(call cmd,bootld,$(obj-boot),zImage.coff.lds)
- $(call cmd,gencoff)
+ $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff \
+ FORCE
+ $(call if_changed_rule,ldcoff,$(obj-boot),zImage.coff.lds)
-$(obj)/miboot.image: $(obj)/dummy.o $(obj)/vmlinux.gz
- $(call cmd,gen-miboot,image)
+$(obj)/miboot.image: $(obj)/dummy.o $(obj)/vmlinux.gz FORCE
+ $(call if_changed,gen-miboot,image)
-$(obj)/miboot.initrd.image: $(obj)/miboot.image $(images)/ramdisk.image.gz
- $(call cmd,gen-miboot,initrd)
+$(obj)/miboot.initrd.image: $(obj)/miboot.image $(images)/ramdisk.image.gz FORCE
+ $(call if_changed,gen-miboot,initrd)
#-----------------------------------------------------------
# build u-boot images
@@ -199,6 +217,7 @@ extra-y += vmlinux.bin vmlinux.gz
$(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objbin)
+ @true
$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
$(call if_changed,mygzip)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [4/5][POWERPC] boot: Makefile and linker scripts for zImage.kexec
2006-07-01 23:46 ` [0/5][POWERPC] boot: create zImage.kexec #2 Milton Miller
` (2 preceding siblings ...)
2006-07-01 23:46 ` [3/5][POWERPC] boot: use more Kbuild rules Milton Miller
@ 2006-07-01 23:46 ` Milton Miller
2006-07-01 23:47 ` [5/5][POWERPC] boot: generate lds file from lds.S Milton Miller
4 siblings, 0 replies; 8+ messages in thread
From: Milton Miller @ 2006-07-01 23:46 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Paul Mackerras, Sam Ravnborg
The Makefile and linker script changes to build zImage.kexec
This patch is based after the if_changed_dep patch.
Signed-off-by: Milton Miller <miltonm@bga.com>
Index: kernel/arch/powerpc/boot/Makefile
===================================================================
--- kernel.orig/arch/powerpc/boot/Makefile 2006-07-01 01:33:55.937370129 -0500
+++ kernel/arch/powerpc/boot/Makefile 2006-07-01 01:41:52.895398201 -0500
@@ -32,12 +32,22 @@ OBJCOPY_MIB_ARGS := -O aixcoff-rs6000 -
zlib := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
zlibheader := infblock.h infcodes.h inffast.h inftrees.h infutil.h
linuxheader := zlib.h zconf.h zutil.h
+linuxheader += stringify.h
-src-boot := crt0.S string.S prom.c stdio.c main.c div64.S
-src-boot += $(zlib)
+src-common := string.S stdio.c main.c div64.S
+src-common += $(zlib)
+
+src-boot := crt0.S prom.c $(src-common)
src-boot := $(addprefix $(obj)/, $(src-boot))
obj-boot := $(addsuffix .o, $(basename $(src-boot)))
+src-kexec := crt0_kexec.S kexec.c $(src-common)
+src-kexec := $(addprefix $(obj)/, $(src-kexec))
+obj-kexec := $(addsuffix .o, $(basename $(src-kexec)))
+
+src-mult := $(sort $(src-boot) $(src-kexec))
+obj-mult := $(sort $(obj-boot) $(obj-kexec))
+
BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj)
quiet_cmd_copy_zlib = COPY $@
@@ -61,7 +71,7 @@ $(addprefix $(obj)/,$(linuxheader)): $(o
$(call if_changed,copy_linuxheader)
targets += $(zlib) $(zlibheader) $(linuxheader)
-targets += $(patsubst $(obj)/%,%, $(obj-boot))
+targets += $(patsubst $(obj)/%,%, $(obj-mult))
quiet_cmd_bootcc = BOOTCC $@
@@ -73,10 +83,10 @@ quiet_cmd_bootas = BOOTAS $@
quiet_cmd_bootld = BOOTLD $@
cmd_bootld = $(CROSS32LD) -T $(srctree)/$(src)/$(3) -o $@ $(2)
-$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
+$(patsubst %.c,%.o, $(filter %.c, $(src-mult))): %.o: %.c FORCE
$(call if_changed_dep,bootcc)
-$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
+$(patsubst %.S,%.o, $(filter %.S, $(src-mult))): %.o: %.S FORCE
$(call if_changed_dep,bootas)
$(obj-boot): COPYHEADERS
@@ -97,6 +107,7 @@ hostprogs-y := addnote addRamDisk hack-
targets += zImage.vmode zImage.initrd.vmode zImage zImage.initrd \
zImage.coff zImage.initrd.coff miboot.image miboot.initrd.image \
+ zImage.kexec zImage.kexec.3264 zImage.kexec64 \
$(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \
$(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \
$(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \
@@ -121,7 +132,7 @@ quiet_cmd_addsection = ADDSEC $@
--set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(OBJCOPY_SEC_FLAGS)
quiet_cmd_addnote = ADDNOTE $@
- cmd_addnote = @cp -f $< $@ && \
+ cmd_addnote = cp -f $< $@ && \
$(obj)/addnote $@
quiet_cmd_gen-miboot = GEN $@
@@ -172,8 +183,35 @@ coffrdimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PP
mibootimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/miboot.image
mibrdimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/miboot.initrd.image
+# The kexec entry point is valid for all kernels. This zImage should work
+# on all loaders (kexec or firmware) that do not use an openfirmware prom
+# callback, assuming the memory node constraints are met.
+#
+# Build if CONFIG_KEXEC=y or on master make zImage.kexec.
+#
+kexecimg-$(CONFIG_KEXEC)-$(CONFIG_PPC64) += $(obj)/zImage.kexec64
+kexecimg-$(CONFIG_KEXEC)-y += $(obj)/zImage.kexec
+
+# Build 64 bit and 32 bit package when 64 bit kernel is being built
+$(obj)/zImage.kexec: $(filter-out $(obj)/zImage.kexec, $(kexecimg-y-y))
+
+$(obj)/zImage.kexec: obj-kexec += $(call obj-sec, $(required))
+$(obj)/zImage.kexec: $(obj-kexec) $(srctree)/$(src)/zImage.kexec.lds \
+ $(call obj-sec, $(required)) FORCE
+ $(call if_changed,bootld,$(obj-kexec),zImage.kexec.lds)
+ @true
+
+$(obj)/zImage.kexec.3264: obj-kexec += $(call obj-sec, $(required))
+$(obj)/zImage.kexec.3264: $(obj-kexec) $(srctree)/$(src)/zImage.kexec64.lds \
+ $(call obj-sec, $(required)) FORCE
+ $(call if_changed,bootld,$(obj-kexec),zImage.kexec64.lds)
+
+OBJCOPYFLAGS_zImage.kexec64 := -I elf32-powerpc -O elf64-powerpc
+$(obj)/zImage.kexec64: $(obj)/zImage.kexec.3264 FORCE
+ $(call if_changed,objcopy,$< $@)
+
$(obj)/zImage: $(obj)/zImage.vmode $(obj)/addnote $(coffimage-y-y) \
- $(mibootimg-y-y) FORCE
+ $(mibootimg-y-y) $(kexecimg-y-y) FORCE
$(call if_changed,addnote)
@true
@@ -231,4 +269,4 @@ $(obj)/uImage: $(obj)/vmlinux.gz
install: $(CONFIGURE) $(BOOTIMAGE)
sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)"
-clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip)
+clean-files += $(addprefix $(objtree)/, $(obj-mult) vmlinux.strip)
Index: kernel/arch/powerpc/Makefile
===================================================================
--- kernel.orig/arch/powerpc/Makefile 2006-07-01 01:30:31.108598026 -0500
+++ kernel/arch/powerpc/Makefile 2006-07-01 01:34:26.665172415 -0500
@@ -147,7 +147,7 @@ all: $(KBUILD_IMAGE)
CPPFLAGS_vmlinux.lds := -Upowerpc
-BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage vmlinux.bin
+BOOT_TARGETS = zImage zImage.initrd zImage.kexec znetboot znetboot.initrd vmlinux.sm uImage vmlinux.bin
PHONY += $(BOOT_TARGETS)
Index: kernel/arch/powerpc/boot/zImage.kexec.lds
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/zImage.kexec.lds 2006-07-01 01:40:22.459982024 -0500
@@ -0,0 +1,51 @@
+OUTPUT_ARCH(powerpc:common)
+ENTRY(master)
+SECTIONS
+{
+ . = 0;
+ _start = .;
+ .text :
+ {
+ *(.text)
+ *(.fixup)
+ }
+ _etext = .;
+ . = ALIGN(4096);
+ .data :
+ {
+ *(.rodata*)
+ *(.data*)
+ *(.sdata*)
+ __got2_start = .;
+ *(.got2)
+ __got2_end = .;
+ }
+
+ . = ALIGN(4096);
+ _vmlinux_start = .;
+ .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
+ _vmlinux_end = .;
+
+ . = ALIGN(4096);
+ _initrd_start = .;
+ .kernel:initrd : { *(.kernel:initrd) }
+ _initrd_end = .;
+
+ . = ALIGN(4096);
+ _edata = .;
+
+ . = ALIGN(4096);
+ __stack_start = .;
+ .stack : { *(.stack) }
+ __stack_end = .;
+
+ . = ALIGN(4096);
+ __bss_start = .;
+ .bss :
+ {
+ *(.sbss)
+ *(.bss)
+ }
+ . = ALIGN(4096);
+ _end = . ;
+}
Index: kernel/arch/powerpc/boot/zImage.kexec64.lds
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/zImage.kexec64.lds 2006-07-01 01:40:22.487977592 -0500
@@ -0,0 +1,52 @@
+OUTPUT_ARCH(powerpc:common)
+ENTRY(_master64)
+SECTIONS
+{
+ . = 0;
+ _start = .;
+ .text :
+ {
+ *(.text)
+ *(.fixup)
+ }
+ _etext = .;
+ . = ALIGN(4096);
+ .data :
+ {
+ *(.rodata*)
+ *(.data*)
+ *(.sdata*)
+ __got2_start = .;
+ *(.got2)
+ __got2_end = .;
+ }
+
+ . = ALIGN(4096);
+ _vmlinux_start = .;
+ .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
+ _vmlinux_end = .;
+
+ . = ALIGN(4096);
+ _initrd_start = .;
+ .kernel:initrd : { *(.kernel:initrd) }
+ _initrd_end = .;
+
+ . = ALIGN(4096);
+ _edata = .;
+
+ . = ALIGN(4096);
+ __stack_start = .;
+ .stack : { *(.stack) }
+ __stack_end = .;
+
+ . = ALIGN(4096);
+ __bss_start = .;
+ .bss :
+ {
+ *(.sbss)
+ *(.bss)
+ }
+ . = ALIGN(4096);
+ _end = . ;
+}
+
^ permalink raw reply [flat|nested] 8+ messages in thread
* [5/5][POWERPC] boot: generate lds file from lds.S
2006-07-01 23:46 ` [0/5][POWERPC] boot: create zImage.kexec #2 Milton Miller
` (3 preceding siblings ...)
2006-07-01 23:46 ` [4/5][POWERPC] boot: Makefile and linker scripts for zImage.kexec Milton Miller
@ 2006-07-01 23:47 ` Milton Miller
4 siblings, 0 replies; 8+ messages in thread
From: Milton Miller @ 2006-07-01 23:47 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Sam Ravnborg
The zImage.kexec and zImage.kexec64 linker files are almost identical to
the base elf file. Use the lds.S -> ld rule to share the source.
Tell the linker the fils is in $(obj) not $(srctree)/$(src)
zImage.coff.lds is different, it links the initrd and kernel in .data
rather than as a seperate section and without alignment, keep it seperate
for now.
Signed-off-by: Milton Miller <miltonm@bga.com>
Index: kernel/arch/powerpc/boot/Makefile
===================================================================
--- kernel.orig/arch/powerpc/boot/Makefile 2006-07-01 01:41:52.895398201 -0500
+++ kernel/arch/powerpc/boot/Makefile 2006-07-01 01:42:18.569198987 -0500
@@ -81,7 +81,7 @@ quiet_cmd_bootas = BOOTAS $@
cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
quiet_cmd_bootld = BOOTLD $@
- cmd_bootld = $(CROSS32LD) -T $(srctree)/$(src)/$(3) -o $@ $(2)
+ cmd_bootld = $(CROSS32LD) -T $(obj)/$(3) -o $@ $(2)
$(patsubst %.c,%.o, $(filter %.c, $(src-mult))): %.o: %.c FORCE
$(call if_changed_dep,bootcc)
@@ -108,6 +108,7 @@ hostprogs-y := addnote addRamDisk hack-
targets += zImage.vmode zImage.initrd.vmode zImage zImage.initrd \
zImage.coff zImage.initrd.coff miboot.image miboot.initrd.image \
zImage.kexec zImage.kexec.3264 zImage.kexec64 \
+ zImage.lds zImage.kexec.lds zImage.kexec64.lds zImage.coff.lds \
$(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \
$(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \
$(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \
@@ -168,12 +169,26 @@ $(call obj-sec, $(required) $(initrd)):
$(call cmd,bootcc)
$(call cmd,addsection)
+lds-fl := -P -C -Upowerpc
+CPPFLAGS_zImage.coff.lds := $(lds-fl)
+CPPFLAGS_zImage.lds := $(lds-fl) -D__ENTRY__=_zimage_start
+CPPFLAGS_zImage.lds += -D__BASE__="4*1024*1024"
+CPPFLAGS_zImage.kexec.lds := $(lds-fl) -D__ENTRY__=master -D__BASE__=0
+CPPFLAGS_zImage.kexec64.lds := $(lds-fl) -D__ENTRY__=_master64 -D__BASE__=0
+
+$(addprefix $(obj)/, zImage.lds zImage.kexec.lds zImage.kexec64.lds): \
+ $(srctree)/$(src)/zImage.lds.S FORCE
+ $(call if_changed_dep,cpp_lds_S)
+
+$(obj)/zImage.coff.lds: $(srctree)/$(src)/$zImage.coff.lds.S FORCE
+ $(call if_changed_dep,cpp_lds_S)
+
$(obj)/zImage.vmode $(obj)/zImage.coff: obj-boot += $(call obj-sec, $(required))
-$(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) $(srctree)/$(src)/zImage.lds FORCE
+$(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) $(obj)/zImage.lds FORCE
$(call if_changed,bootld,$(obj-boot),zImage.lds)
$(obj)/zImage.initrd.vmode $(obj)/zImage.initrd.coff: obj-boot += $(call obj-sec, $(required) $(initrd))
-$(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(srctree)/$(src)/zImage.lds FORCE
+$(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(obj)/zImage.lds FORCE
$(call if_changed,bootld,$(obj-boot),zImage.lds)
# For 32-bit powermacs, build the COFF and miboot images
@@ -196,13 +211,13 @@ kexecimg-$(CONFIG_KEXEC)-y
$(obj)/zImage.kexec: $(filter-out $(obj)/zImage.kexec, $(kexecimg-y-y))
$(obj)/zImage.kexec: obj-kexec += $(call obj-sec, $(required))
-$(obj)/zImage.kexec: $(obj-kexec) $(srctree)/$(src)/zImage.kexec.lds \
+$(obj)/zImage.kexec: $(obj-kexec) $(obj)/zImage.kexec.lds \
$(call obj-sec, $(required)) FORCE
$(call if_changed,bootld,$(obj-kexec),zImage.kexec.lds)
@true
$(obj)/zImage.kexec.3264: obj-kexec += $(call obj-sec, $(required))
-$(obj)/zImage.kexec.3264: $(obj-kexec) $(srctree)/$(src)/zImage.kexec64.lds \
+$(obj)/zImage.kexec.3264: $(obj-kexec) $(obj)/zImage.kexec64.lds \
$(call obj-sec, $(required)) FORCE
$(call if_changed,bootld,$(obj-kexec),zImage.kexec64.lds)
@@ -221,12 +236,11 @@ $(obj)/zImage.initrd: $(obj)/zImage.init
@true
$(obj)/zImage.coff: $(call obj-sec, $(required)) $(obj-boot) \
- $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff FORCE
+ $(obj)/zImage.coff.lds $(obj)/hack-coff FORCE
$(call if_changed_rule,ldcoff,$(obj-boot),zImage.coff.lds)
$(obj)/zImage.initrd.coff: $(call obj-sec, $(required) $(initrd)) $(obj-boot) \
- $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff \
- FORCE
+ $(obj)/zImage.coff.lds $(obj)/hack-coff FORCE
$(call if_changed_rule,ldcoff,$(obj-boot),zImage.coff.lds)
$(obj)/miboot.image: $(obj)/dummy.o $(obj)/vmlinux.gz FORCE
Index: kernel/arch/powerpc/boot/zImage.coff.lds
===================================================================
--- kernel.orig/arch/powerpc/boot/zImage.coff.lds 2006-07-01 01:40:22.406990413 -0500
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-OUTPUT_ARCH(powerpc:common)
-ENTRY(_start)
-SECTIONS
-{
- . = (5*1024*1024);
- _start = .;
- .text :
- {
- *(.text)
- *(.fixup)
- }
- _etext = .;
- . = ALIGN(4096);
- .data :
- {
- *(.rodata*)
- *(.data*)
- *(.sdata*)
- __got2_start = .;
- *(.got2)
- __got2_end = .;
-
- _vmlinux_start = .;
- *(.kernel:vmlinux.strip)
- _vmlinux_end = .;
-
- _initrd_start = .;
- *(.kernel:initrd)
- _initrd_end = .;
- }
-
- . = ALIGN(4096);
- _edata = .;
- __bss_start = .;
- .bss :
- {
- *(.sbss)
- *(.bss)
- }
- _end = . ;
-
- /DISCARD/ :
- {
- *(.comment)
- }
-}
Index: kernel/arch/powerpc/boot/zImage.coff.lds.S
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/zImage.coff.lds.S 2006-07-01 01:42:18.572198512 -0500
@@ -0,0 +1,46 @@
+OUTPUT_ARCH(powerpc:common)
+ENTRY(_start)
+SECTIONS
+{
+ . = (5*1024*1024);
+ _start = .;
+ .text :
+ {
+ *(.text)
+ *(.fixup)
+ }
+ _etext = .;
+ . = ALIGN(4096);
+ .data :
+ {
+ *(.rodata*)
+ *(.data*)
+ *(.sdata*)
+ __got2_start = .;
+ *(.got2)
+ __got2_end = .;
+
+ _vmlinux_start = .;
+ *(.kernel:vmlinux.strip)
+ _vmlinux_end = .;
+
+ _initrd_start = .;
+ *(.kernel:initrd)
+ _initrd_end = .;
+ }
+
+ . = ALIGN(4096);
+ _edata = .;
+ __bss_start = .;
+ .bss :
+ {
+ *(.sbss)
+ *(.bss)
+ }
+ _end = . ;
+
+ /DISCARD/ :
+ {
+ *(.comment)
+ }
+}
Index: kernel/arch/powerpc/boot/zImage.kexec.lds
===================================================================
--- kernel.orig/arch/powerpc/boot/zImage.kexec.lds 2006-07-01 01:40:22.459982024 -0500
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,51 +0,0 @@
-OUTPUT_ARCH(powerpc:common)
-ENTRY(master)
-SECTIONS
-{
- . = 0;
- _start = .;
- .text :
- {
- *(.text)
- *(.fixup)
- }
- _etext = .;
- . = ALIGN(4096);
- .data :
- {
- *(.rodata*)
- *(.data*)
- *(.sdata*)
- __got2_start = .;
- *(.got2)
- __got2_end = .;
- }
-
- . = ALIGN(4096);
- _vmlinux_start = .;
- .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
- _vmlinux_end = .;
-
- . = ALIGN(4096);
- _initrd_start = .;
- .kernel:initrd : { *(.kernel:initrd) }
- _initrd_end = .;
-
- . = ALIGN(4096);
- _edata = .;
-
- . = ALIGN(4096);
- __stack_start = .;
- .stack : { *(.stack) }
- __stack_end = .;
-
- . = ALIGN(4096);
- __bss_start = .;
- .bss :
- {
- *(.sbss)
- *(.bss)
- }
- . = ALIGN(4096);
- _end = . ;
-}
Index: kernel/arch/powerpc/boot/zImage.kexec64.lds
===================================================================
--- kernel.orig/arch/powerpc/boot/zImage.kexec64.lds 2006-07-01 01:40:22.487977592 -0500
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,52 +0,0 @@
-OUTPUT_ARCH(powerpc:common)
-ENTRY(_master64)
-SECTIONS
-{
- . = 0;
- _start = .;
- .text :
- {
- *(.text)
- *(.fixup)
- }
- _etext = .;
- . = ALIGN(4096);
- .data :
- {
- *(.rodata*)
- *(.data*)
- *(.sdata*)
- __got2_start = .;
- *(.got2)
- __got2_end = .;
- }
-
- . = ALIGN(4096);
- _vmlinux_start = .;
- .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
- _vmlinux_end = .;
-
- . = ALIGN(4096);
- _initrd_start = .;
- .kernel:initrd : { *(.kernel:initrd) }
- _initrd_end = .;
-
- . = ALIGN(4096);
- _edata = .;
-
- . = ALIGN(4096);
- __stack_start = .;
- .stack : { *(.stack) }
- __stack_end = .;
-
- . = ALIGN(4096);
- __bss_start = .;
- .bss :
- {
- *(.sbss)
- *(.bss)
- }
- . = ALIGN(4096);
- _end = . ;
-}
-
Index: kernel/arch/powerpc/boot/zImage.lds
===================================================================
--- kernel.orig/arch/powerpc/boot/zImage.lds 2006-07-01 01:40:22.516973001 -0500
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-OUTPUT_ARCH(powerpc:common)
-ENTRY(_zimage_start)
-SECTIONS
-{
- . = (4*1024*1024);
- _start = .;
- .text :
- {
- *(.text)
- *(.fixup)
- }
- _etext = .;
- . = ALIGN(4096);
- .data :
- {
- *(.rodata*)
- *(.data*)
- *(.sdata*)
- __got2_start = .;
- *(.got2)
- __got2_end = .;
- }
-
- . = ALIGN(4096);
- _vmlinux_start = .;
- .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
- _vmlinux_end = .;
-
- . = ALIGN(4096);
- _initrd_start = .;
- .kernel:initrd : { *(.kernel:initrd) }
- _initrd_end = .;
-
- . = ALIGN(4096);
- _edata = .;
-
- . = ALIGN(4096);
- __bss_start = .;
- .bss :
- {
- *(.sbss)
- *(.bss)
- }
- . = ALIGN(4096);
- _end = . ;
-}
Index: kernel/arch/powerpc/boot/zImage.lds.S
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ kernel/arch/powerpc/boot/zImage.lds.S 2006-07-01 01:42:18.576197879 -0500
@@ -0,0 +1,51 @@
+OUTPUT_ARCH(powerpc:common)
+ENTRY(__ENTRY__)
+SECTIONS
+{
+ . = __BASE__;
+ _start = .;
+ .text :
+ {
+ *(.text)
+ *(.fixup)
+ }
+ _etext = .;
+ . = ALIGN(4096);
+ .data :
+ {
+ *(.rodata*)
+ *(.data*)
+ *(.sdata*)
+ __got2_start = .;
+ *(.got2)
+ __got2_end = .;
+ }
+
+ . = ALIGN(4096);
+ _vmlinux_start = .;
+ .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
+ _vmlinux_end = .;
+
+ . = ALIGN(4096);
+ _initrd_start = .;
+ .kernel:initrd : { *(.kernel:initrd) }
+ _initrd_end = .;
+
+ . = ALIGN(4096);
+ _edata = .;
+
+ . = ALIGN(4096);
+ __stack_start = .;
+ .stack : { *(.stack) }
+ __stack_end = .;
+
+ . = ALIGN(4096);
+ __bss_start = .;
+ .bss :
+ {
+ *(.sbss)
+ *(.bss)
+ }
+ . = ALIGN(4096);
+ _end = . ;
+}
^ permalink raw reply [flat|nested] 8+ messages in thread