All of lore.kernel.org
 help / color / mirror / Atom feed
* [DTC PATCH] Add support for decimal, octal and binary based cell values.
@ 2007-02-15 17:13 Jon Loeliger
  2007-02-15 17:30 ` Kumar Gala
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Jon Loeliger @ 2007-02-15 17:13 UTC (permalink / raw)
  To: linuxppc-dev


New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base.  Eg: <d# 123>

Signed-off-by: Jon Loeliger <jdl@freescale.com>

---

Beginnings of test cases in the next patch.
Don't stress the yylloc too much.  We'll eventually
work to make that better and more general later.


 data.c       |   21 +++++++++++++++++++++
 dtc-lexer.l  |   21 +++++++++++++++------
 dtc-parser.y |   16 ++++++++++++++--
 dtc.h        |    1 +
 4 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/data.c b/data.c
index 1907a1a..c6c2350 100644
--- a/data.c
+++ b/data.c
@@ -19,6 +19,7 @@
  */
 
 #include "dtc.h"
+#include "dtc-parser.tab.h"
 
 void fixup_free(struct fixup *f)
 {
@@ -224,6 +225,26 @@ struct data data_merge(struct data d1, struct data d2)
 	return d;
 }
 
+/*
+ * Convert a string representation of a numberic cell
+ * in the given base into a cell.
+ */
+cell_t data_convert_cell(char *s, unsigned int base)
+{
+	cell_t c;
+	extern YYLTYPE yylloc;
+
+	c = strtoul(s, NULL, base);
+	if (errno == EINVAL || errno == ERANGE) {
+		fprintf(stderr,
+			"Line %d: Invalid cell value '%s'; %d assumed\n",
+			yylloc.first_line, s, c);
+	}
+
+	return c;
+}
+
+
 struct data data_append_cell(struct data d, cell_t word)
 {
 	cell_t beword = cpu_to_be32(word);
diff --git a/dtc-lexer.l b/dtc-lexer.l
index 6146bad..93f3268 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -83,15 +83,24 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			BEGIN(INITIAL);
 			return ';';
 		}
+<CELLDATA>[bodh]# {
+			yylloc.first_line = yylineno;
+			if (*yytext == 'b')
+				yylval.cbase = 2;
+			else if (*yytext == 'o')
+				yylval.cbase = 8;
+			else if (*yytext == 'd')
+				yylval.cbase = 10;
+			else
+				yylval.cbase = 16;
+			DPRINT("Base: %d\n", yylval.cbase);
+			return DT_BASE;
+		}
 
 <CELLDATA>[0-9a-fA-F]+	{
 			yylloc.first_line = yylineno;
-			if (yyleng > 2*sizeof(yylval.cval)) {
-				fprintf(stderr,
-					"Cell value %s too long\n", yytext);
-			}
-			yylval.cval = strtoul(yytext, NULL, 16);
-			DPRINT("Cell: %x\n", yylval.cval);
+			yylval.str = strdup(yytext);
+			DPRINT("Cell: '%s'\n", yylval.str);
 			return DT_CELL;
 		}
 
diff --git a/dtc-parser.y b/dtc-parser.y
index bd725fe..992fdb1 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -33,6 +33,7 @@ extern struct boot_info *the_boot_info;
 
 %union {
 	cell_t cval;
+	unsigned int cbase;
 	u8 byte;
 	char *str;
 	struct data data;
@@ -50,7 +51,8 @@ extern struct boot_info *the_boot_info;
 %token <addr> DT_ADDR
 %token <str> DT_PROPNAME
 %token <str> DT_NODENAME
-%token <cval> DT_CELL
+%token <cbase> DT_BASE
+%token <str> DT_CELL
 %token <byte> DT_BYTE
 %token <data> DT_STRING
 %token <str> DT_UNIT
@@ -61,6 +63,7 @@ extern struct boot_info *the_boot_info;
 %type <data> propdataprefix
 %type <re> memreserve
 %type <re> memreserves
+%type <cbase> opt_cell_base
 %type <data> celllist
 %type <data> bytestring
 %type <prop> propdef
@@ -133,7 +136,16 @@ propdataprefix:	propdata ',' { $$ = $1; }
 	|	/* empty */ { $$ = empty_data; }
 	;
 
-celllist:	celllist DT_CELL { $$ = data_append_cell($1, $2); }
+opt_cell_base:
+	  /* empty */
+		{ $$ = 16; }
+	| DT_BASE
+	;
+
+celllist:	celllist opt_cell_base DT_CELL {
+			$$ = data_append_cell($1,
+					      data_convert_cell($3, $2));
+		}
 	|	celllist DT_REF	{
 			$$ = data_append_cell(data_add_fixup($1, $2), -1);
 		}
diff --git a/dtc.h b/dtc.h
index 8d3964c..7ee96a5 100644
--- a/dtc.h
+++ b/dtc.h
@@ -118,6 +118,7 @@ struct data data_copy_mem(char *mem, int len);
 struct data data_copy_escape_string(char *s, int len);
 struct data data_copy_file(FILE *f, size_t len);
 
+cell_t data_convert_cell(char *s, unsigned int base);
 struct data data_append_data(struct data d, void *p, int len);
 struct data data_merge(struct data d1, struct data d2);
 struct data data_append_cell(struct data d, cell_t word);
-- 
1.5.0.rc3.ge4b0e

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 17:13 [DTC PATCH] Add support for decimal, octal and binary based cell values Jon Loeliger
@ 2007-02-15 17:30 ` Kumar Gala
  2007-02-15 17:49   ` Yoder Stuart-B08248
  2007-02-15 17:45 ` Yoder Stuart-B08248
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 23+ messages in thread
From: Kumar Gala @ 2007-02-15 17:30 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev


