iPXE
mlx_memory_priv.c File Reference
#include <ipxe/malloc.h>
#include <stddef.h>
#include <string.h>
#include <byteswap.h>
#include <ipxe/io.h>
#include "../../mlx_utils/include/private/mlx_memory_priv.h"

Go to the source code of this file.

Functions

mlx_status mlx_memory_alloc_priv (IN mlx_utils *utils, IN mlx_size size, OUT mlx_void **ptr)
mlx_status mlx_memory_zalloc_priv (IN mlx_utils *utils, IN mlx_size size, OUT mlx_void **ptr)
mlx_status mlx_memory_free_priv (IN mlx_utils *utils, IN mlx_void *ptr)
mlx_status mlx_memory_alloc_dma_priv (IN mlx_utils *utils, IN mlx_size size, IN mlx_size align, OUT mlx_void **ptr)
mlx_status mlx_memory_free_dma_priv (IN mlx_utils *utils, IN mlx_size size, IN mlx_void *ptr)
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)
mlx_status mlx_memory_ummap_dma_priv (IN mlx_utils *utils, IN mlx_void *mapping)
mlx_status mlx_memory_cmp_priv (IN mlx_utils *utils, IN mlx_void *first_block, IN mlx_void *second_block, IN mlx_size size, OUT mlx_uint32 *out)
mlx_status mlx_memory_set_priv (IN mlx_utils *utils, IN mlx_void *block, IN mlx_int32 value, IN mlx_size size)
mlx_status mlx_memory_cpy_priv (IN mlx_utils *utils, OUT mlx_void *destination_buffer, IN mlx_void *source_buffer, IN mlx_size length)
mlx_status mlx_memory_cpu_to_be32_priv (IN mlx_utils *utils, IN mlx_uint32 source, IN mlx_uint32 *destination)
mlx_status mlx_memory_be32_to_cpu_priv (IN mlx_utils *utils, IN mlx_uint32 source, IN mlx_uint32 *destination)

Function Documentation

◆ mlx_memory_alloc_priv()

mlx_status mlx_memory_alloc_priv ( IN mlx_utils * utils,
IN mlx_size size,
OUT mlx_void ** ptr )

Definition at line 17 of file mlx_memory_priv.c.

22{
24 *ptr = malloc(size);
25 if(*ptr == NULL){
27 }
28 return status;
29}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
uint8_t status
Status.
Definition ena.h:5
uint16_t size
Buffer size.
Definition dwmac.h:3
void * malloc(size_t size)
Allocate memory.
Definition malloc.c:621
#define MLX_SUCCESS
int mlx_status
#define MLX_OUT_OF_RESOURCES

References __attribute__, IN, malloc(), MLX_OUT_OF_RESOURCES, MLX_SUCCESS, NULL, OUT, size, status, and unused.

Referenced by mlx_memory_alloc().

◆ mlx_memory_zalloc_priv()

mlx_status mlx_memory_zalloc_priv ( IN mlx_utils * utils,
IN mlx_size size,
OUT mlx_void ** ptr )

Definition at line 32 of file mlx_memory_priv.c.

37{
39 *ptr = zalloc(size);
40 if(*ptr == NULL){
42 }
43 return status;
44}
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662

References __attribute__, IN, MLX_OUT_OF_RESOURCES, MLX_SUCCESS, NULL, OUT, size, status, unused, and zalloc().

Referenced by mlx_memory_zalloc().

◆ mlx_memory_free_priv()

mlx_status mlx_memory_free_priv ( IN mlx_utils * utils,
IN mlx_void * ptr )

Definition at line 47 of file mlx_memory_priv.c.

51{
53 free(ptr);
54 return status;
55}
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55

References __attribute__, free, IN, MLX_SUCCESS, status, and unused.

Referenced by mlx_memory_free().

◆ mlx_memory_alloc_dma_priv()

mlx_status mlx_memory_alloc_dma_priv ( IN mlx_utils * utils,
IN mlx_size size,
IN mlx_size align,
OUT mlx_void ** ptr )

Definition at line 57 of file mlx_memory_priv.c.

63{
65 *ptr = malloc_phys(size, align);
66 if (*ptr == NULL) {
68 } else {
69 memset(*ptr, 0, size);
70 }
71 return status;
72}
void * memset(void *dest, int character, size_t len) __nonnull
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707

