efi_io.h File Reference

gPXE I/O API for EFI More...

Go to the source code of this file.

Defines

#define IOAPI_PREFIX_efi   __efi_

Functions

 FILE_LICENCE (GPL2_OR_LATER)
unsigned long long efi_ioread (volatile void *io_addr, size_t size)
 Read from device.
void efi_iowrite (unsigned long long data, volatile void *io_addr, size_t size)
 Write to device.
void efi_ioreads (volatile void *io_addr, void *data, size_t size, unsigned int count)
 String read from device.
void efi_iowrites (volatile void *io_addr, const void *data, size_t size, unsigned int count)
 String write to device.
static __always_inline
unsigned long 
IOAPI_INLINE (efi, phys_to_bus)(unsigned long phys_addr)
static __always_inline
unsigned long 
IOAPI_INLINE (efi, bus_to_phys)(unsigned long bus_addr)
static __always_inline void * IOAPI_INLINE (efi, ioremap)(unsigned long bus_addr


Detailed Description

gPXE I/O API for EFI

EFI runs with flat physical addressing, so the various mappings between virtual addresses, I/O addresses and bus addresses are all no-ops. I/O is handled using the EFI_CPU_IO_PROTOCOL.

Definition in file efi_io.h.


Define Documentation

#define IOAPI_PREFIX_efi   __efi_

Definition at line 18 of file efi_io.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

unsigned long long efi_ioread ( volatile void *  io_addr,
size_t  size 
)

Read from device.

Parameters:
io_addr I/O address
size Size of value
Return values:
data Value read

Definition at line 80 of file efi_io.c.

References DBG, efi_strerror(), efi_width(), _EFI_CPU_IO_PROTOCOL::Io, IS_PORT_ADDRESS, _EFI_CPU_IO_PROTOCOL::Mem, and EFI_CPU_IO_PROTOCOL_ACCESS::Read.

00080                                                                       {
00081         EFI_CPU_IO_PROTOCOL_IO_MEM read;
00082         unsigned long long data = 0;
00083         EFI_STATUS efirc;
00084 
00085         read = ( IS_PORT_ADDRESS ( io_addr ) ?
00086                  cpu_io->Io.Read : cpu_io->Mem.Read );
00087 
00088         if ( ( efirc = read ( cpu_io, efi_width ( size ),
00089                               ( intptr_t ) io_addr, 1,
00090                               ( void * ) &data ) ) != 0 ) {
00091                 DBG ( "EFI I/O read at %p failed: %s\n",
00092                       io_addr, efi_strerror ( efirc ) );
00093                 return -1ULL;
00094         }
00095 
00096         return data;
00097 }

void efi_iowrite ( unsigned long long  data,
volatile void *  io_addr,
size_t  size 
)

Write to device.

Parameters:
data Value to write
io_addr I/O address
size Size of value

Definition at line 106 of file efi_io.c.

References DBG, efi_strerror(), efi_width(), _EFI_CPU_IO_PROTOCOL::Io, IS_PORT_ADDRESS, _EFI_CPU_IO_PROTOCOL::Mem, and EFI_CPU_IO_PROTOCOL_ACCESS::Write.

00107                                  {
00108         EFI_CPU_IO_PROTOCOL_IO_MEM write;
00109         EFI_STATUS efirc;
00110 
00111         write = ( IS_PORT_ADDRESS ( io_addr ) ?
00112                   cpu_io->Io.Write : cpu_io->Mem.Write );
00113 
00114         if ( ( efirc = write ( cpu_io, efi_width ( size ),
00115                                ( intptr_t ) io_addr, 1,
00116                                ( void * ) &data ) ) != 0 ) {
00117                 DBG ( "EFI I/O write at %p failed: %s\n",
00118                       io_addr, efi_strerror ( efirc ) );
00119         }
00120 }

void efi_ioreads ( volatile void *  io_addr,
void *  data,
size_t  size,
unsigned int  count 
)

String read from device.

Parameters:
io_addr I/O address
data Data buffer
size Size of values
count Number of values to read

Definition at line 130 of file efi_io.c.

References DBG, efi_strerror(), efi_width(), _EFI_CPU_IO_PROTOCOL::Io, IS_PORT_ADDRESS, _EFI_CPU_IO_PROTOCOL::Mem, and EFI_CPU_IO_PROTOCOL_ACCESS::Read.

00131                                                      {
00132         EFI_CPU_IO_PROTOCOL_IO_MEM read;
00133         EFI_STATUS efirc;
00134 
00135         read = ( IS_PORT_ADDRESS ( io_addr ) ?
00136                  cpu_io->Io.Read : cpu_io->Mem.Read );
00137 
00138         if ( ( efirc = read ( cpu_io, efi_width ( size ),
00139                               ( intptr_t ) io_addr, count,
00140                               ( void * ) data ) ) != 0 ) {
00141                 DBG ( "EFI I/O string read at %p failed: %s\n",
00142                       io_addr, efi_strerror ( efirc ) );
00143         }
00144 }

void efi_iowrites ( volatile void *  io_addr,
const void *  data,
size_t  size,
unsigned int  count 
)

String write to device.

Parameters:
io_addr I/O address
data Data buffer
size Size of values
count Number of values to write

Definition at line 154 of file efi_io.c.

References DBG, efi_strerror(), efi_width(), _EFI_CPU_IO_PROTOCOL::Io, IS_PORT_ADDRESS, _EFI_CPU_IO_PROTOCOL::Mem, and EFI_CPU_IO_PROTOCOL_ACCESS::Write.

00155                                                       {
00156         EFI_CPU_IO_PROTOCOL_IO_MEM write;
00157         EFI_STATUS efirc;
00158 
00159         write = ( IS_PORT_ADDRESS ( io_addr ) ?
00160                  cpu_io->Io.Write : cpu_io->Mem.Write );
00161 
00162         if ( ( efirc = write ( cpu_io, efi_width ( size ),
00163                                ( intptr_t ) io_addr, count,
00164                                ( void * ) data ) ) != 0 ) {
00165                 DBG ( "EFI I/O write at %p failed: %s\n",
00166                       io_addr, efi_strerror ( efirc ) );
00167         }
00168 }

static __always_inline unsigned long IOAPI_INLINE ( efi  ,
phys_to_bus   
) [inline, static]

Definition at line 38 of file efi_io.h.

00038                                                               {
00039         return phys_addr;
00040 }

static __always_inline unsigned long IOAPI_INLINE ( efi  ,
bus_to_phys   
) [inline, static]

Definition at line 43 of file efi_io.h.

00043                                                              {
00044         return bus_addr;
00045 }

static __always_inline void* IOAPI_INLINE ( efi  ,
ioremap   
) [inline, static]


Generated on Tue Apr 6 20:01:48 2010 for gPXE by  doxygen 1.5.7.1