NeKernel dev
Loading...
Searching...
No Matches
System.h File Reference

Go to the source code of this file.

Classes

struct  REF_TYPE
 Types API. More...

Macros

#define kPrintDevicePath   "/devices/tty{}"
 TTY device path.
#define kCDDevicePath   "/devices/dvd{}"

Typedefs

typedef REF_TYPERef
typedef Ref IORef
typedef Ref FSRef
typedef Ref DylibRef
typedef Ref ThreadRef
typedef Ref SocketRef
typedef Ref NetworkRef
typedef Ref MutexRef
typedef Ref EventRef
typedef Ref SemaphoreRef
typedef SInt32(* ThrProcKind) (SInt32 argc, Char **argv)
 Thread procedure function type.
typedef SInt32 AffinityRef
typedef UInt64 ProcessRef

Enumerations

enum  {
  kPowerCodeInvalid = 0 , kPowerCodeShutdown = 12 , kPowerCodeReboot , kPowerCodeSleep ,
  kPowerCodeWake , kPowerCodeCount
}

Functions

IMPORT_C Ref LdrGetDylibSymbolFromHandle (_Input const Char *symbol, _Input Ref dll_handle)
 Dynamic Loader API.
IMPORT_C Ref LdrOpenDylibHandle (_Input const Char *path, _Input const Char *drive_letter)
 Open Dylib handle.
IMPORT_C UInt32 LdrCloseDylibHandle (_Input Ref *dll_handle)
 Close Dylib handle.
IMPORT_C Ref IoOpenFile (const Char *fs_path, const Char *drive_letter)
 Opens a file from a drive.
IMPORT_C Void IoCloseFile (_Input Ref file_desc)
 Closes a file and flushes its content.
IMPORT_C SInt32 IoCtrlFile (_Input Ref file_desc, _Input UInt32 ioctl_code, _Input VoidPtr in_data, _Output VoidPtr out_data)
 I/O control (ioctl) on a file.
IMPORT_C const Char * IoMimeFile (_Input Ref file_desc)
 Gets the file mime (if any).
IMPORT_C const Char * IoDimFile (_Input Ref dir_desc)
 Gets the dir DIM.
IMPORT_C UInt32 IoWriteFile (_Input Ref file_desc, _Output VoidPtr out_data, UInt64 sz_data)
 Write data to a file ref.
IMPORT_C UInt32 IoReadFile (_Input Ref file_desc, _Output VoidPtr *out_data, UInt64 sz_data)
 Read data from a file.
IMPORT_C UInt64 IoRewindFile (_Input Ref file_desc)
 Rewind the file pointer to the beginning of the file.
IMPORT_C UInt64 IoTellFile (_Input Ref file_desc)
 Tell the current position of the file pointer.
IMPORT_C UInt64 IoSeekFile (_Input Ref file_desc, UInt64 file_offset)
 Seek file offset from file descriptor.
IMPORT_C UInt32 RtlSpawnIB (UIntPtr process_id)
 Spawns a Thread Information Block and Global Information Block inside the current process.
IMPORT_C UIntPtr RtlSpawnProcess (const Char *process_path, UInt32 argc, Char **argv, Char **envp, UInt32 envp_len)
 Spawns a process with a unique pid (stored as UIntPtr).
IMPORT_C Bool RtlExitProcess (UIntPtr handle, UIntPtr exit_code)
 Exits a process with an exit_code.
IMPORT_C VoidPtr MmCreateHeap (_Input UInt64 len, _Input UInt32 flags)
 Creates a new heap from the process's address space.
IMPORT_C SInt32 MmDestroyHeap (_Input VoidPtr heap)
 Destroys the pointer.
IMPORT_C SInt32 MmSetHeapFlags (_Input VoidPtr heap, _Input UInt32 flags)
 Change protection flags of a memory region.
IMPORT_C UInt32 MmGetHeapFlags (_Input VoidPtr heap)
 Change protection flags of a memory region.
IMPORT_C UInt32 MmFillCRC32Heap (_Input VoidPtr heap)
 Fill memory region with CRC32.
IMPORT_C VoidPtr MmCopyMemory (_Input VoidPtr dest, _Input VoidPtr src, _Input UInt64 len)
 Copy memory region.
IMPORT_C SInt64 MmCmpMemory (_Input VoidPtr dest, _Input VoidPtr src, _Input UInt64 len)
 Compare memory regions.
IMPORT_C VoidPtr MmFillMemory (_Input VoidPtr dest, _Input UInt64 len, _Input UInt8 value)
 Fill memory region.
