feat: add option to input attr as string of flag names

Change-Id: I56f0364ef43c9d415a335474e15b68e79db37f5d
Signed-off-by: Charlie Bareham <charlie.bareham@arm.com>
This commit is contained in:
Charlie Bareham 2024-06-20 12:11:53 +01:00 committed by Harrison Mutai
parent 792e8e896f
commit 4dcbba98ce
3 changed files with 83 additions and 1 deletions

View file

@ -275,6 +275,33 @@ You can give the name of the tag instead of the tag id number. The valid tag nam
* hob_block
* hob_list
You can input the attr field of entry_point_info as a string of flag
names separated by `|`. The names are taken from ep_info_exp.h in TF-A.
For example:
.. code::
has_checksum: true
max_size: 4096
entries:
- tag_id: 0x102
ep_info:
args:
- 67112976
- 67112960
- 0
- 0
- 0
- 0
- 0
- 0
h:
attr: EP_NON_SECURE | EP_ST_ENABLE
type: 1
version: 2
pc: 67239936
spsr: 965
--------------
*Copyright (c) 2024, Arm Limited. All rights reserved.*

View file

@ -320,6 +320,29 @@ def test_create_from_yaml_check_sum_bytes(tlcrunner, tmpyamlconfig, tmptlstr, en
"0x00000000 0x00000000"
),
),
(
{
"tag_id": 0x102,
"ep_info": {
"h": {
"type": 0x01,
"version": 0x02,
"attr": "EP_NON_SECURE | EP_ST_ENABLE",
},
"pc": 67239936,
"spsr": 965,
"args": [67112976, 67112960, 0, 0, 0, 0, 0, 0],
},
},
(
"0x00580201 0x00000005 0x04020000 0x00000000 "
"0x000003C5 0x00000000 0x04001010 0x00000000 "
"0x04001000 0x00000000 0x00000000 0x00000000 "
"0x00000000 0x00000000 0x00000000 0x00000000 "
"0x00000000 0x00000000 0x00000000 0x00000000 "
"0x00000000 0x00000000"
),
),
],
)
def test_create_from_yaml_check_exact_data(

View file

@ -13,6 +13,7 @@ import typing
import math
import struct
from dataclasses import dataclass
from functools import reduce
from pathlib import Path
from tlc.te import TransferEntry
@ -236,13 +237,44 @@ class TransferList:
# size of the entry_point_info struct
entry_point_size = 88
attr = header["attr"]
if type(attr) is str:
# convert string of flags names to an integer
# bit number | 0 | 1 |
# ------------|-----------------------|----------------------|
# 0 | secure | non-secure |
# 1 | little endian | big-endian |
# 2 | disable secure timer | enable secure timer |
# 3 | executable | non-executable |
# 4 | first exe | not first exe |
#
# Bit 5 and bit 0 are used to determine the security state.
flag_names = {
"EP_SECURE": 0x0,
"EP_NON_SECURE": 0x1,
"EP_REALM": 0x21,
"EP_EE_LITTLE": 0x0,
"EP_EE_BIG": 0x2,
"EP_ST_DISABLE": 0x0,
"EP_ST_ENABLE": 0x4,
"EP_NON_EXECUTABLE": 0x0,
"EP_EXECUTABLE": 0x8,
"EP_FIRST_EXE": 0x10,
}
# create list of integer flags, then bitwise-or them together
flags = [flag_names[f.strip()] for f in attr.split("|")]
attr = reduce(lambda x, y: x | y, flags)
return self.add_transfer_entry_from_struct_format(
0x102,
transfer_entry_formats[0x102]["format"],
header["type"],
header["version"],
entry_point_size,
header["attr"],
attr,
ep_info["pc"],
ep_info["spsr"],
*ep_info["args"],