ArchiSys/TP/TP1/rendu/vmap.h

34 lines
765 B
C

#ifndef DEF_VMAP_H
#define DEF_VMAP_H
#include "mmap.h"
typedef struct VMap {
MMap* mmap;
linkedList* pages;
int index; // index of virt memory
} VMap;
typedef struct PageMapInfo {
int start;
int key; // key for mmap
int cursor; // Last allocation end
int nb_allocs; // Free page if 0
bool swapped;
} PageMapInfo;
VMap* vmap_init();
/**
* Get page hosting a certain pointer
*/
PageMapInfo* vmap_get_page(VMap* vmap, void* ptr);
void vmap_copy_from_memory(struct VMap *vmap, void *src, void *dst, int size);
void vmap_copy_to_memory(struct VMap *vmap, void *src, void *dst, int size);
void* my_malloc(VMap* vmap, int size);
void my_free(VMap* vmap, void* ptr);
void my_copy(VMap* vmap, void* src, void* dst, int size);
#endif