1 | /* $Id: VBoxSFInit.cpp 58178 2015-10-12 11:40:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxSF - OS/2 Shared Folders, Initialization.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person
|
---|
10 | * obtaining a copy of this software and associated documentation
|
---|
11 | * files (the "Software"), to deal in the Software without
|
---|
12 | * restriction, including without limitation the rights to use,
|
---|
13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
14 | * copies of the Software, and to permit persons to whom the
|
---|
15 | * Software is furnished to do so, subject to the following
|
---|
16 | * conditions:
|
---|
17 | *
|
---|
18 | * The above copyright notice and this permission notice shall be
|
---|
19 | * included in all copies or substantial portions of the Software.
|
---|
20 | *
|
---|
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
28 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
29 | */
|
---|
30 |
|
---|
31 |
|
---|
32 | /*********************************************************************************************************************************
|
---|
33 | * Header Files *
|
---|
34 | *********************************************************************************************************************************/
|
---|
35 | #define LOG_GROUP LOG_GROUP_DEFAULT
|
---|
36 | #include "VBoxSFInternal.h"
|
---|
37 |
|
---|
38 | #include <VBox/VBoxGuestLib.h>
|
---|
39 | #include <VBox/log.h>
|
---|
40 | #include <iprt/assert.h>
|
---|
41 | #include <iprt/initterm.h>
|
---|
42 |
|
---|
43 |
|
---|
44 | /*********************************************************************************************************************************
|
---|
45 | * Global Variables *
|
---|
46 | *********************************************************************************************************************************/
|
---|
47 | RT_C_DECLS_BEGIN
|
---|
48 | /* from VBoxSFA.asm */
|
---|
49 | extern RTFAR16 g_fpfnDevHlp;
|
---|
50 | extern VBOXGUESTOS2IDCCONNECT g_VBoxGuestIDC;
|
---|
51 | extern uint32_t g_u32Info;
|
---|
52 | /* from sys0.asm and the linker/end.lib. */
|
---|
53 | extern char _text, _etext, _data, _end;
|
---|
54 | RT_C_DECLS_END
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * 32-bit Ring-0 init routine.
|
---|
60 | *
|
---|
61 | * This is called the first time somebody tries to use the IFS.
|
---|
62 | * It will initialize IPRT, Vbgl and whatever else is required.
|
---|
63 | *
|
---|
64 | * The caller will do the necessary AttachDD and calling of the 16 bit
|
---|
65 | * IDC to initialize the g_VBoxGuestIDC global. Perhaps we should move
|
---|
66 | * this bit to VbglInitClient? It's just that it's so much simpler to do it
|
---|
67 | * while we're on the way here...
|
---|
68 | *
|
---|
69 | */
|
---|
70 | DECLASM(void) VBoxSFR0Init(void)
|
---|
71 | {
|
---|
72 | Log(("VBoxSFR0Init: g_fpfnDevHlp=%lx u32Version=%RX32 u32Session=%RX32 pfnServiceEP=%p g_u32Info=%u (%#x)\n",
|
---|
73 | g_fpfnDevHlp, g_VBoxGuestIDC.u32Version, g_VBoxGuestIDC.u32Session, g_VBoxGuestIDC.pfnServiceEP, g_u32Info, g_u32Info));
|
---|
74 |
|
---|
75 | /*
|
---|
76 | * Start by initializing IPRT.
|
---|
77 | */
|
---|
78 | if ( g_VBoxGuestIDC.u32Version == VMMDEV_VERSION
|
---|
79 | && VALID_PTR(g_VBoxGuestIDC.u32Session)
|
---|
80 | && VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
|
---|
81 | {
|
---|
82 | int rc = RTR0Init(0);
|
---|
83 | if (RT_SUCCESS(rc))
|
---|
84 | {
|
---|
85 | rc = VbglInitClient();
|
---|
86 | if (RT_SUCCESS(rc))
|
---|
87 | {
|
---|
88 | #ifndef DONT_LOCK_SEGMENTS
|
---|
89 | /*
|
---|
90 | * Lock the 32-bit segments in memory.
|
---|
91 | */
|
---|
92 | static KernVMLock_t s_Text32, s_Data32;
|
---|
93 | rc = KernVMLock(VMDHL_LONG,
|
---|
94 | &_text, (uintptr_t)&_etext - (uintptr_t)&_text,
|
---|
95 | &s_Text32, (KernPageList_t *)-1, NULL);
|
---|
96 | AssertMsg(rc == NO_ERROR, ("locking text32 failed, rc=%d\n"));
|
---|
97 | rc = KernVMLock(VMDHL_LONG | VMDHL_WRITE,
|
---|
98 | &_data, (uintptr_t)&_end - (uintptr_t)&_data,
|
---|
99 | &s_Data32, (KernPageList_t *)-1, NULL);
|
---|
100 | AssertMsg(rc == NO_ERROR, ("locking text32 failed, rc=%d\n"));
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | Log(("VBoxSFR0Init: completed successfully\n"));
|
---|
104 | return;
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | LogRel(("VBoxSF: RTR0Init failed, rc=%Rrc\n", rc));
|
---|
109 | }
|
---|
110 | else
|
---|
111 | LogRel(("VBoxSF: Failed to connect to VBoxGuest.sys.\n"));
|
---|
112 | }
|
---|
113 |
|
---|