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.

172 lines
3.4 KiB

  1. #include "enduser.h"
  2. VOID
  3. UpdateMasterDiskState(
  4. IN HDISK DiskHandle,
  5. IN UINT NewState
  6. )
  7. {
  8. MasterDiskInfo.State = NewState;
  9. memset(IoBuffer,0,512);
  10. memcpy(IoBuffer,&MasterDiskInfo,sizeof(MASTER_DISK));
  11. if(!WriteDisk(DiskHandle,1,1,IoBuffer)) {
  12. FatalError(textWriteFailedAtSector,1,1L);
  13. }
  14. }
  15. UINT
  16. LocateMasterDisk(
  17. IN UINT UserSpecifiedInt13Unit OPTIONAL
  18. )
  19. {
  20. UINT DiskCount;
  21. UINT i;
  22. BYTE Int13Unit;
  23. BYTE spt;
  24. USHORT h,cyl;
  25. ULONG ext;
  26. BYTE UnitToMatch;
  27. UnitToMatch = (BYTE)(UserSpecifiedInt13Unit ? UserSpecifiedInt13Unit : 0x80);
  28. DiskCount = InitializeDiskList();
  29. for(i=0; i<DiskCount; i++) {
  30. if(IsMasterDisk(i,IoBuffer)) {
  31. //
  32. // Want unit 80h
  33. //
  34. if(GetDiskInfoById(i,0,&Int13Unit,&spt,&h,&cyl,&ext)
  35. && (Int13Unit == UnitToMatch)) {
  36. return(i);
  37. }
  38. }
  39. }
  40. FatalError(textCantFindMasterDisk);
  41. }
  42. VOID
  43. FatalError(
  44. IN FPCHAR FormatString,
  45. ...
  46. )
  47. {
  48. char strng[250];
  49. va_list arglist;
  50. unsigned p;
  51. DispClearClientArea(NULL);
  52. DispPositionCursor(TEXT_LEFT_MARGIN,TEXT_TOP_LINE);
  53. DispSetCurrentPixelValue(VGAPIX_LIGHT_YELLOW);
  54. DispWriteString(textFatalError1);
  55. DispWriteString("\n\n");
  56. DispWriteString(textFatalError2);
  57. DispSetCurrentPixelValue(VGAPIX_LIGHT_RED);
  58. va_start(arglist,FormatString);
  59. vsprintf(strng,FormatString,arglist);
  60. va_end(arglist);
  61. DispWriteString("\n\n");
  62. DispWriteString(strng);
  63. //
  64. // Hanging this way prevents control-c because DOS isn't involved.
  65. //
  66. // We allow a special way to get out of this screen and exit
  67. // the program, for testing.
  68. //
  69. strcpy(strng,"I am TEDM");
  70. p = (unsigned)strng;
  71. _asm {
  72. y:
  73. mov si,p
  74. x:
  75. push si
  76. xor ax,ax ; get keystroke
  77. int 16h
  78. pop si
  79. push ss
  80. pop ds
  81. cmp byte ptr [si],0 ; reached and of match string?
  82. jnz not0 ; no, try to match chars
  83. cmp al,ASCI_CR ; see if user hit ENTER
  84. je bustout ; user entered magic code, exit to DOS
  85. jne y ; start all over
  86. not0:
  87. cmp [si],al ; still on target for magic sequence?
  88. jne y ; no, start over
  89. inc si ; yes, set up for next iteration
  90. jmp short x
  91. bustout:
  92. mov ax,3
  93. int 10h
  94. }
  95. exit(0);
  96. }
  97. USHORT
  98. GetKey(
  99. VOID
  100. )
  101. {
  102. USHORT c;
  103. _asm {
  104. mov ah,0
  105. int 16h
  106. mov c,ax
  107. }
  108. switch(c) {
  109. case 0x5000:
  110. return(DN_KEY_DOWN);
  111. case 0x4800:
  112. return(DN_KEY_UP);
  113. case 0x4200:
  114. return(DN_KEY_F8);
  115. default:
  116. return(c & 0x00ff);
  117. }
  118. }
  119. VOID
  120. DrainKeyboard(
  121. VOID
  122. )
  123. {
  124. _asm {
  125. drain:
  126. mov ah,1 ; get keyboard status
  127. int 16h ; zero flag set = no key waiting
  128. jz drained ; no key waiting, we're done
  129. mov ah,0 ; get keypress, we know one is there
  130. int 16h
  131. jmp short drain ; see if there are more keys waiting
  132. drained:
  133. }
  134. }