summaryrefslogtreecommitdiffstats
path: root/private/os2/os2ss/sbinit.c
blob: 393888dc140224523c4eb6212a6e96025b4e6257 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*++

Copyright (c) 1989  Microsoft Corporation

Module Name:

    sbinit.c

Abstract:

    This module contains the code to initialize the SbApiPort of the OS/2
    Emulation Subsystem.

Author:

    Steve Wood (stevewo) 22-Aug-1989

Environment:

    User Mode Only

Revision History:

--*/

#include "os2srv.h"

NTSTATUS
Os2SbApiPortInitialize( VOID )
{
    NTSTATUS Status;
    OBJECT_ATTRIBUTES ObjectAttributes;

    RtlInitUnicodeString( &Os2SbApiPortName_U, OS2_SS_SBAPI_PORT_NAME );

#if DBG
    IF_OS2_DEBUG( LPC ) {
        KdPrint(( "OS2SRV: Creating %wZ port and associated thread\n",
                  &Os2SbApiPortName_U ));
        }
#endif

    InitializeObjectAttributes(
	&ObjectAttributes,
	&Os2SbApiPortName_U,
	OBJ_CASE_INSENSITIVE,
	NULL,
	NULL);
    Status = NtCreatePort( &Os2SbApiPort,
                           &ObjectAttributes,
                           sizeof( SBCONNECTINFO ),
                           sizeof( SBAPIMSG ),
                           sizeof( SBAPIMSG ) * 16
                         );

    ASSERT( NT_SUCCESS( Status ) );

    Status = RtlCreateUserThread( NtCurrentProcess(),
                                  NULL,
                                  TRUE,
                                  0,
                                  0,
                                  0,
                                  Os2SbApiRequestThread,
                                  NULL,
                                  &Os2ServerThreadHandles[ OS2_SS_SBAPI_REQUEST_THREAD ],
                                  &Os2ServerThreadClientIds[ OS2_SS_SBAPI_REQUEST_THREAD ]
                                );
    ASSERT( NT_SUCCESS( Status ) );

    Status = NtResumeThread( Os2ServerThreadHandles[ OS2_SS_SBAPI_REQUEST_THREAD ], NULL );
    ASSERT( NT_SUCCESS( Status ) );

    return( Status );
}


VOID
Os2SbApiPortTerminate(
    NTSTATUS Status
    )
{
#if DBG
    IF_OS2_DEBUG( LPC ) {
        KdPrint(( "OS2SRV: Closing %wZ port and associated thread\n",
                  &Os2SbApiPortName_U
                ));
        }
#endif
    NtTerminateThread( Os2ServerThreadHandles[ OS2_SS_SBAPI_REQUEST_THREAD ],
                       Status
                     );

    NtClose( Os2SbApiPort );
    NtClose( Os2SmApiPort );
}