iPXE
bitbash.h File Reference

Bit-bashing interfaces. More...

Go to the source code of this file.

Data Structures

struct  bit_basher_operations
 Bit-bashing operations. More...
struct  bit_basher
 A bit-bashing interface. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static void open_bit (struct bit_basher *basher)
 Open bit-bashing interface.
static void close_bit (struct bit_basher *basher)
 Close bit-bashing interface.
void write_bit (struct bit_basher *basher, unsigned int bit_id, unsigned long data)
 Set/clear output bit.
int read_bit (struct bit_basher *basher, unsigned int bit_id)
 Read input bit.

Detailed Description

Bit-bashing interfaces.

Definition in file bitbash.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ open_bit()

void open_bit ( struct bit_basher * basher)
inlinestatic

Open bit-bashing interface.

Parameters
basherBit-bashing interface

Definition at line 66 of file bitbash.h.

66 {
67 if ( basher->op->open )
68 basher->op->open ( basher );
69}
void(* open)(struct bit_basher *basher)
Open bit-bashing interface (optional)
Definition bitbash.h:22
struct bit_basher_operations * op
Bit-bashing operations.
Definition bitbash.h:58

References bit_basher::op, and bit_basher_operations::open.

Referenced by i2c_bit_read(), i2c_bit_write(), i2c_reset(), and spi_bit_rw().

◆ close_bit()

void close_bit ( struct bit_basher * basher)
inlinestatic

Close bit-bashing interface.

Parameters
basherBit-bashing interface

Definition at line 76 of file bitbash.h.

76 {
77 if ( basher->op->close )
78 basher->op->close ( basher );
79}
void(* close)(struct bit_basher *basher)
Close bit-bashing interface (optional)
Definition bitbash.h:28

References bit_basher_operations::close, and bit_basher::op.

Referenced by i2c_bit_read(), i2c_bit_write(), i2c_reset(), and spi_bit_rw().

◆ write_bit()

void write_bit ( struct bit_basher * basher,
unsigned int bit_id,
unsigned long data )
extern

Set/clear output bit.

Parameters
basherBit-bashing interface
bit_idBit number
dataValue to write

If data is 0, a logic 0 will be written. If data is non-zero, a logic 1 will be written.

Definition at line 45 of file bitbash.c.

46 {
47 basher->op->write ( basher, bit_id, ( data ? -1UL : 0 ) );
48}
uint8_t data[48]
Additional event data.
Definition ena.h:11
void(* write)(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
Definition bitbash.h:42

References data, bit_basher::op, and bit_basher_operations::write.

Referenced by mii_bit_rw(), mii_bit_xfer(), setscl(), setsda(), spi_bit_rw(), spi_bit_set_slave_select(), and spi_bit_transfer().

◆ read_bit()

int read_bit ( struct bit_basher * basher,
unsigned int bit_id )
extern

Read input bit.

Parameters
basherBit-bashing interface
bit_idBit number
Return values
dataValue read

data will always be either 0 or -1UL. The idea is that the caller can simply binary-AND the returned value with whatever mask it needs to apply.

Definition at line 61 of file bitbash.c.

61 {
62 return ( basher->op->read ( basher, bit_id ) ? -1UL : 0 );
63}
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
Definition bitbash.h:52

References bit_basher::op, and bit_basher_operations::read.

Referenced by getsda(), mii_bit_xfer(), and spi_bit_transfer().