lona.kernel¶
Low-level seL4 kernel intrinsics. Used by VM runtime and system code, not application developers.
System Info¶
arch¶
Get current CPU architecture.
Use for architecture-specific code paths (e.g., selecting page table types).
;; @todo
(keyword? (arch)) ; => true
;; arch returns one of the supported architectures
(or (= (arch) :x86_64) (= (arch) :aarch64)) ; => true
IPC Operations¶
seL4 IPC is synchronous and uses endpoints.
send!¶
Blocking send.
send-nb!¶
Non-blocking send.
Message dropped if no receiver.
;; @todo
;; Non-blocking send returns immediately
(def ep endpoint) ; assume endpoint exists
(def mi (msg-info 0 0 0))
(send-nb! ep mi) ; => :ok
recv!¶
Blocking receive.
recv-nb!¶
Non-blocking receive.
;; @todo
;; Non-blocking receive returns nil if no message
(def result (recv-nb! endpoint))
(or (nil? result) (tuple? result)) ; => true
call!¶
RPC: send + receive.
;; @todo
;; call! returns a tuple
(def mi (msg-info 0 0 0))
(def result (call! endpoint mi))
(tuple? result) ; => true
reply!¶
Reply to caller.
reply-recv!¶
Reply + receive (server fast-path).
yield!¶
Voluntarily give up the current timeslice, allowing other threads to run.
Implementation note: Currently implemented via seL4's seL4_SchedContext_YieldTo.
This is an implementation detail and may change; do not rely on specific yield-to
semantics.
Notification Operations¶
Asynchronous signaling.
signal!¶
Signal notification.
ORs badge into notification word, wakes waiters.
wait!¶
Wait for notification.
Blocks until signaled, returns and clears word.
;; @todo
;; wait! returns an integer badge
(def n (make-notification))
(signal! n)
(integer? (wait! n)) ; => true
poll!¶
Poll notification.
TCB Operations¶
Thread Control Block management.
tcb-configure!¶
Configure TCB.
Options: :fault-ep, :cspace-root, :cspace-data, :vspace-root, :vspace-data, :ipc-buffer, :ipc-buffer-addr.
tcb-set-space!¶
Set TCB's CSpace and VSpace.
tcb-set-ipc-buffer!¶
Set IPC buffer.
tcb-set-priority!¶
Set priority (0-255).
tcb-set-mc-priority!¶
Set max controlled priority.
tcb-set-sched-params!¶
Set scheduling parameters (MCS).
Options: :priority, :mcp, :sched-context, :fault-ep.
tcb-set-affinity!¶
Pin to CPU core.
tcb-resume!¶
Make thread runnable.
tcb-suspend!¶
Pause thread.
tcb-read-regs¶
Read registers from suspended thread.
;; @todo
(def regs (tcb-read-regs tcb 10 false))
(map? regs) ; => true
(contains? regs :pc) ; => true
(contains? regs :sp) ; => true
(contains? regs :regs) ; => true
tcb-write-regs!¶
Write registers.
tcb-bind-notification!¶
Bind notification to TCB.
tcb-unbind-notification!¶
Unbind notification.
CNode Operations¶
Capability space management.
cap-copy!¶
Copy capability with rights mask.
cap-mint!¶
Copy with badge.
cap-move!¶
Move capability.
cap-mutate!¶
Move with modified guard.
cap-delete!¶
Delete capability.
cap-revoke!¶
Delete capability and all derivatives.
cap-rotate!¶
Atomic three-way move.
cap-save-caller!¶
Save reply capability.
Untyped Operations¶
untyped-retype!¶
Convert untyped to typed objects.
Common types:
:tcb, :endpoint, :notification, :cnode, :sched-context
Frame types:
:frame-4k, :frame-2m, :frame-1g
Page table types (architecture-specific):
| x86_64 | ARM64 (aarch64) | Description |
|---|---|---|
:pml4 |
:pgd |
Root page table (VSpace root) |
:pdpt |
:pud |
Level 2 |
:page-directory |
:pmd |
Level 3 |
:page-table |
:pte |
Level 4 (leaf) |
Use (arch) to detect architecture and select appropriate types:
Scheduling Operations (MCS)¶
sched-configure!¶
Configure scheduling context.
Options: :budget, :period, :extra-refills, :badge, :flags.
sched-context-bind!¶
Bind TCB or notification.
sched-context-unbind!¶
Unbind all objects.
sched-context-unbind-object!¶
Unbind specific object.
sched-context-consumed¶
Get consumed CPU time.
;; @todo
(integer? (sched-context-consumed sc)) ; => true
(>= (sched-context-consumed sc) 0) ; => true
IRQ Operations¶
irq-control-get!¶
Create IRQ handler capability.
irq-handler-ack!¶
Acknowledge interrupt.
irq-handler-set-notification!¶
Set notification for IRQ.
irq-handler-clear!¶
Remove IRQ handler.
VSpace Operations¶
page-map!¶
Map frame into address space.
Rights: :read, :write, :execute
Attrs: :cached, :uncached, :device, :write-combine
page-unmap!¶
Unmap frame.
page-get-address¶
Get physical address.
page-table-map!¶
Map page table.
page-table-unmap!¶
Unmap page table.
asid-pool-assign!¶
Assign ASID to VSpace.
Debug Operations¶
Available when kernel built with DEBUG_BUILD.
debug-put-char!¶
Output to kernel serial.
debug-halt!¶
Halt system.
;; @todo
;; debug-halt! halts the entire system - cannot test interactively
;; (debug-halt!) ; Would halt system
debug-dump-scheduler!¶
Dump scheduler state.
debug-cap-identify¶
Identify capability type.
debug-name-thread!¶
Set thread name.
Appendix: Expected Derived Functions¶
All functions in this namespace are intrinsics. No derived functions expected.