matos/drivers/zero.c

46 lines
1.1 KiB
C

#include "zero.h"
#include "alloc.h"
struct zeroMappedEntry {
int refCnt;
};
static int zeroOpen(struct uAddrVirtualReg *vreg)
{
(void)vreg;
return 0;
}
static int zeroClose(struct uAddrVirtualReg *vreg)
{
(void)vreg;
return 0;
}
static int zeroNoPage(struct uAddrVirtualReg *vreg, uaddr_t addr, int right)
{
(void)vreg;
(void)addr;
(void)right;
return 0;
}
static struct mappedRessourceOps zeroOps = {
.open = zeroOpen,
.close = zeroClose,
.unmap = NULL,
.nopage = zeroNoPage,
};
int zeroMmap(struct uAddrSpace *as, uaddr_t *uaddr, size_t size, uint32_t rights, uint32_t flags)
{
struct mappedRessource *res = (struct mappedRessource *)zalloc(sizeof(struct mappedRessource));
struct zeroMappedEntry *cust = (struct zeroMappedEntry *)zalloc(sizeof(struct zeroMappedEntry));
res->allowedRight = PAGING_MEM_READ | PAGING_MEM_WRITE | PAGING_MEM_EXEC | PAGING_MEM_USER;
res->ops = &zeroOps;
res->customData = cust;
uAddrSpaceMmap(as, uaddr, size, rights, flags, res);
return 0;
}