XenevaOS
Loading...
Searching...
No Matches
Classes | Functions
liballoc.h File Reference
#include <stdint.h>
#include <aurora.h>
Include dependency graph for liballoc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  boundary_tag
 

Functions

int liballoc_lock ()
 
int liballoc_unlock ()
 
void * liballoc_alloc (int)
 
int liballoc_free (void *, int)
 
void * port_malloc (unsigned int)
 
void * port_realloc (void *, unsigned int)
 
void * port_calloc (unsigned long long, unsigned long long)
 
void port_free (void *)
 

Function Documentation

◆ liballoc_alloc()

void * liballoc_alloc ( int  pages)

This is the hook into the local system which allocates pages. It accepts an integer parameter which is the number of pages required. The page size was set up in the liballoc_init function.

Returns
NULL if the pages were not allocated.
A pointer to the allocated memory.

◆ liballoc_free()

int liballoc_free ( void *  ptr,
int  pages 
)

This frees previously allocated memory. The void* parameter passed to the function is the exact same value returned from a previous liballoc_alloc call.

The integer value is the number of pages to free.

Returns
0 if the memory was successfully freed.

◆ liballoc_lock()

int liballoc_lock ( )

This function is supposed to lock the memory data structures. It could be as simple as disabling interrupts or acquiring a spinlock. It's up to you to decide.

Returns
0 if the lock was acquired successfully. Anything else is failure.

◆ liballoc_unlock()

int liballoc_unlock ( )

This function unlocks what was previously locked by the liballoc_lock function. If it disabled interrupts, it enables interrupts. If it had acquiried a spinlock, it releases the spinlock. etc.

Returns
0 if the lock was successfully released.

◆ port_calloc()

void * port_calloc ( unsigned long long  nobj,
unsigned long long  size 
)

◆ port_free()

void port_free ( void *  ptr)

◆ port_malloc()

void * port_malloc ( unsigned int  size)

◆ port_realloc()

void * port_realloc ( void *  p,
unsigned int  size 
)