2007-10-31 01:02:00 +01:00
|
|
|
/*
|
|
|
|
* hal.dll implementation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Chris Wulff
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
2019-01-24 06:50:34 +01:00
|
|
|
#include "winbase.h"
|
2007-10-31 01:02:00 +01:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "excpt.h"
|
2008-03-06 13:28:27 +01:00
|
|
|
#include "ddk/ntddk.h"
|
2019-05-14 12:30:46 +02:00
|
|
|
#include "wine/asm.h"
|
2007-10-31 01:02:00 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl);
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
#ifdef __i386__
|
2007-10-31 01:02:00 +01:00
|
|
|
|
2021-10-13 21:13:27 +02:00
|
|
|
#ifdef __ASM_USE_FASTCALL_WRAPPER
|
2019-05-16 10:15:26 +02:00
|
|
|
|
|
|
|
extern void * WINAPI wrap_fastcall_func1( void *func, const void *a );
|
|
|
|
__ASM_STDCALL_FUNC( wrap_fastcall_func1, 8,
|
2019-01-29 02:21:14 +01:00
|
|
|
"popl %ecx\n\t"
|
|
|
|
"popl %eax\n\t"
|
|
|
|
"xchgl (%esp),%ecx\n\t"
|
|
|
|
"jmp *%eax" );
|
2019-05-16 10:15:26 +02:00
|
|
|
extern void * WINAPI wrap_fastcall_func2( void *func, const void *a, const void *b );
|
|
|
|
__ASM_STDCALL_FUNC( wrap_fastcall_func2, 12,
|
2019-01-29 02:21:14 +01:00
|
|
|
"popl %edx\n\t"
|
|
|
|
"popl %eax\n\t"
|
|
|
|
"popl %ecx\n\t"
|
|
|
|
"xchgl (%esp),%edx\n\t"
|
|
|
|
"jmp *%eax" );
|
|
|
|
|
2019-05-16 10:15:26 +02:00
|
|
|
#define call_fastcall_func1(func,a) wrap_fastcall_func1(func,a)
|
|
|
|
#define call_fastcall_func2(func,a,b) wrap_fastcall_func2(func,a,b)
|
|
|
|
|
2021-10-13 21:13:27 +02:00
|
|
|
#else /* __ASM_USE_FASTCALL_WRAPPER */
|
2019-05-16 10:15:26 +02:00
|
|
|
|
|
|
|
#define call_fastcall_func1(func,a) func(a)
|
|
|
|
#define call_fastcall_func2(func,a,b) func(a,b)
|
|
|
|
|
2021-10-13 21:13:27 +02:00
|
|
|
#endif /* __ASM_USE_FASTCALL_WRAPPER */
|
2019-01-30 05:01:46 +01:00
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( ExAcquireFastMutex )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL ExAcquireFastMutex( FAST_MUTEX *mutex )
|
2008-12-09 04:19:34 +01:00
|
|
|
{
|
2019-01-30 05:01:46 +01:00
|
|
|
call_fastcall_func1( ExAcquireFastMutexUnsafe, mutex );
|
2008-12-09 04:19:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( ExReleaseFastMutex )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL ExReleaseFastMutex( FAST_MUTEX *mutex )
|
2008-12-09 04:19:34 +01:00
|
|
|
{
|
2019-01-30 05:01:46 +01:00
|
|
|
call_fastcall_func1( ExReleaseFastMutexUnsafe, mutex );
|
2008-12-09 04:19:34 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( ExTryToAcquireFastMutex )
|
2019-05-16 10:15:26 +02:00
|
|
|
BOOLEAN FASTCALL ExTryToAcquireFastMutex( FAST_MUTEX *mutex )
|
2010-09-22 18:04:53 +02:00
|
|
|
{
|
2019-01-30 05:01:47 +01:00
|
|
|
TRACE("mutex %p.\n", mutex);
|
|
|
|
|
|
|
|
return (InterlockedCompareExchange( &mutex->Count, 0, 1 ) == 1);
|
2010-09-22 18:04:53 +02:00
|
|
|
}
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( KfAcquireSpinLock )
|
2019-05-16 10:15:26 +02:00
|
|
|
KIRQL FASTCALL KfAcquireSpinLock( KSPIN_LOCK *lock )
|
2007-10-31 01:02:00 +01:00
|
|
|
{
|
2019-01-24 06:50:36 +01:00
|
|
|
KIRQL irql;
|
|
|
|
KeAcquireSpinLock( lock, &irql );
|
|
|
|
return irql;
|
|
|
|
}
|
2007-10-31 01:02:00 +01:00
|
|
|
|
2019-01-24 06:50:36 +01:00
|
|
|
void WINAPI KeAcquireSpinLock( KSPIN_LOCK *lock, KIRQL *irql )
|
|
|
|
{
|
|
|
|
TRACE("lock %p, irql %p.\n", lock, irql);
|
2019-01-28 03:45:34 +01:00
|
|
|
KeAcquireSpinLockAtDpcLevel( lock );
|
2019-01-24 06:50:36 +01:00
|
|
|
*irql = 0;
|
2007-10-31 01:02:00 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( KfReleaseSpinLock, 8 )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL KfReleaseSpinLock( KSPIN_LOCK *lock, KIRQL irql )
|
2019-01-24 06:50:32 +01:00
|
|
|
{
|
2019-01-24 06:50:34 +01:00
|
|
|
KeReleaseSpinLock( lock, irql );
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI KeReleaseSpinLock( KSPIN_LOCK *lock, KIRQL irql )
|
|
|
|
{
|
|
|
|
TRACE("lock %p, irql %u.\n", lock, irql);
|
2019-01-28 03:45:34 +01:00
|
|
|
KeReleaseSpinLockFromDpcLevel( lock );
|
2019-01-24 06:50:32 +01:00
|
|
|
}
|
2019-01-29 02:21:14 +01:00
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( KeAcquireInStackQueuedSpinLock, 8 )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL KeAcquireInStackQueuedSpinLock( KSPIN_LOCK *lock, KLOCK_QUEUE_HANDLE *queue )
|
2019-01-29 02:21:14 +01:00
|
|
|
{
|
|
|
|
call_fastcall_func2( KeAcquireInStackQueuedSpinLockAtDpcLevel, lock, queue );
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( KeReleaseInStackQueuedSpinLock )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL KeReleaseInStackQueuedSpinLock( KLOCK_QUEUE_HANDLE *queue )
|
2019-01-29 02:21:14 +01:00
|
|
|
{
|
|
|
|
call_fastcall_func1( KeReleaseInStackQueuedSpinLockFromDpcLevel, queue );
|
|
|
|
}
|
2019-01-24 06:50:32 +01:00
|
|
|
#endif /* __i386__ */
|
2007-10-31 01:02:00 +01:00
|
|
|
|
2019-01-24 06:50:32 +01:00
|
|
|
#if defined(__i386__) || defined(__arm__) || defined(__aarch64__)
|
2019-02-27 17:13:28 +01:00
|
|
|
|
|
|
|
DEFINE_FASTCALL1_WRAPPER( KfLowerIrql )
|
2019-05-16 10:15:26 +02:00
|
|
|
VOID FASTCALL KfLowerIrql(KIRQL NewIrql)
|
2007-10-31 01:02:00 +01:00
|
|
|
{
|
|
|
|
FIXME( "(%u) stub!\n", NewIrql );
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( KfRaiseIrql )
|
2019-05-16 10:15:26 +02:00
|
|
|
KIRQL FASTCALL KfRaiseIrql(KIRQL NewIrql)
|
2007-10-31 01:02:00 +01:00
|
|
|
{
|
|
|
|
FIXME( "(%u) stub!\n", NewIrql );
|
|
|
|
|
2008-12-05 07:45:49 +01:00
|
|
|
return 0;
|
2007-10-31 01:02:00 +01:00
|
|
|
}
|
|
|
|
|
2009-07-09 01:57:06 +02:00
|
|
|
KIRQL WINAPI KeGetCurrentIrql(VOID)
|
|
|
|
{
|
|
|
|
FIXME( " stub!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2015-12-23 02:35:00 +01:00
|
|
|
|
2016-04-26 06:47:05 +02:00
|
|
|
UCHAR WINAPI READ_PORT_UCHAR(UCHAR *port)
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub!\n", port);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-23 02:35:00 +01:00
|
|
|
ULONG WINAPI READ_PORT_ULONG(ULONG *port)
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub!\n", port);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-26 06:47:28 +02:00
|
|
|
|
2016-08-16 22:30:20 +02:00
|
|
|
void WINAPI WRITE_PORT_UCHAR(UCHAR *port, UCHAR value)
|
|
|
|
{
|
|
|
|
FIXME("(%p %d) stub!\n", port, value);
|
|
|
|
}
|
|
|
|
|
2016-04-26 06:47:28 +02:00
|
|
|
void WINAPI WRITE_PORT_ULONG(ULONG *port, ULONG value)
|
|
|
|
{
|
2022-02-10 08:43:25 +01:00
|
|
|
FIXME("(%p %ld) stub!\n", port, value);
|
2016-04-26 06:47:28 +02:00
|
|
|
}
|
2019-01-24 06:50:32 +01:00
|
|
|
#endif /* __i386__ || __arm__ || __arm64__ */
|
|
|
|
|
|
|
|
ULONG WINAPI HalGetBusData(BUS_DATA_TYPE BusDataType, ULONG BusNumber, ULONG SlotNumber, PVOID Buffer, ULONG Length)
|
|
|
|
{
|
2022-02-10 08:43:25 +01:00
|
|
|
FIXME("(%u %lu %lu %p %lu) stub!\n", BusDataType, BusNumber, SlotNumber, Buffer, Length);
|
2019-01-24 06:50:32 +01:00
|
|
|
/* Claim that there is no such bus */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI HalGetBusDataByOffset(BUS_DATA_TYPE BusDataType, ULONG BusNumber, ULONG SlotNumber, PVOID Buffer, ULONG Offset, ULONG Length)
|
|
|
|
{
|
2022-02-10 08:43:25 +01:00
|
|
|
FIXME("(%u %lu %lu %p %lu %lu) stub!\n", BusDataType, BusNumber, SlotNumber, Buffer, Offset, Length);
|
2019-01-24 06:50:32 +01:00
|
|
|
/* Claim that there is no such bus */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN WINAPI HalTranslateBusAddress(INTERFACE_TYPE InterfaceType, ULONG BusNumber, PHYSICAL_ADDRESS BusAddress,
|
|
|
|
PULONG AddressSpace, PPHYSICAL_ADDRESS TranslatedAddress)
|
|
|
|
{
|
2022-02-10 08:43:25 +01:00
|
|
|
FIXME("(%d %ld %s %p %p) stub!\n", InterfaceType, BusNumber,
|
2019-01-24 06:50:32 +01:00
|
|
|
wine_dbgstr_longlong(BusAddress.QuadPart), AddressSpace, TranslatedAddress);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2018-02-28 01:29:41 +01:00
|
|
|
|
|
|
|
ULONGLONG WINAPI KeQueryPerformanceCounter(LARGE_INTEGER *frequency)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER counter;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", frequency);
|
|
|
|
|
|
|
|
NtQueryPerformanceCounter(&counter, frequency);
|
|
|
|
return counter.QuadPart;
|
|
|
|
}
|