ntoskrnl header cleanups

svn path=/trunk/; revision=17847
This commit is contained in:
Alex Ionescu 2005-09-14 01:44:19 +00:00
parent e8dcb74344
commit e0eea608a6
26 changed files with 757 additions and 461 deletions

View file

@ -20,6 +20,12 @@
#define I386_INTERRUPT_GATE 0xE #define I386_INTERRUPT_GATE 0xE
#define I386_TRAP_GATE 0xF #define I386_TRAP_GATE 0xF
#define IPI_APC 1
#define IPI_DPC 2
#define IPI_FREEZE 3
#define IPI_PACKET_READY 4
#define IPI_SYNCH_REQUEST 10
/* EXPORTED DATA *************************************************************/ /* EXPORTED DATA *************************************************************/
/* ENUMERATIONS **************************************************************/ /* ENUMERATIONS **************************************************************/

View file

@ -16,6 +16,7 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID
NTAPI
CcInit(VOID) CcInit(VOID)
{ {
CcInitView(); CcInitView();

View file

@ -39,6 +39,7 @@ ULONG CcFastReadResourceMiss;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID
NTAPI
CcInitCacheZeroPage(VOID) CcInitCacheZeroPage(VOID)
{ {
NTSTATUS Status; NTSTATUS Status;
@ -58,6 +59,7 @@ CcInitCacheZeroPage(VOID)
} }
NTSTATUS NTSTATUS
NTAPI
ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length, ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
PVOID Buffer) PVOID Buffer)
{ {
@ -187,6 +189,7 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
} }
NTSTATUS NTSTATUS
NTAPI
ReadCacheSegment(PCACHE_SEGMENT CacheSeg) ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
{ {
ULONG Size; ULONG Size;
@ -228,6 +231,7 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
} }
NTSTATUS NTSTATUS
NTAPI
WriteCacheSegment(PCACHE_SEGMENT CacheSeg) WriteCacheSegment(PCACHE_SEGMENT CacheSeg)
{ {
ULONG Size; ULONG Size;

View file

@ -159,6 +159,7 @@ CcRosTraceCacheMap (
} }
NTSTATUS NTSTATUS
NTAPI
CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment) CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment)
{ {
NTSTATUS Status; NTSTATUS Status;
@ -179,6 +180,7 @@ CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment)
} }
NTSTATUS NTSTATUS
NTAPI
CcRosFlushDirtyPages(ULONG Target, PULONG Count) CcRosFlushDirtyPages(ULONG Target, PULONG Count)
{ {
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
@ -355,6 +357,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
} }
NTSTATUS NTSTATUS
NTAPI
CcRosReleaseCacheSegment(PBCB Bcb, CcRosReleaseCacheSegment(PBCB Bcb,
PCACHE_SEGMENT CacheSeg, PCACHE_SEGMENT CacheSeg,
BOOLEAN Valid, BOOLEAN Valid,
@ -403,6 +406,7 @@ CcRosReleaseCacheSegment(PBCB Bcb,
} }
PCACHE_SEGMENT PCACHE_SEGMENT
NTAPI
CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset) CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset)
{ {
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
@ -434,6 +438,7 @@ CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset)
} }
NTSTATUS NTSTATUS
NTAPI
CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset) CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset)
{ {
PCACHE_SEGMENT CacheSeg; PCACHE_SEGMENT CacheSeg;
@ -470,6 +475,7 @@ CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset)
} }
NTSTATUS NTSTATUS
NTAPI
CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty) CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
{ {
PCACHE_SEGMENT CacheSeg; PCACHE_SEGMENT CacheSeg;
@ -689,6 +695,7 @@ CcRosCreateCacheSegment(PBCB Bcb,
} }
NTSTATUS NTSTATUS
NTAPI
CcRosGetCacheSegmentChain(PBCB Bcb, CcRosGetCacheSegmentChain(PBCB Bcb,
ULONG FileOffset, ULONG FileOffset,
ULONG Length, ULONG Length,
@ -752,6 +759,7 @@ CcRosGetCacheSegmentChain(PBCB Bcb,
} }
NTSTATUS NTSTATUS
NTAPI
CcRosGetCacheSegment(PBCB Bcb, CcRosGetCacheSegment(PBCB Bcb,
ULONG FileOffset, ULONG FileOffset,
PULONG BaseOffset, PULONG BaseOffset,
@ -889,6 +897,7 @@ CcRosInternalFreeCacheSegment(PCACHE_SEGMENT CacheSeg)
} }
NTSTATUS NTSTATUS
NTAPI
CcRosFreeCacheSegment(PBCB Bcb, PCACHE_SEGMENT CacheSeg) CcRosFreeCacheSegment(PBCB Bcb, PCACHE_SEGMENT CacheSeg)
{ {
NTSTATUS Status; NTSTATUS Status;
@ -995,6 +1004,7 @@ CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers,
} }
NTSTATUS NTSTATUS
NTAPI
CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb) CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
/* /*
* FUNCTION: Releases the BCB associated with a file object * FUNCTION: Releases the BCB associated with a file object
@ -1065,7 +1075,9 @@ CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
VOID CcRosReferenceCache(PFILE_OBJECT FileObject) VOID
NTAPI
CcRosReferenceCache(PFILE_OBJECT FileObject)
{ {
PBCB Bcb; PBCB Bcb;
ExAcquireFastMutex(&ViewLock); ExAcquireFastMutex(&ViewLock);
@ -1086,7 +1098,9 @@ VOID CcRosReferenceCache(PFILE_OBJECT FileObject)
ExReleaseFastMutex(&ViewLock); ExReleaseFastMutex(&ViewLock);
} }
VOID CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer) VOID
NTAPI
CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer)
{ {
PBCB Bcb; PBCB Bcb;
DPRINT("CcRosSetRemoveOnClose()\n"); DPRINT("CcRosSetRemoveOnClose()\n");
@ -1104,7 +1118,9 @@ VOID CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer)
} }
VOID CcRosDereferenceCache(PFILE_OBJECT FileObject) VOID
NTAPI
CcRosDereferenceCache(PFILE_OBJECT FileObject)
{ {
PBCB Bcb; PBCB Bcb;
ExAcquireFastMutex(&ViewLock); ExAcquireFastMutex(&ViewLock);
@ -1171,6 +1187,7 @@ CcRosReleaseFileCache(PFILE_OBJECT FileObject)
} }
NTSTATUS NTSTATUS
NTAPI
CcTryToInitializeFileCache(PFILE_OBJECT FileObject) CcTryToInitializeFileCache(PFILE_OBJECT FileObject)
{ {
PBCB Bcb; PBCB Bcb;
@ -1328,7 +1345,9 @@ CmLazyCloseThreadMain(PVOID Ignored)
} }
} }
VOID INIT_FUNCTION VOID
INIT_FUNCTION
NTAPI
CcInitView(VOID) CcInitView(VOID)
{ {
#ifdef CACHE_BITMAP #ifdef CACHE_BITMAP

View file

@ -77,36 +77,45 @@ CcMdlWriteCompleteDev(
); );
NTSTATUS NTSTATUS
NTAPI
CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment); CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment);
NTSTATUS NTSTATUS
NTAPI
CcRosGetCacheSegment( CcRosGetCacheSegment(
PBCB Bcb, PBCB Bcb,
ULONG FileOffset, ULONG FileOffset,
PULONG BaseOffset, PULONG BaseOffset,
PVOID* BaseAddress, PVOID *BaseAddress,
PBOOLEAN UptoDate, PBOOLEAN UptoDate,
PCACHE_SEGMENT* CacheSeg PCACHE_SEGMENT *CacheSeg
); );
VOID VOID
NTAPI
CcInitView(VOID); CcInitView(VOID);
NTSTATUS NTSTATUS
NTAPI
CcRosFreeCacheSegment( CcRosFreeCacheSegment(
PBCB, PBCB,
PCACHE_SEGMENT PCACHE_SEGMENT
); );
NTSTATUS NTSTATUS
NTAPI
ReadCacheSegment(PCACHE_SEGMENT CacheSeg); ReadCacheSegment(PCACHE_SEGMENT CacheSeg);
NTSTATUS NTSTATUS
NTAPI
WriteCacheSegment(PCACHE_SEGMENT CacheSeg); WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
VOID CcInit(VOID); VOID
NTAPI
CcInit(VOID);
NTSTATUS NTSTATUS
NTAPI
CcRosUnmapCacheSegment( CcRosUnmapCacheSegment(
PBCB Bcb, PBCB Bcb,
ULONG FileOffset, ULONG FileOffset,
@ -114,12 +123,14 @@ CcRosUnmapCacheSegment(
); );
PCACHE_SEGMENT PCACHE_SEGMENT
NTAPI
CcRosLookupCacheSegment( CcRosLookupCacheSegment(
PBCB Bcb, PBCB Bcb,
ULONG FileOffset ULONG FileOffset
); );
NTSTATUS NTSTATUS
NTAPI
CcRosGetCacheSegmentChain( CcRosGetCacheSegmentChain(
PBCB Bcb, PBCB Bcb,
ULONG FileOffset, ULONG FileOffset,
@ -128,49 +139,57 @@ CcRosGetCacheSegmentChain(
); );
VOID VOID
NTAPI
CcInitCacheZeroPage(VOID); CcInitCacheZeroPage(VOID);
NTSTATUS NTSTATUS
NTAPI
CcRosMarkDirtyCacheSegment( CcRosMarkDirtyCacheSegment(
PBCB Bcb, PBCB Bcb,
ULONG FileOffset ULONG FileOffset
); );
NTSTATUS NTSTATUS
NTAPI
CcRosFlushDirtyPages( CcRosFlushDirtyPages(
ULONG Target, ULONG Target,
PULONG Count PULONG Count
); );
VOID VOID
NTAPI
CcRosDereferenceCache(PFILE_OBJECT FileObject); CcRosDereferenceCache(PFILE_OBJECT FileObject);
VOID VOID
NTAPI
CcRosReferenceCache(PFILE_OBJECT FileObject); CcRosReferenceCache(PFILE_OBJECT FileObject);
VOID VOID
NTAPI
CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer); CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer);
NTSTATUS NTSTATUS
NTAPI
CcRosReleaseCacheSegment( CcRosReleaseCacheSegment(
BCB* Bcb, BCB* Bcb,
CACHE_SEGMENT* CacheSeg, CACHE_SEGMENT *CacheSeg,
BOOLEAN Valid, BOOLEAN Valid,
BOOLEAN Dirty, BOOLEAN Dirty,
BOOLEAN Mapped BOOLEAN Mapped
); );
NTSTATUS NTSTATUS
STDCALL STDCALL
CcRosRequestCacheSegment( CcRosRequestCacheSegment(
BCB* Bcb, BCB *Bcb,
ULONG FileOffset, ULONG FileOffset,
PVOID* BaseAddress, PVOID* BaseAddress,
PBOOLEAN UptoDate, PBOOLEAN UptoDate,
CACHE_SEGMENT** CacheSeg CACHE_SEGMENT **CacheSeg
); );
NTSTATUS NTSTATUS
NTAPI
CcTryToInitializeFileCache(PFILE_OBJECT FileObject); CcTryToInitializeFileCache(PFILE_OBJECT FileObject);
/* /*

View file

@ -1,89 +0,0 @@
#ifndef __INCLUDE_INTERNAL_IFS_H
#define __INCLUDE_INTERNAL_IFS_H
typedef struct _FILE_LOCK_GRANTED {
LIST_ENTRY ListEntry;
FILE_LOCK_INFO Lock;
PVOID UnlockContext;
} FILE_LOCK_GRANTED, *PFILE_LOCK_GRANTED;
typedef struct _FILE_LOCK_TOC {
KSPIN_LOCK SpinLock;
LIST_ENTRY GrantedListHead;
LIST_ENTRY PendingListHead;
} FILE_LOCK_TOC, *PFILE_LOCK_TOC;
VOID
STDCALL INIT_FUNCTION
FsRtlpInitNotifyImplementation(VOID);
VOID STDCALL
FsRtlpInitFileLockingImplementation(VOID);
VOID STDCALL
FsRtlpFileLockCancelRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
BOOLEAN FASTCALL
FsRtlpCheckLockForReadOrWriteAccess(
IN PFILE_LOCK FileLock,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
IN ULONG Key,
IN PFILE_OBJECT FileObject,
IN PEPROCESS Process,
IN BOOLEAN Read
);
NTSTATUS FASTCALL
FsRtlpFastUnlockAllByKey(
IN PFILE_LOCK FileLock,
IN PFILE_OBJECT FileObject,
IN PEPROCESS Process,
IN DWORD Key, /* FIXME: guess */
IN BOOLEAN UseKey, /* FIXME: guess */
IN PVOID Context OPTIONAL
);
BOOLEAN FASTCALL
FsRtlpAddLock(
IN PFILE_LOCK_TOC LockToc,
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
IN PEPROCESS Process,
IN ULONG Key,
IN BOOLEAN ExclusiveLock,
IN PVOID UnlockContext
);
VOID FASTCALL
FsRtlpCompletePendingLocks(
IN PFILE_LOCK FileLock,
IN PFILE_LOCK_TOC LockToc,
IN OUT PKIRQL oldirql,
IN PVOID Context
);
NTSTATUS FASTCALL
FsRtlpUnlockSingle(
IN PFILE_LOCK FileLock,
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
IN PEPROCESS Process,
IN ULONG Key,
IN PVOID Context OPTIONAL,
IN BOOLEAN CallUnlockRoutine
);
VOID FASTCALL
FsRtlpDumpFileLocks(
IN PFILE_LOCK FileLock
);
#endif