On Feb 15, 2007, at 11:13 AM, Jon Loeliger wrote:

>
> New syntax d#, b#, o# and h# allow for an explicit prefix
> on cell values to specify their base.  Eg: <d# 123>
>
> Signed-off-by: Jon Loeliger <jdl@freescale.com>
>
> ---

What are people's thoughts on supporting '0x' and '0X' for hex?

- k

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

* RE: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 17:13 [DTC PATCH] Add support for decimal, octal and binary based cell values Jon Loeliger
  2007-02-15 17:30 ` Kumar Gala
@ 2007-02-15 17:45 ` Yoder Stuart-B08248
  2007-02-15 18:00   ` Olof Johansson
  2007-02-15 18:05   ` Jon Loeliger
  2007-02-15 22:19 ` David Gibson
  2007-02-15 22:33 ` Dan Malek
  3 siblings, 2 replies; 23+ messages in thread
From: Yoder Stuart-B08248 @ 2007-02-15 17:45 UTC (permalink / raw)
  To: Jon Loeliger, linuxppc-dev


I like to see no space between the d#, h#, etc and the
numeric value.

Does anyone see a good reason to keep whitespace there?

Stuart

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

* RE: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 17:30 ` Kumar Gala
@ 2007-02-15 17:49   ` Yoder Stuart-B08248
  2007-02-15 18:41     ` Kumar Gala
  0 siblings, 1 reply; 23+ messages in thread
From: Yoder Stuart-B08248 @ 2007-02-15 17:49 UTC (permalink / raw)
  To: Kumar Gala, Jon Loeliger; +Cc: linuxppc-dev

=20

> -----Original Message-----
> From: linuxppc-dev-bounces+b08248=3Dfreescale.com@ozlabs.org=20
> [mailto:linuxppc-dev-bounces+b08248=3Dfreescale.com@ozlabs.org]=20
> On Behalf Of Kumar Gala
[snip]
> > New syntax d#, b#, o# and h# allow for an explicit prefix
> > on cell values to specify their base.  Eg: <d# 123>
> >
> > Signed-off-by: Jon Loeliger <jdl@freescale.com>
> >
> > ---
>=20
> What are people's thoughts on supporting '0x' and '0X' for hex?

Are you saying allow d#1234, h#5678, and 0x5678?  Or use 0x instead
of h#?

Stuart

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 17:45 ` Yoder Stuart-B08248
@ 2007-02-15 18:00   ` Olof Johansson
  2007-02-15 18:00     ` Yoder Stuart-B08248
  2007-02-15 18:05   ` Jon Loeliger
  1 sibling, 1 reply; 23+ messages in thread
From: Olof Johansson @ 2007-02-15 18:00 UTC (permalink / raw)
  To: Yoder Stuart-B08248; +Cc: linuxppc-dev, Jon Loeliger

On Thu, Feb 15, 2007 at 10:45:54AM -0700, Yoder Stuart-B08248 wrote:
> 
> I like to see no space between the d#, h#, etc and the
> numeric value.
> 
> Does anyone see a good reason to keep whitespace there?

Does it really matter what color the bike shed is?

http://www.unixguide.net/freebsd/faq/16.19.shtml

(I've seen 0x<hex> <decimal> or 0d<decimal> and 0b<binary> been used
sometimes and work well, but I really don't care if it's what the dtc
uses or not.)

-Olof

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

* RE: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 18:00   ` Olof Johansson
@ 2007-02-15 18:00     ` Yoder Stuart-B08248
  2007-02-15 18:02       ` Scott Wood
  0 siblings, 1 reply; 23+ messages in thread
