14#define HEL_C_LINKAGE extern "C"
27 kHelCallSubmitAsyncNop = 3,
29 kHelCallCreateUniverse = 62,
30 kHelCallTransferDescriptor = 66,
31 kHelCallDescriptorInfo = 32,
32 kHelCallGetCredentials = 84,
33 kHelCallCloseDescriptor = 21,
34 kHelCallObtainHandle = 4,
36 kHelCallCreateQueue = 89,
37 kHelCallDriveQueue = 105,
38 kHelCallAlertQueue = 106,
40 kHelCallAllocateMemory = 51,
41 kHelCallResizeMemory = 83,
42 kHelCallCreateManagedMemory = 64,
43 kHelCallCreateKcovBuffer = 72,
44 kHelCallEnableCoverage = 90,
45 kHelCallDisableCoverage = 92,
46 kHelCallCopyOnWrite = 39,
47 kHelCallAccessPhysical = 30,
48 kHelCallCreateSliceView = 88,
49 kHelCallForkMemory = 40,
50 kHelCallCreateSpace = 27,
51 kHelCallCreateDmaSpace = 108,
52 kHelCallConfigureIrq = 109,
53 kHelCallCreateIndirectMemory = 45,
54 kHelCallAlterMemoryIndirection = 52,
55 kHelCallMapMemory = 44,
56 kHelCallSubmitProtectMemory = 99,
57 kHelCallSubmitSynchronizeSpace = 53,
58 kHelCallUnmapMemory = 36,
59 kHelCallPointerPhysical = 43,
60 kHelCallSubmitReadMemory = 77,
61 kHelCallSubmitWriteMemory = 78,
62 kHelCallMemoryInfo = 26,
63 kHelCallSubmitManageMemory = 46,
64 kHelCallUpdateMemory = 47,
65 kHelCallSubmitLockMemoryView = 48,
66 kHelCallLoadahead = 49,
67 kHelCallCreateVirtualizedSpace = 50,
68 kHelCallCreateSwapSpace = 110,
69 kHelCallAllocateSwappableMemory = 111,
71 kHelCallAccessIommu = 13,
73 kHelCallCreateThread = 67,
74 kHelCallQueryThreadStats = 95,
75 kHelCallSetPriority = 85,
77 kHelCallSubmitObserve = 74,
78 kHelCallKillThread = 87,
79 kHelCallInterruptThread = 86,
81 kHelCallLoadRegisters = 75,
82 kHelCallStoreRegisters = 76,
83 kHelCallQueryRegisterInfo = 102,
84 kHelCallWriteFsBase = 41,
85 kHelCallGetClock = 42,
86 kHelCallSubmitAwaitClock = 80,
87 kHelCallCreateVirtualizedCpu = 37,
88 kHelCallRunVirtualizedCpu = 38,
89 kHelCallAssertVirtualizedIrq = 107,
90 kHelCallKickVirtualizedCpu = 112,
91 kHelCallGetRandomBytes = 101,
92 kHelCallWriteGsBase = 54,
93 kHelCallReadFsBase = 55,
94 kHelCallReadGsBase = 56,
95 kHelCallGetCurrentCpu = 57,
97 kHelCallCreateStream = 68,
98 kHelCallSubmitAsync = 79,
99 kHelCallShutdownLane = 91,
101 kHelCallFutexWait = 73,
102 kHelCallFutexWake = 71,
104 kHelCallCreateOneshotEvent = 96,
105 kHelCallCreateBitsetEvent = 97,
106 kHelCallCreateSequencedEvent = 15,
107 kHelCallRaiseEvent = 98,
108 kHelCallAccessIrq = 14,
109 kHelCallHandleIrq = 5,
110 kHelCallAcknowledgeIrq = 81,
111 kHelCallSubmitAwaitEvent = 82,
112 kHelCallAutomateIrq = 94,
113 kHelCallQueryMsiInfo = 6,
115 kHelCallAccessIo = 11,
116 kHelCallEnableIo = 12,
118 kHelCallBindKernlet = 93,
120 kHelCallGetAffinity = 103,
121 kHelCallSetAffinity = 100,
123 kHelCallCreateToken = 104,
125 kHelCallExtendHierarchy = 7,
127 kHelCallSuper = 0x80000000
132 kHelErrBufferTooSmall = 1,
133 kHelErrBadDescriptor = 2,
135 kHelErrNoDescriptor = 4,
136 kHelErrIllegalSyscall = 5,
137 kHelErrIllegalObject = 6,
138 kHelErrIllegalArgs = 7,
139 kHelErrLaneShutdown = 8,
140 kHelErrEndOfLane = 9,
142 kHelErrThreadTerminated = 11,
143 kHelErrCancelled = 12,
144 kHelErrTransmissionMismatch = 13,
145 kHelErrQueueTooSmall = 14,
146 kHelErrIllegalState = 15,
147 kHelErrNoHardwareSupport = 16,
148 kHelErrNoMemory = 17,
149 kHelErrUnsupportedOperation = 18,
150 kHelErrOutOfBounds = 19,
151 kHelErrDismissed = 20,
152 kHelErrRemoteFault = 21,
153 kHelErrAlreadyExists = 22,
154 kHelErrBadPermissions = 23,
156 kHelErrFutexRace = 25,
157 kHelErrBadRights = 26,
160typedef uint32_t HelRights;
166static const HelRights kHelRightNull = 0;
175static const HelRights kHelRightGrant = UINT32_C(1) << 0;
179static const HelRights kHelRightTake = UINT32_C(1) << 1;
196static const HelRights kHelRightRead = UINT32_C(1) << 2;
212static const HelRights kHelRightWrite = UINT32_C(1) << 3;
216static const HelRights kHelRightExecute = UINT32_C(1) << 4;
221static const HelRights kHelRightInvoke = UINT32_C(1) << 5;
239static const HelRights kHelRightAssign = UINT32_C(1) << 6;
243static const HelRights kHelRightDerive = UINT32_C(1) << 7;
251static const HelRights kHelRightProvision = UINT32_C(1) << 8;
254static const HelRights kHelRightPin = UINT32_C(1) << 9;
257static const HelRights kHelRightFence = UINT32_C(1) << 10;
264static const HelRights kHelRightWait = UINT32_C(1) << 11;
273static const HelRights kHelRightSignal = UINT32_C(1) << 12;
285static const HelRights kHelRightManage = UINT32_C(1) << 13;
287static const HelRights kHelRightsMax = ~UINT32_C(0);
289struct HelX86SegmentRegister {
293 uint8_t type, present, dpl, db, s, l, g, avl;
298struct HelX86DescriptorTable {
303struct HelX86VirtualizationRegs {
324 struct HelX86SegmentRegister cs, ds, es, fs, gs, ss;
325 struct HelX86SegmentRegister tr, ldt;
326 struct HelX86DescriptorTable gdt, idt;
328 uint64_t cr0, cr2, cr3, cr4, cr8;
334struct HelX86VirtualizationBasicRegs {
356struct HelX86VirtualizationMsrs {
357 uint64_t kernelGsBase;
363 uint64_t sysenterEsp;
364 uint64_t sysenterEip;
368struct HelRiscv64VirtualizationRegs {
424#if defined(__riscv) && __riscv_xlen == 64
425typedef struct HelRiscv64VirtualizationRegs HelVirtualizationRegs;
427typedef struct HelX86VirtualizationRegs HelVirtualizationRegs;
432 kHelThisUniverse = -1,
437 kHelWaitInfinite = -1
442 kHelActionDismiss = 11,
444 kHelActionAccept = 6,
445 kHelActionImbueCredentials = 8,
446 kHelActionExtractCredentials = 9,
447 kHelActionSendFromBuffer = 1,
448 kHelActionSendFromBufferSg = 10,
449 kHelActionRecvInline = 7,
450 kHelActionRecvToBuffer = 3,
451 kHelActionPushDescriptor = 2,
452 kHelActionPullDescriptor = 4
457 kHelItemAncillary = 2,
458 kHelItemWantLane = (1 << 16),
461static const uint32_t kHelTransferDescriptorOut = UINT32_C(1) << 0;
462static const uint32_t kHelTransferDescriptorIn = UINT32_C(1) << 1;
465 kHelObtainZeroMemory = 1,
466 kHelObtainClockPage = 2
530struct HelDescriptorInfo {
535 kHelAllocContinuous = 4,
536 kHelAllocOnDemand = 1,
539struct HelAllocRestrictions {
543enum HelManagedFlags {
544 kHelManagedReadahead = 1
547enum HelManageRequests {
548 kHelManageInitialize = 1,
549 kHelManageWriteback = 2
562 kHelMapProtRead = UINT32_C(1) << 8,
563 kHelMapProtWrite = UINT32_C(1) << 9,
564 kHelMapProtExecute = UINT32_C(1) << 10,
565 kHelMapDontRequireBacking = UINT32_C(1) << 7,
566 kHelMapFixed = UINT32_C(1) << 11,
567 kHelMapFixedNoReplace = UINT32_C(1) << 12,
568 kHelMapPreferBottom = UINT32_C(1) << 13,
575 kHelSliceCacheWriteCombine = 1,
579 kHelCachingDefault = 0,
580 kHelCachingUncached = 1,
581 kHelCachingWriteCombine = 2,
582 kHelCachingWriteThrough = 3,
583 kHelCachingWriteBack = 4,
585 kHelCachingMmioNonPosted = 6
589 kHelThreadStopped = 1
594 kHelObserveInterrupt = 4,
595 kHelObservePanic = 3,
596 kHelObserveBreakpoint = 1,
597 kHelObservePageFault = 2,
598 kHelObserveGeneralFault = 5,
599 kHelObserveIllegalInstruction = 6,
600 kHelObserveDivByZero = 7,
601 kHelObserveSuperCall = 0x80000000
604enum HelRegisterSets {
609 kHelRegsVirtualization = 5,
612 kHelRegsPageFault = 8,
613 kHelRegsVirtualizationBasic = 9,
614 kHelRegsVirtualizationMsrs = 10
617enum HelPageFaultFlags {
618 kHelPageFaultMapError = 1,
619 kHelPageFaultAccessError = 2,
620 kHelPageFaultOutOfMemory = 3
629#if defined(__x86_64__)
630enum HelRegisterIndex {
654 kHelRegNumber = kHelRegRdi,
655 kHelRegError = kHelRegRdi,
657 kHelRegArg0 = kHelRegRsi,
658 kHelRegArg1 = kHelRegRdx,
659 kHelRegArg2 = kHelRegRax,
660 kHelRegArg3 = kHelRegR8,
661 kHelRegArg4 = kHelRegR9,
662 kHelRegArg5 = kHelRegR10,
663 kHelRegArg6 = kHelRegR12,
664 kHelRegArg7 = kHelRegR13,
665 kHelRegArg8 = kHelRegR14,
667 kHelRegOut0 = kHelRegRsi,
668 kHelRegOut1 = kHelRegRdx,
669 kHelRegOut2 = kHelRegRax
672#elif defined(__aarch64__)
673enum HelRegisterIndex {
713 kHelRegNumber = kHelRegX0,
714 kHelRegError = kHelRegX0,
716 kHelRegArg0 = kHelRegX1,
717 kHelRegArg1 = kHelRegX2,
718 kHelRegArg2 = kHelRegX3,
719 kHelRegArg3 = kHelRegX4,
720 kHelRegArg4 = kHelRegX5,
721 kHelRegArg5 = kHelRegX6,
722 kHelRegArg6 = kHelRegX7,
723 kHelRegArg7 = kHelRegX8,
724 kHelRegArg8 = kHelRegX9,
726 kHelRegOut0 = kHelRegX1,
727 kHelRegOut1 = kHelRegX2,
728 kHelRegOut2 = kHelRegX3
731#elif defined(__riscv) && __riscv_xlen == 64
732enum HelRegisterIndex {
768 kHelRegNumber = kHelRegA0,
769 kHelRegError = kHelRegA0,
770 kHelRegArg0 = kHelRegA1,
771 kHelRegArg1 = kHelRegA2,
772 kHelRegArg2 = kHelRegA3,
773 kHelRegArg3 = kHelRegA4,
774 kHelRegArg4 = kHelRegA5,
775 kHelRegArg5 = kHelRegA6,
776 kHelRegArg6 = kHelRegA7,
777 kHelRegArg7 = kHelRegS2,
778 kHelRegArg8 = kHelRegS3,
780 kHelRegOut0 = kHelRegA1,
781 kHelRegOut1 = kHelRegA2,
782 kHelRegOut2 = kHelRegA3
787struct HelQueueParameters {
789 unsigned int numChunks;
791 unsigned int numSqChunks;
797struct HelHierarchyParameters {
802 uint32_t controllers;
829 kHelAccessIommuIntelVtd = 1,
830 kHelAccessIommuAmdVi = 2,
834 kHelDmaRegionRead = 1,
835 kHelDmaRegionWrite = 2,
955 uint64_t cancellationTag;
1188struct HelSimpleResult {
1193struct HelCredentialsResult {
1196 char credentials[16];
1199struct HelManageResult {
1206struct HelObserveResult {
1208 unsigned int observation;
1211struct HelInlineResult {
1218struct HelInlineResultNoFlex {
1224struct HelLengthResult {
1230struct HelHandleResult {
1236struct HelPointerResult {
1242struct HelEventResult {
1249 kHelAckAcknowledge = 2,
1252 kHelAckClear = 0x100,
1255union HelKernletData {
1259struct HelThreadStats {
1269 kHelVmexitTranslationFault = 1,
1272 kHelVmexitHyperCall = 2,
1273 kHelVmexitInstructionTrap = 3,
1274 kHelVmexitKicked = 4,
1284 kHelVmexitCpuid = 6,
1287 kHelVmexitRdmsr = 7,
1289 kHelVmexitWrmsr = 8,
1291 kHelVmexitShutdown = 9,
1296 kHelVmexitError = -1,
1298 kHelVmexitUnknownPlatformSpecificExitCode = -2,
1302 kHelVmexitIoIn = 1 << 0,
1303 kHelVmexitIoString = 1 << 1,
1307 kHelVmexitCompletionDone = 0,
1308 kHelVmexitCompletionFault = 1,
1311struct HelVmexitCompletion {
1318 kHelVmFaultRead = 1 << 0,
1319 kHelVmFaultWrite = 1 << 1,
1320 kHelVmFaultExecute = 1 << 2,
1323#if defined(__riscv) && __riscv_xlen == 64
1325struct HelVmexitReason {
1326 uint32_t exitReason;
1329 uint64_t instruction;
1336struct HelVmexitReason {
1337 uint32_t exitReason;
1347enum HelLogSeverity {
1348 kHelLogSeverityEmergency,
1349 kHelLogSeverityAlert,
1350 kHelLogSeverityCritical,
1351 kHelLogSeverityError,
1352 kHelLogSeverityWarning,
1353 kHelLogSeverityNotice,
1354 kHelLogSeverityInfo,
1355 kHelLogSeverityDebug,
1359 kHelAccessIrqByGsi = 1,
1360 kHelAccessIrqByPhandle = 2,
1361 kHelAccessIrqAllocateMsi = 3,
1366 kHelIrqNameSize = 32,
1370 kHelIrqTriggerNull = 0,
1371 kHelIrqTriggerEdge = 1,
1372 kHelIrqTriggerLevel = 2
1376 kHelIrqPolarityNull = 0,
1377 kHelIrqPolarityHigh = 1,
1378 kHelIrqPolarityLow = 2
1390 kHelPageSize = 1 << kHelPageShift
1403HEL_C_LINKAGE HelError
helLog(
const enum HelLogSeverity severity,
const char *
string,
size_t length);
1410HEL_C_LINKAGE
void helPanic(
const char *
string,
size_t length)
1411 __attribute__ (( noreturn ));
1433 const struct HelHierarchyParameters *params, HelHandle *handle);
1451HEL_C_LINKAGE HelError
1453 uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle);
1455HEL_C_LINKAGE HelError helDescriptorInfo(HelHandle handle,
struct HelDescriptorInfo *info);
1502HEL_C_LINKAGE HelError
helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask);
1530 const struct HelAllocRestrictions *restrictions, HelHandle *handle);
1595 HelHandle *backingHandle, HelHandle *frontalHandle);
1619 HelHandle *backingHandle, HelHandle *swapHandle);
1637 size_t size, uint32_t flags, HelHandle *handle);
1658HEL_C_LINKAGE HelError
helCopyOnWrite(HelHandle hierarchy, HelHandle swapSpace, HelHandle memory,
1659 uintptr_t offset,
size_t size, HelHandle *handle);
1661HEL_C_LINKAGE HelError helAccessPhysical(
1662 HelHandle accessToken, uintptr_t physical,
size_t size, uint32_t cachingMode, HelHandle *handle
1689 HelHandle memoryHandle, uintptr_t offset,
size_t size);
1691HEL_C_LINKAGE HelError helCreateSliceView(HelHandle bundle, uintptr_t offset,
size_t size,
1692 uint32_t flags, HelHandle *handle);
1717HEL_C_LINKAGE HelError
helAccessIommu(HelHandle accessHandle, uint32_t mode, uint64_t base,
1741 uint32_t flags, HelHandle *handle);
1760HEL_C_LINKAGE HelError
helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle,
1761 void *pointer, uintptr_t offset,
size_t size, uint32_t flags,
void **actualPointer);
1774HEL_C_LINKAGE HelError
helUnmapMemory(HelHandle spaceHandle,
void *pointer,
size_t size);
1776HEL_C_LINKAGE HelError helPointerPhysical(HelHandle spaceHandle,
const void *pointer, uintptr_t *physical);
1778HEL_C_LINKAGE HelError helMemoryInfo(HelHandle handle,
1781HEL_C_LINKAGE HelError helUpdateMemory(HelHandle handle,
int type, uintptr_t offset,
size_t length);
1793HEL_C_LINKAGE HelError
helLoadahead(HelHandle handle, uintptr_t offset,
size_t length);
1795HEL_C_LINKAGE HelError helCreateVirtualizedSpace(HelHandle *handle);
1816 HelHandle spaceHandle,
void *ip,
void *sp, uint32_t flags, HelHandle *handle);
1884HEL_C_LINKAGE HelError helWriteFsBase(
void *pointer);
1886HEL_C_LINKAGE HelError helReadFsBase(
void **pointer);
1888HEL_C_LINKAGE HelError helWriteGsBase(
void *pointer);
1890HEL_C_LINKAGE HelError helReadGsBase(
void **pointer);
1930 const struct HelVmexitCompletion *completion,
struct HelVmexitReason *reason);
1952HEL_C_LINKAGE HelError helGetRandomBytes(
void *buffer,
size_t wantedSize,
size_t *actualSize);
1963HEL_C_LINKAGE HelError
helGetAffinity(HelHandle handle, uint8_t *mask,
size_t size,
size_t *actualSize);
1985HEL_C_LINKAGE HelError
helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials);
1987HEL_C_LINKAGE HelError helShutdownLane(HelHandle handle);
2010HEL_C_LINKAGE HelError
helFutexWait(
int *pointer,
int expected, int64_t deadline);
2072 HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index,
2073 const char *name, HelHandle *handle
2081HEL_C_LINKAGE HelError
helHandleIrq(HelHandle pinHandle, HelHandle *handle);
2094HEL_C_LINKAGE HelError
helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity);
2104HEL_C_LINKAGE HelError helAcknowledgeIrq(HelHandle handle, uint32_t flags, uint64_t sequence);
2106HEL_C_LINKAGE HelError helAutomateIrq(HelHandle handle, uint32_t flags, HelHandle kernlet);
2112HEL_C_LINKAGE HelError helAccessIo(
2113 HelHandle accessToken,
const uintptr_t *portArray,
size_t numPorts, HelHandle *handle
2135 const union HelKernletData *data,
size_t numData, HelHandle *boundHandle);
2139extern inline __attribute__ (( always_inline ))
const char *_helErrorString(HelError code) {
2143 case kHelErrIllegalSyscall:
2144 return "Illegal syscall";
2145 case kHelErrIllegalArgs:
2146 return "Illegal arguments";
2147 case kHelErrIllegalState:
2148 return "Illegal state";
2149 case kHelErrUnsupportedOperation:
2150 return "Unsupported operation";
2151 case kHelErrNoDescriptor:
2152 return "No such descriptor";
2153 case kHelErrBadDescriptor:
2154 return "Illegal descriptor for this operation";
2155 case kHelErrThreadTerminated:
2156 return "Thread terminated already";
2157 case kHelErrLaneShutdown:
2158 return "Lane shutdown";
2159 case kHelErrEndOfLane:
2160 return "End of lane";
2161 case kHelErrDismissed:
2162 return "IPC item dismissed by remote";
2163 case kHelErrBufferTooSmall:
2164 return "Buffer too small";
2165 case kHelErrQueueTooSmall:
2166 return "Buffer too small";
2169 case kHelErrNoHardwareSupport:
2170 return "Missing hardware support for this feature";
2171 case kHelErrNoMemory:
2172 return "Out of memory";
2173 case kHelErrTransmissionMismatch:
2174 return "Transmission mismatch";
2175 case kHelErrCancelled:
2177 case kHelErrOutOfBounds:
2178 return "Out of bounds";
2179 case kHelErrAlreadyExists:
2180 return "Already exists";
2181 case kHelErrBadRights:
2182 return "Missing rights for this operation";
2188extern inline __attribute__ (( always_inline ))
void _helCheckFailed(HelError err_code,
2189 const char *
string,
int fatal) {
2190 helLog(kHelLogSeverityError,
string, strlen(
string));
2192 const char *err_string = _helErrorString(err_code);
2194 err_string =
"(Unexpected error code)";
2195 helLog(kHelLogSeverityError, err_string, strlen(err_string));
2196 helLog(kHelLogSeverityError,
"\n", 1);
2202#define HEL_STRINGIFY_AUX(x) #x
2203#define HEL_STRINGIFY(x) HEL_STRINGIFY_AUX(x)
2205#define HEL_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
2206 _helCheckFailed(__error, "HEL_CHECK failed: " #expr "\n" \
2207 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 1); } while(0)
2208#define HEL_SOFT_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
2209 _helCheckFailed(__error, "HEL_SOFT_CHECK failed: " #expr "\n" \
2210 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 0); } while(0)
@ kHelClockTsc
x86: TSC.
Definition hel.h:474
@ kHelClockCntvct
ARM: virtual counter (CNTVCT_EL0).
Definition hel.h:478
@ kHelClockCntpct
ARM: physical counter (CNTPCT_EL0).
Definition hel.h:476
@ kHelClockNone
No clock that is accessible to userspace (= helGetClock() has to be used).
Definition hel.h:472
@ kHelClockTime
RISC-V: time CSR.
Definition hel.h:480
HEL_C_LINKAGE HelError helLog(const enum HelLogSeverity severity, const char *string, size_t length)
Writes a text message (e.g., a line of text) to the kernel's log.
HEL_C_LINKAGE HelError helSetPriority(HelHandle handle, int priority)
Set the priority of a thread.
HEL_C_LINKAGE HelError helYield()
Yields the current thread.
HEL_C_LINKAGE HelError helEnableCoverage(HelHandle thread, HelHandle buffer, uint32_t mode)
Attaches a kcov buffer to a thread, which then records coverage to it.
HEL_C_LINKAGE HelError helQueryMsiInfo(HelHandle pinHandle, struct HelMsiInfo *info)
Retrieves the message address and data of an MSI pin.
HEL_C_LINKAGE HelError helAccessIrq(HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index, const char *name, HelHandle *handle)
Access the IRQ pin that an IRQ is attached to.
HEL_C_LINKAGE HelError helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity)
Configure the trigger mode and polarity of an IRQ pin.
static const int kHelUserNotifyAlert
Set in userNotify when the queue is alerted.
Definition hel.h:818
HEL_C_LINKAGE HelError helTransferDescriptor(HelHandle handle, HelHandle universeHandle, uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle)
Copies descriptors from the current universe to another universe.
HEL_C_LINKAGE HelError helCloseDescriptor(HelHandle universeHandle, HelHandle handle)
Closes a descriptor.
HEL_C_LINKAGE HelError helQueryRegisterInfo(int set, struct HelRegisterInfo *info)
Query register-related information.
HEL_C_LINKAGE HelError helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle, void *pointer, uintptr_t offset, size_t size, uint32_t flags, void **actualPointer)
Maps memory objects into an address space.
HEL_C_LINKAGE HelError helSetAffinity(HelHandle handle, uint8_t *mask, size_t size)
Set a thread's CPU affinity mask.
static const int kHelSwapRegionShift
Byte offset (((uint64_t)r << kHelSwapRegionShift) + o) in the backing memory of a swap space addresse...
Definition hel.h:1168
static const uint32_t kHelNumSwapRegions
Number of swap regions per swap space.
Definition hel.h:1170
static const int kHelKernelNotifySqProgress
Set in kernelNotify after userspace has added SQ elements.
Definition hel.h:821
static const uint32_t kHelSubmitInvalidateMemory
SQ opcode: invalidate memory.
Definition hel.h:884
HEL_C_LINKAGE HelError helQueryThreadStats(HelHandle handle, struct HelThreadStats *stats)
Query run-time statistics of a thread.
HEL_C_LINKAGE HelError helAlterMemoryIndirection(HelHandle indirectHandle, size_t slotIndex, HelHandle memoryHandle, uintptr_t offset, size_t size)
Modifies indirect memory objects.
HEL_C_LINKAGE HelError helCreateVirtualizedCpu(HelHandle handle, HelHandle *out_handle)
Creates a virtualized CPU in a virtualized space.
HEL_C_LINKAGE HelError helCreateBitsetEvent(HelHandle *handle)
Create an event consisting of multiple bits that can fire independently.
static const uint32_t kHelInvalidateNoWriteback
Flag for kHelSubmitInvalidateMemory: discard dirty pages instead of writing them back.
Definition hel.h:1083
HEL_C_LINKAGE HelError helGetCredentials(HelHandle handle, uint32_t flags, char *credentials)
Returns the credentials associated with a given descriptor.
HEL_C_LINKAGE HelError helKillThread(HelHandle handle)
Kill (i.e., terminate) a thread.
static const uint32_t kHelSubmitWriteMemory
SQ opcode: write memory.
Definition hel.h:870
static const uint32_t kHelSubmitUnmapMemory
SQ opcode: unmap memory.
Definition hel.h:890
HEL_C_LINKAGE HelError helObtainHandle(int kind, HelHandle *handle)
Obtains a descriptor to one of the kernel's global objects.
HEL_C_LINKAGE HelError helCreateDmaSpace(HelHandle iommuHandle, const struct HelDmaReservedRegion *regions, size_t numRegions, uint32_t flags, HelHandle *handle)
Creates a DMA space that memory can be mapped into for device DMA.
HEL_C_LINKAGE HelError helGetAffinity(HelHandle handle, uint8_t *mask, size_t size, size_t *actualSize)
Get a thread's CPU affinity mask.
static const uint32_t kHelSubmitAsyncNop
SQ opcode: asynchronous no-op (for testing/profiling).
Definition hel.h:856
HEL_C_LINKAGE HelError helAccessIommu(HelHandle accessHandle, uint32_t mode, uint64_t base, HelHandle *handle)
Access an IOMMU that the kernel discovered from firmware.
HEL_C_LINKAGE HelError helGetClock(uint64_t *counter)
Read the system-wide monotone clock.
HEL_C_LINKAGE HelError helLoadahead(HelHandle handle, uintptr_t offset, size_t length)
Notifies the kernel that a certain range of memory should be preloaded.
HEL_C_LINKAGE HelError helCopyOnWrite(HelHandle hierarchy, HelHandle swapSpace, HelHandle memory, uintptr_t offset, size_t size, HelHandle *handle)
Creates memory object that obtains its memory by copy-on-write from another memory object.
HEL_C_LINKAGE HelError helLoadRegisters(HelHandle handle, int set, void *image)
Load a register image (e.g., from a thread).
HEL_C_LINKAGE void helPanic(const char *string, size_t length) __attribute__((noreturn))
Kills the current thread and writes an error message to the kernel's log.
HEL_C_LINKAGE HelError helUnmapMemory(HelHandle spaceHandle, void *pointer, size_t size)
Unmaps memory from an address space.
HEL_C_LINKAGE HelError helAllocateSwappableMemory(HelHandle hierarchy, HelHandle swapSpace, size_t size, uint32_t flags, HelHandle *handle)
Allocates memory that behaves like helAllocateMemory() but is backed by a swap space: under memory pr...
HEL_C_LINKAGE HelError helFutexWake(int *pointer, unsigned int count)
Wakes up all waiters of a futex.
HEL_C_LINKAGE HelError helResizeMemory(HelHandle handle, size_t newSize)
Resizes a memory object.
static const int kHelProgressMask
Mask to extract the number of valid bytes in the chunk.
Definition hel.h:925
static const uint32_t kHelSubmitManageMemory
SQ opcode: manage memory.
Definition hel.h:872
static const uint32_t kHelSubmitForkMemory
SQ opcode: fork memory.
Definition hel.h:880
HEL_C_LINKAGE HelError helInterruptThread(HelHandle handle)
Interrupt a thread.
static const int kHelProgressFull
Set by the producer once the chunk is full (i.e., no more bytes will be written).
Definition hel.h:929
static const uint32_t kHelSubmitUnbindDmaDevice
SQ opcode: block the DMA requests of a device.
Definition hel.h:894
static const uint32_t kHelSubmitSynchronizeSpace
SQ opcode: synchronize space.
Definition hel.h:866
HEL_C_LINKAGE HelError helRaiseEvent(HelHandle handle)
Raise an event.
static const uint32_t kHelDriveWait
Flag for helDriveQueue: wait until userNotify has any bits not in notifyMask set.
Definition hel.h:826
HEL_C_LINKAGE HelError helDisableCoverage(HelHandle thread)
Detaches the kcov buffer that is attached to a thread.
static const uint32_t kHelSubmitObserve
SQ opcode: observe thread.
Definition hel.h:876
HEL_C_LINKAGE HelError helForkMemory(HelHandle handle, HelHandle *forkedHandle)
Forks memory objects, i.e., copies them using copy-on-write.
HEL_C_LINKAGE HelError helCreateQueue(const struct HelQueueParameters *params, HelHandle *handle)
Creates an IPC queue.
HEL_C_LINKAGE HelError helCreateToken(HelHandle *handle)
Create a token object.
static const uint32_t kHelSubmitBindDmaDevice
SQ opcode: bind a device to a DMA space.
Definition hel.h:892
HEL_C_LINKAGE HelError helResume(HelHandle handle)
Resume a suspended thread.
static const uint32_t kHelSubmitExchangeMsgs
SQ opcode: exchange messages on a stream.
Definition hel.h:858
static const uint32_t kHelSubmitReadMemory
SQ opcode: read memory.
Definition hel.h:868
static const int kHelNextPresent
Marks the next field as present.
Definition hel.h:922
static const int kHelKernelNotifySupplyCqChunks
Set in kernelNotify after userspace has supplied new chunks.
Definition hel.h:823
HEL_C_LINKAGE HelError helSubmitAsyncNop(HelHandle queueHandle, uintptr_t context)
Does nothing, asynchronously (useful only for profiling).
HEL_C_LINKAGE HelError helHandleIrq(HelHandle pinHandle, HelHandle *handle)
Install an IRQ handler on an IRQ pin.
HEL_C_LINKAGE HelError helStoreRegisters(HelHandle handle, int set, const void *image)
Store a register image (e.g., to a thread).
static const uint32_t kHelSubmitAwaitEvent
SQ opcode: wait for an event.
Definition hel.h:862
static const uint32_t kHelSubmitAwaitClock
SQ opcode: wait for time to pass.
Definition hel.h:860
static const uint32_t kHelSubmitPopulateSpace
SQ opcode: populate a space.
Definition hel.h:886
HEL_C_LINKAGE HelError helAlertQueue(HelHandle queueHandle)
Alerts an IPC queue.
static const uint32_t kHelSubmitActivateIommu
SQ opcode: activate translation on an IOMMU.
Definition hel.h:896
HEL_C_LINKAGE HelError helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials)
Create a stream (which always consists of two lanes).
static const uint32_t kHelSubmitProtectMemory
SQ opcode: protect memory.
Definition hel.h:864
HelMapFlags
Definition hel.h:560
@ kHelMapNoDirtyTracking
Discards the mapping's dirty bits instead of scheduling the pages for writeback.
Definition hel.h:571
static const uint32_t kHelSubmitMapMemory
SQ opcode: map memory.
Definition hel.h:888
static const int kHelUserNotifySupplySqChunks
Set in userNotify after kernel has supplied new SQ chunks.
Definition hel.h:814
HEL_C_LINKAGE HelError helCreateIndirectMemory(size_t numSlots, HelHandle *handle)
Creates a memory object that obtains its memory by delegating to other memory objects.
HEL_C_LINKAGE HelError helGetCurrentCpu(int *cpu)
Gets the index of the cpu which the calling thread is running on.
HEL_C_LINKAGE HelError helNop()
Does nothing (useful only for profiling).
HEL_C_LINKAGE HelError helRunVirtualizedCpu(HelHandle handle, const struct HelVmexitCompletion *completion, struct HelVmexitReason *reason)
Runs a virtualized CPU until it exits to the VMM.
HEL_C_LINKAGE HelError helFutexWait(int *pointer, int expected, int64_t deadline)
Waits on a futex.
HEL_C_LINKAGE HelError helBindKernlet(HelHandle handle, const union HelKernletData *data, size_t numData, HelHandle *boundHandle)
Bind parameters to a kernlet.
static const int kHelUserNotifyCqProgress
Set in userNotify after kernel has written progress.
Definition hel.h:812
HEL_C_LINKAGE HelError helCreateSpace(HelHandle *handle)
Creates a virtual address space that threads can run in.
static const uint32_t kHelSubmitWritebackFence
SQ opcode: writeback fence.
Definition hel.h:882
HelUpdateMemoryTypes
Additional type values of helUpdateMemory(); these are never issued as manage requests.
Definition hel.h:553
@ kHelUpdateMarkDirty
Marks a range as dirty, as if it had been written through a dirty-tracked mapping.
Definition hel.h:557
HEL_C_LINKAGE HelError helCreateSequencedEvent(HelHandle *waitHandle, HelHandle *raiseHandle)
Create an event that counts how often it was raised.
static const uint32_t kHelSubmitResizeMemory
SQ opcode: resize memory.
Definition hel.h:878
HEL_C_LINKAGE HelError helCreateOneshotEvent(HelHandle *handle)
Create an event that fires at most once.
HEL_C_LINKAGE HelError helCreateSwapSpace(HelHandle hierarchy, uint32_t flags, HelHandle *backingHandle, HelHandle *swapHandle)
Creates a swap space, the backing store for swappable anonymous memory (see helAllocateSwappableMemor...
HEL_C_LINKAGE HelError helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask)
Drives an IPC queue.
static const uint32_t kHelSubmitLockMemoryView
SQ opcode: lock memory view.
Definition hel.h:874
HEL_C_LINKAGE HelError helCreateUniverse(HelHandle *handle)
Creates a new universe descriptor.
static const int kHelProgressDone
Set by the producer once it retires the chunk.
Definition hel.h:927
HEL_C_LINKAGE HelError helEnableIo(HelHandle handle)
Enable userspace access to hardware I/O resources.
static const uint32_t kHelHierarchyMemoryController
Gives the new hierarchy its own memory controller with the given memoryFloor.
Definition hel.h:795
HEL_C_LINKAGE HelError helCreateManagedMemory(HelHandle hierarchy, size_t size, uint32_t flags, HelHandle *backingHandle, HelHandle *frontalHandle)
Creates a memory object that is managed by userspace.
HEL_C_LINKAGE HelError helCreateKcovBuffer(size_t size, HelHandle *handle)
Creates a buffer for kernel code coverage (kcov).
static const int kHelUserNotifyError
Set in userNotify if the queue encounters a contract violation.
Definition hel.h:816
HEL_C_LINKAGE HelError helExtendHierarchy(HelHandle hierarchyHandle, const struct HelHierarchyParameters *params, HelHandle *handle)
Creates a child hierarchy capability.
HEL_C_LINKAGE HelError helCreateThread(HelHandle hierarchy, HelHandle universe, HelHandle spaceHandle, void *ip, void *sp, uint32_t flags, HelHandle *handle)
Create a new thread.
static const uint32_t kHelSubmitSetSwapRegion
SQ opcode: set the capacity of a swap region.
Definition hel.h:898
static const uint32_t kHelSubmitCancel
SQ opcode: cancel an asynchronous operation.
Definition hel.h:854
HEL_C_LINKAGE HelError helKickVirtualizedCpu(HelHandle handle)
Makes helRunVirtualizedCpu() return with kHelVmexitKicked as soon as possible.
HEL_C_LINKAGE HelError helAllocateMemory(HelHandle hierarchy, size_t size, uint32_t flags, const struct HelAllocRestrictions *restrictions, HelHandle *handle)
Creates a memory object consisting of unmanaged RAM.
@ kHelKcovModeCmp
Record comparisons.
Definition hel.h:1557
@ kHelKcovModePc
Record PCs.
Definition hel.h:1555
HEL_C_LINKAGE HelError helAssertVirtualizedIrq(HelHandle handle, uint64_t irq, uint8_t level)
Raises an interrupt in a virtualized CPU.
Parameters that allow userspace to compute the current time on the monotone clock (i....
Definition hel.h:492
int32_t tickShift
Scaling exponent of the tick -> nanosecond conversion.
Definition hel.h:497
uint64_t tickFactor
Factor of the tick -> nanosecond conversion.
Definition hel.h:499
uint32_t clockType
One of the kHelClock* constants.
Definition hel.h:495
Requester ID that a device issues DMA requests as (see kHelSubmitBindDmaDevice).
Definition hel.h:846
Range of physical memory that a DMA space identity-maps (see helCreateDmaSpace).
Definition hel.h:839
A single element of a HelQueue.
Definition hel.h:944
unsigned int length
Length of the element in bytes.
Definition hel.h:946
void * context
User-defined value.
Definition hel.h:950
unsigned int opcode
Operation code (for SQ elements).
Definition hel.h:948
Message address / data pair that raises an MSI (see helQueryMsiInfo).
Definition hel.h:1382
In-memory kernel/user-space queue.
Definition hel.h:901
int kernelNotify
Futex that is used to wake the kernel.
Definition hel.h:910
int userNotify
Futex that is used to wake userspace.
Definition hel.h:905
int cqFirst
Index of the first chunk of the completion queue.
Definition hel.h:914
int sqFirst
Index of the first chunk of the submission queue.
Definition hel.h:918
Register-related information returned by helQueryRegisterInfo.
Definition hel.h:624
int setSize
Size of the selected register set.
Definition hel.h:626
SQ data for kHelSubmitActivateIommu.
Definition hel.h:1160
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1162
SQ data for kHelSubmitAwaitClock.
Definition hel.h:970
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:974
uint64_t counter
Deadline in nanoseconds since boot.
Definition hel.h:972
SQ data for kHelSubmitAwaitEvent.
Definition hel.h:978
HelHandle handle
Handle to the event descriptor.
Definition hel.h:980
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:984
uint64_t sequence
Previous sequence number.
Definition hel.h:982
SQ data for kHelSubmitBindDmaDevice.
Definition hel.h:1136
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1143
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1138
HelHandle dmaSpaceHandle
Handle to a DMA space of that IOMMU (see helCreateDmaSpace).
Definition hel.h:1141
SQ data for kHelSubmitCancel.
Definition hel.h:954
SQ data for kHelSubmitExchangeMsgs.
Definition hel.h:960
uint32_t flags
Flags.
Definition hel.h:966
size_t count
Number of actions.
Definition hel.h:964
HelHandle lane
Handle to the lane.
Definition hel.h:962
SQ data for kHelSubmitForkMemory.
Definition hel.h:1064
HelHandle hierarchyHandle
Handle to the hierarchy object that owns the memory object.
Definition hel.h:1066
HelHandle handle
Handle to the memory object.
Definition hel.h:1068
SQ data for kHelSubmitInvalidateMemory.
Definition hel.h:1086
uint32_t flags
Flags (kHelInvalidate*).
Definition hel.h:1094
HelHandle handle
Handle to the memory object.
Definition hel.h:1088
size_t size
Size of the range.
Definition hel.h:1092
uintptr_t offset
Offset within the memory object.
Definition hel.h:1090
SQ data for kHelSubmitLockMemoryView.
Definition hel.h:1040
size_t size
Size to lock.
Definition hel.h:1046
uintptr_t offset
Offset within the memory object.
Definition hel.h:1044
HelHandle handle
Handle to the memory object.
Definition hel.h:1042
SQ data for kHelSubmitManageMemory.
Definition hel.h:1034
HelHandle handle
Handle to the memory object.
Definition hel.h:1036
SQ data for kHelSubmitMapMemory.
Definition hel.h:1108
uint32_t flags
Flags (kHelMap*).
Definition hel.h:1120
HelHandle spaceHandle
Handle to the space that the memory is mapped into.
Definition hel.h:1112
HelHandle memoryHandle
Handle to the memory object.
Definition hel.h:1110
uintptr_t offset
Offset within the memory object.
Definition hel.h:1116
void * pointer
Address to map at (depending on kHelMap*).
Definition hel.h:1114
size_t size
Size of the mapping.
Definition hel.h:1118
SQ data for kHelSubmitObserve.
Definition hel.h:1050
HelHandle handle
Handle to the thread.
Definition hel.h:1052
SQ data for kHelSubmitPopulateSpace.
Definition hel.h:1098
HelHandle handle
Handle to the memory space.
Definition hel.h:1100
uintptr_t address
Address within the memory space.
Definition hel.h:1102
size_t length
Length of the range.
Definition hel.h:1104
SQ data for kHelSubmitProtectMemory.
Definition hel.h:988
size_t size
Size of the mapping.
Definition hel.h:994
void * pointer
Pointer to the mapping.
Definition hel.h:992
uint32_t flags
Protection flags.
Definition hel.h:996
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:990
SQ data for kHelSubmitReadMemory.
Definition hel.h:1010
uintptr_t address
Address within the memory object.
Definition hel.h:1014
HelHandle handle
Handle to the memory object.
Definition hel.h:1012
size_t length
Length in bytes.
Definition hel.h:1016
void * buffer
Buffer to read into.
Definition hel.h:1018
SQ data for kHelSubmitResizeMemory.
Definition hel.h:1056
HelHandle handle
Handle to the memory object.
Definition hel.h:1058
size_t newSize
New size in bytes.
Definition hel.h:1060
SQ data for kHelSubmitSetSwapRegion.
Definition hel.h:1176
size_t numPages
New capacity of the region in pages.
Definition hel.h:1183
HelHandle swapHandle
Handle to the swap space (from helCreateSwapSpace).
Definition hel.h:1179
uint32_t region
Index of the region. Must be smaller than kHelNumSwapRegions.
Definition hel.h:1185
SQ data for kHelSubmitSynchronizeSpace.
Definition hel.h:1000
void * pointer
Pointer to the mapping.
Definition hel.h:1004
size_t size
Size of the mapping.
Definition hel.h:1006
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:1002
SQ data for kHelSubmitUnbindDmaDevice.
Definition hel.h:1149
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1151
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1153
SQ data for kHelSubmitUnmapMemory.
Definition hel.h:1124
size_t size
Size of the mapping.
Definition hel.h:1130
void * pointer
Pointer to the mapping.
Definition hel.h:1128
HelHandle spaceHandle
Handle to the space that the mapping is removed from.
Definition hel.h:1126
SQ data for kHelSubmitWriteMemory.
Definition hel.h:1022
HelHandle handle
Handle to the memory object.
Definition hel.h:1024
size_t length
Length in bytes.
Definition hel.h:1028
const void * buffer
Buffer to write from.
Definition hel.h:1030
uintptr_t address
Address within the memory object.
Definition hel.h:1026
SQ data for kHelSubmitWritebackFence.
Definition hel.h:1073
HelHandle handle
Handle to the memory object.
Definition hel.h:1075
size_t size
Size of the range.
Definition hel.h:1079
uintptr_t offset
Offset within the memory object.
Definition hel.h:1077