os/libc/memory.h

59 lines
1.6 KiB
C
Raw Normal View History

2020-07-26 15:38:29 -05:00
/**
* \file
*/
#ifndef MEMORY_H
#define MEMORY_H
#include <stddef.h>
2020-07-26 15:38:29 -05:00
#define BLK_SZ 4096 //!< Page size of the architecture
2020-07-26 15:38:29 -05:00
/**
* Allocates pages of memory
* \param num_pages The number of pages to allocate
* \return the start address of the pages
*/
void* alloc_memory(int num_pages);
2020-07-26 15:38:29 -05:00
/**
* Allocates pages of memory at a specified start address
* \param num_pages The number of pages to allocate
* \param addr The start address of the pages
*/
void alloc_memory_virt(int num_pages,void* addr);
2020-07-26 15:38:29 -05:00
/**
* Creates a new address space with kernel mappings
* \return a pointer to the new address space in physical memory
*/
void* new_address_space();
2020-07-26 15:38:29 -05:00
/**
* Copy data into an address space at a specified virtual address
* \param address_space The adress space to copy data to.
2020-07-26 15:38:29 -05:00
* \param data The data to copy
* \param size The size of the data
* \param virt_addr The address to copy the data to in the address space
*/
void copy_data(void* address_space, void* data,size_t size,void* virt_addr);
2020-07-26 15:38:29 -05:00
/**
* Put data into an address space at an unknown virtual address
* \param address_space The adress space to copy data to.
2020-07-26 15:38:29 -05:00
* \param data The data to copy
* \param size The size of the data
* \return The address that the data was copied to.
*/
void* put_data(void* address_space, void* data,size_t size);
2020-07-26 15:38:29 -05:00
/**
* Map physical pages into virtual memory
* \param phys_addr the start of the physical memory block to map
* \param num_pages the number of pages to map
* \return the start address of the mapping in virtual memory
*/
void* map_phys(void* phys_addr,size_t num_pages);
#endif