From: Yoder Stuart-B08248 @ 2007-02-15 18:00 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, Jon Loeliger

=20

> -----Original Message-----
> From: Olof Johansson [mailto:olof@lixom.net]=20
> Sent: Thursday, February 15, 2007 12:00 PM
> To: Yoder Stuart-B08248
> Cc: Jon Loeliger; linuxppc-dev@ozlabs.org
> Subject: Re: [DTC PATCH] Add support for decimal, octal and=20
> binary based cell values.
>=20
> On Thu, Feb 15, 2007 at 10:45:54AM -0700, Yoder Stuart-B08248 wrote:
> >=20
> > I like to see no space between the d#, h#, etc and the
> > numeric value.
> >=20
> > Does anyone see a good reason to keep whitespace there?
>=20
> Does it really matter what color the bike shed is?

In this case I think it does matter (a little :)).  If
you represent a number as <#h5678> it's clear that the
#h and 5678 are related.

If you represent it as <#h 5678> the relation between
the two is not as clear-- of course once you read the=20
spec you figure it out.

It's not a huge deal, but while we're adding a feature
to dtc why not make the syntax as clear as we can?

Stuart

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 18:00     ` Yoder Stuart-B08248
@ 2007-02-15 18:02       ` Scott Wood
  0 siblings, 0 replies; 23+ messages in thread
From: Scott Wood @ 2007-02-15 18:02 UTC (permalink / raw)
  To: Yoder Stuart-B08248; +Cc: Olof Johansson, linuxppc-dev, Jon Loeliger

Yoder Stuart-B08248 wrote:
> In this case I think it does matter (a little :)).  If
> you represent a number as <#h5678> it's clear that the
> #h and 5678 are related.
> 
> If you represent it as <#h 5678> the relation between
> the two is not as clear-- of course once you read the 
> spec you figure it out.
> 
> It's not a huge deal, but while we're adding a feature
> to dtc why not make the syntax as clear as we can?

It should be noted that the patch Jon posted should accept it either 
with or without the space.

-Scott

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 17:45 ` Yoder Stuart-B08248
  2007-02-15 18:00   ` Olof Johansson
