1 #ifndef _IPXE_BITBASH_H
2 #define _IPXE_BITBASH_H
6 * Bit-bashing interfaces
10 FILE_LICENCE ( GPL2_OR_LATER );
14 /** Bit-bashing operations */
15 struct bit_basher_operations {
17 * Open bit-bashing interface (optional)
19 * @v basher Bit-bashing interface
21 void ( * open ) ( struct bit_basher *basher );
23 * Close bit-bashing interface (optional)
25 * @v basher Bit-bashing interface
27 void ( * close ) ( struct bit_basher *basher );
29 * Set/clear output bit
31 * @v basher Bit-bashing interface
32 * @v bit_id Bit number
33 * @v data Value to write
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.
41 void ( * write ) ( struct bit_basher *basher, unsigned int bit_id,
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
51 int ( * read ) ( struct bit_basher *basher, unsigned int bit_id );
54 /** A bit-bashing interface */
56 /** Bit-bashing operations */
57 struct bit_basher_operations *op;
61 * Open bit-bashing interface
63 * @v basher Bit-bashing interface
65 static inline void open_bit ( struct bit_basher *basher ) {
66 if ( basher->op->open )
67 basher->op->open ( basher );
71 * Close bit-bashing interface
73 * @v basher Bit-bashing interface
75 static inline void close_bit ( struct bit_basher *basher ) {
76 if ( basher->op->close )
77 basher->op->close ( basher );
80 extern void write_bit ( struct bit_basher *basher, unsigned int bit_id,
82 extern int read_bit ( struct bit_basher *basher, unsigned int bit_id );
84 #endif /* _IPXE_BITBASH_H */