Skip to content

Commit

Permalink
scripts: build: gen_isr: irq more than 1 byte per level
Browse files Browse the repository at this point in the history
In some architectures such as RISC-V it can be the case that
there are more than 255 interrupts per level. Additionally,
this short comming is not completely solved by simply adding
additional levels or aggrigators. This diff adds the ability
to determine how many bits are needed per level based on the
MAX_IRQ_PER_AGGRIGATOR Kconfig variable.

Signed-off-by: Joshua Lilly <jgl@meta.com>
  • Loading branch information
jgl-meta committed Aug 1, 2023
1 parent 1f39e9e commit 3a55ee7
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions scripts/build/gen_isr_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
# into 1 line which then goes into the 2nd level)
FIRST_LVL_INTERRUPTS = 0x000000FF
SECND_LVL_INTERRUPTS = 0x0000FF00
SECND_LVL_SHIFT = 8
THIRD_LVL_INTERRUPTS = 0x00FF0000
THIRD_LVL_SHIFT = 16

def debug(text):
if args.debug:
Expand Down Expand Up @@ -231,6 +233,12 @@ def getindex(irq, irq_aggregator_pos):
" Recheck interrupt configuration.")

def main():
global FIRST_LVL_INTERRUPTS
global SECND_LVL_INTERRUPTS
global SECND_LVL_SHIFT
global THIRD_LVL_INTERRUPTS
global THIRD_LVL_SHIFT

parse_args()

with open(args.kernel, "rb") as fp:
Expand All @@ -240,13 +248,26 @@ def main():
if "CONFIG_MULTI_LEVEL_INTERRUPTS" in syms:
max_irq_per = syms["CONFIG_MAX_IRQ_PER_AGGREGATOR"]

# if more than 255 interrupts are allowed by the CPU
# per level then we need to recalculate the bit masks

Check failure on line 252 in scripts/build/gen_isr_tables.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

scripts/build/gen_isr_tables.py:252 trailing whitespace
bits = max_irq_per.bit_length()
if bits > 8:
FIRST_LVL_INTERRUPTS = 0
for i in range(0, bits):
FIRST_LVL_INTERRUPTS = (FIRST_LEVEL_MASK << 1) | 1

Check failure on line 258 in scripts/build/gen_isr_tables.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

scripts/build/gen_isr_tables.py:258 trailing whitespace
if "CONFIG_2ND_LEVEL_INTERRUPTS" in syms:
num_aggregators = syms["CONFIG_NUM_2ND_LEVEL_AGGREGATORS"]
irq2_baseoffset = syms["CONFIG_2ND_LVL_ISR_TBL_OFFSET"]
list_2nd_lvl_offsets = [syms['CONFIG_2ND_LVL_INTR_{}_OFFSET'.
format(str(i).zfill(2))] for i in
range(num_aggregators)]

if bits > 8 and 2 * bits < 32:
SECND_LVL_SHIFT += (bits - SECND_LVL_SHIFT)
SECND_LVL_INTERRUPTS = FIRST_LVL_INTERRUPTS << SECND_LVL_SHIFT
else if 2 * bits >= 32:

Check failure on line 268 in scripts/build/gen_isr_tables.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

E0001

scripts/build/gen_isr_tables.py:268 Parsing failed: 'expected ':' (<unknown>, line 268)' (syntax-error)
error("MAX_IRQ_PER_AGGREGATOR is too large to have second tier interrupts.")

Check failure on line 270 in scripts/build/gen_isr_tables.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

scripts/build/gen_isr_tables.py:270 trailing whitespace
debug('2nd level offsets: {}'.format(list_2nd_lvl_offsets))

if "CONFIG_3RD_LEVEL_INTERRUPTS" in syms:
Expand All @@ -256,6 +277,12 @@ def main():
format(str(i).zfill(2))] for i in
range(num_aggregators)]

if bits > 8 and 3 * bits < 32:
THIRD_LVL_SHIFT = 2 * SECND_LVL_SHIFT
THIRD_LVL_INTERRUPTS = FIRST_LVL_INTERRUPTS << THIRD_LVL_SHIFT
else if 3 * bits >= 32:
error("MAX_IRQ_PER_AGGREGATOR is too large to have third tier interrupts.")

debug('3rd level offsets: {}'.format(list_3rd_lvl_offsets))

intlist = read_intlist(args.intlist, syms)
Expand Down Expand Up @@ -311,8 +338,8 @@ def main():
else:
# Figure out third level interrupt position
debug('IRQ = ' + hex(irq))
irq3 = (irq & THIRD_LVL_INTERRUPTS) >> 16
irq2 = (irq & SECND_LVL_INTERRUPTS) >> 8
irq3 = (irq & THIRD_LVL_INTERRUPTS) >> THIRD_LVL_SHIFT
irq2 = (irq & SECND_LVL_INTERRUPTS) >> SECND_LVL_SHIFT
irq1 = irq & FIRST_LVL_INTERRUPTS

if irq3:
Expand Down

0 comments on commit 3a55ee7

Please sign in to comment.