@ 2007-02-15 18:05   ` Jon Loeliger
  2007-02-15 18:10     ` Yoder Stuart-B08248
  2007-02-15 21:44     ` Benjamin Herrenschmidt
  1 sibling, 2 replies; 23+ messages in thread
From: Jon Loeliger @ 2007-02-15 18:05 UTC (permalink / raw)
  To: Yoder Stuart-B08248; +Cc: linuxppc-dev

So, like, the other day "Yoder Stuart-B08248" mumbled:
> 
> I like to see no space between the d#, h#, etc and the
> numeric value.

So, that's one of the really nice things about parsers.
Just do this, then:

    d23 = <d#23>;		// Just like <d# 23>!

The real question, though, is this:  MUST the space between
'd#' and '23' be removed so that it is all one token?
I suppose I could repaint that shed if needed, but I 
don't think it is.

jdl

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

* RE: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 18:05   ` Jon Loeliger
@ 2007-02-15 18:10     ` Yoder Stuart-B08248
  2007-02-15 21:44     ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 23+ messages in thread
From: Yoder Stuart-B08248 @ 2007-02-15 18:10 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev

=20

> -----Original Message-----
> From: Jon Loeliger [mailto:jdl@jdl.com]=20
> Sent: Thursday, February 15, 2007 12:05 PM
> To: Yoder Stuart-B08248
> Cc: linuxppc-dev@ozlabs.org
> Subject: Re: [DTC PATCH] Add support for decimal,octal and=20
> binary based cell values.=20
>=20
> So, like, the other day "Yoder Stuart-B08248" mumbled:
> >=20
> > I like to see no space between the d#, h#, etc and the
> > numeric value.
>=20
> So, that's one of the really nice things about parsers.
> Just do this, then:
>=20
>     d23 =3D <d#23>;		// Just like <d# 23>!
>=20
> The real question, though, is this:  MUST the space between
> 'd#' and '23' be removed so that it is all one token?

As long as the space is not required, it's cool.

Stuart

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 17:49   ` Yoder Stuart-B08248
@ 2007-02-15 18:41     ` Kumar Gala
  2007-02-15 22:14       ` David Gibson
  0 siblings, 1 reply; 23+ messages in thread
From: Kumar Gala @ 2007-02-15 18:41 UTC (permalink / raw)
  To: Yoder Stuart-B08248; +Cc: linuxppc-dev, Jon Loeliger


On Feb 15, 2007, at 11:49 AM, Yoder Stuart-B08248 wrote:

>
>
>> -----Original Message-----
>> From: linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org
>> [mailto:linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org]
>> On Behalf Of Kumar Gala
> [snip]
>>> New syntax d#, b#, o# and h# allow for an explicit prefix
>>> on cell values to specify their base.  Eg: <d# 123>
>>>
>>> Signed-off-by: Jon Loeliger <jdl@freescale.com>
>>>
>>> ---
>>
>> What are people's thoughts on supporting '0x' and '0X' for hex?
>
> Are you saying allow d#1234, h#5678, and 0x5678?  Or use 0x instead
> of h#?

I'm saying in addition to supporting the d#, h# notation.

The reason I'm suggesting support '0x' is its pretty natural from C  
and I know there have been a number of times when I forget that all  
int constants in .dts are hex.

- k

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 18:05   ` Jon Loeliger
  2007-02-15 18:10     ` Yoder Stuart-B08248
@ 2007-02-15 21:44     ` Benjamin Herrenschmidt
  2007-02-15 22:12       ` David Gibson
  2007-02-15 22:59       ` Jon Loeliger
  1 sibling, 2 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-15 21:44 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev, Yoder Stuart-B08248

On Thu, 2007-02-15 at 12:05 -0600, Jon Loeliger wrote:
> So, like, the other day "Yoder Stuart-B08248" mumbled:
> > 
> > I like to see no space between the d#, h#, etc and the
> > numeric value.
> 
> So, that's one of the really nice things about parsers.
> Just do this, then:
> 
>     d23 = <d#23>;		// Just like <d# 23>!
> 
> The real question, though, is this:  MUST the space between
> 'd#' and '23' be removed so that it is all one token?
> I suppose I could repaint that shed if needed, but I 
> don't think it is.

Also, the question is, will the d# affect only the next number or all
the numbers until the next ">" ?

Ben.

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 21:44     ` Benjamin Herrenschmidt
@ 2007-02-15 22:12       ` David Gibson
  2007-02-15 22:59       ` Jon Loeliger
  1 sibling, 0 replies; 23+ messages in thread
