Browse Source

asm: Use assembler macros instead of cpp macros

tests/trees.S is a weird thing: a portable aseembler file, used to produce
a specific binary output.  Currently it uses CPP macros quite heavily to
construct the dtbs we want (including some partial and broken trees).

Using cpp has the side effect that we need to use ; separators between
instructions (or, rather, pseudo-ops), because cpp won't expand newlines.
However, it turns out that while ; is a suitable separator on most
targets, it doesn't work for all of them (e.g. HP PA-RISC).

Switch to using the assembler's inbuilt macros rather than CPP, so that we
can use genuine newlines.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
David Gibson 3 years ago
parent
commit
d24cc189dc
  1. 401
      tests/trees.S

401
tests/trees.S

@ -1,174 +1,187 @@
#include <fdt.h> #include <fdt.h>
#include "testdata.h" #include "testdata.h"


#define FDTLONG(val) \ .macro fdtlong val
.byte ((val) >> 24) & 0xff ; \ .byte ((\val) >> 24) & 0xff
.byte ((val) >> 16) & 0xff ; \ .byte ((\val) >> 16) & 0xff
.byte ((val) >> 8) & 0xff ; \ .byte ((\val) >> 8) & 0xff
.byte (val) & 0xff ; .byte (\val) & 0xff

.endm
#define TREE_HDR(tree) \
.balign 8 ; \ .macro treehdr tree
.globl tree ; \ .balign 8
tree: \ .globl \tree
FDTLONG(FDT_MAGIC) ; \ \tree :
FDTLONG(tree##_end - tree) ; \ fdtlong FDT_MAGIC
FDTLONG(tree##_struct - tree) ; \ fdtlong (\tree\()_end - \tree)
FDTLONG(tree##_strings - tree) ; \ fdtlong (\tree\()_struct - \tree)
FDTLONG(tree##_rsvmap - tree) ; \ fdtlong (\tree\()_strings - \tree)
FDTLONG(0x11) ; \ fdtlong (\tree\()_rsvmap - \tree)
FDTLONG(0x10) ; \ fdtlong 0x11
FDTLONG(0) ; \ fdtlong 0x10
FDTLONG(tree##_strings_end - tree##_strings) ; \ fdtlong 0
FDTLONG(tree##_struct_end - tree##_struct) ; fdtlong (\tree\()_strings_end - \tree\()_strings)

fdtlong (\tree\()_struct_end - \tree\()_struct)
#define RSVMAP_ENTRY(addrh, addrl, lenh, lenl) \ .endm
FDTLONG(addrh) ; \
FDTLONG(addrl) ; \ .macro rsvmape addrh, addrl, lenh, lenl
FDTLONG(lenh) ; \ fdtlong \addrh
FDTLONG(lenl) fdtlong \addrl

fdtlong \lenh
#define EMPTY_RSVMAP(tree) \ fdtlong \lenl
.balign 8 ; \ .endm
tree##_rsvmap: ; \
RSVMAP_ENTRY(0, 0, 0, 0) \ .macro empty_rsvmap tree
tree##_rsvmap_end: ; .balign 8

\tree\()_rsvmap:
#define PROPHDR(tree, name, len) \ rsvmape 0, 0, 0, 0
FDTLONG(FDT_PROP) ; \ \tree\()_rsvmap_end:
FDTLONG(len) ; \ .endm
FDTLONG(tree##_##name - tree##_strings) ;

.macro prophdr tree, name, len
#define PROP_EMPTY(tree, name) \ fdtlong FDT_PROP
PROPHDR(tree, name, 0) ; fdtlong \len

fdtlong (\tree\()_\name - \tree\()_strings)
#define PROP_INT(tree, name, val) \ .endm
PROPHDR(tree, name, 4) \
FDTLONG(val) ; .macro propnil tree, name

prophdr \tree, \name, 0
#define PROP_INT64(tree, name, valh, vall) \ .endm
PROPHDR(tree, name, 8) \
FDTLONG(valh) ; \ .macro propu32 tree, name, val
FDTLONG(vall) ; prophdr \tree, \name, 4

fdtlong \val
#define PROP_STR(tree, name, str) \ .endm
PROPHDR(tree, name, 55f - 54f) \
54: \ .macro propu64 tree, name, valh, vall
.asciz str ; \ prophdr \tree, \name, 8
55: \ fdtlong \valh
.balign 4 ; fdtlong \vall

.endm
#define BEGIN_NODE(name) \
FDTLONG(FDT_BEGIN_NODE) ; \ .macro propstr tree, name, str:vararg
.asciz name ; \ prophdr \tree, \name, (55f - 54f)
.balign 4 ; 54:

.asciz \str
#define END_NODE \ 55:
FDTLONG(FDT_END_NODE) ; .balign 4

.endm
#define STRING(tree, name, str) \
tree##_##name: ; \ .macro beginn name:vararg
.asciz str ; fdtlong FDT_BEGIN_NODE
.asciz \name
.balign 4
.endm

.macro endn
fdtlong FDT_END_NODE
.endm

.macro string tree, name, str:vararg
\tree\()_\name :
.asciz \str
.endm



.data .data


TREE_HDR(test_tree1) treehdr test_tree1


.balign 8 .balign 8
test_tree1_rsvmap: test_tree1_rsvmap:
RSVMAP_ENTRY(TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L) rsvmape TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L
RSVMAP_ENTRY(TEST_ADDR_2H, TEST_ADDR_2L, TEST_SIZE_2H, TEST_SIZE_2L) rsvmape TEST_ADDR_2H, TEST_ADDR_2L, TEST_SIZE_2H, TEST_SIZE_2L
RSVMAP_ENTRY(0, 0, 0, 0) rsvmape 0, 0, 0, 0
test_tree1_rsvmap_end: test_tree1_rsvmap_end:


test_tree1_struct: test_tree1_struct:
BEGIN_NODE("") beginn ""
PROP_STR(test_tree1, compatible, "test_tree1") propstr test_tree1, compatible, "test_tree1"
PROP_INT(test_tree1, prop_int, TEST_VALUE_1) propu32 test_tree1, prop_int, TEST_VALUE_1
PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1H, TEST_VALUE64_1L) propu64 test_tree1, prop_int64, TEST_VALUE64_1H, TEST_VALUE64_1L
PROP_STR(test_tree1, prop_str, TEST_STRING_1) propstr test_tree1, prop_str, TEST_STRING_1
PROP_INT(test_tree1, address_cells, 1) propu32 test_tree1, address_cells, 1
PROP_INT(test_tree1, size_cells, 0) propu32 test_tree1, size_cells, 0


BEGIN_NODE("subnode@1") beginn "subnode@1"
PROP_STR(test_tree1, compatible, "subnode1") propstr test_tree1, compatible, "subnode1"
PROP_INT(test_tree1, reg, 1) propu32 test_tree1, reg, 1
PROP_INT(test_tree1, prop_int, TEST_VALUE_1) propu32 test_tree1, prop_int, TEST_VALUE_1


BEGIN_NODE("subsubnode") beginn "subsubnode"
PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode") propstr test_tree1, compatible, "subsubnode1\0subsubnode"
PROP_STR(test_tree1, placeholder, "this is a placeholder string\0string2") propstr test_tree1, placeholder, "this is a placeholder string\0string2"
PROP_INT(test_tree1, prop_int, TEST_VALUE_1) propu32 test_tree1, prop_int, TEST_VALUE_1
END_NODE endn


BEGIN_NODE("ss1") beginn "ss1"
END_NODE endn


END_NODE endn


BEGIN_NODE("subnode@2") beginn "subnode@2"
PROP_INT(test_tree1, reg, 2) propu32 test_tree1, reg, 2
PROP_INT(test_tree1, linux_phandle, PHANDLE_1) propu32 test_tree1, linux_phandle, PHANDLE_1
PROP_INT(test_tree1, prop_int, TEST_VALUE_2) propu32 test_tree1, prop_int, TEST_VALUE_2
PROP_INT(test_tree1, address_cells, 1) propu32 test_tree1, address_cells, 1
PROP_INT(test_tree1, size_cells, 0) propu32 test_tree1, size_cells, 0


BEGIN_NODE("subsubnode@0") beginn "subsubnode@0"
PROP_INT(test_tree1, reg, 0) propu32 test_tree1, reg, 0
PROP_INT(test_tree1, phandle, PHANDLE_2) propu32 test_tree1, phandle, PHANDLE_2
PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode") propstr test_tree1, compatible, "subsubnode2\0subsubnode"
PROP_INT(test_tree1, prop_int, TEST_VALUE_2) propu32 test_tree1, prop_int, TEST_VALUE_2
END_NODE endn


BEGIN_NODE("ss2") beginn "ss2"
END_NODE endn


END_NODE endn


END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
test_tree1_struct_end: test_tree1_struct_end:


test_tree1_strings: test_tree1_strings:
STRING(test_tree1, compatible, "compatible") string test_tree1, compatible, "compatible"
STRING(test_tree1, prop_int, "prop-int") string test_tree1, prop_int, "prop-int"
STRING(test_tree1, prop_int64, "prop-int64") string test_tree1, prop_int64, "prop-int64"
STRING(test_tree1, prop_str, "prop-str") string test_tree1, prop_str, "prop-str"
STRING(test_tree1, linux_phandle, "linux,phandle") string test_tree1, linux_phandle, "linux,phandle"
STRING(test_tree1, phandle, "phandle") string test_tree1, phandle, "phandle"
STRING(test_tree1, reg, "reg") string test_tree1, reg, "reg"
STRING(test_tree1, placeholder, "placeholder") string test_tree1, placeholder, "placeholder"
STRING(test_tree1, address_cells, "#address-cells") string test_tree1, address_cells, "#address-cells"
STRING(test_tree1, size_cells, "#size-cells") string test_tree1, size_cells, "#size-cells"
test_tree1_strings_end: test_tree1_strings_end:
test_tree1_end: test_tree1_end:




TREE_HDR(truncated_property) treehdr truncated_property
EMPTY_RSVMAP(truncated_property) empty_rsvmap truncated_property


truncated_property_struct: truncated_property_struct:
BEGIN_NODE("") beginn ""
PROPHDR(truncated_property, prop_truncated, 4) prophdr truncated_property, prop_truncated, 4
/* Oops, no actual property data here */ /* Oops, no actual property data here */
truncated_property_struct_end: truncated_property_struct_end:


truncated_property_strings: truncated_property_strings:
STRING(truncated_property, prop_truncated, "truncated") string truncated_property, prop_truncated, "truncated"
truncated_property_strings_end: truncated_property_strings_end:


truncated_property_end: truncated_property_end:




TREE_HDR(bad_node_char) treehdr bad_node_char
EMPTY_RSVMAP(bad_node_char) empty_rsvmap bad_node_char


bad_node_char_struct: bad_node_char_struct:
BEGIN_NODE("") beginn ""
BEGIN_NODE("sub$node") beginn "sub$node"
END_NODE endn
END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
bad_node_char_struct_end: bad_node_char_struct_end:


bad_node_char_strings: bad_node_char_strings:
@ -176,15 +189,15 @@ bad_node_char_strings_end:
bad_node_char_end: bad_node_char_end:




TREE_HDR(bad_node_format) treehdr bad_node_format
EMPTY_RSVMAP(bad_node_format) empty_rsvmap bad_node_format


bad_node_format_struct: bad_node_format_struct:
BEGIN_NODE("") beginn ""
BEGIN_NODE("subnode@1@2") beginn "subnode@1@2"
END_NODE endn
END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
bad_node_format_struct_end: bad_node_format_struct_end:


bad_node_format_strings: bad_node_format_strings:
@ -192,18 +205,18 @@ bad_node_format_strings_end:
bad_node_format_end: bad_node_format_end:




TREE_HDR(bad_prop_char) treehdr bad_prop_char
EMPTY_RSVMAP(bad_prop_char) empty_rsvmap bad_prop_char


bad_prop_char_struct: bad_prop_char_struct:
BEGIN_NODE("") beginn ""
PROP_INT(bad_prop_char, prop, TEST_VALUE_1) propu32 bad_prop_char, prop, TEST_VALUE_1
END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
bad_prop_char_struct_end: bad_prop_char_struct_end:


bad_prop_char_strings: bad_prop_char_strings:
STRING(bad_prop_char, prop, "prop$erty") string bad_prop_char, prop, "prop$erty"
bad_prop_char_strings_end: bad_prop_char_strings_end:
bad_prop_char_end: bad_prop_char_end:


@ -212,46 +225,46 @@ bad_prop_char_end:
.balign 8 .balign 8
.globl ovf_size_strings .globl ovf_size_strings
ovf_size_strings: ovf_size_strings:
FDTLONG(FDT_MAGIC) fdtlong FDT_MAGIC
FDTLONG(ovf_size_strings_end - ovf_size_strings) fdtlong (ovf_size_strings_end - ovf_size_strings)
FDTLONG(ovf_size_strings_struct - ovf_size_strings) fdtlong (ovf_size_strings_struct - ovf_size_strings)
FDTLONG(ovf_size_strings_strings - ovf_size_strings) fdtlong (ovf_size_strings_strings - ovf_size_strings)
FDTLONG(ovf_size_strings_rsvmap - ovf_size_strings) fdtlong (ovf_size_strings_rsvmap - ovf_size_strings)
FDTLONG(0x11) fdtlong 0x11
FDTLONG(0x10) fdtlong 0x10
FDTLONG(0) fdtlong 0
FDTLONG(0xffffffff) fdtlong 0xffffffff
FDTLONG(ovf_size_strings_struct_end - ovf_size_strings_struct) fdtlong (ovf_size_strings_struct_end - ovf_size_strings_struct)
EMPTY_RSVMAP(ovf_size_strings) empty_rsvmap ovf_size_strings


ovf_size_strings_struct: ovf_size_strings_struct:
BEGIN_NODE("") beginn ""
PROP_INT(ovf_size_strings, bad_string, 0) propu32 ovf_size_strings, bad_string, 0
END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
ovf_size_strings_struct_end: ovf_size_strings_struct_end:


ovf_size_strings_strings: ovf_size_strings_strings:
STRING(ovf_size_strings, x, "x") string ovf_size_strings, x, "x"
ovf_size_strings_bad_string = ovf_size_strings_strings + 0x10000000 ovf_size_strings_bad_string = ovf_size_strings_strings + 0x10000000
ovf_size_strings_strings_end: ovf_size_strings_strings_end:
ovf_size_strings_end: ovf_size_strings_end:




/* truncated_string */ /* truncated_string */
TREE_HDR(truncated_string) treehdr truncated_string
EMPTY_RSVMAP(truncated_string) empty_rsvmap truncated_string


truncated_string_struct: truncated_string_struct:
BEGIN_NODE("") beginn ""
PROP_EMPTY(truncated_string, good_string) propnil truncated_string, good_string
PROP_EMPTY(truncated_string, bad_string) propnil truncated_string, bad_string
END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
truncated_string_struct_end: truncated_string_struct_end:


truncated_string_strings: truncated_string_strings:
STRING(truncated_string, good_string, "good") string truncated_string, good_string, "good"
truncated_string_bad_string: truncated_string_bad_string:
.ascii "bad" .ascii "bad"
/* NOTE: terminating \0 deliberately missing */ /* NOTE: terminating \0 deliberately missing */
@ -260,12 +273,12 @@ truncated_string_end:




/* truncated_memrsv */ /* truncated_memrsv */
TREE_HDR(truncated_memrsv) treehdr truncated_memrsv


truncated_memrsv_struct: truncated_memrsv_struct:
BEGIN_NODE("") beginn ""
END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
truncated_memrsv_struct_end: truncated_memrsv_struct_end:


truncated_memrsv_strings: truncated_memrsv_strings:
@ -273,22 +286,22 @@ truncated_memrsv_strings_end:


.balign 8 .balign 8
truncated_memrsv_rsvmap: truncated_memrsv_rsvmap:
RSVMAP_ENTRY(TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L) rsvmape TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L
truncated_memrsv_rsvmap_end: truncated_memrsv_rsvmap_end:


truncated_memrsv_end: truncated_memrsv_end:




/* two root nodes */ /* two root nodes */
TREE_HDR(two_roots) treehdr two_roots
EMPTY_RSVMAP(two_roots) empty_rsvmap two_roots


two_roots_struct: two_roots_struct:
BEGIN_NODE("") beginn ""
END_NODE endn
BEGIN_NODE("") beginn ""
END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
two_roots_struct_end: two_roots_struct_end:


two_roots_strings: two_roots_strings:
@ -298,13 +311,13 @@ two_roots_end:




/* root node with a non-empty name */ /* root node with a non-empty name */
TREE_HDR(named_root) treehdr named_root
EMPTY_RSVMAP(named_root) empty_rsvmap named_root


named_root_struct: named_root_struct:
BEGIN_NODE("fake") beginn "fake"
END_NODE endn
FDTLONG(FDT_END) fdtlong FDT_END
named_root_struct_end: named_root_struct_end:


named_root_strings: named_root_strings:

Loading…
Cancel
Save