galinux.c 5.5 KB

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