From: David Gibson @ 2007-02-15 22:12 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Jon Loeliger, Yoder Stuart-B08248

On Fri, Feb 16, 2007 at 08:44:43AM +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2007-02-15 at 12:05 -0600, Jon Loeliger wrote:
> > So, like, the other day "Yoder Stuart-B08248" mumbled:
> > > 
> > > I like to see no space between the d#, h#, etc and the
> > > numeric value.
> > 
> > So, that's one of the really nice things about parsers.
> > Just do this, then:
> > 
> >     d23 = <d#23>;		// Just like <d# 23>!
> > 
> > The real question, though, is this:  MUST the space between
> > 'd#' and '23' be removed so that it is all one token?
> > I suppose I could repaint that shed if needed, but I 
> > don't think it is.
> 
> Also, the question is, will the d# affect only the next number or all
> the numbers until the next ">" ?

Only the next.

-- 
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] 23+ messages in thread

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 18:41     ` Kumar Gala
@ 2007-02-15 22:14       ` David Gibson
  2007-02-16  0:04         ` Kumar Gala
  0 siblings, 1 reply; 23+ messages in thread
From: David Gibson @ 2007-02-15 22:14 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Jon Loeliger, Yoder Stuart-B08248

On Thu, Feb 15, 2007 at 12:41:50PM -0600, Kumar Gala wrote:
> 
> On Feb 15, 2007, at 11:49 AM, Yoder Stuart-B08248 wrote:
> 
> >
> >
> >> -----Original Message-----
> >> From: linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org
> >> [mailto:linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org]
> >> On Behalf Of Kumar Gala
> > [snip]
> >>> New syntax d#, b#, o# and h# allow for an explicit prefix
> >>> on cell values to specify their base.  Eg: <d# 123>
> >>>
> >>> Signed-off-by: Jon Loeliger <jdl@freescale.com>
> >>>
> >>> ---
> >>
> >> What are people's thoughts on supporting '0x' and '0X' for hex?
> >
> > Are you saying allow d#1234, h#5678, and 0x5678?  Or use 0x instead
> > of h#?
> 
> I'm saying in addition to supporting the d#, h# notation.
> 
> The reason I'm suggesting support '0x' is its pretty natural from C  
> and I know there have been a number of times when I forget that all  
> int constants in .dts are hex.

I'd prefer not to do this.  I agree it would be nice in some ways, but
I'm worried that if people see 0x all over the place, they'll assume
that things without an 0x are decimal, which they can't be for
compatibility.

-- 
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] 23+ messages in thread

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 17:13 [DTC PATCH] Add support for decimal, octal and binary based cell values Jon Loeliger
  2007-02-15 17:30 ` Kumar Gala
  2007-02-15 17:45 ` Yoder Stuart-B08248
@ 2007-02-15 22:19 ` David Gibson
  2007-02-15 23:43   ` Jon Loeliger
  2007-02-15 22:33 ` Dan Malek
  3 siblings, 1 reply; 23+ messages in thread
From: David Gibson @ 2007-02-15 22:19 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev

On Thu, Feb 15, 2007 at 11:13:05AM -0600, Jon Loeliger wrote:
> 
> New syntax d#, b#, o# and h# allow for an explicit prefix
> on cell values to specify their base.  Eg: <d# 123>
> 
> Signed-off-by: Jon Loeliger <jdl@freescale.com>
[snip]
> 
> ---
> 
> Beginnings of test cases in the next patch.
> Don't stress the yylloc too much.  We'll eventually
> work to make that better and more general later.
> 
> 
>  data.c       |   21 +++++++++++++++++++++
>  dtc-lexer.l  |   21 +++++++++++++++------
>  dtc-parser.y |   16 ++++++++++++++--
>  dtc.h        |    1 +
>  4 files changed, 51 insertions(+), 8 deletions(-)
> 
> diff --git a/data.c b/data.c
> index 1907a1a..c6c2350 100644
> --- a/data.c
> +++ b/data.c
> @@ -19,6 +19,7 @@
>   */
>  
>  #include "dtc.h"
> +#include "dtc-parser.tab.h"
>  
>  void fixup_free(struct fixup *f)
>  {
> @@ -224,6 +225,26 @@ struct data data_merge(struct data d1, struct data d2)
>  	return d;
>  }
>  
> +/*
> + * Convert a string representation of a numberic cell
> + * in the given base into a cell.
> + */
> +cell_t data_convert_cell(char *s, unsigned int base)

