VirtualBox

source: vbox/trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFInit.cpp@ 79112

Last change on this file since 79112 was 76693, checked in by vboxsync, 5 years ago

os2/VBoxSF: Added fallbacks for older hosts that doesn't support embedded buffers and contiguous page lists.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use