Source code of Windows XP (NT5)
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.

176 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. port.c
  5. Abstract:
  6. This modules implements com port code to support the boot debugger.
  7. Author:
  8. Bryan M. Willman (bryanwi) 24-Sep-90
  9. Revision History:
  10. --*/
  11. #include "bd.h"
  12. extern BdInstallVectors();
  13. _TUCHAR DebugMessage[80];
  14. LOGICAL
  15. BdPortInitialize(
  16. IN ULONG BaudRate,
  17. IN ULONG PortNumber,
  18. OUT PULONG BdFileId
  19. )
  20. /*++
  21. Routine Description:
  22. This functions initializes the boot debugger com port.
  23. Arguments:
  24. BaudRate - Supplies an optional baud rate.
  25. PortNumber - supplies an optinal port number.
  26. Returned Value:
  27. TRUE - If a debug port is found.
  28. --*/
  29. {
  30. //
  31. // Initialize the specified port.
  32. //
  33. if (!BlPortInitialize(BaudRate, PortNumber, NULL, FALSE, BdFileId)) {
  34. return FALSE;
  35. }
  36. _stprintf(DebugMessage,
  37. TEXT("\r\nBoot Debugger Using: COM%d (Baud Rate %d)\r\n"),
  38. PortNumber,
  39. BaudRate);
  40. //
  41. // Install exception vectors used by BD.
  42. //
  43. BdIa64Init();
  44. #if 0
  45. //
  46. // We cannot use BlPrint() at this time because BlInitStdIo() has not been called, which is
  47. // required to use the Arc emulator code.
  48. //
  49. TextStringOut(DebugMessage);
  50. #else
  51. //
  52. // there's no reason not to use BlPrint since we're not using ARC calls to print
  53. //
  54. BlPrint( DebugMessage );
  55. #endif
  56. return TRUE;
  57. }
  58. ULONG
  59. BdPortGetByte (
  60. OUT PUCHAR Input
  61. )
  62. /*++
  63. Routine Description:
  64. This routine gets a byte from the serial port used by the kernel
  65. debugger.
  66. Arguments:
  67. Input - Supplies a pointer to a variable that receives the input
  68. data byte.
  69. Return Value:
  70. CP_GET_SUCCESS is returned if a byte is successfully read from the
  71. kernel debugger line.
  72. CP_GET_ERROR is returned if an error is encountered during reading.
  73. CP_GET_NODATA is returned if timeout occurs.
  74. --*/
  75. {
  76. return BlPortGetByte(BdFileId, Input);
  77. }
  78. VOID
  79. BdPortPutByte (
  80. IN UCHAR Output
  81. )
  82. /*++
  83. Routine Description:
  84. This routine puts a byte to the serial port used by the kernel debugger.
  85. Arguments:
  86. Output - Supplies the output data byte.
  87. Return Value:
  88. None.
  89. --*/
  90. {
  91. BlPortPutByte(BdFileId, Output);
  92. return;
  93. }
  94. ULONG
  95. BdPortPollByte (
  96. OUT PUCHAR Input
  97. )
  98. /*++
  99. Routine Description:
  100. This routine gets a byte from the serial port used by the kernel
  101. debugger iff a byte is available.
  102. Arguments:
  103. Input - Supplies a pointer to a variable that receives the input
  104. data byte.
  105. Return Value:
  106. CP_GET_SUCCESS is returned if a byte is successfully read from the
  107. kernel debugger line.
  108. CP_GET_ERROR is returned if an error encountered during reading.
  109. CP_GET_NODATA is returned if timeout occurs.
  110. --*/
  111. {
  112. return BlPortPollByte(BdFileId, Input);
  113. }