|Home > Iris APIs > Resources API > Reading a resource|
The semantics of reading a resource are peek rather than architectural read. If possible, all instance implementations should try to achieve side-effect free reads. This is required for non-intrusive debug.
resource_read() function supports reporting bits in registers with an undefined value. It is optional for instances to support this.
It is not always possible to return the exact value of a resource, for example when the instance that exposes the resource is not in a debuggable state. The
resource_read() function supports reporting approximate values.
resource_read()function does not fail with an error for existing resources that could not be read. Instead, such read errors are reported in the
ResourceReadResult, for each resource.
resource_read() returns one
ResourceReadResult object, which contains the read result for all resources that were read, comprising values and errors. Numeric resource values and string resource values are split into two different arrays. Numeric resource values occupy one or more
NumberU64 values in the array, depending on their width. For example:
ResourceReadResult.data= [1, 2, 0xf00daaaa]
ResourceReadResult.data = [1, 2, 3]
ResourceReadResult.data = [0x7766554433221100, 0xffeeddccbbaa9988, 9]
ResourceReadResult.data =  ResourceReadResult.strings = ["abc"]
Reading a 32-bit resource with value 1, a string resource with value
"abc", and a 32-bit resource with value 3:
ResourceReadResult.data = [1, 3] ResourceReadResult.strings = ["abc"]
resource_read() operations give the same result as this example:
"abc", a 32-bit resource with value 1, and a 32-bit resource with value 3.
noValueresource, and a 32-bit resource with value 3:
ResourceReadResult.data = [1, 3]