iPXE
mlx_memory_priv.c
Go to the documentation of this file.
1 /*
2  * MemoryPriv.c
3  *
4  * Created on: Jan 21, 2015
5  * Author: maord
6  */
7 
8 #include <ipxe/malloc.h>
9 #include <stddef.h>
10 #include <byteswap.h>
11 #include <ipxe/io.h>
12 #include "../../mlx_utils/include/private/mlx_memory_priv.h"
13 
14 
17  IN mlx_utils *utils __attribute__ ((unused)),
19  OUT mlx_void **ptr
20  )
21 {
23  *ptr = malloc(size);
24  if(*ptr == NULL){
26  }
27  return status;
28 }
29 
32  IN mlx_utils *utils __attribute__ ((unused)),
34  OUT mlx_void **ptr
35  )
36 {
38  *ptr = zalloc(size);
39  if(*ptr == NULL){
41  }
42  return status;
43 }
44 
47  IN mlx_utils *utils __attribute__ ((unused)),
48  IN mlx_void *ptr
49  )
50 {
52  free(ptr);
53  return status;
54 }
57  IN mlx_utils *utils __attribute__ ((unused)),
58  IN mlx_size size ,
59  IN mlx_size align,
60  OUT mlx_void **ptr
61  )
62 {
64  *ptr = malloc_dma(size, align);
65  if (*ptr == NULL) {
67  } else {
68  memset(*ptr, 0, size);
69  }
70  return status;
71 }
72 
75  IN mlx_utils *utils __attribute__ ((unused)),
76  IN mlx_size size ,
77  IN mlx_void *ptr
78  )
79 {
81  free_dma(ptr, size);
82  return status;
83 }
86  IN mlx_utils *utils __attribute__ ((unused)),
87  IN mlx_void *addr ,
88  IN mlx_size number_of_bytes __attribute__ ((unused)),
89  OUT mlx_physical_address *phys_addr,
90  OUT mlx_void **mapping __attribute__ ((unused))
91  )
92 {
94  *phys_addr = virt_to_bus(addr);
95  return status;
96 }
97 
100  IN mlx_utils *utils __attribute__ ((unused)),
101  IN mlx_void *mapping __attribute__ ((unused))
102  )
103 {
105  return status;
106 }
107 
110  IN mlx_utils *utils __unused,
111  IN mlx_void *first_block,
112  IN mlx_void *second_block,
113  IN mlx_size size,
115  )
116 {
118  *out = memcmp(first_block, second_block, size);
119  return status;
120 }
121 
124  IN mlx_utils *utils __unused,
125  IN mlx_void *block,
128  )
129 {
131  memset(block, value, size);
132  return status;
133 }
134 
137  IN mlx_utils *utils __unused,
138  OUT mlx_void *destination_buffer,
139  IN mlx_void *source_buffer,
141  )
142 {
144  memcpy(destination_buffer, source_buffer, length);
145  return status;
146 }
147 
150  IN mlx_utils *utils __unused,
151  IN mlx_uint32 source,
152  IN mlx_uint32 *destination
153  )
154 {
156  *destination = cpu_to_be32(source);
157  return status;
158 }
159 
160 
163  IN mlx_utils *utils __unused,
164  IN mlx_uint32 source,
165  IN mlx_uint32 *destination
166  )
167 {
169  *destination = be32_to_cpu(source);
170  return status;
171 }
172 
uint16_t length
Length.
Definition: intel.h:14
iPXE I/O API
mlx_status mlx_memory_cmp_priv(IN mlx_utils *utils __attribute__((unused)), IN mlx_void *first_block, IN mlx_void *second_block, IN mlx_size size, OUT mlx_uint32 *out)
uint16_t block
Definition: tftp.h:12
mlx_status mlx_memory_free_priv(IN mlx_utils *utils, IN mlx_void *ptr)
mlx_status mlx_memory_cpy_priv(IN mlx_utils *utils __attribute__((unused)), OUT mlx_void *destination_buffer, IN mlx_void *source_buffer, IN mlx_size length)
mlx_status mlx_memory_free_dma_priv(IN mlx_utils *utils, IN mlx_size size, IN mlx_void *ptr)
mlx_status mlx_memory_set_priv(IN mlx_utils *utils __attribute__((unused)), IN mlx_void *block, IN mlx_int32 value, IN mlx_size size)
Dynamic memory allocation.
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
mlx_status mlx_memory_map_dma_priv(IN mlx_utils *utils, IN mlx_void *addr, IN mlx_size number_of_bytes, OUT mlx_physical_address *phys_addr, OUT mlx_void **mapping)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define OUT
Definition: mlx_utils.h:29
#define be32_to_cpu(value)
Definition: byteswap.h:116
int32_t mlx_int32
mlx_status mlx_memory_ummap_dma_priv(IN mlx_utils *utils, IN mlx_void *mapping)
mlx_status mlx_memory_alloc_dma_priv(IN mlx_utils *utils, IN mlx_size size, IN mlx_size align, OUT mlx_void **ptr)
A 16-bit general register.
Definition: registers.h:24
__be32 out[4]
Definition: CIB_PRM.h:36
#define MLX_SUCCESS
mlx_status mlx_memory_alloc_priv(IN mlx_utils *utils, IN mlx_size size, OUT mlx_void **ptr)
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
u32 addr
Definition: sky2.h:8
size_t mlx_size
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
void mlx_void
#define IN
Definition: mlx_utils.h:28
mlx_status mlx_memory_be32_to_cpu_priv(IN mlx_utils *utils __attribute__((unused)), IN mlx_uint32 source, IN mlx_uint32 *destination)
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define MLX_OUT_OF_RESOURCES
uint8_t unused[32]
Unused.
Definition: eltorito.h:15
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
int mlx_status
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned long mlx_physical_address
mlx_status mlx_memory_zalloc_priv(IN mlx_utils *utils, IN mlx_size size, OUT mlx_void **ptr)
void * memset(void *dest, int character, size_t len) __nonnull
mlx_status mlx_memory_cpu_to_be32_priv(IN mlx_utils *utils __attribute__((unused)), IN mlx_uint32 source, IN mlx_uint32 *destination)