mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[kernel] Pass objects not handles to syscall impls
This commit contains a couple large, interdependent changes: - In preparation for capability checking, the _syscall_verify_* functions now load most handles passed in, and verify that they exist and are of the correct type. Lists and out-handles are not converted to objects. - Also in preparation for capability checking, the internal representation of handles has changed. j6_handle_t is now 32 bits, and a new j6_cap_t (also 32 bits) is added. Handles of a process are now a util::map<j6_handle_t, handle> where handle is a new struct containing the id, capabilities, and object pointer. - The kernel object definition DSL gained a few changes to support auto generating the handle -> object conversion in the _syscall_verify_* functions, mostly knowing the object type, and an optional "cname" attribute on objects where their names differ from C++ code. (Specifically vma/vm_area) - Kernel object code and other code under kernel/objects is now in a new obj:: namespace, because fuck you <cstdlib> for putting "system" in the global namespace. Why even have that header then? - Kernel object types constructed with the construct_handle helper now have a creation_caps static member to declare what capabilities a newly created object's handle should have.
This commit is contained in:
@@ -2,6 +2,7 @@ def _indent(x):
|
||||
from textwrap import indent
|
||||
return indent(str(x), ' ')
|
||||
|
||||
class CName(str): pass
|
||||
class Description(str): pass
|
||||
class Import(str): pass
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ class Interface:
|
||||
parts.extend(map(_indent, self.functions))
|
||||
return "\n".join(parts)
|
||||
|
||||
def __methods(self):
|
||||
@property
|
||||
def methods(self):
|
||||
mm = [(i, None, self.functions[i]) for i in range(len(self.functions))]
|
||||
|
||||
base = len(mm)
|
||||
@@ -39,5 +40,3 @@ class Interface:
|
||||
base += len(o.methods)
|
||||
|
||||
return mm
|
||||
|
||||
methods = property(__methods)
|
||||
|
||||
@@ -2,13 +2,14 @@ from . import _indent
|
||||
from . import Options
|
||||
|
||||
class Object:
|
||||
def __init__(self, name, uid, typename=None, opts=Options(), desc="", children=tuple()):
|
||||
def __init__(self, name, uid, typename=None, opts=Options(), desc="", children=tuple(), cname=None):
|
||||
self.name = name
|
||||
self.uid = uid
|
||||
self.options = opts
|
||||
self.desc = desc
|
||||
self.super = typename
|
||||
self.methods = children
|
||||
self.cname = cname or name
|
||||
|
||||
from . import ObjectRef
|
||||
self.__ref = ObjectRef(name)
|
||||
|
||||
@@ -20,11 +20,10 @@ class ObjectRef(Type):
|
||||
|
||||
if "list" in options:
|
||||
two = "size_t"
|
||||
one = f"{one} *"
|
||||
|
||||
if out:
|
||||
one = f"const {one} *"
|
||||
two += " *"
|
||||
else:
|
||||
one = f"{one} *"
|
||||
return ((one, ""), (two, "_count"))
|
||||
|
||||
else:
|
||||
@@ -33,7 +32,13 @@ class ObjectRef(Type):
|
||||
return ((one, ""),)
|
||||
|
||||
def cxx_names(self, options):
|
||||
return self.c_names(options)
|
||||
if not self.needs_object(options):
|
||||
return self.c_names(options)
|
||||
return ((f"obj::{self.name} *", ""),)
|
||||
|
||||
def needs_object(self, options):
|
||||
return not bool({"out", "inout", "list", "handle"}.intersection(options))
|
||||
|
||||
|
||||
@classmethod
|
||||
def connect(cls, objects):
|
||||
|
||||
@@ -11,3 +11,5 @@ class Type:
|
||||
def cxx_names(self, options):
|
||||
raise NotImplemented("Call to base Type.c_names")
|
||||
|
||||
def needs_object(self, options):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user