View file

@ -0,0 +1,96 @@
#ifndef __INCLUDE_INTERNAL_IFS_H
#define __INCLUDE_INTERNAL_IFS_H
typedef struct _FILE_LOCK_GRANTED
{
LIST_ENTRY ListEntry;
FILE_LOCK_INFO Lock;
PVOID UnlockContext;
} FILE_LOCK_GRANTED, *PFILE_LOCK_GRANTED;
typedef struct _FILE_LOCK_TOC
{
KSPIN_LOCK SpinLock;
LIST_ENTRY GrantedListHead;
LIST_ENTRY PendingListHead;
} FILE_LOCK_TOC, *PFILE_LOCK_TOC;
VOID
INIT_FUNCTION
STDCALL
FsRtlpInitNotifyImplementation(VOID);
VOID
STDCALL
FsRtlpInitFileLockingImplementation(VOID);
VOID
STDCALL
FsRtlpFileLockCancelRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
BOOLEAN
FASTCALL
FsRtlpCheckLockForReadOrWriteAccess(
IN PFILE_LOCK FileLock,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
IN ULONG Key,
IN PFILE_OBJECT FileObject,
IN PEPROCESS Process,
IN BOOLEAN Read
);
NTSTATUS
FASTCALL
FsRtlpFastUnlockAllByKey(
IN PFILE_LOCK FileLock,
IN PFILE_OBJECT FileObject,
IN PEPROCESS Process,
IN DWORD Key,
IN BOOLEAN UseKey,
IN PVOID Context OPTIONAL
);
BOOLEAN
FASTCALL
FsRtlpAddLock(
IN PFILE_LOCK_TOC LockToc,
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
IN PEPROCESS Process,
IN ULONG Key,
IN BOOLEAN ExclusiveLock,
IN PVOID UnlockContext
);
VOID
FASTCALL
FsRtlpCompletePendingLocks(
IN PFILE_LOCK FileLock,
IN PFILE_LOCK_TOC LockToc,
IN OUT PKIRQL oldirql,
IN PVOID Context
);
NTSTATUS
FASTCALL
FsRtlpUnlockSingle(
IN PFILE_LOCK FileLock,
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
IN PEPROCESS Process,
IN ULONG Key,
IN PVOID Context OPTIONAL,
IN BOOLEAN CallUnlockRoutine
);
VOID
FASTCALL
FsRtlpDumpFileLocks(IN PFILE_LOCK FileLock);
#endif

View file

@ -71,6 +71,61 @@ typedef struct _KIRQ_TRAPFRAME
ULONG Eflags; ULONG Eflags;
} KIRQ_TRAPFRAME, *PKIRQ_TRAPFRAME; } KIRQ_TRAPFRAME, *PKIRQ_TRAPFRAME;
/* Emulate cli/sti instructions */
#define KV86M_EMULATE_CLI_STI (0x1)
/* Allow the v86 mode code to access i/o ports */
#define KV86M_ALLOW_IO_PORT_ACCESS (0x2)
typedef struct _KV86M_REGISTERS
{
/*
* General purpose registers
*/
ULONG Ebp;
ULONG Edi;
ULONG Esi;
ULONG Edx;
ULONG Ecx;
ULONG Ebx;
ULONG Eax;
ULONG Ds;
ULONG Es;
ULONG Fs;
ULONG Gs;
/*
* Control registers
*/
ULONG Eip;
ULONG Cs;
ULONG Eflags;
ULONG Esp;
ULONG Ss;
/*
* Control structures
*/
ULONG RecoveryAddress;
UCHAR RecoveryInstruction[4];
ULONG Vif;
ULONG Flags;
PNTSTATUS PStatus;
} KV86M_REGISTERS, *PKV86M_REGISTERS;
typedef struct _KV86M_TRAP_FRAME
{
KTRAP_FRAME Tf;
ULONG SavedExceptionStack;
/*
* These are put on the top of the stack by the routine that entered
* v86 mode so the exception handlers can find the control information
*/
struct _KV86M_REGISTERS* regs;
ULONG orig_ebp;
} KV86M_TRAP_FRAME, *PKV86M_TRAP_FRAME;
extern ULONG Ke386CacheAlignment; extern ULONG Ke386CacheAlignment;
struct _KPCR; struct _KPCR;

View file

@ -1,6 +1,8 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_IO_H #ifndef __NTOSKRNL_INCLUDE_INTERNAL_IO_H
#define __NTOSKRNL_INCLUDE_INTERNAL_IO_H #define __NTOSKRNL_INCLUDE_INTERNAL_IO_H
#include <ddk/ntdddisk.h>
#define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003) #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
extern POBJECT_TYPE IoCompletionType; extern POBJECT_TYPE IoCompletionType;
@ -478,4 +480,59 @@ IopInitIoCompletionImplementation(VOID);
: \ : \
FIELD_OFFSET(CM_RESOURCE_LIST, List) FIELD_OFFSET(CM_RESOURCE_LIST, List)
/* xhal.c */
NTSTATUS
FASTCALL
xHalQueryDriveLayout(
IN PUNICODE_STRING DeviceName,
OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo
);
#undef HalExamineMBR
VOID
FASTCALL
HalExamineMBR(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG MBRTypeIdentifier,
OUT PVOID *Buffer
);
VOID
FASTCALL
xHalIoAssignDriveLetters(
IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PSTRING NtDeviceName,
OUT PUCHAR NtSystemPath,
OUT PSTRING NtSystemPathString
);
NTSTATUS
FASTCALL
xHalIoReadPartitionTable(
PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
BOOLEAN ReturnRecognizedPartitions,
PDRIVE_LAYOUT_INFORMATION *PartitionBuffer
);
NTSTATUS
FASTCALL
xHalIoSetPartitionInformation(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG PartitionNumber,
IN ULONG PartitionType
);
NTSTATUS
FASTCALL
xHalIoWritePartitionTable(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG SectorsPerTrack,
IN ULONG NumberOfHeads,
IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer
);
#endif #endif

View file

