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