XenevaOS
Loading...
Searching...
No Matches
foo Struct Reference

Detailed Description

iosys_map_rd_field - Read a member from a struct in the iosys_map

@map__: The iosys_map structure @struct_offset__: Offset from the beginning of the map, where the struct is located @struct_type__: The struct describing the layout of the mapping @field__: Member of the struct to read

Read a value from iosys_map considering its layout is described by a C struct starting at @struct_offset__. The field offset and size is calculated and its value read. If the field access would incur in un-aligned access, then either iosys_map_memcpy_from() needs to be used or the architecture must support it. For example: suppose there is a below and the value foo.field2.inner2 needs to be read from the iosys_map:

.. code-block:: c

struct foo { int field1; struct { int inner1; int inner2; } field2; int field3; } __packed;

This is the expected memory layout of a buffer using iosys_map_rd_field():

+---------------------------—+-----------------------—+ | Address | Content | +==============================+==========================+ | buffer + 0000 | start of mmapped buffer | | | pointed by iosys_map | +---------------------------—+-----------------------—+ | ... | ... | +---------------------------—+-----------------------—+ | buffer + struct_offset__ | start of struct foo | +---------------------------—+-----------------------—+ | ... | ... | +---------------------------—+-----------------------—+ | buffer + wwww | foo.field2.inner2 | +---------------------------—+-----------------------—+ | ... | ... | +---------------------------—+-----------------------—+ | buffer + yyyy | end of struct foo | +---------------------------—+-----------------------—+ | ... | ... | +---------------------------—+-----------------------—+ | buffer + zzzz | end of mmaped buffer | +---------------------------—+-----------------------—+

Values automatically calculated by this macro or not needed are denoted by wwww, yyyy and zzzz. This is the code to read that value:

.. code-block:: c

x = iosys_map_rd_field(&map, offset, struct foo, field2.inner2);

Returns: The value read from the mapping.


The documentation for this struct was generated from the following file: