📄 mdppfs.c
字号:
/*++
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.
Copyright (c) 1995, 1996, 1997 Microsoft Corporation
Module Name:
mdppfs.c
Abstract:
This file implements the NK kernel ppfs client side interface
Notes:
--*/
#include "windows.h"
#include "p2debug.h"
/*
* Write register in bits 0-7
* Read register in bits 8-15
* Control bits (msw only)
*
* This side:
* 0x8000 - Data byte ready (tx)
* 0x0800 - Ack to ack (noticed other side's ack)
* 0x2000 - Waiting for byte (rx)
* Other side:
* 0x0002 - Ack (noticed this side's byte)
* 0x0010 - Data byte ready (rx)
*/
typedef volatile DWORD *PVDWORD; /* pointer to a volatile dword */
BOOL NoPPFS = FALSE; // parallel port disconnected flag
//***************************************************************************
// OEMParallelPortGetByte - Get byte from parallel port
//
// Input - none
// Ouput - if parallel port disconnected, set NoPPFS=TRUE and returns -1
// else returns byte received from parallel port
//***************************************************************************
int OEMParallelPortGetByte(void)
{
DWORD dwStatus; // parallel port status
unsigned int iWatchdog=0xffffff; // timeout counter
//SA-11x0bd does not support parallel port
NoPPFS=TRUE;
if (NoPPFS) // if parallel port disconnected
return -1; // do nothing
// wait for PAR_INTR
while (!((dwStatus= *(PVDWORD)(PAR_CONTROL_REG)) & PAR_INTR) && --iWatchdog);
*(PVDWORD)(PAR_CONTROL_REG) = PAR_BUSY | PAR_AUTOEN | PAR_SELECT;
if (!iWatchdog) { // if timeout occured
// display error message
#ifndef BOOT_LOADER
NKDbgPrintfW(L"OEMParallelPortGetByte: status timeout.\r\n");
#endif
NoPPFS=TRUE; // set parallel port to disconnected
return -1; // and return failure
}
return((dwStatus>>8)&0xff); // return byte received
}
//***************************************************************************
// OEMParallelPortSendByte - send byte out parallel port
//
// Input - chData=byte to send
//
// Output - sets NoPPFS=TRUE if parallel port disconnected
//***************************************************************************
VOID OEMParallelPortSendByte(BYTE chData)
{
unsigned int iWatchdog=0xffffff; // timeout counter
// parallel port status
DWORD dwStatus = (DWORD)chData | PAR_BUSY_NFAULT | PAR_SELECT;
//SA-11x0bd does not support parallel port
NoPPFS=TRUE;
if (NoPPFS) // if ppfs disconnected
return; // do nothing
// set direction to write
*(PVDWORD)(PAR_CONTROL_REG) = dwStatus;
while (1) {
// wait for AUTOFD
while (!((dwStatus= *(PVDWORD)(PAR_CONTROL_REG)) & PAR_AUTOFD) && --iWatchdog);
if (!iWatchdog) { // if timeout occurred
// display error message
#ifndef BOOT_LOADER
NKDbgPrintfW(L"OEMParallelPortSendByte: status timeout 1.\r\n");
#endif
NoPPFS=TRUE; // and disconnect ppfs
return;
}
// read status two more times to debounce
if (!((dwStatus= *(PVDWORD)(PAR_CONTROL_REG)) & PAR_AUTOFD))
continue;
if (((dwStatus= *(PVDWORD)(PAR_CONTROL_REG)) & PAR_AUTOFD))
break;
}
dwStatus |= PAR_EN; // set PAR_EN
*(PVDWORD)(PAR_CONTROL_REG) = dwStatus;
dwStatus |= PAR_NACK; // set PAR_NACK
*(PVDWORD)(PAR_CONTROL_REG) = dwStatus;
while (1) {
// wait for AUTOFD
while (((dwStatus= *(PVDWORD)(PAR_CONTROL_REG)) & PAR_AUTOFD) && --iWatchdog);
if (!iWatchdog) { // if timeout occurred
// display error message
#ifndef BOOT_LOADER
NKDbgPrintfW(L"OEMParallelPortSendByte: status timeout 2.\r\n");
#endif
NoPPFS=TRUE; // and disconnect ppfs
return;
}
// read status two more times to debounce
if (((dwStatus= *(PVDWORD)(PAR_CONTROL_REG)) & PAR_AUTOFD))
continue;
if (!((dwStatus= *(PVDWORD)(PAR_CONTROL_REG)) & PAR_AUTOFD))
break;
}
// leave status in read mode
*(PVDWORD)(PAR_CONTROL_REG) = PAR_BUSY_NFAULT_AUTOEN_SELECT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -