[project] Generate syscalls from new interface DSL

This change adds a new interface DSL for specifying objects (with
methods) and interfaces (that expose objects, and optionally have their
own methods).

Significant changes:

- Add the new scripts/definitions Python module to parse the DSL
- Add the new definitions directory containing DSL definition files
- Use cog to generate syscall-related code in kernel and libj6
- Unify ordering of pointer + length pairs in interfaces
This commit is contained in:
Justin C. Miller
2021-08-30 01:05:32 -07:00
parent 80f815c020
commit 186724e751
52 changed files with 4025 additions and 206 deletions

View File

@@ -0,0 +1,3 @@
object channel : kobject {
uid 3ea38b96aa0e54c8
}

View File

@@ -0,0 +1,30 @@
# Channels are objects that enable synchronous IPC of
# arbitrary-sized messages.
object endpoint : kobject {
uid c5882f24a4c03b7e
method create [constructor]
# Send a message on a channel. Blocks until the message
# is received.
method send {
param tag uint64
param data buffer
}
# Receieve a message on a channel. Blocks until a message
# is available.
method receive {
param tag uint64 [out]
param data buffer [out]
}
# Send a message on a channel and then await a new message.
# Equivalent to calling send and then recieve, as a single
# operation.
method sendrecv {
param tag uint64 [inout]
param data buffer [inout]
}
}

View File

@@ -0,0 +1,25 @@
# The base type of all kernel-exposed objects
object kobject [virtual] {
uid 667f61fb2cd57bb4
# Get the internal kernel object id of an object
method koid {
param koid uint64 [out]
}
# Block the current thread waiting for an object to assert
# one of a set of signals
method wait {
param mask uint64 # Bitmap of which signals to wait for
param signals uint64 [out] # Returns the state of the signals
}
# Block the current thread waiting for an one of multiple
# objects to assert one of a set of signals
method wait_many [static] {
param handles object kobject [list] # The objects to wait on
param mask uint64 # Bitmap of which signals to wait for
param handle object kobject [out] # Returns the object that signalled
param signals uint64 [out] # Returns the state of the signals
}
}

View File

@@ -0,0 +1,33 @@
# Mailboxes are objects that enable asynchronous IPC via event notification.
# This is a second line of documentation
object mailbox {
uid 99934ad04ece1e07
# Create an unbound mailbox
method create [constructor]
method close [destructor]
method bind {
param index uint
param source object kobject
param event uint
}
method unbind {
param index uint
}
method notify {
param index uint
}
method wait {
param bitmap uint64 [out]
}
method ack {
param bitmap uint64
}
}

View File

@@ -0,0 +1,27 @@
import "objects/kobject.def"
# Processes are a collection of handles and a virtual memory
# space inside which threads are run.
object process : kobject {
uid 0c69ee0b7502ba31
# Create a new empty process
method create [constructor]
# Stop all threads and exit the given process
method kill [destructor]
# Stop all threads and exit the current process
method exit [static] {
param result int32 # The result to retrun to the parent process
}
# Start the given process running. Note that the entrypoint
# address must be specified in the address space of the new
# process.
method start {
param entrypoint address # The address of the main thread entrypoint
param handles object kobject [list] # A list of parent handles to send to the child process
}
}

View File

@@ -0,0 +1,29 @@
import "objects/endpoint.def"
import "objects/vma.def"
# The system object represents a handle to kernel functionality
# needed by drivers and other priviledged services
object system : kobject {
uid fa72506a2cf71a30
# Get a log line from the kernel log
method get_log {
param buffer buffer [out] # Buffer for the log message data structure
}
# Ask the kernel to send this process messages whenever
# the given IRQ fires
method bind_irq {
param dest object endpoint # Endpoint that will receive messages
param irq uint # IRQ number to bind
}
# Create a VMA and map an area of physical memory into it,
# also mapping that VMA into the current process
method map_phys {
param area object vma [out] # Receives a handle to the VMA created
param phys address # The physical address of the area
param size size # Size of the area, in pages
param flags uint32 # Flags to apply to the created VMA
}
}

View File

@@ -0,0 +1,18 @@
object thread : kobject {
uid 11f23e593d5761bd
method create [constructor] {
param entrypoint address
}
method kill [destructor]
method exit [static] {
param status int32
}
method pause [static]
method sleep [static] {
param until uint64
}
}

View File

@@ -0,0 +1,29 @@
import "objects/process.def"
object vma : kobject {
uid d6a12b63b3ed3937
method create [constructor] {
param size size
param flags uint32
}
method create_map [constructor] {
param size size
param address address
param flags uint32
}
method map {
param process object process
param address address
}
method unmap {
param process object process
}
method resize {
param size size [inout]
}
}

27
definitions/syscalls.def Normal file
View File

@@ -0,0 +1,27 @@
import "objects/system.def"
import "objects/kobject.def"
import "objects/process.def"
import "objects/thread.def"
import "objects/channel.def"
import "objects/endpoint.def"
import "objects/vma.def"
interface syscalls [syscall] {
uid 01d9b6a948961097
expose object system
expose object kobject
expose object process
expose object thread
expose object channel
expose object endpoint
expose object vma
# Simple no-op syscall for testing
function noop
# Write a message to the kernel log
function log {
param message string
}
}