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