Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
2.5 KiB

4 years ago
  1. #if defined(JENSEN)
  2. /*++
  3. Copyright (c) 1992 Digital Equipment Corporation
  4. Module Name:
  5. jxbeep.c
  6. Abstract:
  7. This module implements the HAL speaker "beep" routines for the
  8. Alpha/Jensen system.
  9. Author:
  10. Jeff McLeman (mcleman) 23-Jun-1992
  11. Environment:
  12. Kernel mode
  13. Revision History:
  14. --*/
  15. #include "halp.h"
  16. #include "eisa.h"
  17. BOOLEAN
  18. HalMakeBeep(
  19. IN ULONG Frequency
  20. )
  21. /*++
  22. Routine Description:
  23. This function sets the frequency of the speaker, causing it to sound a
  24. tone. The tone will sound until the speaker is explicitly turned off,
  25. so the driver is responsible for controlling the duration of the tone.
  26. Arguments:
  27. Frequency - Supplies the frequency of the desired tone. A frequency of
  28. 0 means the speaker should be shut off.
  29. Return Value:
  30. TRUE - Operation was successful (frequency within range or zero).
  31. FALSE - Operation was unsuccessful (frequency was out of range).
  32. Current tone (if any) is unchanged.
  33. --*/
  34. {
  35. KIRQL oldIrql;
  36. NMI_STATUS NmiStatus;
  37. PEISA_CONTROL controlBase;
  38. TIMER_CONTROL timerControl;
  39. ULONG newCount;
  40. controlBase = HalpEisaControlBase;
  41. KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
  42. //
  43. // Stop the speaker.
  44. //
  45. *((PUCHAR) &NmiStatus) = READ_PORT_UCHAR(&controlBase->NmiStatus);
  46. NmiStatus.SpeakerGate = 0;
  47. NmiStatus.SpeakerData = 0;
  48. WRITE_PORT_UCHAR(&controlBase->NmiStatus, *((PUCHAR) &NmiStatus));
  49. if (Frequency == 0) {
  50. KeLowerIrql(oldIrql);
  51. return(TRUE);
  52. }
  53. //
  54. // Calculate the new counter value.
  55. //
  56. newCount = TIMER_CLOCK_IN / Frequency;
  57. //
  58. // The new count must be less than 16 bits in value.
  59. //
  60. if (newCount >= 0x10000) {
  61. KeLowerIrql(oldIrql);
  62. return(FALSE);
  63. }
  64. //
  65. // Set the speaker timer to the correct mode.
  66. //
  67. timerControl.BcdMode = 0;
  68. timerControl.Mode = TM_SQUARE_WAVE;
  69. timerControl.SelectByte = SB_LSB_THEN_MSB;
  70. timerControl.SelectCounter = SELECT_COUNTER_2;
  71. WRITE_PORT_UCHAR(&controlBase->CommandMode1, *((PUCHAR) &timerControl));
  72. //
  73. // Set the speaker timer to the correct mode.
  74. //
  75. WRITE_PORT_UCHAR(&controlBase->SpeakerTone, newCount);
  76. WRITE_PORT_UCHAR(&controlBase->SpeakerTone, (newCount >> 8));
  77. //
  78. // Start the speaker.
  79. //
  80. NmiStatus.SpeakerGate = 1;
  81. NmiStatus.SpeakerData = 1;
  82. WRITE_PORT_UCHAR(&controlBase->NmiStatus, *((PUCHAR) &NmiStatus));
  83. KeLowerIrql(oldIrql);
  84. return(TRUE);
  85. }
  86. #endif