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 kHelCallCopyOnWrite = 39,
44 kHelCallAccessPhysical = 30,
45 kHelCallCreateSliceView = 88,
46 kHelCallForkMemory = 40,
47 kHelCallCreateSpace = 27,
48 kHelCallCreateDmaSpace = 108,
49 kHelCallConfigureIrq = 109,
50 kHelCallCreateIndirectMemory = 45,
51 kHelCallAlterMemoryIndirection = 52,
52 kHelCallMapMemory = 44,
53 kHelCallSubmitProtectMemory = 99,
54 kHelCallSubmitSynchronizeSpace = 53,
55 kHelCallUnmapMemory = 36,
56 kHelCallPointerPhysical = 43,
57 kHelCallSubmitReadMemory = 77,
58 kHelCallSubmitWriteMemory = 78,
59 kHelCallMemoryInfo = 26,
60 kHelCallSubmitManageMemory = 46,
61 kHelCallUpdateMemory = 47,
62 kHelCallSubmitLockMemoryView = 48,
63 kHelCallLoadahead = 49,
64 kHelCallCreateVirtualizedSpace = 50,
65 kHelCallCreateSwapSpace = 110,
66 kHelCallAllocateSwappableMemory = 111,
68 kHelCallAccessIommu = 13,
70 kHelCallCreateThread = 67,
71 kHelCallQueryThreadStats = 95,
72 kHelCallSetPriority = 85,
74 kHelCallSubmitObserve = 74,
75 kHelCallKillThread = 87,
76 kHelCallInterruptThread = 86,
78 kHelCallLoadRegisters = 75,
79 kHelCallStoreRegisters = 76,
80 kHelCallQueryRegisterInfo = 102,
81 kHelCallWriteFsBase = 41,
82 kHelCallGetClock = 42,
83 kHelCallSubmitAwaitClock = 80,
84 kHelCallCreateVirtualizedCpu = 37,
85 kHelCallRunVirtualizedCpu = 38,
86 kHelCallAssertVirtualizedIrq = 107,
87 kHelCallGetRandomBytes = 101,
88 kHelCallWriteGsBase = 54,
89 kHelCallReadFsBase = 55,
90 kHelCallReadGsBase = 56,
91 kHelCallGetCurrentCpu = 57,
93 kHelCallCreateStream = 68,
94 kHelCallSubmitAsync = 79,
95 kHelCallShutdownLane = 91,
97 kHelCallFutexWait = 73,
98 kHelCallFutexWake = 71,
100 kHelCallCreateOneshotEvent = 96,
101 kHelCallCreateBitsetEvent = 97,
102 kHelCallCreateSequencedEvent = 15,
103 kHelCallRaiseEvent = 98,
104 kHelCallAccessIrq = 14,
105 kHelCallHandleIrq = 5,
106 kHelCallAcknowledgeIrq = 81,
107 kHelCallSubmitAwaitEvent = 82,
108 kHelCallAutomateIrq = 94,
109 kHelCallQueryMsiInfo = 6,
111 kHelCallAccessIo = 11,
112 kHelCallEnableIo = 12,
114 kHelCallBindKernlet = 93,
116 kHelCallGetAffinity = 103,
117 kHelCallSetAffinity = 100,
119 kHelCallCreateToken = 104,
121 kHelCallExtendHierarchy = 7,
123 kHelCallSuper = 0x80000000
128 kHelErrBufferTooSmall = 1,
129 kHelErrBadDescriptor = 2,
131 kHelErrNoDescriptor = 4,
132 kHelErrIllegalSyscall = 5,
133 kHelErrIllegalObject = 6,
134 kHelErrIllegalArgs = 7,
135 kHelErrLaneShutdown = 8,
136 kHelErrEndOfLane = 9,
138 kHelErrThreadTerminated = 11,
139 kHelErrCancelled = 12,
140 kHelErrTransmissionMismatch = 13,
141 kHelErrQueueTooSmall = 14,
142 kHelErrIllegalState = 15,
143 kHelErrNoHardwareSupport = 16,
144 kHelErrNoMemory = 17,
145 kHelErrUnsupportedOperation = 18,
146 kHelErrOutOfBounds = 19,
147 kHelErrDismissed = 20,
148 kHelErrRemoteFault = 21,
149 kHelErrAlreadyExists = 22,
150 kHelErrBadPermissions = 23,
152 kHelErrFutexRace = 25,
153 kHelErrBadRights = 26,
156typedef uint32_t HelRights;
162static const HelRights kHelRightNull = 0;
171static const HelRights kHelRightGrant = UINT32_C(1) << 0;
175static const HelRights kHelRightTake = UINT32_C(1) << 1;
192static const HelRights kHelRightRead = UINT32_C(1) << 2;
208static const HelRights kHelRightWrite = UINT32_C(1) << 3;
212static const HelRights kHelRightExecute = UINT32_C(1) << 4;
217static const HelRights kHelRightInvoke = UINT32_C(1) << 5;
235static const HelRights kHelRightAssign = UINT32_C(1) << 6;
239static const HelRights kHelRightDerive = UINT32_C(1) << 7;
247static const HelRights kHelRightProvision = UINT32_C(1) << 8;
250static const HelRights kHelRightPin = UINT32_C(1) << 9;
253static const HelRights kHelRightFence = UINT32_C(1) << 10;
260static const HelRights kHelRightWait = UINT32_C(1) << 11;
269static const HelRights kHelRightSignal = UINT32_C(1) << 12;
281static const HelRights kHelRightManage = UINT32_C(1) << 13;
283static const HelRights kHelRightsMax = ~UINT32_C(0);
285struct HelX86SegmentRegister {
289 uint8_t type, present, dpl, db, s, l, g, avl;
292struct HelX86DescriptorTable {
297struct HelX86VirtualizationRegs {
318 struct HelX86SegmentRegister cs, ds, es, fs, gs, ss;
319 struct HelX86SegmentRegister tr, ldt;
320 struct HelX86DescriptorTable gdt, idt;
322 uint64_t cr0, cr2, cr3, cr4, cr8;
327struct HelRiscv64VirtualizationRegs {
383#if defined(__riscv) && __riscv_xlen == 64
384typedef struct HelRiscv64VirtualizationRegs HelVirtualizationRegs;
386typedef struct HelX86VirtualizationRegs HelVirtualizationRegs;
391 kHelThisUniverse = -1,
396 kHelWaitInfinite = -1
401 kHelActionDismiss = 11,
403 kHelActionAccept = 6,
404 kHelActionImbueCredentials = 8,
405 kHelActionExtractCredentials = 9,
406 kHelActionSendFromBuffer = 1,
407 kHelActionSendFromBufferSg = 10,
408 kHelActionRecvInline = 7,
409 kHelActionRecvToBuffer = 3,
410 kHelActionPushDescriptor = 2,
411 kHelActionPullDescriptor = 4
416 kHelItemAncillary = 2,
417 kHelItemWantLane = (1 << 16),
420static const uint32_t kHelTransferDescriptorOut = UINT32_C(1) << 0;
421static const uint32_t kHelTransferDescriptorIn = UINT32_C(1) << 1;
424 kHelObtainZeroMemory = 1,
425 kHelObtainClockPage = 2
489struct HelDescriptorInfo {
494 kHelAllocContinuous = 4,
495 kHelAllocOnDemand = 1,
498struct HelAllocRestrictions {
502enum HelManagedFlags {
503 kHelManagedReadahead = 1
506enum HelManageRequests {
507 kHelManageInitialize = 1,
508 kHelManageWriteback = 2
521 kHelMapProtRead = UINT32_C(1) << 8,
522 kHelMapProtWrite = UINT32_C(1) << 9,
523 kHelMapProtExecute = UINT32_C(1) << 10,
524 kHelMapDontRequireBacking = UINT32_C(1) << 7,
525 kHelMapFixed = UINT32_C(1) << 11,
526 kHelMapFixedNoReplace = UINT32_C(1) << 12,
527 kHelMapPreferBottom = UINT32_C(1) << 13,
534 kHelSliceCacheWriteCombine = 1,
538 kHelCachingDefault = 0,
539 kHelCachingUncached = 1,
540 kHelCachingWriteCombine = 2,
541 kHelCachingWriteThrough = 3,
542 kHelCachingWriteBack = 4,
544 kHelCachingMmioNonPosted = 6
548 kHelThreadStopped = 1
553 kHelObserveInterrupt = 4,
554 kHelObservePanic = 3,
555 kHelObserveBreakpoint = 1,
556 kHelObservePageFault = 2,
557 kHelObserveGeneralFault = 5,
558 kHelObserveIllegalInstruction = 6,
559 kHelObserveDivByZero = 7,
560 kHelObserveSuperCall = 0x80000000
563enum HelRegisterSets {
568 kHelRegsVirtualization = 5,
571 kHelRegsPageFault = 8
574enum HelPageFaultFlags {
575 kHelPageFaultMapError = 1,
576 kHelPageFaultAccessError = 2,
577 kHelPageFaultOutOfMemory = 3
586#if defined(__x86_64__)
587enum HelRegisterIndex {
611 kHelRegNumber = kHelRegRdi,
612 kHelRegError = kHelRegRdi,
614 kHelRegArg0 = kHelRegRsi,
615 kHelRegArg1 = kHelRegRdx,
616 kHelRegArg2 = kHelRegRax,
617 kHelRegArg3 = kHelRegR8,
618 kHelRegArg4 = kHelRegR9,
619 kHelRegArg5 = kHelRegR10,
620 kHelRegArg6 = kHelRegR12,
621 kHelRegArg7 = kHelRegR13,
622 kHelRegArg8 = kHelRegR14,
624 kHelRegOut0 = kHelRegRsi,
625 kHelRegOut1 = kHelRegRdx,
626 kHelRegOut2 = kHelRegRax
629#elif defined(__aarch64__)
630enum HelRegisterIndex {
670 kHelRegNumber = kHelRegX0,
671 kHelRegError = kHelRegX0,
673 kHelRegArg0 = kHelRegX1,
674 kHelRegArg1 = kHelRegX2,
675 kHelRegArg2 = kHelRegX3,
676 kHelRegArg3 = kHelRegX4,
677 kHelRegArg4 = kHelRegX5,
678 kHelRegArg5 = kHelRegX6,
679 kHelRegArg6 = kHelRegX7,
680 kHelRegArg7 = kHelRegX8,
681 kHelRegArg8 = kHelRegX9,
683 kHelRegOut0 = kHelRegX1,
684 kHelRegOut1 = kHelRegX2,
685 kHelRegOut2 = kHelRegX3
688#elif defined(__riscv) && __riscv_xlen == 64
689enum HelRegisterIndex {
725 kHelRegNumber = kHelRegA0,
726 kHelRegError = kHelRegA0,
727 kHelRegArg0 = kHelRegA1,
728 kHelRegArg1 = kHelRegA2,
729 kHelRegArg2 = kHelRegA3,
730 kHelRegArg3 = kHelRegA4,
731 kHelRegArg4 = kHelRegA5,
732 kHelRegArg5 = kHelRegA6,
733 kHelRegArg6 = kHelRegA7,
734 kHelRegArg7 = kHelRegS2,
735 kHelRegArg8 = kHelRegS3,
737 kHelRegOut0 = kHelRegA1,
738 kHelRegOut1 = kHelRegA2,
739 kHelRegOut2 = kHelRegA3
744struct HelQueueParameters {
746 unsigned int numChunks;
748 unsigned int numSqChunks;
754struct HelHierarchyParameters {
759 uint32_t controllers;
786 kHelAccessIommuIntelVtd = 1,
787 kHelAccessIommuAmdVi = 2,
791 kHelDmaRegionRead = 1,
792 kHelDmaRegionWrite = 2,
912 uint64_t cancellationTag;
1145struct HelSimpleResult {
1150struct HelCredentialsResult {
1153 char credentials[16];
1156struct HelManageResult {
1163struct HelObserveResult {
1165 unsigned int observation;
1168struct HelInlineResult {
1175struct HelInlineResultNoFlex {
1181struct HelLengthResult {
1187struct HelHandleResult {
1193struct HelPointerResult {
1199struct HelEventResult {
1206 kHelAckAcknowledge = 2,
1209 kHelAckClear = 0x100,
1212union HelKernletData {
1216struct HelThreadStats {
1222 kHelVmexitTranslationFault = 1,
1223 kHelVmexitHyperCall = 2,
1224 kHelVmexitInstructionTrap = 3,
1225 kHelVmexitError = -1,
1226 kHelVmexitUnknownPlatformSpecificExitCode = -2,
1230 kHelVmFaultRead = 1 << 0,
1231 kHelVmFaultWrite = 1 << 1,
1232 kHelVmFaultExecute = 1 << 2,
1235#if defined(__riscv) && __riscv_xlen == 64
1237struct HelVmexitReason {
1238 uint32_t exitReason;
1241 uint64_t instruction;
1248struct HelVmexitReason {
1249 uint32_t exitReason;
1258enum HelLogSeverity {
1259 kHelLogSeverityEmergency,
1260 kHelLogSeverityAlert,
1261 kHelLogSeverityCritical,
1262 kHelLogSeverityError,
1263 kHelLogSeverityWarning,
1264 kHelLogSeverityNotice,
1265 kHelLogSeverityInfo,
1266 kHelLogSeverityDebug,
1270 kHelAccessIrqByGsi = 1,
1271 kHelAccessIrqByPhandle = 2,
1272 kHelAccessIrqAllocateMsi = 3,
1277 kHelIrqNameSize = 32,
1281 kHelIrqTriggerNull = 0,
1282 kHelIrqTriggerEdge = 1,
1283 kHelIrqTriggerLevel = 2
1287 kHelIrqPolarityNull = 0,
1288 kHelIrqPolarityHigh = 1,
1289 kHelIrqPolarityLow = 2
1308HEL_C_LINKAGE HelError
helLog(
const enum HelLogSeverity severity,
const char *
string,
size_t length);
1315HEL_C_LINKAGE
void helPanic(
const char *
string,
size_t length)
1316 __attribute__ (( noreturn ));
1338 const struct HelHierarchyParameters *params, HelHandle *handle);
1356HEL_C_LINKAGE HelError
1358 uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle);
1360HEL_C_LINKAGE HelError helDescriptorInfo(HelHandle handle,
struct HelDescriptorInfo *info);
1407HEL_C_LINKAGE HelError
helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask);
1434 const struct HelAllocRestrictions *restrictions, HelHandle *handle);
1459 HelHandle *backingHandle, HelHandle *frontalHandle);
1483 HelHandle *backingHandle, HelHandle *swapHandle);
1501 size_t size, uint32_t flags, HelHandle *handle);
1521HEL_C_LINKAGE HelError
helCopyOnWrite(HelHandle hierarchy, HelHandle swapSpace, HelHandle memory,
1522 uintptr_t offset,
size_t size, HelHandle *handle);
1524HEL_C_LINKAGE HelError helAccessPhysical(
1525 HelHandle accessToken, uintptr_t physical,
size_t size, uint32_t cachingMode, HelHandle *handle
1552 HelHandle memoryHandle, uintptr_t offset,
size_t size);
1554HEL_C_LINKAGE HelError helCreateSliceView(HelHandle bundle, uintptr_t offset,
size_t size,
1555 uint32_t flags, HelHandle *handle);
1580HEL_C_LINKAGE HelError
helAccessIommu(HelHandle accessHandle, uint32_t mode, uint64_t base,
1604 uint32_t flags, HelHandle *handle);
1623HEL_C_LINKAGE HelError
helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle,
1624 void *pointer, uintptr_t offset,
size_t size, uint32_t flags,
void **actualPointer);
1637HEL_C_LINKAGE HelError
helUnmapMemory(HelHandle spaceHandle,
void *pointer,
size_t size);
1639HEL_C_LINKAGE HelError helPointerPhysical(HelHandle spaceHandle,
const void *pointer, uintptr_t *physical);
1641HEL_C_LINKAGE HelError helMemoryInfo(HelHandle handle,
1644HEL_C_LINKAGE HelError helUpdateMemory(HelHandle handle,
int type, uintptr_t offset,
size_t length);
1656HEL_C_LINKAGE HelError
helLoadahead(HelHandle handle, uintptr_t offset,
size_t length);
1658HEL_C_LINKAGE HelError helCreateVirtualizedSpace(HelHandle *handle);
1679 HelHandle spaceHandle,
void *ip,
void *sp, uint32_t flags, HelHandle *handle);
1747HEL_C_LINKAGE HelError helWriteFsBase(
void *pointer);
1749HEL_C_LINKAGE HelError helReadFsBase(
void **pointer);
1751HEL_C_LINKAGE HelError helWriteGsBase(
void *pointer);
1753HEL_C_LINKAGE HelError helReadGsBase(
void **pointer);
1764HEL_C_LINKAGE HelError helCreateVirtualizedCpu(HelHandle handle, HelHandle *out_handle);
1766HEL_C_LINKAGE HelError helRunVirtualizedCpu(HelHandle handle,
struct HelVmexitReason *reason);
1768HEL_C_LINKAGE HelError helAssertVirtualizedIrq(HelHandle handle, uint64_t irq, uint8_t level);
1770HEL_C_LINKAGE HelError helGetRandomBytes(
void *buffer,
size_t wantedSize,
size_t *actualSize);
1781HEL_C_LINKAGE HelError
helGetAffinity(HelHandle handle, uint8_t *mask,
size_t size,
size_t *actualSize);
1803HEL_C_LINKAGE HelError
helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials);
1805HEL_C_LINKAGE HelError helShutdownLane(HelHandle handle);
1828HEL_C_LINKAGE HelError
helFutexWait(
int *pointer,
int expected, int64_t deadline);
1890 HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index,
1891 const char *name, HelHandle *handle
1899HEL_C_LINKAGE HelError
helHandleIrq(HelHandle pinHandle, HelHandle *handle);
1912HEL_C_LINKAGE HelError
helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity);
1922HEL_C_LINKAGE HelError helAcknowledgeIrq(HelHandle handle, uint32_t flags, uint64_t sequence);
1924HEL_C_LINKAGE HelError helAutomateIrq(HelHandle handle, uint32_t flags, HelHandle kernlet);
1930HEL_C_LINKAGE HelError helAccessIo(
1931 HelHandle accessToken,
const uintptr_t *portArray,
size_t numPorts, HelHandle *handle
1953 const union HelKernletData *data,
size_t numData, HelHandle *boundHandle);
1957extern inline __attribute__ (( always_inline ))
const char *_helErrorString(HelError code) {
1961 case kHelErrIllegalSyscall:
1962 return "Illegal syscall";
1963 case kHelErrIllegalArgs:
1964 return "Illegal arguments";
1965 case kHelErrIllegalState:
1966 return "Illegal state";
1967 case kHelErrUnsupportedOperation:
1968 return "Unsupported operation";
1969 case kHelErrNoDescriptor:
1970 return "No such descriptor";
1971 case kHelErrBadDescriptor:
1972 return "Illegal descriptor for this operation";
1973 case kHelErrThreadTerminated:
1974 return "Thread terminated already";
1975 case kHelErrLaneShutdown:
1976 return "Lane shutdown";
1977 case kHelErrEndOfLane:
1978 return "End of lane";
1979 case kHelErrDismissed:
1980 return "IPC item dismissed by remote";
1981 case kHelErrBufferTooSmall:
1982 return "Buffer too small";
1983 case kHelErrQueueTooSmall:
1984 return "Buffer too small";
1987 case kHelErrNoHardwareSupport:
1988 return "Missing hardware support for this feature";
1989 case kHelErrNoMemory:
1990 return "Out of memory";
1991 case kHelErrTransmissionMismatch:
1992 return "Transmission mismatch";
1993 case kHelErrCancelled:
1995 case kHelErrOutOfBounds:
1996 return "Out of bounds";
1997 case kHelErrAlreadyExists:
1998 return "Already exists";
1999 case kHelErrBadRights:
2000 return "Missing rights for this operation";
2006extern inline __attribute__ (( always_inline ))
void _helCheckFailed(HelError err_code,
2007 const char *
string,
int fatal) {
2008 helLog(kHelLogSeverityError,
string, strlen(
string));
2010 const char *err_string = _helErrorString(err_code);
2012 err_string =
"(Unexpected error code)";
2013 helLog(kHelLogSeverityError, err_string, strlen(err_string));
2014 helLog(kHelLogSeverityError,
"\n", 1);
2020#define HEL_STRINGIFY_AUX(x) #x
2021#define HEL_STRINGIFY(x) HEL_STRINGIFY_AUX(x)
2023#define HEL_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
2024 _helCheckFailed(__error, "HEL_CHECK failed: " #expr "\n" \
2025 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 1); } while(0)
2026#define HEL_SOFT_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
2027 _helCheckFailed(__error, "HEL_SOFT_CHECK failed: " #expr "\n" \
2028 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 0); } while(0)
@ kHelClockTsc
x86: TSC.
Definition hel.h:433
@ kHelClockCntvct
ARM: virtual counter (CNTVCT_EL0).
Definition hel.h:437
@ kHelClockCntpct
ARM: physical counter (CNTPCT_EL0).
Definition hel.h:435
@ kHelClockNone
No clock that is accessible to userspace (= helGetClock() has to be used).
Definition hel.h:431
@ kHelClockTime
RISC-V: time CSR.
Definition hel.h:439
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 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:775
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:1125
static const uint32_t kHelNumSwapRegions
Number of swap regions per swap space.
Definition hel.h:1127
static const int kHelKernelNotifySqProgress
Set in kernelNotify after userspace has added SQ elements.
Definition hel.h:778
static const uint32_t kHelSubmitInvalidateMemory
SQ opcode: invalidate memory.
Definition hel.h:841
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 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:1040
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:827
static const uint32_t kHelSubmitUnmapMemory
SQ opcode: unmap memory.
Definition hel.h:847
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:813
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:882
static const uint32_t kHelSubmitManageMemory
SQ opcode: manage memory.
Definition hel.h:829
static const uint32_t kHelSubmitForkMemory
SQ opcode: fork memory.
Definition hel.h:837
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:886
static const uint32_t kHelSubmitUnbindDmaDevice
SQ opcode: block the DMA requests of a device.
Definition hel.h:851
static const uint32_t kHelSubmitSynchronizeSpace
SQ opcode: synchronize space.
Definition hel.h:823
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:783
static const uint32_t kHelSubmitObserve
SQ opcode: observe thread.
Definition hel.h:833
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:849
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:815
static const uint32_t kHelSubmitReadMemory
SQ opcode: read memory.
Definition hel.h:825
static const int kHelNextPresent
Marks the next field as present.
Definition hel.h:879
static const int kHelKernelNotifySupplyCqChunks
Set in kernelNotify after userspace has supplied new chunks.
Definition hel.h:780
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:819
static const uint32_t kHelSubmitAwaitClock
SQ opcode: wait for time to pass.
Definition hel.h:817
static const uint32_t kHelSubmitPopulateSpace
SQ opcode: populate a space.
Definition hel.h:843
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:853
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:821
HelMapFlags
Definition hel.h:519
@ kHelMapNoDirtyTracking
Discards the mapping's dirty bits instead of scheduling the pages for writeback.
Definition hel.h:530
static const uint32_t kHelSubmitMapMemory
SQ opcode: map memory.
Definition hel.h:845
static const int kHelUserNotifySupplySqChunks
Set in userNotify after kernel has supplied new SQ chunks.
Definition hel.h:771
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 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:769
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:839
HelUpdateMemoryTypes
Additional type values of helUpdateMemory(); these are never issued as manage requests.
Definition hel.h:512
@ kHelUpdateMarkDirty
Marks a range as dirty, as if it had been written through a dirty-tracked mapping.
Definition hel.h:516
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:835
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:831
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:884
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:752
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.
static const int kHelUserNotifyError
Set in userNotify if the queue encounters a contract violation.
Definition hel.h:773
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:855
static const uint32_t kHelSubmitCancel
SQ opcode: cancel an asynchronous operation.
Definition hel.h:811
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.
Parameters that allow userspace to compute the current time on the monotone clock (i....
Definition hel.h:451
int32_t tickShift
Scaling exponent of the tick -> nanosecond conversion.
Definition hel.h:456
uint64_t tickFactor
Factor of the tick -> nanosecond conversion.
Definition hel.h:458
uint32_t clockType
One of the kHelClock* constants.
Definition hel.h:454
Requester ID that a device issues DMA requests as (see kHelSubmitBindDmaDevice).
Definition hel.h:803
Range of physical memory that a DMA space identity-maps (see helCreateDmaSpace).
Definition hel.h:796
A single element of a HelQueue.
Definition hel.h:901
unsigned int length
Length of the element in bytes.
Definition hel.h:903
void * context
User-defined value.
Definition hel.h:907
unsigned int opcode
Operation code (for SQ elements).
Definition hel.h:905
Message address / data pair that raises an MSI (see helQueryMsiInfo).
Definition hel.h:1293
In-memory kernel/user-space queue.
Definition hel.h:858
int kernelNotify
Futex that is used to wake the kernel.
Definition hel.h:867
int userNotify
Futex that is used to wake userspace.
Definition hel.h:862
int cqFirst
Index of the first chunk of the completion queue.
Definition hel.h:871
int sqFirst
Index of the first chunk of the submission queue.
Definition hel.h:875
Register-related information returned by helQueryRegisterInfo.
Definition hel.h:581
int setSize
Size of the selected register set.
Definition hel.h:583
SQ data for kHelSubmitActivateIommu.
Definition hel.h:1117
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1119
SQ data for kHelSubmitAwaitClock.
Definition hel.h:927
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:931
uint64_t counter
Deadline in nanoseconds since boot.
Definition hel.h:929
SQ data for kHelSubmitAwaitEvent.
Definition hel.h:935
HelHandle handle
Handle to the event descriptor.
Definition hel.h:937
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:941
uint64_t sequence
Previous sequence number.
Definition hel.h:939
SQ data for kHelSubmitBindDmaDevice.
Definition hel.h:1093
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1100
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1095
HelHandle dmaSpaceHandle
Handle to a DMA space of that IOMMU (see helCreateDmaSpace).
Definition hel.h:1098
SQ data for kHelSubmitCancel.
Definition hel.h:911
SQ data for kHelSubmitExchangeMsgs.
Definition hel.h:917
uint32_t flags
Flags.
Definition hel.h:923
size_t count
Number of actions.
Definition hel.h:921
HelHandle lane
Handle to the lane.
Definition hel.h:919
SQ data for kHelSubmitForkMemory.
Definition hel.h:1021
HelHandle hierarchyHandle
Handle to the hierarchy object that owns the memory object.
Definition hel.h:1023
HelHandle handle
Handle to the memory object.
Definition hel.h:1025
SQ data for kHelSubmitInvalidateMemory.
Definition hel.h:1043
uint32_t flags
Flags (kHelInvalidate*).
Definition hel.h:1051
HelHandle handle
Handle to the memory object.
Definition hel.h:1045
size_t size
Size of the range.
Definition hel.h:1049
uintptr_t offset
Offset within the memory object.
Definition hel.h:1047
SQ data for kHelSubmitLockMemoryView.
Definition hel.h:997
size_t size
Size to lock.
Definition hel.h:1003
uintptr_t offset
Offset within the memory object.
Definition hel.h:1001
HelHandle handle
Handle to the memory object.
Definition hel.h:999
SQ data for kHelSubmitManageMemory.
Definition hel.h:991
HelHandle handle
Handle to the memory object.
Definition hel.h:993
SQ data for kHelSubmitMapMemory.
Definition hel.h:1065
uint32_t flags
Flags (kHelMap*).
Definition hel.h:1077
HelHandle spaceHandle
Handle to the space that the memory is mapped into.
Definition hel.h:1069
HelHandle memoryHandle
Handle to the memory object.
Definition hel.h:1067
uintptr_t offset
Offset within the memory object.
Definition hel.h:1073
void * pointer
Address to map at (depending on kHelMap*).
Definition hel.h:1071
size_t size
Size of the mapping.
Definition hel.h:1075
SQ data for kHelSubmitObserve.
Definition hel.h:1007
HelHandle handle
Handle to the thread.
Definition hel.h:1009
SQ data for kHelSubmitPopulateSpace.
Definition hel.h:1055
HelHandle handle
Handle to the memory space.
Definition hel.h:1057
uintptr_t address
Address within the memory space.
Definition hel.h:1059
size_t length
Length of the range.
Definition hel.h:1061
SQ data for kHelSubmitProtectMemory.
Definition hel.h:945
size_t size
Size of the mapping.
Definition hel.h:951
void * pointer
Pointer to the mapping.
Definition hel.h:949
uint32_t flags
Protection flags.
Definition hel.h:953
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:947
SQ data for kHelSubmitReadMemory.
Definition hel.h:967
uintptr_t address
Address within the memory object.
Definition hel.h:971
HelHandle handle
Handle to the memory object.
Definition hel.h:969
size_t length
Length in bytes.
Definition hel.h:973
void * buffer
Buffer to read into.
Definition hel.h:975
SQ data for kHelSubmitResizeMemory.
Definition hel.h:1013
HelHandle handle
Handle to the memory object.
Definition hel.h:1015
size_t newSize
New size in bytes.
Definition hel.h:1017
SQ data for kHelSubmitSetSwapRegion.
Definition hel.h:1133
size_t numPages
New capacity of the region in pages.
Definition hel.h:1140
HelHandle swapHandle
Handle to the swap space (from helCreateSwapSpace).
Definition hel.h:1136
uint32_t region
Index of the region. Must be smaller than kHelNumSwapRegions.
Definition hel.h:1142
SQ data for kHelSubmitSynchronizeSpace.
Definition hel.h:957
void * pointer
Pointer to the mapping.
Definition hel.h:961
size_t size
Size of the mapping.
Definition hel.h:963
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:959
SQ data for kHelSubmitUnbindDmaDevice.
Definition hel.h:1106
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1108
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1110
SQ data for kHelSubmitUnmapMemory.
Definition hel.h:1081
size_t size
Size of the mapping.
Definition hel.h:1087
void * pointer
Pointer to the mapping.
Definition hel.h:1085
HelHandle spaceHandle
Handle to the space that the mapping is removed from.
Definition hel.h:1083
SQ data for kHelSubmitWriteMemory.
Definition hel.h:979
HelHandle handle
Handle to the memory object.
Definition hel.h:981
size_t length
Length in bytes.
Definition hel.h:985
const void * buffer
Buffer to write from.
Definition hel.h:987
uintptr_t address
Address within the memory object.
Definition hel.h:983
SQ data for kHelSubmitWritebackFence.
Definition hel.h:1030
HelHandle handle
Handle to the memory object.
Definition hel.h:1032
size_t size
Size of the range.
Definition hel.h:1036
uintptr_t offset
Offset within the memory object.
Definition hel.h:1034