Skip to content

Commit 740dfd0

Browse files
Replace hardcoded 0x8 with te.hdr_size in standard operations
Updated the "Standard Operations" section to consistently use `te.hdr_size` instead of the hardcoded `0x8`. Also add a note explaining the assumption of `te.hdr_size = 0x8` and its potential future configurability. This improves consistency, avoids magic numbers, and prepares the format for variable-sized TE headers. Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
1 parent 6a66fba commit 740dfd0

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

source/transfer_list.rst

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ This section describes the valid operations that may be performed on a TL in
292292
more detail, in order to clarify how to use the various fields and to serve as a
293293
guideline for implementation.
294294

295+
.. note::
296+
This section assumes te.hdr_size is 0x8 for all TE entries. This is used consistently throughout the examples.
297+
In the future, if entries with different header sizes are introduced, some operations may need to explicitly
298+
take te.hdr_size as an argument.
299+
295300
Validating a TL header
296301
^^^^^^^^^^^^^^^^^^^^^^
297302

@@ -338,8 +343,7 @@ Inputs:
338343
is smaller or equal to `tl.used_size`, otherwise abort (the TL is corrupted).
339344

340345
#. If `te.tag_id` (`te_base_addr + 0x0`) is a known tag, interpret the data
341-
at `te_base_addr + te.hdr_size` accordingly. (Do not hardcode the value
342-
for `te.hdr_size`, even for known tags!) Otherwise, ignore the tag and
346+
at `te_base_addr + te.hdr_size` accordingly. Otherwise, ignore the tag and
343347
proceed with the next step.
344348

345349
#. Add `align8(te.hdr_size + te.data_size)` to `te_base_addr`.
@@ -362,14 +366,14 @@ Inputs:
362366

363367
#. Use the `te_base_addr` of this tag for the rest of the operation.
364368

365-
#. If `has_checksum`, Subtract the sum of `align8(new_data_size + 0x8)` bytes
369+
#. If `has_checksum`, Subtract the sum of `align8(new_data_size + te.hdr_size)` bytes
366370
starting at `te_base_addr` from `tl.checksum`.
367371

368372
#. Skip the next step (step 2) with all its substeps.
369373

370374
#. Calculate `te_base_addr` as `tl_base_addr + tl.used_size`.
371375

372-
#. If `tl.total_size - tl.used_size` is smaller than `align8(new_data_size + 0x8)`,
376+
#. If `tl.total_size - tl.used_size` is smaller than `align8(new_data_size + te.hdr_size)`,
373377
abort (not enough room to add TE).
374378

375379
#. If `has_checksum`, subtract the sum of the 4 bytes from
@@ -386,19 +390,19 @@ Inputs:
386390

387391
#. Set `te.data_size` (`te_base_addr + 0x4`) to `new_data_size`.
388392

389-
#. Copy or generate the TE data into `te_base_addr + 0x8`.
393+
#. Copy or generate the TE data into `te_base_addr + te.hdr_size`.
390394

391-
#. If `has_checksum`, add the sum of `align8(new_data_size + 0x8)` bytes
395+
#. If `has_checksum`, add the sum of `align8(new_data_size + te.hdr_size)` bytes
392396
starting at `te_base_addr` to `tl.checksum`.
393397

394398
#. If an existing XFERLIST_VOID TE was chosen to be overwritten in step 1, and
395-
`old_void_data_size - new_data_size` is greater than or equal to `0x8`, then
399+
`old_void_data_size - new_data_size` is greater than or equal to `te.hdr_size`, then
396400
create a new void TE to fill the remaining space by calling `Adding a void TE`_
397401
with the following arguments:
398402

399-
#. `void_te.base_addr` = `te_base_addr + align8(new_data_size + 0x8)`
403+
#. `void_te.base_addr` = `te_base_addr + align8(new_data_size + te.hdr_size)`
400404

401-
#. `void_te.data_size` = `old_void_data_size - align8(new_data_size + 0x8)`
405+
#. `void_te.data_size` = `old_void_data_size - align8(new_data_size + te.hdr_size)`
402406

403407
Removing a TE
404408
^^^^^^^^^^^^^
@@ -411,7 +415,7 @@ Inputs:
411415

412416
#. `void_te.base_addr` = `te_base_addr`
413417

414-
#. `void_te.size` = `te.data_size + te.hdr_size - 0x8`
418+
#. `void_te.size` = `te.data_size`
415419

416420
#. *(Optional)* Implementations may perform memory management by inspecting adjacent entries
417421
and coalescing consecutive `XFERLIST_VOID` entries into a single larger one. This can help
@@ -443,12 +447,12 @@ Inputs:
443447
#. If `has_checksum`, add the sum of `align8(new_data_size)` bytes starting at
444448
`te_base_addr + te.hdr_size` to `tl.checksum`.
445449

446-
#. If `te.data_size - align8(new_data_size)` is greater than or equal to `0x8`, create a new
450+
#. If `te.data_size - align8(new_data_size)` is greater than or equal to `te.hdr_size`, create a new
447451
void TE to fill the remaining space by calling `Adding a void TE`_ with the following arguments:
448452

449453
#. `te_base_addr` = `te_base_addr + align8(new_data_size + te.hdr_size)`
450454

451-
#. `data_size` = `te.data_size - align8(new_data_size - 0x8)`
455+
#. `data_size` = `te.data_size - align8(new_data_size - te.hdr_size)`
452456

453457
Adding a new TE with special data alignment requirement
454458
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)