Kernel - Implementing select()
[tpg/acess2.git] / Kernel / include / acess.h
index 1f969f8..a2d406b 100644 (file)
@@ -20,9 +20,9 @@ typedef  int  tTID;
 typedef Uint   tUID;
 typedef Uint   tGID;
 typedef Sint64 tTimestamp;
+typedef Sint64 tTime;
 typedef struct sShortSpinlock  tShortSpinlock;
 typedef struct sMutex  tMutex;
-typedef struct sSemaphore      tSemaphore;
 
 struct sMutex {
        tShortSpinlock  Protector;      //!< Protector for the lock strucure
@@ -32,14 +32,6 @@ struct sMutex {
        struct sThread  *LastWaiting;   //!< Waiting threads
 };
 
-struct sSemaphore {
-       tShortSpinlock  Protector;      //!< Protector for the lock strucure
-       const char      *Name;  //!< Human-readable name
-       volatile int    Value;  //!< Current mutex value
-       struct sThread  *Waiting;       //!< Waiting threads
-       struct sThread  *LastWaiting;   //!< Waiting threads
-};
-
 // --- Helper Macros ---
 /**
  * \name Helper Macros
@@ -104,7 +96,7 @@ typedef void (*tThreadFunction)(void*);
  * \{
  */
 typedef struct sKernelSymbol {
-       char    *Name;
+       const char      *Name;
        tVAddr  Value;
 } tKernelSymbol;
 #define        EXPORT(_name)   tKernelSymbol _kexp_##_name __attribute__((section ("KEXPORT"),unused))={#_name, (tVAddr)_name}
@@ -119,13 +111,13 @@ typedef struct sKernelSymbol {
 extern int     IRQ_AddHandler(int Num, void (*Callback)(int));
 
 // --- Logging ---
-extern void    Log_KernelPanic(char *Ident, char *Message, ...);
-extern void    Log_Panic(char *Ident, char *Message, ...);
-extern void    Log_Error(char *Ident, char *Message, ...);
-extern void    Log_Warning(char *Ident, char *Message, ...);
-extern void    Log_Notice(char *Ident, char *Message, ...);
-extern void    Log_Log(char *Ident, char *Message, ...);
-extern void    Log_Debug(char *Ident, char *Message, ...);
+extern void    Log_KernelPanic(const char *Ident, const char *Message, ...);
+extern void    Log_Panic(const char *Ident, const char *Message, ...);
+extern void    Log_Error(const char *Ident, const char *Message, ...);
+extern void    Log_Warning(const char *Ident, const char *Message, ...);
+extern void    Log_Notice(const char *Ident, const char *Message, ...);
+extern void    Log_Log(const char *Ident, const char *Message, ...);
+extern void    Log_Debug(const char *Ident, const char *Message, ...);
 
 // --- Debug ---
 /**
@@ -194,7 +186,7 @@ extern Uint64       inq(Uint16 Port);
  * \param VAddr        Virtual Address to allocate at
  * \return Physical address allocated
  */
-extern tPAddr  MM_Allocate(tVAddr VAddr);
+extern tPAddr  MM_Allocate(tVAddr VAddr) __attribute__ ((warn_unused_result));
 /**
  * \brief Deallocate a page
  * \param VAddr        Virtual address to unmap
@@ -286,6 +278,12 @@ extern void        MM_RefPhys(tPAddr PAddr);
  * \param PAddr        Page to dereference
  */
 extern void    MM_DerefPhys(tPAddr PAddr);
+/**
+ * \brief Get the number of times a page has been referenced
+ * \param PAddr        Address to check
+ * \return Reference count for the page
+ */
+extern int     MM_GetRefCount(tPAddr PAddr);
 /**
  * \}
  */
@@ -307,8 +305,8 @@ extern void *memsetd(void *dest, Uint32 val, size_t count);
  * \name Memory Validation
  * \{
  */
-extern int     CheckString(char *String);
-extern int     CheckMem(void *Mem, int Num);
+extern int     CheckString(const char *String);
+extern int     CheckMem(const void *Mem, int Num);
 /**
  * \}
  */
@@ -346,14 +344,14 @@ extern char       **str_split(const char *__str, char __ch);
 extern char    *strchr(const char *__s, int __c);
 extern int     strpos(const char *Str, char Ch);
 extern int     strpos8(const char *str, Uint32 search);
-extern void    itoa(char *buf, Uint num, int base, int minLength, char pad);
+extern void    itoa(char *buf, Uint64 num, int base, int minLength, char pad);
 extern int     atoi(const char *string);
-extern int     ReadUTF8(Uint8 *str, Uint32 *Val);
+extern int     ReadUTF8(const Uint8 *str, Uint32 *Val);
 extern int     WriteUTF8(Uint8 *str, Uint32 Val);
-extern int     ModUtil_SetIdent(char *Dest, char *Value);
-extern int     ModUtil_LookupString(char **Array, char *Needle);
+extern int     ModUtil_SetIdent(char *Dest, const char *Value);
+extern int     ModUtil_LookupString(const char **Array, const char *Needle);
 
-extern Uint8   ByteSum(void *Ptr, int Size);
+extern Uint8   ByteSum(const void *Ptr, int Size);
 extern int     UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString);
 /**
  * \}
@@ -370,8 +368,8 @@ extern int  CallWithArgArray(void *Function, int NArgs, Uint *Args);
  * \name Modules
  * \{
  */
-extern int     Module_LoadMem(void *Buffer, Uint Length, char *ArgStr);
-extern int     Module_LoadFile(char *Path, char *ArgStr);
+extern int     Module_LoadMem(void *Buffer, Uint Length, const char *ArgStr);
+extern int     Module_LoadFile(const char *Path, const char *ArgStr);
 /**
  * \}
  */
@@ -404,6 +402,9 @@ extern int  Time_CreateTimer(int Delta, tTimerCallback *Callback, void *Argument)
  * \brief Removed an active timer
  */
 extern void    Time_RemoveTimer(int ID);
+/**
+ * \brief Wait for a period of milliseconds
+ */
 extern void    Time_Delay(int Delay);
 /**
  * \}
@@ -427,7 +428,7 @@ extern tGID Threads_GetGID(void);
 extern int     SpawnTask(tThreadFunction Function, void *Arg);
 extern Uint    *Threads_GetCfgPtr(int Id);
 extern int     Threads_SetName(const char *NewName);
-extern void    Mutex_Acquire(tMutex *Mutex);
+extern int     Mutex_Acquire(tMutex *Mutex);
 extern void    Mutex_Release(tMutex *Mutex);
 extern int     Mutex_IsLocked(tMutex *Mutex);
 /**

UCC git Repository :: git.ucc.asn.au