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
405 kHelActionDismiss = 11,
407 kHelActionAccept = 6,
408 kHelActionImbueCredentials = 8,
409 kHelActionExtractCredentials = 9,
410 kHelActionSendFromBuffer = 1,
411 kHelActionSendFromBufferSg = 10,
412 kHelActionRecvInline = 7,
413 kHelActionRecvToBuffer = 3,
414 kHelActionPushDescriptor = 2,
415 kHelActionPullDescriptor = 4
420 kHelItemAncillary = 2,
421 kHelItemWantLane = (1 << 16),
424static const uint32_t kHelTransferDescriptorOut = UINT32_C(1) << 0;
425static const uint32_t kHelTransferDescriptorIn = UINT32_C(1) << 1;
428 kHelObtainZeroMemory = 1,
429 kHelObtainClockPage = 2
493struct HelDescriptorInfo {
498 kHelAllocContinuous = 4,
499 kHelAllocOnDemand = 1,
502struct HelAllocRestrictions {
506enum HelManagedFlags {
507 kHelManagedReadahead = 1
510enum HelManageRequests {
511 kHelManageInitialize = 1,
512 kHelManageWriteback = 2
525 kHelMapProtRead = UINT32_C(1) << 8,
526 kHelMapProtWrite = UINT32_C(1) << 9,
527 kHelMapProtExecute = UINT32_C(1) << 10,
528 kHelMapDontRequireBacking = UINT32_C(1) << 7,
529 kHelMapFixed = UINT32_C(1) << 11,
530 kHelMapFixedNoReplace = UINT32_C(1) << 12,
531 kHelMapPreferBottom = UINT32_C(1) << 13,
538 kHelSliceCacheWriteCombine = 1,
542 kHelCachingDefault = 0,
543 kHelCachingUncached = 1,
544 kHelCachingWriteCombine = 2,
545 kHelCachingWriteThrough = 3,
546 kHelCachingWriteBack = 4,
548 kHelCachingMmioNonPosted = 6
552 kHelThreadStopped = 1
557 kHelObserveInterrupt = 4,
558 kHelObservePanic = 3,
559 kHelObserveBreakpoint = 1,
560 kHelObservePageFault = 2,
561 kHelObserveGeneralFault = 5,
562 kHelObserveIllegalInstruction = 6,
563 kHelObserveDivByZero = 7,
564 kHelObserveSuperCall = 0x80000000
567enum HelRegisterSets {
572 kHelRegsVirtualization = 5,
575 kHelRegsPageFault = 8
578enum HelPageFaultFlags {
579 kHelPageFaultMapError = 1,
580 kHelPageFaultAccessError = 2,
581 kHelPageFaultOutOfMemory = 3
590#if defined(__x86_64__)
591enum HelRegisterIndex {
615 kHelRegNumber = kHelRegRdi,
616 kHelRegError = kHelRegRdi,
618 kHelRegArg0 = kHelRegRsi,
619 kHelRegArg1 = kHelRegRdx,
620 kHelRegArg2 = kHelRegRax,
621 kHelRegArg3 = kHelRegR8,
622 kHelRegArg4 = kHelRegR9,
623 kHelRegArg5 = kHelRegR10,
624 kHelRegArg6 = kHelRegR12,
625 kHelRegArg7 = kHelRegR13,
626 kHelRegArg8 = kHelRegR14,
628 kHelRegOut0 = kHelRegRsi,
629 kHelRegOut1 = kHelRegRdx,
630 kHelRegOut2 = kHelRegRax
633#elif defined(__aarch64__)
634enum HelRegisterIndex {
674 kHelRegNumber = kHelRegX0,
675 kHelRegError = kHelRegX0,
677 kHelRegArg0 = kHelRegX1,
678 kHelRegArg1 = kHelRegX2,
679 kHelRegArg2 = kHelRegX3,
680 kHelRegArg3 = kHelRegX4,
681 kHelRegArg4 = kHelRegX5,
682 kHelRegArg5 = kHelRegX6,
683 kHelRegArg6 = kHelRegX7,
684 kHelRegArg7 = kHelRegX8,
685 kHelRegArg8 = kHelRegX9,
687 kHelRegOut0 = kHelRegX1,
688 kHelRegOut1 = kHelRegX2,
689 kHelRegOut2 = kHelRegX3
692#elif defined(__riscv) && __riscv_xlen == 64
693enum HelRegisterIndex {
729 kHelRegNumber = kHelRegA0,
730 kHelRegError = kHelRegA0,
731 kHelRegArg0 = kHelRegA1,
732 kHelRegArg1 = kHelRegA2,
733 kHelRegArg2 = kHelRegA3,
734 kHelRegArg3 = kHelRegA4,
735 kHelRegArg4 = kHelRegA5,
736 kHelRegArg5 = kHelRegA6,
737 kHelRegArg6 = kHelRegA7,
738 kHelRegArg7 = kHelRegS2,
739 kHelRegArg8 = kHelRegS3,
741 kHelRegOut0 = kHelRegA1,
742 kHelRegOut1 = kHelRegA2,
743 kHelRegOut2 = kHelRegA3
748struct HelQueueParameters {
750 unsigned int numChunks;
752 unsigned int numSqChunks;
755struct HelHierarchyParameters {
779 kHelAccessIommuIntelVtd = 1,
780 kHelAccessIommuAmdVi = 2,
784 kHelDmaRegionRead = 1,
785 kHelDmaRegionWrite = 2,
905 uint64_t cancellationTag;
1138struct HelSimpleResult {
1143struct HelCredentialsResult {
1146 char credentials[16];
1149struct HelManageResult {
1156struct HelObserveResult {
1158 unsigned int observation;
1161struct HelInlineResult {
1168struct HelInlineResultNoFlex {
1174struct HelLengthResult {
1180struct HelHandleResult {
1186struct HelPointerResult {
1192struct HelEventResult {
1199 kHelAckAcknowledge = 2,
1202 kHelAckClear = 0x100,
1205union HelKernletData {
1209struct HelThreadStats {
1215 kHelVmexitTranslationFault = 1,
1216 kHelVmexitHyperCall = 2,
1217 kHelVmexitInstructionTrap = 3,
1218 kHelVmexitError = -1,
1219 kHelVmexitUnknownPlatformSpecificExitCode = -2,
1223 kHelVmFaultRead = 1 << 0,
1224 kHelVmFaultWrite = 1 << 1,
1225 kHelVmFaultExecute = 1 << 2,
1228#if defined(__riscv) && __riscv_xlen == 64
1230struct HelVmexitReason {
1231 uint32_t exitReason;
1234 uint64_t instruction;
1241struct HelVmexitReason {
1242 uint32_t exitReason;
1251enum HelLogSeverity {
1252 kHelLogSeverityEmergency,
1253 kHelLogSeverityAlert,
1254 kHelLogSeverityCritical,
1255 kHelLogSeverityError,
1256 kHelLogSeverityWarning,
1257 kHelLogSeverityNotice,
1258 kHelLogSeverityInfo,
1259 kHelLogSeverityDebug,
1263 kHelAccessIrqByGsi = 1,
1264 kHelAccessIrqByPhandle = 2,
1265 kHelAccessIrqAllocateMsi = 3,
1270 kHelIrqNameSize = 32,
1274 kHelIrqTriggerNull = 0,
1275 kHelIrqTriggerEdge = 1,
1276 kHelIrqTriggerLevel = 2
1280 kHelIrqPolarityNull = 0,
1281 kHelIrqPolarityHigh = 1,
1282 kHelIrqPolarityLow = 2
1301HEL_C_LINKAGE HelError
helLog(
const enum HelLogSeverity severity,
const char *
string,
size_t length);
1308HEL_C_LINKAGE
void helPanic(
const char *
string,
size_t length)
1309 __attribute__ (( noreturn ));
1331 const struct HelHierarchyParameters *params, HelHandle *handle);
1349HEL_C_LINKAGE HelError
1351 uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle);
1353HEL_C_LINKAGE HelError helDescriptorInfo(HelHandle handle,
struct HelDescriptorInfo *info);
1400HEL_C_LINKAGE HelError
helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask);
1427 const struct HelAllocRestrictions *restrictions, HelHandle *handle);
1452 HelHandle *backingHandle, HelHandle *frontalHandle);
1476 HelHandle *backingHandle, HelHandle *swapHandle);
1494 size_t size, uint32_t flags, HelHandle *handle);
1514HEL_C_LINKAGE HelError
helCopyOnWrite(HelHandle hierarchy, HelHandle swapSpace, HelHandle memory,
1515 uintptr_t offset,
size_t size, HelHandle *handle);
1517HEL_C_LINKAGE HelError helAccessPhysical(
1518 HelHandle accessToken, uintptr_t physical,
size_t size, uint32_t cachingMode, HelHandle *handle
1545 HelHandle memoryHandle, uintptr_t offset,
size_t size);
1547HEL_C_LINKAGE HelError helCreateSliceView(HelHandle bundle, uintptr_t offset,
size_t size,
1548 uint32_t flags, HelHandle *handle);
1573HEL_C_LINKAGE HelError
helAccessIommu(HelHandle accessHandle, uint32_t mode, uint64_t base,
1597 uint32_t flags, HelHandle *handle);
1616HEL_C_LINKAGE HelError
helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle,
1617 void *pointer, uintptr_t offset,
size_t size, uint32_t flags,
void **actualPointer);
1630HEL_C_LINKAGE HelError
helUnmapMemory(HelHandle spaceHandle,
void *pointer,
size_t size);
1632HEL_C_LINKAGE HelError helPointerPhysical(HelHandle spaceHandle,
const void *pointer, uintptr_t *physical);
1634HEL_C_LINKAGE HelError helMemoryInfo(HelHandle handle,
1637HEL_C_LINKAGE HelError helUpdateMemory(HelHandle handle,
int type, uintptr_t offset,
size_t length);
1649HEL_C_LINKAGE HelError
helLoadahead(HelHandle handle, uintptr_t offset,
size_t length);
1651HEL_C_LINKAGE HelError helCreateVirtualizedSpace(HelHandle *handle);
1671 HelAbi abi,
void *ip,
void *sp, uint32_t flags, HelHandle *handle);
1739HEL_C_LINKAGE HelError helWriteFsBase(
void *pointer);
1741HEL_C_LINKAGE HelError helReadFsBase(
void **pointer);
1743HEL_C_LINKAGE HelError helWriteGsBase(
void *pointer);
1745HEL_C_LINKAGE HelError helReadGsBase(
void **pointer);
1756HEL_C_LINKAGE HelError helCreateVirtualizedCpu(HelHandle handle, HelHandle *out_handle);
1758HEL_C_LINKAGE HelError helRunVirtualizedCpu(HelHandle handle,
struct HelVmexitReason *reason);
1760HEL_C_LINKAGE HelError helAssertVirtualizedIrq(HelHandle handle, uint64_t irq, uint8_t level);
1762HEL_C_LINKAGE HelError helGetRandomBytes(
void *buffer,
size_t wantedSize,
size_t *actualSize);
1773HEL_C_LINKAGE HelError
helGetAffinity(HelHandle handle, uint8_t *mask,
size_t size,
size_t *actualSize);
1795HEL_C_LINKAGE HelError
helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials);
1797HEL_C_LINKAGE HelError helShutdownLane(HelHandle handle);
1820HEL_C_LINKAGE HelError
helFutexWait(
int *pointer,
int expected, int64_t deadline);
1882 HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index,
1883 const char *name, HelHandle *handle
1891HEL_C_LINKAGE HelError
helHandleIrq(HelHandle pinHandle, HelHandle *handle);
1904HEL_C_LINKAGE HelError
helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity);
1914HEL_C_LINKAGE HelError helAcknowledgeIrq(HelHandle handle, uint32_t flags, uint64_t sequence);
1916HEL_C_LINKAGE HelError helAutomateIrq(HelHandle handle, uint32_t flags, HelHandle kernlet);
1922HEL_C_LINKAGE HelError helAccessIo(
1923 HelHandle accessToken,
const uintptr_t *portArray,
size_t numPorts, HelHandle *handle
1945 const union HelKernletData *data,
size_t numData, HelHandle *boundHandle);
1949extern inline __attribute__ (( always_inline ))
const char *_helErrorString(HelError code) {
1953 case kHelErrIllegalSyscall:
1954 return "Illegal syscall";
1955 case kHelErrIllegalArgs:
1956 return "Illegal arguments";
1957 case kHelErrIllegalState:
1958 return "Illegal state";
1959 case kHelErrUnsupportedOperation:
1960 return "Unsupported operation";
1961 case kHelErrNoDescriptor:
1962 return "No such descriptor";
1963 case kHelErrBadDescriptor:
1964 return "Illegal descriptor for this operation";
1965 case kHelErrThreadTerminated:
1966 return "Thread terminated already";
1967 case kHelErrLaneShutdown:
1968 return "Lane shutdown";
1969 case kHelErrEndOfLane:
1970 return "End of lane";
1971 case kHelErrDismissed:
1972 return "IPC item dismissed by remote";
1973 case kHelErrBufferTooSmall:
1974 return "Buffer too small";
1975 case kHelErrQueueTooSmall:
1976 return "Buffer too small";
1979 case kHelErrNoHardwareSupport:
1980 return "Missing hardware support for this feature";
1981 case kHelErrNoMemory:
1982 return "Out of memory";
1983 case kHelErrTransmissionMismatch:
1984 return "Transmission mismatch";
1985 case kHelErrCancelled:
1987 case kHelErrOutOfBounds:
1988 return "Out of bounds";
1989 case kHelErrAlreadyExists:
1990 return "Already exists";
1991 case kHelErrBadRights:
1992 return "Missing rights for this operation";
1998extern inline __attribute__ (( always_inline ))
void _helCheckFailed(HelError err_code,
1999 const char *
string,
int fatal) {
2000 helLog(kHelLogSeverityError,
string, strlen(
string));
2002 const char *err_string = _helErrorString(err_code);
2004 err_string =
"(Unexpected error code)";
2005 helLog(kHelLogSeverityError, err_string, strlen(err_string));
2006 helLog(kHelLogSeverityError,
"\n", 1);
2012#define HEL_STRINGIFY_AUX(x) #x
2013#define HEL_STRINGIFY(x) HEL_STRINGIFY_AUX(x)
2015#define HEL_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
2016 _helCheckFailed(__error, "HEL_CHECK failed: " #expr "\n" \
2017 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 1); } while(0)
2018#define HEL_SOFT_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
2019 _helCheckFailed(__error, "HEL_SOFT_CHECK failed: " #expr "\n" \
2020 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 0); } while(0)
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:768
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:1118
static const uint32_t kHelNumSwapRegions
Number of swap regions per swap space.
Definition hel.h:1120
static const int kHelKernelNotifySqProgress
Set in kernelNotify after userspace has added SQ elements.
Definition hel.h:771
static const uint32_t kHelSubmitInvalidateMemory
SQ opcode: invalidate memory.
Definition hel.h:834
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:1033
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:820
static const uint32_t kHelSubmitUnmapMemory
SQ opcode: unmap memory.
Definition hel.h:840
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:806
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:875
static const uint32_t kHelSubmitManageMemory
SQ opcode: manage memory.
Definition hel.h:822
static const uint32_t kHelSubmitForkMemory
SQ opcode: fork memory.
Definition hel.h:830
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:879
static const uint32_t kHelSubmitUnbindDmaDevice
SQ opcode: block the DMA requests of a device.
Definition hel.h:844
static const uint32_t kHelSubmitSynchronizeSpace
SQ opcode: synchronize space.
Definition hel.h:816
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:776
static const uint32_t kHelSubmitObserve
SQ opcode: observe thread.
Definition hel.h:826
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.
HEL_C_LINKAGE HelError helCreateThread(HelHandle universe, HelHandle spaceHandle, HelAbi abi, void *ip, void *sp, uint32_t flags, HelHandle *handle)
Create a new thread.
static const uint32_t kHelSubmitBindDmaDevice
SQ opcode: bind a device to a DMA space.
Definition hel.h:842
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:808
static const uint32_t kHelSubmitReadMemory
SQ opcode: read memory.
Definition hel.h:818
static const int kHelNextPresent
Marks the next field as present.
Definition hel.h:872
static const int kHelKernelNotifySupplyCqChunks
Set in kernelNotify after userspace has supplied new chunks.
Definition hel.h:773
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:812
static const uint32_t kHelSubmitAwaitClock
SQ opcode: wait for time to pass.
Definition hel.h:810
static const uint32_t kHelSubmitPopulateSpace
SQ opcode: populate a space.
Definition hel.h:836
@ kHelClockTsc
x86: TSC.
Definition hel.h:437
@ kHelClockCntvct
ARM: virtual counter (CNTVCT_EL0).
Definition hel.h:441
@ kHelClockCntpct
ARM: physical counter (CNTPCT_EL0).
Definition hel.h:439
@ kHelClockNone
No clock that is accessible to userspace (= helGetClock() has to be used).
Definition hel.h:435
@ kHelClockTime
RISC-V: time CSR.
Definition hel.h:443
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:846
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:814
HelMapFlags
Definition hel.h:523
@ kHelMapNoDirtyTracking
Discards the mapping's dirty bits instead of scheduling the pages for writeback.
Definition hel.h:534
static const uint32_t kHelSubmitMapMemory
SQ opcode: map memory.
Definition hel.h:838
static const int kHelUserNotifySupplySqChunks
Set in userNotify after kernel has supplied new SQ chunks.
Definition hel.h:764
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:762
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:832
HelUpdateMemoryTypes
Additional type values of helUpdateMemory(); these are never issued as manage requests.
Definition hel.h:516
@ kHelUpdateMarkDirty
Marks a range as dirty, as if it had been written through a dirty-tracked mapping.
Definition hel.h:520
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:828
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:824
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:877
HEL_C_LINKAGE HelError helEnableIo(HelHandle handle)
Enable userspace access to hardware I/O resources.
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:766
HEL_C_LINKAGE HelError helExtendHierarchy(HelHandle hierarchyHandle, const struct HelHierarchyParameters *params, HelHandle *handle)
Creates a child hierarchy capability.
static const uint32_t kHelSubmitSetSwapRegion
SQ opcode: set the capacity of a swap region.
Definition hel.h:848
static const uint32_t kHelSubmitCancel
SQ opcode: cancel an asynchronous operation.
Definition hel.h:804
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:455
int32_t tickShift
Scaling exponent of the tick -> nanosecond conversion.
Definition hel.h:460
uint64_t tickFactor
Factor of the tick -> nanosecond conversion.
Definition hel.h:462
uint32_t clockType
One of the kHelClock* constants.
Definition hel.h:458
Requester ID that a device issues DMA requests as (see kHelSubmitBindDmaDevice).
Definition hel.h:796
Range of physical memory that a DMA space identity-maps (see helCreateDmaSpace).
Definition hel.h:789
A single element of a HelQueue.
Definition hel.h:894
unsigned int length
Length of the element in bytes.
Definition hel.h:896
void * context
User-defined value.
Definition hel.h:900
unsigned int opcode
Operation code (for SQ elements).
Definition hel.h:898
Message address / data pair that raises an MSI (see helQueryMsiInfo).
Definition hel.h:1286
In-memory kernel/user-space queue.
Definition hel.h:851
int kernelNotify
Futex that is used to wake the kernel.
Definition hel.h:860
int userNotify
Futex that is used to wake userspace.
Definition hel.h:855
int cqFirst
Index of the first chunk of the completion queue.
Definition hel.h:864
int sqFirst
Index of the first chunk of the submission queue.
Definition hel.h:868
Register-related information returned by helQueryRegisterInfo.
Definition hel.h:585
int setSize
Size of the selected register set.
Definition hel.h:587
SQ data for kHelSubmitActivateIommu.
Definition hel.h:1110
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1112
SQ data for kHelSubmitAwaitClock.
Definition hel.h:920
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:924
uint64_t counter
Deadline in nanoseconds since boot.
Definition hel.h:922
SQ data for kHelSubmitAwaitEvent.
Definition hel.h:928
HelHandle handle
Handle to the event descriptor.
Definition hel.h:930
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:934
uint64_t sequence
Previous sequence number.
Definition hel.h:932
SQ data for kHelSubmitBindDmaDevice.
Definition hel.h:1086
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1093
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1088
HelHandle dmaSpaceHandle
Handle to a DMA space of that IOMMU (see helCreateDmaSpace).
Definition hel.h:1091
SQ data for kHelSubmitCancel.
Definition hel.h:904
SQ data for kHelSubmitExchangeMsgs.
Definition hel.h:910
uint32_t flags
Flags.
Definition hel.h:916
size_t count
Number of actions.
Definition hel.h:914
HelHandle lane
Handle to the lane.
Definition hel.h:912
SQ data for kHelSubmitForkMemory.
Definition hel.h:1014
HelHandle hierarchyHandle
Handle to the hierarchy object that owns the memory object.
Definition hel.h:1016
HelHandle handle
Handle to the memory object.
Definition hel.h:1018
SQ data for kHelSubmitInvalidateMemory.
Definition hel.h:1036
uint32_t flags
Flags (kHelInvalidate*).
Definition hel.h:1044
HelHandle handle
Handle to the memory object.
Definition hel.h:1038
size_t size
Size of the range.
Definition hel.h:1042
uintptr_t offset
Offset within the memory object.
Definition hel.h:1040
SQ data for kHelSubmitLockMemoryView.
Definition hel.h:990
size_t size
Size to lock.
Definition hel.h:996
uintptr_t offset
Offset within the memory object.
Definition hel.h:994
HelHandle handle
Handle to the memory object.
Definition hel.h:992
SQ data for kHelSubmitManageMemory.
Definition hel.h:984
HelHandle handle
Handle to the memory object.
Definition hel.h:986
SQ data for kHelSubmitMapMemory.
Definition hel.h:1058
uint32_t flags
Flags (kHelMap*).
Definition hel.h:1070
HelHandle spaceHandle
Handle to the space that the memory is mapped into.
Definition hel.h:1062
HelHandle memoryHandle
Handle to the memory object.
Definition hel.h:1060
uintptr_t offset
Offset within the memory object.
Definition hel.h:1066
void * pointer
Address to map at (depending on kHelMap*).
Definition hel.h:1064
size_t size
Size of the mapping.
Definition hel.h:1068
SQ data for kHelSubmitObserve.
Definition hel.h:1000
HelHandle handle
Handle to the thread.
Definition hel.h:1002
SQ data for kHelSubmitPopulateSpace.
Definition hel.h:1048
HelHandle handle
Handle to the memory space.
Definition hel.h:1050
uintptr_t address
Address within the memory space.
Definition hel.h:1052
size_t length
Length of the range.
Definition hel.h:1054
SQ data for kHelSubmitProtectMemory.
Definition hel.h:938
size_t size
Size of the mapping.
Definition hel.h:944
void * pointer
Pointer to the mapping.
Definition hel.h:942
uint32_t flags
Protection flags.
Definition hel.h:946
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:940
SQ data for kHelSubmitReadMemory.
Definition hel.h:960
uintptr_t address
Address within the memory object.
Definition hel.h:964
HelHandle handle
Handle to the memory object.
Definition hel.h:962
size_t length
Length in bytes.
Definition hel.h:966
void * buffer
Buffer to read into.
Definition hel.h:968
SQ data for kHelSubmitResizeMemory.
Definition hel.h:1006
HelHandle handle
Handle to the memory object.
Definition hel.h:1008
size_t newSize
New size in bytes.
Definition hel.h:1010
SQ data for kHelSubmitSetSwapRegion.
Definition hel.h:1126
size_t numPages
New capacity of the region in pages.
Definition hel.h:1133
HelHandle swapHandle
Handle to the swap space (from helCreateSwapSpace).
Definition hel.h:1129
uint32_t region
Index of the region. Must be smaller than kHelNumSwapRegions.
Definition hel.h:1135
SQ data for kHelSubmitSynchronizeSpace.
Definition hel.h:950
void * pointer
Pointer to the mapping.
Definition hel.h:954
size_t size
Size of the mapping.
Definition hel.h:956
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:952
SQ data for kHelSubmitUnbindDmaDevice.
Definition hel.h:1099
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1101
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1103
SQ data for kHelSubmitUnmapMemory.
Definition hel.h:1074
size_t size
Size of the mapping.
Definition hel.h:1080
void * pointer
Pointer to the mapping.
Definition hel.h:1078
HelHandle spaceHandle
Handle to the space that the mapping is removed from.
Definition hel.h:1076
SQ data for kHelSubmitWriteMemory.
Definition hel.h:972
HelHandle handle
Handle to the memory object.
Definition hel.h:974
size_t length
Length in bytes.
Definition hel.h:978
const void * buffer
Buffer to write from.
Definition hel.h:980
uintptr_t address
Address within the memory object.
Definition hel.h:976
SQ data for kHelSubmitWritebackFence.
Definition hel.h:1023
HelHandle handle
Handle to the memory object.
Definition hel.h:1025
size_t size
Size of the range.
Definition hel.h:1029
uintptr_t offset
Offset within the memory object.
Definition hel.h:1027