1 | /* $Id: initterm-r0drv-os2.cpp 48935 2013-10-07 21:19:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Initialization & Termination, Ring-0 Driver, OS/2.
|
---|
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 | #define RT_STRICT
|
---|
32 |
|
---|
33 | /*******************************************************************************
|
---|
34 | * Header Files *
|
---|
35 | *******************************************************************************/
|
---|
36 | #include "the-os2-kernel.h"
|
---|
37 |
|
---|
38 | #include "internal/initterm.h"
|
---|
39 | #include <iprt/err.h>
|
---|
40 | #include <iprt/assert.h>
|
---|
41 |
|
---|
42 |
|
---|
43 | /*******************************************************************************
|
---|
44 | * Global Variables *
|
---|
45 | *******************************************************************************/
|
---|
46 | /** Pointer to the 1st DOS variable table. */
|
---|
47 | PCDOSTABLE g_pDosTable = NULL;
|
---|
48 | /** Pointer to the 2nd DOS variable table. */
|
---|
49 | PCDOSTABLE2 g_pDosTable2 = NULL;
|
---|
50 | /** Pointer to the global info segment. */
|
---|
51 | PGINFOSEG g_pGIS = NULL;
|
---|
52 | /** Far 16:16 pointer to the local info segment.
|
---|
53 | * IIRC this must be converted to a flat pointer when accessed to work correctly on SMP systems. */
|
---|
54 | RTFAR16 g_fpLIS = {0, 0};
|
---|
55 |
|
---|
56 |
|
---|
57 | DECLHIDDEN(int) rtR0InitNative(void)
|
---|
58 | {
|
---|
59 | /*
|
---|
60 | * Get the DOS Tables.
|
---|
61 | */
|
---|
62 | RTFAR16 fp;
|
---|
63 | int rc = RTR0Os2DHQueryDOSVar(DHGETDOSV_DOSTABLES, 0, &fp);
|
---|
64 | AssertMsgReturn(!rc, ("rc=%d\n", rc), VERR_INTERNAL_ERROR);
|
---|
65 | g_pDosTable = (PCDOSTABLE)RTR0Os2Virt2Flat(fp);
|
---|
66 | AssertReturn(g_pDosTable, VERR_INTERNAL_ERROR);
|
---|
67 | g_pDosTable2 = (PCDOSTABLE2)((const uint8_t *)g_pDosTable + g_pDosTable->cul * sizeof(ULONG) + 1);
|
---|
68 |
|
---|
69 | /*
|
---|
70 | * Get the addresses of the two info segments.
|
---|
71 | */
|
---|
72 | rc = RTR0Os2DHQueryDOSVar(DHGETDOSV_SYSINFOSEG, 0, &fp);
|
---|
73 | AssertMsgReturn(!rc, ("rc=%d\n", rc), VERR_INTERNAL_ERROR);
|
---|
74 | g_pGIS = (PGINFOSEG)RTR0Os2Virt2Flat(fp);
|
---|
75 | rc = RTR0Os2DHQueryDOSVar(DHGETDOSV_LOCINFOSEG, 0, &fp);
|
---|
76 | AssertMsgReturn(!rc, ("rc=%d\n", rc), VERR_INTERNAL_ERROR);
|
---|
77 | g_fpLIS = fp;
|
---|
78 |
|
---|
79 | return VINF_SUCCESS;
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | DECLHIDDEN(void) rtR0TermNative(void)
|
---|
84 | {
|
---|
85 | /* nothing to do here yet. */
|
---|
86 | }
|
---|
87 |
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Converts a 16:16 pointer to a flat pointer.
|
---|
91 | *
|
---|
92 | * @returns Flat pointer (NULL if fp is NULL).
|
---|
93 | * @param fp Far pointer to convert.
|
---|
94 | */
|
---|
95 | RTR0DECL(void *) RTR0Os2Virt2Flat(RTFAR16 fp)
|
---|
96 | {
|
---|
97 | return (void *)KernSelToFlat((fp.sel << 16) | fp.off);
|
---|
98 | }
|
---|
99 |
|
---|