X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Kernel%2Finclude%2Facess.h;h=e6afcf5e1f15441f9c796fe967aba3a676b5144e;hb=05e8b329edc7c55eec967c3caba1982c173025e3;hp=83a44ce51488942d1f52ee98978d7d404a715b0d;hpb=dea6bcf35a3f52396724d74e47f71cb3afade37c;p=tpg%2Facess2.git diff --git a/Kernel/include/acess.h b/Kernel/include/acess.h index 83a44ce5..e6afcf5e 100644 --- a/Kernel/include/acess.h +++ b/Kernel/include/acess.h @@ -1,14 +1,15 @@ /* * AcessOS Microkernel Version - * common.h + * acess.h */ -#ifndef _COMMON_H -#define _COMMON_H +#ifndef _ACESS_H +#define _ACESS_H #define NULL ((void*)0) -#define PACKED __attribute__ ((packed)) +#define PACKED __attribute__((packed)) +#define UNUSED(x) UNUSED_##x __attribute__((unused)) +#define offsetof(st, m) ((Uint)((char *)&((st *)(0))->m - (char *)0 )) -//#include #include #include #include "errno.h" @@ -19,6 +20,15 @@ typedef int tTID; typedef Uint tUID; typedef Uint tGID; typedef Sint64 tTimestamp; +typedef struct sShortSpinlock tShortSpinlock; +typedef struct sMutex tMutex; + +struct sMutex { + tShortSpinlock Protector; //!< Protector for the lock strucure + struct sThread *volatile Owner; //!< Owner of the lock (set upon getting the lock) + struct sThread *Waiting; //!< Waiting threads + struct sThread *LastWaiting; //!< Waiting threads +}; // --- Helper Macros --- /** @@ -252,6 +262,7 @@ extern tPAddr MM_AllocPhys(void); /** * \brief Allocate a contiguous range of physical pages * \param Pages Number of pages to allocate + * \param MaxBits Maximum number of address bits allowed * \return First physical address allocated */ extern tPAddr MM_AllocPhysRange(int Pages, int MaxBits); @@ -337,18 +348,7 @@ extern Uint rand(void); extern int CallWithArgArray(void *Function, int NArgs, Uint *Args); // --- Heap --- -/** - * \name Heap - * \{ - */ -extern void *malloc(size_t size); -extern void *calloc(size_t num, size_t size); -extern void *realloc(void *ptr, size_t size); -extern void free(void *Ptr); -extern int IsHeap(void *Ptr); -/** - * \} - */ +#include // --- Modules --- /** @@ -370,8 +370,24 @@ extern int Module_LoadFile(char *Path, char *ArgStr); * \brief Create a timestamp from a time */ extern Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year); +/** + * \brief Gets the current timestamp (miliseconds since Midnight 1st January 1970) + */ extern Sint64 now(void); -extern int Time_CreateTimer(int Delta, void *Callback, void *Argument); +/** + * \brief Timer callback function + */ +typedef void (tTimerCallback)(void *); +/** + * \brief Creates a one-shot timer + * \param Delta Period of the timer + * \param Callback Function to call each time + * \param Argument Argument to pass to the callback + */ +extern int Time_CreateTimer(int Delta, tTimerCallback *Callback, void *Argument); +/** + * \brief Removed an active timer + */ extern void Time_RemoveTimer(int ID); extern void Time_Delay(int Delay); /** @@ -388,7 +404,7 @@ extern int Proc_Spawn(char *Path); extern void Threads_Exit(int TID, int Status); extern void Threads_Yield(void); extern void Threads_Sleep(void); -extern void Threads_WakeTID(tTID Thread); +extern int Threads_WakeTID(tTID Thread); extern tPID Threads_GetPID(void); extern tTID Threads_GetTID(void); extern tUID Threads_GetUID(void); @@ -396,6 +412,9 @@ extern tGID Threads_GetGID(void); extern int SpawnTask(tThreadFunction Function, void *Arg); extern Uint *Threads_GetCfgPtr(int Id); extern int Threads_SetName(char *NewName); +extern void Mutex_Acquire(tMutex *Mutex); +extern void Mutex_Release(tMutex *Mutex); +extern int Mutex_IsLocked(tMutex *Mutex); /** * \} */