IMPORT_C SInt64 MmStrCmp (_Input const Char *dest, _Input const Char *src)
 Compare string regions.
IMPORT_C SInt64 MmStrLen (const Char *str)
 Get length of string.
IMPORT_C SInt32 ErrGetLastError (Void)
IMPORT_C SInt32 ThrExitCurrentThread (_Input SInt32 exit_code)
 Exit the current thread.
IMPORT_C SInt32 ThrExitMainThread (_Input SInt32 exit_code)
 Exit the main thread.
IMPORT_C SInt32 ThrExitThread (_Input ThreadRef thread, _Input SInt32 exit_code)
 Exit a thread.
IMPORT_C ThreadRef ThrCreateThread (const Char *thread_name, ThrProcKind procedure, SInt32 argument_count, SInt32 flags)
 Creates a thread.
IMPORT_C SInt32 ThrYieldThread (ThreadRef thrd)
 Yields the current thread.
IMPORT_C SInt32 ThrJoinThread (ThreadRef thrd)
 Joins a thread.
IMPORT_C SInt32 ThrDetachThread (ThreadRef thrd)
 Detach a thread.
IMPORT_C Char * DrvGetDefaultDriveLetter (Void)
 Get the default drive letter.
IMPORT_C Char * DrvGetDriveLetterFromPath (_Input const Char *path)
 Get the drive letter from a path.
IMPORT_C Ref DrvGetMountedDrive (_Input Char letter)
 Get a mounted drive from a letter.
IMPORT_C Void DrvMountDrive (_Input const Char *path, _Input const Char *letter)
 Mount a drive.
IMPORT_C Void DrvUnmountDrive (_Input Char letter)
 Unmount a drive.
IMPORT_C Void EvtAddListener (_Input const Char *event_name, _Input Ref listener)
 Add an event listener.
IMPORT_C Void EvtRemoveListener (_Input const Char *event_name, _Input Ref listener)
 Remove an event listener.
IMPORT_C VoidPtr EvtDispatchEvent (_Input const Char *event_name, _Input VoidPtr event_data)
 Dispatch an event.
IMPORT_C SInt32 PwrReadCode (_Output SInt32 &code)
IMPORT_C SInt32 PwrSendCode (_Output SInt32 &code)
IMPORT_C IORef CdOpenTray (Void)
IMPORT_C SInt32 CdEjectDrive (_Input IORef cdrom)
IMPORT_C SInt32 CdCloseTray (Void)
IMPORT_C SInt32 PrintOut (IORef file, const Char *fmt,...)
IMPORT_C SInt32 PrintIn (IORef file, const Char *fmt,...)
IMPORT_C IORef PrintCreate (Void)
IMPORT_C SInt32 PrintRelease (IORef)
IMPORT_C IORef PrintGet (const Char *path)
IMPORT_C SInt32 SchedSetAffinity (_Input ProcessRef, SInt32 req, _Input AffinityRef *)
IMPORT_C SInt32 SchedGetAffinity (_Input ProcessRef, _InOut AffinityRef *)
IMPORT_C SInt32 SchedFireSignal (_Input ProcessRef, SInt32)
IMPORT_C SInt32 SchedReadMemory (_Input ProcessRef, SInt32, SInt32)
IMPORT_C SInt32 SchedWriteMemory (_Input ProcessRef, SInt32, SInt32)
IMPORT_C UIntPtr SchedGetCurrentProcessID (Void)
IMPORT_C BOOL FsCopy (const Char *path, const Char *dst)
IMPORT_C BOOL FsMove (const Char *path, const Char *dst)
IMPORT_C BOOL FsExists (const Char *path)
IMPORT_C BOOL FsCreateDir (const Char *path)
IMPORT_C BOOL FsCreateFile (const Char *path)
IMPORT_C BOOL FsCreateAlias (const Char *path, const Char *from)
IMPORT_C BOOL IfsMount (const Char *path, const Char *drive_letter)
IMPORT_C BOOL IfsUnmount (const Char *drive_letter)
IMPORT_C BOOL IfsIsMounted (const Char *drive_letter)
IMPORT_C Char * StrFmt (const Char *fmt,...)
IMPORT_C UInt64 StrMathToNumber (const Char *in, const Char **endp, const SInt16 base)

Macro Definition Documentation

◆ kCDDevicePath

#define kCDDevicePath   "/devices/dvd{}"

◆ kPrintDevicePath

#define kPrintDevicePath   "/devices/tty{}"

TTY device path.

Typedef Documentation

◆ AffinityRef

◆ DylibRef

typedef Ref DylibRef

◆ EventRef

typedef Ref EventRef