I'd prefer a different name for this - and possibly it should go in a
different file.  The data_* prefix should be for functions that
actually manipulate struct data objects.

> +{
> +	cell_t c;
> +	extern YYLTYPE yylloc;
> +
> +	c = strtoul(s, NULL, base);
> +	if (errno == EINVAL || errno == ERANGE) {
> +		fprintf(stderr,
> +			"Line %d: Invalid cell value '%s'; %d assumed\n",
> +			yylloc.first_line, s, c);
> +	}

And I'd really prefer to keep the yyblah junk confined to the parser
code.  I think it would be better to move this function into
dtc-parser.y

Otherwise looks pretty good.

-- 
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] 23+ messages in thread

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 17:13 [DTC PATCH] Add support for decimal, octal and binary based cell values Jon Loeliger
                   ` (2 preceding siblings ...)
  2007-02-15 22:19 ` David Gibson
@ 2007-02-15 22:33 ` Dan Malek
  2007-02-15 22:57   ` David Gibson
  2007-02-16 10:21   ` Segher Boessenkool
  3 siblings, 2 replies; 23+ messages in thread
From: Dan Malek @ 2007-02-15 22:33 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev list


On Feb 15, 2007, at 9:13 AM, Jon Loeliger wrote:

> New syntax d#, b#, o# and h# allow for an explicit prefix
> on cell values to specify their base.  Eg: <d# 123>

Why do we need yet another syntax?  Everyone
else, including most silicon documentation, uses
the standard "C" syntax 0x for hex, 0 for octal, and
nothing for decimal.  If really needed binary, we
could us the '0b'.  Of the few dts files I've done,
anything to make this easier, rather than inventing
something new, would be appreciated.

Thanks.

	-- Dan

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 22:33 ` Dan Malek
@ 2007-02-15 22:57   ` David Gibson
  2007-02-15 23:37     ` Dan Malek
  2007-02-16 10:21   ` Segher Boessenkool
  1 sibling, 1 reply; 23+ messages in thread
From: David Gibson @ 2007-02-15 22:57 UTC (permalink / raw)
  To: Dan Malek; +Cc: linuxppc-dev list, Jon Loeliger

On Thu, Feb 15, 2007 at 02:33:47PM -0800, Dan Malek wrote:
> 
> On Feb 15, 2007, at 9:13 AM, Jon Loeliger wrote:
> 
> > New syntax d#, b#, o# and h# allow for an explicit prefix
> > on cell values to specify their base.  Eg: <d# 123>
> 
> Why do we need yet another syntax?  Everyone
> else, including most silicon documentation, uses
> the standard "C" syntax 0x for hex, 0 for octal, and
> nothing for decimal.  If really needed binary, we
> could us the '0b'.  Of the few dts files I've done,
> anything to make this easier, rather than inventing
> something new, would be appreciated.

Yes, but hex-by-default is already implemented and out there.  We
can't change it without breaking compatibility horribly.

-- 
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] 23+ messages in thread

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 21:44     ` Benjamin Herrenschmidt
  2007-02-15 22:12       ` David Gibson
@ 2007-02-15 22:59       ` Jon Loeliger
  1 sibling, 0 replies; 23+ messages in thread
From: Jon Loeliger @ 2007-02-15 22:59 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev

So, like, the other day Benjamin Herrenschmidt mumbled:
> 
> Also, the question is, will the d# affect only the next number or all
> the numbers until the next ">" ?

Just the next one.

