Skip to content

Types

Common types for zlibc and the zuzu kernel.

#include <types.h>

Types

Type Definition Description
Handle int32_t Index into the Space's object table.
Spid int32_t Space ID.
Tid int32_t Task ID.
Tick uint64_t Tick from the CPU timer.
PhysAddr uintptr_t Physical address in integer form.
VirtAddr uintptr_t Virtual address in integer form.
Irq uint32_t Interrupt number.
Duration uint32_t Duration of time (usually in ms).
Time uint64_t Time, measured in ticks.
Marker uint32_t Stamped value of a distinct object.
Ticket uint32_t Index into a port's held callers queue.
EventWord uint32_t Bits delivered on an event wakeup.

Constants

Name Value Description
TIMEOUT_POLL 0u Pass this sentinel into timeout arguments for the system call to return without blocking.
TIMEOUT_INFINITE UINT32_MAX Pass this sentinel into timeout arguments for the system call to block until the request completes.
TIMESLICE_DEFAULT_US 50000u Default timeslice for a newly created Task.
TIMESLICE_MIN_US 100u The smallest allowed value for a timeslice for a Task.
TIMESLICE_MAX_US 1000000u The largest allowed value for a timeslice for a Task.
HANDLE_ANON ((Handle) - 1) Pass into MemMap() to map anonymous/implicit memory.
MARKER_NONE 0 Sentinel value for an unstamped object's marker.
SIGNAL_BROADCAST (1U << 0) Set this flag in Signal() to wake up all callers at once.
DMA_ALIGN 64U DMA buffer alignment value for cache alignment.
PROT_RW ((PROT_READ) \| (PROT_WRITE)) Protection flag for a read-write memory object.
DEVICE_HANDLE_BASE 16 The base value the Device objects are inserted into rootsvc's object table. devsvc shall start checking from this index.
EVENT_WAIT_ALL (1u << 31) WaitOn argument 3 MSB: waits until all bits are signalled.

Enumerations

HandlePerms

Permissions enum for an object.

Name Value Description
PERM_WAIT 1 This handle can be used for a WaitOn().
PERM_SEND 2 Object with this handle can be Signal()led or Call()ed.
PERM_TXFR 4 Object with this handle can be granted to others.
PERM_MAP 8 Object with this handle can be mapped into the Space.
PERM_CNTL 16 Object with this handle's permissions can be altered.
PERM_WRITE 32 Object with this handle can be mapped writable.
PERM_EXEC 64 Object with this handle can be mapped executable.
PERM_ALL 127 Object with all permissions.

ZuzuObjectCode

Type enum for Create() and Query().

Name Value Description
OBJECT_TASK 0 This handle names a Task object.
OBJECT_SPACE 1 This handle names a Space object.
OBJECT_PORT 2 This handle names a Port object.
OBJECT_EVENT 3 This handle names an Event object.
OBJECT_MEMORY 4 This handle names a Memory object.
OBJECT_CODE_COUNT 5 ZuzuObjectCode enum has this many items.

CreateMemoryFlags

Flags enum for Create().

Name Value Description
MEM_CONTIG 1 This memory is physically contiguous.
MEM_UNCACHED 2 This memory is not cacheable.
MEM_FLAGS_ALL 3 Both flags are OR'ed. Useful for DMA buffers.

DmaDir

Direction enum for DMA memory operations.

Name Value Description
DMA_TO_DEVICE 1 This Memory is read from a DMAC and sent to the device.
DMA_FROM_DEVICE 2 This Memory is written to by a DMAC and read from the device.
DMA_BIDIRECTIONAL 3 This Memory can be read from and written to by a DMAC.

TaskWaitOutcome

Status code of a task that was being waited on.

Name Value Description
TASK_EXITED 0 The task exited voluntarily.
TASK_FAULTED 1 The task faulted, freezing every other Task in the Space.

DmaSyncOp

DmaSync operation verb.

Name Value Description
DMA_SYNC_FOR_DEVICE 0 Make the device synchronize.
DMA_SYNC_FOR_CPU 1 Make the CPU synchronize.

EventType

Event type to bind to a bit of an event.

Name Value Description
EVENT_MEMMGMT 1 Physical memory running low.
EVENT_IRQ 2 Hardware interrupt.
EVENT_PORT 3 Call()ed on port, used to multiplex.
EVENT_TASK 4 A task died.
EVENT_SPACE 5 A space is hollowed out.
EVENT_EVENT 6 Another Event has pending bits.

MemProt

Permission bits for memory objects.

Name Value Description
PROT_READ 1 Read permission.
PROT_WRITE 2 Write permission.
PROT_EXEC 4 Execute permission: cannot be use with Write.

ManageMemoryVerb

ManageMemory operation code.

