* [PATCH 01/10] bootwrapper: Use fsl_get_immr() in cuboot-pq2.c.
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-05 19:21 ` [PATCH 02/10] bootwrapper: Support all-in-one PCI nodes in cuboot-pq2 Scott Wood
` (8 subsequent siblings)
9 siblings, 0 replies; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/cuboot-pq2.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/boot/cuboot-pq2.c b/arch/powerpc/boot/cuboot-pq2.c
index b150bd4..fef2d15 100644
--- a/arch/powerpc/boot/cuboot-pq2.c
+++ b/arch/powerpc/boot/cuboot-pq2.c
@@ -15,6 +15,7 @@
#include "stdio.h"
#include "cuboot.h"
#include "io.h"
+#include "fsl-soc.h"
#define TARGET_CPM2
#define TARGET_HAS_ETH1
@@ -146,16 +147,13 @@ static void fixup_pci(void)
if (!ctrl_node || !dt_is_compatible(ctrl_node, "fsl,pq2-pci"))
return;
- soc_node = finddevice("/soc");
- if (!soc_node || !dt_is_compatible(soc_node, "fsl,pq2-soc"))
- goto err;
-
for (i = 0; i < 3; i++)
if (!dt_xlate_reg(ctrl_node, i,
(unsigned long *)&pci_regs[i], NULL))
goto err;
- if (!dt_xlate_reg(soc_node, 0, (unsigned long *)&soc_regs, NULL))
+ soc_regs = (u8 *)fsl_get_immr();
+ if (!soc_regs)
goto err;
len = getprop(ctrl_node, "fsl,bus", &bus_ph, 4);
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 02/10] bootwrapper: Support all-in-one PCI nodes in cuboot-pq2.
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
2007-09-05 19:21 ` [PATCH 01/10] bootwrapper: Use fsl_get_immr() in cuboot-pq2.c Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-05 19:21 ` [PATCH 03/10] bootwrapper: flatdevtree fixes Scott Wood
` (7 subsequent siblings)
9 siblings, 0 replies; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
Kumar insisted on not splitting the PCI ito bus and control nodes,
but rather hacking extra entries into the soc node's ranges.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/cuboot-pq2.c | 25 ++++++++-----------------
1 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/arch/powerpc/boot/cuboot-pq2.c b/arch/powerpc/boot/cuboot-pq2.c
index fef2d15..986cc71 100644
--- a/arch/powerpc/boot/cuboot-pq2.c
+++ b/arch/powerpc/boot/cuboot-pq2.c
@@ -140,15 +140,15 @@ static void fixup_pci(void)
u32 *pci_regs[3];
u8 *soc_regs;
int i, len;
- void *ctrl_node, *bus_node, *parent_node, *soc_node;
- u32 naddr, nsize, bus_ph, mem_log2;
+ void *node, *parent_node;
+ u32 naddr, nsize, mem_log2;
- ctrl_node = finddevice("/soc/pci");
- if (!ctrl_node || !dt_is_compatible(ctrl_node, "fsl,pq2-pci"))
+ node = finddevice("/soc/pci");
+ if (!node || !dt_is_compatible(node, "fsl,pq2-pci"))
return;
for (i = 0; i < 3; i++)
- if (!dt_xlate_reg(ctrl_node, i,
+ if (!dt_xlate_reg(node, i,
(unsigned long *)&pci_regs[i], NULL))
goto err;
@@ -156,20 +156,11 @@ static void fixup_pci(void)
if (!soc_regs)
goto err;
- len = getprop(ctrl_node, "fsl,bus", &bus_ph, 4);
- if (len != 4)
- goto err;
-
- bus_node = find_node_by_prop_value(NULL, "linux,phandle",
- (char *)&bus_ph, 4);
- if (!bus_node)
- goto err;
-
- dt_get_reg_format(bus_node, &naddr, &nsize);
+ dt_get_reg_format(node, &naddr, &nsize);
if (naddr != 3 || nsize != 2)
goto err;
- parent_node = get_parent(bus_node);
+ parent_node = get_parent(node);
if (!parent_node)
goto err;
@@ -177,7 +168,7 @@ static void fixup_pci(void)
if (naddr != 1 || nsize != 1)
goto err;
- len = getprop(bus_node, "ranges", pci_ranges_buf,
+ len = getprop(node, "ranges", pci_ranges_buf,
sizeof(pci_ranges_buf));
for (i = 0; i < len / sizeof(struct pci_range); i++) {
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 03/10] bootwrapper: flatdevtree fixes
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
2007-09-05 19:21 ` [PATCH 01/10] bootwrapper: Use fsl_get_immr() in cuboot-pq2.c Scott Wood
2007-09-05 19:21 ` [PATCH 02/10] bootwrapper: Support all-in-one PCI nodes in cuboot-pq2 Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-07 0:49 ` David Gibson
2007-09-05 19:21 ` [PATCH 04/10] bootwrapper: Add strtoull() Scott Wood
` (6 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
1. ft_create_node was returning the internal pointer rather than a phandle.
2. ft_find_device_rel was treating a "top" phandle of NULL as an error,
rather than as the root of the tree. The old, absolute ft_find_device
is removed, and the relative version is renamed to ft_find_device().
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/flatdevtree.c | 41 +++++++++++++++------------------
arch/powerpc/boot/flatdevtree.h | 7 ++---
arch/powerpc/boot/flatdevtree_misc.c | 2 +-
3 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 13761bf..0af7291 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -354,16 +354,21 @@ static void ft_put_bin(struct ft_cxt *cxt, const void *data, unsigned int sz)
cxt->p += sza;
}
-int ft_begin_node(struct ft_cxt *cxt, const char *name)
+char *ft_begin_node(struct ft_cxt *cxt, const char *name)
{
unsigned long nlen = strlen(name) + 1;
unsigned long len = 8 + _ALIGN(nlen, 4);
+ char *ret;
if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, len))
- return -1;
+ return NULL;
+
+ ret = cxt->p;
+
ft_put_word(cxt, OF_DT_BEGIN_NODE);
ft_put_bin(cxt, name, strlen(name) + 1);
- return 0;
+
+ return ret;
}
void ft_end_node(struct ft_cxt *cxt)
@@ -625,25 +630,17 @@ void ft_end_tree(struct ft_cxt *cxt)
bph->dt_strings_size = cpu_to_be32(ssize);
}
-void *ft_find_device(struct ft_cxt *cxt, const char *srch_path)
-{
- char *node;
-
- /* require absolute path */
- if (srch_path[0] != '/')
- return NULL;
- node = ft_find_descendent(cxt, ft_root_node(cxt), srch_path);
- return ft_get_phandle(cxt, node);
-}
-
-void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
- const char *srch_path)
+void *ft_find_device(struct ft_cxt *cxt, const void *top, const char *srch_path)
{
char *node;
- node = ft_node_ph2node(cxt, top);
- if (node == NULL)
- return NULL;
+ if (top) {
+ node = ft_node_ph2node(cxt, top);
+ if (node == NULL)
+ return NULL;
+ } else {
+ node = ft_root_node(cxt);
+ }
node = ft_find_descendent(cxt, node, srch_path);
return ft_get_phandle(cxt, node);
@@ -945,7 +942,7 @@ int ft_del_prop(struct ft_cxt *cxt, const void *phandle, const char *propname)
void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
{
struct ft_atom atom;
- char *p, *next;
+ char *p, *next, *ret;
int depth = 0;
if (parent) {
@@ -970,9 +967,9 @@ void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
break;
/* end of node, insert here */
cxt->p = p;
- ft_begin_node(cxt, name);
+ ret = ft_begin_node(cxt, name);
ft_end_node(cxt);
- return p;
+ return ft_get_phandle(cxt, ret);
}
p = next;
}
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index cb26325..2c1c826 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -76,7 +76,7 @@ struct ft_cxt {
unsigned int nodes_used;
};
-int ft_begin_node(struct ft_cxt *cxt, const char *name);
+char *ft_begin_node(struct ft_cxt *cxt, const char *name);
void ft_end_node(struct ft_cxt *cxt);
void ft_begin_tree(struct ft_cxt *cxt);
@@ -96,9 +96,8 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
void ft_dump_blob(const void *bphp);
void ft_merge_blob(struct ft_cxt *cxt, void *blob);
-void *ft_find_device(struct ft_cxt *cxt, const char *srch_path);
-void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
- const char *srch_path);
+void *ft_find_device(struct ft_cxt *cxt, const void *top,
+ const char *srch_path);
void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path);
int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
void *buf, const unsigned int buflen);
diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
index 4341e65..8d1debe 100644
--- a/arch/powerpc/boot/flatdevtree_misc.c
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -18,7 +18,7 @@ static struct ft_cxt cxt;
static void *fdtm_finddevice(const char *name)
{
- return ft_find_device(&cxt, name);
+ return ft_find_device(&cxt, NULL, name);
}
static int fdtm_getprop(const void *phandle, const char *propname,
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 03/10] bootwrapper: flatdevtree fixes
2007-09-05 19:21 ` [PATCH 03/10] bootwrapper: flatdevtree fixes Scott Wood
@ 2007-09-07 0:49 ` David Gibson
0 siblings, 0 replies; 31+ messages in thread
From: David Gibson @ 2007-09-07 0:49 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On Wed, Sep 05, 2007 at 02:21:04PM -0500, Scott Wood wrote:
> 1. ft_create_node was returning the internal pointer rather than a phandle.
> 2. ft_find_device_rel was treating a "top" phandle of NULL as an error,
> rather than as the root of the tree. The old, absolute ft_find_device
> is removed, and the relative version is renamed to ft_find_device().
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Although I'm getting really close to obsoleting flatdevtree.c
anyway...
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 04/10] bootwrapper: Add strtoull().
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
` (2 preceding siblings ...)
2007-09-05 19:21 ` [PATCH 03/10] bootwrapper: flatdevtree fixes Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-05 21:12 ` Josh Boyer
2007-09-07 0:50 ` David Gibson
2007-09-05 19:21 ` [PATCH 05/10] bootwrapper: Add get_path() Scott Wood
` (5 subsequent siblings)
9 siblings, 2 replies; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
This will be needed by PlanetCore firmware support.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 2 +-
arch/powerpc/boot/stdlib.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/stdlib.h | 6 +++++
3 files changed, 52 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/stdlib.c
create mode 100644 arch/powerpc/boot/stdlib.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index cd7c057..90c2f6d 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -45,7 +45,7 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
ns16550.c serial.c simple_alloc.c div64.S util.S \
gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
- cpm-serial.c
+ cpm-serial.c stdlib.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c cuboot-pq2.c
diff --git a/arch/powerpc/boot/stdlib.c b/arch/powerpc/boot/stdlib.c
new file mode 100644
index 0000000..e00d58c
--- /dev/null
+++ b/arch/powerpc/boot/stdlib.c
@@ -0,0 +1,45 @@
+/*
+ * stdlib functions
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "stdlib.h"
+
+/* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
+unsigned long long int strtoull(const char *ptr, char **end, int base)
+{
+ unsigned long long ret = 0;
+
+ if (base > 36)
+ goto out;
+
+ while (*ptr) {
+ int digit;
+
+ if (*ptr >= '0' && *ptr <= '9' && *ptr < '0' + base)
+ digit = *ptr - '0';
+ else if (*ptr >= 'A' && *ptr < 'A' + base - 10)
+ digit = *ptr - 'A' + 10;
+ else if (*ptr >= 'a' && *ptr < 'a' + base - 10)
+ digit = *ptr - 'a' + 10;
+ else
+ break;
+
+ ret *= base;
+ ret += digit;
+ ptr++;
+ }
+
+out:
+ if (end)
+ *end = (char *)ptr;
+
+ return ret;
+}
diff --git a/arch/powerpc/boot/stdlib.h b/arch/powerpc/boot/stdlib.h
new file mode 100644
index 0000000..1bf01ac
--- /dev/null
+++ b/arch/powerpc/boot/stdlib.h
@@ -0,0 +1,6 @@
+#ifndef _PPC_BOOT_STDLIB_H_
+#define _PPC_BOOT_STDLIB_H_
+
+unsigned long long int strtoull(const char *ptr, char **end, int base);
+
+#endif
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 05/10] bootwrapper: Add get_path().
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
` (3 preceding siblings ...)
2007-09-05 19:21 ` [PATCH 04/10] bootwrapper: Add strtoull() Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-07 0:52 ` David Gibson
2007-09-05 19:21 ` [PATCH 06/10] bootwrapper: Move strncmp() from flatdevtree_env.h to string.S/string.h Scott Wood
` (4 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
This will be used by the PlanetCore firmware support to construct
a linux,stdout-path from the serial node that it finds.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/flatdevtree.c | 59 ++++++++++++++++++++++++++++++++++
arch/powerpc/boot/flatdevtree.h | 1 +
arch/powerpc/boot/flatdevtree_misc.c | 6 +++
arch/powerpc/boot/ops.h | 9 +++++
4 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 0af7291..cf30675 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -975,3 +975,62 @@ void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
}
return NULL;
}
+
+/* Returns the start of the path within the provided buffer, or NULL on
+ * error.
+ */
+char *ft_get_path(struct ft_cxt *cxt, const void *phandle,
+ char *buf, int len)
+{
+ const char *path_comp[FT_MAX_DEPTH];
+ struct ft_atom atom;
+ char *p, *next, *pos;
+ int depth = 0, i;
+ void *node;
+
+ node = ft_node_ph2node(cxt, phandle);
+ if (node == NULL)
+ return NULL;
+
+ p = ft_root_node(cxt);
+
+ while ((next = ft_next(cxt, p, &atom)) != NULL) {
+ switch (atom.tag) {
+ case OF_DT_BEGIN_NODE:
+ path_comp[depth++] = atom.name;
+ if (p == node)
+ goto found;
+
+ break;
+
+ case OF_DT_END_NODE:
+ if (--depth == 0)
+ return NULL;
+ }
+
+ p = next;
+ }
+
+found:
+ pos = buf;
+ for (i = 1; i < depth; i++) {
+ int this_len;
+
+ if (len <= 1)
+ return NULL;
+
+ *pos++ = '/';
+ len--;
+
+ strncpy(pos, path_comp[i], len);
+
+ if (pos[len - 1] != 0)
+ return NULL;
+
+ this_len = strlen(pos);
+ len -= this_len;
+ pos += this_len;
+ }
+
+ return buf;
+}
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index 2c1c826..b0957a2 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -108,5 +108,6 @@ void *ft_find_node_by_prop_value(struct ft_cxt *cxt, const void *prev,
const char *propname, const char *propval,
int proplen);
void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name);
+char *ft_get_path(struct ft_cxt *cxt, const void *phandle, char *buf, int len);
#endif /* FLATDEVTREE_H */
diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
index 8d1debe..b367009 100644
--- a/arch/powerpc/boot/flatdevtree_misc.c
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -58,6 +58,11 @@ static unsigned long fdtm_finalize(void)
return (unsigned long)cxt.bph;
}
+static char *fdtm_get_path(const void *phandle, char *buf, int len)
+{
+ return ft_get_path(&cxt, phandle, buf, len);
+}
+
int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device)
{
dt_ops.finddevice = fdtm_finddevice;
@@ -67,6 +72,7 @@ int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device)
dt_ops.create_node = fdtm_create_node;
dt_ops.find_node_by_prop_value = fdtm_find_node_by_prop_value;
dt_ops.finalize = fdtm_finalize;
+ dt_ops.get_path = fdtm_get_path;
return ft_open(&cxt, dt_blob, max_size, max_find_device,
platform_ops.realloc);
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 45c2268..703255b 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -47,6 +47,7 @@ struct dt_ops {
const char *propname,
const char *propval, int proplen);
unsigned long (*finalize)(void);
+ char *(*get_path)(const void *phandle, char *buf, int len);
};
extern struct dt_ops dt_ops;
@@ -170,6 +171,14 @@ static inline void *find_node_by_linuxphandle(const u32 linuxphandle)
(char *)&linuxphandle, sizeof(u32));
}
+static inline char *get_path(const void *phandle, char *buf, int len)
+{
+ if (dt_ops.get_path)
+ return dt_ops.get_path(phandle, buf, len);
+
+ return NULL;
+}
+
static inline void *malloc(unsigned long size)
{
return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 06/10] bootwrapper: Move strncmp() from flatdevtree_env.h to string.S/string.h.
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
` (4 preceding siblings ...)
2007-09-05 19:21 ` [PATCH 05/10] bootwrapper: Add get_path() Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-07 0:51 ` David Gibson
2007-09-05 19:21 ` [PATCH 07/10] bootwrapper: Add PlanetCore firmware support Scott Wood
` (3 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
It will be needed for PlanetCore firmware support.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/flatdevtree_env.h | 14 +-------------
arch/powerpc/boot/string.S | 13 +++++++++++++
arch/powerpc/boot/string.h | 1 +
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/boot/flatdevtree_env.h b/arch/powerpc/boot/flatdevtree_env.h
index 83bc1c7..643bf7f 100644
--- a/arch/powerpc/boot/flatdevtree_env.h
+++ b/arch/powerpc/boot/flatdevtree_env.h
@@ -2,7 +2,7 @@
* This file adds the header file glue so that the shared files
* flatdevicetree.[ch] can compile and work in the powerpc bootwrapper.
*
- * strncmp & strchr copied from <file:lib/strings.c>
+ * strchr copied from <file:lib/strings.c>
* Copyright (C) 1991, 1992 Linus Torvalds
*
* Maintained by: Mark A. Greer <mgreer@mvista.com>
@@ -24,18 +24,6 @@
#define be64_to_cpu(x) (x)
#define cpu_to_be64(x) (x)
-static inline int strncmp(const char *cs, const char *ct, size_t count)
-{
- signed char __res = 0;
-
- while (count) {
- if ((__res = *cs - *ct++) != 0 || !*cs++)
- break;
- count--;
- }
- return __res;
-}
-
static inline char *strchr(const char *s, int c)
{
for (; *s != (char)c; ++s)
diff --git a/arch/powerpc/boot/string.S b/arch/powerpc/boot/string.S
index ac3d43b..ce68c58 100644
--- a/arch/powerpc/boot/string.S
+++ b/arch/powerpc/boot/string.S
@@ -61,6 +61,19 @@ strcmp:
beq 1b
blr
+ .globl strncmp
+strncmp:
+ mtctr r5
+ addi r5,r3,-1
+ addi r4,r4,-1
+1: lbzu r3,1(r5)
+ cmpwi 1,r3,0
+ lbzu r0,1(r4)
+ subf. r3,r0,r3
+ beqlr 1
+ bdnzt 2, 1b
+ blr
+
.globl strlen
strlen:
addi r4,r3,-1
diff --git a/arch/powerpc/boot/string.h b/arch/powerpc/boot/string.h
index 9fdff1c..db401b7 100644
--- a/arch/powerpc/boot/string.h
+++ b/arch/powerpc/boot/string.h
@@ -6,6 +6,7 @@ extern char *strcpy(char *dest, const char *src);
extern char *strncpy(char *dest, const char *src, size_t n);
extern char *strcat(char *dest, const char *src);
extern int strcmp(const char *s1, const char *s2);
+extern int strncmp(const char *s1, const char *s2, size_t n);
extern size_t strlen(const char *s);
extern size_t strnlen(const char *s, size_t count);
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 06/10] bootwrapper: Move strncmp() from flatdevtree_env.h to string.S/string.h.
2007-09-05 19:21 ` [PATCH 06/10] bootwrapper: Move strncmp() from flatdevtree_env.h to string.S/string.h Scott Wood
@ 2007-09-07 0:51 ` David Gibson
2007-09-07 14:24 ` Scott Wood
0 siblings, 1 reply; 31+ messages in thread
From: David Gibson @ 2007-09-07 0:51 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On Wed, Sep 05, 2007 at 02:21:14PM -0500, Scott Wood wrote:
> It will be needed for PlanetCore firmware support.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
I still have a patch that already does this, plus strchr() as well,
pending...
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 06/10] bootwrapper: Move strncmp() from flatdevtree_env.h to string.S/string.h.
2007-09-07 0:51 ` David Gibson
@ 2007-09-07 14:24 ` Scott Wood
0 siblings, 0 replies; 31+ messages in thread
From: Scott Wood @ 2007-09-07 14:24 UTC (permalink / raw)
To: galak, linuxppc-dev
On Fri, Sep 07, 2007 at 10:51:31AM +1000, David Gibson wrote:
> On Wed, Sep 05, 2007 at 02:21:14PM -0500, Scott Wood wrote:
> > It will be needed for PlanetCore firmware support.
> >
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
>
> I still have a patch that already does this, plus strchr() as well,
> pending...
Sure, and I noted last time that this patch should be dropped if yours is
merged. I kept it in the patchset because it's needed to make later
patches build and work.
-Scott
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 07/10] bootwrapper: Add PlanetCore firmware support.
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
` (5 preceding siblings ...)
2007-09-05 19:21 ` [PATCH 06/10] bootwrapper: Move strncmp() from flatdevtree_env.h to string.S/string.h Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-07 1:03 ` David Gibson
2007-09-05 19:21 ` [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target Scott Wood
` (2 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
This is a library that board code can use to extract information from the
PlanetCore configuration keys. PlanetCore is used on various boards from
Embedded Planet.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 2 +-
arch/powerpc/boot/planetcore.c | 164 ++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/planetcore.h | 49 ++++++++++++
3 files changed, 214 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/planetcore.c
create mode 100644 arch/powerpc/boot/planetcore.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 90c2f6d..02f0fe0 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -45,7 +45,7 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
ns16550.c serial.c simple_alloc.c div64.S util.S \
gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
- cpm-serial.c stdlib.c
+ cpm-serial.c stdlib.c planetcore.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c cuboot-pq2.c
diff --git a/arch/powerpc/boot/planetcore.c b/arch/powerpc/boot/planetcore.c
new file mode 100644
index 0000000..c09e952
--- /dev/null
+++ b/arch/powerpc/boot/planetcore.c
@@ -0,0 +1,164 @@
+/*
+ * PlanetCore configuration data support functions
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "stdio.h"
+#include "stdlib.h"
+#include "ops.h"
+#include "planetcore.h"
+#include "io.h"
+
+/* PlanetCore passes information to the OS in the form of
+ * a table of key=value strings, separated by newlines.
+ *
+ * The list is terminated by an empty string (i.e. two
+ * consecutive newlines).
+ *
+ * To make it easier to parse, we first convert all the
+ * newlines into null bytes.
+ */
+
+void planetcore_prepare_table(char *table)
+{
+ do {
+ if (*table == '\n')
+ *table = 0;
+
+ table++;
+ } while (*(table - 1) || *table != '\n');
+
+ *table = 0;
+}
+
+const char *planetcore_get_key(const char *table, const char *key)
+{
+ int keylen = strlen(key);
+
+ do {
+ if (!strncmp(table, key, keylen) && table[keylen] == '=')
+ return table + keylen + 1;
+
+ table += strlen(table) + 1;
+ } while (strlen(table) != 0);
+
+ return NULL;
+}
+
+int planetcore_get_decimal(const char *table, const char *key, u64 *val)
+{
+ const char *str = planetcore_get_key(table, key);
+ if (!str)
+ return 0;
+
+ *val = strtoull(str, NULL, 10);
+ return 1;
+}
+
+int planetcore_get_hex(const char *table, const char *key, u64 *val)
+{
+ const char *str = planetcore_get_key(table, key);
+ if (!str)
+ return 0;
+
+ *val = strtoull(str, NULL, 16);
+ return 1;
+}
+
+static u64 mac_table[4] = {
+ 0x000000000000,
+ 0x000000800000,
+ 0x000000400000,
+ 0x000000c00000,
+};
+
+void planetcore_set_mac_addrs(const char *table)
+{
+ char addr[4][6];
+ u64 int_addr;
+ int i, j;
+
+ if (!planetcore_get_hex(table, PLANETCORE_KEY_MAC_ADDR, &int_addr))
+ return;
+
+ for (i = 0; i < 4; i++) {
+ u64 this_dev_addr = int_addr | mac_table[i];
+
+ for (j = 5; j >= 0; j--) {
+ addr[i][j] = this_dev_addr & 0xff;
+ this_dev_addr >>= 8;
+ }
+ }
+
+ dt_fixup_mac_addresses(addr[0], addr[1], addr[2], addr[3]);
+}
+
+static char prop_buf[MAX_PROP_LEN];
+
+void planetcore_set_stdout_path(const char *table)
+{
+ char *path;
+ const char *label;
+ void *node, *chosen;
+
+ label = planetcore_get_key(table, PLANETCORE_KEY_SERIAL_PORT);
+ if (!label)
+ return;
+
+ node = find_node_by_prop_value_str(NULL, "linux,planetcore-label",
+ label);
+ if (!node)
+ return;
+
+ path = get_path(node, prop_buf, MAX_PROP_LEN);
+ if (!path)
+ return;
+
+ chosen = finddevice("/chosen");
+ if (!chosen)
+ chosen = create_node(NULL, "chosen");
+ if (!chosen)
+ return;
+
+ setprop_str(chosen, "linux,stdout-path", path);
+}
+
+void planetcore_set_serial_speed(const char *table)
+{
+ void *chosen, *stdout;
+ u64 baud;
+ u32 baud32;
+ int len;
+
+ chosen = finddevice("/chosen");
+ if (!chosen)
+ return;
+
+ len = getprop(chosen, "linux,stdout-path", prop_buf, MAX_PROP_LEN);
+ if (len <= 0)
+ return;
+
+ stdout = finddevice(prop_buf);
+ if (!stdout) {
+ printf("planetcore_set_serial_speed: "
+ "Bad /chosen/linux,stdout-path.\r\n");
+
+ return;
+ }
+
+ if (!planetcore_get_decimal(table, PLANETCORE_KEY_SERIAL_BAUD,
+ &baud)) {
+ printf("planetcore_set_serial_speed: No SB tag.\r\n");
+ return;
+ }
+
+ baud32 = baud;
+ setprop(stdout, "current-speed", &baud32, 4);
+}
diff --git a/arch/powerpc/boot/planetcore.h b/arch/powerpc/boot/planetcore.h
new file mode 100644
index 0000000..0d4094f
--- /dev/null
+++ b/arch/powerpc/boot/planetcore.h
@@ -0,0 +1,49 @@
+#ifndef _PPC_BOOT_PLANETCORE_H_
+#define _PPC_BOOT_PLANETCORE_H_
+
+#include "types.h"
+
+#define PLANETCORE_KEY_BOARD_TYPE "BO"
+#define PLANETCORE_KEY_BOARD_REV "BR"
+#define PLANETCORE_KEY_MB_RAM "D1"
+#define PLANETCORE_KEY_MAC_ADDR "EA"
+#define PLANETCORE_KEY_FLASH_SPEED "FS"
+#define PLANETCORE_KEY_IP_ADDR "IP"
+#define PLANETCORE_KEY_KB_NVRAM "NV"
+#define PLANETCORE_KEY_PROCESSOR "PR"
+#define PLANETCORE_KEY_PROC_VARIANT "PV"
+#define PLANETCORE_KEY_SERIAL_BAUD "SB"
+#define PLANETCORE_KEY_SERIAL_PORT "SP"
+#define PLANETCORE_KEY_SWITCH "SW"
+#define PLANETCORE_KEY_TEMP_OFFSET "TC"
+#define PLANETCORE_KEY_TARGET_IP "TIP"
+#define PLANETCORE_KEY_CRYSTAL_HZ "XT"
+
+/* Prepare the table for processing, by turning all newlines
+ * into NULL bytes.
+ */
+void planetcore_prepare_table(char *table);
+
+/* Return the value associated with a given key in text,
+ * decimal, or hex format.
+ *
+ * Returns zero/NULL on failure, non-zero on success.
+ */
+const char *planetcore_get_key(const char *table, const char *key);
+int planetcore_get_decimal(const char *table, const char *key, u64 *val);
+int planetcore_get_hex(const char *table, const char *key, u64 *val);
+
+/* Updates the device tree local-mac-address properties based
+ * on the EA tag.
+ */
+void planetcore_set_mac_addrs(const char *table);
+
+/* Sets the linux,stdout-path in the /chosen node. This requires the
+ * linux,planetcore-label property in each serial node.
+ */
+void planetcore_set_stdout_path(const char *table);
+
+/* Sets the current-speed property in the serial node. */
+void planetcore_set_serial_speed(const char *table);
+
+#endif
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 07/10] bootwrapper: Add PlanetCore firmware support.
2007-09-05 19:21 ` [PATCH 07/10] bootwrapper: Add PlanetCore firmware support Scott Wood
@ 2007-09-07 1:03 ` David Gibson
0 siblings, 0 replies; 31+ messages in thread
From: David Gibson @ 2007-09-07 1:03 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On Wed, Sep 05, 2007 at 02:21:15PM -0500, Scott Wood wrote:
> This is a library that board code can use to extract information from the
> PlanetCore configuration keys. PlanetCore is used on various boards from
> Embedded Planet.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
[snip]
> +void planetcore_set_mac_addrs(const char *table)
> +{
> + char addr[4][6];
> + u64 int_addr;
> + int i, j;
> +
> + if (!planetcore_get_hex(table, PLANETCORE_KEY_MAC_ADDR, &int_addr))
> + return;
> +
> + for (i = 0; i < 4; i++) {
> + u64 this_dev_addr = int_addr | mac_table[i];
> +
> + for (j = 5; j >= 0; j--) {
> + addr[i][j] = this_dev_addr & 0xff;
> + this_dev_addr >>= 8;
> + }
> + }
> +
> + dt_fixup_mac_addresses(addr[0], addr[1], addr[2], addr[3]);
> +}
It seems a bit silly to loop generating the MAC addresses, then loop
again assigning them to the device nodes. Better, I think, to extract
the loop innards from dt_fixup_mac_addresses(), taking the
network-index as a parameter, then call that from within your loop
here.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
` (6 preceding siblings ...)
2007-09-05 19:21 ` [PATCH 07/10] bootwrapper: Add PlanetCore firmware support Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-07 0:58 ` David Gibson
` (2 more replies)
2007-09-05 19:21 ` [PATCH 09/10] bootwrapper: Only print MAC addresses when the node is actually present Scott Wood
2007-09-05 19:21 ` [PATCH 10/10] bootwrapper: Add fsl_get_immr() and 8xx/pq2 clock functions Scott Wood
9 siblings, 3 replies; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
This target produces a flat binary rather than an ELF file,
fixes the entry point at the beginning of the image, and takes
a complete device tree with no fixups needed.
The device tree must have labels on /#address-cells, the timebase
frequency, and the memory size.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/Kconfig | 12 +++++++++++
arch/powerpc/boot/Makefile | 4 ++-
arch/powerpc/boot/fixed-head.S | 4 +++
arch/powerpc/boot/io.h | 7 ++++++
arch/powerpc/boot/raw-platform.c | 41 ++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/wrapper | 21 ++++++++++++++----
6 files changed, 83 insertions(+), 6 deletions(-)
create mode 100644 arch/powerpc/boot/fixed-head.S
create mode 100644 arch/powerpc/boot/raw-platform.c
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 00099ef..251d0c3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -358,6 +358,18 @@ config WANT_DEVICE_TREE
bool
default n
+config BUILD_RAW_IMAGE
+ bool "Build firmware-independent image"
+ select WANT_DEVICE_TREE
+ help
+ If this is enabled, a firmware independent "raw" image will be
+ built, as zImage.raw. This requires a completely filled-in
+ device tree, with the following labels:
+
+ mem_size_cells: on /#address-cells
+ memsize: on the size portion of /memory/reg
+ timebase: on the boot CPU's timebase property
+
config DEVICE_TREE
string "Static device tree source file"
depends on WANT_DEVICE_TREE
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 02f0fe0..2a6a4c6 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -48,7 +48,8 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
cpm-serial.c stdlib.c planetcore.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
- ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c cuboot-pq2.c
+ ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c \
+ cuboot-8xx.c cuboot-pq2.c fixed-head.S raw-platform.c
src-boot := $(src-wlib) $(src-plat) empty.c
src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -146,6 +147,7 @@ image-$(CONFIG_PPC_83xx) += cuImage.83xx
image-$(CONFIG_PPC_85xx) += cuImage.85xx
image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony
image-$(CONFIG_BAMBOO) += treeImage.bamboo
+image-$(CONFIG_BUILD_RAW_IMAGE) += zImage.raw
endif
# For 32-bit powermacs, build the COFF and miboot images
diff --git a/arch/powerpc/boot/fixed-head.S b/arch/powerpc/boot/fixed-head.S
new file mode 100644
index 0000000..8e14cd9
--- /dev/null
+++ b/arch/powerpc/boot/fixed-head.S
@@ -0,0 +1,4 @@
+ .text
+ .global _zimage_start
+_zimage_start:
+ b _zimage_start_lib
diff --git a/arch/powerpc/boot/io.h b/arch/powerpc/boot/io.h
index ccaedae..ec57ec9 100644
--- a/arch/powerpc/boot/io.h
+++ b/arch/powerpc/boot/io.h
@@ -99,4 +99,11 @@ static inline void barrier(void)
asm volatile("" : : : "memory");
}
+static inline void disable_irq(void)
+{
+ int dummy;
+ asm volatile("mfmsr %0; rlwinm %0, %0, 0, ~(1<<15); mtmsr %0" :
+ "=r" (dummy) : : "memory");
+}
+
#endif /* _IO_H */
diff --git a/arch/powerpc/boot/raw-platform.c b/arch/powerpc/boot/raw-platform.c
new file mode 100644
index 0000000..b9caeee
--- /dev/null
+++ b/arch/powerpc/boot/raw-platform.c
@@ -0,0 +1,41 @@
+/*
+ * The "raw" platform -- for booting from a complete dtb without
+ * any fixups.
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ops.h"
+#include "types.h"
+#include "io.h"
+
+BSS_STACK(4096);
+
+/* These are labels in the device tree. */
+extern u32 memsize[2], timebase, mem_size_cells;
+
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+ unsigned long r6, unsigned long r7)
+{
+ u64 memsize64 = memsize[0];
+
+ if (mem_size_cells == 2) {
+ memsize64 <<= 32;
+ memsize64 |= memsize[1];
+ }
+
+ if (sizeof(void *) == 4 && memsize64 >= 0x100000000ULL)
+ memsize64 = 0xffffffff;
+
+ disable_irq();
+ timebase_period_ns = 1000000000 / timebase;
+ simple_alloc_init(_end, memsize64 - (unsigned long)_end, 32, 64);
+ ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
+ serial_console_init();
+}
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 65f6854..a6501e9 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -30,6 +30,7 @@ dtb=
dts=
cacheit=
gzip=.gz
+binary=
# cross-compilation prefix
CROSS=
@@ -107,10 +108,11 @@ while [ "$#" -gt 0 ]; do
done
if [ -n "$dts" ]; then
- if [ -z "$dtb" ]; then
- dtb="$platform.dtb"
- fi
- dtc -O dtb -o "$dtb" -b 0 -V 16 "$dts" || exit 1
+ dtasm="$object/$platform.dtb.S"
+ dto="$object/$platform.dtb.o"
+ echo '.section .kernel:dtb,"a"' > "$dtasm"
+ dtc -O asm -b 0 -V 16 "$dts" >> "$dtasm" || exit 1
+ ${CROSS}gcc "$dtasm" -c -o "$dto"
fi
if [ -z "$kernel" ]; then
@@ -153,6 +155,10 @@ ps3)
ksection=.kernel:vmlinux.bin
isection=.kernel:initrd
;;
+raw)
+ platformo="$object/fixed-head.o $object/raw-platform.o"
+ binary=y
+ ;;
esac
vmz="$tmpdir/`basename \"$kernel\"`.$ext"
@@ -216,7 +222,7 @@ fi
if [ "$platform" != "miboot" ]; then
${CROSS}ld -m elf32ppc -T $lds -o "$ofile" \
- $platformo $tmp $object/wrapper.a
+ $platformo $tmp $dto $object/wrapper.a
rm $tmp
fi
@@ -295,3 +301,8 @@ ps3)
gzip --force -9 --stdout "$ofile.bin" > "$object/otheros.bld"
;;
esac
+
+if [ -n "$binary" ]; then
+ mv "$ofile" "$ofile".elf
+ ${CROSS}objcopy -O binary "$ofile".elf "$ofile"
+fi
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-05 19:21 ` [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target Scott Wood
@ 2007-09-07 0:58 ` David Gibson
2007-09-09 23:29 ` Milton Miller
2007-09-21 17:31 ` Grant Likely
2007-10-03 20:29 ` Grant Likely
2 siblings, 1 reply; 31+ messages in thread
From: David Gibson @ 2007-09-07 0:58 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On Wed, Sep 05, 2007 at 02:21:16PM -0500, Scott Wood wrote:
> This target produces a flat binary rather than an ELF file,
> fixes the entry point at the beginning of the image, and takes
> a complete device tree with no fixups needed.
>
> The device tree must have labels on /#address-cells, the timebase
> frequency, and the memory size.
Hrm... the actual contents of this patch are less about producing an
unheadered binary image than they are about introducing the "raw"
platform. I don't mind the idea of a "raw" platform (although I'm not
sure I like that name for it), but the patch comment needs work.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-07 0:58 ` David Gibson
@ 2007-09-09 23:29 ` Milton Miller
2007-09-10 14:25 ` Scott Wood
2007-09-10 21:17 ` Segher Boessenkool
0 siblings, 2 replies; 31+ messages in thread
From: Milton Miller @ 2007-09-09 23:29 UTC (permalink / raw)
To: Scott Wood; +Cc: ppcdev, David Gibson
On Fri Sep 7 10:58:03 EST 2007, David Gibson wrote:
>> On Wed, Sep 05, 2007 at 02:21:16PM -0500, Scott Wood wrote:
>> This target produces a flat binary rather than an ELF file,
>> fixes the entry point at the beginning of the image, and takes
>> a complete device tree with no fixups needed.
>>
>> The device tree must have labels on /#address-cells, the timebase
>> frequency, and the memory size.
>
> Hrm... the actual contents of this patch are less about producing an
> unheadered binary image than they are about introducing the "raw"
> platform. I don't mind the idea of a "raw" platform (although I'm not
> sure I like that name for it), but the patch comment needs work.
Plus, its not quite as generic as you think.
>> Signed-off-by: Scott Wood <scottwood at freescale.com>
>> ---
>> arch/powerpc/Kconfig | 12 +++++++++++
>> arch/powerpc/boot/Makefile | 4 ++-
>> arch/powerpc/boot/fixed-head.S | 4 +++
>> arch/powerpc/boot/io.h | 7 ++++++
>> arch/powerpc/boot/raw-platform.c | 41
>> ++++++++++++++++++++++++++++++++++++++
>> arch/powerpc/boot/wrapper | 21 ++++++++++++++----
>> 6 files changed, 83 insertions(+), 6 deletions(-)
>> create mode 100644 arch/powerpc/boot/fixed-head.S
>> create mode 100644 arch/powerpc/boot/raw-platform.c
>>
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 00099ef..251d0c3 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -358,6 +358,18 @@ config WANT_DEVICE_TREE
>> bool
>> default n
>>
>> +config BUILD_RAW_IMAGE
>> + bool "Build firmware-independent image"
>> + select WANT_DEVICE_TREE
>> + help
>> + If this is enabled, a firmware independent "raw" image will
>> be
>> + built, as zImage.raw. This requires a completely filled-in
>> + device tree, with the following labels:
>> +
>> + mem_size_cells: on /#address-cells
>> + memsize: on the size portion of /memory/reg
>> + timebase: on the boot CPU's timebase property
>>
You need these labels on (in) the data not on the property struct ...
(one can label either today, but only properties in the not to distant
past).
>> +
>> config DEVICE_TREE
>> string "Static device tree source file"
>> depends on WANT_DEVICE_TREE
>> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
>> index 02f0fe0..2a6a4c6 100644
>> --- a/arch/powerpc/boot/Makefile
>> +++ b/arch/powerpc/boot/Makefile
>> @@ -48,7 +48,8 @@ src-wlib := string.S crt0.S stdio.c main.c
>> flatdevtree.c flatdevtree_misc.c \
>> cpm-serial.c stdlib.c planetcore.c
>> src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
>> cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
>> - ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c
>> cuboot-8xx.c cuboot-pq2.c
>> + ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c \
>> + cuboot-8xx.c cuboot-pq2.c fixed-head.S raw-platform.c
>> src-boot := $(src-wlib) $(src-plat) empty.c
>>
>> src-boot := $(addprefix $(obj)/, $(src-boot))
>> @@ -146,6 +147,7 @@ image-$(CONFIG_PPC_83xx) +=
>> cuImage.83xx
>> image-$(CONFIG_PPC_85xx) += cuImage.85xx
>> image-$(CONFIG_EBONY) += treeImage.ebony
>> cuImage.ebony
>> image-$(CONFIG_BAMBOO) += treeImage.bamboo
>> +image-$(CONFIG_BUILD_RAW_IMAGE) += zImage.raw
>> endif
>>
>> # For 32-bit powermacs, build the COFF and miboot images
>> diff --git a/arch/powerpc/boot/fixed-head.S
>> b/arch/powerpc/boot/fixed-head.S
>> new file mode 100644
>> index 0000000..8e14cd9
>> --- /dev/null
>> +++ b/arch/powerpc/boot/fixed-head.S
>> @@ -0,0 +1,4 @@
>> + .text
>> + .global _zimage_start
>> +_zimage_start:
>> + b _zimage_start_lib
>> diff --git a/arch/powerpc/boot/io.h b/arch/powerpc/boot/io.h
>> index ccaedae..ec57ec9 100644
>> --- a/arch/powerpc/boot/io.h
>> +++ b/arch/powerpc/boot/io.h
>> @@ -99,4 +99,11 @@ static inline void barrier(void)
>> asm volatile("" : : : "memory");
>> }
>>
>> +static inline void disable_irq(void)
>> +{
>> + int dummy;
>> + asm volatile("mfmsr %0; rlwinm %0, %0, 0, ~(1<<15); mtmsr %0"
>> :
>> + "=r" (dummy) : : "memory");
>> +}
This will fail (mtmsr illegal instruction) on 64 bit processors that do
not implement the bridge facility (POWER4, 5, 6, PPC970, ...)
>> +
>> #endif /* _IO_H */
>> diff --git a/arch/powerpc/boot/raw-platform.c
>> b/arch/powerpc/boot/raw-platform.c
>> new file mode 100644
>> index 0000000..b9caeee
>> --- /dev/null
>> +++ b/arch/powerpc/boot/raw-platform.c
>> @@ -0,0 +1,41 @@
>> +/*
>> + * The "raw" platform -- for booting from a complete dtb without
>> + * any fixups.
>> + *
>> + * Author: Scott Wood <scottwood at freescale.com>
>> + *
>> + * Copyright (c) 2007 Freescale Semiconductor, Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or
>> modify it
>> + * under the terms of the GNU General Public License version 2 as
>> published
>> + * by the Free Software Foundation.
>> + */
>> +
>> +#include "ops.h"
>> +#include "types.h"
>> +#include "io.h"
>> +
>> +BSS_STACK(4096);
>> +
>> +/* These are labels in the device tree. */
>> +extern u32 memsize[2], timebase, mem_size_cells;
>> +
>> +void platform_init(unsigned long r3, unsigned long r4, unsigned long
>> r5,
>> + unsigned long r6, unsigned long r7)
>> +{
>> + u64 memsize64 = memsize[0];
>> +
>> + if (mem_size_cells == 2) {
>> + memsize64 <<= 32;
>> + memsize64 |= memsize[1];
>> + }
>> +
>> + if (sizeof(void *) == 4 && memsize64 >= 0x100000000ULL)
>> + memsize64 = 0xffffffff;
>> +
>> + disable_irq();
see above, only works on some processors.
>> + timebase_period_ns = 1000000000 / timebase;
>> + simple_alloc_init(_end, memsize64 - (unsigned long)_end, 32,
>> 64);
>> + ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
>>
only 64 malloc slots?
So the labels are linked against to find the memory size to allocate
all above the load address to malloc ...
We can eliminate the need for the labels by calling simple_alloc_init
twice: the first time on a small bss region, read the properties, then
call it again with the full memory, and then call ft_init again. That
is the trick I used in the kexec series. When dtlib merges, we can
read the tree without malloc and avoid the extra dance.
>> + serial_console_init();
I'm not sure I consider serial_console firemware independent: our
wrapper IO macros simply do normal loads and stores, and rely on
firmware to setup either tlbs, virtural mappings, or other to make the
IO cache inhibited ...
yea, i realize it doesn't have to find a console, and it all works
without it. But this is why I pulled the call from my kexec patches.
>> +}
Just to clarify: this should go in the Kconfig help:
This platform requires
(1) device tree fully filled out, including memory size and timebase
frequency
(2) (currently) labels
(3) firmware that jumps to start of image (this is like old kernels)
(4) after its in ram (we must have writable data/bss)
(5) space below load to decompress vmlinux (no vmlinux_alloc to
fallback to malloc)
(6) all space above load address available to hold malloc region
(7) for console output (or input) from wrapper, on most cpus, some
magic setup
Except for this supplying the dt instead of looking for one passed in
r3, it is very similar to my kexec platform. That platform has a few
more features, however
(1) support for SMP with 64 bit kernel (6xx would require small patch)
(2) support for finding available space above or below, via memregions
(3) support for avoiding memroy blocks (rtas, etc)
I think that code could be tweaked to be used by both.
>> diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
>> index 65f6854..a6501e9 100755
>> --- a/arch/powerpc/boot/wrapper
>> +++ b/arch/powerpc/boot/wrapper
>> @@ -30,6 +30,7 @@ dtb=
>> dts=
>> cacheit=
>> gzip=.gz
>> +binary=
>>
>> # cross-compilation prefix
>> CROSS=
>> @@ -107,10 +108,11 @@ while [ "$#" -gt 0 ]; do
>> done
>>
>> if [ -n "$dts" ]; then
>> - if [ -z "$dtb" ]; then
>> - dtb="$platform.dtb"
>> - fi
>> - dtc -O dtb -o "$dtb" -b 0 -V 16 "$dts" || exit 1
>> + dtasm="$object/$platform.dtb.S"
>> + dto="$object/$platform.dtb.o"
>> + echo '.section .kernel:dtb,"a"' > "$dtasm"
>> + dtc -O asm -b 0 -V 16 "$dts" >> "$dtasm" || exit 1
>> + ${CROSS}gcc "$dtasm" -c -o "$dto"
>> fi
If we are going to start calling gcc from the wrapper (even if it is on
a .S) ...
and synthesizing the input file from pieces ...
and not checking if you need -m32 or if its disallowed ...
not sanitizing preprocessor include environment ...
and if one passes dts and dtb you changed behavior ...
If we need the asm label, I'd rather add the call to dtc->asm and
asm->.o in the makefile and link it into the platform, maybe using a
raw-* rule like cuboot and treeboot, or just hardcode the output to be
dtb.o (since we only have one dts). If we want it to show up in the
.dtb instead of .text then we can use objcopy to rename the section or
do your cat of echo and dtc in a gen_ rule).
... but I think minimal alloc/peek at tree/full alloc is the way to go
for now.
>>
>> if [ -z "$kernel" ]; then
>> @@ -153,6 +155,10 @@ ps3)
>> ksection=.kernel:vmlinux.bin
>> isection=.kernel:initrd
>> ;;
>> +raw)
>> + platformo="$object/fixed-head.o $object/raw-platform.o"
>> + binary=y
>> + ;;
>> esac
>>
>> vmz="$tmpdir/`basename \"$kernel\"`.$ext"
>> @@ -216,7 +222,7 @@ fi
>>
>> if [ "$platform" != "miboot" ]; then
>> ${CROSS}ld -m elf32ppc -T $lds -o "$ofile" \
>> - $platformo $tmp $object/wrapper.a
>> + $platformo $tmp $dto $object/wrapper.a
>> rm $tmp
>> fi
>>
>> @@ -295,3 +301,8 @@ ps3)
>> gzip --force -9 --stdout "$ofile.bin" > "$object/otheros.bld"
>> ;;
>> esac
>> +
>> +if [ -n "$binary" ]; then
>> + mv "$ofile" "$ofile".elf
>> + ${CROSS}objcopy -O binary "$ofile".elf "$ofile"
>> +fi
I'm not sure how putting a binary flag test here will help other
platforms. Even those that want a .elf left behind, if they need ohter
processing they will done the move already. I'd say just make this
part of the platform case just above, although I could accept it being
moved ahead of that case.
Actually, looking at the current case, treeboot, cuboot, and ps3 all
(could) start with this rename and objcopy, so lets put it above the
final platform fixup case, and update those platforms to use this
feature (adjusting the calls to nm, dd, gzip, etc accordingly).
Bottom line: This looks like a very simple platform, but it has hidden
assumptions in its environment (mtmsr, laod in the middle of memory,
others?) and takes the wrapper script in directions i'd rather it not
go. I'd like you to look at my kexec platform series, and see if
reusing some of that code would give us a more robust "raw" image.
(even if you don't need the detached kernel, initramfs parsing, and
detached initrd; I was thinking more like memranges and the
vmlinuz_alloc. The policy about not using memory to end can be
relaxed, and find_end_of_ram made to search memory). It's on my short
list to rediff and repost those anyways.
milton
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-09 23:29 ` Milton Miller
@ 2007-09-10 14:25 ` Scott Wood
2007-09-10 14:30 ` Scott Wood
2007-09-10 16:09 ` Milton Miller
2007-09-10 21:17 ` Segher Boessenkool
1 sibling, 2 replies; 31+ messages in thread
From: Scott Wood @ 2007-09-10 14:25 UTC (permalink / raw)
To: Milton Miller; +Cc: ppcdev, David Gibson
On Sun, Sep 09, 2007 at 06:29:11PM -0500, Milton Miller wrote:
> >>diff --git a/arch/powerpc/boot/io.h b/arch/powerpc/boot/io.h
> >>index ccaedae..ec57ec9 100644
> >>--- a/arch/powerpc/boot/io.h
> >>+++ b/arch/powerpc/boot/io.h
> >>@@ -99,4 +99,11 @@ static inline void barrier(void)
> >> asm volatile("" : : : "memory");
> >> }
> >>
> >>+static inline void disable_irq(void)
> >>+{
> >>+ int dummy;
> >>+ asm volatile("mfmsr %0; rlwinm %0, %0, 0, ~(1<<15); mtmsr %0"
> >>:
> >>+ "=r" (dummy) : : "memory");
> >>+}
>
> This will fail (mtmsr illegal instruction) on 64 bit processors that do
> not implement the bridge facility (POWER4, 5, 6, PPC970, ...)
Ouch... And given the One wrapper.a To Rule Them All mandate, we can't
ifdef it here, but instead must make separate platform files. :-P
> >>+ timebase_period_ns = 1000000000 / timebase;
> >>+ simple_alloc_init(_end, memsize64 - (unsigned long)_end, 32,
> >>64);
> >>+ ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
> >>
>
> only 64 malloc slots?
That was copied from other platforms; it should probably be higher.
> So the labels are linked against to find the memory size to allocate
> all above the load address to malloc ...
>
> We can eliminate the need for the labels by calling simple_alloc_init
> twice: the first time on a small bss region, read the properties, then
> call it again with the full memory, and then call ft_init again. That
> is the trick I used in the kexec series. When dtlib merges, we can
> read the tree without malloc and avoid the extra dance.
OK.
> >>+ serial_console_init();
>
> I'm not sure I consider serial_console firemware independent: our
> wrapper IO macros simply do normal loads and stores, and rely on
> firmware to setup either tlbs, virtural mappings, or other to make the
> IO cache inhibited ...
The intent wasn't to run without firmware (that's require memory
initialization and other fun stuff that isn't here, and certainly isn't
generic), but to run without caring what the firmware is. It's assumed
that whatever firmware is there has initialized the serial port to meet
the needs of whatever serial port the device tree points at.
> yea, i realize it doesn't have to find a console, and it all works
> without it. But this is why I pulled the call from my kexec patches.
That option is available, by not specifying linux,stdout-path at all.
> Just to clarify: this should go in the Kconfig help:
> This platform requires
> (1) device tree fully filled out, including memory size and timebase
> frequency
> (2) (currently) labels
> (3) firmware that jumps to start of image (this is like old kernels)
> (4) after its in ram (we must have writable data/bss)
> (5) space below load to decompress vmlinux (no vmlinux_alloc to
> fallback to malloc)
> (6) all space above load address available to hold malloc region
> (7) for console output (or input) from wrapper, on most cpus, some
> magic setup
For #5, I really need to get around to implementing setting the load
address at build-time based on the size of vmlinux...
> >>+if [ -n "$binary" ]; then
> >>+ mv "$ofile" "$ofile".elf
> >>+ ${CROSS}objcopy -O binary "$ofile".elf "$ofile"
> >>+fi
>
> I'm not sure how putting a binary flag test here will help other
> platforms. Even those that want a .elf left behind, if they need ohter
> processing they will done the move already. I'd say just make this
> part of the platform case just above, although I could accept it being
> moved ahead of that case.
Well, it's also used by planetcore platforms...
> Actually, looking at the current case, treeboot, cuboot, and ps3 all
> (could) start with this rename and objcopy, so lets put it above the
> final platform fixup case, and update those platforms to use this
> feature (adjusting the calls to nm, dd, gzip, etc accordingly).
...but moving it earlier and letting other platforms use the result in
this way would be better, yes.
> Bottom line: This looks like a very simple platform, but it has hidden
> assumptions in its environment (mtmsr, laod in the middle of memory,
> others?) and takes the wrapper script in directions i'd rather it not
> go. I'd like you to look at my kexec platform series, and see if
> reusing some of that code would give us a more robust "raw" image.
> (even if you don't need the detached kernel, initramfs parsing, and
> detached initrd; I was thinking more like memranges and the
> vmlinuz_alloc. The policy about not using memory to end can be
> relaxed, and find_end_of_ram made to search memory). It's on my short
> list to rediff and repost those anyways.
Where can I find the existing patches?
-Scott
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-10 14:25 ` Scott Wood
@ 2007-09-10 14:30 ` Scott Wood
2007-09-10 16:01 ` Milton Miller
2007-09-10 16:09 ` Milton Miller
1 sibling, 1 reply; 31+ messages in thread
From: Scott Wood @ 2007-09-10 14:30 UTC (permalink / raw)
To: Milton Miller; +Cc: ppcdev, David Gibson
On Mon, Sep 10, 2007 at 09:25:13AM -0500, Scott Wood wrote:
> > (5) space below load to decompress vmlinux (no vmlinux_alloc to
> > fallback to malloc)
> > (6) all space above load address available to hold malloc region
> > (7) for console output (or input) from wrapper, on most cpus, some
> > magic setup
>
> For #5, I really need to get around to implementing setting the load
> address at build-time based on the size of vmlinux...
Actually, this isn't needed for raw images -- you can just load them
wherever you want (and thus yes, it should be documented). cuboot needs
it, though.
-Scott
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-10 14:30 ` Scott Wood
@ 2007-09-10 16:01 ` Milton Miller
0 siblings, 0 replies; 31+ messages in thread
From: Milton Miller @ 2007-09-10 16:01 UTC (permalink / raw)
To: Scott Wood; +Cc: ppcdev, David Gibson
On Sep 10, 2007, at 9:30 AM, Scott Wood wrote:
> On Mon, Sep 10, 2007 at 09:25:13AM -0500, Scott Wood wrote:
>>> (5) space below load to decompress vmlinux (no vmlinux_alloc to
>>> fallback to malloc)
>>> (6) all space above load address available to hold malloc region
>>> (7) for console output (or input) from wrapper, on most cpus, some
>>> magic setup
>>
>> For #5, I really need to get around to implementing setting the load
>> address at build-time based on the size of vmlinux...
>
> Actually, this isn't needed for raw images -- you can just load them
> wherever you want (and thus yes, it should be documented). cuboot
> needs
> it, though.
Yea, raw doesn't really care about the linked address.
>>> It's on my short list to rediff and repost those anyways.
>>
>> Where can I find the existing patches?
The last rediff is patchwork id 12168-12181 posted Jul 11. They get
context rejects in the Makefile and ops.h, and I plan to change the
property name from boot-file in patch 12. Also, I need to make the
search for rmo_end be based on device_type "memory", looking for the
extent starting at 0.
milton
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-10 14:25 ` Scott Wood
2007-09-10 14:30 ` Scott Wood
@ 2007-09-10 16:09 ` Milton Miller
1 sibling, 0 replies; 31+ messages in thread
From: Milton Miller @ 2007-09-10 16:09 UTC (permalink / raw)
To: Scott Wood; +Cc: ppcdev, David Gibson
On Sep 10, 2007, at 9:25 AM, Scott Wood wrote:
>>>> +static inline void disable_irq(void)
>>>> +{
>>>> + int dummy;
>>>> + asm volatile("mfmsr %0; rlwinm %0, %0, 0, ~(1<<15); mtmsr
>>>> %0"
>>>> :
>>>> + "=r" (dummy) : : "memory");
>>>> +}
>>
>> This will fail (mtmsr illegal instruction) on 64 bit processors that
>> do
>> not implement the bridge facility (POWER4, 5, 6, PPC970, ...)
>
> Ouch... And given the One wrapper.a To Rule Them All mandate, we can't
> ifdef it here, but instead must make separate platform files. :-P
Rather than a seperate c file, I think this should go in your
_zimage_start, renaming fixed-head.S.
milton
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-09 23:29 ` Milton Miller
2007-09-10 14:25 ` Scott Wood
@ 2007-09-10 21:17 ` Segher Boessenkool
1 sibling, 0 replies; 31+ messages in thread
From: Segher Boessenkool @ 2007-09-10 21:17 UTC (permalink / raw)
To: Milton Miller; +Cc: ppcdev, David Gibson
>>> +static inline void disable_irq(void)
>>> +{
>>> + int dummy;
>>> + asm volatile("mfmsr %0; rlwinm %0, %0, 0, ~(1<<15); mtmsr %0"
>>> :
>>> + "=r" (dummy) : : "memory");
>>> +}
>
> This will fail (mtmsr illegal instruction) on 64 bit processors that do
> not implement the bridge facility (POWER4, 5, 6, PPC970, ...)
The latest ISA lists mtmsr as non-optional, not part of the bridge
facility. That suggests that all CPUs do in fact implement it.
970 does implement the 64-bit bridge facility, btw (well, "most of it").
Segher
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-05 19:21 ` [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target Scott Wood
2007-09-07 0:58 ` David Gibson
@ 2007-09-21 17:31 ` Grant Likely
2007-09-21 17:33 ` Scott Wood
2007-10-03 20:29 ` Grant Likely
2 siblings, 1 reply; 31+ messages in thread
From: Grant Likely @ 2007-09-21 17:31 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On 9/5/07, Scott Wood <scottwood@freescale.com> wrote:
> This target produces a flat binary rather than an ELF file,
> fixes the entry point at the beginning of the image, and takes
> a complete device tree with no fixups needed.
>
> The device tree must have labels on /#address-cells, the timebase
> frequency, and the memory size.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 02f0fe0..2a6a4c6 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -48,7 +48,8 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
> cpm-serial.c stdlib.c planetcore.c
> src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
> cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
> - ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c cuboot-pq2.c
> + ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c \
> + cuboot-8xx.c cuboot-pq2.c fixed-head.S raw-platform.c
> src-boot := $(src-wlib) $(src-plat) empty.c
>
> src-boot := $(addprefix $(obj)/, $(src-boot))
> @@ -146,6 +147,7 @@ image-$(CONFIG_PPC_83xx) += cuImage.83xx
> image-$(CONFIG_PPC_85xx) += cuImage.85xx
> image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony
> image-$(CONFIG_BAMBOO) += treeImage.bamboo
> +image-$(CONFIG_BUILD_RAW_IMAGE) += zImage.raw
> endif
>
> # For 32-bit powermacs, build the COFF and miboot images
Are these makefile changes complete? When I attempt to compile with
this patch I get the following error:
grant@trillian:~/hacking/linux-2.6$ ppc4xx make
CHK include/linux/version.h
CHK include/linux/utsrelease.h
CALL scripts/checksyscalls.sh
CHK include/linux/compile.h
make[1]: *** No rule to make target `arch/powerpc/boot/zImage.raw',
needed by `arch/powerpc/boot/zImage'. Stop.
make: *** [zImage] Error 2
grant@trillian:~/hacking/linux-2.6$
Cheers,
g.
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-21 17:31 ` Grant Likely
@ 2007-09-21 17:33 ` Scott Wood
0 siblings, 0 replies; 31+ messages in thread
From: Scott Wood @ 2007-09-21 17:33 UTC (permalink / raw)
To: Grant Likely; +Cc: linuxppc-dev
On Fri, Sep 21, 2007 at 11:31:11AM -0600, Grant Likely wrote:
> Are these makefile changes complete? When I attempt to compile with
> this patch I get the following error:
>
> grant@trillian:~/hacking/linux-2.6$ ppc4xx make
> CHK include/linux/version.h
> CHK include/linux/utsrelease.h
> CALL scripts/checksyscalls.sh
> CHK include/linux/compile.h
> make[1]: *** No rule to make target `arch/powerpc/boot/zImage.raw',
> needed by `arch/powerpc/boot/zImage'. Stop.
> make: *** [zImage] Error 2
> grant@trillian:~/hacking/linux-2.6$
Odd... It should match the zImage.% target.
-Scott
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target.
2007-09-05 19:21 ` [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target Scott Wood
2007-09-07 0:58 ` David Gibson
2007-09-21 17:31 ` Grant Likely
@ 2007-10-03 20:29 ` Grant Likely
2 siblings, 0 replies; 31+ messages in thread
From: Grant Likely @ 2007-10-03 20:29 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On 9/5/07, Scott Wood <scottwood@freescale.com> wrote:
> This target produces a flat binary rather than an ELF file,
> fixes the entry point at the beginning of the image, and takes
> a complete device tree with no fixups needed.
>
> The device tree must have labels on /#address-cells, the timebase
> frequency, and the memory size.
Scott,
Are you planning to address the comments on this patch and resubmit in
time for the 2.6.24 merge window? The raw platform is quite useful
for Xilinx Virtex support, so I'd really like to see it get merged.
Thanks,
g.
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 09/10] bootwrapper: Only print MAC addresses when the node is actually present.
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
` (7 preceding siblings ...)
2007-09-05 19:21 ` [PATCH 08/10] bootwrapper: Add a firmware-independent "raw" target Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-07 0:52 ` David Gibson
2007-09-05 19:21 ` [PATCH 10/10] bootwrapper: Add fsl_get_immr() and 8xx/pq2 clock functions Scott Wood
9 siblings, 1 reply; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
Some firmwares (such as PlanetCore) only provide a base MAC address, and
expect the kernel to set certain bits to generate the addresses for the
other ports. As such, MAC addresses are generated that may not correspond
to actual hardware.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/devtree.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index e1b8122..549463b 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -100,12 +100,14 @@ void __dt_fixup_mac_addresses(u32 startindex, ...)
devp = find_node_by_prop_value(NULL, "linux,network-index",
(void*)&index, sizeof(index));
- printf("ENET%d: local-mac-address <-"
- " %02x:%02x:%02x:%02x:%02x:%02x\n\r", index,
- addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+ if (devp) {
+ printf("ENET%d: local-mac-address <-"
+ " %02x:%02x:%02x:%02x:%02x:%02x\n\r", index,
+ addr[0], addr[1], addr[2],
+ addr[3], addr[4], addr[5]);
- if (devp)
setprop(devp, "local-mac-address", addr, 6);
+ }
index++;
}
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 10/10] bootwrapper: Add fsl_get_immr() and 8xx/pq2 clock functions.
2007-09-05 19:20 [PATCH 00/10] Bootwrapper patches Scott Wood
` (8 preceding siblings ...)
2007-09-05 19:21 ` [PATCH 09/10] bootwrapper: Only print MAC addresses when the node is actually present Scott Wood
@ 2007-09-05 19:21 ` Scott Wood
2007-09-07 0:53 ` David Gibson
9 siblings, 1 reply; 31+ messages in thread
From: Scott Wood @ 2007-09-05 19:21 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev
fsl_get_immr() is equivalent to the kernel's get_immrbase() function.
mpc885_get_clock() transforms a crystal frequency into a system frequency
according to the PLL register settings.
pq2_get_clocks() does the same as the above for the PowerQUICC II,
except that it produces several different clocks.
The mpc8xx/pq2 set_clocks() functions modify common properties in
the device tree based on the given clock data.
The mpc885/pq2 fixup_clocks() functions call get_clocks(), and
pass the results to set_clocks().
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 2 +-
arch/powerpc/boot/fsl-soc.c | 47 ++++++++++++++++++++
arch/powerpc/boot/fsl-soc.h | 8 +++
arch/powerpc/boot/mpc8xx.c | 82 ++++++++++++++++++++++++++++++++++
arch/powerpc/boot/mpc8xx.h | 11 +++++
arch/powerpc/boot/pq2.c | 102 +++++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/pq2.h | 11 +++++
7 files changed, 262 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/fsl-soc.c
create mode 100644 arch/powerpc/boot/fsl-soc.h
create mode 100644 arch/powerpc/boot/mpc8xx.c
create mode 100644 arch/powerpc/boot/mpc8xx.h
create mode 100644 arch/powerpc/boot/pq2.c
create mode 100644 arch/powerpc/boot/pq2.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 2a6a4c6..e6bed21 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -45,7 +45,7 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
ns16550.c serial.c simple_alloc.c div64.S util.S \
gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
- cpm-serial.c stdlib.c planetcore.c
+ cpm-serial.c stdlib.c planetcore.c fsl-soc.c mpc8xx.c pq2.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c \
diff --git a/arch/powerpc/boot/fsl-soc.c b/arch/powerpc/boot/fsl-soc.c
new file mode 100644
index 0000000..e86a1fa
--- /dev/null
+++ b/arch/powerpc/boot/fsl-soc.c
@@ -0,0 +1,47 @@
+/*
+ * Freescale SOC support functions
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ops.h"
+#include "types.h"
+#include "fsl-soc.h"
+#include "stdio.h"
+
+static u32 prop_buf[MAX_PROP_LEN / 4];
+
+u32 *fsl_get_immr(void)
+{
+ void *soc;
+ unsigned long ret;
+
+ soc = find_node_by_devtype(NULL, "soc");
+ if (soc) {
+ int size;
+ u32 naddr;
+
+ size = getprop(soc, "#address-cells", prop_buf, MAX_PROP_LEN);
+ if (size == 4)
+ naddr = prop_buf[0];
+ else
+ naddr = 2;
+
+ size = getprop(soc, "ranges", prop_buf, MAX_PROP_LEN);
+ if (size >= 12) {
+ if (!dt_xlate_addr(soc, prop_buf + naddr, 8, &ret)) {
+ printf("fsl_get_immr: Can't xlate %x\r\n",
+ prop_buf[naddr]);
+ ret = 0;
+ }
+ }
+ } else printf("fsl_get_immr: No SOC node\r\n");
+
+ return (u32 *)ret;
+}
diff --git a/arch/powerpc/boot/fsl-soc.h b/arch/powerpc/boot/fsl-soc.h
new file mode 100644
index 0000000..5da26fc
--- /dev/null
+++ b/arch/powerpc/boot/fsl-soc.h
@@ -0,0 +1,8 @@
+#ifndef _PPC_BOOT_FSL_SOC_H_
+#define _PPC_BOOT_FSL_SOC_H_
+
+#include "types.h"
+
+u32 *fsl_get_immr(void);
+
+#endif
diff --git a/arch/powerpc/boot/mpc8xx.c b/arch/powerpc/boot/mpc8xx.c
new file mode 100644
index 0000000..add55a7
--- /dev/null
+++ b/arch/powerpc/boot/mpc8xx.c
@@ -0,0 +1,82 @@
+/*
+ * MPC8xx support functions
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ops.h"
+#include "types.h"
+#include "fsl-soc.h"
+#include "mpc8xx.h"
+#include "stdio.h"
+#include "io.h"
+
+#define MPC8XX_PLPRCR (0x284/4) /* PLL and Reset Control Register */
+
+/* Return system clock from crystal frequency */
+u32 mpc885_get_clock(u32 crystal)
+{
+ u32 *immr;
+ u32 plprcr;
+ int mfi, mfn, mfd, pdf, div;
+ u32 ret;
+
+ immr = fsl_get_immr();
+ if (!immr) {
+ printf("mpc885_get_clock: Couldn't get IMMR base.\r\n");
+ return 0;
+ }
+
+ plprcr = in_be32(&immr[MPC8XX_PLPRCR]);
+
+ mfi = (plprcr >> 16) & 15;
+ if (mfi < 5) {
+ printf("Warning: PLPRCR[MFI] value of %d out-of-bounds\r\n",
+ mfi);
+ mfi = 5;
+ }
+
+ pdf = (plprcr >> 1) & 0xf;
+ div = (plprcr >> 20) & 3;
+ mfd = (plprcr >> 22) & 0x1f;
+ mfn = (plprcr >> 27) & 0x1f;
+
+ ret = crystal * mfi;
+
+ if (mfn != 0)
+ ret += crystal * mfn / (mfd + 1);
+
+ return ret / (pdf + 1);
+}
+
+/* Set common device tree fields based on the given clock frequencies. */
+void mpc8xx_set_clocks(u32 sysclk)
+{
+ void *node;
+
+ dt_fixup_cpu_clocks(sysclk, sysclk / 16, sysclk);
+
+ node = finddevice("/soc/cpm");
+ if (node)
+ setprop(node, "clock-frequency", &sysclk, 4);
+
+ node = finddevice("/soc/cpm/brg");
+ if (node)
+ setprop(node, "clock-frequency", &sysclk, 4);
+}
+
+int mpc885_fixup_clocks(u32 crystal)
+{
+ u32 sysclk = mpc885_get_clock(crystal);
+ if (!sysclk)
+ return 0;
+
+ mpc8xx_set_clocks(sysclk);
+ return 1;
+}
diff --git a/arch/powerpc/boot/mpc8xx.h b/arch/powerpc/boot/mpc8xx.h
new file mode 100644
index 0000000..3f59901
--- /dev/null
+++ b/arch/powerpc/boot/mpc8xx.h
@@ -0,0 +1,11 @@
+#ifndef _PPC_BOOT_MPC8xx_H_
+#define _PPC_BOOT_MPC8xx_H_
+
+#include "types.h"
+
+void mpc8xx_set_clocks(u32 sysclk);
+
+u32 mpc885_get_clock(u32 crystal);
+int mpc885_fixup_clocks(u32 crystal);
+
+#endif
diff --git a/arch/powerpc/boot/pq2.c b/arch/powerpc/boot/pq2.c
new file mode 100644
index 0000000..f6d1185
--- /dev/null
+++ b/arch/powerpc/boot/pq2.c
@@ -0,0 +1,102 @@
+/*
+ * PowerQUICC II support functions
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ops.h"
+#include "types.h"
+#include "fsl-soc.h"
+#include "pq2.h"
+#include "stdio.h"
+#include "io.h"
+
+#define PQ2_SCCR (0x10c80/4) /* System Clock Configuration Register */
+#define PQ2_SCMR (0x10c88/4) /* System Clock Mode Register */
+
+static int pq2_corecnf_map[] = {
+ 3, 2, 2, 2, 4, 4, 5, 9, 6, 11, 8, 10, 3, 12, 7, -1,
+ 6, 5, 13, 2, 14, 4, 15, 9, 0, 11, 8, 10, 16, 12, 7, -1
+};
+
+/* Get various clocks from crystal frequency.
+ * Returns zero on failure and non-zero on success.
+ */
+int pq2_get_clocks(u32 crystal, u32 *sysfreq, u32 *corefreq,
+ u32 *timebase, u32 *brgfreq)
+{
+ u32 *immr;
+ u32 sccr, scmr, mainclk, busclk;
+ int corecnf, busdf, plldf, pllmf, dfbrg;
+
+ immr = fsl_get_immr();
+ if (!immr) {
+ printf("pq2_get_clocks: Couldn't get IMMR base.\r\n");
+ return 0;
+ }
+
+ sccr = in_be32(&immr[PQ2_SCCR]);
+ scmr = in_be32(&immr[PQ2_SCMR]);
+
+ dfbrg = sccr & 3;
+ corecnf = (scmr >> 24) & 0x1f;
+ busdf = (scmr >> 20) & 0xf;
+ plldf = (scmr >> 12) & 1;
+ pllmf = scmr & 0xfff;
+
+ mainclk = crystal * (pllmf + 1) / (plldf + 1);
+ busclk = mainclk / (busdf + 1);
+
+ if (sysfreq)
+ *sysfreq = mainclk / 2;
+ if (timebase)
+ *timebase = busclk / 4;
+ if (brgfreq)
+ *brgfreq = mainclk / (1 << ((dfbrg + 1) * 2));
+
+ if (corefreq) {
+ int coremult = pq2_corecnf_map[corecnf];
+
+ if (coremult < 0)
+ *corefreq = mainclk / 2;
+ else if (coremult == 0)
+ return 0;
+ else
+ *corefreq = busclk * coremult / 2;
+ }
+
+ return 1;
+}
+
+/* Set common device tree fields based on the given clock frequencies. */
+void pq2_set_clocks(u32 sysfreq, u32 corefreq, u32 timebase, u32 brgfreq)
+{
+ void *node;
+
+ dt_fixup_cpu_clocks(corefreq, timebase, sysfreq);
+
+ node = finddevice("/soc/cpm");
+ if (node)
+ setprop(node, "clock-frequency", &sysfreq, 4);
+
+ node = finddevice("/soc/cpm/brg");
+ if (node)
+ setprop(node, "clock-frequency", &brgfreq, 4);
+}
+
+int pq2_fixup_clocks(u32 crystal)
+{
+ u32 sysfreq, corefreq, timebase, brgfreq;
+
+ if (!pq2_get_clocks(crystal, &sysfreq, &corefreq, &timebase, &brgfreq))
+ return 0;
+
+ pq2_set_clocks(sysfreq, corefreq, timebase, brgfreq);
+ return 1;
+}
diff --git a/arch/powerpc/boot/pq2.h b/arch/powerpc/boot/pq2.h
new file mode 100644
index 0000000..481698c
--- /dev/null
+++ b/arch/powerpc/boot/pq2.h
@@ -0,0 +1,11 @@
+#ifndef _PPC_BOOT_PQ2_H_
+#define _PPC_BOOT_PQ2_H_
+
+#include "types.h"
+
+int pq2_get_clocks(u32 crystal, u32 *sysfreq, u32 *corefreq,
+ u32 *timebase, u32 *brgfreq);
+void pq2_set_clocks(u32 sysfreq, u32 corefreq, u32 timebase, u32 brgfreq);
+int pq2_fixup_clocks(u32 crystal);
+
+#endif
--
1.5.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 10/10] bootwrapper: Add fsl_get_immr() and 8xx/pq2 clock functions.
2007-09-05 19:21 ` [PATCH 10/10] bootwrapper: Add fsl_get_immr() and 8xx/pq2 clock functions Scott Wood
@ 2007-09-07 0:53 ` David Gibson
2007-09-07 14:26 ` Scott Wood
0 siblings, 1 reply; 31+ messages in thread
From: David Gibson @ 2007-09-07 0:53 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On Wed, Sep 05, 2007 at 02:21:19PM -0500, Scott Wood wrote:
> fsl_get_immr() is equivalent to the kernel's get_immrbase() function.
>
> mpc885_get_clock() transforms a crystal frequency into a system frequency
> according to the PLL register settings.
>
> pq2_get_clocks() does the same as the above for the PowerQUICC II,
> except that it produces several different clocks.
>
> The mpc8xx/pq2 set_clocks() functions modify common properties in
> the device tree based on the given clock data.
>
> The mpc885/pq2 fixup_clocks() functions call get_clocks(), and
> pass the results to set_clocks().
Uh... doesn't this need to go in the series *before* the patch that
uses fsl_get_immr() for the pq2 code..?
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 31+ messages in thread