matos/core/uaddrspace.h

48 lines
1.5 KiB
C
Raw Normal View History

2022-08-09 16:15:00 +02:00
#pragma once
#include "mmuContext.h"
#include "process.h"
#include "types.h"
#include <stddef.h>
struct uAddrSpace;
struct uAddrVirtualReg;
2023-11-10 09:01:55 +01:00
// 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;
};
2022-08-09 16:15:00 +02:00
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);
2022-09-03 23:32:31 +02:00
int uAddrSpaceCheckNAlloc(struct uAddrSpace *as, vaddr_t addr);
2022-08-09 16:15:00 +02:00
uaddr_t sysBrk(struct uAddrSpace *as, uaddr_t newHeapTop);
2023-11-10 09:01:55 +01:00
int uAddrSpaceMmap(struct uAddrSpace *as, uaddr_t *uaddr, size_t size, uint32_t rights, uint32_t flags,
struct mappedRessource *res);