jdl

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 22:57   ` David Gibson
@ 2007-02-15 23:37     ` Dan Malek
  2007-02-16  0:09       ` David Gibson
  0 siblings, 1 reply; 23+ messages in thread
From: Dan Malek @ 2007-02-15 23:37 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev list, Jon Loeliger


On Feb 15, 2007, at 2:57 PM, David Gibson wrote:

> Yes, but hex-by-default is already implemented and out there.  We
> can't change it without breaking compatibility horribly.

Compatibility with what?  The few dts files that exist
that are still all changing frequently due to other
tool modifications?  I'd prefer to change them now,
rather than propagate this new syntax.

Thanks.

	-- Dan

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 22:19 ` David Gibson
@ 2007-02-15 23:43   ` Jon Loeliger
  0 siblings, 0 replies; 23+ messages in thread
From: Jon Loeliger @ 2007-02-15 23:43 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

So, like, the other day David Gibson mumbled:
> 
> I'd prefer a different name for this - and possibly it should go in a
> different file.  The data_* prefix should be for functions that
> actually manipulate struct data objects.

...

> And I'd really prefer to keep the yyblah junk confined to the parser
> code.  I think it would be better to move this function into
> dtc-parser.y

OK.  Yeah, that's sort of what I was alluding to with
the "don't stress the yylval gunk".  But OK, in any event
I'll move this function to the parser file or so.

> Otherwise looks pretty good.

Thanks.

jdl

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 22:14       ` David Gibson
@ 2007-02-16  0:04         ` Kumar Gala
  2007-02-16 10:23           ` Segher Boessenkool
  0 siblings, 1 reply; 23+ messages in thread
From: Kumar Gala @ 2007-02-16  0:04 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev, Jon Loeliger, Yoder Stuart-B08248


On Feb 15, 2007, at 4:14 PM, David Gibson wrote:

> On Thu, Feb 15, 2007 at 12:41:50PM -0600, Kumar Gala wrote:
>>
>> On Feb 15, 2007, at 11:49 AM, Yoder Stuart-B08248 wrote:
>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org
>>>> [mailto:linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org]
>>>> On Behalf Of Kumar Gala
>>> [snip]
>>>>> New syntax d#, b#, o# and h# allow for an explicit prefix
>>>>> on cell values to specify their base.  Eg: <d# 123>
>>>>>
>>>>> Signed-off-by: Jon Loeliger <jdl@freescale.com>
>>>>>
>>>>> ---
>>>>
>>>> What are people's thoughts on supporting '0x' and '0X' for hex?
>>>
>>> Are you saying allow d#1234, h#5678, and 0x5678?  Or use 0x instead
>>> of h#?
>>
>> I'm saying in addition to supporting the d#, h# notation.
>>
>> The reason I'm suggesting support '0x' is its pretty natural from C
>> and I know there have been a number of times when I forget that all
>> int constants in .dts are hex.
>
> I'd prefer not to do this.  I agree it would be nice in some ways, but
> I'm worried that if people see 0x all over the place, they'll assume
> that things without an 0x are decimal, which they can't be for
> compatibility.

People don't know what to assume, I know I've made a number of errors  
when I forget that all numbers where hex.

I think we should change dtc to follow standard C conventions and do  
it now rather than later.

We've already introduced dtc version compatibilities issues.  I agree  
with Dan that we should fix this now while there are a small handful  
of .dts in existence and we can provide a compat mode flag that  
treats non-prefixed numbers as hex instead of decimal.

(in theory with that we can use dtc to convert old .dts into new .dts)

- k

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 23:37     ` Dan Malek
@ 2007-02-16  0:09       ` David Gibson
  0 siblings, 0 replies; 23+ messages in thread
From: David Gibson @ 2007-02-16  0:09 UTC (permalink / raw)
  To: Dan Malek; +Cc: linuxppc-dev list, Jon Loeliger

