[21227] | 1 | /* $Id: VBoxSFInit.cpp 48942 2013-10-07 21:30:03Z vboxsync $ */
|
---|
[3655] | 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 | *******************************************************************************/
|
---|
[20374] | 47 | RT_C_DECLS_BEGIN
|
---|
[3655] | 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;
|
---|
[20374] | 54 | RT_C_DECLS_END
|
---|
[3655] | 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 VbglInit? 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)
|
---|
| 71 | VBoxSFR0Init(void)
|
---|
| 72 | {
|
---|
| 73 | Log(("VBoxSFR0Init: g_fpfnDevHlp=%lx u32Version=%RX32 u32Session=%RX32 pfnServiceEP=%p g_u32Info=%u (%#x)\n",
|
---|
| 74 | g_fpfnDevHlp, g_VBoxGuestIDC.u32Version, g_VBoxGuestIDC.u32Session, g_VBoxGuestIDC.pfnServiceEP, g_u32Info, g_u32Info));
|
---|
| 75 |
|
---|
| 76 | /*
|
---|
| 77 | * Start by initializing IPRT.
|
---|
| 78 | */
|
---|
| 79 | if ( g_VBoxGuestIDC.u32Version == VMMDEV_VERSION
|
---|
| 80 | && VALID_PTR(g_VBoxGuestIDC.u32Session)
|
---|
| 81 | && VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
|
---|
| 82 | {
|
---|
| 83 | int rc = RTR0Init(0);
|
---|
| 84 | if (RT_SUCCESS(rc))
|
---|
| 85 | {
|
---|
| 86 | rc = VbglInit();
|
---|
| 87 | if (RT_SUCCESS(rc))
|
---|
| 88 | {
|
---|
| 89 | #ifndef DONT_LOCK_SEGMENTS
|
---|
| 90 | /*
|
---|
| 91 | * Lock the 32-bit segments in memory.
|
---|
| 92 | */
|
---|
| 93 | static KernVMLock_t s_Text32, s_Data32;
|
---|
| 94 | rc = KernVMLock(VMDHL_LONG,
|
---|
| 95 | &_text, (uintptr_t)&_etext - (uintptr_t)&_text,
|
---|
| 96 | &s_Text32, (KernPageList_t *)-1, NULL);
|
---|
| 97 | AssertMsg(rc == NO_ERROR, ("locking text32 failed, rc=%d\n"));
|
---|
| 98 | rc = KernVMLock(VMDHL_LONG | VMDHL_WRITE,
|
---|
| 99 | &_data, (uintptr_t)&_end - (uintptr_t)&_data,
|
---|
| 100 | &s_Data32, (KernPageList_t *)-1, NULL);
|
---|
| 101 | AssertMsg(rc == NO_ERROR, ("locking text32 failed, rc=%d\n"));
|
---|
| 102 | #endif
|
---|
| 103 |
|
---|
| 104 | Log(("VBoxSFR0Init: completed successfully\n"));
|
---|
| 105 | return;
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | LogRel(("VBoxSF: RTR0Init failed, rc=%Rrc\n", rc));
|
---|
| 110 | }
|
---|
| 111 | else
|
---|
| 112 | LogRel(("VBoxSF: Failed to connect to VBoxGuest.sys.\n"));
|
---|
| 113 | }
|
---|
| 114 |
|
---|