]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/MAI/bios_emulator/scitech/src/common/aaos2.c
* Patch by Thomas Frieden, 13 Nov 2002:
[karo-tx-uboot.git] / board / MAI / bios_emulator / scitech / src / common / aaos2.c
1 /****************************************************************************
2 *
3 *                   SciTech Nucleus Graphics Architecture
4 *
5 *               Copyright (C) 1991-1998 SciTech Software, Inc.
6 *                            All rights reserved.
7 *
8 *  ======================================================================
9 *  |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
10 *  |                                                                    |
11 *  |This copyrighted computer code contains proprietary technology      |
12 *  |owned by SciTech Software, Inc., located at 505 Wall Street,        |
13 *  |Chico, CA 95928 USA (http://www.scitechsoft.com).                   |
14 *  |                                                                    |
15 *  |The contents of this file are subject to the SciTech Nucleus        |
16 *  |License; you may *not* use this file or related software except in  |
17 *  |compliance with the License. You may obtain a copy of the License   |
18 *  |at http://www.scitechsoft.com/nucleus-license.txt                   |
19 *  |                                                                    |
20 *  |Software distributed under the License is distributed on an         |
21 *  |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or      |
22 *  |implied. See the License for the specific language governing        |
23 *  |rights and limitations under the License.                           |
24 *  |                                                                    |
25 *  |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
26 *  ======================================================================
27 *
28 * Language:     ANSI C
29 * Environment:  OS/2 32-bit
30 *
31 * Description:  OS specific Nucleus Graphics Architecture services for
32 *               the OS/2 operating system environments.
33 *
34 ****************************************************************************/
35
36 #include "pm_help.h"
37 #define INCL_DOSERRORS
38 #define INCL_DOS
39 #define INCL_SUB
40 #define INCL_VIO
41 #define INCL_KBD
42 #include <os2.h>
43
44 /*---------------------------- Global Variables ---------------------------*/
45
46 static HFILE        hSDDHelp;
47 static ulong        outLen;         /* Must not cross 64Kb boundary!    */
48 static ulong        result;         /* Must not cross 64Kb boundary!    */
49 static ibool        haveRDTSC;
50
51 /*-------------------------- Implementation -------------------------------*/
52
53 /****************************************************************************
54 REMARKS:
55 This function returns a pointer to the common graphics driver loaded in the
56 helper VxD. The memory for the VxD is shared between all processes via
57 the VxD, so that the VxD, 16-bit code and 32-bit code all see the same
58 state when accessing the graphics binary portable driver.
59 ****************************************************************************/
60 GA_sharedInfo * NAPI GA_getSharedInfo(
61     int device)
62 {
63     /* Initialise the PM library and connect to our runtime DLL's */
64     PM_init();
65
66     /* Open our helper device driver */
67     if (DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0,
68             FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
69             NULL))
70         PM_fatalError("Unable to open SDDHELP$ helper device driver!");
71     outLen = sizeof(result);
72     DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,PMHELP_GETSHAREDINFO,
73         NULL, 0, NULL,
74         &result, outLen, &outLen);
75     DosClose(hSDDHelp);
76     if (result) {
77         /* We have found the shared Nucleus packet. Because not all processes
78          * map to SDDPMI.DLL, we need to ensure that we connect to this
79          * DLL so that it gets mapped into our address space (that is
80          * where the shared Nucleus packet is located). Simply doing a
81          * DosLoadModule on it is enough for this.
82          */
83         HMODULE hModSDDPMI;
84         char    buf[80];
85         DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"SDDPMI.DLL",&hModSDDPMI);
86         }
87     return (GA_sharedInfo*)result;
88 }
89
90 /****************************************************************************
91 REMARKS:
92 Nothing special for this OS.
93 ****************************************************************************/
94 ibool NAPI GA_getSharedExports(
95     GA_exports *gaExp)
96 {
97     (void)gaExp;
98     return false;
99 }
100
101 /****************************************************************************
102 REMARKS:
103 This function initialises the high precision timing functions for the
104 Nucleus loader library.
105 ****************************************************************************/
106 ibool NAPI GA_TimerInit(void)
107 {
108     if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0)
109         haveRDTSC = true;
110     return true;
111 }
112
113 /****************************************************************************
114 REMARKS:
115 This function reads the high resolution timer.
116 ****************************************************************************/
117 void NAPI GA_TimerRead(
118     GA_largeInteger *value)
119 {
120     if (haveRDTSC)
121         _GA_readTimeStamp(value);
122     else
123         DosTmrQueryTime((QWORD*)value);
124 }