/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define WIN32_LEAN_AND_MEAN #include #include #include "porttalk_IOCTL.h" // Globals extern BOOL bWindowsNT; HANDLE hFddDev=INVALID_HANDLE_VALUE; void outportb(UINT portid, BYTE value) { __asm mov edx,portid __asm mov al,value __asm out dx,al } BOOL OpenFddDevice(void) { if (!bWindowsNT) return TRUE; if((hFddDev = CreateFile("\\\\.\\PortTalk", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) return FALSE; return TRUE; } BOOL ToggleFddLight(BYTE drive, BYTE status) { DWORD BytesReturned; unsigned char Buffer[3]; unsigned short *pBuffer; BYTE value = status<<(drive|4)|drive|12; if (!bWindowsNT) { outportb(0x3F2, value); return TRUE; } if (hFddDev == INVALID_HANDLE_VALUE) return FALSE; pBuffer = (unsigned short *)&Buffer[0]; *pBuffer = 0x3F2; Buffer[2] = (unsigned char)value; if (!DeviceIoControl(hFddDev, IOCTL_WRITE_PORT_UCHAR, &Buffer, 3, NULL, 0, &BytesReturned, NULL)) return FALSE; return TRUE; } void CloseFddDevice(void) { if (!bWindowsNT) return; if (hFddDev != INVALID_HANDLE_VALUE) CloseHandle(hFddDev); }