◆ FSRef

typedef Ref FSRef

◆ IORef

typedef Ref IORef

◆ MutexRef

typedef Ref MutexRef

◆ NetworkRef

typedef Ref NetworkRef

◆ ProcessRef

typedef UInt64 ProcessRef

◆ Ref

typedef REF_TYPE* Ref

◆ SemaphoreRef

typedef Ref SemaphoreRef

◆ SocketRef

typedef Ref SocketRef

◆ ThreadRef

typedef Ref ThreadRef

◆ ThrProcKind

typedef SInt32(* ThrProcKind) (SInt32 argc, Char **argv)

Thread procedure function type.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kPowerCodeInvalid 
kPowerCodeShutdown 
kPowerCodeReboot 
kPowerCodeSleep 
kPowerCodeWake 
kPowerCodeCount 

Function Documentation

◆ CdCloseTray()

IMPORT_C SInt32 CdCloseTray ( Void )

◆ CdEjectDrive()

IMPORT_C SInt32 CdEjectDrive ( _Input IORef cdrom)

◆ CdOpenTray()

IMPORT_C IORef CdOpenTray ( Void )

◆ DrvGetDefaultDriveLetter()

IMPORT_C Char * DrvGetDefaultDriveLetter ( Void )

Get the default drive letter.

Parameters
void.
Returns
the drive letter.

◆ DrvGetDriveLetterFromPath()

IMPORT_C Char * DrvGetDriveLetterFromPath ( _Input const Char * path)

Get the drive letter from a path.

Parameters
paththe path.
Returns
the drive letter.

◆ DrvGetMountedDrive()

IMPORT_C Ref DrvGetMountedDrive ( _Input Char letter)

Get a mounted drive from a letter.

Parameters
letterthe letter (A..Z).
Returns
the drive object.

◆ DrvMountDrive()

IMPORT_C Void DrvMountDrive ( _Input const Char * path,
_Input const Char * letter )

Mount a drive.

Parameters
paththe path to mount.
letterthe letter to mount.

◆ DrvUnmountDrive()

IMPORT_C Void DrvUnmountDrive ( _Input Char letter)

Unmount a drive.

Parameters
letterthe letter to unmount.

◆ ErrGetLastError()

IMPORT_C SInt32 ErrGetLastError ( Void )

◆ EvtAddListener()

IMPORT_C Void EvtAddListener ( _Input const Char * event_name,
_Input Ref listener )

Add an event listener.

Parameters
event_namethe event name.
listenerthe listener to add.
Returns
the event listener.

◆ EvtDispatchEvent()

IMPORT_C VoidPtr EvtDispatchEvent ( _Input const Char * event_name,
_Input VoidPtr event_data )

Dispatch an event.

Parameters
event_namethe event name.
event_datathe event data.
Returns
the event data.

◆ EvtRemoveListener()

IMPORT_C Void EvtRemoveListener ( _Input const Char * event_name,
_Input Ref listener )

Remove an event listener.

Parameters
event_namethe event name.
listenerthe listener to remove.
Returns
the event listener.

◆ FsCopy()

IMPORT_C BOOL FsCopy ( const Char * path,
const Char * dst )

◆ FsCreateAlias()

IMPORT_C BOOL FsCreateAlias ( const Char * path,
const Char * from )

◆ FsCreateDir()

IMPORT_C BOOL FsCreateDir ( const Char * path)

◆ FsCreateFile()

IMPORT_C BOOL FsCreateFile ( const Char * path)

◆ FsExists()

IMPORT_C BOOL FsExists ( const Char * path)

◆ FsMove()

IMPORT_C BOOL FsMove ( const Char * path,
const Char * dst )

◆ IfsIsMounted()

IMPORT_C BOOL IfsIsMounted ( const Char * drive_letter)

◆ IfsMount()

IMPORT_C BOOL IfsMount ( const Char * path,
const Char * drive_letter )

◆ IfsUnmount()

IMPORT_C BOOL IfsUnmount ( const Char * drive_letter)

◆ IoCloseFile()

IMPORT_C Void IoCloseFile ( _Input Ref file_desc)

Closes a file and flushes its content.

Parameters
file_descthe file descriptor.
Returns
Function doesn't return a type.

◆ IoCtrlFile()

IMPORT_C SInt32 IoCtrlFile ( _Input Ref file_desc,
_Input UInt32 ioctl_code,
_Input VoidPtr in_data,
_Output VoidPtr out_data )

I/O control (ioctl) on a file.

