L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
L4drivers::Register_block< MAX_BITS, BLOCK > Class Template Reference

Handles a reference to a register block of the given maximum access width. More...

#include <hw_register_block>

+ Collaboration diagram for L4drivers::Register_block< MAX_BITS, BLOCK >:

Public Member Functions

template<unsigned BITS>
Ro_register_tmpl< BITS, Block > r (unsigned offset) const
 Read only access to register at offset offset.
 
Ro_register operator[] (unsigned offset) const
 Read only access to register at offset offset.
 
template<unsigned BITS>
Register_tmpl< BITS, Block > r (unsigned offset)
 Read/write access to register at offset offset.
 
Register operator[] (unsigned offset)
 Read/write access to register at offset offset.
 

Detailed Description

template<unsigned MAX_BITS, typename BLOCK = Register_block_tmpl< Register_block_base<MAX_BITS> >>
class L4drivers::Register_block< MAX_BITS, BLOCK >

Handles a reference to a register block of the given maximum access width.

Template Parameters
MAX_BITSMaximum access width for the registers in this block.
BLOCKType implementing the register accesses (read<>(), write<>(), modify<>(), set<>(), and clear<>()).

Provides access to registers in this block via r<WIDTH>() and operator[]().

Example usage:

void test()
{
// create a register block reference for max. 16bit accesses, using a
// MMIO register block implementation (at address 0x1000).
Hw::Register_block<16> regs = new Hw::Mmio_register_block<16>(0x1000);
// Alternatively it is allowed to use an implementation that allows
// wider access than actually needed.
Hw::Register_block<16> regs = new Hw::Mmio_register_block<32>(0x1000);
// read a 16bit register at offset 8byte
unsigned short x = regs.r<16>(8);
unsigned short x1 = regs[8]; // alternative
// read an 8bit register at offset 0byte
unsigned v = regs.r<8>(0);
// do a 16bit write to register at offset 2byte (four variants)
regs[2] = 22;
regs.r<16>(2) = 22;
regs[2].write(22);
regs.r<16>().write(22);
// do an 8bit write (two variants)
regs.r<8>(0) = 9;
regs.r<8>(0).write(9);
// do 16bit read-modify-write (two variants)
regs[4].modify(0xf, 3); // clear 4 lowest bits and set them to 3
regs.r<16>(4).modify(0xf, 3);
// do 8bit read-modify-write
regs.r<8>(0).modify(0xf, 3);
// fails to compile, because of too wide access
// (32 bit access but regs is Hw::Register_block<16>)
unsigned long v = regs.r<32>(4)
}

Definition at line 329 of file hw_register_block.

Member Function Documentation

◆ operator[]() [1/2]

template<unsigned MAX_BITS, typename BLOCK = Register_block_tmpl< Register_block_base<MAX_BITS> >>
Register L4drivers::Register_block< MAX_BITS, BLOCK >::operator[] ( unsigned  offset)
inline

Read/write access to register at offset offset.

Parameters
offsetThe offset of the register within the register file.
Returns
register object allowing read and write access with width MAX_BITS.

Definition at line 384 of file hw_register_block.

◆ operator[]() [2/2]

template<unsigned MAX_BITS, typename BLOCK = Register_block_tmpl< Register_block_base<MAX_BITS> >>
Ro_register L4drivers::Register_block< MAX_BITS, BLOCK >::operator[] ( unsigned  offset) const
inline

Read only access to register at offset offset.

Parameters
offsetThe offset of the register within the register file.
Returns
register object allowing read only access with width MAX_BITS.

Definition at line 364 of file hw_register_block.

◆ r() [1/2]

template<unsigned MAX_BITS, typename BLOCK = Register_block_tmpl< Register_block_base<MAX_BITS> >>
template<unsigned BITS>
Register_tmpl< BITS, Block > L4drivers::Register_block< MAX_BITS, BLOCK >::r ( unsigned  offset)
inline

Read/write access to register at offset offset.

Template Parameters
BITSthe access width in bits for the register.
Parameters
offsetThe offset of the register within the register file.
Returns
register object allowing read and write access with width BITS.

Definition at line 375 of file hw_register_block.

◆ r() [2/2]

template<unsigned MAX_BITS, typename BLOCK = Register_block_tmpl< Register_block_base<MAX_BITS> >>
template<unsigned BITS>
Ro_register_tmpl< BITS, Block > L4drivers::Register_block< MAX_BITS, BLOCK >::r ( unsigned  offset) const
inline

Read only access to register at offset offset.

Template Parameters
BITSthe access width in bits for the register.
Parameters
offsetThe offset of the register within the register file.
Returns
register object allowing read only access with width BITS.

Definition at line 356 of file hw_register_block.


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