aboutsummaryrefslogtreecommitdiff
path: root/dtc-parser.y
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@arm.com>2018-05-15 17:42:54 -0500
committerDavid Gibson <david@gibson.dropbear.id.au>2018-06-04 18:50:07 +1000
commit44d3efedc81618e2d51ebbc2305ff020d1107988 (patch)
tree111fb59d82b1fefeddeb74e39b0b233338fff487 /dtc-parser.y
parentf0be81bd8de093e1c775e62b92449c9773e7f732 (diff)
downloaddtc-44d3efedc81618e2d51ebbc2305ff020d1107988.zip
dtc-44d3efedc81618e2d51ebbc2305ff020d1107988.tar.gz
dtc-44d3efedc81618e2d51ebbc2305ff020d1107988.tar.bz2
Preserve datatype information when parsing dts
The current code throws away all the data type and grouping information when parsing the DTS source file, which makes it difficult to reconstruct the data format when emitting a format that can express data types (ie. dts and yaml). Use the marker structure to mark the beginning of each integer array block (<> and []), and the datatype contained in each (8, 16, 32 & 64 bit widths). Signed-off-by: Grant Likely <grant.likely@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> [robh: s/MARKER_/TYPE_/] Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r--dtc-parser.y15
1 files changed, 10 insertions, 5 deletions
diff --git a/dtc-parser.y b/dtc-parser.y
index 011a5b2..815481a 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -340,22 +340,27 @@ arrayprefix:
DT_BITS DT_LITERAL '<'
{
unsigned long long bits;
+ enum markertype type = TYPE_UINT32;
bits = $2;
- if ((bits != 8) && (bits != 16) &&
- (bits != 32) && (bits != 64)) {
+ switch (bits) {
+ case 8: type = TYPE_UINT8; break;
+ case 16: type = TYPE_UINT16; break;
+ case 32: type = TYPE_UINT32; break;
+ case 64: type = TYPE_UINT64; break;
+ default:
ERROR(&@2, "Array elements must be"
" 8, 16, 32 or 64-bits");
bits = 32;
}
- $$.data = empty_data;
+ $$.data = data_add_marker(empty_data, type, NULL);
$$.bits = bits;
}
| '<'
{
- $$.data = empty_data;
+ $$.data = data_add_marker(empty_data, TYPE_UINT32, NULL);
$$.bits = 32;
}
| arrayprefix integer_prim
@@ -499,7 +504,7 @@ integer_unary:
bytestring:
/* empty */
{
- $$ = empty_data;
+ $$ = data_add_marker(empty_data, TYPE_UINT8, NULL);
}
| bytestring DT_BYTE
{