1 | /* $Id: initterm-r0drv-os2.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Initialization & Termination, Ring-0 Driver, OS/2.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Contributed by knut st. osmundsen.
|
---|
8 | *
|
---|
9 | * Copyright (C) 2007-2022 Oracle and/or its affiliates.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox base platform packages, as
|
---|
12 | * available from https://www.virtualbox.org.
|
---|
13 | *
|
---|
14 | * This program is free software; you can redistribute it and/or
|
---|
15 | * modify it under the terms of the GNU General Public License
|
---|
16 | * as published by the Free Software Foundation, in version 3 of the
|
---|
17 | * License.
|
---|
18 | *
|
---|
19 | * This program is distributed in the hope that it will be useful, but
|
---|
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | * General Public License for more details.
|
---|
23 | *
|
---|
24 | * You should have received a copy of the GNU General Public License
|
---|
25 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
26 | *
|
---|
27 | * The contents of this file may alternatively be used under the terms
|
---|
28 | * of the Common Development and Distribution License Version 1.0
|
---|
29 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
30 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
31 | * CDDL are applicable instead of those of the GPL.
|
---|
32 | *
|
---|
33 | * You may elect to license modified versions of this file under the
|
---|
34 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
35 | *
|
---|
36 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
37 | * --------------------------------------------------------------------
|
---|
38 | *
|
---|
39 | * This code is based on:
|
---|
40 | *
|
---|
41 | * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
---|
42 | *
|
---|
43 | * Permission is hereby granted, free of charge, to any person
|
---|
44 | * obtaining a copy of this software and associated documentation
|
---|
45 | * files (the "Software"), to deal in the Software without
|
---|
46 | * restriction, including without limitation the rights to use,
|
---|
47 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
48 | * copies of the Software, and to permit persons to whom the
|
---|
49 | * Software is furnished to do so, subject to the following
|
---|
50 | * conditions:
|
---|
51 | *
|
---|
52 | * The above copyright notice and this permission notice shall be
|
---|
53 | * included in all copies or substantial portions of the Software.
|
---|
54 | *
|
---|
55 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
56 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
57 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
58 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
59 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
60 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
61 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
62 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
63 | */
|
---|
64 |
|
---|
65 |
|
---|
66 | /*********************************************************************************************************************************
|
---|
67 | * Header Files *
|
---|
68 | *********************************************************************************************************************************/
|
---|
69 | #include "the-os2-kernel.h"
|
---|
70 |
|
---|
71 | #include "internal/initterm.h"
|
---|
72 | #include <iprt/errcore.h>
|
---|
73 | #include <iprt/assert.h>
|
---|
74 |
|
---|
75 |
|
---|
76 | /*********************************************************************************************************************************
|
---|
77 | * Global Variables *
|
---|
78 | *********************************************************************************************************************************/
|
---|
79 | /** Pointer to the 1st DOS variable table. */
|
---|
80 | PCDOSTABLE g_pDosTable = NULL;
|
---|
81 | /** Pointer to the 2nd DOS variable table. */
|
---|
82 | PCDOSTABLE2 g_pDosTable2 = NULL;
|
---|
83 | /** Pointer to the global info segment. */
|
---|
84 | PGINFOSEG g_pGIS = NULL;
|
---|
85 | /** Far 16:16 pointer to the local info segment.
|
---|
86 | * IIRC this must be converted to a flat pointer when accessed to work correctly on SMP systems. */
|
---|
87 | RTFAR16 g_fpLIS = {0, 0};
|
---|
88 |
|
---|
89 |
|
---|
90 | DECLHIDDEN(int) rtR0InitNative(void)
|
---|
91 | {
|
---|
92 | /*
|
---|
93 | * Get the DOS Tables.
|
---|
94 | */
|
---|
95 | RTFAR16 fp;
|
---|
96 | int rc = RTR0Os2DHQueryDOSVar(DHGETDOSV_DOSTABLES, 0, &fp);
|
---|
97 | AssertMsgReturn(!rc, ("rc=%d\n", rc), VERR_INTERNAL_ERROR);
|
---|
98 | g_pDosTable = (PCDOSTABLE)RTR0Os2Virt2Flat(fp);
|
---|
99 | AssertReturn(g_pDosTable, VERR_INTERNAL_ERROR);
|
---|
100 | g_pDosTable2 = (PCDOSTABLE2)((const uint8_t *)g_pDosTable + g_pDosTable->cul * sizeof(ULONG) + 1);
|
---|
101 |
|
---|
102 | /*
|
---|
103 | * Get the addresses of the two info segments.
|
---|
104 | */
|
---|
105 | rc = RTR0Os2DHQueryDOSVar(DHGETDOSV_SYSINFOSEG, 0, &fp);
|
---|
106 | AssertMsgReturn(!rc, ("rc=%d\n", rc), VERR_INTERNAL_ERROR);
|
---|
107 | g_pGIS = (PGINFOSEG)RTR0Os2Virt2Flat(fp);
|
---|
108 | rc = RTR0Os2DHQueryDOSVar(DHGETDOSV_LOCINFOSEG, 0, &fp);
|
---|
109 | AssertMsgReturn(!rc, ("rc=%d\n", rc), VERR_INTERNAL_ERROR);
|
---|
110 | g_fpLIS = fp;
|
---|
111 |
|
---|
112 | return VINF_SUCCESS;
|
---|
113 | }
|
---|
114 |
|
---|
115 |
|
---|
116 | DECLHIDDEN(void) rtR0TermNative(void)
|
---|
117 | {
|
---|
118 | /* nothing to do here yet. */
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Converts a 16:16 pointer to a flat pointer.
|
---|
124 | *
|
---|
125 | * @returns Flat pointer (NULL if fp is NULL).
|
---|
126 | * @param fp Far pointer to convert.
|
---|
127 | */
|
---|
128 | RTR0DECL(void *) RTR0Os2Virt2Flat(RTFAR16 fp)
|
---|
129 | {
|
---|
130 | return (void *)KernSelToFlat(((uint32_t)fp.sel << 16) | fp.off);
|
---|
131 | }
|
---|
132 |
|
---|