Name Value Description
MNGMEM_MAP 0 Map implicit or explicit memory.
MNGMEM_UNMAP 1 Map implicit or explicit memory.
MNGMEM_PROTECT 2 Change protection flags.
MNGMEM_INJECTOBJ 3 Inject a memory object to a kitten Space.
MNGMEM_DMAMAP 4 Map DMA memory.
MNGMEM_DMAUNMAP 5 Unmap DMA memory.
MNGMEM_DMASYNC 6 Synchronize hardware during a DMA transfer.
MNGMEM_DMAADOPT 7 Adopt an existing mapping belonging to a device.

QueryWhat

Query operation code.

Name Value Description
QUERY_TYPE 0 Query the type of object this handle is referring to.
QUERY_PERMS 1 Query the permissions this object has.
QUERY_MARKER 2 Query the marker this object has.
QUERY_STATUS 3 Query the status of this object.
QUERY_SIZE 4 Query the size: memory objects only.
QUERY_DMA_COUNT 5 Query the amount of DMA mappings for this device: device mmio objects only.
QUERY_DMA_ID 6 Query the DMA ID for this object: device mmio objects only.
QUERY_DMA_BUS 7 Query the bus ID for this object.
QUERY_DMA_LEN 8 Query the DMA length for this object.
QUERY_DMA_DIR 9 Query the DMA direction for this object.

ManageHandleVerb

ManageHandle operation code.

Name Value Description
MNGHNDL_DUPLICATE 0 Duplicate this object to a new handle.
MNGHNDL_RESTRICT 1 Reduce the permissions of this object.
MNGHNDL_CLOSE 2 Drop the handle to this object, destroy if no one is referencing it.
MNGHNDL_QUERY 3 Query this object.
MNGHNDL_DESTROY 4 If owned by the caller, destroy this object fully.
MNGHNDL_GRANT 5 Grant this object to a kitten.
MNGHNDL_IRQ_REARM 6 Re-arm an interrupt of this device.

ManageTaskVerb

ManageTask operation code.

Name Value Description
MNGTASK_START 0 Start a created task.
MNGTASK_KILL 1 Kill an owned task.
MNGTASK_SET_PRIORITY 2 Change the priority of the caller or an owned task.
MNGTASK_SET_MAX_PRIO 3 Change the max. priority of the caller or an owned task
MNGTASK_SET_TIMESLICE 4 Change the timeslice of the caller or an owned task.
MNGTASK_SUSPEND 5 Suspend an owned task.
MNGTASK_RESUME 6 Resume an owned task.
MNGTASK_GET_REGS 7 Get the register frame of an owned task.
MNGTASK_SET_REGS 8 Change the register frame of an owned task.

Structures

DmaMapArgs

Arguments required to map a DMA buffer.

Field Type Description
dev Handle Device handle for the DMA buffer related to the device.
mem Handle Memory buffer to turn into a DMA buffer. Should be MEM_CONTIG | MEM_UNCACHED.
offset size_t Byte offset into the memory object where the DMA window is.
len size_t Size of the DMA window.
dir DmaDir Direction of DMA.

KickstartArgs

Arguments required to map a DMA buffer.

Field Type Description
entry void * Entry point for the Task.
sp void * Stack point for the Task. Must be mapped.
r0 uint32_t First initial register value for the Task.
r1 uint32_t Second initial register value for the Task.

PortWaitResult

Return values for WaitOn on a port object.

Field Type Description
status Err If the wait succeeded, returns ZUZU_OK. If the request was nonblocking and the wait timed out, it returns ERR_TIMEOUT.
sender Marker Marker assigned to the sender's port object.
xlen uint32_t Length of the message.
granted Handle Handle to a granted object in the receiver's table.

EventWaitResult

Return values for WaitOn on an event object.

Field Type Description
status Err If the wait succeeded, returns ZUZU_OK. If the request was nonblocking and the wait timed out, it returns ERR_TIMEOUT.
bits EventWord The word at the time of wakeup.

TaskWaitResult

Return values for WaitOn on a task object.

Field Type Description
status Err If the wait succeeded, returns ZUZU_OK. If the request was nonblocking and the wait timed out, it returns ERR_TIMEOUT.
outcome TaskWaitOutcome Why the task stopped.
value int32_t If exited gracefully, the task's return code.

SpaceWaitResult

Return values for WaitOn on a space object.

Field Type Description
status Err If the wait succeeded, returns ZUZU_OK. If the request was nonblocking and the wait timed out, it returns ERR_TIMEOUT.
exit_status Err The last task's return code.

DmaMapResult

Return values for DmaMap.

Field Type Description
status Err ZUZU_OK on success, negative on failure.
bus_addr uintptr_t Address as seen by the device.
id uint32_t ID of the mapping, for adoption.

InjectObjArgs

Arguments used to call InjectObj with.

Field Type Description
mem Handle The object to inject into the kitten Space.
dest_vaddr VirtAddr The VA to inject it to.
offset size_t The offset to write it into.
len size_t The length of the object.
prot MemProt The protection flags of the object.