pgtt/codegen.py
def _mk_blocks( n:int, t:table.Table, index:int, r:Region ) -> str:
    """
    Generate assembly to program a range of contiguous block/page entries.

    args
    ====

        n
                    table number in sequential order from ttbr0_eln

        t
                    translation table being programmed

        index
                    index of the first block/page in the contiguous range

        r
                    the memory region
    """
    (value,comment) = mmu.block_page_template(r.memory_type, r.ap_type, t.level >= 3)
    if r.num_contig > 1:
        return f"""
/* {r.comment} */
/* {comment} */
    MOV64    x9, {value}  //
    MOV64   x10, {index}            // index: {index}
    MOV64   x11, {index + r.num_contig}     // to {index + r.num_contig} ({r.num_contig} entries)
    MOV64   x12, {hex(r.addr)}      // output address of entry[index]
pt{hex(r.addr)}:
    orr     x12, x12, x9    // merge output address with template
    str     X12, [x21, x10, lsl #3]     // write entry into table
    add     x10, x10, #1                // prepare for next entry
    add     x12, x12, x22               // add chunk to address
    cmp     x10, x11            // last index?
    b.ne    pt{hex(r.addr)}                     //
"""
    else:
        return f"""
/* {r.comment} */
/* {comment} */
    MOV64    x9, {value} //
    MOV64   x10, {index}                // index: {index}
    MOV64   x12, {hex(r.addr)}      // output address of entry[index]
    orr     x12, x12, x9    // merge output address with template
    str     x12, [x21, x10, lsl #3]     // write entry into table
"""

    Generate assembly to program a range of contiguous block/page entries.

    args
    ====

        n
                    table number in sequential order from ttbr0_eln

        t
                    translation table being programmed

        index
                    index of the first block/page in the contiguous range

        r
                    the memory region
    
Generate assembly to program a range of contiguous block/page entries.
args

n
table number in sequential order from ttbr0_eln

t
translation table being programmed

index
index of the first block/page in the contiguous range

r
the memory region
Generate assembly to program a range of contiguous block / page entries . args n table number in sequential order from ttbr0_eln t translation table being programmed index index of the first block / page in the contiguous range r the memory region
def _mk_blocks( n:int, t:table.Table, index:int, r:Region ) -> str:
    (value,comment) = mmu.block_page_template(r.memory_type, r.ap_type, t.level >= 3)
    if r.num_contig > 1:
        return f"""
/* {r.comment} */
/* {comment} */
    MOV64    x9, {value}  //
    MOV64   x10, {index}            // index: {index}
    MOV64   x11, {index + r.num_contig}     // to {index + r.num_contig} ({r.num_contig} entries)
    MOV64   x12, {hex(r.addr)}      // output address of entry[index]
pt{hex(r.addr)}:
    orr     x12, x12, x9    // merge output address with template
    str     X12, [x21, x10, lsl #3]     // write entry into table
    add     x10, x10, #1                // prepare for next entry
    add     x12, x12, x22               // add chunk to address
    cmp     x10, x11            // last index?
    b.ne    pt{hex(r.addr)}                     //
"""
    else:
        return f"""
/* {r.comment} */
/* {comment} */
    MOV64    x9, {value} //
    MOV64   x10, {index}                // index: {index}
    MOV64   x12, {hex(r.addr)}      // output address of entry[index]
    orr     x12, x12, x9    // merge output address with template
    str     x12, [x21, x10, lsl #3]     // write entry into table
"""
def _mk_blocks ( n : int , t : table . Table , index : int , r : Region ) -> str : ( value , comment ) = mmu . block_page_template ( r . memory_type , r . ap_type , t . level >= 3 ) if r . num_contig > 1 : return f"""
/* {r.comment} */
/* {comment} */
    MOV64    x9, {value}  //
    MOV64   x10, {index}            // index: {index}
    MOV64   x11, {index + r.num_contig}     // to {index + r.num_contig} ({r.num_contig} entries)
    MOV64   x12, {hex(r.addr)}      // output address of entry[index]
pt{hex(r.addr)}:
    orr     x12, x12, x9    // merge output address with template
    str     X12, [x21, x10, lsl #3]     // write entry into table
    add     x10, x10, #1                // prepare for next entry
    add     x12, x12, x22               // add chunk to address
    cmp     x10, x11            // last index?
    b.ne    pt{hex(r.addr)}                     //
""" else : return f"""
/* {r.comment} */
/* {comment} */
    MOV64    x9, {value} //
    MOV64   x10, {index}                // index: {index}
    MOV64   x12, {hex(r.addr)}      // output address of entry[index]
    orr     x12, x12, x9    // merge output address with template
    str     x12, [x21, x10, lsl #3]     // write entry into table
"""
Generate assembly to program a range of contiguous block/page entries.
Generate assembly to program a range of contiguous block / page entries .
"""
    Generate assembly to program a range of contiguous block/page entries.

    args
    ====

        n
                    table number in sequential order from ttbr0_eln

        t
                    translation table being programmed

        index
                    index of the first block/page in the contiguous range

        r
                    the memory region
    """
n
int
t
table.Table
index
int
r
Region