3a22e5ea741828b9621acd4e55e7d97c027b18aa
[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 Called just before a process is freed
32  */
33 extern void     Proc_ClearProcess(tProcess *Process);
34 /**
35  * \brief Get the ID of this CPU
36  * \return Zero based CPU ID
37  */
38 extern int      GetCPUNum(void);
39 /**
40  * \brief Create a copy of the current process
41  * \param Flags Options for the clone
42  * \return ID of the new thread/process
43  */
44 extern tTID     Proc_Clone(Uint Flags);
45 /**
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
50  */
51 extern tTID     Proc_NewKThread( void (*Fnc)(void*), void *Ptr );
52 /**
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
60  */
61 extern void     Proc_StartUser(Uint Entrypoint, Uint Base, int ArgC, char **ArgV, int DataSize) NORETURN;
62 /**
63  * \brief Call the fault handler for a thread
64  * \param Thread        Thread that is at fault :)
65  */
66 extern void     Proc_CallFaultHandler(tThread *Thread);
67 /**
68  * \brief Dump the CPU state for a thread
69  */
70 extern void     Proc_DumpThreadCPUState(tThread *Thread);
71 /**
72  * \brief Select a new task and run it, suspending this
73  */
74 extern void     Proc_Reschedule(void);
75
76 /**
77  * \brief Clear the user's memory space back to the minimum required to run
78  */
79 extern void     MM_ClearUser(void);
80 /**
81  * \brief Dump the address space to the debug channel
82  * \param Start First address
83  * \param End   Last address
84  */
85 extern void     MM_DumpTables(tVAddr Start, tVAddr End);
86
87 /**
88  * \brief Check if a buffer is valid (and all user if originally user)
89  * \param Addr  Base address
90  * \param Size  Size of the buffer in bytes
91  * \return Boolean valid (0: invalid, non-0: Valid)
92  */
93 extern int      MM_IsValidBuffer(tVAddr Addr, size_t Size);
94 #endif

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