@ -12,7 +12,23 @@ typedef struct _WOW64_PROCESS
PVOID Wow64; PVOID Wow64;
} WOW64_PROCESS, *PWOW64_PROCESS; } WOW64_PROCESS, *PWOW64_PROCESS;
/* INTERNAL KERNEL FUNCTIONS ************************************************/ typedef struct _KPROFILE_SOURCE_OBJECT
{
KPROFILE_SOURCE Source;
LIST_ENTRY ListEntry;
} KPROFILE_SOURCE_OBJECT, *PKPROFILE_SOURCE_OBJECT;
/* Cached modules from the loader block */
typedef enum _CACHED_MODULE_TYPE
{
AnsiCodepage,
OemCodepage,
UnicodeCasemap,
SystemRegistry,
HardwareRegistry,
MaximumCachedModuleType,
} CACHED_MODULE_TYPE, *PCACHED_MODULE_TYPE;
extern PLOADER_MODULE CachedModules[MaximumCachedModuleType];
struct _KIRQ_TRAPFRAME; struct _KIRQ_TRAPFRAME;
struct _KPCR; struct _KPCR;
@ -23,11 +39,8 @@ extern PVOID KeUserApcDispatcher;
extern PVOID KeUserCallbackDispatcher; extern PVOID KeUserCallbackDispatcher;
extern PVOID KeUserExceptionDispatcher; extern PVOID KeUserExceptionDispatcher;
extern PVOID KeRaiseUserExceptionDispatcher; extern PVOID KeRaiseUserExceptionDispatcher;
extern LARGE_INTEGER SystemBootTime;
#define IPI_REQUEST_FUNCTIONCALL 0 extern ULONG_PTR KERNEL_BASE;
#define IPI_REQUEST_APC 1
#define IPI_REQUEST_DPC 2
#define IPI_REQUEST_FREEZE 3
/* MACROS *************************************************************************/ /* MACROS *************************************************************************/
@ -49,6 +62,14 @@ extern PVOID KeRaiseUserExceptionDispatcher;
} \ } \
} }
#define KEBUGCHECKWITHTF(a,b,c,d,e,f) \
DbgPrint("KeBugCheckWithTf at %s:%i\n",__FILE__,__LINE__), KeBugCheckWithTf(a,b,c,d,e,f)
#define MAXIMUM_PROCESSORS 32
/* INTERNAL KERNEL FUNCTIONS ************************************************/
/* threadsch.c ********************************************************************/ /* threadsch.c ********************************************************************/
/* Thread Scheduler Functions */ /* Thread Scheduler Functions */
@ -66,17 +87,21 @@ KiDispatchThread(ULONG NewThreadStatus);
/* Puts a Thread into a block state. */ /* Puts a Thread into a block state. */
VOID VOID
STDCALL STDCALL
KiBlockThread(PNTSTATUS Status, KiBlockThread(
UCHAR Alertable, PNTSTATUS Status,
ULONG WaitMode, UCHAR Alertable,
UCHAR WaitReason); ULONG WaitMode,
UCHAR WaitReason
);
/* Removes a thread out of a block state. */ /* Removes a thread out of a block state. */
VOID VOID
STDCALL STDCALL
KiUnblockThread(PKTHREAD Thread, KiUnblockThread(
PNTSTATUS WaitStatus, PKTHREAD Thread,
KPRIORITY Increment); PNTSTATUS WaitStatus,
KPRIORITY Increment
);
NTSTATUS NTSTATUS
STDCALL STDCALL
@ -108,62 +133,59 @@ KeSignalGateBoostPriority(PKGATE Gate);
VOID VOID
FASTCALL FASTCALL
KeWaitForGate(PKGATE Gate, KeWaitForGate(
KWAIT_REASON WaitReason, PKGATE Gate,
KPROCESSOR_MODE WaitMode); KWAIT_REASON WaitReason,
KPROCESSOR_MODE WaitMode
);
/* ipi.c ********************************************************************/ /* ipi.c ********************************************************************/
BOOLEAN STDCALL BOOLEAN
KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, STDCALL
IN struct _KEXCEPTION_FRAME* ExceptionFrame); KiIpiServiceRoutine(
IN PKTRAP_FRAME TrapFrame,
IN struct _KEXCEPTION_FRAME* ExceptionFrame
);
VOID VOID
KiIpiSendRequest(KAFFINITY TargetSet, NTAPI
ULONG IpiRequest); KiIpiSendRequest(
KAFFINITY TargetSet,
ULONG IpiRequest
);
VOID VOID
KeIpiGenericCall(VOID (STDCALL *WorkerRoutine)(PVOID), NTAPI
PVOID Argument); KeIpiGenericCall(
VOID (STDCALL *WorkerRoutine)(PVOID),
PVOID Argument
);
/* next file ***************************************************************/ /* next file ***************************************************************/
typedef struct _KPROFILE_SOURCE_OBJECT
{
KPROFILE_SOURCE Source;
LIST_ENTRY ListEntry;
} KPROFILE_SOURCE_OBJECT, *PKPROFILE_SOURCE_OBJECT;
/* Cached modules from the loader block */
typedef enum _CACHED_MODULE_TYPE
{
AnsiCodepage,
OemCodepage,
UnicodeCasemap,
SystemRegistry,
HardwareRegistry,
MaximumCachedModuleType,
} CACHED_MODULE_TYPE, *PCACHED_MODULE_TYPE;
extern PLOADER_MODULE CachedModules[MaximumCachedModuleType];
VOID VOID
STDCALL STDCALL
DbgBreakPointNoBugCheck(VOID); DbgBreakPointNoBugCheck(VOID);
VOID VOID
STDCALL STDCALL
KeInitializeProfile(struct _KPROFILE* Profile, KeInitializeProfile(
struct _KPROCESS* Process, struct _KPROFILE* Profile,
PVOID ImageBase, struct _KPROCESS* Process,
ULONG ImageSize, PVOID ImageBase,
ULONG BucketSize, ULONG ImageSize,
KPROFILE_SOURCE ProfileSource, ULONG BucketSize,
KAFFINITY Affinity); KPROFILE_SOURCE ProfileSource,
KAFFINITY Affinity
);
VOID VOID
STDCALL STDCALL
KeStartProfile(struct _KPROFILE* Profile, KeStartProfile(
PVOID Buffer); struct _KPROFILE* Profile,
PVOID Buffer
);
VOID VOID
STDCALL STDCALL
@ -175,8 +197,10 @@ KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource);
VOID VOID
STDCALL STDCALL
KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource, KeSetIntervalProfile(
ULONG Interval); KPROFILE_SOURCE ProfileSource,
ULONG Interval
);
VOID VOID
STDCALL STDCALL
@ -187,40 +211,77 @@ KeProfileInterrupt(
VOID VOID
STDCALL STDCALL
KeProfileInterruptWithSource( KeProfileInterruptWithSource(
IN PKTRAP_FRAME TrapFrame, IN PKTRAP_FRAME TrapFrame,
IN KPROFILE_SOURCE Source IN KPROFILE_SOURCE Source
); );
BOOLEAN BOOLEAN
STDCALL STDCALL
KiRosPrintAddress(PVOID Address); KiRosPrintAddress(PVOID Address);
VOID STDCALL KeUpdateSystemTime(PKTRAP_FRAME TrapFrame, KIRQL Irql); VOID
VOID STDCALL KeUpdateRunTime(PKTRAP_FRAME TrapFrame, KIRQL Irql); STDCALL
KeUpdateSystemTime(
VOID STDCALL KiExpireTimers(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2); PKTRAP_FRAME TrapFrame,
KIRQL Irql
KIRQL inline FASTCALL KeAcquireDispatcherDatabaseLock(VOID); );
VOID inline FASTCALL KeAcquireDispatcherDatabaseLockAtDpcLevel(VOID);
VOID inline FASTCALL KeReleaseDispatcherDatabaseLock(KIRQL Irql);
VOID inline FASTCALL KeReleaseDispatcherDatabaseLockFromDpcLevel(VOID);
VOID VOID
STDCALL STDCALL
KeInitializeThread(struct _KPROCESS* Process, KeUpdateRunTime(
PKTHREAD Thread, PKTRAP_FRAME TrapFrame,
PKSYSTEM_ROUTINE SystemRoutine, KIRQL Irql
PKSTART_ROUTINE StartRoutine, );
PVOID StartContext,
PCONTEXT Context, VOID
PVOID Teb, STDCALL
PVOID KernelStack); KiExpireTimers(
PKDPC Dpc,
PVOID DeferredContext,
PVOID SystemArgument1,
PVOID SystemArgument2
);
KIRQL
inline
FASTCALL
KeAcquireDispatcherDatabaseLock(VOID);
VOID
__inline
FASTCALL
KeAcquireDispatcherDatabaseLockAtDpcLevel(VOID);
VOID
__inline
FASTCALL
KeReleaseDispatcherDatabaseLock(KIRQL Irql);
VOID
__inline
FASTCALL
KeReleaseDispatcherDatabaseLockFromDpcLevel(VOID);
VOID
STDCALL
KeInitializeThread(
struct _KPROCESS* Process,
PKTHREAD Thread,
PKSYSTEM_ROUTINE SystemRoutine,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext,
PCONTEXT Context,
PVOID Teb,
PVOID KernelStack
);
VOID VOID
STDCALL STDCALL
KeRundownThread(VOID); KeRundownThread(VOID);
NTSTATUS KeReleaseThread(PKTHREAD Thread); NTSTATUS
NTAPI
KeReleaseThread(PKTHREAD Thread);
LONG LONG
STDCALL STDCALL
@ -228,45 +289,62 @@ KeQueryBasePriorityThread(IN PKTHREAD Thread);
VOID VOID
STDCALL STDCALL
KiSetPriorityThread(PKTHREAD Thread, KiSetPriorityThread(
KPRIORITY Priority, PKTHREAD Thread,
PBOOLEAN Released); KPRIORITY Priority,
PBOOLEAN Released
);
BOOLEAN
NTAPI
KiDispatcherObjectWake(
DISPATCHER_HEADER* hdr,
KPRIORITY increment
);
VOID VOID
STDCALL STDCALL
KeStackAttachProcess ( KeExpireTimers(
IN struct _KPROCESS* Process, PKDPC Apc,
OUT PKAPC_STATE ApcState PVOID Arg1,
); PVOID Arg2,
PVOID Arg3
);
VOID VOID
STDCALL __inline
KeUnstackDetachProcess ( FASTCALL
IN PKAPC_STATE ApcState KeInitializeDispatcherHeader(
); DISPATCHER_HEADER* Header,
ULONG Type,
ULONG Size,
ULONG SignalState
);
BOOLEAN KiDispatcherObjectWake(DISPATCHER_HEADER* hdr, KPRIORITY increment); VOID
VOID STDCALL KeExpireTimers(PKDPC Apc, NTAPI
PVOID Arg1, KeDumpStackFrames(PULONG Frame);
PVOID Arg2,
PVOID Arg3); BOOLEAN
VOID inline FASTCALL KeInitializeDispatcherHeader(DISPATCHER_HEADER* Header, ULONG Type, NTAPI
ULONG Size, ULONG SignalState); KiTestAlert(VOID);
VOID KeDumpStackFrames(PULONG Frame);
BOOLEAN KiTestAlert(VOID);
VOID VOID
FASTCALL FASTCALL
KiAbortWaitThread(PKTHREAD Thread, KiAbortWaitThread(
NTSTATUS WaitStatus, PKTHREAD Thread,
KPRIORITY Increment); NTSTATUS WaitStatus,
KPRIORITY Increment
);
VOID VOID
STDCALL STDCALL
KeInitializeProcess(struct _KPROCESS *Process, KeInitializeProcess(
KPRIORITY Priority, struct _KPROCESS *Process,
KAFFINITY Affinity, KPRIORITY Priority,
LARGE_INTEGER DirectoryTableBase); KAFFINITY Affinity,
LARGE_INTEGER DirectoryTableBase
);
ULONG ULONG
STDCALL STDCALL
@ -276,215 +354,302 @@ BOOLEAN
STDCALL STDCALL
KeDisableThreadApcQueueing(IN PKTHREAD Thread); KeDisableThreadApcQueueing(IN PKTHREAD Thread);
BOOLEAN STDCALL KiInsertTimer(PKTIMER Timer, LARGE_INTEGER DueTime); BOOLEAN
STDCALL
KiInsertTimer(
PKTIMER Timer,
LARGE_INTEGER DueTime
);
VOID inline FASTCALL KiSatisfyObjectWait(PDISPATCHER_HEADER Object, PKTHREAD Thread); VOID
inline
FASTCALL
KiSatisfyObjectWait(
PDISPATCHER_HEADER Object,
PKTHREAD Thread
);
BOOLEAN inline FASTCALL KiIsObjectSignaled(PDISPATCHER_HEADER Object, PKTHREAD Thread); BOOLEAN
inline
FASTCALL
KiIsObjectSignaled(
PDISPATCHER_HEADER Object,
PKTHREAD Thread
);
VOID inline FASTCALL KiSatisifyMultipleObjectWaits(PKWAIT_BLOCK WaitBlock); VOID
inline
FASTCALL
KiSatisifyMultipleObjectWaits(PKWAIT_BLOCK WaitBlock);
VOID FASTCALL KiWaitTest(PDISPATCHER_HEADER Object, KPRIORITY Increment); VOID
FASTCALL
KiWaitTest(
PDISPATCHER_HEADER Object,
KPRIORITY Increment
);
PULONG
NTAPI
KeGetStackTopThread(struct _ETHREAD* Thread);
BOOLEAN
STDCALL
KeContextToTrapFrame(
PCONTEXT Context,
PKEXCEPTION_FRAME ExeptionFrame,
PKTRAP_FRAME TrapFrame,
KPROCESSOR_MODE PreviousMode
);
VOID
STDCALL
KiDeliverApc(
KPROCESSOR_MODE PreviousMode,
PVOID Reserved,
PKTRAP_FRAME TrapFrame
);
PULONG KeGetStackTopThread(struct _ETHREAD* Thread);
BOOLEAN STDCALL KeContextToTrapFrame(PCONTEXT Context,
PKEXCEPTION_FRAME ExeptionFrame,
PKTRAP_FRAME TrapFrame,
KPROCESSOR_MODE PreviousMode);
VOID STDCALL KiDeliverApc(KPROCESSOR_MODE PreviousMode,
PVOID Reserved,
PKTRAP_FRAME TrapFrame);
VOID VOID
STDCALL STDCALL
KiKernelApcDeliveryCheck(VOID); KiKernelApcDeliveryCheck(VOID);
LONG LONG
STDCALL STDCALL
KiInsertQueue(IN PKQUEUE Queue, KiInsertQueue(
IN PLIST_ENTRY Entry, IN PKQUEUE Queue,
BOOLEAN Head); IN PLIST_ENTRY Entry,
BOOLEAN Head
);
ULONG ULONG
STDCALL STDCALL
KeSetProcess(struct _KPROCESS* Process, KeSetProcess(
KPRIORITY Increment); struct _KPROCESS* Process,
KPRIORITY Increment
);
VOID
STDCALL
KeInitializeEventPair(PKEVENT_PAIR EventPair);
VOID STDCALL KeInitializeEventPair(PKEVENT_PAIR EventPair); VOID
STDCALL
VOID STDCALL KiInitializeUserApc(IN PKEXCEPTION_FRAME Reserved, KiInitializeUserApc(
IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME Reserved,
IN PKNORMAL_ROUTINE NormalRoutine, IN PKTRAP_FRAME TrapFrame,
IN PVOID NormalContext, IN PKNORMAL_ROUTINE NormalRoutine,
IN PVOID SystemArgument1, IN PVOID NormalContext,
IN PVOID SystemArgument2); IN PVOID SystemArgument1,
IN PVOID SystemArgument2
);
PLIST_ENTRY PLIST_ENTRY
STDCALL STDCALL
KeFlushQueueApc(IN PKTHREAD Thread, KeFlushQueueApc(
IN KPROCESSOR_MODE PreviousMode); IN PKTHREAD Thread,
IN KPROCESSOR_MODE PreviousMode
);
VOID
STDCALL
KiAttachProcess(
struct _KTHREAD *Thread,
struct _KPROCESS *Process,
KIRQL ApcLock,
struct _KAPC_STATE *SavedApcState
);
VOID STDCALL KiAttachProcess(struct _KTHREAD *Thread, struct _KPROCESS *Process, KIRQL ApcLock, struct _KAPC_STATE *SavedApcState); VOID
STDCALL
VOID STDCALL KiSwapProcess(struct _KPROCESS *NewProcess, struct _KPROCESS *OldProcess); KiSwapProcess(
struct _KPROCESS *NewProcess,
struct _KPROCESS *OldProcess
);
BOOLEAN BOOLEAN
STDCALL STDCALL
KeTestAlertThread(IN KPROCESSOR_MODE AlertMode); KeTestAlertThread(IN KPROCESSOR_MODE AlertMode);
BOOLEAN STDCALL KeRemoveQueueApc (PKAPC Apc); BOOLEAN
VOID FASTCALL KiWakeQueue(IN PKQUEUE Queue); STDCALL
PLIST_ENTRY STDCALL KeRundownQueue(IN PKQUEUE Queue); KeRemoveQueueApc(PKAPC Apc);
extern LARGE_INTEGER SystemBootTime; VOID
FASTCALL
KiWakeQueue(IN PKQUEUE Queue);
PLIST_ENTRY
STDCALL
KeRundownQueue(IN PKQUEUE Queue);
/* INITIALIZATION FUNCTIONS *************************************************/ /* INITIALIZATION FUNCTIONS *************************************************/
extern ULONG_PTR KERNEL_BASE; VOID
NTAPI
KeInitExceptions(VOID);
VOID KeInitExceptions(VOID); VOID
VOID KeInitInterrupts(VOID); NTAPI
VOID KeInitTimer(VOID); KeInitInterrupts(VOID);
VOID KeInitDpc(struct _KPRCB* Prcb);
VOID KeInitDispatcher(VOID);
VOID inline FASTCALL KeInitializeDispatcher(VOID);
VOID KiInitializeSystemClock(VOID);
VOID KiInitializeBugCheck(VOID);
VOID Phase1Initialization(PVOID Context);
VOID KeInit1(PCHAR CommandLine, PULONG LastKernelAddress); VOID
VOID KeInit2(VOID); NTAPI
KeInitTimer(VOID);
BOOLEAN KiDeliverUserApc(PKTRAP_FRAME TrapFrame); VOID
NTAPI
KeInitDpc(struct _KPRCB* Prcb);
VOID
NTAPI
KeInitDispatcher(VOID);
VOID
__inline
FASTCALL
KeInitializeDispatcher(VOID);
VOID
NTAPI
KiInitializeSystemClock(VOID);
VOID
NTAPI
KiInitializeBugCheck(VOID);
VOID
NTAPI
Phase1Initialization(PVOID Context);
VOID
NTAPI
KeInit1(
PCHAR CommandLine,
PULONG LastKernelAddress
);
VOID
NTAPI
KeInit2(VOID);
BOOLEAN
NTAPI
KiDeliverUserApc(PKTRAP_FRAME TrapFrame);
VOID VOID
STDCALL STDCALL
KiMoveApcState (PKAPC_STATE OldState, KiMoveApcState(
PKAPC_STATE NewState); PKAPC_STATE OldState,
PKAPC_STATE NewState
);
VOID VOID
KiAddProfileEvent(KPROFILE_SOURCE Source, ULONG Pc); NTAPI
KiAddProfileEvent(
KPROFILE_SOURCE Source,
ULONG Pc
);
VOID VOID
NTAPI NTAPI
KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, KiDispatchException(
PKEXCEPTION_FRAME ExceptionFrame, PEXCEPTION_RECORD ExceptionRecord,
PKTRAP_FRAME Tf, PKEXCEPTION_FRAME ExceptionFrame,
KPROCESSOR_MODE PreviousMode, PKTRAP_FRAME Tf,
BOOLEAN SearchFrames); KPROCESSOR_MODE PreviousMode,
BOOLEAN SearchFrames
);
VOID VOID
NTAPI NTAPI
KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame, KeTrapFrameToContext(
IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame,
IN OUT PCONTEXT Context); IN PKEXCEPTION_FRAME ExceptionFrame,
IN OUT PCONTEXT Context
);
VOID VOID
NTAPI
KeApplicationProcessorInit(VOID); KeApplicationProcessorInit(VOID);
VOID VOID
NTAPI
KePrepareForApplicationProcessorInit(ULONG id); KePrepareForApplicationProcessorInit(ULONG id);
ULONG ULONG
KiUserTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr, PVOID Cr2); NTAPI
VOID STDCALL KiUserTrapHandler(
KePushAndStackSwitchAndSysRet(ULONG Push, PVOID NewStack); PKTRAP_FRAME Tf,
VOID STDCALL ULONG ExceptionNr,
KeStackSwitchAndRet(PVOID NewStack); PVOID Cr2
VOID STDCALL );
KeBugCheckWithTf(ULONG BugCheckCode,
ULONG BugCheckParameter1,
ULONG BugCheckParameter2,
ULONG BugCheckParameter3,
ULONG BugCheckParameter4,
PKTRAP_FRAME Tf);
#define KEBUGCHECKWITHTF(a,b,c,d,e,f) DbgPrint("KeBugCheckWithTf at %s:%i\n",__FILE__,__LINE__), KeBugCheckWithTf(a,b,c,d,e,f)
VOID VOID
KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG ExceptionNr, ULONG cr2); STDCALL
KePushAndStackSwitchAndSysRet(
ULONG Push,
PVOID NewStack
);
VOID
STDCALL
KeStackSwitchAndRet(PVOID NewStack);
VOID
STDCALL
KeBugCheckWithTf(
ULONG BugCheckCode,
ULONG BugCheckParameter1,
ULONG BugCheckParameter2,
ULONG BugCheckParameter3,
ULONG BugCheckParameter4,
PKTRAP_FRAME Tf
);
VOID
STDCALL
KiDumpTrapFrame(
PKTRAP_FRAME Tf,
ULONG ExceptionNr,
ULONG cr2
);
VOID VOID
STDCALL STDCALL
KeFlushCurrentTb(VOID); KeFlushCurrentTb(VOID);
/* REACTOS SPECIFIC */
VOID STDCALL
KeRosDumpStackFrames(
PULONG Frame,
ULONG FrameCount);
ULONG STDCALL
KeRosGetStackFrames(
PULONG Frames,
ULONG FrameCount);
VOID VOID
STDCALL
KeRosDumpStackFrames(
PULONG Frame,
ULONG FrameCount
);
ULONG
STDCALL
KeRosGetStackFrames(
PULONG Frames,
ULONG FrameCount
);
VOID
NTAPI
KiSetSystemTime(PLARGE_INTEGER NewSystemTime); KiSetSystemTime(PLARGE_INTEGER NewSystemTime);
/* Emulate cli/sti instructions */
#define KV86M_EMULATE_CLI_STI (0x1)
/* Allow the v86 mode code to access i/o ports */
#define KV86M_ALLOW_IO_PORT_ACCESS (0x2)
typedef struct _KV86M_REGISTERS
{
/*
* General purpose registers
*/
ULONG Ebp;
ULONG Edi;
ULONG Esi;
ULONG Edx;
ULONG Ecx;
ULONG Ebx;
ULONG Eax;
ULONG Ds;
ULONG Es;
ULONG Fs;
ULONG Gs;
/*
* Control registers
*/
ULONG Eip;
ULONG Cs;
ULONG Eflags;
ULONG Esp;
ULONG Ss;
/*
* Control structures
*/
ULONG RecoveryAddress;
UCHAR RecoveryInstruction[4];
ULONG Vif;
ULONG Flags;
PNTSTATUS PStatus;
} KV86M_REGISTERS, *PKV86M_REGISTERS;
typedef struct _KV86M_TRAP_FRAME
{
KTRAP_FRAME Tf;
ULONG SavedExceptionStack;
/*
* These are put on the top of the stack by the routine that entered
* v86 mode so the exception handlers can find the control information
*/
struct _KV86M_REGISTERS* regs;
ULONG orig_ebp;
} KV86M_TRAP_FRAME, *PKV86M_TRAP_FRAME;
NTSTATUS NTSTATUS
STDCALL STDCALL
Ke386CallBios( Ke386CallBios(
UCHAR Int, UCHAR Int,
PKV86M_REGISTERS Regs PKV86M_REGISTERS Regs
); );
ULONG ULONG
NTAPI
KeV86Exception( KeV86Exception(
ULONG ExceptionNr, ULONG ExceptionNr,
PKTRAP_FRAME Tf, PKTRAP_FRAME Tf,
ULONG address ULONG address
); );
#define MAXIMUM_PROCESSORS 32
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_KE_H */ #endif /* __NTOSKRNL_INCLUDE_INTERNAL_KE_H */