Parameters
file_descthe file descriptor.
ioctl_codethe ioctl code.
in_datathe input data.
out_datathe output data.
Returns
the number of bytes written.
Note
This function is used to control the file descriptor, introduced for OpenHeFS.

◆ IoDimFile()

IMPORT_C const Char * IoDimFile ( _Input Ref dir_desc)

Gets the dir DIM.

Parameters
dir_descdirectory descriptor.
Note
only works in OpenHeFS, will return nil-x/nil if used on any other filesystem.

◆ IoMimeFile()

IMPORT_C const Char * IoMimeFile ( _Input Ref file_desc)

Gets the file mime (if any).

Parameters
file_descthe file descriptor.

◆ IoOpenFile()

IMPORT_C Ref IoOpenFile ( const Char * fs_path,
const Char * drive_letter )

Opens a file from a drive.

Parameters
fs_paththe filesystem path.
drive_letterdrive name, use NULL to use default drive location.
Returns
the file descriptor of the file.

◆ IoReadFile()

IMPORT_C UInt32 IoReadFile ( _Input Ref file_desc,
_Output VoidPtr * out_data,
UInt64 sz_data )

Read data from a file.

Parameters
file_descthe file descriptor.
out_datathe data to read.
sz_datathe size of the data to read.

◆ IoRewindFile()

IMPORT_C UInt64 IoRewindFile ( _Input Ref file_desc)

Rewind the file pointer to the beginning of the file.

Parameters
file_descthe file descriptor.
Returns
the number of bytes read.

◆ IoSeekFile()

IMPORT_C UInt64 IoSeekFile ( _Input Ref file_desc,
UInt64 file_offset )

Seek file offset from file descriptor.

◆ IoTellFile()

IMPORT_C UInt64 IoTellFile ( _Input Ref file_desc)

Tell the current position of the file pointer.

Parameters
file_descthe file descriptor.
Returns
the current position of the file pointer.

◆ IoWriteFile()

IMPORT_C UInt32 IoWriteFile ( _Input Ref file_desc,
_Output VoidPtr out_data,
UInt64 sz_data )

Write data to a file ref.

Parameters
file_descthe file descriptor.
out_datathe data to write.
sz_datathe size of the data to write.
Returns
the number of bytes written.

◆ LdrCloseDylibHandle()

IMPORT_C UInt32 LdrCloseDylibHandle ( _Input Ref * dll_handle)

Close Dylib handle.

Parameters
dll_handlethe dylib ref.
Returns
whether it closed or not.

◆ LdrGetDylibSymbolFromHandle()

IMPORT_C Ref LdrGetDylibSymbolFromHandle ( _Input const Char * symbol,
_Input Ref dll_handle )

Dynamic Loader API.

Get function which is part of the Dylib.

Parameters
symbolthe symbol to look for
dll_handlethe Dylib handle.
Returns
the proc pointer.

◆ LdrOpenDylibHandle()

IMPORT_C Ref LdrOpenDylibHandle ( _Input const Char * path,
_Input const Char * drive_letter )

Open Dylib handle.

Parameters
pathdll path.
drvdriver letter.
Returns
a dylib ref.

◆ MmCmpMemory()

IMPORT_C SInt64 MmCmpMemory ( _Input VoidPtr dest,
_Input VoidPtr src,
_Input UInt64 len )

Compare memory regions.

◆ MmCopyMemory()

IMPORT_C VoidPtr MmCopyMemory ( _Input VoidPtr dest,
_Input VoidPtr src,
_Input UInt64 len )

Copy memory region.

◆ MmCreateHeap()

IMPORT_C VoidPtr MmCreateHeap ( _Input UInt64 len,
_Input UInt32 flags )

Creates a new heap from the process's address space.

Parameters
lenthe length of it.
flagsthe flags of it.
Returns
heap pointer.

◆ MmDestroyHeap()

IMPORT_C SInt32 MmDestroyHeap ( _Input VoidPtr heap)

Destroys the pointer.

Parameters
heapthe heap itself.
Returns
void.

◆ MmFillCRC32Heap()

IMPORT_C UInt32 MmFillCRC32Heap ( _Input VoidPtr heap)

Fill memory region with CRC32.

◆ MmFillMemory()

IMPORT_C VoidPtr MmFillMemory ( _Input VoidPtr dest,
_Input UInt64 len,
_Input UInt8 value )

Fill memory region.

◆ MmGetHeapFlags()

IMPORT_C UInt32 MmGetHeapFlags ( _Input VoidPtr heap)

Change protection flags of a memory region.

◆ MmSetHeapFlags()

IMPORT_C SInt32 MmSetHeapFlags ( _Input VoidPtr heap,
_Input UInt32 flags )

