Leaked source code of windows server 2003
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.

171 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. kdapi.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Wesley Witt (wesw) 15-Aug-1993
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. VOID
  16. InternalReadIoSpace(
  17. ULONG InputSize,
  18. LPSTR args
  19. )
  20. /*++
  21. Routine Description:
  22. Input a byte froma port.
  23. Arguments:
  24. None.
  25. Return Value:
  26. None.
  27. --*/
  28. {
  29. ULONG64 IoAddress;
  30. ULONG InputValue;
  31. UCHAR Format[] = "%08p: %01lx\n";
  32. ULONG OriginalInputSize = InputSize;
  33. InputValue = 0;
  34. if (TargetIsDump) {
  35. dprintf("This is not supported on dump targets\n");
  36. return;
  37. }
  38. Format[9] = (UCHAR)('0' + (InputSize * 2));
  39. IoAddress = GetExpression( args );
  40. if (IoAddress == 0) {
  41. dprintf( "Could not evaluate address expresion (%s)\n", args );
  42. return;
  43. }
  44. ReadIoSpace64( IoAddress, &InputValue, &InputSize );
  45. if (InputSize) {
  46. dprintf(Format, IoAddress, InputValue);
  47. }
  48. else {
  49. dprintf(" %08p: \n", IoAddress);
  50. while (OriginalInputSize--) {
  51. dprintf("??");
  52. }
  53. dprintf("\n");
  54. }
  55. }
  56. DECLARE_API( ib )
  57. {
  58. InternalReadIoSpace( 1, (PSTR)args );
  59. return S_OK;
  60. }
  61. DECLARE_API( iw )
  62. {
  63. InternalReadIoSpace( 2, (PSTR)args );
  64. return S_OK;
  65. }
  66. DECLARE_API( id )
  67. {
  68. InternalReadIoSpace( 4, (PSTR)args );
  69. return S_OK;
  70. }
  71. VOID
  72. InternalWriteIoSpace(
  73. ULONG OutputSize,
  74. LPSTR args
  75. )
  76. /*++
  77. Routine Description:
  78. Input a byte froma port.
  79. Arguments:
  80. None.
  81. Return Value:
  82. None.
  83. --*/
  84. {
  85. ULONG64 IoAddress = 0;
  86. ULONG OutputValue = 0;
  87. LPSTR p;
  88. p = strtok( args, " \t" );
  89. if (p) {
  90. IoAddress = GetExpression( p );
  91. }
  92. if (IoAddress == 0) {
  93. dprintf( "Could not evaluate address expresion (%s)\n", args );
  94. return;
  95. }
  96. p = strtok( NULL, " \t" );
  97. if (p) {
  98. OutputValue = (ULONG) GetExpression( p );
  99. }
  100. WriteIoSpace64( IoAddress, OutputValue, &OutputSize );
  101. }
  102. DECLARE_API( ob )
  103. {
  104. InternalWriteIoSpace( 1, (PSTR)args );
  105. return S_OK;
  106. }
  107. DECLARE_API( ow )
  108. {
  109. InternalWriteIoSpace( 2, (PSTR)args );
  110. return S_OK;
  111. }
  112. DECLARE_API( od )
  113. {
  114. InternalWriteIoSpace( 4, (PSTR)args );
  115. return S_OK;
  116. }