VirtualBox

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

Last change on this file since 4377 was 3655, checked in by vboxsync, 17 years ago

export

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1/** $Id: VBoxSFInit.cpp 3655 2007-07-16 18:47:26Z 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/VBoxGuest.h>
39#include <VBox/VBoxGuestLib.h>
40#include <VBox/log.h>
41#include <iprt/assert.h>
42#include <iprt/initterm.h>
43
44
45/*******************************************************************************
46* Global Variables *
47*******************************************************************************/
48__BEGIN_DECLS
49/* from VBoxSFA.asm */
50extern RTFAR16 g_fpfnDevHlp;
51extern VBOXGUESTOS2IDCCONNECT g_VBoxGuestIDC;
52extern uint32_t g_u32Info;
53/* from sys0.asm and the linker/end.lib. */
54extern char _text, _etext, _data, _end;
55__END_DECLS
56
57
58
59/**
60 * 32-bit Ring-0 init routine.
61 *
62 * This is called the first time somebody tries to use the IFS.
63 * It will initialize IPRT, Vbgl and whatever else is required.
64 *
65 * The caller will do the necessary AttachDD and calling of the 16 bit
66 * IDC to initialize the g_VBoxGuestIDC global. Perhaps we should move
67 * this bit to VbglInit? It's just that it's so much simpler to do it
68 * while we're on the way here...
69 *
70 */
71DECLASM(void)
72VBoxSFR0Init(void)
73{
74 Log(("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
77 /*
78 * Start by initializing IPRT.
79 */
80 if ( g_VBoxGuestIDC.u32Version == VMMDEV_VERSION
81 && VALID_PTR(g_VBoxGuestIDC.u32Session)
82 && VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
83 {
84 int rc = RTR0Init(0);
85 if (RT_SUCCESS(rc))
86 {
87 rc = VbglInit();
88 if (RT_SUCCESS(rc))
89 {
90#ifndef DONT_LOCK_SEGMENTS
91 /*
92 * Lock the 32-bit segments in memory.
93 */
94 static KernVMLock_t s_Text32, s_Data32;
95 rc = KernVMLock(VMDHL_LONG,
96 &_text, (uintptr_t)&_etext - (uintptr_t)&_text,
97 &s_Text32, (KernPageList_t *)-1, NULL);
98 AssertMsg(rc == NO_ERROR, ("locking text32 failed, rc=%d\n"));
99 rc = KernVMLock(VMDHL_LONG | VMDHL_WRITE,
100 &_data, (uintptr_t)&_end - (uintptr_t)&_data,
101 &s_Data32, (KernPageList_t *)-1, NULL);
102 AssertMsg(rc == NO_ERROR, ("locking text32 failed, rc=%d\n"));
103#endif
104
105 Log(("VBoxSFR0Init: completed successfully\n"));
106 return;
107 }
108 }
109
110 LogRel(("VBoxSF: RTR0Init failed, rc=%Rrc\n", rc));
111 }
112 else
113 LogRel(("VBoxSF: Failed to connect to VBoxGuest.sys.\n"));
114}
115
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette