Macros | Functions | Variables
platform.c File Reference

Go to the source code of this file.

Macros

#define _POSIX_C_SOURCE   200809L
 
#define PAGE_ROUND_UP(x)   ( (((uintptr_t)(x)) + MAX_PAGE_SIZE-1) & (~(MAX_PAGE_SIZE-1)) )
 

Functions

int verify_no_mem_leaks (void)
 
void * platform_alloc_rw (uint64_t len)
 
void * platform_alloc_rwe (uint64_t len)
 
void platform_free_rw (void *addr, uint64_t len)
 
void platform_free_rwe (void *addr, uint64_t len)
 
void * platform_virt_to_phys (void *virt)
 
void platform_memset (void *ptr, char value, uint64_t num)
 
void platform_memcpy (void *dst, const void *src, uint64_t num)
 
void platform_start (void)
 
void platform_stop (void)
 
int64_t platform_num_cpus (void)
 
int64_t platform_set_affinity (int64_t affinity)
 
void platform_restore_affinity (int64_t affinity)
 
void platform_vmcall (struct vmcall_registers_t *regs)
 
void platform_vmcall_event (struct vmcall_registers_t *regs)
 

Variables

int alloc_count_rw = 0
 
int alloc_count_rwe = 0
 
uint64_t g_malloc_fails = 0
 
uint64_t g_set_afinity_fails = 0
 
uint64_t g_vmcall = 0
 

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

Definition at line 23 of file platform.c.

◆ PAGE_ROUND_UP

#define PAGE_ROUND_UP (   x)    ( (((uintptr_t)(x)) + MAX_PAGE_SIZE-1) & (~(MAX_PAGE_SIZE-1)) )

Definition at line 35 of file platform.c.

Function Documentation

◆ verify_no_mem_leaks()

int verify_no_mem_leaks ( void  )

Definition at line 42 of file platform.c.

◆ platform_alloc_rw()

void* platform_alloc_rw ( uint64_t  len)

Allocate Memory

Used by the common code to allocate virtual memory.

Parameters
lenthe size of virtual memory to be allocated in bytes.
Returns
a virtual address pointing to the newly allocated memory

Definition at line 51 of file platform.c.

◆ platform_alloc_rwe()

void* platform_alloc_rwe ( uint64_t  len)

Allocate Executable Memory

Used by the common code to allocate executable virtual memory.

Parameters
lenthe size of virtual memory to be allocated in bytes.
Returns
a virtual address pointing to the newly allocated memory

Definition at line 63 of file platform.c.

◆ platform_free_rw()

void platform_free_rw ( void *  addr,
uint64_t  len 
)

Free Memory

Used by the common code to free virtual memory that was allocated using the platform_alloc function.

Parameters
addrthe virtual address returned from platform_alloc
lenthe size of the memory allocated

Definition at line 87 of file platform.c.

◆ platform_free_rwe()

void platform_free_rwe ( void *  addr,
uint64_t  len 
)

Free Executable Memory

Used by the common code to free virtual memory that was allocated using the platform_alloc_exec function.

Parameters
addrthe virtual address returned from platform_alloc_exec
lenthe size of the memory allocated

Definition at line 96 of file platform.c.

◆ platform_virt_to_phys()

void* platform_virt_to_phys ( void *  virt)

Convert Virtual Address to Physical Address

Given a virtual address, this function returns the associated physical address. Note that any page pool issues should be handle by the platform (i.e. the users of this function should be able to provide any virtual address, regardless of where the address originated from).

Parameters
virtthe virtual address to convert
Returns
the physical address assocaited with the provided virtual address

Definition at line 105 of file platform.c.

◆ platform_memset()

void platform_memset ( void *  ptr,
char  value,
uint64_t  num 
)

Memset

Parameters
ptra pointer to the memory to set
valuethe value to set each byte to
numthe number of bytes to set

Definition at line 111 of file platform.c.

◆ platform_memcpy()

void platform_memcpy ( void *  dst,
const void *  src,
uint64_t  num 
)

Memcpy

Parameters
dsta pointer to the memory to copy to
srca pointer to the memory to copy from
numthe number of bytes to copy

Definition at line 120 of file platform.c.

◆ platform_start()

void platform_start ( void  )

Start

Run after the start function has been executed.

Definition at line 129 of file platform.c.

◆ platform_stop()

void platform_stop ( void  )

Stop

Run after the stop function has been executed.

Definition at line 134 of file platform.c.

◆ platform_num_cpus()

int64_t platform_num_cpus ( void  )

Get Number of CPUs

Returns
returns the total number of CPUs available to the driver.

Definition at line 139 of file platform.c.

◆ platform_set_affinity()

int64_t platform_set_affinity ( int64_t  affinity)

Set CPU affinity

Changes the current core that the driver is running on.

Parameters
affinitythe cpu number to change to
Returns
The affinity mask of the CPU before the change

Definition at line 145 of file platform.c.

◆ platform_restore_affinity()

void platform_restore_affinity ( int64_t  affinity)

Restore CPU affinity

If an OS requires the cores used by the user space thread to match on return from a call into the kernel (e.g. IOCTL), reset the affinity to it's previous state.

Parameters
affinitythe cpu affinity mask.

Definition at line 156 of file platform.c.

◆ platform_vmcall()

void platform_vmcall ( struct vmcall_registers_t regs)

VMCall

Parameters
regsthe vmcall registers used in the vmcall

Definition at line 162 of file platform.c.

◆ platform_vmcall_event()

void platform_vmcall_event ( struct vmcall_registers_t regs)

VMCall Event

Parameters
regsthe vmcall registers used in the vmcall

Definition at line 168 of file platform.c.

Variable Documentation

◆ alloc_count_rw

int alloc_count_rw = 0

Definition at line 32 of file platform.c.

◆ alloc_count_rwe

int alloc_count_rwe = 0

Definition at line 33 of file platform.c.

◆ g_malloc_fails

uint64_t g_malloc_fails = 0

Definition at line 37 of file platform.c.

◆ g_set_afinity_fails

uint64_t g_set_afinity_fails = 0

Definition at line 38 of file platform.c.

◆ g_vmcall

uint64_t g_vmcall = 0

Definition at line 39 of file platform.c.