Kernel - Fixing very slow CheckMem function
[tpg/acess2.git] / Kernel / include / hal_proc.h
1 /**
2  * Acess2
3  * - By John Hodge (thePowersGang)
4  *
5  * include/hal_proc.h
6  * - HAL Process management functions
7  * 
8  */
9 #ifndef _HAL_PROC_H_
10 #define _HAL_PROC_H_
11 /**
12  * \file hal_proc.h
13  * \brief Achitecture defined thread/process management functions
14  */
15
16 #include <threads_int.h>
17
18 /**
19  * \brief Initialise the architecture dependent side of threading
20  */
21 extern void     ArchThreads_Init(void);
22 /**
23  * \brief Start preemptive multithreading (if needed)
24  */
25 extern void     Proc_Start(void);
26 /**
27  * \brief Called just before a thread is freed
28  */
29 extern void     Proc_ClearThread(tThread *Thread);
30 /**
31  * \brief Get the ID of this CPU
32  * \return Zero based CPU ID
33  */
34 extern int      GetCPUNum(void);
35 /**
36  * \brief Create a copy of the current process
37  * \param Flags Options for the clone
38  * \return ID of the new thread/process
39  */
40 extern tTID     Proc_Clone(Uint Flags);
41 /**
42  * \brief Create a new kernel thread for the process
43  * \param Fnc   Thread root function
44  * \param Ptr   Argument to pass the root function
45  * \return ID of new thread
46  */
47 extern tTID     Proc_NewKThread( void (*Fnc)(void*), void *Ptr );
48 /**
49  * \brief Start a user task
50  * \param Entrypoint    User entrypoint
51  * \param Base  Base of executable (argument for ld-acess)
52  * \param ArgC  Number of arguments when the program was invoked
53  * \param ArgV  Heap allocated arguments and environment (two NULL terminated lists)
54  * \param DataSize      Size of the \a ArgV buffer in bytes
55  * \note This function should free \a ArgV
56  */
57 extern void     Proc_StartUser(Uint Entrypoint, Uint Base, int ArgC, char **ArgV, int DataSize) NORETURN;
58 /**
59  * \brief Call the fault handler for a thread
60  * \param Thread        Thread that is at fault :)
61  */
62 extern void     Proc_CallFaultHandler(tThread *Thread);
63 /**
64  * \brief Dump the CPU state for a thread
65  */
66 extern void     Proc_DumpThreadCPUState(tThread *Thread);
67 /**
68  * \brief Select a new task and run it, suspending this
69  */
70 extern void     Proc_Reschedule(void);
71
72 /**
73  * \brief Clear the user's memory space back to the minimum required to run
74  */
75 extern void     MM_ClearUser(void);
76 /**
77  * \brief Dump the address space to the debug channel
78  * \param Start First address
79  * \param End   Last address
80  */
81 extern void     MM_DumpTables(tVAddr Start, tVAddr End);
82
83 /**
84  * \brief Check if a buffer is valid (and all user if originally user)
85  * \param Addr  Base address
86  * \param Size  Size of the buffer in bytes
87  * \return Boolean valid (0: invalid, non-0: Valid)
88  */
89 extern int      MM_IsValidBuffer(tVAddr Addr, size_t Size);
90 #endif

UCC git Repository :: git.ucc.asn.au