1 | /* $Id: VBoxSFInit.cpp 79113 2019-06-13 03:56:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxSF - OS/2 Shared Folders, Initialization.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2007-2018 knut st. osmundsen <[email protected]>
|
---|
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/VBoxGuest.h>
|
---|
40 | #include <VBox/log.h>
|
---|
41 | #include <VBox/version.h>
|
---|
42 | #include <iprt/assert.h>
|
---|
43 | #include <iprt/errcore.h>
|
---|
44 | #include <iprt/initterm.h>
|
---|
45 |
|
---|
46 |
|
---|
47 | /*********************************************************************************************************************************
|
---|
48 | * Global Variables *
|
---|
49 | *********************************************************************************************************************************/
|
---|
50 | RT_C_DECLS_BEGIN
|
---|
51 | /* from VBoxSFA.asm */
|
---|
52 | extern RTFAR16 g_fpfnDevHlp;
|
---|
53 | extern VBGLOS2ATTACHDD g_VBoxGuestIDC;
|
---|
54 | extern uint32_t g_u32Info;
|
---|
55 | /* from sys0.asm and the linker/end.lib. */
|
---|
56 | extern char _text, _etext, _data, _end;
|
---|
57 | RT_C_DECLS_END
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * 32-bit Ring-0 init routine.
|
---|
63 | *
|
---|
64 | * This is called the first time somebody tries to use the IFS.
|
---|
65 | * It will initialize IPRT, Vbgl and whatever else is required.
|
---|
66 | *
|
---|
67 | * The caller will do the necessary AttachDD and calling of the 16 bit
|
---|
68 | * IDC to initialize the g_VBoxGuestIDC global. Perhaps we should move
|
---|
69 | * this bit to VbglR0InitClient? It's just that it's so much simpler to do it
|
---|
70 | * while we're on the way here...
|
---|
71 | *
|
---|
72 | */
|
---|
73 | DECLASM(void) VBoxSFR0Init(void)
|
---|
74 | {
|
---|
75 | RTLogBackdoorPrintf("VBoxSFR0Init: version " VBOX_VERSION_STRING " r" RT_XSTR(VBOX_SVN_REV));
|
---|
76 | RTLogBackdoorPrintf("VBoxSFR0Init: g_fpfnDevHlp=%lx u32Version=%RX32 u32Session=%RX32 pfnServiceEP=%p g_u32Info=%u (%#x)\n",
|
---|
77 | g_fpfnDevHlp, g_VBoxGuestIDC.u32Version, g_VBoxGuestIDC.u32Session, g_VBoxGuestIDC.pfnServiceEP, g_u32Info, g_u32Info);
|
---|
78 | //RTLogBackdoorPrintf("&KernSISData=%p\n", &KernSISData);
|
---|
79 | //RTLogBackdoorPrintf("&KernLISData=%p\n", &KernLISData);
|
---|
80 | //RTLogBackdoorPrintf("KernInterruptLevel=%#x\n", KernInterruptLevel);
|
---|
81 | //RTLogBackdoorPrintf("KernTKSSBase=%p\n", KernTKSSBase);
|
---|
82 |
|
---|
83 | KernAllocMutexLock(&g_MtxFolders);
|
---|
84 | RTListInit(&g_FolderHead);
|
---|
85 |
|
---|
86 | /*
|
---|
87 | * Start by initializing IPRT.
|
---|
88 | */
|
---|
89 | if ( g_VBoxGuestIDC.u32Version == VBGL_IOC_VERSION
|
---|
90 | && VALID_PTR(g_VBoxGuestIDC.u32Session)
|
---|
91 | && VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
|
---|
92 | {
|
---|
93 | int rc = RTR0Init(0);
|
---|
94 | if (RT_SUCCESS(rc))
|
---|
95 | {
|
---|
96 | rc = VbglR0InitClient();
|
---|
97 | if (RT_SUCCESS(rc))
|
---|
98 | {
|
---|
99 | /*
|
---|
100 | * Complain if the embedded buffers feature is missing.
|
---|
101 | */
|
---|
102 | uint32_t fFeatures = 0;
|
---|
103 | rc = VbglR0QueryHostFeatures(&fFeatures);
|
---|
104 | if (RT_FAILURE(rc))
|
---|
105 | RTLogBackdoorPrintf("VBoxSFR0Init: Missing VBoxGuest.sys IDC connection! Check order in Config.kmk!\n");
|
---|
106 | else
|
---|
107 | {
|
---|
108 | g_fHostFeatures = fFeatures;
|
---|
109 | if (!(fFeatures & VMMDEV_HVF_HGCM_EMBEDDED_BUFFERS))
|
---|
110 | RTLogBackdoorPrintf("VBoxSFR0Init: WARNING! Embedded buffers feature is missing. Upgrade to latest VirtualBox!\n");
|
---|
111 | if (!(fFeatures & VMMDEV_HVF_HGCM_CONTIGUOUS_PAGE_LIST))
|
---|
112 | RTLogBackdoorPrintf("VBoxSFR0Init: WARNING! Contiguous page list buffers feature is missing. Upgrade to latest VirtualBox!\n");
|
---|
113 | }
|
---|
114 |
|
---|
115 | /*
|
---|
116 | * Allocate some big buffers for reading and writing.
|
---|
117 | */
|
---|
118 | vboxSfOs2InitFileBuffers();
|
---|
119 |
|
---|
120 | #ifndef DONT_LOCK_SEGMENTS
|
---|
121 | /*
|
---|
122 | * Lock the 32-bit segments in memory.
|
---|
123 | */
|
---|
124 | static KernVMLock_t s_Text32, s_Data32;
|
---|
125 | rc = KernVMLock(VMDHL_LONG,
|
---|
126 | &_text, (uintptr_t)&_etext - (uintptr_t)&_text,
|
---|
127 | &s_Text32, (KernPageList_t *)-1, NULL);
|
---|
128 | AssertMsg(rc == NO_ERROR, ("locking text32 failed, rc=%d\n"));
|
---|
129 | rc = KernVMLock(VMDHL_LONG | VMDHL_WRITE,
|
---|
130 | &_data, (uintptr_t)&_end - (uintptr_t)&_data,
|
---|
131 | &s_Data32, (KernPageList_t *)-1, NULL);
|
---|
132 | AssertMsg(rc == NO_ERROR, ("locking text32 failed, rc=%d\n"));
|
---|
133 | #endif
|
---|
134 |
|
---|
135 | RTLogBackdoorPrintf("VBoxSFR0Init: completed successfully\n");
|
---|
136 | return;
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | RTLogBackdoorPrintf("VBoxSF: RTR0Init failed, rc=%Rrc\n", rc);
|
---|
141 | }
|
---|
142 | else
|
---|
143 | RTLogBackdoorPrintf("VBoxSF: Failed to connect to VBoxGuest.sys.\n");
|
---|
144 | }
|
---|
145 |
|
---|