On Thu, Feb 15, 2007 at 03:37:36PM -0800, Dan Malek wrote:
> 
> On Feb 15, 2007, at 2:57 PM, David Gibson wrote:
> 
> > Yes, but hex-by-default is already implemented and out there.  We
> > can't change it without breaking compatibility horribly.
> 
> Compatibility with what?  The few dts files that exist
> that are still all changing frequently due to other
> tool modifications?  I'd prefer to change them now,
> rather than propagate this new syntax.

Nonetheless there are enough dts files out there - some of them within
vendors where I can't see them - that I absolutely do not want to
change something som fundamental in the format.

I have considered defining a "new-style" cell format, with delimiters
different from < > that uses C style literals.  But that idea's fairly
ugly too.

-- 
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] 23+ messages in thread

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-15 22:33 ` Dan Malek
  2007-02-15 22:57   ` David Gibson
@ 2007-02-16 10:21   ` Segher Boessenkool
  1 sibling, 0 replies; 23+ messages in thread
From: Segher Boessenkool @ 2007-02-16 10:21 UTC (permalink / raw)
  To: Dan Malek; +Cc: linuxppc-dev list, Jon Loeliger

> Why do we need yet another syntax?  Everyone
> else, including most silicon documentation, uses
> the standard "C" syntax 0x for hex, 0 for octal, and
> nothing for decimal.

[Completely off-topic]

You're joking, right?  Many docs use 1234h for hex and
1011b for binary; or $1234 for hex and %1011 for binary;
or x'1234 and b'1011; or 1234_{(16)} and 1011_{(2)} (TeX
notation -- base as decimal in a parenthesised subscript);
etc. etc. etc.

Almost all computer languages use something more sane
than the C-family stuff too (esp. the dreaded "0 is
octal" thing is not exactly great).

Anyway, really off-topic :-)


Segher

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

* Re: [DTC PATCH] Add support for decimal, octal and binary based cell values.
  2007-02-16  0:04         ` Kumar Gala
@ 2007-02-16 10:23           ` Segher Boessenkool
  0 siblings, 0 replies; 23+ messages in thread
From: Segher Boessenkool @ 2007-02-16 10:23 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Jon Loeliger, Yoder Stuart-B08248, David Gibson

> I think we should change dtc to follow standard C conventions and do
> it now rather than later.
>
> We've already introduced dtc version compatibilities issues.  I agree
> with Dan that we should fix this now while there are a small handful
> of .dts in existence and we can provide a compat mode flag that
> treats non-prefixed numbers as hex instead of decimal.
>
> (in theory with that we can use dtc to convert old .dts into new .dts)

May I suggest every DTS file start with a version statement?
That way, you can change its format easily whenever you
want.  This would be version of the source language, not the
same thing as version of the generated blob.


Segher

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

end of thread, other threads:[~2007-02-16 10:24 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-15 17:13 [DTC PATCH] Add support for decimal, octal and binary based cell values Jon Loeliger
2007-02-15 17:30 ` Kumar Gala
2007-02-15 17:49   ` Yoder Stuart-B08248
2007-02-15 18:41     ` Kumar Gala
2007-02-15 22:14       ` David Gibson
2007-02-16  0:04         ` Kumar Gala
2007-02-16 10:23           ` Segher Boessenkool
2007-02-15 17:45 ` Yoder Stuart-B08248
2007-02-15 18:00   ` Olof Johansson
2007-02-15 18:00     ` Yoder Stuart-B08248
2007-02-15 18:02       ` Scott Wood
2007-02-15 18:05   ` Jon Loeliger
2007-02-15 18:10     ` Yoder Stuart-B08248
2007-02-15 21:44     ` Benjamin Herrenschmidt
2007-02-15 22:12       ` David Gibson
2007-02-15 22:59       ` Jon Loeliger
2007-02-15 22:19 ` David Gibson
2007-02-15 23:43   ` Jon Loeliger
2007-02-15 22:33 ` Dan Malek
2007-02-15 22:57   ` David Gibson
2007-02-15 23:37     ` Dan Malek
2007-02-16  0:09       ` David Gibson
2007-02-16 10:21   ` Segher Boessenkool

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.