* [PATCH] dtc: add setting of physical boot cpu
@ 2006-05-18 3:56 Michael Neuling
2006-05-18 13:23 ` Jimi Xenidis
0 siblings, 1 reply; 5+ messages in thread
From: Michael Neuling @ 2006-05-18 3:56 UTC (permalink / raw)
To: linuxppc-dev, Jon Loeliger
dtc always sets the physical boot CPU to 0xfeedbeef. Add a -b option to
set this.
---
I've tested the blob output but not asm output.
---
dtc.c | 12 +++++++++---
dtc.h | 6 ++++--
flattree.c | 16 ++++++++++------
3 files changed, 23 insertions(+), 11 deletions(-)
Index: dtc/dtc.c
===================================================================
--- dtc.orig/dtc.c
+++ dtc/dtc.c
@@ -95,6 +95,8 @@ static void usage(void)
fprintf(stderr, "\t\tBlob version to produce, defaults to 3 (relevant for dtb\n\t\tand asm output only)\n");
fprintf(stderr, "\t-R <number>\n");
fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n");
+ fprintf(stderr, "\t-b <number>\n");
+ fprintf(stderr, "\t\tSet the physical boot cpu\n");
fprintf(stderr, "\t-f\n");
fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
exit(2);
@@ -113,8 +115,9 @@ int main(int argc, char *argv[])
FILE *outf = NULL;
int outversion = 3;
int reservenum = 1;
+ int boot_cpuid_phys = 0xfeedbeef;
- while ((opt = getopt(argc, argv, "I:O:o:V:R:f")) != EOF) {
+ while ((opt = getopt(argc, argv, "I:O:o:V:R:fb:")) != EOF) {
switch (opt) {
case 'I':
inform = optarg;
@@ -134,6 +137,9 @@ int main(int argc, char *argv[])
case 'f':
force = 1;
break;
+ case 'b':
+ boot_cpuid_phys = strtol(optarg, NULL, 0);
+ break;
default:
usage();
}
@@ -185,9 +191,9 @@ int main(int argc, char *argv[])
if (streq(outform, "dts")) {
dt_to_source(outf, bi);
} else if (streq(outform, "dtb")) {
- dt_to_blob(outf, bi, outversion);
+ dt_to_blob(outf, bi, outversion, boot_cpuid_phys);
} else if (streq(outform, "asm")) {
- dt_to_asm(outf, bi, outversion);
+ dt_to_asm(outf, bi, outversion, boot_cpuid_phys);
} else if (streq(outform, "null")) {
/* do nothing */
} else {
Index: dtc/dtc.h
===================================================================
--- dtc.orig/dtc.h
+++ dtc/dtc.h
@@ -207,8 +207,10 @@ struct boot_info *build_boot_info(struct
/* Flattened trees */
-void dt_to_blob(FILE *f, struct boot_info *bi, int version);
-void dt_to_asm(FILE *f, struct boot_info *bi, int version);
+void dt_to_blob(FILE *f, struct boot_info *bi, int version,
+ int boot_cpuid_phys);
+void dt_to_asm(FILE *f, struct boot_info *bi, int version,
+ int boot_cpuid_phys);
struct boot_info *dt_from_blob(FILE *f);
Index: dtc/flattree.c
===================================================================
--- dtc.orig/flattree.c
+++ dtc/flattree.c
@@ -301,7 +301,8 @@ static struct data flatten_reserve_list(
}
static void make_bph(struct boot_param_header *bph,
struct version_info *vi,
- int reservesize, int dtsize, int strsize)
+ int reservesize, int dtsize, int strsize,
+ int boot_cpuid_phys)
{
int reserve_off;
@@ -324,12 +325,13 @@ static void make_bph(struct boot_param_h
+ dtsize + strsize);
if (vi->flags & FTF_BOOTCPUID)
- bph->boot_cpuid_phys = 0xfeedbeef;
+ bph->boot_cpuid_phys = cpu_to_be32(boot_cpuid_phys);
if (vi->flags & FTF_STRTABSIZE)
bph->size_dt_strings = cpu_to_be32(strsize);
}
-void dt_to_blob(FILE *f, struct boot_info *bi, int version)
+void dt_to_blob(FILE *f, struct boot_info *bi, int version,
+ int boot_cpuid_phys)
{
struct version_info *vi = NULL;
int i;
@@ -355,7 +357,8 @@ void dt_to_blob(FILE *f, struct boot_inf
reservebuf = flatten_reserve_list(bi->reservelist, vi);
/* Make header */
- make_bph(&bph, vi, reservebuf.len, dtbuf.len, strbuf.len);
+ make_bph(&bph, vi, reservebuf.len, dtbuf.len, strbuf.len,
+ boot_cpuid_phys);
fwrite(&bph, vi->hdr_size, 1, f);
@@ -395,7 +398,7 @@ static void dump_stringtable_asm(FILE *f
}
}
-void dt_to_asm(FILE *f, struct boot_info *bi, int version)
+void dt_to_asm(FILE *f, struct boot_info *bi, int version, int boot_cpuid_phys)
{
struct version_info *vi = NULL;
int i;
@@ -434,7 +437,8 @@ void dt_to_asm(FILE *f, struct boot_info
vi->last_comp_version);
if (vi->flags & FTF_BOOTCPUID)
- fprintf(f, "\t.long\t0xdeadbeef\t/*boot_cpuid_phys*/\n");
+ fprintf(f, "\t.long\t%i\t/*boot_cpuid_phys*/\n",
+ boot_cpuid_phys);
if (vi->flags & FTF_STRTABSIZE)
fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n",
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dtc: add setting of physical boot cpu
2006-05-18 3:56 [PATCH] dtc: add setting of physical boot cpu Michael Neuling
@ 2006-05-18 13:23 ` Jimi Xenidis
2006-05-18 16:59 ` Michael Neuling
0 siblings, 1 reply; 5+ messages in thread
From: Jimi Xenidis @ 2006-05-18 13:23 UTC (permalink / raw)
To: Michael Neuling; +Cc: linuxppc-dev
Hey Michael, a few questions:
How does this interact with "linux,boot-cpu"?
If -b is defined then the absence of "linux,boot-cpu" should no
longer cause a warning.
Perhaps if -b is missing the header value is set from "linux,boot-
cpu" property?
Should we extend the "linux,boot-cpu" to actually contain a thread-id
or are we deprecating this prop?
-JX
On May 17, 2006, at 11:56 PM, Michael Neuling wrote:
> dtc always sets the physical boot CPU to 0xfeedbeef. Add a -b
> option to
> set this.
>
> ---
> I've tested the blob output but not asm output.
>
> ---
> dtc.c | 12 +++++++++---
> dtc.h | 6 ++++--
> flattree.c | 16 ++++++++++------
> 3 files changed, 23 insertions(+), 11 deletions(-)
>
> Index: dtc/dtc.c
> ===================================================================
> --- dtc.orig/dtc.c
> +++ dtc/dtc.c
> @@ -95,6 +95,8 @@ static void usage(void)
> fprintf(stderr, "\t\tBlob version to produce, defaults to 3
> (relevant for dtb\n\t\tand asm output only)\n");
> fprintf(stderr, "\t-R <number>\n");
> fprintf(stderr, "\t\tMake space for <number> reserve map entries
> (relevant for \n\t\tdtb and asm output only)\n");
> + fprintf(stderr, "\t-b <number>\n");
> + fprintf(stderr, "\t\tSet the physical boot cpu\n");
> fprintf(stderr, "\t-f\n");
> fprintf(stderr, "\t\tForce - try to produce output even if the
> input tree has errors\n");
> exit(2);
> @@ -113,8 +115,9 @@ int main(int argc, char *argv[])
> FILE *outf = NULL;
> int outversion = 3;
> int reservenum = 1;
> + int boot_cpuid_phys = 0xfeedbeef;
>
> - while ((opt = getopt(argc, argv, "I:O:o:V:R:f")) != EOF) {
> + while ((opt = getopt(argc, argv, "I:O:o:V:R:fb:")) != EOF) {
> switch (opt) {
> case 'I':
> inform = optarg;
> @@ -134,6 +137,9 @@ int main(int argc, char *argv[])
> case 'f':
> force = 1;
> break;
> + case 'b':
> + boot_cpuid_phys = strtol(optarg, NULL, 0);
> + break;
> default:
> usage();
> }
> @@ -185,9 +191,9 @@ int main(int argc, char *argv[])
> if (streq(outform, "dts")) {
> dt_to_source(outf, bi);
> } else if (streq(outform, "dtb")) {
> - dt_to_blob(outf, bi, outversion);
> + dt_to_blob(outf, bi, outversion, boot_cpuid_phys);
> } else if (streq(outform, "asm")) {
> - dt_to_asm(outf, bi, outversion);
> + dt_to_asm(outf, bi, outversion, boot_cpuid_phys);
> } else if (streq(outform, "null")) {
> /* do nothing */
> } else {
> Index: dtc/dtc.h
> ===================================================================
> --- dtc.orig/dtc.h
> +++ dtc/dtc.h
> @@ -207,8 +207,10 @@ struct boot_info *build_boot_info(struct
>
> /* Flattened trees */
>
> -void dt_to_blob(FILE *f, struct boot_info *bi, int version);
> -void dt_to_asm(FILE *f, struct boot_info *bi, int version);
> +void dt_to_blob(FILE *f, struct boot_info *bi, int version,
> + int boot_cpuid_phys);
> +void dt_to_asm(FILE *f, struct boot_info *bi, int version,
> + int boot_cpuid_phys);
>
> struct boot_info *dt_from_blob(FILE *f);
>
> Index: dtc/flattree.c
> ===================================================================
> --- dtc.orig/flattree.c
> +++ dtc/flattree.c
> @@ -301,7 +301,8 @@ static struct data flatten_reserve_list(
> }
> static void make_bph(struct boot_param_header *bph,
> struct version_info *vi,
> - int reservesize, int dtsize, int strsize)
> + int reservesize, int dtsize, int strsize,
> + int boot_cpuid_phys)
> {
> int reserve_off;
>
> @@ -324,12 +325,13 @@ static void make_bph(struct boot_param_h
> + dtsize + strsize);
>
> if (vi->flags & FTF_BOOTCPUID)
> - bph->boot_cpuid_phys = 0xfeedbeef;
> + bph->boot_cpuid_phys = cpu_to_be32(boot_cpuid_phys);
> if (vi->flags & FTF_STRTABSIZE)
> bph->size_dt_strings = cpu_to_be32(strsize);
> }
>
> -void dt_to_blob(FILE *f, struct boot_info *bi, int version)
> +void dt_to_blob(FILE *f, struct boot_info *bi, int version,
> + int boot_cpuid_phys)
> {
> struct version_info *vi = NULL;
> int i;
> @@ -355,7 +357,8 @@ void dt_to_blob(FILE *f, struct boot_inf
> reservebuf = flatten_reserve_list(bi->reservelist, vi);
>
> /* Make header */
> - make_bph(&bph, vi, reservebuf.len, dtbuf.len, strbuf.len);
> + make_bph(&bph, vi, reservebuf.len, dtbuf.len, strbuf.len,
> + boot_cpuid_phys);
>
> fwrite(&bph, vi->hdr_size, 1, f);
>
> @@ -395,7 +398,7 @@ static void dump_stringtable_asm(FILE *f
> }
> }
>
> -void dt_to_asm(FILE *f, struct boot_info *bi, int version)
> +void dt_to_asm(FILE *f, struct boot_info *bi, int version, int
> boot_cpuid_phys)
> {
> struct version_info *vi = NULL;
> int i;
> @@ -434,7 +437,8 @@ void dt_to_asm(FILE *f, struct boot_info
> vi->last_comp_version);
>
> if (vi->flags & FTF_BOOTCPUID)
> - fprintf(f, "\t.long\t0xdeadbeef\t/*boot_cpuid_phys*/\n");
> + fprintf(f, "\t.long\t%i\t/*boot_cpuid_phys*/\n",
> + boot_cpuid_phys);
>
> if (vi->flags & FTF_STRTABSIZE)
> fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/*
> size_dt_strings */\n",
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dtc: add setting of physical boot cpu
2006-05-18 13:23 ` Jimi Xenidis
@ 2006-05-18 16:59 ` Michael Neuling
2006-05-30 22:31 ` Michael Neuling
0 siblings, 1 reply; 5+ messages in thread
From: Michael Neuling @ 2006-05-18 16:59 UTC (permalink / raw)
To: Jimi Xenidis; +Cc: linuxppc-dev
> How does this interact with "linux,boot-cpu"?
Currently, the -b option only changes the value in blob header.
linux,boot-cpu is still taken from whatever the input dts/dtb/fs
specifies.
> If -b is defined then the absence of "linux,boot-cpu" should no
> longer cause a warning.
For version 2 of the blob, this property should be in the header.
Perhaps we should warn if linux,boot-cpu is _missing_ when using <
version 2 and warn if it's _there_ for >= version 2.
I should add an error if someone specifies -b with version < 2.
> Perhaps if -b is missing the header value is set from "linux,boot-
> cpu" property?
I believe they're suppose to be mutually exclusive, so probably not a
good idea.
> Should we extend the "linux,boot-cpu" to actually contain a thread-id
> or are we deprecating this prop?
Yeah, the linux,boot-cpu is deprecated in version >= 2.
The dtc docs say that the boot_cpuid_phys field should match the "reg"
property in the CPU node. Their should be a "reg" property for each
thread, which I think solves your problem.
On a different note, dtc reading blobs on little endian machines is
broken. Just look at reserve mem entries in the output. I think the
main issue is with flat_read_chunk using memcpy.
Mikey
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] dtc: add setting of physical boot cpu
2006-05-18 16:59 ` Michael Neuling
@ 2006-05-30 22:31 ` Michael Neuling
2006-06-07 14:49 ` Jon Loeliger
0 siblings, 1 reply; 5+ messages in thread
From: Michael Neuling @ 2006-05-30 22:31 UTC (permalink / raw)
To: linuxppc-dev, Jon Loeliger
dtc always sets the physical boot CPU to 0xfeedbeef. Add a -b option to
set this. Also add warnings when using the wrong property with the
wrong blob version.
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
Retransmission with updated warnings after discussion with Jimi.
dtc.c | 14 ++++++++++----
dtc.h | 8 +++++---
flattree.c | 16 ++++++++++------
livetree.c | 17 ++++++++++++-----
4 files changed, 37 insertions(+), 18 deletions(-)
Index: dtc/dtc.c
===================================================================
--- dtc.orig/dtc.c
+++ dtc/dtc.c
@@ -95,6 +95,8 @@ static void usage(void)
fprintf(stderr, "\t\tBlob version to produce, defaults to 3 (relevant for dtb\n\t\tand asm output only)\n");
fprintf(stderr, "\t-R <number>\n");
fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n");
+ fprintf(stderr, "\t-b <number>\n");
+ fprintf(stderr, "\t\tSet the physical boot cpu\n");
fprintf(stderr, "\t-f\n");
fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
exit(2);
@@ -113,8 +115,9 @@ int main(int argc, char *argv[])
FILE *outf = NULL;
int outversion = 3;
int reservenum = 1;
+ int boot_cpuid_phys = 0xfeedbeef;
- while ((opt = getopt(argc, argv, "I:O:o:V:R:f")) != EOF) {
+ while ((opt = getopt(argc, argv, "I:O:o:V:R:fb:")) != EOF) {
switch (opt) {
case 'I':
inform = optarg;
@@ -134,6 +137,9 @@ int main(int argc, char *argv[])
case 'f':
force = 1;
break;
+ case 'b':
+ boot_cpuid_phys = strtol(optarg, NULL, 0);
+ break;
default:
usage();
}
@@ -167,7 +173,7 @@ int main(int argc, char *argv[])
if (! bi || ! bi->dt)
die("Couldn't read input tree\n");
- if (! check_device_tree(bi->dt)) {
+ if (! check_device_tree(bi->dt, outversion, boot_cpuid_phys)) {
fprintf(stderr, "Input tree has errors\n");
if (! force)
exit(1);
@@ -185,9 +191,9 @@ int main(int argc, char *argv[])
if (streq(outform, "dts")) {
dt_to_source(outf, bi);
} else if (streq(outform, "dtb")) {
- dt_to_blob(outf, bi, outversion);
+ dt_to_blob(outf, bi, outversion, boot_cpuid_phys);
} else if (streq(outform, "asm")) {
- dt_to_asm(outf, bi, outversion);
+ dt_to_asm(outf, bi, outversion, boot_cpuid_phys);
} else if (streq(outform, "null")) {
/* do nothing */
} else {
Index: dtc/dtc.h
===================================================================
--- dtc.orig/dtc.h
+++ dtc/dtc.h
@@ -178,7 +178,7 @@ struct node *chain_node(struct node *fir
void add_property(struct node *node, struct property *prop);
void add_child(struct node *parent, struct node *child);
-int check_device_tree(struct node *dt);
+int check_device_tree(struct node *dt, int outversion, int boot_cpuid_phys);
/* Boot info (tree plus memreserve information */
@@ -207,8 +207,10 @@ struct boot_info *build_boot_info(struct
/* Flattened trees */
-void dt_to_blob(FILE *f, struct boot_info *bi, int version);
-void dt_to_asm(FILE *f, struct boot_info *bi, int version);
+void dt_to_blob(FILE *f, struct boot_info *bi, int version,
+ int boot_cpuid_phys);
+void dt_to_asm(FILE *f, struct boot_info *bi, int version,
+ int boot_cpuid_phys);
struct boot_info *dt_from_blob(FILE *f);
Index: dtc/flattree.c
===================================================================
--- dtc.orig/flattree.c
+++ dtc/flattree.c
@@ -301,7 +301,8 @@ static struct data flatten_reserve_list(
}
static void make_bph(struct boot_param_header *bph,
struct version_info *vi,
- int reservesize, int dtsize, int strsize)
+ int reservesize, int dtsize, int strsize,
+ int boot_cpuid_phys)
{
int reserve_off;
@@ -324,12 +325,13 @@ static void make_bph(struct boot_param_h
+ dtsize + strsize);
if (vi->flags & FTF_BOOTCPUID)
- bph->boot_cpuid_phys = 0xfeedbeef;
+ bph->boot_cpuid_phys = cpu_to_be32(boot_cpuid_phys);
if (vi->flags & FTF_STRTABSIZE)
bph->size_dt_strings = cpu_to_be32(strsize);
}
-void dt_to_blob(FILE *f, struct boot_info *bi, int version)
+void dt_to_blob(FILE *f, struct boot_info *bi, int version,
+ int boot_cpuid_phys)
{
struct version_info *vi = NULL;
int i;
@@ -355,7 +357,8 @@ void dt_to_blob(FILE *f, struct boot_inf
reservebuf = flatten_reserve_list(bi->reservelist, vi);
/* Make header */
- make_bph(&bph, vi, reservebuf.len, dtbuf.len, strbuf.len);
+ make_bph(&bph, vi, reservebuf.len, dtbuf.len, strbuf.len,
+ boot_cpuid_phys);
fwrite(&bph, vi->hdr_size, 1, f);
@@ -395,7 +398,7 @@ static void dump_stringtable_asm(FILE *f
}
}
-void dt_to_asm(FILE *f, struct boot_info *bi, int version)
+void dt_to_asm(FILE *f, struct boot_info *bi, int version, int boot_cpuid_phys)
{
struct version_info *vi = NULL;
int i;
@@ -434,7 +437,8 @@ void dt_to_asm(FILE *f, struct boot_info
vi->last_comp_version);
if (vi->flags & FTF_BOOTCPUID)
- fprintf(f, "\t.long\t0xdeadbeef\t/*boot_cpuid_phys*/\n");
+ fprintf(f, "\t.long\t%i\t/*boot_cpuid_phys*/\n",
+ boot_cpuid_phys);
if (vi->flags & FTF_STRTABSIZE)
fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n",
Index: dtc/livetree.c
===================================================================
--- dtc.orig/livetree.c
+++ dtc/livetree.c
@@ -456,7 +456,7 @@ static int check_root(struct node *root)
return ok;
}
-static int check_cpus(struct node *root)
+static int check_cpus(struct node *root, int outversion, int boot_cpuid_phys)
{
struct node *cpus, *cpu;
struct property *prop;
@@ -518,8 +518,15 @@ static int check_cpus(struct node *root)
}
}
- if (! bootcpu)
- WARNMSG("No cpu has \"linux,boot-cpu\" property\n");
+ if (outversion < 2) {
+ if (! bootcpu)
+ WARNMSG("No cpu has \"linux,boot-cpu\" property\n");
+ } else {
+ if (bootcpu)
+ WARNMSG("\"linux,boot-cpu\" property is deprecated in blob version 2 or higher\n");
+ if (boot_cpuid_phys == 0xfeedbeef)
+ WARNMSG("physical boot CPU not set. Use -b option to set\n");
+ }
return ok;
}
@@ -697,7 +704,7 @@ static void fixup_phandles(struct node *
fixup_phandles(root, child);
}
-int check_device_tree(struct node *dt)
+int check_device_tree(struct node *dt, int outversion, int boot_cpuid_phys)
{
int ok = 1;
@@ -713,7 +720,7 @@ int check_device_tree(struct node *dt)
return 0;
ok = ok && check_root(dt);
- ok = ok && check_cpus(dt);
+ ok = ok && check_cpus(dt, outversion, boot_cpuid_phys);
ok = ok && check_memory(dt);
ok = ok && check_chosen(dt);
if (! ok)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dtc: add setting of physical boot cpu
2006-05-30 22:31 ` Michael Neuling
@ 2006-06-07 14:49 ` Jon Loeliger
0 siblings, 0 replies; 5+ messages in thread
From: Jon Loeliger @ 2006-06-07 14:49 UTC (permalink / raw)
To: Michael Neuling; +Cc: linuxppc-dev
So, like, the other day Michael Neuling mumbled:
> dtc always sets the physical boot CPU to 0xfeedbeef. Add a -b option to
> set this. Also add warnings when using the wrong property with the
> wrong blob version.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
Applied and pushed out to:
http://www.jdl.com/git_repos
Sorry for the hang time.
Thanks,
jdl
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-07 15:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-18 3:56 [PATCH] dtc: add setting of physical boot cpu Michael Neuling
2006-05-18 13:23 ` Jimi Xenidis
2006-05-18 16:59 ` Michael Neuling
2006-05-30 22:31 ` Michael Neuling
2006-06-07 14:49 ` Jon Loeliger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).