mirror of
https://github.com/winfsp/winfsp.git
synced 2025-07-02 00:42:54 -05:00
ARM64: initial port
This commit is contained in:
@ -442,13 +442,13 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
||||
|
||||
/* initialize our timer routine and start our expiration timer */
|
||||
#pragma prefast(suppress:28133, "We are a filesystem: we do not have AddDevice")
|
||||
Result = IoInitializeTimer(DeviceObject, FspFsvolDeviceTimerRoutine, 0);
|
||||
Result = FspDeviceInitializeTimer(DeviceObject, FspFsvolDeviceTimerRoutine, 0);
|
||||
if (!NT_SUCCESS(Result))
|
||||
return Result;
|
||||
KeInitializeSpinLock(&FsvolDeviceExtension->ExpirationLock);
|
||||
ExInitializeWorkItem(&FsvolDeviceExtension->ExpirationWorkItem,
|
||||
FspFsvolDeviceExpirationRoutine, DeviceObject);
|
||||
IoStartTimer(DeviceObject);
|
||||
FspDeviceStartTimer(DeviceObject);
|
||||
FsvolDeviceExtension->InitDoneTimer = 1;
|
||||
|
||||
/* initialize the volume information */
|
||||
@ -472,7 +472,7 @@ static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject)
|
||||
* references our DeviceObject before queueing work items.
|
||||
*/
|
||||
if (FsvolDeviceExtension->InitDoneTimer)
|
||||
IoStopTimer(DeviceObject);
|
||||
FspDeviceStopTimer(DeviceObject);
|
||||
|
||||
/* delete the file system statistics */
|
||||
if (FsvolDeviceExtension->InitDoneStat)
|
||||
|
124
src/sys/devtimer.c
Normal file
124
src/sys/devtimer.c
Normal file
@ -0,0 +1,124 @@
|
||||
/**
|
||||
* @file sys/devtimer.c
|
||||
*
|
||||
* @copyright 2015-2021 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
*
|
||||
* You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License version 3 as published by the Free Software
|
||||
* Foundation.
|
||||
*
|
||||
* Licensees holding a valid commercial license may use this software
|
||||
* in accordance with the commercial license agreement provided in
|
||||
* conjunction with the software. The terms and conditions of any such
|
||||
* commercial license agreement shall govern, supersede, and render
|
||||
* ineffective any application of the GPLv3 license to this software,
|
||||
* notwithstanding of any reference thereto in the software or
|
||||
* associated repository.
|
||||
*/
|
||||
|
||||
#include <sys/driver.h>
|
||||
|
||||
/*
|
||||
* IoTimer Emulation.
|
||||
*
|
||||
* This is required because IoInitializeTimer and friends is missing from Windows on ARM64.
|
||||
*/
|
||||
|
||||
static LIST_ENTRY FspDeviceTimerList;
|
||||
static KSPIN_LOCK FspDeviceTimerLock;
|
||||
static KDPC FspDeviceTimerDpc;
|
||||
static KTIMER FspDeviceTimer;
|
||||
|
||||
static KDEFERRED_ROUTINE FspDeviceTimerRoutine;
|
||||
|
||||
NTSTATUS FspDeviceInitializeAllTimers(VOID)
|
||||
{
|
||||
LARGE_INTEGER DueTime;
|
||||
LONG Period;
|
||||
|
||||
InitializeListHead(&FspDeviceTimerList);
|
||||
KeInitializeSpinLock(&FspDeviceTimerLock);
|
||||
|
||||
KeInitializeDpc(&FspDeviceTimerDpc, FspDeviceTimerRoutine, 0);
|
||||
KeInitializeTimerEx(&FspDeviceTimer, SynchronizationTimer);
|
||||
|
||||
DueTime.QuadPart = 1000/*ms*/ * -10000;
|
||||
Period = 1000/*ms*/;
|
||||
KeSetTimerEx(&FspDeviceTimer, DueTime, Period, &FspDeviceTimerDpc);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID FspDeviceFinalizeAllTimers(VOID)
|
||||
{
|
||||
KeCancelTimer(&FspDeviceTimer);
|
||||
|
||||
#if DBG
|
||||
KIRQL Irql;
|
||||
KeAcquireSpinLock(&FspDeviceTimerLock, &Irql);
|
||||
ASSERT(IsListEmpty(&FspDeviceTimerList));
|
||||
KeReleaseSpinLock(&FspDeviceTimerLock, Irql);
|
||||
#endif
|
||||
}
|
||||
|
||||
static VOID FspDeviceTimerRoutine(
|
||||
PKDPC Dpc,
|
||||
PVOID DeferredContext,
|
||||
PVOID SystemArgument1,
|
||||
PVOID SystemArgument2)
|
||||
{
|
||||
FSP_DEVICE_TIMER *Timer;
|
||||
PLIST_ENTRY ListEntry;
|
||||
KIRQL Irql;
|
||||
|
||||
KeAcquireSpinLock(&FspDeviceTimerLock, &Irql);
|
||||
for (ListEntry = FspDeviceTimerList.Flink;
|
||||
&FspDeviceTimerList != ListEntry;
|
||||
ListEntry = ListEntry->Flink)
|
||||
{
|
||||
Timer = CONTAINING_RECORD(ListEntry, FSP_DEVICE_TIMER, ListEntry);
|
||||
Timer->TimerRoutine(Timer->DeviceObject, Timer->Context);
|
||||
}
|
||||
KeReleaseSpinLock(&FspDeviceTimerLock, Irql);
|
||||
}
|
||||
|
||||
NTSTATUS FspDeviceInitializeTimer(PDEVICE_OBJECT DeviceObject,
|
||||
PIO_TIMER_ROUTINE TimerRoutine, PVOID Context)
|
||||
{
|
||||
FSP_DEVICE_EXTENSION *DeviceExtension;
|
||||
|
||||
DeviceExtension = FspDeviceExtension(DeviceObject);
|
||||
|
||||
DeviceExtension->DeviceTimer.TimerRoutine = TimerRoutine;
|
||||
DeviceExtension->DeviceTimer.DeviceObject = DeviceObject;
|
||||
DeviceExtension->DeviceTimer.Context = Context;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID FspDeviceStartTimer(PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
FSP_DEVICE_EXTENSION *DeviceExtension;
|
||||
KIRQL Irql;
|
||||
|
||||
DeviceExtension = FspDeviceExtension(DeviceObject);
|
||||
|
||||
KeAcquireSpinLock(&FspDeviceTimerLock, &Irql);
|
||||
InsertTailList(&FspDeviceTimerList, &DeviceExtension->DeviceTimer.ListEntry);
|
||||
KeReleaseSpinLock(&FspDeviceTimerLock, Irql);
|
||||
}
|
||||
|
||||
VOID FspDeviceStopTimer(PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
FSP_DEVICE_EXTENSION *DeviceExtension;
|
||||
KIRQL Irql;
|
||||
|
||||
DeviceExtension = FspDeviceExtension(DeviceObject);
|
||||
|
||||
KeAcquireSpinLock(&FspDeviceTimerLock, &Irql);
|
||||
RemoveEntryList(&DeviceExtension->DeviceTimer.ListEntry);
|
||||
KeReleaseSpinLock(&FspDeviceTimerLock, Irql);
|
||||
}
|
@ -123,7 +123,7 @@ NTSTATUS DriverEntry(
|
||||
DriverObject->FastIoDispatch = &FspFastIoDispatch;
|
||||
|
||||
BOOLEAN InitDoneGRes = FALSE, InitDoneSilo = FALSE, InitDonePsBuf = FALSE,
|
||||
InitDoneDevices = FALSE;
|
||||
InitDoneTimers = FALSE, InitDoneDevices = FALSE;
|
||||
|
||||
FspDriverObject = DriverObject;
|
||||
FspDriverMultiVersionInitialize();
|
||||
@ -141,6 +141,11 @@ NTSTATUS DriverEntry(
|
||||
goto exit;
|
||||
InitDonePsBuf = TRUE;
|
||||
|
||||
Result = FspDeviceInitializeAllTimers();
|
||||
if (!NT_SUCCESS(Result))
|
||||
goto exit;
|
||||
InitDoneTimers = TRUE;
|
||||
|
||||
Result = FspDriverInitializeDevices();
|
||||
if (!NT_SUCCESS(Result))
|
||||
goto exit;
|
||||
@ -153,6 +158,8 @@ exit:
|
||||
{
|
||||
if (InitDoneDevices)
|
||||
FspDriverFinalizeDevices();
|
||||
if (InitDoneTimers)
|
||||
FspDeviceFinalizeAllTimers();
|
||||
if (InitDonePsBuf)
|
||||
FspProcessBufferFinalize();
|
||||
if (InitDoneSilo)
|
||||
|
@ -1117,6 +1117,13 @@ enum
|
||||
FspFsvolDeviceEaCacheItemSizeMax = FSP_FSCTL_ALIGN_UP(16384, PAGE_SIZE),
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
PIO_TIMER_ROUTINE TimerRoutine;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PVOID Context;
|
||||
} FSP_DEVICE_TIMER;
|
||||
typedef struct
|
||||
{
|
||||
PUNICODE_STRING FileName;
|
||||
PVOID Context;
|
||||
@ -1144,6 +1151,8 @@ typedef struct
|
||||
LONG RefCount;
|
||||
UINT32 Kind;
|
||||
GUID SiloContainerId;
|
||||
/* IoTimer emulation */
|
||||
FSP_DEVICE_TIMER DeviceTimer;
|
||||
} FSP_DEVICE_EXTENSION;
|
||||
typedef struct
|
||||
{
|
||||
@ -1295,6 +1304,12 @@ NTSTATUS FspDeviceCopyList(
|
||||
VOID FspDeviceDeleteList(
|
||||
PDEVICE_OBJECT *DeviceObjects, ULONG DeviceObjectCount);
|
||||
VOID FspDeviceDeleteAll(VOID);
|
||||
NTSTATUS FspDeviceInitializeAllTimers(VOID);
|
||||
VOID FspDeviceFinalizeAllTimers(VOID);
|
||||
NTSTATUS FspDeviceInitializeTimer(PDEVICE_OBJECT DeviceObject,
|
||||
PIO_TIMER_ROUTINE TimerRoutine, PVOID Context);
|
||||
VOID FspDeviceStartTimer(PDEVICE_OBJECT DeviceObject);
|
||||
VOID FspDeviceStopTimer(PDEVICE_OBJECT DeviceObject);
|
||||
static inline
|
||||
VOID FspDeviceGlobalLock(VOID)
|
||||
{
|
||||
|
Reference in New Issue
Block a user