48 lines
1.5 KiB
C
48 lines
1.5 KiB
C
#pragma once
|
|
#include "mmuContext.h"
|
|
#include "process.h"
|
|
#include "types.h"
|
|
#include <stddef.h>
|
|
|
|
struct uAddrSpace;
|
|
struct uAddrVirtualReg;
|
|
|
|
// TODO : move this struct to .c and add accessors
|
|
struct uAddrVirtualReg {
|
|
uaddr_t addr;
|
|
size_t size;
|
|
int right; // PAGING_MEM_*
|
|
uint32_t offset; // in the mappedRessource
|
|
uint flags;
|
|
|
|
struct mappedRessource *res;
|
|
struct uAddrVirtualReg *nextInAddrSpace, *prevInAddrSpace;
|
|
struct uAddrVirtualReg *nextInMappedRes, *prevInMappedRes;
|
|
};
|
|
|
|
struct mappedRessourceOps {
|
|
int (*open)(struct uAddrVirtualReg *vreg);
|
|
int (*close)(struct uAddrVirtualReg *vreg);
|
|
int (*unmap)(struct uAddrVirtualReg *vreg, uaddr_t addr, size_t size);
|
|
int (*nopage)(struct uAddrVirtualReg *vreg, uaddr_t addr,
|
|
int right); // Called by the pageflt handler when the page is missing
|
|
};
|
|
|
|
struct mappedRessource {
|
|
int allowedRight; // PAGING_MEM_*
|
|
struct mappedRessourceOps *ops;
|
|
struct uAddrVirtualReg *listVirtualReg;
|
|
void *customData;
|
|
};
|
|
|
|
|
|
struct uAddrSpace * uAddrSpaceCreate(struct process *proc);
|
|
int uAddrSpaceDelete(struct uAddrSpace *addr);
|
|
struct mmu_context * uAddrSpaceGetMMUContext(struct uAddrSpace *addr);
|
|
int uAddrSpaceSetHeap(struct uAddrSpace *as, uaddr_t addr, size_t size);
|
|
int uAddrSpaceCheckNAlloc(struct uAddrSpace *as, vaddr_t addr);
|
|
uaddr_t sysBrk(struct uAddrSpace *as, uaddr_t newHeapTop);
|
|
|
|
int uAddrSpaceMmap(struct uAddrSpace *as, uaddr_t *uaddr, size_t size, uint32_t rights, uint32_t flags,
|
|
struct mappedRessource *res);
|