[kernel] Create system_map_mmio syscall

Create a syscall for drivers to be able to ask the kernel for a VMA that
maps a MMIO area. Also expose vm_flags via j6 table style include file
and new flags.h header.
This commit is contained in:
Justin C. Miller
2021-02-04 19:42:45 -08:00
parent 2244764777
commit b898949ffc
5 changed files with 36 additions and 14 deletions

View File

@@ -17,20 +17,9 @@ class vm_space;
enum class vm_flags : uint32_t
{
none = 0x00000000,
write = 0x00000001,
exec = 0x00000002,
zero = 0x00000010,
contiguous = 0x00000020,
large_pages = 0x00000100,
huge_pages = 0x00000200,
mmio = 0x00010000,
write_combine = 0x00020000,
#define VM_FLAG(name, v) name = v,
#include "j6/tables/vm_flags.inc"
#undef VM_FLAG
user_mask = 0x0000ffff ///< flags allowed via syscall
};

View File

@@ -6,6 +6,7 @@
#include "objects/endpoint.h"
#include "objects/thread.h"
#include "objects/system.h"
#include "objects/vm_area.h"
#include "syscalls/helpers.h"
extern log::logger &g_logger;
@@ -58,4 +59,16 @@ system_bind_irq(j6_handle_t sys, j6_handle_t endp, unsigned irq)
return j6_err_invalid_arg;
}
j6_status_t
system_map_mmio(j6_handle_t sys, j6_handle_t *vma_handle, uintptr_t phys_addr, size_t size, uint32_t flags)
{
// TODO: check capabilities on sys handle
if (!vma_handle) return j6_err_invalid_arg;
vm_flags vmf = vm_flags::mmio | (static_cast<vm_flags>(flags) & vm_flags::user_mask);
construct_handle<vm_area_fixed>(vma_handle, phys_addr, size, vmf);
return j6_status_ok;
}
} // namespace syscalls