iPXE
bitbash.h
Go to the documentation of this file.
1 #ifndef _IPXE_BITBASH_H
2 #define _IPXE_BITBASH_H
3 
4 /** @file
5  *
6  * Bit-bashing interfaces
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 struct bit_basher;
13 
14 /** Bit-bashing operations */
16  /**
17  * Open bit-bashing interface (optional)
18  *
19  * @v basher Bit-bashing interface
20  */
21  void ( * open ) ( struct bit_basher *basher );
22  /**
23  * Close bit-bashing interface (optional)
24  *
25  * @v basher Bit-bashing interface
26  */
27  void ( * close ) ( struct bit_basher *basher );
28  /**
29  * Set/clear output bit
30  *
31  * @v basher Bit-bashing interface
32  * @v bit_id Bit number
33  * @v data Value to write
34  *
35  * @c data will be 0 if a logic 0 should be written (i.e. the
36  * bit should be cleared), or -1UL if a logic 1 should be
37  * written (i.e. the bit should be set). This is done so that
38  * the method may simply binary-AND @c data with the
39  * appropriate bit mask.
40  */
41  void ( * write ) ( struct bit_basher *basher, unsigned int bit_id,
42  unsigned long data );
43  /**
44  * Read input bit
45  *
46  * @v basher Bit-bashing interface
47  * @v bit_id Bit number
48  * @ret zero Input is a logic 0
49  * @ret non-zero Input is a logic 1
50  */
51  int ( * read ) ( struct bit_basher *basher, unsigned int bit_id );
52 };
53 
54 /** A bit-bashing interface */
55 struct bit_basher {
56  /** Bit-bashing operations */
58 };
59 
60 /**
61  * Open bit-bashing interface
62  *
63  * @v basher Bit-bashing interface
64  */
65 static inline void open_bit ( struct bit_basher *basher ) {
66  if ( basher->op->open )
67  basher->op->open ( basher );
68 }
69 
70 /**
71  * Close bit-bashing interface
72  *
73  * @v basher Bit-bashing interface
74  */
75 static inline void close_bit ( struct bit_basher *basher ) {
76  if ( basher->op->close )
77  basher->op->close ( basher );
78 }
79 
80 extern void write_bit ( struct bit_basher *basher, unsigned int bit_id,
81  unsigned long data );
82 extern int read_bit ( struct bit_basher *basher, unsigned int bit_id );
83 
84 #endif /* _IPXE_BITBASH_H */
static void open_bit(struct bit_basher *basher)
Open bit-bashing interface.
Definition: bitbash.h:65
Bit-bashing operations.
Definition: bitbash.h:15
struct bit_basher_operations * op
Bit-bashing operations.
Definition: bitbash.h:57
void(* close)(struct bit_basher *basher)
Close bit-bashing interface (optional)
Definition: bitbash.h:27
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
Definition: bitbash.h:51
A bit-bashing interface.
Definition: bitbash.h:55
int read_bit(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
Definition: bitbash.c:60
void(* write)(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
Definition: bitbash.h:41
void write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
Definition: bitbash.c:44
uint8_t data[48]
Additional event data.
Definition: ena.h:22
static void close_bit(struct bit_basher *basher)
Close bit-bashing interface.
Definition: bitbash.h:75
void(* open)(struct bit_basher *basher)
Open bit-bashing interface (optional)
Definition: bitbash.h:21