6e559bede1e2b90d0638c47f7057b40389ead75d
[tpg/acess2.git] / Kernel / arch / x86 / include / proc.h
1 /*
2  * AcessOS Microkernel Version
3  * proc.h
4  */
5 #ifndef _PROC_H
6 #define _PROC_H
7
8 // === CONSTANTS ===
9 #define GETMSG_IGNORE   ((void*)-1)
10
11 // === TYPES ===
12 typedef struct sMessage {
13         struct sMessage *Next;
14         Uint    Source;
15         Uint    Length;
16         Uint8   Data[];
17 } tMsg; // sizeof = 12+
18
19 typedef struct sThread {
20         struct sThread  *Next;
21          int    IsLocked;
22          int    Status; //!< Thread Status
23         
24         Uint    TID;    //!< Thread ID
25         Uint    TGID;   //!< Thread Group (Process)
26         Uint    UID, GID;       //!< User and Group
27         char    *ThreadName;    //!< Name of thread
28         
29         Uint    ESP, EBP, EIP;  //!< State on switch
30         #if USE_PAE
31         Uint64  PML4[3];        //!< Address Space
32         #else
33         Uint    CR3;    //!< Memory Space
34         #endif
35         
36         Uint    KernelStack;    //!< Thread's Kernel Stack
37         
38         tMsg    *Messages;      //!< Message Queue
39         tMsg    *LastMessage;   //!< Last Message (speeds up insertion)
40         
41          int    Quantum, Remaining;     //!< Quantum Size and remaining timesteps
42          int    NumTickets;     //!< Priority - Chance of gaining CPU
43         
44         Uint    Config[NUM_CFG_ENTRIES];        //!< Per-process configuration
45 } tThread;      // sizeof = 68
46
47 enum {
48         THREAD_STAT_NULL,
49         THREAD_STAT_ACTIVE,
50         THREAD_STAT_SLEEPING,
51         THREAD_STAT_WAITING,
52         THREAD_STAT_DEAD
53 };
54
55 typedef struct sTSS {
56         Uint32  Link;
57         Uint32  ESP0, SS0;
58         Uint32  ESP1, SS1;
59         Uint32  ESP2, SS2;
60         Uint32  CR3;
61         Uint32  EIP;
62         Uint32  EFLAGS;
63         Uint32  EAX, ECX, EDX, EBX;
64         Uint32  ESP, EBP, ESI, EDI;
65         Uint32  ES, CS, DS, SS, FS, GS;
66         Uint32  LDTR;
67         Uint16  Resvd, IOPB;    // IO Permissions Bitmap
68 } tTSS;
69
70 // === GLOBALS ===
71 extern tThread  *gCurrentThread;
72
73 // === FUNCTIONS ===
74 extern void     Proc_Start();
75 extern int      Proc_Clone(Uint *Err, Uint Flags);
76 extern void Proc_Exit();
77 extern void Proc_Yield();
78 extern void Proc_Sleep();
79 extern void Proc_SetTickets(int Num);
80 extern tThread  *Proc_GetThread(Uint TID);
81 extern void     Thread_Wake(tThread *Thread);
82
83 #endif

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