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,
67 kHelCallSetSwapBudget = 112,
69 kHelCallAccessIommu = 13,
71 kHelCallCreateThread = 67,
72 kHelCallQueryThreadStats = 95,
73 kHelCallSetPriority = 85,
75 kHelCallSubmitObserve = 74,
76 kHelCallKillThread = 87,
77 kHelCallInterruptThread = 86,
79 kHelCallLoadRegisters = 75,
80 kHelCallStoreRegisters = 76,
81 kHelCallQueryRegisterInfo = 102,
82 kHelCallWriteFsBase = 41,
83 kHelCallGetClock = 42,
84 kHelCallSubmitAwaitClock = 80,
85 kHelCallCreateVirtualizedCpu = 37,
86 kHelCallRunVirtualizedCpu = 38,
87 kHelCallAssertVirtualizedIrq = 107,
88 kHelCallGetRandomBytes = 101,
89 kHelCallWriteGsBase = 54,
90 kHelCallReadFsBase = 55,
91 kHelCallReadGsBase = 56,
92 kHelCallGetCurrentCpu = 57,
94 kHelCallCreateStream = 68,
95 kHelCallSubmitAsync = 79,
96 kHelCallShutdownLane = 91,
98 kHelCallFutexWait = 73,
99 kHelCallFutexWake = 71,
101 kHelCallCreateOneshotEvent = 96,
102 kHelCallCreateBitsetEvent = 97,
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
589#if defined(__x86_64__)
590enum HelRegisterIndex {
614 kHelRegNumber = kHelRegRdi,
615 kHelRegError = kHelRegRdi,
617 kHelRegArg0 = kHelRegRsi,
618 kHelRegArg1 = kHelRegRdx,
619 kHelRegArg2 = kHelRegRax,
620 kHelRegArg3 = kHelRegR8,
621 kHelRegArg4 = kHelRegR9,
622 kHelRegArg5 = kHelRegR10,
623 kHelRegArg6 = kHelRegR12,
624 kHelRegArg7 = kHelRegR13,
625 kHelRegArg8 = kHelRegR14,
627 kHelRegOut0 = kHelRegRsi,
628 kHelRegOut1 = kHelRegRdx,
629 kHelRegOut2 = kHelRegRax
632#elif defined(__aarch64__)
633enum HelRegisterIndex {
673 kHelRegNumber = kHelRegX0,
674 kHelRegError = kHelRegX0,
676 kHelRegArg0 = kHelRegX1,
677 kHelRegArg1 = kHelRegX2,
678 kHelRegArg2 = kHelRegX3,
679 kHelRegArg3 = kHelRegX4,
680 kHelRegArg4 = kHelRegX5,
681 kHelRegArg5 = kHelRegX6,
682 kHelRegArg6 = kHelRegX7,
683 kHelRegArg7 = kHelRegX8,
684 kHelRegArg8 = kHelRegX9,
686 kHelRegOut0 = kHelRegX1,
687 kHelRegOut1 = kHelRegX2,
688 kHelRegOut2 = kHelRegX3
691#elif defined(__riscv) && __riscv_xlen == 64
692enum HelRegisterIndex {
728 kHelRegNumber = kHelRegA0,
729 kHelRegError = kHelRegA0,
730 kHelRegArg0 = kHelRegA1,
731 kHelRegArg1 = kHelRegA2,
732 kHelRegArg2 = kHelRegA3,
733 kHelRegArg3 = kHelRegA4,
734 kHelRegArg4 = kHelRegA5,
735 kHelRegArg5 = kHelRegA6,
736 kHelRegArg6 = kHelRegA7,
737 kHelRegArg7 = kHelRegS2,
738 kHelRegArg8 = kHelRegS3,
740 kHelRegOut0 = kHelRegA1,
741 kHelRegOut1 = kHelRegA2,
742 kHelRegOut2 = kHelRegA3
747struct HelQueueParameters {
749 unsigned int numChunks;
751 unsigned int numSqChunks;
754struct HelHierarchyParameters {
778 kHelAccessIommuIntelVtd = 1,
779 kHelAccessIommuAmdVi = 2,
783 kHelDmaRegionRead = 1,
784 kHelDmaRegionWrite = 2,
902 uint64_t cancellationTag;
1112struct HelSimpleResult {
1117struct HelCredentialsResult {
1120 char credentials[16];
1123struct HelManageResult {
1130struct HelObserveResult {
1132 unsigned int observation;
1135struct HelInlineResult {
1142struct HelInlineResultNoFlex {
1148struct HelLengthResult {
1154struct HelHandleResult {
1160struct HelPointerResult {
1166struct HelEventResult {
1173 kHelAckAcknowledge = 2,
1176 kHelAckClear = 0x100,
1179union HelKernletData {
1183struct HelThreadStats {
1189 kHelVmexitTranslationFault = 1,
1190 kHelVmexitHyperCall = 2,
1191 kHelVmexitInstructionTrap = 3,
1192 kHelVmexitError = -1,
1193 kHelVmexitUnknownPlatformSpecificExitCode = -2,
1197 kHelVmFaultRead = 1 << 0,
1198 kHelVmFaultWrite = 1 << 1,
1199 kHelVmFaultExecute = 1 << 2,
1202#if defined(__riscv) && __riscv_xlen == 64
1204struct HelVmexitReason {
1205 uint32_t exitReason;
1208 uint64_t instruction;
1215struct HelVmexitReason {
1216 uint32_t exitReason;
1225enum HelLogSeverity {
1226 kHelLogSeverityEmergency,
1227 kHelLogSeverityAlert,
1228 kHelLogSeverityCritical,
1229 kHelLogSeverityError,
1230 kHelLogSeverityWarning,
1231 kHelLogSeverityNotice,
1232 kHelLogSeverityInfo,
1233 kHelLogSeverityDebug,
1237 kHelAccessIrqByGsi = 1,
1238 kHelAccessIrqByPhandle = 2,
1239 kHelAccessIrqAllocateMsi = 3,
1244 kHelIrqNameSize = 32,
1248 kHelIrqTriggerNull = 0,
1249 kHelIrqTriggerEdge = 1,
1250 kHelIrqTriggerLevel = 2
1254 kHelIrqPolarityNull = 0,
1255 kHelIrqPolarityHigh = 1,
1256 kHelIrqPolarityLow = 2
1275HEL_C_LINKAGE HelError
helLog(
const enum HelLogSeverity severity,
const char *
string,
size_t length);
1282HEL_C_LINKAGE
void helPanic(
const char *
string,
size_t length)
1283 __attribute__ (( noreturn ));
1305 const struct HelHierarchyParameters *params, HelHandle *handle);
1323HEL_C_LINKAGE HelError
1325 uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle);
1327HEL_C_LINKAGE HelError helDescriptorInfo(HelHandle handle,
struct HelDescriptorInfo *info);
1374HEL_C_LINKAGE HelError
helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask);
1401 const struct HelAllocRestrictions *restrictions, HelHandle *handle);
1426 HelHandle *backingHandle, HelHandle *frontalHandle);
1450 HelHandle *backingHandle, HelHandle *swapHandle);
1467 size_t size, uint32_t flags, HelHandle *handle);
1494HEL_C_LINKAGE HelError
helCopyOnWrite(HelHandle hierarchy, HelHandle swapSpace, HelHandle memory,
1495 uintptr_t offset,
size_t size, HelHandle *handle);
1497HEL_C_LINKAGE HelError helAccessPhysical(
1498 HelHandle accessToken, uintptr_t physical,
size_t size, uint32_t cachingMode, HelHandle *handle
1525 HelHandle memoryHandle, uintptr_t offset,
size_t size);
1527HEL_C_LINKAGE HelError helCreateSliceView(HelHandle bundle, uintptr_t offset,
size_t size,
1528 uint32_t flags, HelHandle *handle);
1553HEL_C_LINKAGE HelError
helAccessIommu(HelHandle accessHandle, uint32_t mode, uint64_t base,
1577 uint32_t flags, HelHandle *handle);
1596HEL_C_LINKAGE HelError
helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle,
1597 void *pointer, uintptr_t offset,
size_t size, uint32_t flags,
void **actualPointer);
1610HEL_C_LINKAGE HelError
helUnmapMemory(HelHandle spaceHandle,
void *pointer,
size_t size);
1612HEL_C_LINKAGE HelError helPointerPhysical(HelHandle spaceHandle,
const void *pointer, uintptr_t *physical);
1614HEL_C_LINKAGE HelError helMemoryInfo(HelHandle handle,
1617HEL_C_LINKAGE HelError helUpdateMemory(HelHandle handle,
int type, uintptr_t offset,
size_t length);
1629HEL_C_LINKAGE HelError
helLoadahead(HelHandle handle, uintptr_t offset,
size_t length);
1631HEL_C_LINKAGE HelError helCreateVirtualizedSpace(HelHandle *handle);
1651 HelAbi abi,
void *ip,
void *sp, uint32_t flags, HelHandle *handle);
1719HEL_C_LINKAGE HelError helWriteFsBase(
void *pointer);
1721HEL_C_LINKAGE HelError helReadFsBase(
void **pointer);
1723HEL_C_LINKAGE HelError helWriteGsBase(
void *pointer);
1725HEL_C_LINKAGE HelError helReadGsBase(
void **pointer);
1736HEL_C_LINKAGE HelError helCreateVirtualizedCpu(HelHandle handle, HelHandle *out_handle);
1738HEL_C_LINKAGE HelError helRunVirtualizedCpu(HelHandle handle,
struct HelVmexitReason *reason);
1740HEL_C_LINKAGE HelError helAssertVirtualizedIrq(HelHandle handle, uint64_t irq, uint8_t level);
1742HEL_C_LINKAGE HelError helGetRandomBytes(
void *buffer,
size_t wantedSize,
size_t *actualSize);
1753HEL_C_LINKAGE HelError
helGetAffinity(HelHandle handle, uint8_t *mask,
size_t size,
size_t *actualSize);
1775HEL_C_LINKAGE HelError
helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials);
1777HEL_C_LINKAGE HelError helShutdownLane(HelHandle handle);
1800HEL_C_LINKAGE HelError
helFutexWait(
int *pointer,
int expected, int64_t deadline);
1849 HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index,
1850 const char *name, HelHandle *handle
1858HEL_C_LINKAGE HelError
helHandleIrq(HelHandle pinHandle, HelHandle *handle);
1871HEL_C_LINKAGE HelError
helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity);
1881HEL_C_LINKAGE HelError helAcknowledgeIrq(HelHandle handle, uint32_t flags, uint64_t sequence);
1883HEL_C_LINKAGE HelError helAutomateIrq(HelHandle handle, uint32_t flags, HelHandle kernlet);
1889HEL_C_LINKAGE HelError helAccessIo(
1890 HelHandle accessToken,
const uintptr_t *portArray,
size_t numPorts, HelHandle *handle
1912 const union HelKernletData *data,
size_t numData, HelHandle *boundHandle);
1916extern inline __attribute__ (( always_inline ))
const char *_helErrorString(HelError code) {
1920 case kHelErrIllegalSyscall:
1921 return "Illegal syscall";
1922 case kHelErrIllegalArgs:
1923 return "Illegal arguments";
1924 case kHelErrIllegalState:
1925 return "Illegal state";
1926 case kHelErrUnsupportedOperation:
1927 return "Unsupported operation";
1928 case kHelErrNoDescriptor:
1929 return "No such descriptor";
1930 case kHelErrBadDescriptor:
1931 return "Illegal descriptor for this operation";
1932 case kHelErrThreadTerminated:
1933 return "Thread terminated already";
1934 case kHelErrLaneShutdown:
1935 return "Lane shutdown";
1936 case kHelErrEndOfLane:
1937 return "End of lane";
1938 case kHelErrDismissed:
1939 return "IPC item dismissed by remote";
1940 case kHelErrBufferTooSmall:
1941 return "Buffer too small";
1942 case kHelErrQueueTooSmall:
1943 return "Buffer too small";
1946 case kHelErrNoHardwareSupport:
1947 return "Missing hardware support for this feature";
1948 case kHelErrNoMemory:
1949 return "Out of memory";
1950 case kHelErrTransmissionMismatch:
1951 return "Transmission mismatch";
1952 case kHelErrCancelled:
1954 case kHelErrOutOfBounds:
1955 return "Out of bounds";
1956 case kHelErrAlreadyExists:
1957 return "Already exists";
1958 case kHelErrBadRights:
1959 return "Missing rights for this operation";
1965extern inline __attribute__ (( always_inline ))
void _helCheckFailed(HelError err_code,
1966 const char *
string,
int fatal) {
1967 helLog(kHelLogSeverityError,
string, strlen(
string));
1969 const char *err_string = _helErrorString(err_code);
1971 err_string =
"(Unexpected error code)";
1972 helLog(kHelLogSeverityError, err_string, strlen(err_string));
1973 helLog(kHelLogSeverityError,
"\n", 1);
1979#define HEL_STRINGIFY_AUX(x) #x
1980#define HEL_STRINGIFY(x) HEL_STRINGIFY_AUX(x)
1982#define HEL_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
1983 _helCheckFailed(__error, "HEL_CHECK failed: " #expr "\n" \
1984 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 1); } while(0)
1985#define HEL_SOFT_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
1986 _helCheckFailed(__error, "HEL_SOFT_CHECK failed: " #expr "\n" \
1987 " 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:767
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 helSetSwapBudget(HelHandle swapSpace, size_t numPages)
Sets a swap space's budget, which is the number of pages that may be swapped out.
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 kHelKernelNotifySqProgress
Set in kernelNotify after userspace has added SQ elements.
Definition hel.h:770
static const uint32_t kHelSubmitInvalidateMemory
SQ opcode: invalidate memory.
Definition hel.h:833
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:1030
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:819
static const uint32_t kHelSubmitUnmapMemory
SQ opcode: unmap memory.
Definition hel.h:839
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:805
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:872
static const uint32_t kHelSubmitManageMemory
SQ opcode: manage memory.
Definition hel.h:821
static const uint32_t kHelSubmitForkMemory
SQ opcode: fork memory.
Definition hel.h:829
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:876
static const uint32_t kHelSubmitUnbindDmaDevice
SQ opcode: block the DMA requests of a device.
Definition hel.h:843
static const uint32_t kHelSubmitSynchronizeSpace
SQ opcode: synchronize space.
Definition hel.h:815
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:775
static const uint32_t kHelSubmitObserve
SQ opcode: observe thread.
Definition hel.h:825
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:841
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:807
static const uint32_t kHelSubmitReadMemory
SQ opcode: read memory.
Definition hel.h:817
static const int kHelNextPresent
Marks the next field as present.
Definition hel.h:869
static const int kHelKernelNotifySupplyCqChunks
Set in kernelNotify after userspace has supplied new chunks.
Definition hel.h:772
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:811
static const uint32_t kHelSubmitAwaitClock
SQ opcode: wait for time to pass.
Definition hel.h:809
static const uint32_t kHelSubmitPopulateSpace
SQ opcode: populate a space.
Definition hel.h:835
@ 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:845
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:813
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:837
static const int kHelUserNotifySupplySqChunks
Set in userNotify after kernel has supplied new SQ chunks.
Definition hel.h:763
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:761
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:831
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
static const uint32_t kHelSubmitResizeMemory
SQ opcode: resize memory.
Definition hel.h:827
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:823
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:874
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:765
HEL_C_LINKAGE HelError helExtendHierarchy(HelHandle hierarchyHandle, const struct HelHierarchyParameters *params, HelHandle *handle)
Creates a child hierarchy capability.
static const uint32_t kHelSubmitCancel
SQ opcode: cancel an asynchronous operation.
Definition hel.h:803
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:795
Range of physical memory that a DMA space identity-maps (see helCreateDmaSpace).
Definition hel.h:788
A single element of a HelQueue.
Definition hel.h:891
unsigned int length
Length of the element in bytes.
Definition hel.h:893
void * context
User-defined value.
Definition hel.h:897
unsigned int opcode
Operation code (for SQ elements).
Definition hel.h:895
Message address / data pair that raises an MSI (see helQueryMsiInfo).
Definition hel.h:1260
In-memory kernel/user-space queue.
Definition hel.h:848
int kernelNotify
Futex that is used to wake the kernel.
Definition hel.h:857
int userNotify
Futex that is used to wake userspace.
Definition hel.h:852
int cqFirst
Index of the first chunk of the completion queue.
Definition hel.h:861
int sqFirst
Index of the first chunk of the submission queue.
Definition hel.h:865
Register-related information returned by helQueryRegisterInfo.
Definition hel.h:584
int setSize
Size of the selected register set.
Definition hel.h:586
SQ data for kHelSubmitActivateIommu.
Definition hel.h:1107
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1109
SQ data for kHelSubmitAwaitClock.
Definition hel.h:917
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:921
uint64_t counter
Deadline in nanoseconds since boot.
Definition hel.h:919
SQ data for kHelSubmitAwaitEvent.
Definition hel.h:925
HelHandle handle
Handle to the event descriptor.
Definition hel.h:927
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:931
uint64_t sequence
Previous sequence number.
Definition hel.h:929
SQ data for kHelSubmitBindDmaDevice.
Definition hel.h:1083
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1090
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1085
HelHandle dmaSpaceHandle
Handle to a DMA space of that IOMMU (see helCreateDmaSpace).
Definition hel.h:1088
SQ data for kHelSubmitCancel.
Definition hel.h:901
SQ data for kHelSubmitExchangeMsgs.
Definition hel.h:907
uint32_t flags
Flags.
Definition hel.h:913
size_t count
Number of actions.
Definition hel.h:911
HelHandle lane
Handle to the lane.
Definition hel.h:909
SQ data for kHelSubmitForkMemory.
Definition hel.h:1011
HelHandle hierarchyHandle
Handle to the hierarchy object that owns the memory object.
Definition hel.h:1013
HelHandle handle
Handle to the memory object.
Definition hel.h:1015
SQ data for kHelSubmitInvalidateMemory.
Definition hel.h:1033
uint32_t flags
Flags (kHelInvalidate*).
Definition hel.h:1041
HelHandle handle
Handle to the memory object.
Definition hel.h:1035
size_t size
Size of the range.
Definition hel.h:1039
uintptr_t offset
Offset within the memory object.
Definition hel.h:1037
SQ data for kHelSubmitLockMemoryView.
Definition hel.h:987
size_t size
Size to lock.
Definition hel.h:993
uintptr_t offset
Offset within the memory object.
Definition hel.h:991
HelHandle handle
Handle to the memory object.
Definition hel.h:989
SQ data for kHelSubmitManageMemory.
Definition hel.h:981
HelHandle handle
Handle to the memory object.
Definition hel.h:983
SQ data for kHelSubmitMapMemory.
Definition hel.h:1055
uint32_t flags
Flags (kHelMap*).
Definition hel.h:1067
HelHandle spaceHandle
Handle to the space that the memory is mapped into.
Definition hel.h:1059
HelHandle memoryHandle
Handle to the memory object.
Definition hel.h:1057
uintptr_t offset
Offset within the memory object.
Definition hel.h:1063
void * pointer
Address to map at (depending on kHelMap*).
Definition hel.h:1061
size_t size
Size of the mapping.
Definition hel.h:1065
SQ data for kHelSubmitObserve.
Definition hel.h:997
HelHandle handle
Handle to the thread.
Definition hel.h:999
SQ data for kHelSubmitPopulateSpace.
Definition hel.h:1045
HelHandle handle
Handle to the memory space.
Definition hel.h:1047
uintptr_t address
Address within the memory space.
Definition hel.h:1049
size_t length
Length of the range.
Definition hel.h:1051
SQ data for kHelSubmitProtectMemory.
Definition hel.h:935
size_t size
Size of the mapping.
Definition hel.h:941
void * pointer
Pointer to the mapping.
Definition hel.h:939
uint32_t flags
Protection flags.
Definition hel.h:943
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:937
SQ data for kHelSubmitReadMemory.
Definition hel.h:957
uintptr_t address
Address within the memory object.
Definition hel.h:961
HelHandle handle
Handle to the memory object.
Definition hel.h:959
size_t length
Length in bytes.
Definition hel.h:963
void * buffer
Buffer to read into.
Definition hel.h:965
SQ data for kHelSubmitResizeMemory.
Definition hel.h:1003
HelHandle handle
Handle to the memory object.
Definition hel.h:1005
size_t newSize
New size in bytes.
Definition hel.h:1007
SQ data for kHelSubmitSynchronizeSpace.
Definition hel.h:947
void * pointer
Pointer to the mapping.
Definition hel.h:951
size_t size
Size of the mapping.
Definition hel.h:953
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:949
SQ data for kHelSubmitUnbindDmaDevice.
Definition hel.h:1096
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1098
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1100
SQ data for kHelSubmitUnmapMemory.
Definition hel.h:1071
size_t size
Size of the mapping.
Definition hel.h:1077
void * pointer
Pointer to the mapping.
Definition hel.h:1075
HelHandle spaceHandle
Handle to the space that the mapping is removed from.
Definition hel.h:1073
SQ data for kHelSubmitWriteMemory.
Definition hel.h:969
HelHandle handle
Handle to the memory object.
Definition hel.h:971
size_t length
Length in bytes.
Definition hel.h:975
const void * buffer
Buffer to write from.
Definition hel.h:977
uintptr_t address
Address within the memory object.
Definition hel.h:973
SQ data for kHelSubmitWritebackFence.
Definition hel.h:1020
HelHandle handle
Handle to the memory object.
Definition hel.h:1022
size_t size
Size of the range.
Definition hel.h:1026
uintptr_t offset
Offset within the memory object.
Definition hel.h:1024