iPXE
bitbash.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25FILE_SECBOOT ( PERMITTED );
26
27#include <ipxe/bitbash.h>
28
29/** @file
30 *
31 * Bit-bashing interfaces
32 *
33 */
34
35/**
36 * Set/clear output bit
37 *
38 * @v basher Bit-bashing interface
39 * @v bit_id Bit number
40 * @v data Value to write
41 *
42 * If @c data is 0, a logic 0 will be written. If @c data is
43 * non-zero, a logic 1 will be written.
44 */
45void write_bit ( struct bit_basher *basher, unsigned int bit_id,
46 unsigned long data ) {
47 basher->op->write ( basher, bit_id, ( data ? -1UL : 0 ) );
48}
49
50/**
51 * Read input bit
52 *
53 * @v basher Bit-bashing interface
54 * @v bit_id Bit number
55 * @ret data Value read
56 *
57 * @c data will always be either 0 or -1UL. The idea is that the
58 * caller can simply binary-AND the returned value with whatever mask
59 * it needs to apply.
60 */
61int read_bit ( struct bit_basher *basher, unsigned int bit_id ) {
62 return ( basher->op->read ( basher, bit_id ) ? -1UL : 0 );
63}
int read_bit(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
Definition bitbash.c:61
void write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
Definition bitbash.c:45
Bit-bashing interfaces.
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
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
A bit-bashing interface.
Definition bitbash.h:56
struct bit_basher_operations * op
Bit-bashing operations.
Definition bitbash.h:58