mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 20:36:35 +00:00
Changed beep to compile as sys driver.
svn path=/trunk/; revision=350
This commit is contained in:
parent
aa77254872
commit
9e3fe0593a
2 changed files with 181 additions and 157 deletions
|
@ -24,7 +24,8 @@ typedef struct _BEEP_DEVICE_EXTENSION
|
||||||
KDPC Dpc;
|
KDPC Dpc;
|
||||||
KTIMER Timer;
|
KTIMER Timer;
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
LONG BeepOn;
|
// LONG BeepOn;
|
||||||
|
BOOL BeepOn;
|
||||||
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,12 +34,13 @@ typedef struct _BEEP_DEVICE_EXTENSION
|
||||||
|
|
||||||
VOID BeepDPC (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
|
VOID BeepDPC (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
|
||||||
{
|
{
|
||||||
PDEVICE_EXTENSION pDeviceExtension = DeferredContext;
|
PDEVICE_EXTENSION DeviceExtension = DeferredContext;
|
||||||
|
|
||||||
DPRINT ("BeepDPC() called!\n");
|
DPRINT ("BeepDPC() called!\n");
|
||||||
HalMakeBeep (0);
|
HalMakeBeep (0);
|
||||||
InterlockedExchange (&(pDeviceExtension->BeepOn), 0);
|
// InterlockedExchange (&(DeviceExtension->BeepOn), FALSE);
|
||||||
KeSetEvent (&(pDeviceExtension->Event), 0, TRUE);
|
DeviceExtension->BeepOn = FALSE;
|
||||||
|
KeSetEvent (&(DeviceExtension->Event), 0, TRUE);
|
||||||
|
|
||||||
DPRINT ("BeepDPC() finished!\n");
|
DPRINT ("BeepDPC() finished!\n");
|
||||||
}
|
}
|
||||||
|
@ -138,14 +140,12 @@ NTSTATUS BeepDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
PDEVICE_EXTENSION pDeviceExtension;
|
PDEVICE_EXTENSION DeviceExtension;
|
||||||
PBEEP_SET_PARAMETERS pbsp;
|
PBEEP_SET_PARAMETERS pbsp;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
pDeviceExtension = DeviceObject->DeviceExtension;
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
if (Stack->MajorFunction == IRP_MJ_DEVICE_CONTROL)
|
|
||||||
{
|
|
||||||
DPRINT ("BeepDeviceControl() called!\n");
|
DPRINT ("BeepDeviceControl() called!\n");
|
||||||
if (Stack->Parameters.DeviceIoControl.IoControlCode == IOCTL_BEEP_SET)
|
if (Stack->Parameters.DeviceIoControl.IoControlCode == IOCTL_BEEP_SET)
|
||||||
{
|
{
|
||||||
|
@ -167,13 +167,14 @@ NTSTATUS BeepDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
{
|
{
|
||||||
DueTime = (LARGE_INTEGER)pbsp->Duration * 10000;
|
DueTime = (LARGE_INTEGER)pbsp->Duration * 10000;
|
||||||
|
|
||||||
KeSetTimer (&pDeviceExtension->Timer,
|
KeSetTimer (&DeviceExtension->Timer,
|
||||||
-DueTime,
|
-DueTime,
|
||||||
&pDeviceExtension->Dpc);
|
&DeviceExtension->Dpc);
|
||||||
|
|
||||||
HalMakeBeep (pbsp->Frequency);
|
HalMakeBeep (pbsp->Frequency);
|
||||||
InterlockedExchange(&(pDeviceExtension->BeepOn), TRUE);
|
// InterlockedExchange (&(DeviceExtension->BeepOn), TRUE);
|
||||||
KeWaitForSingleObject (&(pDeviceExtension->Event),
|
DeviceExtension->BeepOn = TRUE;
|
||||||
|
KeWaitForSingleObject (&(DeviceExtension->Event),
|
||||||
Executive,
|
Executive,
|
||||||
KernelMode,
|
KernelMode,
|
||||||
FALSE,
|
FALSE,
|
||||||
|
@ -181,15 +182,17 @@ NTSTATUS BeepDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
}
|
}
|
||||||
else if (pbsp->Duration == (DWORD)-1)
|
else if (pbsp->Duration == (DWORD)-1)
|
||||||
{
|
{
|
||||||
if (pDeviceExtension->BeepOn)
|
if (DeviceExtension->BeepOn)
|
||||||
{
|
{
|
||||||
HalMakeBeep (0);
|
HalMakeBeep (0);
|
||||||
InterlockedExchange(&(pDeviceExtension->BeepOn), FALSE);
|
// InterlockedExchange (&(DeviceExtension->BeepOn), FALSE);
|
||||||
|
DeviceExtension->BeepOn = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HalMakeBeep (pbsp->Frequency);
|
HalMakeBeep (pbsp->Frequency);
|
||||||
InterlockedExchange(&(pDeviceExtension->BeepOn), TRUE);
|
// InterlockedExchange (&(DeviceExtension->BeepOn), TRUE);
|
||||||
|
DeviceExtension->BeepOn = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,9 +214,6 @@ NTSTATUS BeepDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
{
|
{
|
||||||
status = STATUS_NOT_IMPLEMENTED;
|
status = STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
status = STATUS_NOT_IMPLEMENTED;
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = status;
|
Irp->IoStatus.Status = status;
|
||||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
||||||
|
@ -228,7 +228,6 @@ NTSTATUS BeepUnload(PDRIVER_OBJECT DriverObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Called by the system to initalize the driver
|
* FUNCTION: Called by the system to initalize the driver
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -236,9 +235,12 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
* RegistryPath = path to our configuration entries
|
* RegistryPath = path to our configuration entries
|
||||||
* RETURNS: Success or failure
|
* RETURNS: Success or failure
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
STDCALL NTSTATUS
|
||||||
|
DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT pDeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
PDEVICE_EXTENSION pDeviceExtension;
|
PDEVICE_EXTENSION DeviceExtension;
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
ANSI_STRING ansi_device_name;
|
ANSI_STRING ansi_device_name;
|
||||||
UNICODE_STRING device_name;
|
UNICODE_STRING device_name;
|
||||||
|
@ -255,7 +257,7 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
FILE_DEVICE_BEEP,
|
FILE_DEVICE_BEEP,
|
||||||
0,
|
0,
|
||||||
FALSE,
|
FALSE,
|
||||||
&pDeviceObject);
|
&DeviceObject);
|
||||||
if (ret!=STATUS_SUCCESS)
|
if (ret!=STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
return (ret);
|
return (ret);
|
||||||
|
@ -273,15 +275,15 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
DriverObject->DriverUnload = BeepUnload;
|
DriverObject->DriverUnload = BeepUnload;
|
||||||
|
|
||||||
/* set up device extension */
|
/* set up device extension */
|
||||||
pDeviceObject->Flags |= DO_BUFFERED_IO;
|
// DeviceObject->Flags = DO_BUFFERED_IO;
|
||||||
pDeviceExtension = pDeviceObject->DeviceExtension;
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
pDeviceExtension->BeepOn = 0; /* FALSE */
|
DeviceExtension->BeepOn = FALSE;
|
||||||
|
|
||||||
KeInitializeDpc (&(pDeviceExtension->Dpc),
|
KeInitializeDpc (&(DeviceExtension->Dpc),
|
||||||
BeepDPC,
|
BeepDPC,
|
||||||
pDeviceExtension);
|
DeviceExtension);
|
||||||
KeInitializeTimer (&(pDeviceExtension->Timer));
|
KeInitializeTimer (&(DeviceExtension->Timer));
|
||||||
KeInitializeEvent (&(pDeviceExtension->Event),
|
KeInitializeEvent (&(DeviceExtension->Event),
|
||||||
SynchronizationEvent,
|
SynchronizationEvent,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
|
|
|
@ -1 +1,23 @@
|
||||||
all: beep.o
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
OBJECTS = beep.o ../../../ntoskrnl/ntoskrnl.a
|
||||||
|
|
||||||
|
all: beep.sys
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
beep.sys: $(OBJECTS)
|
||||||
|
$(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \
|
||||||
|
-Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
|
||||||
|
-Wl,--base-file,base.tmp $(OBJECTS)
|
||||||
|
- $(RM) junk.tmp
|
||||||
|
$(DLLTOOL) --dllname beep.sys --base-file base.tmp \
|
||||||
|
--output-exp temp.exp
|
||||||
|
- $(RM) base.tmp
|
||||||
|
$(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \
|
||||||
|
-specs=../../svc_specs -mdll -o beep.sys $(OBJECTS) -Wl,temp.exp
|
||||||
|
- $(RM) temp.exp
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue