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

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