Port plat_m(un)map from the VFIO branch

This commit is contained in:
RichardG867
2021-10-16 20:12:49 -03:00
parent e25482db11
commit 5bf8aa2d58
6 changed files with 66 additions and 69 deletions

View File

@@ -302,7 +302,7 @@ plat_get_basename(const char *path)
while (c > 0) {
if (path[c] == '/')
return((char *)&path[c]);
return((char *)&path[c + 1]);
c--;
}
@@ -366,6 +366,19 @@ plat_dir_create(char *path)
return mkdir(path, S_IRWXU);
}
void *
plat_mmap(size_t size, uint8_t executable)
{
void *ret = mmap(0, size, PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0), MAP_ANON | MAP_PRIVATE, 0, 0);
return (ret < 0) ? NULL : ret;
}
void
plat_munmap(void *ptr, size_t size)
{
munmap(ptr, size);
}
uint64_t
plat_timer_read(void)
{