3 * - By John Hodge (thePowersGang)
6 * - HAL Process management functions
13 * \brief Achitecture defined thread/process management functions
16 #include <threads_int.h>
19 * \brief Initialise the architecture dependent side of threading
21 extern void ArchThreads_Init(void);
23 * \brief Start preemptive multithreading (if needed)
25 extern void Proc_Start(void);
27 * \brief Called just before a thread is freed
29 extern void Proc_ClearThread(tThread *Thread);
31 * \brief Called just before a process is freed
33 extern void Proc_ClearProcess(tProcess *Process);
35 * \brief Get the ID of this CPU
36 * \return Zero based CPU ID
38 extern int GetCPUNum(void);
40 * \brief Create a copy of the current process
41 * \param Flags Options for the clone
42 * \return ID of the new thread/process
44 extern tTID Proc_Clone(Uint Flags);
46 * \brief Create a new kernel thread for the process
47 * \param Fnc Thread root function
48 * \param Ptr Argument to pass the root function
49 * \return ID of new thread
51 extern tTID Proc_NewKThread( void (*Fnc)(void*), void *Ptr );
53 * \brief Start a user task
54 * \param Entrypoint User entrypoint
55 * \param Base Base of executable (argument for ld-acess)
56 * \param ArgC Number of arguments when the program was invoked
57 * \param ArgV Heap allocated arguments and environment (two NULL terminated lists)
58 * \param DataSize Size of the \a ArgV buffer in bytes
59 * \note This function should free \a ArgV
61 extern void Proc_StartUser(Uint Entrypoint, Uint Base, int ArgC, const char **ArgV, int DataSize) NORETURN;
63 * \brief Call the fault handler for a thread
64 * \param Thread Thread that is at fault :)
66 extern void Proc_CallFaultHandler(tThread *Thread);
68 * \brief Dump the CPU state for a thread
70 extern void Proc_DumpThreadCPUState(tThread *Thread);
72 * \brief Select a new task and run it, suspending this
74 extern void Proc_Reschedule(void);
77 * \brief Clear the user's memory space back to the minimum required to run
79 extern void MM_ClearUser(void);
81 * \brief Dump the address space to the debug channel
82 * \param Start First address
83 * \param End Last address
85 extern void MM_DumpTables(tVAddr Start, tVAddr End);
88 * \brief Dump physical memory usage statistics to the debug channel
90 extern void MM_DumpStatistics(void);
93 * \brief Check if a buffer is valid (and all user if originally user)
94 * \param Addr Base address
95 * \param Size Size of the buffer in bytes
96 * \return Boolean valid (0: invalid, non-0: Valid)
98 extern int MM_IsValidBuffer(tVAddr Addr, size_t Size);