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 kHelCallCreateThread = 67,
70 kHelCallQueryThreadStats = 95,
71 kHelCallSetPriority = 85,
73 kHelCallSubmitObserve = 74,
74 kHelCallKillThread = 87,
75 kHelCallInterruptThread = 86,
77 kHelCallLoadRegisters = 75,
78 kHelCallStoreRegisters = 76,
79 kHelCallQueryRegisterInfo = 102,
80 kHelCallWriteFsBase = 41,
81 kHelCallGetClock = 42,
82 kHelCallSubmitAwaitClock = 80,
83 kHelCallCreateVirtualizedCpu = 37,
84 kHelCallRunVirtualizedCpu = 38,
85 kHelCallAssertVirtualizedIrq = 107,
86 kHelCallGetRandomBytes = 101,
87 kHelCallWriteGsBase = 54,
88 kHelCallReadFsBase = 55,
89 kHelCallReadGsBase = 56,
90 kHelCallGetCurrentCpu = 57,
92 kHelCallCreateStream = 68,
93 kHelCallSubmitAsync = 79,
94 kHelCallShutdownLane = 91,
96 kHelCallFutexWait = 73,
97 kHelCallFutexWake = 71,
99 kHelCallCreateOneshotEvent = 96,
100 kHelCallCreateBitsetEvent = 97,
101 kHelCallRaiseEvent = 98,
102 kHelCallAccessIrq = 14,
103 kHelCallHandleIrq = 5,
104 kHelCallAcknowledgeIrq = 81,
105 kHelCallSubmitAwaitEvent = 82,
106 kHelCallAutomateIrq = 94,
107 kHelCallQueryMsiInfo = 6,
109 kHelCallAccessIo = 11,
110 kHelCallEnableIo = 12,
112 kHelCallBindKernlet = 93,
114 kHelCallGetAffinity = 103,
115 kHelCallSetAffinity = 100,
117 kHelCallCreateToken = 104,
119 kHelCallSuper = 0x80000000
124 kHelErrBufferTooSmall = 1,
125 kHelErrBadDescriptor = 2,
127 kHelErrNoDescriptor = 4,
128 kHelErrIllegalSyscall = 5,
129 kHelErrIllegalObject = 6,
130 kHelErrIllegalArgs = 7,
131 kHelErrLaneShutdown = 8,
132 kHelErrEndOfLane = 9,
134 kHelErrThreadTerminated = 11,
135 kHelErrCancelled = 12,
136 kHelErrTransmissionMismatch = 13,
137 kHelErrQueueTooSmall = 14,
138 kHelErrIllegalState = 15,
139 kHelErrNoHardwareSupport = 16,
140 kHelErrNoMemory = 17,
141 kHelErrUnsupportedOperation = 18,
142 kHelErrOutOfBounds = 19,
143 kHelErrDismissed = 20,
144 kHelErrRemoteFault = 21,
145 kHelErrAlreadyExists = 22,
146 kHelErrBadPermissions = 23,
148 kHelErrFutexRace = 25,
149 kHelErrBadRights = 26,
152typedef uint32_t HelRights;
158static const HelRights kHelRightNull = 0;
167static const HelRights kHelRightGrant = UINT32_C(1) << 0;
171static const HelRights kHelRightTake = UINT32_C(1) << 1;
188static const HelRights kHelRightRead = UINT32_C(1) << 2;
204static const HelRights kHelRightWrite = UINT32_C(1) << 3;
208static const HelRights kHelRightExecute = UINT32_C(1) << 4;
213static const HelRights kHelRightInvoke = UINT32_C(1) << 5;
231static const HelRights kHelRightAssign = UINT32_C(1) << 6;
234static const HelRights kHelRightDerive = UINT32_C(1) << 7;
241static const HelRights kHelRightProvision = UINT32_C(1) << 8;
244static const HelRights kHelRightPin = UINT32_C(1) << 9;
247static const HelRights kHelRightFence = UINT32_C(1) << 10;
254static const HelRights kHelRightWait = UINT32_C(1) << 11;
263static const HelRights kHelRightSignal = UINT32_C(1) << 12;
275static const HelRights kHelRightManage = UINT32_C(1) << 13;
277static const HelRights kHelRightsMax = ~UINT32_C(0);
279struct HelX86SegmentRegister {
283 uint8_t type, present, dpl, db, s, l, g, avl;
286struct HelX86DescriptorTable {
291struct HelX86VirtualizationRegs {
312 struct HelX86SegmentRegister cs, ds, es, fs, gs, ss;
313 struct HelX86SegmentRegister tr, ldt;
314 struct HelX86DescriptorTable gdt, idt;
316 uint64_t cr0, cr2, cr3, cr4, cr8;
321struct HelRiscv64VirtualizationRegs {
377#if defined(__riscv) && __riscv_xlen == 64
378typedef struct HelRiscv64VirtualizationRegs HelVirtualizationRegs;
380typedef struct HelX86VirtualizationRegs HelVirtualizationRegs;
385 kHelThisUniverse = -1,
390 kHelWaitInfinite = -1
399 kHelActionDismiss = 11,
401 kHelActionAccept = 6,
402 kHelActionImbueCredentials = 8,
403 kHelActionExtractCredentials = 9,
404 kHelActionSendFromBuffer = 1,
405 kHelActionSendFromBufferSg = 10,
406 kHelActionRecvInline = 7,
407 kHelActionRecvToBuffer = 3,
408 kHelActionPushDescriptor = 2,
409 kHelActionPullDescriptor = 4
414 kHelItemAncillary = 2,
415 kHelItemWantLane = (1 << 16),
418static const uint32_t kHelTransferDescriptorOut = UINT32_C(1) << 0;
419static const uint32_t kHelTransferDescriptorIn = UINT32_C(1) << 1;
422 kHelObtainZeroMemory = 1,
423 kHelObtainClockPage = 2
487struct HelDescriptorInfo {
492 kHelAllocContinuous = 4,
493 kHelAllocOnDemand = 1,
496struct HelAllocRestrictions {
500enum HelManagedFlags {
501 kHelManagedReadahead = 1
504enum HelManageRequests {
505 kHelManageInitialize = 1,
506 kHelManageWriteback = 2
511 kHelMapProtRead = 256,
512 kHelMapProtWrite = 512,
513 kHelMapProtExecute = 1024,
514 kHelMapDontRequireBacking = 128,
516 kHelMapFixedNoReplace = 4096,
517 kHelMapPreferBottom = 8192
521 kHelSliceCacheWriteCombine = 1,
525 kHelCachingDefault = 0,
526 kHelCachingUncached = 1,
527 kHelCachingWriteCombine = 2,
528 kHelCachingWriteThrough = 3,
529 kHelCachingWriteBack = 4,
531 kHelCachingMmioNonPosted = 6
535 kHelThreadStopped = 1
540 kHelObserveInterrupt = 4,
541 kHelObservePanic = 3,
542 kHelObserveBreakpoint = 1,
543 kHelObservePageFault = 2,
544 kHelObserveGeneralFault = 5,
545 kHelObserveIllegalInstruction = 6,
546 kHelObserveDivByZero = 7,
547 kHelObserveSuperCall = 0x80000000
550enum HelRegisterSets {
555 kHelRegsVirtualization = 5,
558 kHelRegsPageFault = 8
561enum HelPageFaultFlags {
562 kHelPageFaultMapError = 1,
563 kHelPageFaultAccessError = 2
572#if defined(__x86_64__)
573enum HelRegisterIndex {
597 kHelRegNumber = kHelRegRdi,
598 kHelRegError = kHelRegRdi,
600 kHelRegArg0 = kHelRegRsi,
601 kHelRegArg1 = kHelRegRdx,
602 kHelRegArg2 = kHelRegRax,
603 kHelRegArg3 = kHelRegR8,
604 kHelRegArg4 = kHelRegR9,
605 kHelRegArg5 = kHelRegR10,
606 kHelRegArg6 = kHelRegR12,
607 kHelRegArg7 = kHelRegR13,
608 kHelRegArg8 = kHelRegR14,
610 kHelRegOut0 = kHelRegRsi,
611 kHelRegOut1 = kHelRegRdx,
612 kHelRegOut2 = kHelRegRax
615#elif defined(__aarch64__)
616enum HelRegisterIndex {
656 kHelRegNumber = kHelRegX0,
657 kHelRegError = kHelRegX0,
659 kHelRegArg0 = kHelRegX1,
660 kHelRegArg1 = kHelRegX2,
661 kHelRegArg2 = kHelRegX3,
662 kHelRegArg3 = kHelRegX4,
663 kHelRegArg4 = kHelRegX5,
664 kHelRegArg5 = kHelRegX6,
665 kHelRegArg6 = kHelRegX7,
666 kHelRegArg7 = kHelRegX8,
667 kHelRegArg8 = kHelRegX9,
669 kHelRegOut0 = kHelRegX1,
670 kHelRegOut1 = kHelRegX2,
671 kHelRegOut2 = kHelRegX3
674#elif defined(__riscv) && __riscv_xlen == 64
675enum HelRegisterIndex {
711 kHelRegNumber = kHelRegA0,
712 kHelRegError = kHelRegA0,
713 kHelRegArg0 = kHelRegA1,
714 kHelRegArg1 = kHelRegA2,
715 kHelRegArg2 = kHelRegA3,
716 kHelRegArg3 = kHelRegA4,
717 kHelRegArg4 = kHelRegA5,
718 kHelRegArg5 = kHelRegA6,
719 kHelRegArg6 = kHelRegA7,
720 kHelRegArg7 = kHelRegS2,
721 kHelRegArg8 = kHelRegS3,
723 kHelRegOut0 = kHelRegA1,
724 kHelRegOut1 = kHelRegA2,
725 kHelRegOut2 = kHelRegA3
730struct HelQueueParameters {
732 unsigned int numChunks;
734 unsigned int numSqChunks;
844 uint64_t cancellationTag;
993struct HelSimpleResult {
998struct HelCredentialsResult {
1001 char credentials[16];
1004struct HelManageResult {
1011struct HelObserveResult {
1013 unsigned int observation;
1016struct HelInlineResult {
1023struct HelInlineResultNoFlex {
1029struct HelLengthResult {
1035struct HelHandleResult {
1041struct HelEventResult {
1048 kHelAckAcknowledge = 2,
1051 kHelAckClear = 0x100,
1054union HelKernletData {
1058struct HelThreadStats {
1064 kHelVmexitTranslationFault = 1,
1065 kHelVmexitHyperCall = 2,
1066 kHelVmexitInstructionTrap = 3,
1067 kHelVmexitError = -1,
1068 kHelVmexitUnknownPlatformSpecificExitCode = -2,
1072 kHelVmFaultRead = 1 << 0,
1073 kHelVmFaultWrite = 1 << 1,
1074 kHelVmFaultExecute = 1 << 2,
1077#if defined(__riscv) && __riscv_xlen == 64
1079struct HelVmexitReason {
1080 uint32_t exitReason;
1083 uint64_t instruction;
1090struct HelVmexitReason {
1091 uint32_t exitReason;
1100enum HelLogSeverity {
1101 kHelLogSeverityEmergency,
1102 kHelLogSeverityAlert,
1103 kHelLogSeverityCritical,
1104 kHelLogSeverityError,
1105 kHelLogSeverityWarning,
1106 kHelLogSeverityNotice,
1107 kHelLogSeverityInfo,
1108 kHelLogSeverityDebug,
1112 kHelAccessIrqByGsi = 1,
1113 kHelAccessIrqByPhandle = 2,
1114 kHelAccessIrqAllocateMsi = 3,
1119 kHelIrqNameSize = 32,
1123 kHelIrqTriggerNull = 0,
1124 kHelIrqTriggerEdge = 1,
1125 kHelIrqTriggerLevel = 2
1129 kHelIrqPolarityNull = 0,
1130 kHelIrqPolarityHigh = 1,
1131 kHelIrqPolarityLow = 2
1150HEL_C_LINKAGE HelError
helLog(
const enum HelLogSeverity severity,
const char *
string,
size_t length);
1157HEL_C_LINKAGE
void helPanic(
const char *
string,
size_t length)
1158 __attribute__ (( noreturn ));
1188HEL_C_LINKAGE HelError
1190 uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle);
1192HEL_C_LINKAGE HelError helDescriptorInfo(HelHandle handle,
struct HelDescriptorInfo *info);
1239HEL_C_LINKAGE HelError
helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask);
1263 const struct HelAllocRestrictions *restrictions, HelHandle *handle);
1285 HelHandle *backingHandle, HelHandle *frontalHandle);
1302 HelHandle *swapHandle);
1315 size_t size, uint32_t flags, HelHandle *handle);
1335 uintptr_t offset,
size_t size, HelHandle *handle);
1337HEL_C_LINKAGE HelError helAccessPhysical(
1338 HelHandle accessToken, uintptr_t physical,
size_t size, uint32_t cachingMode, HelHandle *handle
1365 HelHandle memoryHandle, uintptr_t offset,
size_t size);
1367HEL_C_LINKAGE HelError helCreateSliceView(HelHandle bundle, uintptr_t offset,
size_t size,
1368 uint32_t flags, HelHandle *handle);
1408HEL_C_LINKAGE HelError
helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle,
1409 void *pointer, uintptr_t offset,
size_t size, uint32_t flags,
void **actualPointer);
1422HEL_C_LINKAGE HelError
helUnmapMemory(HelHandle spaceHandle,
void *pointer,
size_t size);
1424HEL_C_LINKAGE HelError helPointerPhysical(HelHandle spaceHandle,
const void *pointer, uintptr_t *physical);
1426HEL_C_LINKAGE HelError helMemoryInfo(HelHandle handle,
1429HEL_C_LINKAGE HelError helUpdateMemory(HelHandle handle,
int type, uintptr_t offset,
size_t length);
1441HEL_C_LINKAGE HelError
helLoadahead(HelHandle handle, uintptr_t offset,
size_t length);
1443HEL_C_LINKAGE HelError helCreateVirtualizedSpace(HelHandle *handle);
1463 HelAbi abi,
void *ip,
void *sp, uint32_t flags, HelHandle *handle);
1531HEL_C_LINKAGE HelError helWriteFsBase(
void *pointer);
1533HEL_C_LINKAGE HelError helReadFsBase(
void **pointer);
1535HEL_C_LINKAGE HelError helWriteGsBase(
void *pointer);
1537HEL_C_LINKAGE HelError helReadGsBase(
void **pointer);
1548HEL_C_LINKAGE HelError helCreateVirtualizedCpu(HelHandle handle, HelHandle *out_handle);
1550HEL_C_LINKAGE HelError helRunVirtualizedCpu(HelHandle handle,
struct HelVmexitReason *reason);
1552HEL_C_LINKAGE HelError helAssertVirtualizedIrq(HelHandle handle, uint64_t irq, uint8_t level);
1554HEL_C_LINKAGE HelError helGetRandomBytes(
void *buffer,
size_t wantedSize,
size_t *actualSize);
1565HEL_C_LINKAGE HelError
helGetAffinity(HelHandle handle, uint8_t *mask,
size_t size,
size_t *actualSize);
1587HEL_C_LINKAGE HelError
helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials);
1589HEL_C_LINKAGE HelError helShutdownLane(HelHandle handle);
1612HEL_C_LINKAGE HelError
helFutexWait(
int *pointer,
int expected, int64_t deadline);
1661 HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index,
1662 const char *name, HelHandle *handle
1670HEL_C_LINKAGE HelError
helHandleIrq(HelHandle pinHandle, HelHandle *handle);
1683HEL_C_LINKAGE HelError
helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity);
1693HEL_C_LINKAGE HelError helAcknowledgeIrq(HelHandle handle, uint32_t flags, uint64_t sequence);
1695HEL_C_LINKAGE HelError helAutomateIrq(HelHandle handle, uint32_t flags, HelHandle kernlet);
1701HEL_C_LINKAGE HelError helAccessIo(
1702 HelHandle accessToken,
const uintptr_t *portArray,
size_t numPorts, HelHandle *handle
1724 const union HelKernletData *data,
size_t numData, HelHandle *boundHandle);
1728extern inline __attribute__ (( always_inline ))
const char *_helErrorString(HelError code) {
1732 case kHelErrIllegalSyscall:
1733 return "Illegal syscall";
1734 case kHelErrIllegalArgs:
1735 return "Illegal arguments";
1736 case kHelErrIllegalState:
1737 return "Illegal state";
1738 case kHelErrUnsupportedOperation:
1739 return "Unsupported operation";
1740 case kHelErrNoDescriptor:
1741 return "No such descriptor";
1742 case kHelErrBadDescriptor:
1743 return "Illegal descriptor for this operation";
1744 case kHelErrThreadTerminated:
1745 return "Thread terminated already";
1746 case kHelErrLaneShutdown:
1747 return "Lane shutdown";
1748 case kHelErrEndOfLane:
1749 return "End of lane";
1750 case kHelErrDismissed:
1751 return "IPC item dismissed by remote";
1752 case kHelErrBufferTooSmall:
1753 return "Buffer too small";
1754 case kHelErrQueueTooSmall:
1755 return "Buffer too small";
1758 case kHelErrNoHardwareSupport:
1759 return "Missing hardware support for this feature";
1760 case kHelErrNoMemory:
1761 return "Out of memory";
1762 case kHelErrTransmissionMismatch:
1763 return "Transmission mismatch";
1764 case kHelErrCancelled:
1766 case kHelErrOutOfBounds:
1767 return "Out of bounds";
1768 case kHelErrAlreadyExists:
1769 return "Already exists";
1770 case kHelErrBadRights:
1771 return "Missing rights for this operation";
1777extern inline __attribute__ (( always_inline ))
void _helCheckFailed(HelError err_code,
1778 const char *
string,
int fatal) {
1779 helLog(kHelLogSeverityError,
string, strlen(
string));
1781 const char *err_string = _helErrorString(err_code);
1783 err_string =
"(Unexpected error code)";
1784 helLog(kHelLogSeverityError, err_string, strlen(err_string));
1785 helLog(kHelLogSeverityError,
"\n", 1);
1791#define HEL_STRINGIFY_AUX(x) #x
1792#define HEL_STRINGIFY(x) HEL_STRINGIFY_AUX(x)
1794#define HEL_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
1795 _helCheckFailed(__error, "HEL_CHECK failed: " #expr "\n" \
1796 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 1); } while(0)
1797#define HEL_SOFT_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
1798 _helCheckFailed(__error, "HEL_SOFT_CHECK failed: " #expr "\n" \
1799 " 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:744
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:747
static const uint32_t kHelSubmitInvalidateMemory
SQ opcode: invalidate memory.
Definition hel.h:785
HEL_C_LINKAGE HelError helCreateDmaSpace(uint32_t flags, HelHandle *handle)
Creates a DMA space that memory can be mapped into for device DMA.
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:969
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:771
HEL_C_LINKAGE HelError helObtainHandle(int kind, HelHandle *handle)
Obtains a descriptor to one of the kernel's global objects.
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:757
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 helLoadRegisters(HelHandle handle, int set, void *image)
Load a register image (e.g., from a thread).
HEL_C_LINKAGE HelError helCopyOnWrite(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 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 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:814
static const uint32_t kHelSubmitManageMemory
SQ opcode: manage memory.
Definition hel.h:773
HEL_C_LINKAGE HelError helCreateManagedMemory(size_t size, uint32_t flags, HelHandle *backingHandle, HelHandle *frontalHandle)
Creates a memory object that is managed by userspace.
static const uint32_t kHelSubmitForkMemory
SQ opcode: fork memory.
Definition hel.h:781
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:818
static const uint32_t kHelSubmitSynchronizeSpace
SQ opcode: synchronize space.
Definition hel.h:767
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:752
static const uint32_t kHelSubmitObserve
SQ opcode: observe thread.
Definition hel.h:777
HEL_C_LINKAGE HelError helForkMemory(HelHandle handle, HelHandle *forkedHandle)
Forks memory objects, i.e., copies them using copy-on-write.
HEL_C_LINKAGE HelError helAllocateSwappableMemory(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 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 helAllocateMemory(size_t size, uint32_t flags, const struct HelAllocRestrictions *restrictions, HelHandle *handle)
Creates a memory object consisting of unmanaged RAM.
HEL_C_LINKAGE HelError helCreateThread(HelHandle universe, HelHandle spaceHandle, HelAbi abi, void *ip, void *sp, uint32_t flags, HelHandle *handle)
Create a new thread.
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:759
static const uint32_t kHelSubmitReadMemory
SQ opcode: read memory.
Definition hel.h:769
static const int kHelNextPresent
Marks the next field as present.
Definition hel.h:811
static const int kHelKernelNotifySupplyCqChunks
Set in kernelNotify after userspace has supplied new chunks.
Definition hel.h:749
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:763
static const uint32_t kHelSubmitAwaitClock
SQ opcode: wait for time to pass.
Definition hel.h:761
static const uint32_t kHelSubmitPopulateSpace
SQ opcode: populate a space.
Definition hel.h:787
@ kHelClockTsc
x86: TSC.
Definition hel.h:431
@ kHelClockCntvct
ARM: virtual counter (CNTVCT_EL0).
Definition hel.h:435
@ kHelClockCntpct
ARM: physical counter (CNTPCT_EL0).
Definition hel.h:433
@ kHelClockNone
No clock that is accessible to userspace (= helGetClock() has to be used).
Definition hel.h:429
@ kHelClockTime
RISC-V: time CSR.
Definition hel.h:437
HEL_C_LINKAGE HelError helAlertQueue(HelHandle queueHandle)
Alerts an IPC queue.
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:765
static const int kHelUserNotifySupplySqChunks
Set in userNotify after kernel has supplied new SQ chunks.
Definition hel.h:740
HEL_C_LINKAGE HelError helCreateSwapSpace(uint32_t flags, HelHandle *backingHandle, HelHandle *swapHandle)
Creates a swap space, the backing store for swappable anonymous memory (see helAllocateSwappableMemor...
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:738
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:783
static const uint32_t kHelSubmitResizeMemory
SQ opcode: resize memory.
Definition hel.h:779
HEL_C_LINKAGE HelError helCreateOneshotEvent(HelHandle *handle)
Create an event that fires at most once.
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:775
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:816
HEL_C_LINKAGE HelError helEnableIo(HelHandle handle)
Enable userspace access to hardware I/O resources.
static const int kHelUserNotifyError
Set in userNotify if the queue encounters a contract violation.
Definition hel.h:742
static const uint32_t kHelSubmitCancel
SQ opcode: cancel an asynchronous operation.
Definition hel.h:755
Parameters that allow userspace to compute the current time on the monotone clock (i....
Definition hel.h:449
int32_t tickShift
Scaling exponent of the tick -> nanosecond conversion.
Definition hel.h:454
uint64_t tickFactor
Factor of the tick -> nanosecond conversion.
Definition hel.h:456
uint32_t clockType
One of the kHelClock* constants.
Definition hel.h:452
A single element of a HelQueue.
Definition hel.h:833
unsigned int length
Length of the element in bytes.
Definition hel.h:835
void * context
User-defined value.
Definition hel.h:839
unsigned int opcode
Operation code (for SQ elements).
Definition hel.h:837
Message address / data pair that raises an MSI (see helQueryMsiInfo).
Definition hel.h:1135
In-memory kernel/user-space queue.
Definition hel.h:790
int kernelNotify
Futex that is used to wake the kernel.
Definition hel.h:799
int userNotify
Futex that is used to wake userspace.
Definition hel.h:794
int cqFirst
Index of the first chunk of the completion queue.
Definition hel.h:803
int sqFirst
Index of the first chunk of the submission queue.
Definition hel.h:807
Register-related information returned by helQueryRegisterInfo.
Definition hel.h:567
int setSize
Size of the selected register set.
Definition hel.h:569
SQ data for kHelSubmitAwaitClock.
Definition hel.h:859
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:863
uint64_t counter
Deadline in nanoseconds since boot.
Definition hel.h:861
SQ data for kHelSubmitAwaitEvent.
Definition hel.h:867
HelHandle handle
Handle to the event descriptor.
Definition hel.h:869
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:873
uint64_t sequence
Previous sequence number.
Definition hel.h:871
SQ data for kHelSubmitCancel.
Definition hel.h:843
SQ data for kHelSubmitExchangeMsgs.
Definition hel.h:849
uint32_t flags
Flags.
Definition hel.h:855
size_t count
Number of actions.
Definition hel.h:853
HelHandle lane
Handle to the lane.
Definition hel.h:851
SQ data for kHelSubmitForkMemory.
Definition hel.h:953
HelHandle handle
Handle to the memory object.
Definition hel.h:955
SQ data for kHelSubmitInvalidateMemory.
Definition hel.h:972
uint32_t flags
Flags (kHelInvalidate*).
Definition hel.h:980
HelHandle handle
Handle to the memory object.
Definition hel.h:974
size_t size
Size of the range.
Definition hel.h:978
uintptr_t offset
Offset within the memory object.
Definition hel.h:976
SQ data for kHelSubmitLockMemoryView.
Definition hel.h:929
size_t size
Size to lock.
Definition hel.h:935
uintptr_t offset
Offset within the memory object.
Definition hel.h:933
HelHandle handle
Handle to the memory object.
Definition hel.h:931
SQ data for kHelSubmitManageMemory.
Definition hel.h:923
HelHandle handle
Handle to the memory object.
Definition hel.h:925
SQ data for kHelSubmitObserve.
Definition hel.h:939
HelHandle handle
Handle to the thread.
Definition hel.h:941
SQ data for kHelSubmitPopulateSpace.
Definition hel.h:984
HelHandle handle
Handle to the memory space.
Definition hel.h:986
uintptr_t address
Address within the memory space.
Definition hel.h:988
size_t length
Length of the range.
Definition hel.h:990
SQ data for kHelSubmitProtectMemory.
Definition hel.h:877
size_t size
Size of the mapping.
Definition hel.h:883
void * pointer
Pointer to the mapping.
Definition hel.h:881
uint32_t flags
Protection flags.
Definition hel.h:885
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:879
SQ data for kHelSubmitReadMemory.
Definition hel.h:899
uintptr_t address
Address within the memory object.
Definition hel.h:903
HelHandle handle
Handle to the memory object.
Definition hel.h:901
size_t length
Length in bytes.
Definition hel.h:905
void * buffer
Buffer to read into.
Definition hel.h:907
SQ data for kHelSubmitResizeMemory.
Definition hel.h:945
HelHandle handle
Handle to the memory object.
Definition hel.h:947
size_t newSize
New size in bytes.
Definition hel.h:949
SQ data for kHelSubmitSynchronizeSpace.
Definition hel.h:889
void * pointer
Pointer to the mapping.
Definition hel.h:893
size_t size
Size of the mapping.
Definition hel.h:895
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:891
SQ data for kHelSubmitWriteMemory.
Definition hel.h:911
HelHandle handle
Handle to the memory object.
Definition hel.h:913
size_t length
Length in bytes.
Definition hel.h:917
const void * buffer
Buffer to write from.
Definition hel.h:919
uintptr_t address
Address within the memory object.
Definition hel.h:915
SQ data for kHelSubmitWritebackFence.
Definition hel.h:959
HelHandle handle
Handle to the memory object.
Definition hel.h:961
size_t size
Size of the range.
Definition hel.h:965
uintptr_t offset
Offset within the memory object.
Definition hel.h:963