iPXE
Functions
dma.c File Reference

DMA mappings. More...

#include <assert.h>
#include <errno.h>
#include <ipxe/dma.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 PROVIDE_DMAAPI_INLINE (flat, dma_map)
 
 PROVIDE_DMAAPI_INLINE (flat, dma_unmap)
 
 PROVIDE_DMAAPI_INLINE (flat, dma_alloc)
 
 PROVIDE_DMAAPI_INLINE (flat, dma_free)
 
 PROVIDE_DMAAPI_INLINE (flat, dma_umalloc)
 
 PROVIDE_DMAAPI_INLINE (flat, dma_ufree)
 
 PROVIDE_DMAAPI_INLINE (flat, dma_set_mask)
 
 PROVIDE_DMAAPI_INLINE (flat, dma_phys)
 
static int dma_op_map (struct dma_device *dma, struct dma_mapping *map, physaddr_t addr, size_t len, int flags)
 Map buffer for DMA. More...
 
static void dma_op_unmap (struct dma_mapping *map)
 Unmap buffer. More...
 
static void * dma_op_alloc (struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
 Allocate and map DMA-coherent buffer. More...
 
static void dma_op_free (struct dma_mapping *map, void *addr, size_t len)
 Unmap and free DMA-coherent buffer. More...
 
static userptr_t dma_op_umalloc (struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
 Allocate and map DMA-coherent buffer from external (user) memory. More...
 
static void dma_op_ufree (struct dma_mapping *map, userptr_t addr, size_t len)
 Unmap and free DMA-coherent buffer from external (user) memory. More...
 
static void dma_op_set_mask (struct dma_device *dma, physaddr_t mask)
 Set addressable space mask. More...
 
 PROVIDE_DMAAPI (op, dma_map, dma_op_map)
 
 PROVIDE_DMAAPI (op, dma_unmap, dma_op_unmap)
 
 PROVIDE_DMAAPI (op, dma_alloc, dma_op_alloc)
 
 PROVIDE_DMAAPI (op, dma_free, dma_op_free)
 
 PROVIDE_DMAAPI (op, dma_umalloc, dma_op_umalloc)
 
 PROVIDE_DMAAPI (op, dma_ufree, dma_op_ufree)
 
 PROVIDE_DMAAPI (op, dma_set_mask, dma_op_set_mask)
 
 PROVIDE_DMAAPI_INLINE (op, dma_phys)
 

Detailed Description

DMA mappings.

Definition in file dma.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ PROVIDE_DMAAPI_INLINE() [1/9]

PROVIDE_DMAAPI_INLINE ( flat  ,
dma_map   
)

◆ PROVIDE_DMAAPI_INLINE() [2/9]

PROVIDE_DMAAPI_INLINE ( flat  ,
dma_unmap   
)

◆ PROVIDE_DMAAPI_INLINE() [3/9]

PROVIDE_DMAAPI_INLINE ( flat  ,
dma_alloc   
)

◆ PROVIDE_DMAAPI_INLINE() [4/9]

PROVIDE_DMAAPI_INLINE ( flat  ,
dma_free   
)

◆ PROVIDE_DMAAPI_INLINE() [5/9]

PROVIDE_DMAAPI_INLINE ( flat  ,
dma_umalloc   
)

◆ PROVIDE_DMAAPI_INLINE() [6/9]

PROVIDE_DMAAPI_INLINE ( flat  ,
dma_ufree   
)

◆ PROVIDE_DMAAPI_INLINE() [7/9]

PROVIDE_DMAAPI_INLINE ( flat  ,
dma_set_mask   
)

◆ PROVIDE_DMAAPI_INLINE() [8/9]

PROVIDE_DMAAPI_INLINE ( flat  ,
dma_phys   
)

◆ dma_op_map()

static int dma_op_map ( struct dma_device dma,
struct dma_mapping map,
physaddr_t  addr,
size_t  len,
int  flags 
)
static

Map buffer for DMA.

Parameters
dmaDMA device
mapDMA mapping to fill in
addrBuffer address
lenLength of buffer
flagsMapping flags
Return values
rcReturn status code

Definition at line 69 of file dma.c.

70  {
71  struct dma_operations *op = dma->op;
72 
73  if ( ! op )
74  return -ENODEV;
75  return op->map ( dma, map, addr, len, flags );
76 }
uint8_t flags
Flags.
Definition: ena.h:18
#define ENODEV
No such device.
Definition: errno.h:509
DMA operations.
Definition: dma.h:59
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
u32 addr
Definition: sky2.h:8
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436
uint32_t len
Length.
Definition: ena.h:14

References addr, dma(), ENODEV, flags, len, map, and op.

◆ dma_op_unmap()

static void dma_op_unmap ( struct dma_mapping map)
static

Unmap buffer.

Parameters
mapDMA mapping

Definition at line 83 of file dma.c.

83  {
84  struct dma_device *dma = map->dma;
85 
86  assert ( dma != NULL );
87  assert ( dma->op != NULL );
88  dma->op->unmap ( dma, map );
89 }
struct dma_device * dma
DMA device (if unmapping is required)
Definition: dma.h:41
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A DMA-capable device.
Definition: dma.h:47

References assert(), dma_mapping::dma, dma(), map, and NULL.

◆ dma_op_alloc()

static void* dma_op_alloc ( struct dma_device dma,
struct dma_mapping map,
size_t  len,
size_t  align 
)
static

Allocate and map DMA-coherent buffer.

Parameters
dmaDMA device
mapDMA mapping to fill in
lenLength of buffer
alignPhysical alignment
Return values
addrBuffer address, or NULL on error

Definition at line 100 of file dma.c.

101  {
102  struct dma_operations *op = dma->op;
103 
104  if ( ! op )
105  return NULL;
106  return op->alloc ( dma, map, len, align );
107 }
static __always_inline void struct dma_mapping size_t size_t align
Definition: dma.h:222
DMA operations.
Definition: dma.h:59
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436
uint32_t len
Length.
Definition: ena.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References align, dma(), len, map, NULL, and op.

◆ dma_op_free()

static void dma_op_free ( struct dma_mapping map,
void *  addr,
size_t  len 
)
static

Unmap and free DMA-coherent buffer.

Parameters
mapDMA mapping
addrBuffer address
lenLength of buffer

Definition at line 116 of file dma.c.

116  {
117  struct dma_device *dma = map->dma;
118 
119  assert ( dma != NULL );
120  assert ( dma->op != NULL );
121  dma->op->free ( dma, map, addr, len );
122 }
struct dma_device * dma
DMA device (if unmapping is required)
Definition: dma.h:41
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
u32 addr
Definition: sky2.h:8
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436
uint32_t len
Length.
Definition: ena.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A DMA-capable device.
Definition: dma.h:47

References addr, assert(), dma_mapping::dma, dma(), len, map, and NULL.

◆ dma_op_umalloc()

static userptr_t dma_op_umalloc ( struct dma_device dma,
struct dma_mapping map,
size_t  len,
size_t  align 
)
static

Allocate and map DMA-coherent buffer from external (user) memory.

Parameters
dmaDMA device
mapDMA mapping to fill in
lenLength of buffer
alignPhysical alignment
Return values
addrBuffer address, or NULL on error

Definition at line 133 of file dma.c.

135  {
136  struct dma_operations *op = dma->op;
137 
138  if ( ! op )
139  return UNULL;
140  return op->umalloc ( dma, map, len, align );
141 }
static __always_inline void struct dma_mapping size_t size_t align
Definition: dma.h:222
DMA operations.
Definition: dma.h:59
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:42
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436
uint32_t len
Length.
Definition: ena.h:14

References align, dma(), len, map, op, and UNULL.

◆ dma_op_ufree()

static void dma_op_ufree ( struct dma_mapping map,
userptr_t  addr,
size_t  len 
)
static

Unmap and free DMA-coherent buffer from external (user) memory.

Parameters
mapDMA mapping
addrBuffer address
lenLength of buffer

Definition at line 150 of file dma.c.

151  {
152  struct dma_device *dma = map->dma;
153 
154  assert ( dma != NULL );
155  assert ( dma->op != NULL );
156  dma->op->ufree ( dma, map, addr, len );
157 }
struct dma_device * dma
DMA device (if unmapping is required)
Definition: dma.h:41
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
u32 addr
Definition: sky2.h:8
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436
uint32_t len
Length.
Definition: ena.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A DMA-capable device.
Definition: dma.h:47

References addr, assert(), dma_mapping::dma, dma(), len, map, and NULL.

◆ dma_op_set_mask()

static void dma_op_set_mask ( struct dma_device dma,
physaddr_t  mask 
)
static

Set addressable space mask.

Parameters
dmaDMA device
maskAddressable space mask

Definition at line 165 of file dma.c.

165  {
166  struct dma_operations *op = dma->op;
167 
168  if ( op )
169  op->set_mask ( dma, mask );
170 }
DMA operations.
Definition: dma.h:59
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436

References dma(), and op.

◆ PROVIDE_DMAAPI() [1/7]

PROVIDE_DMAAPI ( op  ,
dma_map  ,
dma_op_map   
)

◆ PROVIDE_DMAAPI() [2/7]

PROVIDE_DMAAPI ( op  ,
dma_unmap  ,
dma_op_unmap   
)

◆ PROVIDE_DMAAPI() [3/7]

PROVIDE_DMAAPI ( op  ,
dma_alloc  ,
dma_op_alloc   
)

◆ PROVIDE_DMAAPI() [4/7]

PROVIDE_DMAAPI ( op  ,
dma_free  ,
dma_op_free   
)

◆ PROVIDE_DMAAPI() [5/7]

PROVIDE_DMAAPI ( op  ,
dma_umalloc  ,
dma_op_umalloc   
)

◆ PROVIDE_DMAAPI() [6/7]

PROVIDE_DMAAPI ( op  ,
dma_ufree  ,
dma_op_ufree   
)

◆ PROVIDE_DMAAPI() [7/7]

PROVIDE_DMAAPI ( op  ,
dma_set_mask  ,
dma_op_set_mask   
)

◆ PROVIDE_DMAAPI_INLINE() [9/9]

PROVIDE_DMAAPI_INLINE ( op  ,
dma_phys   
)