References __attribute__, IN, malloc_phys(), memset(), MLX_OUT_OF_RESOURCES, MLX_SUCCESS, NULL, OUT, size, status, and unused.

Referenced by mlx_memory_alloc_dma().

◆ mlx_memory_free_dma_priv()

mlx_status mlx_memory_free_dma_priv ( IN mlx_utils * utils,
IN mlx_size size,
IN mlx_void * ptr )

Definition at line 75 of file mlx_memory_priv.c.

80{
82 free_phys(ptr, size);
83 return status;
84}
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723

References __attribute__, free_phys(), IN, MLX_SUCCESS, size, status, and unused.

Referenced by mlx_memory_free_dma().

◆ mlx_memory_map_dma_priv()

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 )

Definition at line 86 of file mlx_memory_priv.c.

93{
95 *phys_addr = virt_to_bus(addr);
96 return status;
97}
uint32_t addr
Buffer address.
Definition dwmac.h:9
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184

References __attribute__, addr, IN, MLX_SUCCESS, OUT, status, unused, and virt_to_bus().

Referenced by mlx_memory_map_dma().

◆ mlx_memory_ummap_dma_priv()

mlx_status mlx_memory_ummap_dma_priv ( IN mlx_utils * utils,
IN mlx_void * mapping )

Definition at line 100 of file mlx_memory_priv.c.

104{
106 return status;
107}

References __attribute__, IN, MLX_SUCCESS, status, and unused.

Referenced by mlx_memory_ummap_dma().

◆ mlx_memory_cmp_priv()

mlx_status mlx_memory_cmp_priv ( IN mlx_utils * utils,
IN mlx_void * first_block,
IN mlx_void * second_block,
IN mlx_size size,
OUT mlx_uint32 * out )

Definition at line 110 of file mlx_memory_priv.c.

117{
119 *out = memcmp(first_block, second_block, size);
120 return status;
121}
__be32 out[4]
Definition CIB_PRM.h:8
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115

References __unused, IN, memcmp(), MLX_SUCCESS, OUT, out, size, and status.

Referenced by mlx_memory_cmp().

◆ mlx_memory_set_priv()

mlx_status mlx_memory_set_priv ( IN mlx_utils * utils,
IN mlx_void * block,
IN mlx_int32 value,
IN mlx_size size )

Definition at line 124 of file mlx_memory_priv.c.

130{
133 return status;
134}
pseudo_bit_t value[0x00020]
Definition arbel.h:2
uint8_t block[3][8]
DES-encrypted blocks.
Definition mschapv2.h:1

References __unused, block, IN, memset(), MLX_SUCCESS, size, status, and value.

Referenced by mlx_memory_set().

◆ mlx_memory_cpy_priv()

mlx_status mlx_memory_cpy_priv ( IN mlx_utils * utils,
OUT mlx_void * destination_buffer,
IN mlx_void * source_buffer,
IN mlx_size length )

Definition at line 137 of file mlx_memory_priv.c.

143{
145 memcpy(destination_buffer, source_buffer, length);
146 return status;
147}
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u16 length
Definition sky2.h:1

References __unused, IN, length, memcpy(), MLX_SUCCESS, OUT, and status.

Referenced by mlx_memory_cpy().

◆ mlx_memory_cpu_to_be32_priv()

mlx_status mlx_memory_cpu_to_be32_priv ( IN mlx_utils * utils,
IN mlx_uint32 source,
IN mlx_uint32 * destination )

Definition at line 150 of file mlx_memory_priv.c.

155{
157 *destination = cpu_to_be32(source);
158 return status;
159}
#define cpu_to_be32(value)
Definition byteswap.h:111

References __unused, cpu_to_be32, IN, MLX_SUCCESS, and status.

Referenced by mlx_memory_cpu_to_be32().

◆ mlx_memory_be32_to_cpu_priv()

mlx_status mlx_memory_be32_to_cpu_priv ( IN mlx_utils * utils,
IN mlx_uint32 source,
IN mlx_uint32 * destination )

Definition at line 163 of file mlx_memory_priv.c.

168{
170 *destination = be32_to_cpu(source);
171 return status;
172}
#define be32_to_cpu(value)
Definition byteswap.h:117

References __unused, be32_to_cpu, IN, MLX_SUCCESS, and status.

Referenced by mlx_memory_be32_to_cpu().