View file

@ -1,33 +1,38 @@
#ifndef __INCLUDE_INTERNAL_LDR_H #ifndef __INCLUDE_INTERNAL_LDR_H
#define __INCLUDE_INTERNAL_LDR_H #define __INCLUDE_INTERNAL_LDR_H
#define KERNEL_MODULE_NAME L"ntoskrnl.exe" #define KERNEL_MODULE_NAME L"ntoskrnl.exe"
#define HAL_MODULE_NAME L"hal.dll" #define HAL_MODULE_NAME L"hal.dll"
#define DRIVER_ROOT_NAME L"\\Driver\\" #define DRIVER_ROOT_NAME L"\\Driver\\"
#define FILESYSTEM_ROOT_NAME L"\\FileSystem\\" #define FILESYSTEM_ROOT_NAME L"\\FileSystem\\"
extern ULONG_PTR LdrHalBase; extern ULONG_PTR LdrHalBase;
NTSTATUS NTSTATUS
NTAPI
LdrLoadInitialProcess( LdrLoadInitialProcess(
PHANDLE ProcessHandle, PHANDLE ProcessHandle,
PHANDLE ThreadHandle PHANDLE ThreadHandle
); );
VOID VOID
LdrLoadAutoConfigDrivers (VOID); NTAPI
LdrLoadAutoConfigDrivers(VOID);
VOID VOID
LdrInitModuleManagement (VOID); NTAPI
LdrInitModuleManagement(VOID);
NTSTATUS NTSTATUS
NTAPI
LdrpMapImage( LdrpMapImage(
HANDLE ProcessHandle, HANDLE ProcessHandle,
HANDLE SectionHandle, HANDLE SectionHandle,
PVOID * ImageBase PVOID *ImageBase
); );
NTSTATUS NTSTATUS
NTAPI
LdrpLoadImage( LdrpLoadImage(
PUNICODE_STRING DriverName, PUNICODE_STRING DriverName,
PVOID *ModuleBase, PVOID *ModuleBase,
@ -37,12 +42,15 @@ LdrpLoadImage(
); );
NTSTATUS NTSTATUS
NTAPI
LdrpUnloadImage(PVOID ModuleBase); LdrpUnloadImage(PVOID ModuleBase);
NTSTATUS NTSTATUS
NTAPI
LdrpLoadAndCallImage(PUNICODE_STRING DriverName); LdrpLoadAndCallImage(PUNICODE_STRING DriverName);
NTSTATUS NTSTATUS
NTAPI
LdrpQueryModuleInformation( LdrpQueryModuleInformation(
PVOID Buffer, PVOID Buffer,
ULONG Size, ULONG Size,
@ -50,15 +58,18 @@ LdrpQueryModuleInformation(
); );
VOID VOID
NTAPI
LdrInit1(VOID); LdrInit1(VOID);
VOID VOID
NTAPI
LdrInitDebug( LdrInitDebug(
PLOADER_MODULE Module, PLOADER_MODULE Module,
PWCH Name PWCH Name
); );
PVOID PVOID
NTAPI
LdrSafePEProcessModule( LdrSafePEProcessModule(
PVOID ModuleLoadBase, PVOID ModuleLoadBase,
PVOID DriverBase, PVOID DriverBase,
@ -67,15 +78,18 @@ LdrSafePEProcessModule(
); );
NTSTATUS NTSTATUS
NTAPI
LdrLoadModule( LdrLoadModule(
PUNICODE_STRING Filename, PUNICODE_STRING Filename,
PLDR_DATA_TABLE_ENTRY *ModuleObject PLDR_DATA_TABLE_ENTRY *ModuleObject
); );
NTSTATUS NTSTATUS
NTAPI
LdrUnloadModule(PLDR_DATA_TABLE_ENTRY ModuleObject); LdrUnloadModule(PLDR_DATA_TABLE_ENTRY ModuleObject);
PLDR_DATA_TABLE_ENTRY PLDR_DATA_TABLE_ENTRY
NTAPI
LdrGetModuleObject(PUNICODE_STRING ModuleName); LdrGetModuleObject(PUNICODE_STRING ModuleName);
#endif /* __INCLUDE_INTERNAL_LDR_H */ #endif /* __INCLUDE_INTERNAL_LDR_H */

View file

@ -24,10 +24,8 @@
#include "ldr.h" #include "ldr.h"
#include "kd.h" #include "kd.h"
#include "ex.h" #include "ex.h"
#include "xhal.h" #include "fsrtl.h"
#include "v86m.h" #include "lpc.h"
#include "fs.h"
#include "port.h"
#include "rtl.h" #include "rtl.h"
#ifdef KDBG #ifdef KDBG
#include "../kdbg/kdb.h" #include "../kdbg/kdb.h"

View file

@ -1,15 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/include/internal/v86m.h
* PURPOSE: V86 Headers
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES ******************************************************************/
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_V86M_H
#define __NTOSKRNL_INCLUDE_INTERNAL_V86M_H
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_V86M_H */

View file

@ -1,69 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/include/internal/xhal.h
* PURPOSE: HAL Callbacks
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES ******************************************************************/
#ifndef __INCLUDE_INTERNAL_XHAL_H
#define __INCLUDE_INTERNAL_XHAL_H
#include <ddk/ntdddisk.h>
NTSTATUS
FASTCALL
xHalQueryDriveLayout(
IN PUNICODE_STRING DeviceName,
OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo
);
#undef HalExamineMBR
VOID
FASTCALL
HalExamineMBR(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG MBRTypeIdentifier,
OUT PVOID *Buffer
);
VOID
FASTCALL
xHalIoAssignDriveLetters(
IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PSTRING NtDeviceName,
OUT PUCHAR NtSystemPath,
OUT PSTRING NtSystemPathString
);
NTSTATUS
FASTCALL
xHalIoReadPartitionTable(
PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
BOOLEAN ReturnRecognizedPartitions,
PDRIVE_LAYOUT_INFORMATION *PartitionBuffer
);
NTSTATUS
FASTCALL
xHalIoSetPartitionInformation(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG PartitionNumber,
IN ULONG PartitionType
);
NTSTATUS
FASTCALL
xHalIoWritePartitionTable(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG SectorsPerTrack,
IN ULONG NumberOfHeads,
IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer
);
#endif

View file

@ -27,6 +27,7 @@ static ULONG KeBugCheckCount = 1;
VOID VOID
INIT_FUNCTION INIT_FUNCTION
NTAPI
KiInitializeBugCheck(VOID) KiInitializeBugCheck(VOID)
{ {
PRTL_MESSAGE_RESOURCE_DATA BugCheckData; PRTL_MESSAGE_RESOURCE_DATA BugCheckData;

View file

@ -73,6 +73,7 @@ EXPORTED ULONG KeMinimumIncrement = 100000;
*/ */
VOID VOID
INIT_FUNCTION INIT_FUNCTION
NTAPI
KiInitializeSystemClock(VOID) KiInitializeSystemClock(VOID)
{ {
TIME_FIELDS TimeFields; TIME_FIELDS TimeFields;
@ -100,6 +101,7 @@ KiInitializeSystemClock(VOID)
} }
VOID VOID
NTAPI
KiSetSystemTime(PLARGE_INTEGER NewSystemTime) KiSetSystemTime(PLARGE_INTEGER NewSystemTime)
{ {
LARGE_INTEGER OldSystemTime; LARGE_INTEGER OldSystemTime;

View file

@ -32,6 +32,7 @@
*/ */
VOID VOID
INIT_FUNCTION INIT_FUNCTION
NTAPI
KeInitDpc(PKPRCB Prcb) KeInitDpc(PKPRCB Prcb)
{ {
InitializeListHead(&Prcb->DpcData[0].DpcListHead); InitializeListHead(&Prcb->DpcData[0].DpcListHead);

View file

@ -400,6 +400,7 @@ KiDoubleFaultHandler(VOID)
} }
VOID VOID
NTAPI
KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2) KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
{ {
ULONG cr3_; ULONG cr3_;
@ -926,6 +927,7 @@ KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
} }
VOID VOID
NTAPI
KeDumpStackFrames(PULONG Frame) KeDumpStackFrames(PULONG Frame)
{ {
PULONG StackBase, StackEnd; PULONG StackBase, StackEnd;
@ -1109,7 +1111,9 @@ set_task_gate(unsigned int sel, unsigned task_sel)
KiIdt[sel].b = 0x8500; KiIdt[sel].b = 0x8500;
} }
VOID INIT_FUNCTION VOID
INIT_FUNCTION
NTAPI
KeInitExceptions(VOID) KeInitExceptions(VOID)
/* /*
* FUNCTION: Initalize CPU exception handling * FUNCTION: Initalize CPU exception handling

View file

@ -137,7 +137,9 @@ static ISR_TABLE IsrTable[NR_IRQS][1];
#define PRESENT (0x8000) #define PRESENT (0x8000)
#define I486_INTERRUPT_GATE (0xe00) #define I486_INTERRUPT_GATE (0xe00)
VOID INIT_FUNCTION VOID
INIT_FUNCTION
NTAPI
KeInitInterrupts (VOID) KeInitInterrupts (VOID)
{ {
int i, j; int i, j;

View file

@ -165,7 +165,9 @@ KeCreateApplicationProcessorIdleThread(ULONG Id)
Id, IdleThread->Cid.UniqueThread); Id, IdleThread->Cid.UniqueThread);
} }
VOID INIT_FUNCTION VOID
INIT_FUNCTION
NTAPI
KePrepareForApplicationProcessorInit(ULONG Id) KePrepareForApplicationProcessorInit(ULONG Id)
{ {
DPRINT("KePrepareForApplicationProcessorInit(Id %d)\n", Id); DPRINT("KePrepareForApplicationProcessorInit(Id %d)\n", Id);
@ -205,6 +207,7 @@ KePrepareForApplicationProcessorInit(ULONG Id)
} }
VOID VOID
NTAPI
KeApplicationProcessorInit(VOID) KeApplicationProcessorInit(VOID)
{ {
ULONG Offset; ULONG Offset;
@ -266,7 +269,9 @@ KeApplicationProcessorInit(VOID)
Ke386EnableInterrupts(); Ke386EnableInterrupts();
} }
VOID INIT_FUNCTION VOID
INIT_FUNCTION
NTAPI
KeInit1(PCHAR CommandLine, PULONG LastKernelAddress) KeInit1(PCHAR CommandLine, PULONG LastKernelAddress)
{ {
PKIPCR KPCR; PKIPCR KPCR;
@ -401,7 +406,9 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress)
} }
} }
VOID INIT_FUNCTION VOID
INIT_FUNCTION
NTAPI
KeInit2(VOID) KeInit2(VOID)
{ {
PKIPCR Pcr = (PKIPCR)KeGetCurrentKPCR(); PKIPCR Pcr = (PKIPCR)KeGetCurrentKPCR();

View file

@ -78,6 +78,7 @@ print_user_address(PVOID address)
} }
ULONG ULONG
NTAPI
KiUserTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr, PVOID Cr2) KiUserTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr, PVOID Cr2)
{ {
EXCEPTION_RECORD Er; EXCEPTION_RECORD Er;

View file

@ -681,6 +681,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf)
} }
ULONG ULONG
NTAPI
KeV86Exception(ULONG ExceptionNr, PKTRAP_FRAME Tf, ULONG address) KeV86Exception(ULONG ExceptionNr, PKTRAP_FRAME Tf, ULONG address)
{ {
PUCHAR Ip; PUCHAR Ip;

View file

@ -22,6 +22,7 @@ KSPIN_LOCK KiIpiLock;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID
NTAPI
KiIpiSendRequest(KAFFINITY TargetSet, ULONG IpiRequest) KiIpiSendRequest(KAFFINITY TargetSet, ULONG IpiRequest)
{ {
LONG i; LONG i;
@ -59,18 +60,18 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
Prcb = KeGetCurrentPrcb(); Prcb = KeGetCurrentPrcb();
if (Ke386TestAndClearBit(IPI_REQUEST_APC, &Prcb->IpiFrozen)) if (Ke386TestAndClearBit(IPI_APC, &Prcb->IpiFrozen))
{ {
HalRequestSoftwareInterrupt(APC_LEVEL); HalRequestSoftwareInterrupt(APC_LEVEL);
} }
if (Ke386TestAndClearBit(IPI_REQUEST_DPC, &Prcb->IpiFrozen)) if (Ke386TestAndClearBit(IPI_DPC, &Prcb->IpiFrozen))
{ {
Prcb->DpcInterruptRequested = TRUE; Prcb->DpcInterruptRequested = TRUE;
HalRequestSoftwareInterrupt(DISPATCH_LEVEL); HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
} }
if (Ke386TestAndClearBit(IPI_REQUEST_FUNCTIONCALL, &Prcb->IpiFrozen)) if (Ke386TestAndClearBit(IPI_SYNCH_REQUEST, &Prcb->IpiFrozen))
{ {
InterlockedDecrementUL(&Prcb->SignalDone->CurrentPacket[1]); InterlockedDecrementUL(&Prcb->SignalDone->CurrentPacket[1]);
if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0)) if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0))
@ -140,7 +141,7 @@ KiIpiSendPacket(KAFFINITY TargetSet, VOID (STDCALL*WorkerRoutine)(PVOID), PVOID
{ {
Prcb = ((PKPCR)(KPCR_BASE + i * PAGE_SIZE))->Prcb; Prcb = ((PKPCR)(KPCR_BASE + i * PAGE_SIZE))->Prcb;
while(0 != InterlockedCompareExchangeUL(&Prcb->SignalDone, (LONG)CurrentPrcb, 0)); while(0 != InterlockedCompareExchangeUL(&Prcb->SignalDone, (LONG)CurrentPrcb, 0));
Ke386TestAndSetBit(IPI_REQUEST_FUNCTIONCALL, &Prcb->IpiFrozen); Ke386TestAndSetBit(IPI_SYNCH_REQUEST, &Prcb->IpiFrozen);
if (Processor != CurrentPrcb->SetMember) if (Processor != CurrentPrcb->SetMember)
{ {
HalRequestIpi(i); HalRequestIpi(i);
@ -156,6 +157,7 @@ KiIpiSendPacket(KAFFINITY TargetSet, VOID (STDCALL*WorkerRoutine)(PVOID), PVOID
} }
VOID VOID
NTAPI
KeIpiGenericCall(VOID (STDCALL *Function)(PVOID), PVOID Argument) KeIpiGenericCall(VOID (STDCALL *Function)(PVOID), PVOID Argument)
{ {
KIRQL oldIrql; KIRQL oldIrql;

View file

@ -38,7 +38,7 @@ KiRequestReschedule(CCHAR Processor)
Pcr = (PKPCR)(KPCR_BASE + Processor * PAGE_SIZE); Pcr = (PKPCR)(KPCR_BASE + Processor * PAGE_SIZE);
Pcr->Prcb->QuantumEnd = TRUE; Pcr->Prcb->QuantumEnd = TRUE;
KiIpiSendRequest(1 << Processor, IPI_REQUEST_DPC); KiIpiSendRequest(1 << Processor, IPI_DPC);
} }
STATIC STATIC

View file

@ -89,18 +89,23 @@ LdrPEFixupImports ( PLDR_DATA_TABLE_ENTRY Module );
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID
NTAPI
LdrInitDebug ( PLOADER_MODULE Module, PWCH Name ) LdrInitDebug ( PLOADER_MODULE Module, PWCH Name )
{ {
} }
VOID INIT_FUNCTION VOID
INIT_FUNCTION
NTAPI
LdrInit1 ( VOID ) LdrInit1 ( VOID )
{ {
/* Hook for KDB on initialization of the loader. */ /* Hook for KDB on initialization of the loader. */
KDB_LOADERINIT_HOOK(&NtoskrnlModuleObject, &HalModuleObject); KDB_LOADERINIT_HOOK(&NtoskrnlModuleObject, &HalModuleObject);
} }
VOID INIT_FUNCTION VOID
INIT_FUNCTION
NTAPI
LdrInitModuleManagement ( VOID ) LdrInitModuleManagement ( VOID )
{ {
PIMAGE_NT_HEADERS NtHeader; PIMAGE_NT_HEADERS NtHeader;
@ -138,6 +143,7 @@ LdrInitModuleManagement ( VOID )
} }
NTSTATUS NTSTATUS
NTAPI
LdrpLoadImage ( LdrpLoadImage (
PUNICODE_STRING DriverName, PUNICODE_STRING DriverName,
PVOID *ModuleBase, PVOID *ModuleBase,
@ -175,6 +181,7 @@ LdrpLoadImage (
NTSTATUS NTSTATUS
NTAPI
LdrpUnloadImage ( PVOID ModuleBase ) LdrpUnloadImage ( PVOID ModuleBase )
{ {
return(STATUS_NOT_IMPLEMENTED); return(STATUS_NOT_IMPLEMENTED);
@ -182,6 +189,7 @@ LdrpUnloadImage ( PVOID ModuleBase )
NTSTATUS NTSTATUS
NTAPI
LdrpLoadAndCallImage ( PUNICODE_STRING ModuleName ) LdrpLoadAndCallImage ( PUNICODE_STRING ModuleName )
{ {
PDRIVER_INITIALIZE DriverEntry; PDRIVER_INITIALIZE DriverEntry;
@ -217,6 +225,7 @@ LdrpLoadAndCallImage ( PUNICODE_STRING ModuleName )
NTSTATUS NTSTATUS
NTAPI
LdrLoadModule( LdrLoadModule(
PUNICODE_STRING Filename, PUNICODE_STRING Filename,
PLDR_DATA_TABLE_ENTRY *ModuleObject ) PLDR_DATA_TABLE_ENTRY *ModuleObject )
@ -321,6 +330,7 @@ LdrLoadModule(
NTSTATUS NTSTATUS
NTAPI
LdrUnloadModule ( PLDR_DATA_TABLE_ENTRY ModuleObject ) LdrUnloadModule ( PLDR_DATA_TABLE_ENTRY ModuleObject )
{ {
KIRQL Irql; KIRQL Irql;
@ -365,6 +375,7 @@ LdrProcessModule(
} }
NTSTATUS NTSTATUS
NTAPI
LdrpQueryModuleInformation ( LdrpQueryModuleInformation (
PVOID Buffer, PVOID Buffer,
ULONG Size, ULONG Size,
@ -542,6 +553,7 @@ LdrpCompareModuleNames (
} }
PLDR_DATA_TABLE_ENTRY PLDR_DATA_TABLE_ENTRY
NTAPI
LdrGetModuleObject ( PUNICODE_STRING ModuleName ) LdrGetModuleObject ( PUNICODE_STRING ModuleName )
{ {
PLDR_DATA_TABLE_ENTRY Module; PLDR_DATA_TABLE_ENTRY Module;
@ -870,7 +882,9 @@ LdrPEProcessModule(
} }
PVOID INIT_FUNCTION PVOID
INIT_FUNCTION
NTAPI
LdrSafePEProcessModule ( LdrSafePEProcessModule (
PVOID ModuleLoadBase, PVOID ModuleLoadBase,
PVOID DriverBase, PVOID DriverBase,