Skip to content

Commit 3d80c0c

Browse files
MarcusJGStreetsathoelke
authored andcommitted
Version 2, for further review
I think this addresses Andrew's comments Signed-off-by: Marcus Streets <marcus.streets@arm.com>
1 parent fd9e2a3 commit 3d80c0c

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

doc/storage/api/api.rst

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ These definitions must be defined in the header file :file:`psa/storage_common.h
6666
.. struct:: psa_storage_iterator_t
6767

6868
.. summary::
69-
An implantation defined opaque structure containing the context for an iterator.
70-
The structure MUST contain all all the state required by the iterator.
71-
No further state is retained by the implementation.
69+
An implementation-defined opaque structure containing the context for an iterator.
70+
The structure MUST contain all all the state required by the iterator.
71+
That is, further state MUST NOT be retained by the implementation.
7272

7373
The structure is initilaised by the `ps_iterator_start` function.
7474
It is modified by the `ps_iterator_next` function.
7575

76-
It is the duty of the calling application to free memory when the iterator is no longer required.
76+
the caller can discard or reuse the iterator object once it has finished using it. This can be before, or after, the iterator has reached the end of the iteration.
7777

78-
This structure is only required if PSA_STORAGE_SUPPORT_ITERATION is `True`
78+
The header file is only required to define this structure if PSA_STORAGE_SUPPORT_ITERATION is `True`
7979

8080
.. typedef:: uint32_t psa_storage_create_flags_t
8181

@@ -743,10 +743,7 @@ These definitions must be defined in the header file :file:`psa/protected_storag
743743
* the ``psa_storage_rename_flags_t`` has a value set other than ``PSA_STORAGE_FLAG_REPLACE``
744744

745745
.. retval:: PSA_ERROR_NOT_PERMITTED
746-
The operation failed because either:
747-
748-
* ``uid_new`` exists and was created with ``PSA_STORAGE_FLAG_WRITE_ONCE``.
749-
* ``uid_new`` exists and ``PSA_STORAGE_FLAG_REPLACE`` is not specified
746+
The operation failed because ``uid_new`` exists and was created with ``PSA_STORAGE_FLAG_WRITE_ONCE``.
750747

