Win32 utility to bootstrap the PSX subsystem (it is an optional subsystem, therefore...
[reactos.git] / posix / server / include / psxss.h
1 /* $Id: psxss.h,v 1.3 2002/10/29 04:45:54 rex Exp $ */
2 #ifndef _PSX_PSXSS_H
3 #define _PSX_PSXSS_H
4
5 #define NTOS_MODE_USER
6 #include <ntos.h>
7 #include <ntdll/rtl.h>
8 #include <psx/lpcproto.h>
9
10 #ifdef __PSXSS_ON_W32__
11 #include <windows.h>
12 #endif
13
14 #define NAME_BUFFER_SIZE 64
15
16 /* PSXSS GLOBAL DATA */
17
18 typedef struct _SERVER_DIRECTORY
19 {
20 HANDLE hObject;
21 LPWSTR wsName;
22 UNICODE_STRING usName;
23
24 } SERVER_DIRECTORY;
25
26 #define PSXSS_THREADS_PER_PORT 2
27
28 typedef struct _SERVER_PORT
29 {
30 HANDLE hObject;
31 LPWSTR wsName;
32 UNICODE_STRING usName;
33 PTHREAD_START_ROUTINE EntryPoint;
34 struct {
35 HANDLE hObject;
36 DWORD Id;
37 } ThreadInfo [PSXSS_THREADS_PER_PORT];
38
39 } SERVER_PORT, * PSERVER_PORT;
40
41 #define SERVER_DIRECTORY_COUNT 3
42 #define SERVER_PORT_COUNT 3
43
44 typedef struct _SERVER
45 {
46 HANDLE Heap;
47 SERVER_DIRECTORY Directory [SERVER_DIRECTORY_COUNT];
48 SERVER_PORT Port [SERVER_PORT_COUNT];
49
50 } SERVER;
51
52 #define PSX_PORT_API 0
53 #define PSX_PORT_SBAPI 1
54 #define PSX_PORT_SESSION 2
55
56 #define PSX_DIRECTORY_POSIX 0
57 #define PSX_DIRECTORY_SESSIONS 1
58 #define PSX_DIRECTORY_SYSTEM 2
59
60 extern SERVER Server; /* server/misc/init.c */
61
62 /* System call type */
63 typedef NTSTATUS (STDCALL *PSX_SYSTEM_CALL)(PPSX_MAX_MESSAGE);
64
65 /* System calls table */
66
67 extern PSX_SYSTEM_CALL SystemCall []; /* server/call/syscall.c */
68
69 /* Listener's Threads */
70 VOID STDCALL ApiPortListener (PVOID);
71 VOID STDCALL SbApiPortListener (PVOID);
72 VOID STDCALL SessionPortListener (PVOID);
73
74 /* TERMINAL OBJECT */
75
76 typedef struct _PSX_TERMINAL
77 {
78 DWORD Id;
79 /* TODO */
80 } PSX_TERMINAL, * PPSX_TERMINAL;
81
82 /* PROCESS OBJECT */
83
84 typedef enum
85 {
86 PROCESS_STATUS_INITIALIZATION,
87 PROCESS_STATUS_READY,
88 PROCESS_STATUS_WAITING,
89 PROCESS_STATUS_DEAD,
90 PROCESS_STATUS_ZOMBIE
91
92 } PROCESS_STATUS;
93
94 typedef DWORD PSX_SECURITY; /* TODO */
95
96 struct _PSX_SESSION;
97
98 typedef struct _PSX_PROCESS
99 {
100 INT Id; /* pid */
101 HANDLE hProcess; /* hProcess */
102 PROCESS_STATUS Status;
103 struct _PSX_PROCESS * Parent;
104 struct _PSX_SESSION * Session;
105 PPSX_TERMINAL ControlTty;
106 PSX_SECURITY Security;
107
108 } PSX_PROCESS, * PPSX_PROCESS;
109
110 /* SESSION OBJECT */
111
112 typedef enum
113 {
114 SESSION_STATUS_INITIALIZATION,
115 SESSION_STATUS_READY,
116 SESSION_STATUS_SHUTDOWN,
117 SESSION_STATUS_ERROR
118
119 } SESSION_STATUS;
120
121 typedef struct _PSX_SESSION
122 {
123 DWORD Id;
124 ULONG ReferenceCount;
125 SESSION_STATUS Status;
126 HANDLE Heap;
127 struct {
128 HANDLE hPort;
129 ULONG ulPortIdentifier;
130 } SessionChannel;
131 struct {
132 ULONG Id; /* csrterm pid */
133 HANDLE hPort; /* LPC port owned by csrterm: \POSIX+\Sessions\P{Id} */
134 struct {
135 HANDLE Handle; /* Section owned by csrterm: \POSIX+\Sessions\D{Id} */
136 PVOID BaseAddress;
137 ULONG ViewSize;
138 } Section;
139 } TerminalChannel;
140 PPSX_PROCESS Leader;
141 CRITICAL_SECTION Lock;
142 struct _PSX_SESSION * Previous;
143 struct _PSX_SESSION * Next;
144
145 } PSX_SESSION, * PPSX_SESSION;
146
147 /* prototypes */
148
149 VOID STDCALL debug_print (LPWSTR Template, ...);
150 NTSTATUS STDCALL PsxInitializeSessions (VOID); /* ob/session.c */
151 NTSTATUS STDCALL PsxCreateSession (PLPC_MAX_MESSAGE,HANDLE,ULONG);
152 NTSTATUS STDCALL PsxInitializeProcesses (VOID); /* ob/process.c */
153 NTSTATUS STDCALL PsxCreateProcess (PLPC_MAX_MESSAGE,HANDLE,ULONG);
154
155 #endif /* ndef _PSX_PSXSS_H */