Old fashion design for PC-104
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.
 
 
 
 
 

116 lines
2.4 KiB

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: Port32.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// http://www.internals.com //
//----------------------------------------------------------------------------
// ---------------------------------------------------- //
// WinIo v2.0 //
// Direct Hardware Access Under Windows 9x/NT/2000/XP //
// Copyright 1998-2002 Yariv Kaplan //
// http://www.internals.com //
// ---------------------------------------------------- //
#include <windows.h>
#include <winioctl.h>
#include <conio.h>
#include "port32.h"
#include "drv\nt\winio_nt.h"
#include "drv\9x\winio_9x.h"
#include "kernelio.h"
bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize)
{
tagPort32Struct Port32Struct;
DWORD dwBytesReturned;
if (!IsWinIoInitialized)
return false;
if (IsNT)
{
switch (bSize)
{
case 1:
*pdwPortVal = _inp(wPortAddr);
break;
case 2:
*pdwPortVal = _inpw(wPortAddr);
break;
case 4:
*pdwPortVal = _inpd(wPortAddr);
break;
}
}
else
{
Port32Struct.bSize = bSize;
Port32Struct.wPortAddr = wPortAddr;
return DeviceIoControl(hDriver, WINIO_READPORT, &Port32Struct, sizeof(Port32Struct),
pdwPortVal, sizeof(DWORD), &dwBytesReturned, NULL);
}
return true;
}
bool _stdcall SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize)
{
tagPort32Struct Port32Struct;
DWORD dwBytesReturned;
if (!IsWinIoInitialized)
return false;
if (IsNT)
{
switch (bSize)
{
case 1:
_outp(wPortAddr, dwPortVal);
break;
case 2:
_outpw(wPortAddr, (WORD)dwPortVal);
break;
case 4:
_outpd(wPortAddr, dwPortVal);
break;
}
}
else
{
Port32Struct.bSize = bSize;
Port32Struct.dwPortVal = dwPortVal;
Port32Struct.wPortAddr = wPortAddr;
return DeviceIoControl(hDriver, WINIO_WRITEPORT, &Port32Struct, sizeof(Port32Struct),
NULL, 0, &dwBytesReturned, NULL);
}
return true;
}