X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Finclude%2Facess.h;h=a956d148842e9f9a88e5a58ec03e700a1e3f3ff9;hb=7d76ac580a19c897ea849d4bc684068ab1fdc6f3;hp=ad865784f78922cbb283b06c1af5cc35345bfc60;hpb=1544491b3b1a854e2c8333ca75d6b20a5550e03f;p=tpg%2Facess2.git diff --git a/Kernel/include/acess.h b/Kernel/include/acess.h index ad865784..a956d148 100644 --- a/Kernel/include/acess.h +++ b/Kernel/include/acess.h @@ -7,9 +7,13 @@ #define NULL ((void*)0) #define PACKED __attribute__((packed)) +#define NORETURN __attribute__((noreturn)) #define UNUSED(x) UNUSED_##x __attribute__((unused)) #define offsetof(st, m) ((Uint)((char *)&((st *)(0))->m - (char *)0 )) +#define TRUE 1 +#define FALSE 0 + #include #include #include "errno.h" @@ -22,6 +26,7 @@ typedef Uint tGID; typedef Sint64 tTimestamp; typedef Sint64 tTime; typedef struct sShortSpinlock tShortSpinlock; +typedef int bool; // --- Helper Macros --- /** @@ -33,6 +38,10 @@ typedef struct sShortSpinlock tShortSpinlock; #define STR(x) #x #define EXPAND_STR(x) STR(x) +extern char __buildnum[]; +#define BUILD_NUM ((int)(Uint)&__buildnum) +extern const char gsGitHash[]; + #define VER2(major,minor) ((((major)&0xFF)<<8)|((minor)&0xFF)) /** * \} @@ -102,7 +111,7 @@ typedef struct sKernelSymbol { // === FUNCTIONS === // --- IRQs --- -extern int IRQ_AddHandler(int Num, void (*Callback)(int)); +extern int IRQ_AddHandler(int Num, void (*Callback)(int, void*), void *Ptr); extern void IRQ_RemHandler(int Handle); // --- Logging --- @@ -154,6 +163,16 @@ extern void Debug_HexDump(const char *Header, const void *Data, Uint Length); */ // --- IO --- +#if NO_IO_BUS +#define inb(a) (Log_Panic("Arch", "ARMv7 does not support in*/out* (%s:%i)", __FILE__, __LINE__),0) +#define inw(a) inb(a) +#define ind(a) inb(a) +#define inq(a) inb(a) +#define outb(a,b) inb(a) +#define outw(a,b) inb(a) +#define outd(a,b) inb(a) +#define outq(a,b) inb(a) +#else /** * \name I/O Memory Access * \{ @@ -169,7 +188,7 @@ extern Uint64 inq(Uint16 Port); /** * \} */ - +#endif // --- Memory Management --- /** * \name Memory Management @@ -247,7 +266,7 @@ extern tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number); extern tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr); /** * \brief Unmaps an allocated hardware range - * \param VAddr Virtual address allocate by ::MM_MapHWPage or ::MM_AllocDMA + * \param VAddr Virtual address allocate by ::MM_MapHWPages or ::MM_AllocDMA * \param Number Number of pages to free */ extern void MM_UnmapHWPages(tVAddr VAddr, Uint Number); @@ -280,25 +299,23 @@ extern void MM_DerefPhys(tPAddr PAddr); */ extern int MM_GetRefCount(tPAddr PAddr); /** - * \brief Set the node/offset associated with a page + * \brief Set the node associated with a page * \param PAddr Physical address of page * \param Node Node pointer (tVFS_Node) - * \param Offset File offset * \return Boolean failure * \retval 0 Success * \retval 1 Page not allocated */ -extern int MM_SetPageInfo(tPAddr PAddr, void *Node, Uint64 Offset); +extern int MM_SetPageNode(tPAddr PAddr, void *Node); /** - * \brief Get the node/offset associated with a page + * \brief Get the node associated with a page * \param PAddr Physical address of page * \param Node Node pointer (tVFS_Node) destination - * \param Offset File offset destination (pointer) * \return Boolean failure * \retval 0 Success * \retval 1 Page not allocated */ -extern int MM_GetPageInfo(tPAddr PAddr, void **Node, Uint64 *Offset); +extern int MM_GetPageNode(tPAddr PAddr, void **Node); /** * \} */ @@ -309,10 +326,11 @@ extern int MM_GetPageInfo(tPAddr PAddr, void **Node, Uint64 *Offset); * \{ */ extern int memcmp(const void *m1, const void *m2, size_t count); -extern void *memcpy(void *dest, const void *src, size_t count); -extern void *memcpyd(void *dest, const void *src, size_t count); -extern void *memset(void *dest, int val, size_t count); -extern void *memsetd(void *dest, Uint32 val, size_t count); +extern void *memcpy(void *dest, const void *src, size_t count); +extern void *memcpyd(void *dest, const void *src, size_t count); +extern void *memmove(void *dest, const void *src, size_t len); +extern void *memset(void *dest, int val, size_t count); +extern void *memsetd(void *dest, Uint32 val, size_t count); /** * \} */ @@ -440,8 +458,8 @@ extern void Time_Delay(int Delay); * \name Threads and Processes * \{ */ -extern int Proc_SpawnWorker(void); -extern int Proc_Spawn(char *Path); +extern int Proc_SpawnWorker(void (*Fcn)(void*), void *Data); +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); @@ -459,10 +477,10 @@ extern int Threads_SetName(const char *NewName); // --- Simple Math --- extern int DivUp(int num, int dem); +extern Uint64 DivMod64U(Uint64 Num, Uint64 Den, Uint64 *Rem); #include #include -#include #include #endif