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 "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#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"
|
2007-10-31 01:02:00 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl);
|
|
|
|
|
|
|
|
#ifdef __i386__
|
2019-02-27 17:13:28 +01:00
|
|
|
#define DEFINE_FASTCALL1_WRAPPER(func) \
|
2019-03-01 10:30:56 +01:00
|
|
|
__ASM_STDCALL_FUNC( __fastcall_ ## func, 4, \
|
2007-10-31 01:02:00 +01:00
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
2019-02-27 17:13:28 +01:00
|
|
|
"jmp " __ASM_NAME(#func) __ASM_STDCALL(4) )
|
|
|
|
#define DEFINE_FASTCALL_WRAPPER(func,args) \
|
2019-03-01 10:30:56 +01:00
|
|
|
__ASM_STDCALL_FUNC( __fastcall_ ## func, args, \
|
2007-10-31 01:02:00 +01:00
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %edx\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
2019-02-27 17:13:28 +01:00
|
|
|
"jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
|
|
|
|
#else
|
|
|
|
#define DEFINE_FASTCALL1_WRAPPER(func) /* nothing */
|
|
|
|
#define DEFINE_FASTCALL_WRAPPER(func,args) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __i386__
|
2007-10-31 01:02:00 +01:00
|
|
|
|
2019-01-29 02:21:14 +01:00
|
|
|
extern void * WINAPI call_fastcall_func1( void *func, const void *a );
|
|
|
|
__ASM_STDCALL_FUNC( call_fastcall_func1, 8,
|
|
|
|
"popl %ecx\n\t"
|
|
|
|
"popl %eax\n\t"
|
|
|
|
"xchgl (%esp),%ecx\n\t"
|
|
|
|
"jmp *%eax" );
|
|
|
|
|
|
|
|
extern void * WINAPI call_fastcall_func2( void *func, const void *a, const void *b );
|
|
|
|
__ASM_STDCALL_FUNC( call_fastcall_func2, 12,
|
|
|
|
"popl %edx\n\t"
|
|
|
|
"popl %eax\n\t"
|
|
|
|
"popl %ecx\n\t"
|
|
|
|
"xchgl (%esp),%edx\n\t"
|
|
|
|
"jmp *%eax" );
|
|
|
|
|
2019-01-30 05:01:46 +01:00
|
|
|
extern void WINAPI ExAcquireFastMutexUnsafe( FAST_MUTEX * );
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( ExAcquireFastMutex )
|
|
|
|
void WINAPI 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-01-30 05:01:46 +01:00
|
|
|
extern void WINAPI ExReleaseFastMutexUnsafe( FAST_MUTEX * );
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( ExReleaseFastMutex )
|
|
|
|
void WINAPI 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 )
|
|
|
|
BOOLEAN WINAPI 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 )
|
|
|
|
KIRQL WINAPI 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 )
|
|
|
|
void WINAPI 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
|
|
|
|
|
|
|
extern void WINAPI KeAcquireInStackQueuedSpinLockAtDpcLevel( KSPIN_LOCK *, KLOCK_QUEUE_HANDLE * );
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( KeAcquireInStackQueuedSpinLock, 8 )
|
|
|
|
void WINAPI KeAcquireInStackQueuedSpinLock( KSPIN_LOCK *lock, KLOCK_QUEUE_HANDLE *queue )
|
2019-01-29 02:21:14 +01:00
|
|
|
{
|
|
|
|
call_fastcall_func2( KeAcquireInStackQueuedSpinLockAtDpcLevel, lock, queue );
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void WINAPI KeReleaseInStackQueuedSpinLockFromDpcLevel( KLOCK_QUEUE_HANDLE * );
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( KeReleaseInStackQueuedSpinLock )
|
|
|
|
void WINAPI 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 )
|
2007-10-31 01:02:00 +01:00
|
|
|
VOID WINAPI KfLowerIrql(KIRQL NewIrql)
|
|
|
|
{
|
|
|
|
FIXME( "(%u) stub!\n", NewIrql );
|
|
|
|
}
|
|
|
|
|
2019-02-27 17:13:28 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( KfRaiseIrql )
|
2007-10-31 01:02:00 +01:00
|
|
|
KIRQL WINAPI KfRaiseIrql(KIRQL NewIrql)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
FIXME("(%p %d) stub!\n", port, value);
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
FIXME("(%u %u %u %p %u) stub!\n", BusDataType, BusNumber, SlotNumber, Buffer, Length);
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
FIXME("(%u %u %u %p %u %u) stub!\n", BusDataType, BusNumber, SlotNumber, Buffer, Offset, Length);
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
FIXME("(%d %d %s %p %p) stub!\n", InterfaceType, BusNumber,
|
|
|
|
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;
|
|
|
|
}
|