/*
* 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 UNUSED(x) UNUSED_##x __attribute__((unused))
#define offsetof(st, m) ((Uint)((char *)&((st *)(0))->m - (char *)0 ))
-//#include <stdint.h>
#include <arch.h>
#include <stdarg.h>
#include "errno.h"
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 ---
/**
/**
* \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);
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);
+//extern char *strdup(const char *Str);
+#define strdup(Str) _strdup(_MODULE_NAME_"/"__FILE__, __LINE__, (Str))
+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);
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 int WriteUTF8(Uint8 *str, Uint32 Val);
extern int ModUtil_SetIdent(char *Dest, char *Value);
extern int ModUtil_LookupString(char **Array, char *Needle);
+
extern Uint8 ByteSum(void *Ptr, int Size);
+extern int UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString);
/**
* \}
*/
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 <heap.h>
// --- Modules ---
/**
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);
/**
* \}
*/