hardware interrupts and parallel in visual c+ or c++ builder

Status
Not open for further replies.

is_razi

Full Member level 3
Joined
Apr 6, 2002
Messages
162
Helped
13
Reputation
26
Reaction score
7
Trophy points
1,298
Location
Tabriz
Activity points
1,190
interrupt builder c++

hi
is there anyone who can introduce me an ebook about hardware interrupts and interfacing in microsoft visualc++ or c++ builder .

thanks very much.
:? :? :?
 

hardware interrupt + c

Hi I have writeen some code for accessing hradware for win 32 platform
e.g. win NT XP & 95 & 98 for BCC builder using a public libeary (dll)

PM me if your intersted



bobi
 

return c++ buider

Hi..

You can use WinDriver from jungo to create parallel interrupt
with c++ builder/MS VC++
 

isa interruppt level affinity vector

Can you Help me ?
Give me some sample code to create parallel interrupt ?
 

interrupt service routine msvc++

**broken link removed**
 

use rtlinitunicodestring

/******************************************************************/
/* Example NT/2000/XP Interrupt & DPC Driver */
/* Copyright 2001 Craig Peacock, Craig.Peacock@beyondlogic.org */
/* See https://www.beyondlogic.org for a complete description */
/* Last Updated 11th November 2001 */
/******************************************************************/

#include <ntddk.h>

#define PortAddress 0x378
#define CONTROL PortAddress+2
#define outportb(ADDR,BYTE) outp(ADDR,BYTE)
#define inportb(ADDR) inp(ADDR)

typedef struct _LOCAL_DEVICE_INFO {
PKINTERRUPT InterruptObject;
ULONG Level;
ULONG Vector;
KAFFINITY Affinity;
} LOCAL_DEVICE_INFO, *PLOCAL_DEVICE_INFO;

NTSTATUS InterruptCreateDispatch(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}

BOOLEAN InterruptIsr(IN PKINTERRUPT Interrupt, IN OUT PVOID Context)
{
PDEVICE_OBJECT DeviceObject = Context;

KdPrint( ("Interrupt.sys: Interrupt Service Routine\n") );

/* We should check if the interrupt comes from us and return */

IoRequestDpc(DeviceObject,
DeviceObject->CurrentIrp,
NULL);

return TRUE;
}

VOID InterruptDpcRoutine(IN PKDPC Dpc, PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
{
PLOCAL_DEVICE_INFO DeviceExtension;
PIRP pIrp;

pIrp = DeviceObject->CurrentIrp;
DeviceExtension = DeviceObject->DeviceExtension;

KdPrint( ("Interrupt.sys: DPC Routine - Completing Interrupt Request\n") );

/* Do any processing here */

return;
}

VOID InterruptUnload(IN PDRIVER_OBJECT DriverObject)
{
WCHAR DOSNameBuffer[] = L"\\DosDevices\\Interrupt";
UNICODE_STRING uniDOSString;
PLOCAL_DEVICE_INFO extension = DriverObject->DeviceObject->DeviceExtension;

KdPrint( ("Interrupt.sys: Interrupt.sys is Unloading") );

/* Disable Parallel Port IRQ's */
outportb(CONTROL, inportb(CONTROL) & 0xEF);

/* Disconnect Interrupt */
IoDisconnectInterrupt(extension->InterruptObject);

/* Delete Symbolic Link */
RtlInitUnicodeString(&uniDOSString, DOSNameBuffer);
IoDeleteSymbolicLink (&uniDOSString);

/* Delete Device */
IoDeleteDevice(DriverObject->DeviceObject);
}

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
PDEVICE_OBJECT DeviceObject;
NTSTATUS status;
PLOCAL_DEVICE_INFO DeviceExtension;

ULONG MappedVector;
KIRQL Irql;

WCHAR NameBuffer[] = L"\\Device\\Interrupt";
WCHAR DOSNameBuffer[] = L"\\DosDevices\\Interrupt";
UNICODE_STRING uniNameString, uniDOSString;

KdPrint( ("Interrupt.sys: Interrupt.sys Loading") );

RtlInitUnicodeString(&uniNameString, NameBuffer);
RtlInitUnicodeString(&uniDOSString, DOSNameBuffer);

status = IoCreateDevice(DriverObject, // DriverObject
sizeof(LOCAL_DEVICE_INFO), // DeviceExtensionSize
&uniNameString, // DeviceName
FILE_DEVICE_UNKNOWN, // DeviceType
0, // DeviceCharacteristics
TRUE, // Exclusive
&DeviceObject); // *DeviceObject

if(!NT_SUCCESS(status)) return status;

DeviceExtension = DeviceObject->DeviceExtension;

status = IoCreateSymbolicLink (&uniDOSString, &uniNameString);

if (!NT_SUCCESS(status)) return status;

DeviceExtension->Level = 7;
DeviceExtension->Vector = DeviceExtension->Level;

MappedVector = HalGetInterruptVector(Isa,
0,
DeviceExtension->Level,
DeviceExtension->Vector,
&Irql,
&DeviceExtension->Affinity);

KdPrint( ("Interrupt.sys: MappedVector = 0x%08X\n",MappedVector) );
KdPrint( ("Interrupt.sys: Level = 0x%08X\n",DeviceExtension->Level) );
KdPrint( ("Interrupt.sys: Vector = 0x%08X\n",DeviceExtension->Vector) );
KdPrint( ("Interrupt.sys: Irql = 0x%08X\n",Irql) );
KdPrint( ("Interrupt.sys: Affinity = 0x%08X\n",DeviceExtension->Affinity) );

if (MappedVector == 0) DbgPrint("Interrupt.sys: HalGetInterruptVector failed\n");

IoInitializeDpcRequest(DeviceObject,InterruptDpcRoutine);

status = IoConnectInterrupt(&DeviceExtension->InterruptObject, // InterruptObject
InterruptIsr, // ServiceRoutine
DeviceObject, // ServiceContext
NULL, // SpinLock
MappedVector, // Vector
Irql, // Irql
Irql, // SynchronizeIrql
Latched, // InterruptMode
FALSE, // ShareVector
DeviceExtension->Affinity, // ProcessorEnableMask
FALSE); // FloatingSave

if (!NT_SUCCESS (status)) DbgPrint("Interrupt.sys: IoConnectInterrupt Failed\n");

/* Enable Parallel Port IRQ's */
outportb(CONTROL, inportb(CONTROL) | 0x10);

DriverObject->MajorFunction[IRP_MJ_CREATE] = InterruptCreateDispatch;
DriverObject->DriverUnload = InterruptUnload;

return STATUS_SUCCESS;
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…