MyOS Libc
memory.h File Reference
#include <stddef.h>

Go to the source code of this file.

Macros

#define BLK_SZ   4096
 Page size of the architecture.
 

Functions

void * alloc_memory (int num_pages)
 
void alloc_memory_virt (int num_pages, void *addr)
 
void * new_address_space ()
 
void copy_data (void *address_space, void *data, size_t size, void *virt_addr)
 
void * put_data (void *address_space, void *data, size_t size)
 
void * map_phys (void *phys_addr, size_t num_pages)
 

Function Documentation

◆ alloc_memory()

void* alloc_memory ( int  num_pages)

Allocates pages of memory

Parameters
num_pagesThe number of pages to allocate
Returns
the start address of the pages

◆ alloc_memory_virt()

void alloc_memory_virt ( int  num_pages,
void *  addr 
)

Allocates pages of memory at a specified start address

Parameters
num_pagesThe number of pages to allocate
addrThe start address of the pages

◆ copy_data()

void copy_data ( void *  address_space,
void *  data,
size_t  size,
void *  virt_addr 
)

Copy data into an address space at a specified virtual address

Parameters
address_spaceThe adress space to copy data to.
dataThe data to copy
sizeThe size of the data
virt_addrThe address to copy the data to in the address space

◆ map_phys()

void* map_phys ( void *  phys_addr,
size_t  num_pages 
)

Map physical pages into virtual memory

Parameters
phys_addrthe start of the physical memory block to map
num_pagesthe number of pages to map
Returns
the start address of the mapping in virtual memory

◆ new_address_space()

void* new_address_space ( )

Creates a new address space with kernel mappings

Returns
a pointer to the new address space in physical memory

◆ put_data()

void* put_data ( void *  address_space,
void *  data,
size_t  size 
)

Put data into an address space at an unknown virtual address

Parameters
address_spaceThe adress space to copy data to.
dataThe data to copy
sizeThe size of the data
Returns
The address that the data was copied to.