iosys_map_rd_field(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… iosys_map_rd_field(9) โ€” like, the whole Kernel API Manual, but make it make sense

okay so bestie, welcome to iosys_map_rd_field โ€” it's a macro from the Kernel API Manual and honestly it's giving "tiny but powerful" ๐Ÿ’–. Its whole thing? Read a member from a struct in an iosys_map. That's it. That's the vibe check. โœจ


๐ŸŒธ NAME ๐ŸŒธ

iosys_map_rd_field โ€” reads a member out of a struct that lives inside the iosys_map. no cap, that's the job ๐Ÿซถ


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

iosys_map_rd_field (map__ , struct_offset__ , struct_type__ , field__ );

๐ŸŽ€ ARGUMENTS ๐ŸŽ€

  • map__ โ€” the iosys_map structure itself. the main character, literally ๐Ÿ‘‘
  • struct_offset__ โ€” offset from the beginning of the map, i.e. where the struct is hanging out. like a little address coordinate ๐Ÿ—บ๏ธ
  • struct_type__ โ€” the struct that describes how the mapping is laid out. it's the blueprint, the floor plan, the whole aesthetic ๐Ÿ 
  • field__ โ€” the member of the struct you actually wanna read. the one you came for ๐Ÿ’…

โœจ DESCRIPTION โœจ

So what it does is โ€” it reads a value from iosys_map, and it figures out the layout because a C struct is describing it, starting at struct_offset__. It calculates the field offset and the size, then reads the value. Math but make it fashion. ๐Ÿงฎโœจ

โš ๏ธ okay important, don't skip this: if the field access would incur in unaligned access, then either iosys_map_memcpy_from needs to be used, or the architecture must support it. no vibes-based guessing here, bestie. it's fr fr a real caveat ๐Ÿ˜ญ

For example: suppose there's a struct foo defined like below, and you need to read the value foo.field2.inner2 from the iosys_map:

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    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The values that this macro calculates automatically โ€” or the ones that just aren't needed โ€” are denoted by wwww, yyyy and zzzz. cute little placeholders, they ate ๐Ÿ“

And this is the code to read that value:

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

๐Ÿ”ฅ RETURN ๐Ÿ”ฅ

The value read from the mapping. that's it, that's the whole return, and it understood the assignment ๐Ÿ’œ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

  • Kernel file ./include/linux/iosys-map.h overview(9)
  • struct iosys_map(9)
  • IOSYS_MAP_INIT_VADDR(9)
  • IOSYS_MAP_INIT_VADDR_IOMEM(9)
  • IOSYS_MAP_INIT_OFFSET(9)
  • iosys_map_set_vaddr(9)
  • iosys_map_set_vaddr_iomem(9)
  • iosys_map_is_equal(9)
  • iosys_map_is_null(9)
  • iosys_map_is_set(9)
  • iosys_map_clear(9)
  • iosys_map_memcpy_to(9)
  • iosys_map_memcpy_from(9)
  • iosys_map_incr(9)
  • iosys_map_memset(9)
  • iosys_map_rd(9)
  • iosys_map_wr(9)
  • iosys_map_wr_field(9)

like, the whole iosys_map friend group showed up to the party ๐Ÿซถ๐ŸŽ‰


okay that's the page!! sourced straight from ./include/linux, dated October 2026, and yeah โ€” iosys_map_rd_field(9), that's her ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from