X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Finclude%2Facess.h;h=6373cec51b3717520e0ed74fce3fdb528238907c;hb=0b24cbc2f18942b3d1d74efa025ecfa318ab35ec;hp=d2e1e8023c469b484c66a04756f28b714bff9f3d;hpb=635bc78017d8a4a16314a973e39c849b2afac795;p=tpg%2Facess2.git diff --git a/Kernel/include/acess.h b/Kernel/include/acess.h index d2e1e802..6373cec5 100644 --- a/Kernel/include/acess.h +++ b/Kernel/include/acess.h @@ -20,16 +20,8 @@ typedef int tTID; typedef Uint tUID; typedef Uint tGID; typedef Sint64 tTimestamp; +typedef Sint64 tTime; typedef struct sShortSpinlock tShortSpinlock; -typedef struct sMutex tMutex; - -struct sMutex { - tShortSpinlock Protector; //!< Protector for the lock strucure - const char *Name; //!< Human-readable name - 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 --- /** @@ -47,7 +39,7 @@ struct sMutex { */ /** - * \name Per-Process Configuration Settings + * \name Per-Thread Configuration Settings * \{ */ enum eConfigTypes { @@ -60,10 +52,13 @@ enum eConfigs { CFG_VFS_CWD, CFG_VFS_MAXFILES, CFG_VFS_CHROOT, + CFG_ERRNO, NUM_CFG_ENTRIES }; #define CFGINT(id) (*Threads_GetCfgPtr(id)) #define CFGPTR(id) (*(void**)Threads_GetCfgPtr(id)) + +#define errno (CFGINT(CFG_ERRNO)) /** * \} */ @@ -95,7 +90,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} @@ -108,15 +103,16 @@ typedef struct sKernelSymbol { // === FUNCTIONS === // --- IRQs --- extern int IRQ_AddHandler(int Num, void (*Callback)(int)); +extern void IRQ_RemHandler(int Handle); // --- 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 --- /** @@ -185,7 +181,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 @@ -277,6 +273,30 @@ 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); +/** + * \brief Set the node associated with a page + * \param PAddr Physical address of page + * \param Node Node pointer (tVFS_Node) + * \return Boolean failure + * \retval 0 Success + * \retval 1 Page not allocated + */ +extern int MM_SetPageNode(tPAddr PAddr, void *Node); +/** + * \brief Get the node associated with a page + * \param PAddr Physical address of page + * \param Node Node pointer (tVFS_Node) destination + * \return Boolean failure + * \retval 0 Success + * \retval 1 Page not allocated + */ +extern int MM_GetPageNode(tPAddr PAddr, void **Node); /** * \} */ @@ -298,8 +318,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); /** * \} */ @@ -309,10 +329,19 @@ extern int CheckMem(void *Mem, int Num); * \name Endianness Swapping * \{ */ -extern Uint16 LittleEndian16(Uint16 Val); -extern Uint16 BigEndian16(Uint16 Val); -extern Uint32 LittleEndian32(Uint32 Val); -extern Uint32 BigEndian32(Uint32 Val); +#ifdef __BIG_ENDIAN__ +#define LittleEndian16(_val) SwapEndian16(_val) +#define LittleEndian32(_val) SwapEndian32(_val) +#define BigEndian16(_val) (_val) +#define BigEndian32(_val) (_val) +#else +#define LittleEndian16(_val) (_val) +#define LittleEndian32(_val) (_val) +#define BigEndian16(_val) SwapEndian16(_val) +#define BigEndian32(_val) SwapEndian32(_val) +#endif +extern Uint16 SwapEndian16(Uint16 Val); +extern Uint32 SwapEndian32(Uint32 Val); /** * \} */ @@ -327,11 +356,12 @@ extern int sprintf(char *__s, const char *__format, ...); extern size_t strlen(const char *Str); extern char *strcpy(char *__dest, const char *__src); extern char *strncpy(char *__dest, const char *__src, size_t max); +extern char *strcat(char *__dest, const char *__src); +extern char *strncat(char *__dest, const char *__src, size_t n); extern int strcmp(const char *__str1, const char *__str2); extern int strncmp(const char *Str1, const char *Str2, size_t num); extern int strucmp(const char *Str1, const char *Str2); -//extern char *strdup(const char *Str); -#define strdup(Str) _strdup(_MODULE_NAME_"/"__FILE__, __LINE__, (Str)) +// strdup macro is defined in heap.h extern char *_strdup(const char *File, int Line, const char *Str); extern char **str_split(const char *__str, char __ch); extern char *strchr(const char *__s, int __c); @@ -339,12 +369,12 @@ extern int strpos(const char *Str, char Ch); extern int strpos8(const char *str, Uint32 search); 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); /** * \} @@ -361,8 +391,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); /** * \} */ @@ -409,7 +439,7 @@ extern void Time_Delay(int Delay); * \{ */ extern int Proc_SpawnWorker(void); -extern int Proc_Spawn(char *Path); +extern int Proc_Spawn(const char *Path); extern void Threads_Exit(int TID, int Status); extern void Threads_Yield(void); extern void Threads_Sleep(void); @@ -421,9 +451,6 @@ 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 int Mutex_Acquire(tMutex *Mutex); -extern void Mutex_Release(tMutex *Mutex); -extern int Mutex_IsLocked(tMutex *Mutex); /** * \} */ @@ -433,6 +460,6 @@ extern int DivUp(int num, int dem); #include #include -#include +#include #endif