Import upstream u-boot 1.1.4
[u-boot.git] / board / MAI / bios_emulator / scitech / src / common / gabeos.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:  Linux
30 *
31 * Description:  OS specific Nucleus Graphics Architecture services for
32 *               the Linux operating system.
33 *
34 ****************************************************************************/
35
36 #include "nucleus/graphics.h"
37 #include <sys/time.h>
38
39 static ibool            haveRDTSC;
40
41 /*-------------------------- Implementation -------------------------------*/
42
43 /****************************************************************************
44 PARAMETERS:
45 path    - Local path to the Nucleus driver files.
46
47 REMARKS:
48 This function is used by the application program to override the location
49 of the Nucleus driver files that are loaded. Normally the loader code
50 will look in the system Nucleus directories first, then in the 'drivers'
51 directory relative to the current working directory, and finally relative
52 to the MGL_ROOT environment variable.
53 ****************************************************************************/
54 void NAPI GA_setLocalPath(
55     const char *path)
56 {
57     PM_setLocalBPDPath(path);
58 }
59
60 /****************************************************************************
61 RETURNS:
62 Pointer to the system wide PM library imports, or the internal version if none
63
64 REMARKS:
65 In order to support deploying new Nucleus drivers that may require updated
66 PM library functions, we check here to see if there is a system wide version
67 of the PM functions available. If so we return those functions for use with
68 the system wide Nucleus drivers, otherwise the compiled in version of the PM
69 library is used with the application local version of Nucleus.
70 ****************************************************************************/
71 PM_imports * NAPI GA_getSystemPMImports(void)
72 {
73     /* TODO: We may very well want to provide a system shared library */
74     /*       that eports the PM functions required by the Nucleus library */
75     /*       for BeOS here. That will eliminate fatal errors loading new */
76     /*       drivers on BeOS! */
77     return &_PM_imports;
78 }
79
80 /****************************************************************************
81 REMARKS:
82 Nothing special for this OS.
83 ****************************************************************************/
84 ibool NAPI GA_getSharedExports(
85     GA_exports *gaExp,
86     ibool shared)
87 {
88     (void)gaExp;
89     (void)shared;
90     return false;
91 }
92
93 #ifndef TEST_HARNESS
94 /****************************************************************************
95 REMARKS:
96 Nothing special for this OS
97 ****************************************************************************/
98 ibool NAPI GA_queryFunctions(
99     GA_devCtx *dc,
100     N_uint32 id,
101     void _FAR_ *funcs)
102 {
103     return __GA_exports.GA_queryFunctions(dc,id,funcs);
104 }
105
106 /****************************************************************************
107 REMARKS:
108 Nothing special for this OS
109 ****************************************************************************/
110 ibool NAPI REF2D_queryFunctions(
111     REF2D_driver *ref2d,
112     N_uint32 id,
113     void _FAR_ *funcs)
114 {
115     return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs);
116 }
117 #endif
118
119 /****************************************************************************
120 REMARKS:
121 This function initialises the high precision timing functions for the
122 Nucleus loader library.
123 ****************************************************************************/
124 ibool NAPI GA_TimerInit(void)
125 {
126     if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0)
127         haveRDTSC = true;
128     return true;
129 }
130
131 /****************************************************************************
132 REMARKS:
133 This function reads the high resolution timer.
134 ****************************************************************************/
135 void NAPI GA_TimerRead(
136     GA_largeInteger *value)
137 {
138     if (haveRDTSC)
139         _GA_readTimeStamp(value);
140     else {
141         struct timeval t;
142         gettimeofday(&t, NULL);
143         value->low = t.tv_sec*1000000 + t.tv_usec;
144         value->high = 0;
145         }
146 }