1/*#
2 *#Copyright 2019, Data61
3 *#Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 *#ABN 41 687 119 230.
5 *#
6 *#This software may be distributed and modified according to the terms of
7 *#the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 *#See "LICENSE_BSD2.txt" for details.
9 *#
10 *#@TAG(DATA61_BSD)
11  #*/
12
13/*- macro parse_dtb_node_reg(node) -*/
14    /*- set regs = node.get('reg') -*/
15    /*- set reg_set = [] -*/
16    /*- if regs is not none -*/
17        /*- if node.get('this_size_cells')[0] == 0 -*/
18            /*? raise(TemplateError('This hardware device has a value of 0 for #size-cells, we do not support mapping in a block of 0 bytes')) ?*/
19        /*- endif -*/
20
21        /*- set num_address_cells = node.get('this_address_cells')[0] -*/
22        /*- set num_size_cells = node.get('this_size_cells')[0] -*/
23
24        /*- set reg_entry_size = num_address_cells + num_size_cells -*/
25        /*- set num_regs = len(regs) // reg_entry_size -*/
26        /*- for i in range(0, num_regs) -*/
27
28            /*- set index = i -*/
29
30            /*# Set a temporary namespace to bypass scoping #*/
31            /*- set temp_ns = namespace(paddr=0, size=0) -*/
32            /*- for j in range(0, num_address_cells) -*/
33                /*# Extract the paddr and size, read back to front, the register address and size #*/
34                /*# is written in big endian, __rshift__ because Jinja2 doesn't like '<<' #*/
35                /*- set paddr_part = regs[i * reg_entry_size + (num_address_cells - 1 - j)].__lshift__(j * 32) -*/
36                /*- set temp_ns.paddr = temp_ns.paddr + paddr_part -*/
37            /*- endfor -*/
38
39            /*- for j in range(0, num_size_cells) -*/
40                /*# Same idea as above #*/
41                /*- set size_part = regs[i * reg_entry_size + (num_size_cells - 1 - j) + num_address_cells].__lshift__(j * 32) -*/
42                /*- set temp_ns.size = temp_ns.size + size_part -*/
43            /*- endfor -*/
44
45            /*- set paddr =  macros.align_page_address(temp_ns.paddr, options.architecture) -*/
46            /*- set size = temp_ns.size -*/
47
48            /*- do reg_set.append((paddr, size)) -*/
49        /*- endfor -*/
50    /*- endif -*/
51    /*- do stash('reg_set', reg_set) -*/
52/*- endmacro -*/
53
54/*- macro parse_dtb_node_interrupts(node, max_num_interrupts) -*/
55    /*- set irq_set = macros.parse_dtb_node_interrupts(node, max_num_interrupts) -*/
56    /*- do stash('irq_set', irq_set) -*/
57/*- endmacro -*/
58