Skip to content

Commit a55d142

Browse files
brooniectmarinas
authored andcommitted
arm64/sysreg: Allow enumerations to be declared as signed or unsigned
Many of our enumerations follow a standard scheme where the values can be treated as signed however there are some where the value must be treated as signed and others that are simple enumerations where there is no clear ordering to the values. Provide new field types SignedEnum and UnsignedEnum which allows the signedness to be specified in the sysreg definition and emit a REG_FIELD_SIGNED define for these which is a boolean corresponding to our current FTR_UNSIGNED and FTR_SIGNED macros. Existing Enums will need to be converted, since these do not have a define generated anyone wishing to use the sign of one of these will need to explicitly annotate that field so nothing should start going wrong by default. Acked-by: Mark Rutland <[email protected]> Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 9b074bb commit a55d142

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

arch/arm64/tools/gen-sysreg.awk

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ function define_field(reg, field, msb, lsb) {
4444
define(reg "_" field "_WIDTH", msb - lsb + 1)
4545
}
4646

47+
# Print a field _SIGNED definition for a field
48+
function define_field_sign(reg, field, sign) {
49+
define(reg "_" field "_SIGNED", sign)
50+
}
51+
4752
# Parse a "<msb>[:<lsb>]" string into the global variables @msb and @lsb
4853
function parse_bitdef(reg, field, bitdef, _bits)
4954
{
@@ -233,6 +238,30 @@ END {
233238
next
234239
}
235240

241+
/^SignedEnum/ {
242+
change_block("Enum<", "Sysreg", "Enum")
243+
expect_fields(3)
244+
field = $3
245+
parse_bitdef(reg, field, $2)
246+
247+
define_field(reg, field, msb, lsb)
248+
define_field_sign(reg, field, "true")
249+
250+
next
251+
}
252+
253+
/^UnsignedEnum/ {
254+
change_block("Enum<", "Sysreg", "Enum")
255+
expect_fields(3)
256+
field = $3
257+
parse_bitdef(reg, field, $2)
258+
259+
define_field(reg, field, msb, lsb)
260+
define_field_sign(reg, field, "false")
261+
262+
next
263+
}
264+
236265
/^Enum/ {
237266
change_block("Enum", "Sysreg", "Enum")
238267
expect_fields(3)

0 commit comments

Comments
 (0)