diff --git a/definitions/objects/system.def b/definitions/objects/system.def index f206c12..0b6188d 100644 --- a/definitions/objects/system.def +++ b/definitions/objects/system.def @@ -26,4 +26,10 @@ object system : kobject { param size size # Size of the area, in pages param flags uint32 # Flags to apply to the created VMA } + + # Request the kernel change the IOPL for this process. The only values + # that make sense are 0 and 3. + method request_iopl { + param iopl uint # The IOPL to set for this process + } } diff --git a/src/kernel/syscalls/system.cpp b/src/kernel/syscalls/system.cpp index 90928e5..5cdb730 100644 --- a/src/kernel/syscalls/system.cpp +++ b/src/kernel/syscalls/system.cpp @@ -1,6 +1,7 @@ #include "j6/errors.h" #include "j6/types.h" +#include "cpu.h" #include "device_manager.h" #include "frame_allocator.h" #include "log.h" @@ -77,4 +78,17 @@ system_map_phys(j6_handle_t handle, j6_handle_t * area, uintptr_t phys, size_t s return j6_status_ok; } +j6_status_t +system_request_iopl(j6_handle_t handle, unsigned iopl) +{ + // TODO: check capabilities on sys handle + if (iopl != 0 && iopl != 3) + return j6_err_invalid_arg; + + constexpr uint64_t mask = 3 << 12; + cpu_data &cpu = current_cpu(); + cpu.rflags3 = (cpu.rflags3 & ~mask) | ((iopl << 12) & mask); + return j6_status_ok; +} + } // namespace syscalls