Change protection flags of a memory region.

◆ MmStrCmp()

IMPORT_C SInt64 MmStrCmp ( _Input const Char * dest,
_Input const Char * src )

Compare string regions.

◆ MmStrLen()

IMPORT_C SInt64 MmStrLen ( const Char * str)

Get length of string.

◆ PrintCreate()

IMPORT_C IORef PrintCreate ( Void )

◆ PrintGet()

IMPORT_C IORef PrintGet ( const Char * path)

◆ PrintIn()

IMPORT_C SInt32 PrintIn ( IORef file,
const Char * fmt,
... )

◆ PrintOut()

IMPORT_C SInt32 PrintOut ( IORef file,
const Char * fmt,
... )

◆ PrintRelease()

IMPORT_C SInt32 PrintRelease ( IORef )

◆ PwrReadCode()

IMPORT_C SInt32 PwrReadCode ( _Output SInt32 & code)

◆ PwrSendCode()

IMPORT_C SInt32 PwrSendCode ( _Output SInt32 & code)

◆ RtlExitProcess()

IMPORT_C Bool RtlExitProcess ( UIntPtr handle,
UIntPtr exit_code )

Exits a process with an exit_code.

Returns
if it has succeeded true, otherwise false.

◆ RtlSpawnIB()

IMPORT_C UInt32 RtlSpawnIB ( UIntPtr process_id)

Spawns a Thread Information Block and Global Information Block inside the current process.

Parameters
process_idTarget Process ID, must be valid.
Returns
> 0 error occurred or already present, = 0 success.

◆ RtlSpawnProcess()

IMPORT_C UIntPtr RtlSpawnProcess ( const Char * process_path,
UInt32 argc,
Char ** argv,
Char ** envp,
UInt32 envp_len )

Spawns a process with a unique pid (stored as UIntPtr).

Parameters
process_pathprocess filesystem path.
Returns
> 0 process was created.

◆ SchedFireSignal()

IMPORT_C SInt32 SchedFireSignal ( _Input ProcessRef,
SInt32  )

◆ SchedGetAffinity()

IMPORT_C SInt32 SchedGetAffinity ( _Input ProcessRef,
_InOut AffinityRef *  )

◆ SchedGetCurrentProcessID()

IMPORT_C UIntPtr SchedGetCurrentProcessID ( Void )

◆ SchedReadMemory()

IMPORT_C SInt32 SchedReadMemory ( _Input ProcessRef,
SInt32 ,
SInt32  )

◆ SchedSetAffinity()

IMPORT_C SInt32 SchedSetAffinity ( _Input ProcessRef,
SInt32 req,
_Input AffinityRef *  )

◆ SchedWriteMemory()

IMPORT_C SInt32 SchedWriteMemory ( _Input ProcessRef,
SInt32 ,
SInt32  )

◆ StrFmt()

IMPORT_C Char * StrFmt ( const Char * fmt,
... )

◆ StrMathToNumber()

IMPORT_C UInt64 StrMathToNumber ( const Char * in,
const Char ** endp,
const SInt16 base )

◆ ThrCreateThread()

IMPORT_C ThreadRef ThrCreateThread ( const Char * thread_name,
ThrProcKind procedure,
SInt32 argument_count,
SInt32 flags )

Creates a thread.

Parameters
procedurethe thread procedure.
argument_countnumber of arguments inside that thread.
flagsThread flags.
Returns
the thread object.

◆ ThrDetachThread()

IMPORT_C SInt32 ThrDetachThread ( ThreadRef thrd)

Detach a thread.

Parameters
threadthe thread to detach.

◆ ThrExitCurrentThread()

IMPORT_C SInt32 ThrExitCurrentThread ( _Input SInt32 exit_code)

Exit the current thread.

Parameters
exit_codethe exit code.

◆ ThrExitMainThread()

IMPORT_C SInt32 ThrExitMainThread ( _Input SInt32 exit_code)

Exit the main thread.

Parameters
exit_codethe exit code.

◆ ThrExitThread()

IMPORT_C SInt32 ThrExitThread ( _Input ThreadRef thread,
_Input SInt32 exit_code )

Exit a thread.

Parameters
threadthe thread to exit.
exit_codethe exit code.

◆ ThrJoinThread()

IMPORT_C SInt32 ThrJoinThread ( ThreadRef thrd)

Joins a thread.

Parameters
threadthe thread to join.

◆ ThrYieldThread()

IMPORT_C SInt32 ThrYieldThread ( ThreadRef thrd)

Yields the current thread.

Parameters
threadthe thread to yield.