You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/storage/api/api.rst
+33-27Lines changed: 33 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,16 +66,16 @@ These definitions must be defined in the header file :file:`psa/storage_common.h
66
66
.. struct:: psa_storage_iterator_t
67
67
68
68
.. 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.
72
72
73
73
The structure is initilaised by the `ps_iterator_start` function.
74
74
It is modified by the `ps_iterator_next` function.
75
75
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.
77
77
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`
79
79
80
80
.. typedef:: uint32_t psa_storage_create_flags_t
81
81
@@ -743,10 +743,7 @@ These definitions must be defined in the header file :file:`psa/protected_storag
743
743
* the ``psa_storage_rename_flags_t`` has a value set other than ``PSA_STORAGE_FLAG_REPLACE``
744
744
745
745
.. 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``.
750
747
751
748
.. retval:: PSA_ERROR_NOT_SUPPORTED
752
749
The implementation does not support the operation.
@@ -762,61 +759,64 @@ These definitions must be defined in the header file :file:`psa/protected_storag
762
759
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.
763
760
764
761
765
-
766
-
767
762
.. function:: psa_ps_iterator_start
768
763
769
764
.. summary::
770
765
Initialises an iterator that can be used to return a list of uids in the Protected Storage .
771
766
772
767
.. param:: psa_storage_iterator_t* context
773
768
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
+
776
770
.. param:: psa_storage_uid_t filter
777
771
A value used to filter the results included in this iteration.
778
772
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
780
777
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.
781
778
782
779
.. return:: psa_status_t
783
780
A status indicating the success or failure of the operation.
784
781
785
782
.. retval:: PSA_SUCCESS
786
783
The operation completed successfully.
784
+
787
785
.. retval:: PSA_ERROR_DOES_NOT_EXIST
788
786
No ``uid`` matches this iteration.
789
787
790
788
.. retval:: PSA_ERROR_STORAGE_FAILURE
791
789
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
-
795
790
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.
799
792
800
793
The iterator will only returns those ``uid`` that were created by the caller. It MUST not return any ``uid`` created by a different user.
801
794
802
795
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.
803
796
804
797
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. ###
807
798
808
799
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.
809
802
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
+
810
809
811
810
.. function:: psa_ps_iterator_next
811
+
812
812
.. summary::
813
813
814
-
Returns the next ``uid`` in this iteration.
814
+
Returns the next ``uid`` in this iteration.
815
815
816
816
.. param:: psa_storage_iterator_t* context
817
817
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.
818
818
819
-
.. param:: *psa_storage_uid_t result
819
+
.. param:: psa_storage_uid_t *result
820
820
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.
821
821
822
822
.. return:: psa_status_t
@@ -826,8 +826,13 @@ These definitions must be defined in the header file :file:`psa/protected_storag
826
826
The operation completed successfully.
827
827
.. retval:: PSA_ERROR_DOES_NOT_EXIST
828
828
The iterator has returned all the uids that match this iteration.
829
+
829
830
.. retval:: PSA_ERROR_STORAGE_FAILURE
830
831
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
+
831
836
.. retval:: PSA_ERROR_INVALID_ARGUMENT
832
837
The operation failed because either:
833
838
@@ -837,13 +842,14 @@ These definitions must be defined in the header file :file:`psa/protected_storag
837
842
838
843
.. function:: psa_ps_get_support
839
844
840
-
.. return:: uint32_t
841
-
842
845
.. summary::
843
846
Returns a bitmask with flags set for the optional features supported by the implementation.
0 commit comments