aaos2.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #include "pm_help.h"
  36. #define INCL_DOSERRORS
  37. #define INCL_DOS
  38. #define INCL_SUB
  39. #define INCL_VIO
  40. #define INCL_KBD
  41. #include <os2.h>
  42. /*---------------------------- Global Variables ---------------------------*/
  43. static HFILE hSDDHelp;
  44. static ulong outLen; /* Must not cross 64Kb boundary! */
  45. static ulong result; /* Must not cross 64Kb boundary! */
  46. static ibool haveRDTSC;
  47. /*-------------------------- Implementation -------------------------------*/
  48. /****************************************************************************
  49. REMARKS:
  50. This function returns a pointer to the common graphics driver loaded in the
  51. helper VxD. The memory for the VxD is shared between all processes via
  52. the VxD, so that the VxD, 16-bit code and 32-bit code all see the same
  53. state when accessing the graphics binary portable driver.
  54. ****************************************************************************/
  55. GA_sharedInfo * NAPI GA_getSharedInfo(
  56. int device)
  57. {
  58. /* Initialise the PM library and connect to our runtime DLL's */
  59. PM_init();
  60. /* Open our helper device driver */
  61. if (DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0,
  62. FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
  63. NULL))
  64. PM_fatalError("Unable to open SDDHELP$ helper device driver!");
  65. outLen = sizeof(result);
  66. DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,PMHELP_GETSHAREDINFO,
  67. NULL, 0, NULL,
  68. &result, outLen, &outLen);
  69. DosClose(hSDDHelp);
  70. if (result) {
  71. /* We have found the shared Nucleus packet. Because not all processes
  72. * map to SDDPMI.DLL, we need to ensure that we connect to this
  73. * DLL so that it gets mapped into our address space (that is
  74. * where the shared Nucleus packet is located). Simply doing a
  75. * DosLoadModule on it is enough for this.
  76. */
  77. HMODULE hModSDDPMI;
  78. char buf[80];
  79. DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"SDDPMI.DLL",&hModSDDPMI);
  80. }
  81. return (GA_sharedInfo*)result;
  82. }
  83. /****************************************************************************
  84. REMARKS:
  85. Nothing special for this OS.
  86. ****************************************************************************/
  87. ibool NAPI GA_getSharedExports(
  88. GA_exports *gaExp)
  89. {
  90. (void)gaExp;
  91. return false;
  92. }
  93. /****************************************************************************
  94. REMARKS:
  95. This function initialises the high precision timing functions for the
  96. Nucleus loader library.
  97. ****************************************************************************/
  98. ibool NAPI GA_TimerInit(void)
  99. {
  100. if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0)
  101. haveRDTSC = true;
  102. return true;
  103. }
  104. /****************************************************************************
  105. REMARKS:
  106. This function reads the high resolution timer.
  107. ****************************************************************************/
  108. void NAPI GA_TimerRead(
  109. GA_largeInteger *value)
  110. {
  111. if (haveRDTSC)
  112. _GA_readTimeStamp(value);
  113. else
  114. DosTmrQueryTime((QWORD*)value);
  115. }