; Static Name Aliases ; TITLE mdppfs.c .286p .287 INCLUDELIB SLIBCE INCLUDELIB OLDNAMES.LIB _TEXT SEGMENT WORD PUBLIC 'CODE' _TEXT ENDS _DATA SEGMENT WORD PUBLIC 'DATA' _DATA ENDS CONST SEGMENT WORD PUBLIC 'CONST' CONST ENDS _BSS SEGMENT WORD PUBLIC 'BSS' _BSS ENDS $$SYMBOLS SEGMENT BYTE PUBLIC 'DEBSYM' $$SYMBOLS ENDS $$TYPES SEGMENT BYTE PUBLIC 'DEBTYP' $$TYPES ENDS DGROUP GROUP CONST, _BSS, _DATA ASSUME DS: DGROUP, SS: DGROUP EXTRN _printf:NEAR _BSS SEGMENT COMM NEAR _bLastOpWasWrite: BYTE: 4 _BSS ENDS EXTRN _PtrCurMSec:WORD _BSS SEGMENT COMM NEAR _NoPPFS: BYTE: 4 _BSS ENDS _DATA SEGMENT $SG343 DB 0dH, 0aH, 'WaitForStatus: time out (1), status = %2.2X', 0dH DB 0aH, 00H $SG347 DB 0dH, 0aH, 'WaitForStatus: PPSH disconnected', 0dH, 0aH, 00H _DATA ENDS _TEXT SEGMENT ASSUME CS: _TEXT PUBLIC _WaitForStatus _WaitForStatus PROC NEAR ;|*** // ;|*** // Copyright (c) Microsoft Corporation. All rights reserved. ;|*** // ;|*** // ;|*** // Use of this sample source code is subject to the terms of the Microsoft ;|*** // license agreement under which you licensed this sample source code. If ;|*** // you did not accept the terms of the license agreement, you are not ;|*** // authorized to use this sample source code. For the terms of the license, ;|*** // please see the license agreement between you and Microsoft or, if applicable, ;|*** // see the LICENSE.RTF on your install media or the root of your tools installation. ;|*** // THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES. ;|*** // ;|*** /*++ ;|*** THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ;|*** ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO ;|*** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A ;|*** PARTICULAR PURPOSE. ;|*** ;|*** Module Name: ;|*** ;|*** mdppfs.c ;|*** ;|*** Abstract: ;|*** ;|*** This file implements the NK kernel ppfs client side interface ;|*** ;|*** Notes: ;|*** ;|*** --*/ ;|*** ;|*** #include "windows.h" ;|*** #include "wdm.h" ;|*** #include "pc.h" ;|*** ;|*** #define PAR_PORT_BASE 0x0378 ;|*** #define PAR_PORT_DATA 0 ;|*** #define PAR_PORT_STAT 1 ;|*** #define PAR_PORT_CTRL 2 ;|*** ;|*** #define PAR_STAT_NBUSY 0x80 ;|*** #define PAR_STAT_NACK 0x40 ;|*** #define PAR_STAT_PE 0x20 ;|*** #define PAR_STAT_SLCT 0x10 ;|*** #define PAR_STAT_NERR 0x08 // This isn't connected ;|*** ;|*** #define PAR_CTRL_READ 0x20 ;|*** #define PAR_CTRL_IRQE 0x10 ;|*** #define PAR_CTRL_SLCT_IN 0x08 ;|*** #define PAR_CTRL_NINIT 0x04 ;|*** #define PAR_CTRL_AUTOFEED 0x02 ;|*** #define PAR_CTRL_STROBE 0x01 ;|*** ;|*** #define STATUS_IS_DISCONNECTED(a) \ ;|*** ((((a) & (PAR_STAT_PE | PAR_STAT_SLCT)) != PAR_STAT_SLCT) || \ ;|*** (((a) & (PAR_STAT_NBUSY | PAR_STAT_NACK)) == PAR_STAT_NACK)) ;|*** ;|*** //#define STATUS_IS_DISCONNECTED(a) (!((a) & PAR_STAT_SLCT)) ;|*** ;|*** #if DEBUG ;|*** #define LOG_ENTRY_TYPE_MASK 0xFF00 ;|*** #define LOG_ENTRY_DATA_MASK 0x00FF ;|*** ;|*** #define LOG_ENTRY_READ ((USHORT)('R' << 8)) ;|*** #define LOG_ENTRY_WRITE ((USHORT)('W' << 8)) ;|*** #define LOG_ENTRY_CONTROL ((USHORT)('C' << 8)) ;|*** #define LOG_ENTRY_STATUS ((USHORT)('S' << 8)) ;|*** #define LOG_ENTRY_DATA ((USHORT)('D' << 8)) ;|*** #define LOG_ENTRY_EXIT ((USHORT)('E' << 8)) ;|*** #define LOG_ENTRY_EVENT ((USHORT)('V' << 8)) ;|*** ;|*** #define LOG_EVENT_SKIP_RECEIVE ((USHORT)0) ;|*** #define LOG_EVENT_BAD_STATUS ((USHORT)1) ;|*** #define LOG_EVENT_BAD_DISCONNECT ((USHORT)2) ;|*** ;|*** #define NUMBER_LOG_EVENTS 3 ;|*** ;|*** TCHAR *EventDescriptions[NUMBER_LOG_EVENTS] = ;|*** { ;|*** TEXT("# Skipped Receives"), ;|*** TEXT("# Bad Status"), ;|*** TEXT("# Bad Disconnect"), ;|*** }; ;|*** ;|*** DWORD dwEventCounters[NUMBER_LOG_EVENTS]; ;|*** ;|*** VOID LogEntry(USHORT usEntry); ;|*** VOID DumpLog(VOID); ;|*** VOID DumpCounters(VOID); ;|*** ;|*** #define LOG_ENTRY(a) LogEntry(a) ;|*** #define DUMP_LOG() DumpLog() ;|*** #else ;|*** #define LOG_ENTRY(a) ;|*** #define DUMP_LOG() ;|*** #endif ;|*** ;|*** extern volatile DWORD *PtrCurMSec; /* current millisecond counter */ ;|*** ;|*** #define IoPortBase ((PUCHAR)PAR_PORT_BASE) ;|*** ;|*** BOOL NoPPFS; ;|*** BOOL bLastOpWasWrite; ;|*** ;|*** BOOL __inline VerifyDisconnect(VOID) ;|*** { ;|*** int i; ;|*** USHORT usStatus; ;|*** ;|*** for (i = 0; i < 3; i++) ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** if (!STATUS_IS_DISCONNECTED(usStatus)) ;|*** { ;|*** LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS); ;|*** ;|*** return FALSE; ;|*** } ;|*** } ;|*** return TRUE; ;|*** ;|*** } ;|*** ;|*** BOOL WaitForStatus(USHORT usMask, USHORT usValue) ;|*** { ; Line 127 *** 000000 c8 0a 00 00 enter 10,0 *** 000004 57 push di *** 000005 56 push si ; usMask = 4 ; usValue = 6 ; usStatus = -2 ; msecStart = -8 ; tries = -10 ; register cx = i ;|*** USHORT usStatus; ;|*** DWORD msecStart = *PtrCurMSec; ; Line 129 *** 000006 8b 1e 00 00 mov bx,WORD PTR _PtrCurMSec *** 00000a 8b 07 mov ax,WORD PTR [bx] *** 00000c 8b 57 02 mov dx,WORD PTR [bx+2] *** 00000f 89 46 f8 mov WORD PTR [bp-8],ax ;msecStart *** 000012 89 56 fa mov WORD PTR [bp-6],dx ;|*** int tries = 0; ; Line 130 *** 000015 c7 46 f6 00 00 mov WORD PTR [bp-10],0 ;tries ;|*** { ; Line 105 *** 00001a 8b 4e fe mov cx,WORD PTR [bp-2] ;usStatus *** 00001d 8b 5e 04 mov bx,WORD PTR [bp+4] ;usMask ;|*** int i; ;|*** USHORT usStatus; ;|*** ;|*** for (i = 0; i < 3; i++) ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** if (!STATUS_IS_DISCONNECTED(usStatus)) ;|*** { ;|*** LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS); ;|*** ;|*** return FALSE; ;|*** } ;|*** } ;|*** return TRUE; ;|*** ;|*** } ;|*** ;|*** BOOL WaitForStatus(USHORT usMask, USHORT usValue) ;|*** { ;|*** USHORT usStatus; ;|*** DWORD msecStart = *PtrCurMSec; ;|*** int tries = 0; ;|*** ;|*** do ; Line 132 $D338: ;|*** { ;|*** if (*PtrCurMSec - msecStart >= 200) ; Line 134 *** 000020 8b 36 00 00 mov si,WORD PTR _PtrCurMSec *** 000024 8b 04 mov ax,WORD PTR [si] *** 000026 8b 54 02 mov dx,WORD PTR [si+2] *** 000029 2b 46 f8 sub ax,WORD PTR [bp-8] ;msecStart *** 00002c 1b 56 fa sbb dx,WORD PTR [bp-6] *** 00002f 0b d2 or dx,dx *** 000031 75 05 jne $L393 *** 000033 3d c8 00 cmp ax,200 ;00c8H *** 000036 72 17 jb $I341 $L393: ;|*** { ;|*** if (++tries > 5) ; Line 136 *** 000038 ff 46 f6 inc WORD PTR [bp-10] ;tries *** 00003b 83 7e f6 05 cmp WORD PTR [bp-10],5 ;tries *** 00003f 7e 03 jle $JCC63 *** 000041 e9 a4 00 jmp $L384 $JCC63: ;|*** { ;|*** NoPPFS = TRUE; ;|*** ;|*** printf("\r\nWaitForStatus: time out (1), status = %2.2X\r\n", ;|*** usStatus); ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 2); ;|*** ;|*** DUMP_LOG(); ;|*** ;|*** return FALSE; ;|*** } ;|*** msecStart = *PtrCurMSec; ; Line 149 *** 000044 8b 04 mov ax,WORD PTR [si] *** 000046 8b 54 02 mov dx,WORD PTR [si+2] *** 000049 89 46 f8 mov WORD PTR [bp-8],ax ;msecStart *** 00004c 89 56 fa mov WORD PTR [bp-6],dx ;|*** } ;|*** ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ; Line 152 $I341: ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** // ;|*** // Use SELECTIN to identify the existence of ppsh ;|*** // ;|*** if (STATUS_IS_DISCONNECTED(usStatus)) ; Line 159 *** 00004f ba 79 03 mov dx,889 ;0379H *** 000052 ec in al,dx *** 000053 8a c8 mov cl,al *** 000055 2a ed sub ch,ch *** 000057 8b c1 mov ax,cx *** 000059 24 30 and al,48 ;0030H *** 00005b 3c 10 cmp al,16 ;0010H *** 00005d 75 08 jne $I345 *** 00005f 8a c1 mov al,cl *** 000061 24 c0 and al,192 ;00c0H *** 000063 3c 40 cmp al,64 ;0040H *** 000065 75 69 jne $L392 ;|*** { ; Line 105 $I345: ;|*** int i; ;|*** USHORT usStatus; ;|*** ;|*** for (i = 0; i < 3; i++) ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** if (!STATUS_IS_DISCONNECTED(usStatus)) ;|*** { ;|*** LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS); ;|*** ;|*** return FALSE; ;|*** } ;|*** } ;|*** return TRUE; ;|*** ;|*** } ;|*** ;|*** BOOL WaitForStatus(USHORT usMask, USHORT usValue) ;|*** { ;|*** USHORT usStatus; ;|*** DWORD msecStart = *PtrCurMSec; ;|*** int tries = 0; ;|*** ;|*** do ;|*** { ;|*** if (*PtrCurMSec - msecStart >= 200) ;|*** { ;|*** if (++tries > 5) ;|*** { ;|*** NoPPFS = TRUE; ;|*** ;|*** printf("\r\nWaitForStatus: time out (1), status = %2.2X\r\n", ;|*** usStatus); ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 2); ;|*** ;|*** DUMP_LOG(); ;|*** ;|*** return FALSE; ;|*** } ;|*** msecStart = *PtrCurMSec; ;|*** } ;|*** ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** // ;|*** // Use SELECTIN to identify the existence of ppsh ;|*** // ;|*** if (STATUS_IS_DISCONNECTED(usStatus)) ;|*** { ;|*** if (VerifyDisconnect()) ; Line 161 *** 000067 c7 46 fe 00 00 mov WORD PTR [bp-2],0 ;usStatus ;|*** { ; Line 105 *** 00006c 8b 7e 06 mov di,WORD PTR [bp+6] ;usValue ;|*** int i; ;|*** USHORT usStatus; ;|*** ;|*** for (i = 0; i < 3; i++) ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** if (!STATUS_IS_DISCONNECTED(usStatus)) ;|*** { ;|*** LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS); ;|*** ;|*** return FALSE; ;|*** } ;|*** } ;|*** return TRUE; ;|*** ;|*** } ;|*** ;|*** BOOL WaitForStatus(USHORT usMask, USHORT usValue) ;|*** { ;|*** USHORT usStatus; ;|*** DWORD msecStart = *PtrCurMSec; ;|*** int tries = 0; ;|*** ;|*** do ;|*** { ;|*** if (*PtrCurMSec - msecStart >= 200) ;|*** { ;|*** if (++tries > 5) ;|*** { ;|*** NoPPFS = TRUE; ;|*** ;|*** printf("\r\nWaitForStatus: time out (1), status = %2.2X\r\n", ;|*** usStatus); ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 2); ;|*** ;|*** DUMP_LOG(); ;|*** ;|*** return FALSE; ;|*** } ;|*** msecStart = *PtrCurMSec; ;|*** } ;|*** ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** // ;|*** // Use SELECTIN to identify the existence of ppsh ;|*** // ;|*** if (STATUS_IS_DISCONNECTED(usStatus)) ;|*** { ;|*** if (VerifyDisconnect()) ; Line 161 $L376: *** 00006f ba 79 03 mov dx,889 ;0379H *** 000072 ec in al,dx *** 000073 8a c8 mov cl,al *** 000075 2a ed sub ch,ch *** 000077 8b c1 mov ax,cx *** 000079 24 30 and al,48 ;0030H *** 00007b 3c 10 cmp al,16 ;0010H *** 00007d 75 08 jne $L375 *** 00007f 8a c1 mov al,cl *** 000081 24 c0 and al,192 ;00c0H *** 000083 3c 40 cmp al,64 ;0040H *** 000085 75 4f jne $L383 $L375: *** 000087 ff 46 fe inc WORD PTR [bp-2] ;usStatus *** 00008a 83 7e fe 03 cmp WORD PTR [bp-2],3 ;usStatus *** 00008e 7c df jl $L376 *** 000090 c7 46 fc 01 00 mov WORD PTR [bp-4],1 *** 000095 c7 46 fe 00 00 mov WORD PTR [bp-2],0 ;usStatus $L377: *** 00009a 8b 46 fe mov ax,WORD PTR [bp-2] ;usStatus *** 00009d 0b 46 fc or ax,WORD PTR [bp-4] *** 0000a0 75 5e jne $L386 ;|*** { ;|*** printf("\r\nWaitForStatus: PPSH disconnected\r\n"); ;|*** ;|*** NoPPFS = TRUE; ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 1); ;|*** ;|*** DUMP_LOG(); ;|*** ;|*** return FALSE; ;|*** } ;|*** else ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ; Line 175 *** 0000a2 ec in al,dx *** 0000a3 8a c8 mov cl,al *** 0000a5 2a ed sub ch,ch ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** } ;|*** } ;|*** ;|*** if ((usStatus & usMask) == usValue) ; Line 180 $I344: *** 0000a7 8b c1 mov ax,cx *** 0000a9 23 c3 and ax,bx *** 0000ab 3b c7 cmp ax,di *** 0000ad 75 14 jne $DC339 ;|*** { ;|*** int i; ;|*** ;|*** for (i = 0; i < 2; i++) ; Line 184 *** 0000af 33 c9 xor cx,cx $F351: ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** if ((usStatus & usMask) != usValue) ; Line 190 *** 0000b1 ba 79 03 mov dx,889 ;0379H *** 0000b4 ec in al,dx *** 0000b5 2a e4 sub ah,ah *** 0000b7 89 46 fe mov WORD PTR [bp-2],ax ;usStatus *** 0000ba 23 c3 and ax,bx *** 0000bc 3b c7 cmp ax,di *** 0000be 74 20 je $L391 ;|*** { ; Line 105 $L390: *** 0000c0 8b 4e fe mov cx,WORD PTR [bp-2] ;usStatus $DC339: *** 0000c3 8b c1 mov ax,cx *** 0000c5 23 c3 and ax,bx *** 0000c7 3b c7 cmp ax,di *** 0000c9 74 03 je $JCC201 *** 0000cb e9 52 ff jmp $D338 $JCC201: *** 0000ce eb 4e jmp SHORT $L385 $L392: *** 0000d0 8b 7e 06 mov di,WORD PTR [bp+6] ;usValue *** 0000d3 eb d2 jmp SHORT $I344 *** 0000d5 90 nop ;|*** int i; ;|*** USHORT usStatus; ;|*** ;|*** for (i = 0; i < 3; i++) ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** if (!STATUS_IS_DISCONNECTED(usStatus)) ;|*** { ;|*** LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS); ;|*** ;|*** return FALSE; ;|*** } ;|*** } ;|*** return TRUE; ;|*** ;|*** } ;|*** ;|*** BOOL WaitForStatus(USHORT usMask, USHORT usValue) ;|*** { ;|*** USHORT usStatus; ;|*** DWORD msecStart = *PtrCurMSec; ;|*** int tries = 0; ;|*** ;|*** do ;|*** { ;|*** if (*PtrCurMSec - msecStart >= 200) ;|*** { ;|*** if (++tries > 5) ;|*** { ;|*** NoPPFS = TRUE; ;|*** ;|*** printf("\r\nWaitForStatus: time out (1), status = %2.2X\r\n", ;|*** usStatus); ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 2); ;|*** ;|*** DUMP_LOG(); ;|*** ;|*** return FALSE; ;|*** } ;|*** msecStart = *PtrCurMSec; ;|*** } ;|*** ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** // ;|*** // Use SELECTIN to identify the existence of ppsh ;|*** // ;|*** if (STATUS_IS_DISCONNECTED(usStatus)) ; Line 159 $L383: *** 0000d6 2b c0 sub ax,ax *** 0000d8 89 46 fe mov WORD PTR [bp-2],ax ;usStatus *** 0000db 89 46 fc mov WORD PTR [bp-4],ax *** 0000de eb ba jmp SHORT $L377 $L391: *** 0000e0 41 inc cx *** 0000e1 83 f9 02 cmp cx,2 *** 0000e4 7c cb jl $F351 *** 0000e6 eb d8 jmp SHORT $L390 ;|*** { ;|*** if (VerifyDisconnect()) ;|*** { ;|*** printf("\r\nWaitForStatus: PPSH disconnected\r\n"); ;|*** ;|*** NoPPFS = TRUE; ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 1); ;|*** ;|*** DUMP_LOG(); ;|*** ;|*** return FALSE; ;|*** } ;|*** else ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** } ;|*** } ;|*** ;|*** if ((usStatus & usMask) == usValue) ;|*** { ;|*** int i; ;|*** ;|*** for (i = 0; i < 2; i++) ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** if ((usStatus & usMask) != usValue) ;|*** { ;|*** LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS); ;|*** ;|*** break; ;|*** } ;|*** } ;|*** } ;|*** } ;|*** while ((usStatus & usMask) != usValue); ; Line 199 $L384: ;|*** NoPPFS = TRUE; ; Line 138 *** 0000e8 c7 06 00 00 01 00 mov WORD PTR _NoPPFS,1 *** 0000ee c7 06 02 00 00 00 mov WORD PTR _NoPPFS+2,0 ;|*** ;|*** printf("\r\nWaitForStatus: time out (1), status = %2.2X\r\n", ;|*** usStatus); ; Line 141 *** 0000f4 51 push cx *** 0000f5 68 00 00 push OFFSET DGROUP:$SG343 *** 0000f8 e8 00 00 call _printf *** 0000fb 83 c4 04 add sp,4 *** 0000fe eb 15 jmp SHORT $L398 $L386: ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 2); ;|*** ;|*** DUMP_LOG(); ;|*** ;|*** return FALSE; ;|*** } ;|*** msecStart = *PtrCurMSec; ;|*** } ;|*** ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** // ;|*** // Use SELECTIN to identify the existence of ppsh ;|*** // ;|*** if (STATUS_IS_DISCONNECTED(usStatus)) ;|*** { ;|*** if (VerifyDisconnect()) ;|*** { ;|*** printf("\r\nWaitForStatus: PPSH disconnected\r\n"); ; Line 163 *** 000100 68 00 00 push OFFSET DGROUP:$SG347 *** 000103 e8 00 00 call _printf *** 000106 83 c4 02 add sp,2 ;|*** ;|*** NoPPFS = TRUE; ; Line 165 *** 000109 c7 06 00 00 01 00 mov WORD PTR _NoPPFS,1 *** 00010f c7 06 02 00 00 00 mov WORD PTR _NoPPFS+2,0 ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 1); ;|*** ;|*** DUMP_LOG(); ;|*** ;|*** return FALSE; ; Line 171 $L398: *** 000115 33 c0 xor ax,ax *** 000117 33 d2 xor dx,dx *** 000119 5e pop si *** 00011a 5f pop di *** 00011b c9 leave *** 00011c c3 ret *** 00011d 90 nop $L385: ;|*** } ;|*** else ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** } ;|*** } ;|*** ;|*** if ((usStatus & usMask) == usValue) ;|*** { ;|*** int i; ;|*** ;|*** for (i = 0; i < 2; i++) ;|*** { ;|*** usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT); ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus)); ;|*** ;|*** if ((usStatus & usMask) != usValue) ;|*** { ;|*** LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS); ;|*** ;|*** break; ;|*** } ;|*** } ;|*** } ;|*** } ;|*** while ((usStatus & usMask) != usValue); ;|*** ;|*** return TRUE; ; Line 201 *** 00011e b8 01 00 mov ax,1 *** 000121 33 d2 xor dx,dx ;|*** } ; Line 202 *** 000123 5e pop si *** 000124 5f pop di *** 000125 c9 leave *** 000126 c3 ret *** 000127 90 nop _WaitForStatus ENDP PUBLIC _OEMParallelPortInit _OEMParallelPortInit PROC NEAR ;|*** ;|*** int OEMParallelPortInit(void) ;|*** { ;|*** LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE); ;|*** ;|*** WRITE_PORT_UCHAR( ; Line 208 *** 000128 b8 03 00 mov ax,3 *** 00012b ba 7a 03 mov dx,890 ;037aH *** 00012e ee out dx, al ;|*** IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE); ;|*** ;|*** return TRUE; ; Line 211 *** 00012f b8 01 00 mov ax,1 ;|*** } ; Line 212 *** 000132 c3 ret *** 000133 90 nop _OEMParallelPortInit ENDP PUBLIC _OEMParallelPortGetByte _OEMParallelPortGetByte PROC NEAR ;|*** ;|*** int OEMParallelPortGetByte(void) ;|*** { ; Line 215 *** 000134 c8 02 00 00 enter 2,0 ; value = -1 ;|*** BYTE value; ;|*** ;|*** if (NoPPFS) ; Line 218 *** 000138 a1 02 00 mov ax,WORD PTR _NoPPFS+2 *** 00013b 0b 06 00 00 or ax,WORD PTR _NoPPFS *** 00013f 74 05 je $L394 ;|*** { ;|*** return -1; ; Line 220 $L399: *** 000141 b8 ff ff mov ax,-1 ;ffffH *** 000144 c9 leave *** 000145 c3 ret $L394: ;|*** } ;|*** ;|*** Retry: ;|*** LOG_ENTRY(LOG_ENTRY_READ); ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_READ | PAR_CTRL_STROBE); ;|*** ;|*** WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_READ | PAR_CTRL_STROBE); ; Line 228 *** 000146 b8 21 00 mov ax,33 ;0021H *** 000149 ba 7a 03 mov dx,890 ;037aH *** 00014c ee out dx, al ;|*** ;|*** if (!WaitForStatus(PAR_STAT_NACK, PAR_STAT_NACK)) ; Line 230 *** 00014d 6a 40 push 64 ;0040H *** 00014f 6a 40 push 64 ;0040H *** 000151 e8 ac fe call _WaitForStatus *** 000154 83 c4 04 add sp,4 *** 000157 0b d0 or dx,ax *** 000159 74 e6 je $L399 ;|*** { ;|*** return -1; ;|*** } ;|*** ;|*** value = READ_PORT_UCHAR(IoPortBase + PAR_PORT_DATA); ; Line 235 *** 00015b ba 78 03 mov dx,888 ;0378H *** 00015e ec in al,dx *** 00015f 88 46 ff mov BYTE PTR [bp-1],al ;value ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_DATA | value)); ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE); ;|*** ;|*** WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE); ; Line 241 *** 000162 b8 03 00 mov ax,3 *** 000165 ba 7a 03 mov dx,890 ;037aH *** 000168 ee out dx, al ;|*** ;|*** if (!WaitForStatus(PAR_STAT_NACK, 0)) ; Line 243 *** 000169 6a 00 push 0 *** 00016b 6a 40 push 64 ;0040H *** 00016d e8 90 fe call _WaitForStatus *** 000170 83 c4 04 add sp,4 *** 000173 0b d0 or dx,ax *** 000175 74 ca je $L399 ;|*** { ;|*** return -1; ;|*** } ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 0); ;|*** ;|*** if (bLastOpWasWrite && value == 0x1A) ; Line 250 *** 000177 a1 02 00 mov ax,WORD PTR _bLastOpWasWrite+2 *** 00017a 0b 06 00 00 or ax,WORD PTR _bLastOpWasWrite *** 00017e 74 10 je $I364 *** 000180 80 7e ff 1a cmp BYTE PTR [bp-1],26 ;001aH ;value *** 000184 75 0a jne $I364 ;|*** { ;|*** // ;|*** // The problem is that periodically the first character we ;|*** // receive after a write is the last byte sent of the previous write. ;|*** // ;|*** // For now we will ignore it ;|*** // ;|*** LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_SKIP_RECEIVE); ;|*** bLastOpWasWrite = FALSE; ; Line 259 *** 000186 2b c0 sub ax,ax *** 000188 a3 02 00 mov WORD PTR _bLastOpWasWrite+2,ax *** 00018b a3 00 00 mov WORD PTR _bLastOpWasWrite,ax ;|*** goto Retry; ; Line 260 *** 00018e eb b6 jmp SHORT $L394 $I364: *** 000190 2b c0 sub ax,ax *** 000192 a3 02 00 mov WORD PTR _bLastOpWasWrite+2,ax *** 000195 a3 00 00 mov WORD PTR _bLastOpWasWrite,ax ;|*** } ;|*** ;|*** bLastOpWasWrite = FALSE; ;|*** ;|*** return value; ; Line 265 *** 000198 8a 46 ff mov al,BYTE PTR [bp-1] ;value ;|*** } ; Line 266 *** 00019b c9 leave *** 00019c c3 ret *** 00019d 90 nop _OEMParallelPortGetByte ENDP PUBLIC _OEMParallelPortSendByte _OEMParallelPortSendByte PROC NEAR ;|*** ;|*** VOID OEMParallelPortSendByte(BYTE chData) ;|*** { ; Line 269 *** 00019e 55 push bp *** 00019f 8b ec mov bp,sp ; chData = 4 ;|*** if (NoPPFS) ; Line 270 *** 0001a1 a1 02 00 mov ax,WORD PTR _NoPPFS+2 *** 0001a4 0b 06 00 00 or ax,WORD PTR _NoPPFS *** 0001a8 75 45 jne $EX368 ;|*** return; ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_WRITE); ;|*** ;|*** if (!WaitForStatus(PAR_STAT_NBUSY, 0)) ; Line 275 *** 0001aa 6a 00 push 0 *** 0001ac 68 80 00 push 128 ;0080H *** 0001af e8 4e fe call _WaitForStatus *** 0001b2 8b e5 mov sp,bp *** 0001b4 0b d0 or dx,ax *** 0001b6 74 37 je $EX368 ;|*** { ;|*** return; ;|*** } ;|*** ;|*** LOG_ENTRY((USHORT)(LOG_ENTRY_DATA | chData)); ;|*** ;|*** WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE); ; Line 282 *** 0001b8 b8 03 00 mov ax,3 *** 0001bb ba 7a 03 mov dx,890 ;037aH *** 0001be ee out dx, al ;|*** ;|*** WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_DATA, chData); ; Line 284 *** 0001bf 8a 46 04 mov al,BYTE PTR [bp+4] ;chData *** 0001c2 ba 78 03 mov dx,888 ;0378H *** 0001c5 ee out dx, al ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_AUTOFEED); ;|*** ;|*** WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED); ; Line 288 *** 0001c6 b8 02 00 mov ax,2 *** 0001c9 ba 7a 03 mov dx,890 ;037aH *** 0001cc ee out dx, al ;|*** ;|*** if (!WaitForStatus(PAR_STAT_NBUSY, PAR_STAT_NBUSY)) ; Line 290 *** 0001cd 68 80 00 push 128 ;0080H *** 0001d0 68 80 00 push 128 ;0080H *** 0001d3 e8 2a fe call _WaitForStatus *** 0001d6 8b e5 mov sp,bp *** 0001d8 0b d0 or dx,ax *** 0001da 74 13 je $EX368 ;|*** { ;|*** return; ;|*** } ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE); ;|*** ;|*** WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE); ; Line 297 *** 0001dc b8 03 00 mov ax,3 *** 0001df ba 7a 03 mov dx,890 ;037aH *** 0001e2 ee out dx, al ;|*** ;|*** LOG_ENTRY(LOG_ENTRY_EXIT | 0); ;|*** ;|*** bLastOpWasWrite = TRUE; ; Line 301 *** 0001e3 c7 06 00 00 01 00 mov WORD PTR _bLastOpWasWrite,1 *** 0001e9 c7 06 02 00 00 00 mov WORD PTR _bLastOpWasWrite+2,0 ;|*** } ; Line 302 $EX368: *** 0001ef c9 leave *** 0001f0 c3 ret *** 0001f1 90 nop _OEMParallelPortSendByte ENDP _TEXT ENDS END ;|*** ;|*** #if DEBUG ;|*** #define LOG_SIZE 0x1000 ;|*** #define RW_STACK_SIZE 10 ;|*** ;|*** WCHAR wcHexDigits[16] = ;|*** { ;|*** TEXT('0'), TEXT('1'), TEXT('2'), TEXT('3'), ;|*** TEXT('4'), TEXT('5'), TEXT('6'), TEXT('7'), ;|*** TEXT('8'), TEXT('9'), TEXT('A'), TEXT('B'), ;|*** TEXT('C'), TEXT('D'), TEXT('E'), TEXT('F') ;|*** }; ;|*** ;|*** USHORT usLogBuffer[LOG_SIZE]; ;|*** int iLogHead = 0; ;|*** int iLogTail = 0; ;|*** ;|*** VOID ;|*** LogEntry(USHORT usEntry) ;|*** { ;|*** static USHORT usLastEntry; ;|*** USHORT usEntryType; ;|*** USHORT usEntryData; ;|*** ;|*** usEntryData = usEntry & LOG_ENTRY_DATA_MASK; ;|*** usEntryType = usEntry & LOG_ENTRY_TYPE_MASK; ;|*** ;|*** switch (usEntryType) ;|*** { ;|*** case LOG_ENTRY_STATUS: ;|*** if (usLastEntry == usEntry) ;|*** { ;|*** // ;|*** // Don't log duplicate status ;|*** // ;|*** return; ;|*** } ;|*** break; ;|*** ;|*** case LOG_ENTRY_EVENT: ;|*** if (usEntryData < NUMBER_LOG_EVENTS) ;|*** { ;|*** dwEventCounters[usEntryData]++; ;|*** } ;|*** break; ;|*** } ;|*** ;|*** usLastEntry = usEntry; ;|*** ;|*** usLogBuffer[iLogTail++] = usEntry; ;|*** iLogTail %= LOG_SIZE; ;|*** ;|*** if (iLogTail == iLogHead) ;|*** { ;|*** iLogHead++; ;|*** iLogHead %= LOG_SIZE; ;|*** } ;|*** } ;|*** ;|*** VOID ;|*** DumpLog(VOID) ;|*** { ;|*** // R 00 W 4F ;|*** TCHAR szPrintLine[100]; ;|*** int iLogCurrent; ;|*** PTCHAR pCurrentColumn; ;|*** int nDataItems; ;|*** USHORT usCurrentOp, usLastOp; ;|*** int iReadWriteStack[RW_STACK_SIZE]; ;|*** int i; ;|*** ;|*** pCurrentColumn = szPrintLine; ;|*** nDataItems = 0; ;|*** ;|*** usLastOp = 0; ;|*** ;|*** for (i = 0; i < RW_STACK_SIZE; i++) ;|*** { ;|*** iReadWriteStack[i] = iLogTail; ;|*** } ;|*** ;|*** for (iLogCurrent = iLogHead; iLogCurrent != iLogTail; ;|*** iLogCurrent++, iLogCurrent %= LOG_SIZE) ;|*** { ;|*** usCurrentOp = usLogBuffer[iLogCurrent] & LOG_ENTRY_TYPE_MASK; ;|*** switch (usCurrentOp) ;|*** { ;|*** case LOG_ENTRY_READ: ;|*** case LOG_ENTRY_WRITE: ;|*** if (usLastOp != usCurrentOp) ;|*** { ;|*** if (pCurrentColumn != szPrintLine) ;|*** { ;|*** memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n"))); ;|*** OutputDebugString(szPrintLine); ;|*** pCurrentColumn = szPrintLine; ;|*** } ;|*** ;|*** *pCurrentColumn++ = (TCHAR)(usLogBuffer[iLogCurrent] >> 8); ;|*** *pCurrentColumn++ = TEXT(' '); ;|*** usLastOp = usCurrentOp; ;|*** nDataItems = 0; ;|*** } ;|*** ;|*** for (i = 0; i < (RW_STACK_SIZE - 1); i++) ;|*** { ;|*** iReadWriteStack[i] = iReadWriteStack[i + 1]; ;|*** } ;|*** ;|*** iReadWriteStack[RW_STACK_SIZE - 1] = iLogCurrent; ;|*** break; ;|*** ;|*** case LOG_ENTRY_EVENT: ;|*** case LOG_ENTRY_DATA: ;|*** if (nDataItems == 25) ;|*** { ;|*** memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n"))); ;|*** OutputDebugString(szPrintLine); ;|*** pCurrentColumn = szPrintLine; ;|*** *pCurrentColumn++ = TEXT(' '); ;|*** *pCurrentColumn++ = TEXT(' '); ;|*** nDataItems = 0; ;|*** } ;|*** *pCurrentColumn++ = wcHexDigits[(usLogBuffer[iLogCurrent] >> 4) & 0x0F]; ;|*** *pCurrentColumn++ = wcHexDigits[usLogBuffer[iLogCurrent] & 0x0F]; ;|*** *pCurrentColumn++ = usCurrentOp == LOG_ENTRY_DATA ? TEXT(' ') : TEXT('!'); ;|*** nDataItems++; ;|*** break; ;|*** } ;|*** } ;|*** ;|*** if (pCurrentColumn != szPrintLine) ;|*** { ;|*** memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n"))); ;|*** OutputDebugString(szPrintLine); ;|*** pCurrentColumn = szPrintLine; ;|*** } ;|*** ;|*** nDataItems = 0; ;|*** ;|*** for (i = 0; i < RW_STACK_SIZE; i++) ;|*** { ;|*** if (iReadWriteStack[i] != iLogTail) ;|*** { ;|*** break; ;|*** } ;|*** } ;|*** ;|*** iLogCurrent = (i < RW_STACK_SIZE) ? iReadWriteStack[i] : iLogTail; ;|*** ;|*** for ( ; iLogCurrent != iLogTail; iLogCurrent++, iLogCurrent %= LOG_SIZE) ;|*** { ;|*** if (nDataItems == 16) ;|*** { ;|*** memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n"))); ;|*** OutputDebugString(szPrintLine); ;|*** pCurrentColumn = szPrintLine; ;|*** nDataItems = 0; ;|*** } ;|*** ;|*** *pCurrentColumn++ = (TCHAR)(usLogBuffer[iLogCurrent] >> 8); ;|*** ;|*** *pCurrentColumn++ = TEXT(' '); ;|*** ;|*** *pCurrentColumn++ = wcHexDigits[(usLogBuffer[iLogCurrent] >> 4) & 0x0F]; ;|*** ;|*** *pCurrentColumn++ = wcHexDigits[usLogBuffer[iLogCurrent] & 0x0F]; ;|*** ;|*** *pCurrentColumn++ = TEXT(' '); ;|*** ;|*** nDataItems++; ;|*** } ;|*** ;|*** if (pCurrentColumn != szPrintLine) ;|*** { ;|*** memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n"))); ;|*** OutputDebugString(szPrintLine); ;|*** pCurrentColumn = szPrintLine; ;|*** } ;|*** ;|*** DumpCounters(); ;|*** } ;|*** ;|*** VOID ;|*** DumpCounters(VOID) ;|*** { ;|*** int i; ;|*** ;|*** for (i = 0; i < NUMBER_LOG_EVENTS; i++) ;|*** { ;|*** if (dwEventCounters[i] != 0) ;|*** { ;|*** NKDbgPrintfW( ;|*** TEXT("%s = %d\r\n"), EventDescriptions[i], dwEventCounters[i]); ;|*** } ;|*** } ;|*** } ;|*** #endif