751748
.. retval:: PSA_ERROR_NOT_SUPPORTED
752749
The implementation does not support the operation.
@@ -762,61 +759,64 @@ These definitions must be defined in the header file :file:`psa/protected_storag
762759
Except in the case of ``PSA_ERROR_STORAGE_FAILURE``, in which case no guarantees can be made, the operation shall either succeed or leave storage unchanged.
763760

764761

765-
766-
767762
.. function:: psa_ps_iterator_start
768763

769764
.. summary::
770765
Initialises an iterator that can be used to return a list of uids in the Protected Storage .
771766

772767
.. param:: psa_storage_iterator_t* context
773768
A pointer to a context for this iterator. This is set to a new value on success and is undefined on error. The content of the iterator is implementation defined. The pointer MUST be valid and MUST point to a block of memory of the size given by the ``PSA_STORAGE_ITERATOR_CTX__SIZE`` macro to which the caller has write access.
774-
.. param:: psa_storage_uid_t mask
775-
A value used to filter the results included in this iteration.
769+
776770
.. param:: psa_storage_uid_t filter
777771
A value used to filter the results included in this iteration.
778772

779-
.. param:: *psa_storage_uid_t result
773+
.. param:: int_t filter_length
774+
A length of the filter to use, this must be a value `-63 < filter_lemngth < 63`.
775+
776+
.. param:: psa_storage_uid_t *result
780777
A pointer to the location in which to store ``uid``. On success the contents of this location will be updated with the first matching ``uid``. On error, the contents are undefined.
781778

782779
.. return:: psa_status_t
783780
A status indicating the success or failure of the operation.
784781

785782
.. retval:: PSA_SUCCESS
786783
The operation completed successfully.
784+
787785
.. retval:: PSA_ERROR_DOES_NOT_EXIST
788786
No ``uid`` matches this iteration.
789787

790788
.. retval:: PSA_ERROR_STORAGE_FAILURE
791789
The operation failed because the physical storage has failed (Fatal error).
792-
.. retval:: PSA_ERROR_INVALID_ARGUMENT
793-
The operation failed because the caller cannot access some or all of the memory in the range [``context``, ``context + PSA_STORAGE_ITERATOR_CTX__SIZE - 1``].
794-
795790

796-
Any bit positions where the mask is set to one must match the value in the filter.
797-
798-
That is, the iterator returns those values where ``uid & mask = filter``
791+
The iterator returns those values where the ``filter_length`` bits of the `uid` matches the bits in ``filter``. If the value of ``filter_length`` is positive, it matches left most bits, if it i nagative, it matches the right most bits.
799792

800793
The iterator will only returns those ``uid`` that were created by the caller. It MUST not return any ``uid`` created by a different user.
801794

802795
An iterator is not required to return uids in any specific order, but MUST return them in a consistent order each time it is called. For example, if an implementation returns entries in numerical order, it should not arbitrarily change to returning them in creation order. However, the caller should not make assumptions as to the order in which entries are returned, except that each uid will be returned only once in each iteration.
803796

804797
Changes to storage by other users MUST NOT affect any open iterations.
805-
806-
### todo: We need to state what effects are required/denied/permitted (i.e. imp-def) when the caller modifies the storage while iterating. ###
807798

808799
A caller may initialize multiple iteration contexts at the same time. Each iteration shall be independent. Calling ``psa_ps_iterator_next()`` on one iterator MUST not effect any other open iteration.
800+
801+
A caller may read the contents of any `uid` with ``psa_ps_get()`` or write with ``psa_ps_set()`` or ``psa_ps_set_extended()`` without invalidating the iteration context.
809802

803+
A caller may create a `uid` with ``psa_ps_set()`` or ``psa_ps_create()`` without invalidating the iteration context, provided the `uid` does *NOT* match the filter. However, if the `uid` matches the filter then any later call to `psa_ps_iterator_next()` fails with `PSA_ERROR_DATA_CORRUPT`.
804+
805+
A caller may delete a `uid` with ``psa_ps_remove(uid)`` without invalidating the iteration context, provided the `uid` does *NOT* match the filter. However, if the `uid` matches the filter then any later call to `psa_ps_iterator_next()` fails with `PSA_ERROR_DATA_CORRUPT`.
806+
807+
A caller may call `psa_ps_rename(uid, uid_new)` without invalidating the iteration context, provided the `uid` does *NOT* match the filter, as this is equivalent to calling `psa_ps_remove(uid)`. However, if the `uid` matches the filter then any later call to `psa_ps_iterator_next()` fails with `PSA_ERROR_DATA_CORRUPT`.
808+
810809

811810
.. function:: psa_ps_iterator_next
811+
812812
.. summary::
813813

814-
Returns the next ``uid`` in this iteration.
814+
Returns the next ``uid`` in this iteration.
815815

816816
.. param:: psa_storage_iterator_t* context
817817
A pointer to a context for this iterator as returned by ``psa_ps_iterator_start()`` or updated by a previous call to ``psa_ps_iterator_next``. The content of the iterator will change on success and is undefined on error.
818818

819-
.. param:: *psa_storage_uid_t result
819+
.. param:: psa_storage_uid_t *result
820820
A pointer to the location in which to store ``uid``. On success the contents of this location will be updated with the next matching ``uid``. On error, the contents are undefined.
821821

822822
.. return:: psa_status_t
@@ -826,8 +826,13 @@ These definitions must be defined in the header file :file:`psa/protected_storag
826826
The operation completed successfully.
827827
.. retval:: PSA_ERROR_DOES_NOT_EXIST
828828
The iterator has returned all the uids that match this iteration.
829+
829830
.. retval:: PSA_ERROR_STORAGE_FAILURE
830831
The operation failed because the physical storage has failed (Fatal error).
832+
833+
.. retval:: PSA_ERROR_DATA_CORRUPT
834+
The operation failed because the contents of the iteration have changed. That is a `uid` matching the filter has either been created or deleted.
835+
831836
.. retval:: PSA_ERROR_INVALID_ARGUMENT
832837
The operation failed because either:
833838

@@ -837,13 +842,14 @@ These definitions must be defined in the header file :file:`psa/protected_storag
837842

838843
.. function:: psa_ps_get_support
839844

840-
.. return:: uint32_t
841-
842845
.. summary::
843846
Returns a bitmask with flags set for the optional features supported by the implementation.
844847

845848
Currently defined flags are limited to:
846849

847850
* `PSA_STORAGE_SUPPORT_SET_EXTENDED`
848851
* `PSA_STORAGE_SUPPORT_RENAME`
849-
* `PSA_STORAGE_SUPPORT_ITERATION`
852+
* `PSA_STORAGE_SUPPORT_ITERATION`
853+
854+
.. return:: uint32_t
855+

0 commit comments

Comments
 (0)