mirror of
https://github.com/reactos/reactos
synced 2025-10-06 16:32:42 +02:00
Compare commits
7 Commits
rfb/advapi
...
ReactOS-0.
Author | SHA1 | Date | |
---|---|---|---|
|
0b545b592e | ||
|
935b7c2953 | ||
|
1b7327da76 | ||
|
f77c44657c | ||
|
df0328b7cc | ||
|
94c8483b04 | ||
|
fc7e59ce74 |
@@ -33,157 +33,6 @@ enum
|
||||
PagedPoolCacheAligned,
|
||||
};
|
||||
|
||||
/*
|
||||
* Possible status codes
|
||||
* FIXME: These may not be the actual values used by NT
|
||||
*/
|
||||
enum
|
||||
{
|
||||
STATUS_SUCCESS = 0x0,
|
||||
STATUS_INSUFFICIENT_RESOURCES = 0x80000000,
|
||||
STATUS_OBJECT_NAME_EXISTS,
|
||||
STATUS_OBJECT_NAME_COLLISION,
|
||||
// STATUS_DATATYPE_MISALIGNMENT,
|
||||
STATUS_CTL_FILE_NOT_SUPPORTED,
|
||||
// STATUS_ACCESS_VIOLATION,
|
||||
STATUS_PORT_ALREADY_SET,
|
||||
STATUS_SECTION_NOT_IMAGE,
|
||||
STATUS_BAD_WORKING_SET_LIMIT,
|
||||
STATUS_INCOMPATIBLE_FILE_MAP,
|
||||
STATUS_HANDLE_NOT_WAITABLE,
|
||||
STATUS_PORT_DISCONNECTED,
|
||||
STATUS_NOT_LOCKED,
|
||||
STATUS_NOT_MAPPED_VIEW,
|
||||
STATUS_UNABLE_TO_FREE_VM,
|
||||
STATUS_UNABLE_TO_DELETE_SECTION,
|
||||
STATUS_MORE_PROCESSING_REQUIRED,
|
||||
STATUS_INVALID_CID,
|
||||
STATUS_BAD_INITIAL_STACK,
|
||||
STATUS_INVALID_VOLUME_LABEL,
|
||||
STATUS_SECTION_NOT_EXTENDED,
|
||||
STATUS_NOT_MAPPED_DATA,
|
||||
STATUS_INFO_LENGTH_MISMATCH,
|
||||
STATUS_INVALID_INFO_CLASS,
|
||||
STATUS_SUSPEND_COUNT_EXCEEDED,
|
||||
STATUS_NOTIFY_ENUM_DIR,
|
||||
STATUS_REGISTRY_RECOVERED,
|
||||
STATUS_REGISTRY_IO_FAILED,
|
||||
STATUS_KEY_DELETED,
|
||||
STATUS_NO_LOG_SPACE,
|
||||
STATUS_KEY_HAS_CHILDREN,
|
||||
STATUS_CHILD_MUST_BE_VOLATILE,
|
||||
STATUS_REGISTRY_CORRUPT,
|
||||
STATUS_DLL_NOT_FOUND,
|
||||
STATUS_DLL_INIT_FAILED,
|
||||
STATUS_ORDINAL_NOT_FOUND,
|
||||
STATUS_ENTRYPOINT_NOT_FOUND,
|
||||
// STATUS_PENDING,
|
||||
STATUS_MORE_ENTRIES,
|
||||
// STATUS_INTEGER_OVERFLOW,
|
||||
STATUS_BUFFER_OVERFLOW,
|
||||
STATUS_NO_MORE_FILES,
|
||||
STATUS_NO_INHERITANCE,
|
||||
STATUS_NO_MORE_EAS,
|
||||
STATUS_NO_MORE_ENTRIES,
|
||||
STATUS_GUIDS_EXHAUSTED,
|
||||
STATUS_AGENTS_EXHAUSTED,
|
||||
STATUS_UNSUCCESSFUL,
|
||||
STATUS_NOT_IMPLEMENTED,
|
||||
STATUS_ILLEGAL_FUNCTION,
|
||||
// STATUS_IN_PAGE_ERROR,
|
||||
STATUS_PAGEFILE_QUOTA,
|
||||
STATUS_COMMITMENT_LIMIT,
|
||||
STATUS_SECTION_TOO_BIG,
|
||||
RPC_NT_SS_IN_NULL_CONTEXT,
|
||||
RPC_NT_INVALID_BINDING,
|
||||
// STATUS_INVALID_HANDLE,
|
||||
STATUS_OBJECT_FILE_MISMATCH,
|
||||
STATUS_FILE_CLOSED,
|
||||
STATUS_INVALID_PORT_HANDLE,
|
||||
STATUS_NOT_COMMITTED,
|
||||
STATUS_INVALID_PARAMETER,
|
||||
STATUS_INVALID_PARAMETER_1,
|
||||
STATUS_INVALID_PARAMETER_2,
|
||||
STATUS_INVALID_PARAMETER_3,
|
||||
STATUS_INVALID_PARAMETER_4,
|
||||
STATUS_INVALID_PARAMETER_5,
|
||||
STATUS_INVALID_PARAMETER_6,
|
||||
STATUS_INVALID_PARAMETER_7,
|
||||
STATUS_INVALID_PARAMETER_8,
|
||||
STATUS_INVALID_PARAMETER_9,
|
||||
STATUS_INVALID_PARAMETER_10,
|
||||
STATUS_INVALID_PARAMETER_11,
|
||||
STATUS_INVALID_PARAMETER_12,
|
||||
STATUS_INVALID_PARAMETER_MAX,
|
||||
STATUS_INVALID_PAGE_PROTECTION,
|
||||
STATUS_RESOURCE_DATA_NOT_FOUND,
|
||||
STATUS_RESOURCE_TYPE_NOT_FOUND,
|
||||
STATUS_RESOURCE_NAME_NOT_FOUND,
|
||||
STATUS_RESOURCE_LANG_NOT_FOUND,
|
||||
STATUS_NO_SUCH_DEVICE,
|
||||
STATUS_NO_SUCH_FILE,
|
||||
STATUS_INVALID_DEVICE_REQUEST,
|
||||
STATUS_END_OF_FILE,
|
||||
STATUS_FILE_FORCED_CLOSED,
|
||||
STATUS_WRONG_VOLUME,
|
||||
STATUS_NO_MEDIA,
|
||||
STATUS_NO_MEDIA_IN_DEVICE,
|
||||
STATUS_NONEXISTENT_SECTOR,
|
||||
STATUS_WORKING_SET_QUOTA,
|
||||
// STATUS_NO_MEMORY,
|
||||
STATUS_CONFLICTING_ADDRESS,
|
||||
STATUS_INVALID_SYSTEM_SERVICE,
|
||||
STATUS_THREAD_IS_TERMINATING,
|
||||
STATUS_PROCESS_IS_TERMINATING,
|
||||
STATUS_INVALID_LOCK_SEQUENCE,
|
||||
STATUS_INVALID_VIEW_SIZE,
|
||||
STATUS_ALREADY_COMMITTED,
|
||||
STATUS_ACCESS_DENIED,
|
||||
STATUS_FILE_IS_A_DIRECTORY,
|
||||
STATUS_CANNOT_DELETE,
|
||||
STATUS_INVALID_COMPUTER_NAME,
|
||||
STATUS_FILE_DELETED,
|
||||
STATUS_DELETE_PENDING,
|
||||
STATUS_PORT_CONNECTION_REFUSED,
|
||||
STATUS_NO_SUCH_PRIVILEGE,
|
||||
STATUS_PRIVILEGE_NOT_HELD,
|
||||
STATUS_CANNOT_IMPERSONATE,
|
||||
STATUS_LOGON_FAILURE,
|
||||
STATUS_ACCOUNT_RESTRICTION,
|
||||
STATUS_INVALID_LOGON_HOURS,
|
||||
STATUS_INVALID_WORKSTATION,
|
||||
STATUS_BUFFER_TOO_SMALL,
|
||||
STATUS_UNABLE_TO_DECOMMIT_VM,
|
||||
STATUS_DISK_CORRUPT_ERROR,
|
||||
STATUS_OBJECT_NAME_INVALID,
|
||||
STATUS_OBJECT_NAME_NOT_FOUND,
|
||||
// STATUS_OBJECT_NAME_COLLISION,
|
||||
STATUS_OBJECT_PATH_INVALID,
|
||||
STATUS_OBJECT_PATH_NOT_FOUND,
|
||||
STATUS_DFS_EXIT_PATH_FOUND,
|
||||
STATUS_OBJECT_PATH_SYNTAX_BAD,
|
||||
STATUS_DATA_OVERRUN,
|
||||
STATUS_DATA_LATE_ERROR,
|
||||
STATUS_DATA_ERROR,
|
||||
STATUS_CRC_ERROR,
|
||||
STATUS_SHARING_VIOLATION,
|
||||
STATUS_QUOTA_EXCEEDED,
|
||||
STATUS_MUTANT_NOT_OWNED,
|
||||
STATUS_SEMAPHORE_LIMIT_EXCEEDED,
|
||||
STATUS_DISK_FULL,
|
||||
STATUS_LOCK_NOT_GRANTED,
|
||||
|
||||
STATUS_DEVICE_NOT_READY,
|
||||
STATUS_IO_TIMEOUT,
|
||||
STATUS_MEDIA_WRITE_PROTECTED,
|
||||
STATUS_NO_MEDIA_IN_DRIVE,
|
||||
STATUS_VERIFY_REQUIRED,
|
||||
STATUS_UNRECOGNIZED_MEDIA,
|
||||
STATUS_UNRECOGNIZED_VOLUME,
|
||||
// STATUS_WRONG_VOLUME,
|
||||
STATUS_FS_DRIVER_REQUIRED,
|
||||
};
|
||||
|
||||
/*
|
||||
* This is a list of bug check types (not MS's)
|
||||
*/
|
||||
|
@@ -39,7 +39,7 @@ typedef struct _ERESOURCE
|
||||
typedef struct
|
||||
{
|
||||
LONG Count;
|
||||
PKTHREAD Owner;
|
||||
struct _KTHREAD* Owner;
|
||||
ULONG Contention;
|
||||
KEVENT Event;
|
||||
ULONG OldIrql;
|
||||
|
@@ -1,3 +1,6 @@
|
||||
#ifndef __INCLUDE_DDK_IODEF_H
|
||||
#define __INCLUDE_DDK_IODEF_H
|
||||
|
||||
typedef enum _IO_QUERY_DEVICE_DESCRIPTION
|
||||
{
|
||||
IoQueryDeviceIdentifier = 0,
|
||||
@@ -282,3 +285,17 @@ enum
|
||||
IRP_MJ_MAXIMUM_FUNCTION,
|
||||
};
|
||||
|
||||
enum
|
||||
/*
|
||||
* PURPOSE: Details about the result of a file open or create
|
||||
*/
|
||||
{
|
||||
FILE_CREATED,
|
||||
// FILE_OPENED,
|
||||
FILE_OVERWRITTEN,
|
||||
FILE_SUPERSEDED,
|
||||
FILE_EXISTS,
|
||||
FILE_DOES_NOT_EXIST,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -325,7 +325,7 @@ PCONFIGURATION_INFORMATION IoGetConfigurationInformation(VOID);
|
||||
*/
|
||||
PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(IRP* irp);
|
||||
|
||||
PEPROCESS IoGetCurrentProcess(VOID);
|
||||
struct _EPROCESS* IoGetCurrentProcess(VOID);
|
||||
|
||||
NTSTATUS IoGetDeviceObjectPointer(PUNICODE_STRING ObjectName,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
|
@@ -61,6 +61,10 @@ typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
|
||||
|
||||
/* STRUCTURE TYPES ***********************************************************/
|
||||
|
||||
typedef struct _ADAPTER_OBJECT
|
||||
{
|
||||
} ADAPTER_OBJECT, *PADAPTER_OBJECT;
|
||||
|
||||
/*
|
||||
* PURPOSE: Special timer associated with each device
|
||||
* NOTES: This is a guess
|
||||
@@ -282,7 +286,7 @@ typedef struct _IRP
|
||||
struct
|
||||
{
|
||||
KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
|
||||
PETHREAD Thread;
|
||||
struct _ETHREAD* Thread;
|
||||
PCHAR AuxiliaryBuffer;
|
||||
LIST_ENTRY ListEntry;
|
||||
struct _IO_STACK_LOCATION* CurrentStackLocation;
|
||||
|
@@ -8,6 +8,7 @@ typedef enum _EVENT_TYPE
|
||||
{
|
||||
NotificationEvent,
|
||||
SynchronizationEvent,
|
||||
SemaphoreType,
|
||||
} EVENT_TYPE;
|
||||
|
||||
typedef enum _KWAIT_REASON
|
||||
|
@@ -3,11 +3,25 @@
|
||||
|
||||
/* KERNEL FUNCTIONS ********************************************************/
|
||||
|
||||
struct _KAPC;
|
||||
|
||||
void KeInitializeApc(
|
||||
struct _KAPC *Apc,
|
||||
PKTHREAD Thread,
|
||||
UCHAR StateIndex,
|
||||
PKKERNEL_ROUTINE KernelRoutine,
|
||||
PKRUNDOWN_ROUTINE RundownRoutine,
|
||||
PKNORMAL_ROUTINE NormalRoutine,
|
||||
UCHAR Mode,
|
||||
PVOID Context
|
||||
);
|
||||
|
||||
void KeInsertQueueApc(struct _KAPC *Apc, PVOID SystemArgument1,
|
||||
PVOID SystemArgument2, UCHAR Mode);
|
||||
void KeAttachProcess(struct _EPROCESS* Process);
|
||||
void KeDetachProcess(VOID);
|
||||
VOID KeDrainApcQueue(VOID);
|
||||
VOID KeInitializeApc(PKAPC Apc, PKNORMAL_ROUTINE NormalRoutine,
|
||||
PVOID NormalContext,
|
||||
PKTHREAD TargetThread);
|
||||
BOOLEAN KeInsertQueueApc(PKAPC Apc);
|
||||
PKPROCESS KeGetCurrentProcess(VOID);
|
||||
|
||||
/*
|
||||
* FUNCTION: Acquires a spinlock so the caller can synchronize access to
|
||||
|
@@ -3,6 +3,8 @@
|
||||
#ifndef __INCLUDE_DDK_KETYPES_H
|
||||
#define __INCLUDE_DDK_KETYPES_H
|
||||
|
||||
struct _KMUTANT;
|
||||
|
||||
typedef LONG KPRIORITY;
|
||||
|
||||
typedef VOID (*PKBUGCHECK_CALLBACK_ROUTINE)(PVOID Buffer, ULONG Length);
|
||||
@@ -34,9 +36,75 @@ typedef struct
|
||||
USHORT WaitType;
|
||||
} KWAIT_BLOCK, *PKWAIT_BLOCK;
|
||||
|
||||
typedef struct _DISPATCHER_HEADER
|
||||
{
|
||||
UCHAR Type;
|
||||
UCHAR Absolute;
|
||||
UCHAR Size;
|
||||
UCHAR Inserted;
|
||||
LONG SignalState;
|
||||
LIST_ENTRY WaitListHead;
|
||||
} DISPATCHER_HEADER;
|
||||
|
||||
struct _KDPC;
|
||||
|
||||
typedef struct _KTIMER
|
||||
{
|
||||
/*
|
||||
* Pointers to maintain the linked list of activated timers
|
||||
*/
|
||||
LIST_ENTRY entry;
|
||||
|
||||
/*
|
||||
* Absolute expiration time in system time units
|
||||
*/
|
||||
signed long long expire_time;
|
||||
|
||||
/*
|
||||
* Optional dpc associated with the timer
|
||||
*/
|
||||
struct _KDPC* dpc;
|
||||
|
||||
/*
|
||||
* True if the timer is signaled
|
||||
*/
|
||||
BOOLEAN signaled;
|
||||
|
||||
/*
|
||||
* True if the timer is in the system timer queue
|
||||
*/
|
||||
BOOLEAN running;
|
||||
|
||||
/*
|
||||
* Type of the timer either Notification or Synchronization
|
||||
*/
|
||||
TIMER_TYPE type;
|
||||
|
||||
/*
|
||||
* Period of the timer in milliseconds (zero if once-only)
|
||||
*/
|
||||
ULONG period;
|
||||
|
||||
} KTIMER, *PKTIMER;
|
||||
|
||||
struct _KSPIN_LOCK;
|
||||
|
||||
typedef struct _KSPIN_LOCK
|
||||
{
|
||||
KIRQL irql;
|
||||
} KSPIN_LOCK, *PKSPIN_LOCK;
|
||||
|
||||
typedef struct _KDEVICE_QUEUE
|
||||
{
|
||||
LIST_ENTRY ListHead;
|
||||
BOOLEAN Busy;
|
||||
KSPIN_LOCK Lock;
|
||||
} KDEVICE_QUEUE, *PKDEVICE_QUEUE;
|
||||
|
||||
#if RIGHT_DEFINITION_PROVIDED_ABOVE
|
||||
#define _KTHREAD _ETHREAD
|
||||
|
||||
typedef struct _ETHREAD
|
||||
typedef struct _KTHREAD
|
||||
/*
|
||||
* PURPOSE: Describes a thread of execution
|
||||
*/
|
||||
@@ -84,17 +152,14 @@ typedef struct _ETHREAD
|
||||
*/
|
||||
hal_thread_state context;
|
||||
|
||||
} KTHREAD, *PKTHREAD, *PETHREAD;
|
||||
/*
|
||||
* PURPOSE: Timeout for the thread to be woken up
|
||||
*/
|
||||
signed long long int wake_time;
|
||||
|
||||
} KTHREAD, *PKTHREAD, *PETHREAD;
|
||||
#endif
|
||||
|
||||
typedef struct _DISPATCHER_HEADER
|
||||
{
|
||||
UCHAR Type;
|
||||
UCHAR Absolute;
|
||||
UCHAR Size;
|
||||
UCHAR Inserted;
|
||||
LONG SignalState;
|
||||
LIST_ENTRY WaitListHead;
|
||||
} DISPATCHER_HEADER;
|
||||
|
||||
typedef struct _KAPC
|
||||
{
|
||||
@@ -152,10 +217,6 @@ typedef struct _KEVENT
|
||||
} KEVENT, *PKEVENT;
|
||||
|
||||
|
||||
typedef struct _KSPIN_LOCK
|
||||
{
|
||||
KIRQL irql;
|
||||
} KSPIN_LOCK, *PKSPIN_LOCK;
|
||||
|
||||
typedef VOID (*PDRIVER_ADD_DEVICE)(VOID);
|
||||
|
||||
@@ -206,12 +267,6 @@ typedef struct _KDPC
|
||||
} KDPC, *PKDPC;
|
||||
|
||||
|
||||
typedef struct _KDEVICE_QUEUE
|
||||
{
|
||||
LIST_ENTRY ListHead;
|
||||
BOOLEAN Busy;
|
||||
KSPIN_LOCK Lock;
|
||||
} KDEVICE_QUEUE, *PKDEVICE_QUEUE;
|
||||
|
||||
typedef struct _KDEVICE_QUEUE_ENTRY
|
||||
{
|
||||
@@ -223,46 +278,6 @@ typedef struct _WAIT_CONTEXT_BLOCK
|
||||
{
|
||||
} WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
|
||||
|
||||
|
||||
typedef struct _KTIMER
|
||||
{
|
||||
/*
|
||||
* Pointers to maintain the linked list of activated timers
|
||||
*/
|
||||
LIST_ENTRY entry;
|
||||
|
||||
/*
|
||||
* Absolute expiration time in system time units
|
||||
*/
|
||||
unsigned long long expire_time;
|
||||
|
||||
/*
|
||||
* Optional dpc associated with the timer
|
||||
*/
|
||||
PKDPC dpc;
|
||||
|
||||
/*
|
||||
* True if the timer is signaled
|
||||
*/
|
||||
BOOLEAN signaled;
|
||||
|
||||
/*
|
||||
* True if the timer is in the system timer queue
|
||||
*/
|
||||
BOOLEAN running;
|
||||
|
||||
/*
|
||||
* Type of the timer either Notification or Synchronization
|
||||
*/
|
||||
TIMER_TYPE type;
|
||||
|
||||
/*
|
||||
* Period of the timer in milliseconds (zero if once-only)
|
||||
*/
|
||||
ULONG period;
|
||||
|
||||
} KTIMER, *PKTIMER;
|
||||
|
||||
struct _KINTERRUPT;
|
||||
|
||||
typedef BOOLEAN (*PKSERVICE_ROUTINE)(struct _KINTERRUPT* Interrupt,
|
||||
|
@@ -294,3 +294,4 @@ VOID MmUnlockPagableImageSection(PVOID ImageSectionHandle);
|
||||
|
||||
VOID MmUnmapIoSpace(PVOID BaseAddress, ULONG NumberOfBytes);
|
||||
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList);
|
||||
PVOID MmAllocateSection(ULONG Length);
|
||||
|
@@ -20,28 +20,8 @@ extern "C"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
|
||||
#define NTKERNELAPI
|
||||
|
||||
#define CTL_CODE(Dev, Func, Meth, Acc) ( ((Dev)<<16) | ((Acc)<<14) | ((Func)<<2) | (Meth))
|
||||
|
||||
// IOCTL Parameter buffering methods
|
||||
#define METHOD_BUFFERED 0
|
||||
#define METHOD_IN_DIRECT 1
|
||||
#define METHOD_OUT_DIRECT 2
|
||||
#define METHOD_NEITHER 3
|
||||
|
||||
// IOCTL File access type
|
||||
#define FILE_ANY_ACCESS 0
|
||||
#define FILE_READ_ACCESS 1
|
||||
#define FILE_WRITE_ACCESS 2
|
||||
|
||||
#define QUAD_PART(LI) (*(LONGLONG *)(&LI))
|
||||
|
||||
enum {
|
||||
STATUS_NOT_SUPPORTED = 9999,
|
||||
STATUS_DISK_OPERATION_FAILED
|
||||
};
|
||||
|
||||
#define IO_DISK_INCREMENT 4
|
||||
|
||||
@@ -49,11 +29,19 @@ enum {
|
||||
|
||||
#define FILE_OPENED 0x0001
|
||||
|
||||
#include <ddk/status.h>
|
||||
#include <ddk/ntdef.h>
|
||||
#include <ddk/defines.h>
|
||||
#include <ddk/types.h>
|
||||
#include <ddk/structs.h>
|
||||
#include <ddk/cfgtypes.h>
|
||||
#include <ddk/ketypes.h>
|
||||
#include <ddk/obtypes.h>
|
||||
#include <ddk/mmtypes.h>
|
||||
#include <ddk/iotypes.h>
|
||||
#include <ddk/extypes.h>
|
||||
#include <ddk/pstypes.h>
|
||||
#include <ddk/setypes.h>
|
||||
|
||||
#include <ddk/ioctrl.h>
|
||||
#include <internal/hal/ddk.h>
|
||||
|
||||
#include <ddk/rtl.h>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
struct _DIRECTORY_OBJECT;
|
||||
|
||||
typedef ULONG ACCESS_STATE, *PACCESS_STATE;
|
||||
|
||||
typedef struct _OBJECT_HANDLE_INFORMATION {
|
||||
ULONG HandleAttributes;
|
||||
ACCESS_MASK GrantedAccess;
|
||||
@@ -113,6 +115,8 @@ typedef struct _OBJECT
|
||||
*/
|
||||
ULONG HandleCount;
|
||||
|
||||
struct _DIRECTORY_OBJECT* Parent;
|
||||
|
||||
/*
|
||||
* PURPOSE: Object type
|
||||
* NOTE: This overlaps the first member of the object body
|
||||
@@ -125,6 +129,7 @@ typedef struct _OBJECT
|
||||
*/
|
||||
CSHORT Size;
|
||||
|
||||
|
||||
} OBJECT_HEADER, *POBJECT_HEADER;
|
||||
|
||||
/*
|
||||
|
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
|
||||
|
||||
/*
|
||||
* FUNCTION: Creates a thread which executes in kernel mode
|
||||
@@ -29,4 +28,4 @@ NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus);
|
||||
NTSTATUS PsSuspendThread(VOID);
|
||||
NTSTATUS PsWakeThread(PETHREAD Thread);
|
||||
PETHREAD PsGetCurrentThread(VOID);
|
||||
PEPROCESS PsGetCurrentProcess(VOID);
|
||||
struct _EPROCESS* PsGetCurrentProcess(VOID);
|
||||
|
@@ -2,69 +2,93 @@
|
||||
#define __INCLUDE_DDK_PSTYPES_H
|
||||
|
||||
#include <kernel32/heap.h>
|
||||
#include <internal/hal.h>
|
||||
|
||||
typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
|
||||
|
||||
typedef struct _STACK_INFORMATION
|
||||
{
|
||||
PVOID BaseAddress;
|
||||
PVOID UpperAddress;
|
||||
} STACK_INFORMATION, *PSTACK_INFORMATION;
|
||||
|
||||
typedef struct linux_sigcontext {
|
||||
int sc_gs;
|
||||
int sc_fs;
|
||||
int sc_es;
|
||||
int sc_ds;
|
||||
int sc_edi;
|
||||
int sc_esi;
|
||||
int sc_ebp;
|
||||
int sc_esp;
|
||||
int sc_ebx;
|
||||
int sc_edx;
|
||||
int sc_ecx;
|
||||
int sc_eax;
|
||||
int sc_trapno;
|
||||
int sc_err;
|
||||
int sc_eip;
|
||||
int sc_cs;
|
||||
int sc_eflags;
|
||||
int sc_esp_at_signal;
|
||||
int sc_ss;
|
||||
int sc_387;
|
||||
int sc_mask;
|
||||
int sc_cr2;
|
||||
} TRAP_FRAME, *PTRAP_FRAME;
|
||||
|
||||
typedef ULONG THREADINFOCLASS;
|
||||
|
||||
typedef void* ATOMTABLE;
|
||||
|
||||
typedef struct _pPebInfo {
|
||||
WCHAR* WindowTitle;
|
||||
WCHAR* ImageFile;
|
||||
WCHAR* CommandLine;
|
||||
WCHAR* DllPath;
|
||||
// STARTUPINFOW StartupInfo;
|
||||
} PEBINFO;
|
||||
|
||||
typedef struct _LDR_ {
|
||||
UCHAR Initialized;
|
||||
UCHAR InInitializationOrderModuleList;
|
||||
PVOID InLoadOrderModuleList;
|
||||
PVOID InMemoryOrderModuleList;
|
||||
} LDR, *PLDR;
|
||||
|
||||
|
||||
typedef struct _NT_PEB
|
||||
{
|
||||
UCHAR InheritedAddressSpace;
|
||||
UCHAR ReadImageFileExecOptions;
|
||||
UCHAR BeingDebugged;
|
||||
LONG ImageBaseAddress;
|
||||
LDR Ldr;
|
||||
DWORD dwTlsBits[2]; // tls in use bits
|
||||
WORD NumberOfProcessors;
|
||||
WORD NtGlobalFlag;
|
||||
DWORD HeapReserve;
|
||||
DWORD HeapCommit;
|
||||
DWORD HeapDecommitFreeBlockThreshold;
|
||||
DWORD NumberOfHeaps;
|
||||
DWORD MaxiumNumberOfHeaps;
|
||||
PEBINFO* PebInfo;
|
||||
PHEAP ProcessHeap;
|
||||
ATOMTABLE LocalAtomTable;
|
||||
LPCRITICAL_SECTION CriticalSection;
|
||||
DWORD CriticalSectionTimeout;
|
||||
WORD MajorVersion;
|
||||
WORD MinorVersion;
|
||||
WORD BuildNumber;
|
||||
WORD PlatformId;
|
||||
} NT_PEB, *PNT_PEB;
|
||||
|
||||
typedef struct _CLIENT_ID
|
||||
{
|
||||
HANDLE UniqueProcess;
|
||||
HANDLE UniqueThread;
|
||||
} CLIENT_ID, *PCLIENT_ID;
|
||||
|
||||
//typedef void* HEAP;
|
||||
typedef void* HANDLE_TABLE;
|
||||
typedef void* ATOMTABLE;
|
||||
|
||||
typedef struct _pPebInfo {
|
||||
LPWSTR lpCommandLine;
|
||||
DWORD cb;
|
||||
HANDLE hStdInput; //18
|
||||
HANDLE hStdput;
|
||||
HANDLE hStdError;
|
||||
LPWSTR lpEnvironment;
|
||||
DWORD dwX;
|
||||
DWORD dwY;
|
||||
DWORD dwXSize;
|
||||
DWORD dwYSize;
|
||||
DWORD dwXCountChars;
|
||||
DWORD dwYCountChars;
|
||||
DWORD dwFillAttribute;
|
||||
DWORD dwFlags;
|
||||
DWORD wShowWindow;
|
||||
LPTSTR lpTitle;
|
||||
LPTSTR lpDesktop;
|
||||
LPTSTR reserved;
|
||||
DWORD cbReserved2;
|
||||
LPTSTR lpReserved1;
|
||||
} PEBINFO;
|
||||
|
||||
typedef struct _NT_PEB
|
||||
{
|
||||
|
||||
LONG ImageBaseAddress;
|
||||
DWORD nActiveStdHandle;
|
||||
void *HeapIndex;
|
||||
DWORD dwTlsBits[2]; // tls in use bits
|
||||
WORD NumberOfProcessors;
|
||||
WORD NtGlobalFlag;
|
||||
DWORD dwCriticalSectionTime;
|
||||
DWORD dwHeapReserve;
|
||||
DWORD dwHeapCommit;
|
||||
DWORD dwHeapDecommitFreeBlockThreshold;
|
||||
DWORD dwNumberOfHeaps;
|
||||
DWORD dwMaxiumNumberOfHeaps;
|
||||
PEBINFO *pPebInfo;
|
||||
HEAP *pProcessHeap;
|
||||
HANDLE_TABLE htGDISharedHandleTable;
|
||||
ATOMTABLE LocalAtomTable;
|
||||
CRITICAL_SECTION *pCriticalSection;
|
||||
WORD wMajorVersion;
|
||||
WORD wMinorVersion;
|
||||
WORD wBuildNumber;
|
||||
WORD wPlatformId;
|
||||
} NT_PEB, *PPEB;
|
||||
|
||||
|
||||
typedef struct _NT_TIB {
|
||||
struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
|
||||
PVOID StackBase;
|
||||
@@ -73,7 +97,7 @@ typedef struct _NT_TIB {
|
||||
union {
|
||||
PVOID FiberData;
|
||||
ULONG Version;
|
||||
} s;
|
||||
} Fib;
|
||||
PVOID ArbitraryUserPointer;
|
||||
struct _NT_TIB *Self;
|
||||
} NT_TIB, *PNT_TIB;
|
||||
@@ -82,79 +106,180 @@ typedef struct _NT_TEB
|
||||
{
|
||||
|
||||
NT_TIB Tib;
|
||||
DWORD dwProcessId;
|
||||
DWORD dwThreadId;
|
||||
HANDLE hRPC;
|
||||
CLIENT_ID Cid;
|
||||
HANDLE RPCHandle;
|
||||
PVOID TlsData;
|
||||
NT_PEB *pPeb;
|
||||
DWORD dwErrCode;
|
||||
WORD nMutexCount;
|
||||
LCID Locale;
|
||||
//HQUEUE MessageQueue
|
||||
DWORD dwTlsIndex ;
|
||||
LPVOID TlsData[512];
|
||||
|
||||
DWORD LastErrorCode;
|
||||
NTSTATUS LastStatusValue;
|
||||
DWORD LockCount;
|
||||
UCHAR HardErrorMode;
|
||||
|
||||
} NT_TEB;
|
||||
|
||||
typedef struct _KTHREAD
|
||||
{
|
||||
DISPATCHER_HEADER DispatcherHeader;
|
||||
TIME ElapsedTime;
|
||||
TIME KernelTime;
|
||||
TIME UserTime;
|
||||
STACK_INFORMATION StackInformation;
|
||||
PVOID ServiceDescriptorTable; // points to KeServiceDescriptorTable
|
||||
KAFFINITY Affinity;
|
||||
KPRIORITY CurrentPriority;
|
||||
KPRIORITY BasePriority;
|
||||
ULONG Quantum;
|
||||
UCHAR ThreadState; //Thread state is a typeless enum, otherwise it should be const integer
|
||||
ULONG FreezeCount;
|
||||
ULONG SuspendCount;
|
||||
PTRAP_FRAME TrapFrame;
|
||||
PVOID *Tls;
|
||||
KWAIT_BLOCK WaitBlock[4];
|
||||
struct _KMUTANT* MutantList;
|
||||
PLIST_ENTRY ApcList;
|
||||
UCHAR KernelApcDisable;
|
||||
KTIMER TimerBlock;
|
||||
KDEVICE_QUEUE DeviceQueue;
|
||||
NT_TEB* Teb;
|
||||
|
||||
typedef NT_TEB *PINITIAL_TEB;
|
||||
/*
|
||||
* PURPOSE: CPU state
|
||||
* NOTE: I have temporarily added this to give somewhere to store
|
||||
* cpu state when the thread isn't running
|
||||
*/
|
||||
hal_thread_state Context;
|
||||
LIST_ENTRY Entry;
|
||||
} KTHREAD, *PKTHREAD;
|
||||
|
||||
|
||||
// According to documentation the stack should have a commited [ 1 page ] and
|
||||
// a reserved part [ 1 M ].
|
||||
|
||||
typedef struct _INITIAL_TEB {
|
||||
PVOID StackCommit;
|
||||
PVOID StackReserved;
|
||||
} INITIAL_TEB, *PINITIAL_TEB;
|
||||
|
||||
|
||||
|
||||
|
||||
//ThreadState defines the current state of a thread
|
||||
//FIXME I am allready defined in psmgr.h as a enum
|
||||
/*
|
||||
enum
|
||||
{
|
||||
THREAD_STATE_INITIALIZED = 0,
|
||||
THREAD_STATE_READY,
|
||||
THREAD_STATE_RUNNING,
|
||||
THREAD_STATE_STANDBY,
|
||||
THREAD_STATE_TERMINATED,
|
||||
THREAD_STATE_WAIT,
|
||||
THREAD_STATE_TRANSITION,
|
||||
THREAD_STATE_RESERVED
|
||||
};
|
||||
*/
|
||||
|
||||
// wait reason only applies for threads in a wait state
|
||||
// part of this enum is double ????
|
||||
|
||||
/*
|
||||
typedef _KWAIT_REASON
|
||||
{
|
||||
WAIT_EXCECUTIVE1 = 0,
|
||||
WAIT_FREE_PAGE1,
|
||||
WAIT_PAGE_IN1,
|
||||
WAIT_POOL_ALLOCATION1,
|
||||
WAIT_EXECUTION_DELAY1,
|
||||
WAIT_SUSPENDED_CONDITION1,
|
||||
WAIT_USER_REQUEST1,
|
||||
WAIT_EXCECUTIVE2,
|
||||
WAIT_FREE_PAGE2,
|
||||
WAIT_PAGE_IN2,
|
||||
WAIT_POOL_ALLOCATION2,
|
||||
WAIT_EXECUTION_DELAY2,
|
||||
WAIT_SUSPENDED_CONDITION2,
|
||||
WAIT_USER_REQUEST2,
|
||||
WAIT_EVENT_PAIR_HIGH,
|
||||
WAIT_EVENT_PAIR_LOW,
|
||||
WAIT_LPC_RECEIVE,
|
||||
WAIT_LPC_REPLY,
|
||||
WAIT_VIRTUAL_MEMORY,
|
||||
WAIT_PAGE_OUT
|
||||
} KWAIT_REASON;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// TopLevelIrp can be one of the following values:
|
||||
// FIXME I belong somewhere else
|
||||
|
||||
#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
|
||||
#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
|
||||
#define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
|
||||
#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
|
||||
#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
|
||||
|
||||
typedef struct _TOP_LEVEL_IRP
|
||||
{
|
||||
PIRP TopLevelIrp;
|
||||
ULONG TopLevelIrpConst;
|
||||
} TOP_LEVEL_IRP;
|
||||
|
||||
typedef struct _ETHREAD {
|
||||
KTHREAD Tcb;
|
||||
TIME CreateTime;
|
||||
TIME ExitTime;
|
||||
NTSTATUS ExitStatus;
|
||||
LIST_ENTRY PostBlockList;
|
||||
LIST_ENTRY TerminationPortList;
|
||||
ULONG ActiveTimerListLock;
|
||||
PVOID ActiveTimerListHead;
|
||||
CLIENT_ID Cid;
|
||||
PLARGE_INTEGER LpcReplySemaphore;
|
||||
PVOID LpcReplyMessage;
|
||||
PLARGE_INTEGER LpcReplyMessageId;
|
||||
PVOID ImpersonationInfo;
|
||||
LIST_ENTRY IrpList; //
|
||||
TOP_LEVEL_IRP TopLevelIrp;
|
||||
ULONG ReadClusterSize;
|
||||
UCHAR ForwardClusterOnly;
|
||||
UCHAR DisablePageFaultClustering;
|
||||
UCHAR DeadThread;
|
||||
UCHAR HasTerminated;
|
||||
ACCESS_MASK GrantedAccess;
|
||||
struct _EPROCESS* ThreadsProcess;
|
||||
PKSTART_ROUTINE StartAddress;
|
||||
LPTHREAD_START_ROUTINE Win32StartAddress; // Should Specify a win32 start func
|
||||
UCHAR LpcExitThreadCalled;
|
||||
UCHAR HardErrorsAreDisabled;
|
||||
} ETHREAD, *PETHREAD;
|
||||
|
||||
|
||||
typedef struct _KPROCESS {
|
||||
DISPATCHER_HEADER DispatcherHeader;
|
||||
PVOID PageTableDirectory; // FIXME: I shoud point to a PTD
|
||||
TIME ElapsedTime;
|
||||
TIME KernelTime;
|
||||
TIME UserTime;
|
||||
LIST_ENTRY InOutSwap; // ??
|
||||
KSPIN_LOCK SpinLock;
|
||||
KAFFINITY Affinity;
|
||||
ULONG StackCount;
|
||||
KPRIORITY BasePriority;
|
||||
ULONG DefaultThreadQuantum;
|
||||
UCHAR ProcessState;
|
||||
ULONG ThreadSeed;
|
||||
UCHAR DisableBoost;
|
||||
|
||||
/*
|
||||
* Added by David Welch (welch@mcmail.com)
|
||||
*/
|
||||
LIST_ENTRY MemoryAreaList;
|
||||
} KPROCESS, *PKPROCESS;
|
||||
|
||||
typedef struct _EPROCESS
|
||||
{
|
||||
KPROCESS Pcb;
|
||||
} EPROCESS, *PEPROCESS;
|
||||
|
||||
//typedef KTHREAD ETHREAD, *PETHREAD;
|
||||
|
||||
#if ETHREAD_NOT_THE_SAME_AS_KTHREAD
|
||||
typedef struct _ETHREAD
|
||||
{
|
||||
EPROCESS* Process;
|
||||
} ETHREAD, *PETHREAD;
|
||||
|
||||
/*
|
||||
* PURPOSE: Thread object
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
CSHORT Type;
|
||||
CSHORT Size;
|
||||
|
||||
/*
|
||||
* PURPOSE: Entry in the linked list of threads
|
||||
*/
|
||||
LIST_ENTRY Entry;
|
||||
|
||||
/*
|
||||
* PURPOSE: Current state of the thread
|
||||
*/
|
||||
ULONG State;
|
||||
|
||||
/*
|
||||
* PURPOSE: Priority modifier of the thread
|
||||
*/
|
||||
ULONG Priority;
|
||||
|
||||
/*
|
||||
* PURPOSE: Pointer to our parent process
|
||||
*/
|
||||
// PEPROCESS Parent;
|
||||
|
||||
/*
|
||||
* PURPOSE: Handle of our parent process
|
||||
*/
|
||||
HANDLE ParentHandle;
|
||||
|
||||
/*
|
||||
* PURPOSE: Not currently used
|
||||
*/
|
||||
ULONG AffinityMask;
|
||||
|
||||
/*
|
||||
* PURPOSE: Saved thread context
|
||||
*/
|
||||
hal_thread_state context;
|
||||
|
||||
} THREAD_OBJECT, *PTHREAD_OBJECT;
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_DDK_PSTYPES_H */
|
||||
|
@@ -153,6 +153,8 @@ LONG RtlCompareString(PSTRING String1, PSTRING String2,
|
||||
LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
|
||||
PUNICODE_STRING String2,
|
||||
BOOLEAN BaseInsensitive);
|
||||
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
|
||||
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
|
||||
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
|
||||
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length);
|
||||
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
|
||||
@@ -165,12 +167,27 @@ NTSTATUS RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||
NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo,
|
||||
PWSTR Path,
|
||||
PWSTR ValueName);
|
||||
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
|
||||
LONG Multiplier);
|
||||
ULONG RtlEnlargedUnsignedDivide(ULARGE_INTEGER Dividend,
|
||||
ULONG Divisor,
|
||||
PULONG Remainder);
|
||||
LARGE_INTEGER RtlEnlargedUnsignedMultiply(ULONG Multiplicand,
|
||||
ULONG Multiplier);
|
||||
BOOLEAN RtlEqualString(PSTRING String1,
|
||||
PSTRING String2,
|
||||
BOOLEAN CaseInSensitive);
|
||||
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1,
|
||||
PUNICODE_STRING String2,
|
||||
BOOLEAN CaseInSensitive);
|
||||
LARGE_INTEGER RtlExtendedIntegerMultiply(LARGE_INTEGER Multiplicand,
|
||||
LONG Multiplier);
|
||||
LARGE_INTEGER RtlExtendedLargeIntegerDivide(LARGE_INTEGER Dividend,
|
||||
ULONG Divisor,
|
||||
PULONG Remainder);
|
||||
LARGE_INTEGER RtlExtendedMagicDivide(LARGE_INTEGER Dividend,
|
||||
LARGE_INTEGER MagicDivisor,
|
||||
CCHAR ShiftCount);
|
||||
VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill);
|
||||
VOID RtlFreeAnsiString(PANSI_STRING AnsiString);
|
||||
VOID RtlFreeUnicodeString(PUNICODE_STRING UnicodeString);
|
||||
@@ -182,8 +199,13 @@ VOID RtlInitUnicodeString(PUNICODE_STRING DestinationString,
|
||||
NTSTATUS RtlIntegerToUnicodeString(ULONG Value,
|
||||
ULONG Base,
|
||||
PUNICODE_STRING String);
|
||||
LARGE_INTEGER RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
|
||||
LARGE_INTEGER Addend2);
|
||||
VOID RtlLargeIntegerAnd(PLARGE_INTEGER Result,
|
||||
LARGE_INTEGER Source,
|
||||
LARGE_INTEGER Mask);
|
||||
|
||||
/** LARGE_INTEGER Functions *******************************************/
|
||||
/* MISSING FUNCTIONS GO HERE */
|
||||
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
|
||||
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
|
||||
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
|
||||
@@ -240,8 +262,6 @@ LARGE_INTEGER RtlLargeIntegerShiftRight(LARGE_INTEGER LargeInteger,
|
||||
LARGE_INTEGER RtlLargeIntegerSubtract(LARGE_INTEGER Minuend,
|
||||
LARGE_INTEGER Subtrahend);
|
||||
|
||||
/* MISSING FUNCTIONS GO HERE */
|
||||
|
||||
ULONG RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
|
||||
VOID RtlMoveMemory(PVOID Destination, CONST VOID* Source, ULONG Length);
|
||||
NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo,
|
||||
@@ -262,6 +282,7 @@ BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS TimeFields, PLARGE_INTEGER Time);
|
||||
VOID RtlTimeToTimeFields(PLARGE_INTEGER Time, PTIME_FIELDS TimeFields);
|
||||
PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep, PWSTR* temp);
|
||||
VOID RtlGetCallersAddress(PVOID* CallersAddress);
|
||||
VOID RtlZeroMemory(PVOID Destination, ULONG Length);
|
||||
|
||||
typedef struct {
|
||||
ULONG Length;
|
||||
|
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory for details
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: include/ddk/setypes.h
|
||||
* PURPOSE: Security manager types
|
||||
* REVISION HISTORY:
|
||||
* ??/??/??: Created with empty stubs by David Welch
|
||||
* 29/08/98: ACCESS_TOKEN definition from Boudewijn Dekker
|
||||
*/
|
||||
|
||||
typedef ULONG ACCESS_MODE, *PACCESS_MODE;
|
||||
|
||||
@@ -8,3 +17,25 @@ typedef struct _SECURITY_SUBJECT_CONTEXT
|
||||
typedef struct _SECURITY_DESCRIPTOR_CONTEXT
|
||||
{
|
||||
} SECURITY_DESCRIPTOR_CONTEXT, *PSECURITY_DESCRIPTOR_CONTEXT;
|
||||
|
||||
typedef struct _ACCESS_TOKEN {
|
||||
TOKEN_SOURCE TokenSource;
|
||||
LUID AuthenticationId;
|
||||
LARGE_INTEGER ExpirationTime;
|
||||
LUID ModifiedId;
|
||||
ULONG UserAndGroupCount;
|
||||
ULONG PrivilegeCount;
|
||||
ULONG VariableLength;
|
||||
ULONG DynamicCharged;
|
||||
ULONG DynamicAvailable;
|
||||
ULONG DefaultOwnerIndex;
|
||||
PACL DefaultDacl;
|
||||
TOKEN_TYPE TokenType;
|
||||
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
|
||||
UCHAR TokenFlags;
|
||||
UCHAR TokenInUse;
|
||||
UCHAR Unused[2];
|
||||
PVOID ProxyData;
|
||||
PVOID AuditData;
|
||||
UCHAR VariablePart[0];
|
||||
} ACCESS_TOKEN, *PACCESS_TOKEN;
|
||||
|
@@ -1,14 +0,0 @@
|
||||
/* SYSTEM STRUCTURES ******************************************************/
|
||||
|
||||
#include <internal/hal/hal.h>
|
||||
#include <ddk/cfgtypes.h>
|
||||
#include <ddk/ketypes.h>
|
||||
#include <ddk/obtypes.h>
|
||||
#include <ddk/mmtypes.h>
|
||||
#include <ddk/iotypes.h>
|
||||
#include <ddk/extypes.h>
|
||||
#include <ddk/pstypes.h>
|
||||
|
||||
typedef struct _ADAPTER_OBJECT
|
||||
{
|
||||
} ADAPTER_OBJECT, *PADAPTER_OBJECT;
|
@@ -58,10 +58,16 @@ typedef ULONG LOCK_OPERATION;
|
||||
typedef ULONG KEY_INFORMATION_CLASS;
|
||||
typedef ULONG FILE_INFORMATION_CLASS;
|
||||
typedef ULONG KEY_VALUE_INFORMATION_CLASS;
|
||||
typedef ULONG PHYSICAL_ADDRESS;
|
||||
typedef LARGE_INTEGER PHYSICAL_ADDRESS;
|
||||
typedef PHYSICAL_ADDRESS* PPHYSICAL_ADDRESS;
|
||||
typedef ULONG WAIT_TYPE;
|
||||
//typedef ULONG KINTERRUPT_MODE;
|
||||
typedef USHORT CSHORT;
|
||||
|
||||
|
||||
typedef struct _TIME {
|
||||
DWORD LowPart;
|
||||
LONG HighPart;
|
||||
} TIME;
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -16,13 +16,13 @@
|
||||
#ifndef __INTERNAL_DEBUG
|
||||
#define __INTERNAL_DEBUG
|
||||
|
||||
#define UNIMPLEMENTED do {printk("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
|
||||
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DPRINT(fmt,args...) do { printk("(%s:%d) ",__FILE__,__LINE__); printk(fmt,args); } while(0);
|
||||
//#define assert(x) if (!(x)) {printk("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
|
||||
#define assert(x) if (!(x)) {printk("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
|
||||
#define CHECKPOINT printk("%s:%d\n",__FILE__,__LINE__)
|
||||
#define DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0);
|
||||
//#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
|
||||
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
|
||||
#define CHECKPOINT DbgPrint("%s:%d\n",__FILE__,__LINE__)
|
||||
#else
|
||||
#define DPRINT(fmt,args...)
|
||||
#define assert(x)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: dma.h,v 1.3 1998/08/25 04:48:36 rex Exp $
|
||||
/* $Id: dma.h,v 1.1.1.2 1998/08/25 04:27:32 rex Exp $
|
||||
* linux/include/asm/dma.h: Defines for using and allocating dma channels.
|
||||
* Written by Hennus Bergman, 1992.
|
||||
* High DMA channel support & info by Hannu Savolainen
|
||||
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __INTERNAL_HAL_HAL_H
|
||||
#define __INTERNAL_HAL_HAL_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short previous_task;
|
||||
unsigned short reserved1;
|
||||
unsigned long esp0;
|
||||
unsigned short ss0;
|
||||
unsigned short reserved2;
|
||||
unsigned long esp1;
|
||||
unsigned short ss1;
|
||||
unsigned short reserved3;
|
||||
unsigned long esp2;
|
||||
unsigned short ss2;
|
||||
unsigned short reserved4;
|
||||
unsigned long cr3;
|
||||
unsigned long eip;
|
||||
unsigned long eflags;
|
||||
unsigned long eax;
|
||||
unsigned long ecx;
|
||||
unsigned long edx;
|
||||
unsigned long ebx;
|
||||
unsigned long esp;
|
||||
unsigned long ebp;
|
||||
unsigned long esi;
|
||||
unsigned long edi;
|
||||
unsigned short es;
|
||||
unsigned short reserved5;
|
||||
unsigned short cs;
|
||||
unsigned short reserved6;
|
||||
unsigned short ss;
|
||||
unsigned short reserved7;
|
||||
unsigned short ds;
|
||||
unsigned short reserved8;
|
||||
unsigned short fs;
|
||||
unsigned short reserved9;
|
||||
unsigned short gs;
|
||||
unsigned short reserved10;
|
||||
unsigned short ldt;
|
||||
unsigned short reserved11;
|
||||
unsigned short trap;
|
||||
unsigned short iomap_base;
|
||||
|
||||
unsigned short nr;
|
||||
|
||||
unsigned char io_bitmap[1];
|
||||
} hal_thread_state;
|
||||
|
||||
/*
|
||||
* FUNCTION: Probes for a PCI bus
|
||||
* RETURNS: True if found
|
||||
*/
|
||||
BOOL HalPciProbe(void);
|
||||
|
||||
/*
|
||||
* FUNCTION: Probes for a BIOS32 extension
|
||||
*/
|
||||
VOID Hal_bios32_probe(VOID);
|
||||
|
||||
/*
|
||||
* FUNCTION: Determines if a a bios32 service is present
|
||||
*/
|
||||
BOOLEAN Hal_bios32_is_service_present(ULONG service);
|
||||
|
||||
|
||||
#endif /* __INTERNAL_HAL_HAL_H */
|
@@ -5,7 +5,7 @@
|
||||
#ifndef __INTERNAL_HAL_PAGE_H
|
||||
#define __INTERNAL_HAL_PAGE_H
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#define PAGESIZE (4096)
|
||||
|
||||
@@ -27,6 +27,8 @@ void set_page(unsigned int vaddr, unsigned int attributes,
|
||||
#define PA_READ (1<<0)
|
||||
#define PA_WRITE ((1<<0)+(1<<1))
|
||||
#define PA_EXECUTE PA_READ
|
||||
#define PA_PCD (1<<4)
|
||||
#define PA_PWT (1<<3)
|
||||
|
||||
/*
|
||||
* Page attributes
|
||||
@@ -60,7 +62,6 @@ extern inline unsigned int* get_page_directory(void)
|
||||
unsigned int page_dir=0;
|
||||
__asm__("movl %%cr3,%0\n\t"
|
||||
: "=r" (page_dir));
|
||||
// printk("page_dir %x %x\n",page_dir,physical_to_linear(page_dir));
|
||||
return((unsigned int *)physical_to_linear(page_dir));
|
||||
}
|
||||
|
||||
|
@@ -1,109 +1 @@
|
||||
/*
|
||||
* Various useful prototypes
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL_H
|
||||
#define __KERNEL_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/linkage.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/*
|
||||
* Use these to place a function in a specific section of the executable
|
||||
*/
|
||||
#define PLACE_IN_SECTION(s) __attribute__((section (s)))
|
||||
#define INIT_FUNCTION (PLACE_IN_SECTION("init"))
|
||||
#define PAGE_LOCKED_FUNCTION (PLACE_IN_SECTION("pagelk"))
|
||||
#define PAGE_UNLOCKED_FUNCTION (PLACE_IN_SECTION("pagepo"))
|
||||
|
||||
/*
|
||||
* Maximum size of the kmalloc area (this is totally arbitary)
|
||||
*/
|
||||
#define NONPAGED_POOL_SIZE (4*1024*1024)
|
||||
|
||||
VOID KiInterruptDispatch(unsigned int irq);
|
||||
VOID KiDispatchInterrupt(unsigned int irq);
|
||||
VOID KeTimerInterrupt(VOID);
|
||||
|
||||
/*
|
||||
* Defines a descriptor as it appears in the processor tables
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned int a;
|
||||
unsigned int b;
|
||||
} descriptor;
|
||||
|
||||
extern descriptor idt[256];
|
||||
extern descriptor gdt[256];
|
||||
|
||||
/*
|
||||
* printf style functions
|
||||
*/
|
||||
asmlinkage void printk(const char* fmt, ...);
|
||||
int vsprintf(char *buf, const char *fmt, va_list args);
|
||||
int sprintf(char* buf, const char* fmt, ...);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
* Magic value (useless really)
|
||||
*/
|
||||
unsigned int magic;
|
||||
|
||||
/*
|
||||
* Cursor position
|
||||
*/
|
||||
unsigned int cursorx;
|
||||
unsigned int cursory;
|
||||
|
||||
/*
|
||||
* Number of files (including the kernel) loaded
|
||||
*/
|
||||
unsigned int nr_files;
|
||||
|
||||
/*
|
||||
* Range of physical memory being used by the system
|
||||
*/
|
||||
unsigned int start_mem;
|
||||
unsigned int end_mem;
|
||||
|
||||
/*
|
||||
* List of module lengths (terminated by a 0)
|
||||
*/
|
||||
unsigned int module_length[64];
|
||||
} boot_param;
|
||||
|
||||
|
||||
/*
|
||||
* Initalization functions (called once by main())
|
||||
*/
|
||||
void MmInitalize(boot_param* bp);
|
||||
void InitalizeExceptions(void);
|
||||
void InitalizeIRQ(void);
|
||||
void InitializeTimer(void);
|
||||
void InitConsole(boot_param* bp);
|
||||
void KeInitDpc(void);
|
||||
void HalInit(boot_param* bp);
|
||||
void IoInit(void);
|
||||
void ObjNamespcInit(void);
|
||||
void PsMgrInit(void);
|
||||
void KeInitializeBugCheck(void);
|
||||
VOID KeInitializeDispatcher(VOID);
|
||||
void TstBegin(void);
|
||||
void KeCalibrateTimerLoop(void);
|
||||
|
||||
/*
|
||||
* FUNCTION: Called to execute queued dpcs
|
||||
*/
|
||||
void KeDrainDpcQueue(void);
|
||||
|
||||
void KeExpireTimers(void);
|
||||
|
||||
typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
|
||||
asmlinkage unsigned int ExHookException(exception_hook fn, UINT exp);
|
||||
|
||||
#endif
|
||||
#include <internal/ntoskrnl.h>
|
||||
|
@@ -2,81 +2,60 @@
|
||||
* Higher level memory managment definitions
|
||||
*/
|
||||
|
||||
#ifndef __MM_H
|
||||
#define __MM_H
|
||||
#ifndef __INCLUDE_INTERNAL_MM_H
|
||||
#define __INCLUDE_INTERNAL_MM_H
|
||||
|
||||
#define PAGE_SYSTEM (0x80000000)
|
||||
|
||||
#include <internal/linkage.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct _memory_area
|
||||
/*
|
||||
* PURPOSE: Describes an area of virtual memory
|
||||
*/
|
||||
/* TYPES *********************************************************************/
|
||||
|
||||
enum
|
||||
{
|
||||
/*
|
||||
* Access protection
|
||||
*/
|
||||
unsigned int access;
|
||||
MEMORY_AREA_INVALID,
|
||||
MEMORY_AREA_SECTION_VIEW,
|
||||
MEMORY_AREA_CONTINUOUS_MEMORY,
|
||||
MEMORY_AREA_NO_CACHE,
|
||||
MEMORY_AREA_IO_MAPPING,
|
||||
MEMORY_AREA_SYSTEM,
|
||||
MEMORY_AREA_MDL_MAPPING,
|
||||
};
|
||||
|
||||
/*
|
||||
* Memory region base
|
||||
*/
|
||||
unsigned int base;
|
||||
typedef struct
|
||||
{
|
||||
FILE_OBJECT* File;
|
||||
} SECTION_OBJECT;
|
||||
|
||||
/*
|
||||
* Memory region length
|
||||
*/
|
||||
unsigned int length;
|
||||
typedef struct
|
||||
{
|
||||
ULONG Type;
|
||||
ULONG BaseAddress;
|
||||
ULONG Length;
|
||||
ULONG Attributes;
|
||||
LIST_ENTRY Entry;
|
||||
union
|
||||
{
|
||||
SECTION_OBJECT* Section;
|
||||
} d;
|
||||
} MEMORY_AREA;
|
||||
|
||||
/*
|
||||
* Memory type (Mapped file, mapped from an executable or private)
|
||||
*/
|
||||
unsigned int type;
|
||||
|
||||
/*
|
||||
* Memory region state (committed, reserved or free)
|
||||
*/
|
||||
unsigned int state;
|
||||
|
||||
/*
|
||||
* Original access protection
|
||||
*/
|
||||
unsigned int initial_access;
|
||||
|
||||
/*
|
||||
* Used to maintain the linked list of memory areas
|
||||
*/
|
||||
struct _memory_area* previous;
|
||||
struct _memory_area* next;
|
||||
|
||||
/*
|
||||
* True the region is locked
|
||||
*/
|
||||
BOOL lock;
|
||||
|
||||
/*
|
||||
* FUNCTION: Decommits all the pages in the regions
|
||||
*/
|
||||
void (*free)(struct _memory_area* marea);
|
||||
|
||||
/*
|
||||
* FUNCTION: Handles a page fault by loading the required page
|
||||
* RECEIVES:
|
||||
* marea = the memory area
|
||||
* address = the relative address of the page to load
|
||||
* RETURNS:
|
||||
* TRUE = the access should be restarted
|
||||
* FALSE = the access was illegal and an exception should
|
||||
* be generated
|
||||
* NOTES: This function is guarrented to be called within the context
|
||||
* of the thread which required a page to be loaded
|
||||
*/
|
||||
BOOL (*load_page)(struct _memory_area* marea, unsigned int address);
|
||||
} memory_area;
|
||||
|
||||
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
||||
ULONG Type,
|
||||
PULONG BaseAddress,
|
||||
ULONG Length,
|
||||
ULONG Attributes,
|
||||
MEMORY_AREA** Result);
|
||||
MEMORY_AREA* MmOpenMemoryAreaByAddress(ULONG Address);
|
||||
NTSTATUS MmInitMemoryAreas(VOID);
|
||||
VOID ExInitNonPagedPool(ULONG BaseAddress);
|
||||
NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
|
||||
ULONG Length,
|
||||
BOOLEAN FreePages);
|
||||
VOID MmDumpMemoryAreas(VOID);
|
||||
|
||||
/*
|
||||
* FUNCTION: Gets a page with a restricted max physical address (i.e.
|
||||
@@ -120,27 +99,4 @@ void mark_page_not_writable(unsigned int vaddr);
|
||||
|
||||
void VirtualInit(boot_param* bp);
|
||||
|
||||
/*
|
||||
* FUNCTION: Returns the first memory area starting in the region or the last
|
||||
* one before the start of the region
|
||||
* ARGUMENTS:
|
||||
* list_head = Head of the list of memory areas to search
|
||||
* base = base address of the region
|
||||
* length = length of the region
|
||||
* RETURNS: A pointer to the area found or
|
||||
* NULL if the region was before the first region on the list
|
||||
*/
|
||||
memory_area* find_first_marea(memory_area* list_head, unsigned int base,
|
||||
unsigned int length);
|
||||
|
||||
/*
|
||||
* Head of the list of system memory areas
|
||||
*/
|
||||
extern memory_area* system_memory_area_list_head;
|
||||
|
||||
/*
|
||||
* Head of the list of user memory areas (this should be per process)
|
||||
*/
|
||||
extern memory_area* memory_area_list_head;
|
||||
|
||||
#endif
|
||||
|
@@ -26,6 +26,7 @@ typedef struct _DIRECTORY_OBJECT
|
||||
* PURPOSE: Head of the list of our subdirectories
|
||||
*/
|
||||
LIST_ENTRY head;
|
||||
KSPIN_LOCK Lock;
|
||||
} DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
|
||||
|
||||
|
||||
|
@@ -1,9 +1,13 @@
|
||||
#ifndef __INCLUDE_INTERNAL_PSMGR_H
|
||||
#define __INCLUDE_INTERNAL_PSMGR_H
|
||||
|
||||
#include <internal/hal/hal.h>
|
||||
#include <internal/hal.h>
|
||||
|
||||
extern EPROCESS SystemProcess;
|
||||
extern HANDLE SystemProcessHandle;
|
||||
|
||||
void PsInitThreadManagment(void);
|
||||
VOID PsInitIdleThread(VOID);
|
||||
|
||||
/*
|
||||
* PURPOSE: Thread states
|
||||
|
@@ -9,9 +9,9 @@
|
||||
#ifndef __VERSION_H
|
||||
#define __VERSION_H
|
||||
|
||||
#define KERNEL_VERSION "0.0.9"
|
||||
#define KERNEL_VERSION "0.0.10"
|
||||
#define KERNEL_MAJOR_VERSION 0
|
||||
#define KERNEL_MINOR_VERSION 0
|
||||
#define KERNEL_PATCH_LEVEL 9
|
||||
#define KERNEL_PATCH_LEVEL 10
|
||||
|
||||
#endif
|
||||
|
@@ -1,2 +0,0 @@
|
||||
extern KSPIN_LOCK DispatcherDatabaseLock;
|
||||
extern BOOLEAN WaitSet;
|
@@ -105,6 +105,6 @@ typedef struct __HEAP
|
||||
HEAP_BLOCK Start __attribute__((aligned (8)));
|
||||
} HEAP, *PHEAP;
|
||||
|
||||
PHEAP __ProcessHeap;
|
||||
//PHEAP __ProcessHeap;
|
||||
|
||||
#endif /* __INCLUDE_KERNEL32_HEAP_H */
|
||||
|
@@ -20,7 +20,7 @@ typedef unsigned short wchar_t;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
wchar_t * ___wcstok;
|
||||
//wchar_t * ___wcstok = NULL;
|
||||
extern wchar_t * wcscpy(wchar_t *,const wchar_t *);
|
||||
extern wchar_t * wcsncpy(wchar_t *,const wchar_t *, __kernel_size_t);
|
||||
extern wchar_t * wcscat(wchar_t *, const wchar_t *);
|
||||
|
BIN
reactos/lib/ntdll/genntdll
Normal file
BIN
reactos/lib/ntdll/genntdll
Normal file
Binary file not shown.
@@ -27,12 +27,9 @@
|
||||
;
|
||||
; $Logfile: C:/dos-c/src/boot/boot.asv $
|
||||
;
|
||||
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.asm,v 1.3 1998/08/25 04:37:43 rex Exp $
|
||||
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.asm,v 1.1.1.2 1998/08/25 04:27:38 rex Exp $
|
||||
;
|
||||
; $Log: boot.asm,v $
|
||||
; Revision 1.3 1998/08/25 04:37:43 rex
|
||||
; new release cleanup
|
||||
;
|
||||
; Revision 1.1.1.2 1998/08/25 04:27:38 rex
|
||||
; A much Needed Update
|
||||
;
|
||||
@@ -289,3 +286,6 @@ filename db "KERNEL BIN"
|
||||
sign dw 0aa55h
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
640
reactos/loaders/boot/boot.lst
Normal file
640
reactos/loaders/boot/boot.lst
Normal file
@@ -0,0 +1,640 @@
|
||||
1 ;
|
||||
2 ; File:
|
||||
3 ; boot.asm
|
||||
4 ; Description:
|
||||
5 ; DOS-C boot
|
||||
6 ;
|
||||
7 ; Copyright (c) 1997;
|
||||
8 ; Svante Frey
|
||||
9 ; All Rights Reserved
|
||||
10 ;
|
||||
11 ; This file is part of DOS-C.
|
||||
12 ;
|
||||
13 ; DOS-C is free software; you can redistribute it and/or
|
||||
14 ; modify it under the terms of the GNU General Public License
|
||||
15 ; as published by the Free Software Foundation; either version
|
||||
16 ; 2, or (at your option) any later version.
|
||||
17 ;
|
||||
18 ; DOS-C is distributed in the hope that it will be useful, but
|
||||
19 ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
21 ; the GNU General Public License for more details.
|
||||
22 ;
|
||||
23 ; You should have received a copy of the GNU General Public
|
||||
24 ; License along with DOS-C; see the file COPYING. If not,
|
||||
25 ; write to the Free Software Foundation, 675 Mass Ave,
|
||||
26 ; Cambridge, MA 02139, USA.
|
||||
27 ;
|
||||
28 ; $Logfile: C:/dos-c/src/boot/boot.asv $
|
||||
29 ;
|
||||
30 ; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.lst,v 1.1.1.2 1998/08/25 04:27:38 rex Exp $
|
||||
31 ;
|
||||
32 ; $Log: boot.lst,v $
|
||||
32 ; Revision 1.1.1.2 1998/08/25 04:27:38 rex
|
||||
32 ; A much Needed Update
|
||||
32 ;
|
||||
33 ;
|
||||
34 ; Rev 1.5 10 Jan 1997 4:58:06 patv
|
||||
35 ; Corrected copyright
|
||||
36 ;
|
||||
37 ; Rev 1.4 10 Jan 1997 4:52:50 patv
|
||||
38 ; Re-written to support C drive and eliminate restrictions on IPL.SYS
|
||||
39 ;
|
||||
40 ; Rev 1.3 29 Aug 1996 13:06:50 patv
|
||||
41 ; Bug fixes for v0.91b
|
||||
42 ;
|
||||
43 ; Rev 1.2 01 Sep 1995 17:56:44 patv
|
||||
44 ; First GPL release.
|
||||
45 ;
|
||||
46 ; Rev 1.1 30 Jul 1995 20:37:38 patv
|
||||
47 ; Initialized stack before use.
|
||||
48 ;
|
||||
49 ; Rev 1.0 02 Jul 1995 10:57:52 patv
|
||||
50 ; Initial revision.
|
||||
51 ;
|
||||
52
|
||||
53 section .text
|
||||
54
|
||||
55 org 0
|
||||
56 00000000 E93D00 Entry: jmp real_start
|
||||
57
|
||||
58 ; bp is initialized to 7c00h
|
||||
59 %define oem [bp+3]
|
||||
60 %define bytesPerSector [bp+0bh]
|
||||
61 %define sectPerCluster [bp+0dh]
|
||||
62 %define resSectors [bp+0eh]
|
||||
63 %define nFats [bp+10h]
|
||||
64 %define nRootDir [bp+11h]
|
||||
65 %define nSectors [bp+13h]
|
||||
66 %define MID [bp+15h]
|
||||
67 %define sectPerFat [bp+16h]
|
||||
68 %define sectPerTrack [bp+18h]
|
||||
69 %define nHeads [bp+1ah]
|
||||
70 %define nHidden [bp+1ch]
|
||||
71 %define nHidden_hi [bp+1eh]
|
||||
72 %define nSectorHuge [bp+20h]
|
||||
73 %define drive [bp+24h]
|
||||
74 %define extBoot [bp+26h]
|
||||
75 %define volid [bp+27h]
|
||||
76 %define vollabel [bp+2bh]
|
||||
77 %define filesys 36h
|
||||
78
|
||||
79 LOADSEG equ 2000h
|
||||
80
|
||||
81 FATBUF equ 4000h ; offset of temporary buffer for FAT
|
||||
82 ; chain
|
||||
83 RETRYCOUNT equ 5 ; number of retries on disk errors
|
||||
84
|
||||
85 ; Some extra variables that are created on the stack frame
|
||||
86
|
||||
87 %define fat_start [bp-4] ; first FAT sector
|
||||
88 %define fat_start_hi [bp-2]
|
||||
89 %define root_dir_start [bp-8] ; first root directory sector
|
||||
90 %define root_dir_start_hi [bp-6]
|
||||
91 %define data_start [bp-12] ; first data sector
|
||||
92 %define data_start_hi [bp-10]
|
||||
93
|
||||
94 ;
|
||||
95 ; Include macros for filesystem access
|
||||
96 ;
|
||||
97 %include "boot.inc"
|
||||
98 <1> ; To save space, functions that are just called once are
|
||||
99 <1> ; implemented as macros instead. Four bytes are saved by
|
||||
100 <1> ; avoiding the call / ret instructions.
|
||||
101 <1>
|
||||
102 <1>
|
||||
103 <1> ; FINDFILE: Searches for the file in the root directory.
|
||||
104 <1> ;
|
||||
105 <1> ; Returns:
|
||||
106 <1> ;
|
||||
107 <1> ; If file not found: CF set
|
||||
108 <1> ;
|
||||
109 <1> ; If file found: CF clear
|
||||
110 <1> ; AX = first cluster of file
|
||||
111 <1>
|
||||
112 <1>
|
||||
113 <1> %macro FINDFILE 0
|
||||
114 <1> ; First, read the whole root directory
|
||||
115 <1> ; into the temporary buffer.
|
||||
116 <1>
|
||||
117 <1> mov ax, word root_dir_start
|
||||
118 <1> mov dx, word root_dir_start_hi
|
||||
119 <1> mov di, nRootDir
|
||||
120 <1> xor bx, bx
|
||||
121 <1> mov es, tempbuf
|
||||
122 <1> call readDisk
|
||||
123 <1> jc ffDone
|
||||
124 <1>
|
||||
125 <1> xor di, di
|
||||
126 <1>
|
||||
127 <1> next_entry: mov cx, 11
|
||||
128 <1> mov si, filename+7c00h
|
||||
129 <1> push di
|
||||
130 <1> repe cmpsb
|
||||
131 <1> pop di
|
||||
132 <1> mov ax, [es:di+1ah] ; get cluster number from directory entry
|
||||
133 <1> clc
|
||||
134 <1> je ffDone
|
||||
135 <1>
|
||||
136 <1> add di, 20h ; go to next directory entry
|
||||
137 <1> cmp byte [es:di], 0 ; if the first byte of the name is 0,
|
||||
138 <1> jnz next_entry ; there is no more files in the directory
|
||||
139 <1>
|
||||
140 <1> stc
|
||||
141 <1> ffDone:
|
||||
142 <1> %endmacro
|
||||
143 <1>
|
||||
144 <1> ; GETDRIVEPARMS: Calculate start of some disk areas.
|
||||
145 <1>
|
||||
146 <1> %macro GETDRIVEPARMS 0
|
||||
147 <1> mov si, word nHidden
|
||||
148 <1> mov di, word nHidden_hi
|
||||
149 <1> add si, word resSectors
|
||||
150 <1> adc di, 0 ; DI:SI = first FAT sector
|
||||
151 <1>
|
||||
152 <1> mov word fat_start, si
|
||||
153 <1> mov word fat_start_hi, di
|
||||
154 <1>
|
||||
155 <1> mov al, nFats
|
||||
156 <1> xor ah, ah
|
||||
157 <1> mul word sectPerFat ; DX:AX = total number of FAT sectors
|
||||
158 <1>
|
||||
159 <1> add si, ax
|
||||
160 <1> adc di, dx ; DI:SI = first root directory sector
|
||||
161 <1> mov word root_dir_start, si
|
||||
162 <1> mov word root_dir_start_hi, di
|
||||
163 <1>
|
||||
164 <1> ; Calculate how many sectors the root directory occupies.
|
||||
165 <1> mov bx, bytesPerSector
|
||||
166 <1> mov cl, 5 ; divide BX by 32
|
||||
167 <1> shr bx, cl ; BX = directory entries per sector
|
||||
168 <1>
|
||||
169 <1> mov ax, nRootDir
|
||||
170 <1> xor dx, dx
|
||||
171 <1> div bx
|
||||
172 <1>
|
||||
173 <1> mov nRootDir, ax ; AX = sectors per root directory
|
||||
174 <1>
|
||||
175 <1> add si, ax
|
||||
176 <1> adc di, 0 ; DI:SI = first data sector
|
||||
177 <1>
|
||||
178 <1> mov data_start, si
|
||||
179 <1> mov data_start_hi, di
|
||||
180 <1> %endmacro
|
||||
181 <1>
|
||||
182 <1> ; GETFATCHAIN:
|
||||
183 <1> ;
|
||||
184 <1> ; Reads the FAT chain and stores it in a temporary buffer in the first
|
||||
185 <1> ; 64 kb. The FAT chain is stored an array of 16-bit cluster numbers,
|
||||
186 <1> ; ending with 0.
|
||||
187 <1> ;
|
||||
188 <1> ; The file must fit in conventional memory, so it can't be larger than
|
||||
189 <1> ; 640 kb. The sector size must be at least 512 bytes, so the FAT chain
|
||||
190 <1> ; can't be larger than around 3 kb.
|
||||
191 <1> ;
|
||||
192 <1> ; Call with: AX = first cluster in chain
|
||||
193 <1> ;
|
||||
194 <1> ; Returns: CF clear on success, set on error
|
||||
195 <1>
|
||||
196 <1> %macro GETFATCHAIN 0
|
||||
197 <1> push ax ; store first cluster number
|
||||
198 <1>
|
||||
199 <1> ; Load the complete FAT into memory. The FAT can't be larger
|
||||
200 <1> ; than 128 kb, so it should fit in the temporary buffer.
|
||||
201 <1>
|
||||
202 <1> mov es, tempbuf
|
||||
203 <1> xor bx, bx
|
||||
204 <1> mov di, sectPerFat
|
||||
205 <1> mov ax, word fat_start
|
||||
206 <1> mov dx, word fat_start_hi
|
||||
207 <1> call readDisk
|
||||
208 <1> pop ax ; restore first cluster number
|
||||
209 <1> jc boot_error
|
||||
210 <1>
|
||||
211 <1> ; Set ES:DI to the temporary storage for the FAT chain.
|
||||
212 <1> push ds
|
||||
213 <1> push es
|
||||
214 <1> pop ds
|
||||
215 <1> pop es
|
||||
216 <1> mov di, FATBUF
|
||||
217 <1>
|
||||
218 <1> next_clust: stosw ; store cluster number
|
||||
219 <1> mov si, ax ; SI = cluster number
|
||||
220 <1> cmp byte extBoot, 29h
|
||||
221 <1> jne fat_12
|
||||
222 <1> cmp byte [bp+filesys+4], '6' ; check for FAT-16 system
|
||||
223 <1> je fat_16
|
||||
224 <1>
|
||||
225 <1> ; This is a FAT-12 disk.
|
||||
226 <1>
|
||||
227 <1> fat_12: add si, si ; multiply cluster number by 3...
|
||||
228 <1> add si, ax
|
||||
229 <1> shr si, 1 ; ...and divide by 2
|
||||
230 <1> lodsw
|
||||
231 <1>
|
||||
232 <1> ; If the cluster number was even, the cluster value is now in
|
||||
233 <1> ; bits 0-11 of AX. If the cluster number was odd, the cluster
|
||||
234 <1> ; value is in bits 4-15, and must be shifted right 4 bits. If
|
||||
235 <1> ; the number was odd, CF was set in the last shift instruction.
|
||||
236 <1>
|
||||
237 <1> jnc fat_even
|
||||
238 <1> mov cl, 4
|
||||
239 <1> shr ax, cl ; shift the cluster number
|
||||
240 <1>
|
||||
241 <1> fat_even: and ah, 0fh ; mask off the highest 4 bits
|
||||
242 <1> cmp ax, 0fffh ; check for EOF
|
||||
243 <1> jmp short next_test
|
||||
244 <1>
|
||||
245 <1> ; This is a FAT-16 disk. The maximal size of a 16-bit FAT
|
||||
246 <1> ; is 128 kb, so it may not fit within a single 64 kb segment.
|
||||
247 <1>
|
||||
248 <1> fat_16: mov dx, tempbuf
|
||||
249 <1> add si, si ; multiply cluster number by two
|
||||
250 <1> jnc first_half ; if overflow...
|
||||
251 <1> add dh, 10h ; ...add 64 kb to segment value
|
||||
252 <1>
|
||||
253 <1> first_half: mov ds, dx ; DS:SI = pointer to next cluster
|
||||
254 <1> lodsw ; AX = next cluster
|
||||
255 <1>
|
||||
256 <1> cmp ax, 0fff8h ; >= FFF8 = 16-bit EOF
|
||||
257 <1> next_test: jb next_clust ; continue if not EOF
|
||||
258 <1>
|
||||
259 <1> finished: ; Mark end of FAT chain with 0, so we have a single
|
||||
260 <1> ; EOF marker for both FAT-12 and FAT-16 systems.
|
||||
261 <1>
|
||||
262 <1> xor ax, ax
|
||||
263 <1> stosw
|
||||
264 <1> fatError:
|
||||
265 <1> %endmacro
|
||||
266 <1>
|
||||
267 <1>
|
||||
268 <1> ; loadFile: Loads the file into memory, one cluster at a time.
|
||||
269 <1>
|
||||
270 <1> %macro LOADFILE 0
|
||||
271 <1> mov es, tempbuf ; set ES:BX to load address
|
||||
272 <1> xor bx, bx
|
||||
273 <1>
|
||||
274 <1> mov si, FATBUF ; set DS:SI to the FAT chain
|
||||
275 <1> push cs
|
||||
276 <1> pop ds
|
||||
277 <1>
|
||||
278 <1> next_cluster: lodsw ; AX = next cluster to read
|
||||
279 <1> or ax, ax ; if EOF...
|
||||
280 <1> je boot_success ; ...boot was successful
|
||||
281 <1>
|
||||
282 <1> dec ax ; cluster numbers start with 2
|
||||
283 <1> dec ax
|
||||
284 <1>
|
||||
285 <1> mov di, word sectPerCluster
|
||||
286 <1> and di, 0ffh ; DI = sectors per cluster
|
||||
287 <1> mul di
|
||||
288 <1> add ax, data_start
|
||||
289 <1> adc dx, data_start_hi ; DX:AX = first sector to read
|
||||
290 <1> call readDisk
|
||||
291 <1> jnc next_cluster
|
||||
292 <1>
|
||||
293 <1> %endmacro
|
||||
294
|
||||
295 ;
|
||||
296 ;
|
||||
297 ;
|
||||
298 00000003 00<rept> TIMES 3eh-($-$$) DB 0
|
||||
299
|
||||
300 %define tempbuf [bp+3eh]
|
||||
301 0000003E 0020 load_seg dw LOADSEG
|
||||
302
|
||||
303 00000040 FA real_start: cli
|
||||
304 00000041 FC cld
|
||||
305 00000042 8CC8 mov ax, cs
|
||||
306 00000044 8ED0 mov ss, ax ; initialize stack
|
||||
307 00000046 BD007C mov bp, 7c00h
|
||||
308 00000049 8D66E0 lea sp, [bp-20h]
|
||||
309 0000004C FB sti
|
||||
310
|
||||
311 0000004D 8EC0 mov es, ax
|
||||
312 0000004F 8ED8 mov ds, ax
|
||||
313 00000051 885624 mov drive, dl ; BIOS passes drive number in DL
|
||||
314
|
||||
315 GETDRIVEPARMS
|
||||
316 00000054 8B761C <1> mov si, word nHidden
|
||||
317 00000057 8B7E1E <1> mov di, word nHidden_hi
|
||||
318 0000005A 03760E <1> add si, word resSectors
|
||||
319 0000005D 81D70000 <1> adc di, 0
|
||||
320 <1>
|
||||
321 00000061 8976FC <1> mov word fat_start, si
|
||||
322 00000064 897EFE <1> mov word fat_start_hi, di
|
||||
323 <1>
|
||||
324 00000067 8A4610 <1> mov al, nFats
|
||||
325 0000006A 30E4 <1> xor ah, ah
|
||||
326 0000006C F76616 <1> mul word sectPerFat
|
||||
327 <1>
|
||||
328 0000006F 01C6 <1> add si, ax
|
||||
329 00000071 11D7 <1> adc di, dx
|
||||
330 00000073 8976F8 <1> mov word root_dir_start, si
|
||||
331 00000076 897EFA <1> mov word root_dir_start_hi, di
|
||||
332 <1>
|
||||
333 <1>
|
||||
334 00000079 8B5E0B <1> mov bx, bytesPerSector
|
||||
335 0000007C B105 <1> mov cl, 5
|
||||
336 0000007E D3EB <1> shr bx, cl
|
||||
337 <1>
|
||||
338 00000080 8B4611 <1> mov ax, nRootDir
|
||||
339 00000083 31D2 <1> xor dx, dx
|
||||
340 00000085 F7F3 <1> div bx
|
||||
341 <1>
|
||||
342 00000087 894611 <1> mov nRootDir, ax
|
||||
343 <1>
|
||||
344 0000008A 01C6 <1> add si, ax
|
||||
345 0000008C 81D70000 <1> adc di, 0
|
||||
346 <1>
|
||||
347 00000090 8976F4 <1> mov data_start, si
|
||||
348 00000093 897EF6 <1> mov data_start_hi, di
|
||||
349
|
||||
350 FINDFILE ; locate file in root directory
|
||||
351 <1>
|
||||
352 <1>
|
||||
353 <1>
|
||||
354 00000096 8B46F8 <1> mov ax, word root_dir_start
|
||||
355 00000099 8B56FA <1> mov dx, word root_dir_start_hi
|
||||
356 0000009C 8B7E11 <1> mov di, nRootDir
|
||||
357 0000009F 31DB <1> xor bx, bx
|
||||
358 000000A1 8E463E <1> mov es, tempbuf
|
||||
359 000000A4 E8B900 <1> call readDisk
|
||||
360 000000A7 721E <1> jc ffDone
|
||||
361 <1>
|
||||
362 000000A9 31FF <1> xor di, di
|
||||
363 <1>
|
||||
364 000000AB B90B00 <1> next_entry: mov cx, 11
|
||||
365 000000AE BE[F17D] <1> mov si, filename+7c00h
|
||||
366 000000B1 57 <1> push di
|
||||
367 000000B2 F3A6 <1> repe cmpsb
|
||||
368 000000B4 5F <1> pop di
|
||||
369 000000B5 268B451A <1> mov ax, [es:di+1ah]
|
||||
370 000000B9 F8 <1> clc
|
||||
371 000000BA 740B <1> je ffDone
|
||||
372 <1>
|
||||
373 000000BC 81C72000 <1> add di, 20h
|
||||
374 000000C0 26803D00 <1> cmp byte [es:di], 0
|
||||
375 000000C4 75E5 <1> jnz next_entry
|
||||
376 <1>
|
||||
377 000000C6 F9 <1> stc
|
||||
378 <1> ffDone:
|
||||
379 000000C7 727A jc boot_error ; fail if not found
|
||||
380
|
||||
381 GETFATCHAIN ; read FAT chain
|
||||
382 000000C9 50 <1> push ax
|
||||
383 <1>
|
||||
384 <1>
|
||||
385 <1>
|
||||
386 <1>
|
||||
387 000000CA 8E463E <1> mov es, tempbuf
|
||||
388 000000CD 31DB <1> xor bx, bx
|
||||
389 000000CF 8B7E16 <1> mov di, sectPerFat
|
||||
390 000000D2 8B46FC <1> mov ax, word fat_start
|
||||
391 000000D5 8B56FE <1> mov dx, word fat_start_hi
|
||||
392 000000D8 E88500 <1> call readDisk
|
||||
393 000000DB 58 <1> pop ax
|
||||
394 000000DC 7265 <1> jc boot_error
|
||||
395 <1>
|
||||
396 <1>
|
||||
397 000000DE 1E <1> push ds
|
||||
398 000000DF 06 <1> push es
|
||||
399 000000E0 1F <1> pop ds
|
||||
400 000000E1 07 <1> pop es
|
||||
401 000000E2 BF0040 <1> mov di, FATBUF
|
||||
402 <1>
|
||||
403 000000E5 AB <1> next_clust: stosw
|
||||
404 000000E6 89C6 <1> mov si, ax
|
||||
405 000000E8 807E2629 <1> cmp byte extBoot, 29h
|
||||
406 000000EC 7506 <1> jne fat_12
|
||||
407 000000EE 807E3A36 <1> cmp byte [bp+filesys+4], '6'
|
||||
408 000000F2 7415 <1> je fat_16
|
||||
409 <1>
|
||||
410 <1>
|
||||
411 <1>
|
||||
412 000000F4 01F6 <1> fat_12: add si, si
|
||||
413 000000F6 01C6 <1> add si, ax
|
||||
414 000000F8 D1EE <1> shr si, 1
|
||||
415 000000FA AD <1> lodsw
|
||||
416 <1>
|
||||
417 <1>
|
||||
418 <1>
|
||||
419 <1>
|
||||
420 <1>
|
||||
421 <1>
|
||||
422 000000FB 7304 <1> jnc fat_even
|
||||
423 000000FD B104 <1> mov cl, 4
|
||||
424 000000FF D3E8 <1> shr ax, cl
|
||||
425 <1>
|
||||
426 00000101 80E40F <1> fat_even: and ah, 0fh
|
||||
427 00000104 3DFF0F <1> cmp ax, 0fffh
|
||||
428 00000107 EB10 <1> jmp short next_test
|
||||
429 <1>
|
||||
430 <1>
|
||||
431 <1>
|
||||
432 <1>
|
||||
433 00000109 8B563E <1> fat_16: mov dx, tempbuf
|
||||
434 0000010C 01F6 <1> add si, si
|
||||
435 0000010E 7303 <1> jnc first_half
|
||||
436 00000110 80C610 <1> add dh, 10h
|
||||
437 <1>
|
||||
438 00000113 8EDA <1> first_half: mov ds, dx
|
||||
439 00000115 AD <1> lodsw
|
||||
440 <1>
|
||||
441 00000116 3DF8FF <1> cmp ax, 0fff8h
|
||||
442 00000119 72CA <1> next_test: jb next_clust
|
||||
443 <1>
|
||||
444 <1> finished:
|
||||
445 <1>
|
||||
446 <1>
|
||||
447 0000011B 31C0 <1> xor ax, ax
|
||||
448 0000011D AB <1> stosw
|
||||
449 <1> fatError:
|
||||
450 LOADFILE ; load file (jumps to boot_sucess if successful)
|
||||
451 0000011E 8E463E <1> mov es, tempbuf
|
||||
452 00000121 31DB <1> xor bx, bx
|
||||
453 <1>
|
||||
454 00000123 BE0040 <1> mov si, FATBUF
|
||||
455 00000126 0E <1> push cs
|
||||
456 00000127 1F <1> pop ds
|
||||
457 <1>
|
||||
458 00000128 AD <1> next_cluster: lodsw
|
||||
459 00000129 09C0 <1> or ax, ax
|
||||
460 0000012B 742B <1> je boot_success
|
||||
461 <1>
|
||||
462 0000012D 48 <1> dec ax
|
||||
463 0000012E 48 <1> dec ax
|
||||
464 <1>
|
||||
465 0000012F 8B7E0D <1> mov di, word sectPerCluster
|
||||
466 00000132 81E7FF00 <1> and di, 0ffh
|
||||
467 00000136 F7E7 <1> mul di
|
||||
468 00000138 0346F4 <1> add ax, data_start
|
||||
469 0000013B 1356F6 <1> adc dx, data_start_hi
|
||||
470 0000013E E81F00 <1> call readDisk
|
||||
471 00000141 73E5 <1> jnc next_cluster
|
||||
472 <1>
|
||||
473
|
||||
474 00000143 B90A00 boot_error: mov cx, ERRMSGLEN
|
||||
475 00000146 BE[E77D] mov si, errmsg+7c00h
|
||||
476
|
||||
477 00000149 AC next_char: lodsb ; print error message
|
||||
478 0000014A B40E mov ah, 0eh
|
||||
479 0000014C 30FF xor bh, bh
|
||||
480 0000014E CD10 int 10h
|
||||
481 00000150 E2F7 loop next_char
|
||||
482
|
||||
483 00000152 30E4 xor ah, ah
|
||||
484 00000154 CD16 int 16h ; wait for keystroke
|
||||
485 00000156 CD19 int 19h ; invoke bootstrap loader
|
||||
486
|
||||
487 00000158 8A5624 boot_success: mov dl, drive
|
||||
488
|
||||
489 0000015B EA db 0eah ; far jump to LOADSEG:0000
|
||||
490 0000015C 0000 dw 0
|
||||
491 0000015E 0020 dw LOADSEG
|
||||
492
|
||||
493
|
||||
494 ; readDisk: Reads a number of sectors into memory.
|
||||
495 ;
|
||||
496 ; Call with: DX:AX = 32-bit DOS sector number
|
||||
497 ; DI = number of sectors to read
|
||||
498 ; ES:BX = destination buffer
|
||||
499 ; ES must be 64k aligned (1000h, 2000h etc).
|
||||
500 ;
|
||||
501 ; Returns: CF set on error
|
||||
502 ; ES:BX points one byte after the last byte read.
|
||||
503
|
||||
504 readDisk:
|
||||
505 00000160 56 push si
|
||||
506 00000161 52 read_next: push dx
|
||||
507 00000162 50 push ax
|
||||
508
|
||||
509 ;
|
||||
510 ; translate sector number to BIOS parameters
|
||||
511 ;
|
||||
512
|
||||
513 ;
|
||||
514 ; abs = sector offset in track
|
||||
515 ; + head * sectPerTrack offset in cylinder
|
||||
516 ; + track * sectPerTrack * nHeads offset in platter
|
||||
517 ;
|
||||
518 ; t1 = abs / sectPerTrack (ax has t1)
|
||||
519 ; sector = abs mod sectPerTrack (cx has sector)
|
||||
520 ;
|
||||
521 00000163 F77618 div word sectPerTrack
|
||||
522 00000166 89D1 mov cx, dx
|
||||
523
|
||||
524 ;
|
||||
525 ; t1 = head + track * nHeads
|
||||
526 ;
|
||||
527 ; track = t1 / nHeads (ax has track)
|
||||
528 ; head = t1 mod nHeads (dl has head)
|
||||
529 ;
|
||||
530 00000168 31D2 xor dx, dx
|
||||
531 0000016A F7761A div word nHeads
|
||||
532
|
||||
533 ; the following manipulations are necessary in order to
|
||||
534 ; properly place parameters into registers.
|
||||
535 ; ch = cylinder number low 8 bits
|
||||
536 ; cl = 7-6: cylinder high two bits
|
||||
537 ; 5-0: sector
|
||||
538 0000016D 88D6 mov dh, dl ; save head into dh for bios
|
||||
539 0000016F D0CC ror ah, 1 ; move track high bits into
|
||||
540 00000171 D0CC ror ah, 1 ; bits 7-6 (assumes top = 0)
|
||||
541 00000173 86C4 xchg al, ah ; swap for later
|
||||
542 00000175 8A5618 mov dl, byte sectPerTrack
|
||||
543 00000178 28CA sub dl, cl
|
||||
544 0000017A FEC1 inc cl ; sector offset from 1
|
||||
545 0000017C 09C1 or cx, ax ; merge cylinder into sector
|
||||
546 0000017E 88D0 mov al, dl ; al has # of sectors left
|
||||
547
|
||||
548 ; Calculate how many sectors can be transfered in this read
|
||||
549 ; due to dma boundary conditions.
|
||||
550 00000180 52 push dx
|
||||
551
|
||||
552 00000181 89FE mov si, di ; temp register save
|
||||
553 ; this computes remaining bytes because of modulo 65536
|
||||
554 ; nature of dma boundary condition
|
||||
555 00000183 89D8 mov ax, bx ; get offset pointer
|
||||
556 00000185 F7D8 neg ax ; and convert to bytes
|
||||
557 00000187 740B jz ax_min_1 ; started at seg:0, skip ahead
|
||||
558
|
||||
559 00000189 31D2 xor dx, dx ; convert to sectors
|
||||
560 0000018B F7760B div word bytesPerSector
|
||||
561
|
||||
562 0000018E 39F8 cmp ax, di ; check remainder vs. asked
|
||||
563 00000190 7202 jb ax_min_1 ; less, skip ahead
|
||||
564 00000192 89C6 mov si, ax ; transfer only what we can
|
||||
565
|
||||
566 00000194 5A ax_min_1: pop dx
|
||||
567
|
||||
568 ; Check that request sectors do not exceed track boundary
|
||||
569 00000195 8B7618 mov si, sectPerTrack
|
||||
570 00000198 46 inc si
|
||||
571 00000199 89C8 mov ax, cx ; get the sector/cyl byte
|
||||
572 0000019B 253F00 and ax, 03fh ; and mask out sector
|
||||
573 0000019E 29C6 sub si, ax ; si has how many we can read
|
||||
574 000001A0 89F8 mov ax, di
|
||||
575 000001A2 39FE cmp si, di ; see if asked <= available
|
||||
576 000001A4 7D02 jge ax_min_2
|
||||
577 000001A6 89F0 mov ax, si ; get what can be xfered
|
||||
578
|
||||
579 000001A8 BE0500 ax_min_2: mov si, RETRYCOUNT
|
||||
580 000001AB B402 mov ah, 2
|
||||
581 000001AD 8A5624 mov dl, drive
|
||||
582
|
||||
583 000001B0 50 retry: push ax
|
||||
584 000001B1 CD13 int 13h
|
||||
585 000001B3 58 pop ax
|
||||
586 000001B4 7310 jnc read_ok
|
||||
587 000001B6 50 push ax
|
||||
588 000001B7 31C0 xor ax, ax ; reset the drive
|
||||
589 000001B9 CD13 int 13h
|
||||
590 000001BB 58 pop ax
|
||||
591 000001BC 4E dec si
|
||||
592 000001BD 75F1 jnz retry
|
||||
593 000001BF F9 stc
|
||||
594 000001C0 58 pop ax
|
||||
595 000001C1 5A pop dx
|
||||
596 000001C2 5E pop si
|
||||
597 000001C3 C3 ret
|
||||
598
|
||||
599 000001C4 EB9B read_next_jmp: jmp short read_next
|
||||
600 000001C6 30E4 read_ok: xor ah, ah
|
||||
601 000001C8 89C6 mov si, ax ; AX = SI = number of sectors read
|
||||
602 000001CA F7660B mul word bytesPerSector ; AX = number of bytes read
|
||||
603 000001CD 01C3 add bx, ax ; add number of bytes read to BX
|
||||
604 000001CF 7307 jnc no_incr_es ; if overflow...
|
||||
605
|
||||
606 000001D1 8CC0 mov ax, es
|
||||
607 000001D3 80C410 add ah, 10h ; ...add 1000h to ES
|
||||
608 000001D6 8EC0 mov es, ax
|
||||
609
|
||||
610 000001D8 58 no_incr_es: pop ax
|
||||
611 000001D9 5A pop dx ; DX:AX = last sector number
|
||||
612
|
||||
613 000001DA 01F0 add ax, si
|
||||
614 000001DC 81D20000 adc dx, 0 ; DX:AX = next sector to read
|
||||
615 000001E0 29F7 sub di, si ; if there is anything left to read,
|
||||
616 000001E2 7FE0 jg read_next_jmp ; continue
|
||||
617
|
||||
618 000001E4 F8 clc
|
||||
619 000001E5 5E pop si
|
||||
620 000001E6 C3 ret
|
||||
621
|
||||
622 000001E7 426F6F74206572726F- errmsg db "Boot error"
|
||||
623 000001F0 72
|
||||
624 ERRMSGLEN equ $ - errmsg
|
||||
625
|
||||
626
|
||||
627 ;filename db "OSLDR BIN"
|
||||
628 000001F1 4B45524E454C202042- filename db "KERNEL BIN"
|
||||
629 000001FA 494E
|
||||
630
|
||||
631 000001FC 00<rept> TIMES 510-($-$$) DB 0
|
||||
632 000001FE 55AA sign dw 0aa55h
|
||||
633
|
||||
634
|
||||
635
|
||||
636
|
||||
637
|
@@ -1,12 +1,9 @@
|
||||
#
|
||||
# makefile for DOS-C boot
|
||||
#
|
||||
# $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.mak,v 1.3 1998/08/25 04:39:40 rex Exp $
|
||||
# $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.mak,v 1.1.1.2 1998/08/25 04:27:38 rex Exp $
|
||||
#
|
||||
# $Log: boot.mak,v $
|
||||
# Revision 1.3 1998/08/25 04:39:40 rex
|
||||
# Release cleanup
|
||||
#
|
||||
# Revision 1.1.1.2 1998/08/25 04:27:38 rex
|
||||
# A much Needed Update
|
||||
#
|
||||
@@ -56,4 +53,3 @@ clean:
|
||||
del *.las
|
||||
del *.obj
|
||||
del *.exe
|
||||
|
||||
|
@@ -27,12 +27,9 @@
|
||||
;
|
||||
; $Logfile: C:/dos-c/src/boot/boot.asv $
|
||||
;
|
||||
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/bootbk.asm,v 1.3 1998/08/25 04:40:47 rex Exp $
|
||||
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/bootbk.asm,v 1.1.1.2 1998/08/25 04:27:38 rex Exp $
|
||||
;
|
||||
; $Log: bootbk.asm,v $
|
||||
; Revision 1.3 1998/08/25 04:40:47 rex
|
||||
; Release cleanup
|
||||
;
|
||||
; Revision 1.1.1.2 1998/08/25 04:27:38 rex
|
||||
; A much Needed Update
|
||||
;
|
||||
@@ -293,3 +290,5 @@ TEXT ENDS
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -267,13 +267,12 @@ _load_file:
|
||||
; Move onto the next position in prepartion for a future read
|
||||
;
|
||||
movzx eax,word [size_div_4k]
|
||||
inc eax
|
||||
mov bx,[size_mod_4k]
|
||||
cmp bx,0
|
||||
je l20
|
||||
inc eax
|
||||
l20:
|
||||
shl eax,12
|
||||
shl eax,0ch
|
||||
add [next_load_base],eax
|
||||
|
||||
push fs
|
||||
|
BIN
reactos/loaders/dos/loadros.com
Normal file
BIN
reactos/loaders/dos/loadros.com
Normal file
Binary file not shown.
@@ -32,6 +32,8 @@ all: $(COMPONENTS) $(LOADERS) $(MODULES)
|
||||
#
|
||||
# Device driver rules
|
||||
#
|
||||
ide: dummy
|
||||
make -C services/ide
|
||||
|
||||
parallel: dummy
|
||||
make -C services/parallel
|
||||
|
@@ -5,9 +5,9 @@
|
||||
#
|
||||
# Select your host
|
||||
#
|
||||
#HOST = djgpp-linux
|
||||
HOST = djgpp-linux
|
||||
#HOST = mingw32-linux
|
||||
HOST = djgpp-msdos
|
||||
#HOST = djgpp-msdos
|
||||
#HOST = mingw32-windows
|
||||
|
||||
include rules.mak
|
||||
@@ -30,13 +30,19 @@ LOADERS = dos
|
||||
#
|
||||
# Select the device drivers and filesystems you want
|
||||
#
|
||||
KERNEL_SERVICES = parallel keyboard null mouse serial sound test ide ide-test
|
||||
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test
|
||||
|
||||
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES)
|
||||
|
||||
#
|
||||
# Device driver rules
|
||||
#
|
||||
ide-test: dummy
|
||||
make -C services/ide-test
|
||||
|
||||
ide: dummy
|
||||
make -C services/ide
|
||||
|
||||
test: dummy
|
||||
make -C services/test
|
||||
|
||||
@@ -61,12 +67,6 @@ serial: dummy
|
||||
sound: dummy
|
||||
make -C services/sound
|
||||
|
||||
ide: dummy
|
||||
make -C services/ide
|
||||
|
||||
ide-test: dummy
|
||||
make -C services/ide-test
|
||||
|
||||
#
|
||||
# Kernel loaders
|
||||
#
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -12,7 +12,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
@@ -46,7 +45,7 @@ typedef struct
|
||||
/*
|
||||
* PURPOSE: Queue of items waiting to be processed at normal priority
|
||||
*/
|
||||
WORK_QUEUE normal_work_queue;
|
||||
WORK_QUEUE normal_work_queue = {0,};
|
||||
|
||||
#define WAIT_INTERVAL (0)
|
||||
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/hal/page.h>
|
||||
@@ -133,7 +132,7 @@ VOID Hal_bios32_probe()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
printk("BIOS32 detected at %x\n",i);
|
||||
DbgPrint("BIOS32 detected at %x\n",i);
|
||||
bios32_indirect.address = service_entry->entry;
|
||||
bios32_detected=TRUE;
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/base/bug.c
|
||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
||||
* FILE: ntoskrnl/hal/x86/bus.c
|
||||
* PURPOSE: Bus functions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/hal/x86/dma.c
|
||||
* FILE: ntoskrnl/hal/x86/dma.c
|
||||
* PURPOSE: DMA functions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/hal/x86/exp.c
|
||||
* FILE: ntoskrnl/hal/x86/exp.c
|
||||
* PURPOSE: Handling exceptions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* REVISION HISTORY:
|
||||
@@ -11,13 +11,19 @@
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/hal/segment.h>
|
||||
#include <internal/hal/page.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
|
||||
asmlinkage unsigned int ExHookException(exception_hook fn, UINT exp);
|
||||
|
||||
extern descriptor idt[256];
|
||||
static exception_hook* exception_hooks[256]={NULL,};
|
||||
|
||||
@@ -116,6 +122,8 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||
unsigned int i;
|
||||
unsigned int* stack;
|
||||
|
||||
__asm__("cli\n\t");
|
||||
|
||||
/*
|
||||
* Activate any hook for the exception
|
||||
*/
|
||||
@@ -129,6 +137,7 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||
*/
|
||||
printk("Exception: %d(%x)\n",type,error_code&0xffff);
|
||||
printk("CS:EIP %x:%x\n",cs&0xffff,eip);
|
||||
for(;;);
|
||||
printk("EAX: %.8x EBX: %.8x ECX: %.8x\n",eax,ebx,ecx);
|
||||
printk("EDX: %.8x EBP: %.8x ESI: %.8x\n",edx,ebp,esi);
|
||||
printk("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
|
||||
@@ -192,13 +201,15 @@ asmlinkage unsigned int ExHookException(exception_hook fn, unsigned int exp)
|
||||
return(0);
|
||||
}
|
||||
|
||||
asmlinkage void InitalizeExceptions(void)
|
||||
asmlinkage void KeInitExceptions(void)
|
||||
/*
|
||||
* FUNCTION: Initalize CPU exception handling
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
|
||||
DPRINT("KeInitExceptions()\n",0);
|
||||
|
||||
set_interrupt_gate(0,(int)exception_handler0);
|
||||
set_interrupt_gate(1,(int)exception_handler1);
|
||||
set_interrupt_gate(2,(int)exception_handler2);
|
||||
|
@@ -10,16 +10,18 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/hal/hal.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/hal.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID HalInit(boot_param* bp)
|
||||
{
|
||||
|
||||
InitalizeExceptions();
|
||||
InitalizeIRQ();
|
||||
KeInitExceptions();
|
||||
KeInitIRQ();
|
||||
KeLowerIrql(DISPATCH_LEVEL);
|
||||
|
||||
/*
|
||||
* Probe for a BIOS32 extension
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: mkernel/hal/x86/irq.c
|
||||
* FILE: ntoskrnl/hal/x86/irq.c
|
||||
* PURPOSE: IRQ handling
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -20,7 +20,8 @@
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/stddef.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <internal/string.h>
|
||||
@@ -79,8 +80,8 @@ static unsigned int irq_handler[NR_IRQS]=
|
||||
* be accessed at any irq level.
|
||||
*/
|
||||
static LIST_ENTRY isr_table[NR_IRQS]={{NULL,NULL},};
|
||||
static PKSPIN_LOCK isr_lock[NR_IRQS];
|
||||
static KSPIN_LOCK isr_table_lock;
|
||||
static PKSPIN_LOCK isr_lock[NR_IRQS] = {NULL,};
|
||||
static KSPIN_LOCK isr_table_lock = {0,};
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
@@ -88,7 +89,7 @@ static KSPIN_LOCK isr_table_lock;
|
||||
#define PRESENT (0x8000)
|
||||
#define I486_INTERRUPT_GATE (0xe00)
|
||||
|
||||
asmlinkage void KiInterruptDispatch(unsigned int irq)
|
||||
asmlinkage VOID KiInterruptDispatch(ULONG irq)
|
||||
/*
|
||||
* FUNCTION: Calls the irq specific handler for an irq
|
||||
* ARGUMENTS:
|
||||
@@ -103,7 +104,7 @@ asmlinkage void KiInterruptDispatch(unsigned int irq)
|
||||
* Notify the rest of the kernel of the raised irq level
|
||||
*/
|
||||
old_level = KeGetCurrentIrql();
|
||||
DPRINT("old_level %d\n",old_level);
|
||||
// DPRINT("old_level %d\n",old_level);
|
||||
KeSetCurrentIrql(HIGH_LEVEL - irq);
|
||||
|
||||
/*
|
||||
@@ -114,7 +115,7 @@ asmlinkage void KiInterruptDispatch(unsigned int irq)
|
||||
|
||||
if (irq==0)
|
||||
{
|
||||
KeTimerInterrupt();
|
||||
KiTimerInterrupt();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -125,7 +126,8 @@ asmlinkage void KiInterruptDispatch(unsigned int irq)
|
||||
current = isr_table[irq].Flink;
|
||||
isr = CONTAINING_RECORD(current,KINTERRUPT,Entry);
|
||||
DPRINT("current %x isr %x\n",current,isr);
|
||||
while (current!=NULL && !isr->ServiceRoutine(isr,isr->ServiceContext))
|
||||
while (current!=(&isr_table[irq]) &&
|
||||
!isr->ServiceRoutine(isr,isr->ServiceContext))
|
||||
{
|
||||
current = current->Flink;
|
||||
isr = CONTAINING_RECORD(current,KINTERRUPT,Entry);
|
||||
@@ -172,10 +174,12 @@ asmlinkage void KiInterruptDispatch(unsigned int irq)
|
||||
KeSetCurrentIrql(old_level);
|
||||
}
|
||||
|
||||
void InitalizeIRQ(void)
|
||||
void KeInitIRQ(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
DPRINT("KeInitIrq()\n",0);
|
||||
|
||||
/*
|
||||
* First mask off all interrupts from pic
|
||||
*/
|
||||
@@ -195,6 +199,27 @@ void InitalizeIRQ(void)
|
||||
}
|
||||
}
|
||||
|
||||
static VOID KeDumpIrqList(VOID)
|
||||
{
|
||||
PKINTERRUPT current;
|
||||
PLIST_ENTRY current_entry;
|
||||
unsigned int i;
|
||||
|
||||
for (i=0;i<NR_IRQS;i++)
|
||||
{
|
||||
DPRINT("For irq %x ",i);
|
||||
current_entry = isr_table[i].Flink;
|
||||
current = CONTAINING_RECORD(current,KINTERRUPT,Entry);
|
||||
while (current_entry!=(&isr_table[i]))
|
||||
{
|
||||
DPRINT("Isr %x ",current);
|
||||
current_entry = current_entry->Flink;
|
||||
current = CONTAINING_RECORD(current_entry,KINTERRUPT,Entry);
|
||||
}
|
||||
DPRINT("\n",0);
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS IoConnectInterrupt(PKINTERRUPT* InterruptObject,
|
||||
PKSERVICE_ROUTINE ServiceRoutine,
|
||||
PVOID ServiceContext,
|
||||
@@ -240,6 +265,8 @@ NTSTATUS IoConnectInterrupt(PKINTERRUPT* InterruptObject,
|
||||
|
||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
||||
|
||||
DPRINT("IoConnectInterrupt(Vector %x)\n",Vector);
|
||||
|
||||
/*
|
||||
* Check the parameters
|
||||
*/
|
||||
@@ -305,6 +332,8 @@ NTSTATUS IoConnectInterrupt(PKINTERRUPT* InterruptObject,
|
||||
*/
|
||||
KeReleaseSpinLock(&isr_table_lock,oldlvl);
|
||||
|
||||
KeDumpIrqList();
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -320,8 +349,7 @@ VOID IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
|
||||
|
||||
KeRaiseIrql(InterruptObject->SynchLevel,&oldlvl);
|
||||
KeAcquireSpinLockAtDpcLevel(InterruptObject->IrqLock);
|
||||
RemoveEntryFromList(&isr_table[InterruptObject->Vector],
|
||||
&InterruptObject->Entry);
|
||||
RemoveEntryList(&InterruptObject->Entry);
|
||||
KeReleaseSpinLockFromDpcLevel(InterruptObject->IrqLock);
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
|
@@ -122,7 +122,7 @@ VOID KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
|
||||
// OldIrql);
|
||||
if (NewIrql < CurrentIrql)
|
||||
{
|
||||
printk("%s:%d\n",__FILE__,__LINE__);
|
||||
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
|
@@ -12,10 +12,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/hal/page.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
@@ -27,7 +23,7 @@ BOOL HalIsaProbe()
|
||||
* true
|
||||
*/
|
||||
{
|
||||
printk("Assuming ISA bus\n");
|
||||
DbgPrint("Assuming ISA bus\n");
|
||||
|
||||
/*
|
||||
* Probe for plug and play support
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
/* INCLUDES ***************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/hal/page.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/string.h>
|
||||
@@ -127,8 +126,11 @@ PHYSICAL_ADDRESS MmGetPhysicalAddress(PVOID vaddr)
|
||||
* FUNCTION: Returns the physical address corresponding to a virtual address
|
||||
*/
|
||||
{
|
||||
PHYSICAL_ADDRESS p;
|
||||
DPRINT("get_page_physical_address(vaddr %x)\n",vaddr);
|
||||
return(PAGE_MASK(*get_page_entry((unsigned int)vaddr)));
|
||||
p.HighPart = 0;
|
||||
p.LowPart = PAGE_MASK(*get_page_entry((unsigned int)vaddr));
|
||||
return(p);
|
||||
}
|
||||
|
||||
BOOL is_page_present(unsigned int vaddr)
|
||||
|
@@ -16,10 +16,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/hal/page.h>
|
||||
|
||||
/* FUNCTIONS **************************************************************/
|
||||
|
||||
@@ -33,7 +29,7 @@ BOOL HalPciProbe()
|
||||
{
|
||||
if (Hal_bios32_is_service_present(PCI_SERVICE))
|
||||
{
|
||||
printk("Detected PCI service\n");
|
||||
DbgPrint("Detected PCI service\n");
|
||||
return(TRUE);
|
||||
}
|
||||
return(FALSE);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/hal/x86/printk.c
|
||||
* FILE: ntoskrnl/hal/x86/printk.c
|
||||
* PURPOSE: Writing to the console
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/hal/page.h>
|
||||
#include <internal/hal/io.h>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/base/bug.c
|
||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
||||
* FILE: ntoskrnl/hal/x86/sysinfo.c
|
||||
* PURPOSE: Getting system information
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/hal/x86/thread.c
|
||||
* FILE: ntoskrnl/hal/x86/thread.c
|
||||
* PURPOSE: HAL multitasking functions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* REVISION HISTORY:
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/psmgr.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/hal/hal.h>
|
||||
#include <internal/hal.h>
|
||||
#include <internal/hal/segment.h>
|
||||
#include <internal/hal/page.h>
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
#define FIRST_TSS_SELECTOR (KERNEL_DS + 0x8)
|
||||
#define FIRST_TSS_OFFSET (FIRST_TSS_SELECTOR / 8)
|
||||
|
||||
static char null_ldt[8]={0,};
|
||||
static unsigned int null_ldt_sel=0;
|
||||
static PKTHREAD FirstThread=NULL;
|
||||
|
||||
/* FUNCTIONS **************************************************************/
|
||||
|
||||
void HalTaskSwitch(PKTHREAD thread)
|
||||
@@ -38,13 +42,40 @@ void HalTaskSwitch(PKTHREAD thread)
|
||||
* again
|
||||
*/
|
||||
{
|
||||
DPRINT("Scheduling thread %x\n",thread->Context.nr);
|
||||
DPRINT("previous task %x reserved1 %x esp0 %x ss0 %x\n",
|
||||
thread->Context.previous_task,thread->Context.reserved1,
|
||||
thread->Context.esp0,thread->Context.ss0);
|
||||
DPRINT("reserved2 %x esp1 %x ss1 %x reserved3 %x esp2 %x ss2 %x\n",
|
||||
thread->Context.reserved2,thread->Context.esp1,thread->Context.ss1,
|
||||
thread->Context.reserved3,thread->Context.esp2,thread->Context.ss2);
|
||||
DPRINT("reserved4 %x cr3 %x eip %x eflags %x eax %x\n",
|
||||
thread->Context.reserved4,thread->Context.cr3,thread->Context.eip,
|
||||
thread->Context.eflags,thread->Context.eax);
|
||||
DPRINT("ecx %x edx %x ebx %x esp %x ebp %x esi %x\n",
|
||||
thread->Context.ecx,thread->Context.edx,thread->Context.ebx,
|
||||
thread->Context.esp,thread->Context.ebp,thread->Context.esi);
|
||||
DPRINT("edi %x es %x reserved5 %x cs %x reserved6 %x\n",
|
||||
thread->Context.edi,thread->Context.es,thread->Context.reserved5,
|
||||
thread->Context.cs,thread->Context.reserved6);
|
||||
DPRINT("ss %x reserved7 %x ds %x reserved8 %x fs %x\n",
|
||||
thread->Context.ss,thread->Context.reserved7,thread->Context.ds,
|
||||
thread->Context.reserved8,thread->Context.fs);
|
||||
DPRINT("reserved9 %x gs %x reserved10 %x ldt %x reserved11 %x\n",
|
||||
thread->Context.reserved9,thread->Context.gs,
|
||||
thread->Context.reserved10,thread->Context.ldt,
|
||||
thread->Context.reserved11);
|
||||
DPRINT("trap %x iomap_base %x nr %x io_bitmap[0] %x\n",
|
||||
thread->Context.trap,thread->Context.iomap_base,
|
||||
thread->Context.nr,thread->Context.io_bitmap[0]);
|
||||
__asm__("pushfl\n\t"
|
||||
"cli\n\t"
|
||||
"ljmp %0\n\t"
|
||||
"popfl\n\t"
|
||||
: /* No outputs */
|
||||
: "m" (*(((unsigned char *)(&(thread->context.nr)))-4) )
|
||||
: "m" (*(((unsigned char *)(&(thread->Context.nr)))-4) )
|
||||
: "ax","dx");
|
||||
// set_breakpoint(0,&(FirstThread->Context.gs),HBP_READWRITE,HBP_DWORD);
|
||||
}
|
||||
|
||||
static unsigned int allocate_tss_descriptor(void)
|
||||
@@ -76,7 +107,7 @@ static void begin_thread(PKSTART_ROUTINE fn, PVOID start_context)
|
||||
*/
|
||||
{
|
||||
NTSTATUS ret;
|
||||
DPRINT("begin_thread %x %x\n",fn,start_context);
|
||||
// DPRINT("begin_thread %x %x\n",fn,start_context);
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
ret = fn(start_context);
|
||||
PsTerminateSystemThread(ret);
|
||||
@@ -96,9 +127,12 @@ BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn,
|
||||
{
|
||||
unsigned int desc = allocate_tss_descriptor();
|
||||
unsigned int length = sizeof(hal_thread_state) - 1;
|
||||
unsigned int base = (unsigned int)(&(thread->context));
|
||||
unsigned int base = (unsigned int)(&(thread->Context));
|
||||
unsigned int* kernel_stack = ExAllocatePool(NonPagedPool,4096);
|
||||
|
||||
DPRINT("HalInitTask(Thread %x, fn %x, StartContext %x)\n",
|
||||
thread,fn,StartContext);
|
||||
|
||||
/*
|
||||
* Make sure
|
||||
*/
|
||||
@@ -122,23 +156,25 @@ BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn,
|
||||
/*
|
||||
* Initialize the thread context
|
||||
*/
|
||||
memset(&thread->context,0,sizeof(hal_thread_state));
|
||||
thread->context.ldt = 0;
|
||||
thread->context.eflags = (1<<1)+(1<<9);
|
||||
thread->context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
|
||||
thread->context.esp0 = &kernel_stack[1021];
|
||||
thread->context.ss0 = KERNEL_DS;
|
||||
thread->context.esp = &kernel_stack[1021];
|
||||
thread->context.ss = KERNEL_DS;
|
||||
thread->context.cs = KERNEL_CS;
|
||||
thread->context.eip = (unsigned long)begin_thread;
|
||||
thread->context.io_bitmap[0] = 0xff;
|
||||
thread->context.cr3 = ((unsigned int)get_page_directory()) - IDMAP_BASE;
|
||||
thread->context.ds = KERNEL_DS;
|
||||
thread->context.es = KERNEL_DS;
|
||||
thread->context.fs = KERNEL_DS;
|
||||
thread->context.gs = KERNEL_DS;
|
||||
thread->context.nr = desc * 8;
|
||||
memset(&thread->Context,0,sizeof(hal_thread_state));
|
||||
thread->Context.ldt = null_ldt_sel;
|
||||
thread->Context.eflags = (1<<1)+(1<<9);
|
||||
thread->Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
|
||||
thread->Context.esp0 = &kernel_stack[1021];
|
||||
thread->Context.ss0 = KERNEL_DS;
|
||||
thread->Context.esp = &kernel_stack[1021];
|
||||
thread->Context.ss = KERNEL_DS;
|
||||
thread->Context.cs = KERNEL_CS;
|
||||
thread->Context.eip = (unsigned long)begin_thread;
|
||||
thread->Context.io_bitmap[0] = 0xff;
|
||||
thread->Context.cr3 = ((unsigned int)get_page_directory()) - IDMAP_BASE;
|
||||
thread->Context.ds = KERNEL_DS;
|
||||
thread->Context.es = KERNEL_DS;
|
||||
thread->Context.fs = KERNEL_DS;
|
||||
thread->Context.gs = KERNEL_DS;
|
||||
thread->Context.nr = desc * 8;
|
||||
DPRINT("Allocated %x\n",desc*8);
|
||||
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
@@ -149,6 +185,19 @@ void HalInitFirstTask(PKTHREAD thread)
|
||||
* initial thread
|
||||
*/
|
||||
{
|
||||
unsigned int base;
|
||||
unsigned int length;
|
||||
unsigned int desc;
|
||||
|
||||
memset(null_ldt,0,sizeof(null_ldt));
|
||||
desc = allocate_tss_descriptor();
|
||||
base = (unsigned int)&null_ldt;
|
||||
length = sizeof(null_ldt) - 1;
|
||||
gdt[desc].a = (length & 0xffff) | ((base & 0xffff) << 16);
|
||||
gdt[desc].b = ((base & 0xff0000)>>16) | 0x8200 | (length & 0xf0000)
|
||||
| (base & 0xff000000);
|
||||
null_ldt_sel = desc*8;
|
||||
|
||||
/*
|
||||
* Initialize the thread context
|
||||
*/
|
||||
@@ -159,5 +208,6 @@ void HalInitFirstTask(PKTHREAD thread)
|
||||
*/
|
||||
__asm__("ltr %%ax"
|
||||
: /* no output */
|
||||
: "a" (FIRST_TSS_OFFSET*8));
|
||||
: "a" (thread->Context.nr));
|
||||
FirstThread = thread;
|
||||
}
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/base/bug.c
|
||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
||||
* FILE: ntoskrnl/io/arc.c
|
||||
* PURPOSE: arc names
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#define NDEBUG
|
||||
@@ -19,7 +17,7 @@
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
static KSPIN_LOCK CancelSpinLock;
|
||||
static KSPIN_LOCK CancelSpinLock = {0,};
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -12,7 +12,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/iomgr.h>
|
||||
#include <internal/string.h>
|
||||
@@ -33,6 +32,28 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||
ULONG CreateOptions,
|
||||
PVOID EaBuffer,
|
||||
ULONG EaLength)
|
||||
/*
|
||||
* FUNCTION: Either causes a new file or directory to be created, or it opens
|
||||
* an existing file, device, directory or volume, giving the caller a handle
|
||||
* for the file object. This handle can be used by subsequent calls to
|
||||
* manipulate data within the file or the file object's state of attributes.
|
||||
* ARGUMENTS:
|
||||
* FileHandle (OUT) = Points to a variable which receives the file
|
||||
* handle on return
|
||||
* DesiredAccess = Desired access to the file
|
||||
* ObjectAttributes = Structure describing the file
|
||||
* IoStatusBlock (OUT) = Receives information about the operation on
|
||||
* return
|
||||
* AllocationSize = Initial size of the file in bytes
|
||||
* FileAttributes = Attributes to create the file with
|
||||
* ShareAccess = Type of shared access the caller would like to the file
|
||||
* CreateDisposition = Specifies what to do, depending on whether the
|
||||
* file already existings
|
||||
* CreateOptions = Options for creating a new file
|
||||
* EaBuffer = Undocumented
|
||||
* EaLength = Undocumented
|
||||
* RETURNS: Status
|
||||
*/
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
@@ -43,6 +64,19 @@ NTSTATUS ZwOpenFile(PHANDLE FileHandle,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
ULONG ShareAccess,
|
||||
ULONG OpenOptions)
|
||||
/*
|
||||
* FUNCTION: Opens a file (simpler than ZwCreateFile)
|
||||
* ARGUMENTS:
|
||||
* FileHandle (OUT) = Variable that receives the file handle on return
|
||||
* DesiredAccess = Access desired by the caller to the file
|
||||
* ObjectAttributes = Structue describing the file to be opened
|
||||
* IoStatusBlock (OUT) = Receives details about the result of the
|
||||
* operation
|
||||
* ShareAccess = Type of shared access the caller requires
|
||||
* OpenOptions = Options for the file open
|
||||
* RETURNS: Status
|
||||
* NOTE: Undocumented
|
||||
*/
|
||||
{
|
||||
PVOID Object;
|
||||
NTSTATUS Status;
|
||||
|
@@ -12,12 +12,11 @@
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/iomgr.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
@@ -92,7 +91,7 @@ NTSTATUS InitalizeLoadedDriver(PDRIVER_INITIALIZE entry)
|
||||
DriverObject=ExAllocatePool(NonPagedPool,sizeof(DRIVER_OBJECT));
|
||||
if (DriverObject==NULL)
|
||||
{
|
||||
printk("%s:%d\n",__FILE__,__LINE__);
|
||||
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
memset(DriverObject,sizeof(DRIVER_OBJECT),0);
|
||||
@@ -195,6 +194,7 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||
dev->DeviceType=DeviceType;
|
||||
dev->StackSize=1;
|
||||
dev->AlignmentRequirement=1;
|
||||
KeInitializeDeviceQueue(&dev->DeviceQueue);
|
||||
|
||||
*DeviceObject=dev;
|
||||
DPRINT("dev->DriverObject %x\n",dev->DriverObject);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/base/bug.c
|
||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
||||
* FILE: ntoskrnl/io/dpc.c
|
||||
* PURPOSE: io manager dpc functions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/iomgr/drvlck.c
|
||||
* FILE: ntoskrnl/io/drvlck.c
|
||||
* PURPOSE: Managing driver managing
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/base/bug.c
|
||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
||||
* FILE: ntoskrnl/io/errlog.c
|
||||
* PURPOSE: Error logging
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/io/file.c
|
||||
* FILE: ntoskrnl/io/file.c
|
||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
@@ -26,8 +24,8 @@ typedef struct
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
static KSPIN_LOCK FileSystemListLock;
|
||||
static LIST_ENTRY FileSystemListHead;
|
||||
static KSPIN_LOCK FileSystemListLock = {0,};
|
||||
static LIST_ENTRY FileSystemListHead = {NULL,NULL};
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
@@ -113,7 +111,7 @@ VOID IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||
current = CONTAINING_RECORD(current_entry,FILE_SYSTEM_OBJECT,Entry);
|
||||
if (current->DeviceObject == DeviceObject)
|
||||
{
|
||||
RemoveEntryFromList(&FileSystemListHead,current_entry);
|
||||
RemoveEntryList(current_entry);
|
||||
KeReleaseSpinLock(&FileSystemListLock,oldlvl);
|
||||
return;
|
||||
}
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -12,9 +12,11 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/objmgr.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
OBJECT_TYPE DeviceObjectType = {{0,0,NULL},
|
||||
@@ -64,22 +66,28 @@ VOID IoInit(VOID)
|
||||
/*
|
||||
* Register iomgr types
|
||||
*/
|
||||
CHECKPOINT;
|
||||
RtlInitAnsiString(&astring,"Device");
|
||||
CHECKPOINT;
|
||||
RtlAnsiStringToUnicodeString(&DeviceObjectType.TypeName,&astring,TRUE);
|
||||
CHECKPOINT;
|
||||
ObRegisterType(OBJTYP_DEVICE,&DeviceObjectType);
|
||||
|
||||
CHECKPOINT;
|
||||
RtlInitAnsiString(&astring,"File");
|
||||
RtlAnsiStringToUnicodeString(&FileObjectType.TypeName,&astring,TRUE);
|
||||
ObRegisterType(OBJTYP_FILE,&FileObjectType);
|
||||
|
||||
CHECKPOINT;
|
||||
/*
|
||||
* Create the device directory
|
||||
*/
|
||||
RtlInitAnsiString(&astring,"\\Device");
|
||||
CHECKPOINT;
|
||||
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
|
||||
CHECKPOINT;
|
||||
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
|
||||
CHECKPOINT;
|
||||
ZwCreateDirectoryObject(&handle,0,&attr);
|
||||
|
||||
CHECKPOINT;
|
||||
IoInitCancelHandling();
|
||||
IoInitSymbolicLinkImplementation();
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#include <internal/string.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#define NDEBUG
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <internal/hal/page.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
|
@@ -10,15 +10,13 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
PEPROCESS IoGetCurrentProcess()
|
||||
struct _EPROCESS* IoGetCurrentProcess()
|
||||
{
|
||||
return(PsGetCurrentProcess());
|
||||
}
|
||||
|
@@ -10,7 +10,8 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
@@ -54,6 +55,9 @@ VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable)
|
||||
PIRP Irp;
|
||||
KIRQL oldirql;
|
||||
|
||||
DPRINT("IoStartNextPacket(DeviceObject %x, Cancelable %d)\n",
|
||||
DeviceObject,Cancelable);
|
||||
|
||||
entry = KeRemoveDeviceQueue(&DeviceObject->DeviceQueue);
|
||||
|
||||
if (entry!=NULL)
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -12,7 +12,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/iomgr.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/objmgr.h>
|
||||
@@ -29,7 +28,7 @@
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||
HANDLE Event,
|
||||
HANDLE EventHandle,
|
||||
PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
@@ -42,6 +41,7 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||
PFILE_OBJECT FileObject = (PFILE_OBJECT)hdr;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
KEVENT Event;
|
||||
|
||||
if (hdr==NULL)
|
||||
{
|
||||
@@ -75,6 +75,8 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||
Irp->UserBuffer = NULL;
|
||||
Irp->AssociatedIrp.SystemBuffer = NULL;
|
||||
}
|
||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||
Irp->UserEvent=&Event;
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
DPRINT("StackPtr %x\n",StackPtr);
|
||||
@@ -106,7 +108,11 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||
|
||||
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||
IoCallDriver(FileObject->DeviceObject,Irp);
|
||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||
if (FileObject->DeviceObject->Flags&DO_BUFFERED_IO)
|
||||
{
|
||||
memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
@@ -23,9 +21,9 @@ VOID KeDrainApcQueue(VOID)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
PKAPC current;
|
||||
PKTHREAD CurrentThread=KeGetCurrentThread();
|
||||
|
||||
current_entry = KeGetCurrentThread()->ApcQueueHead.Flink;
|
||||
while (current_entry!=NULL)
|
||||
while ((current_entry=RemoveHeadList(CurrentThread->ApcList))!=NULL)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry,KAPC,ApcListEntry);
|
||||
current->NormalRoutine(current->NormalContext,
|
||||
@@ -35,25 +33,40 @@ VOID KeDrainApcQueue(VOID)
|
||||
}
|
||||
}
|
||||
|
||||
VOID KeInitializeApc(PKAPC Apc, PKNORMAL_ROUTINE NormalRoutine,
|
||||
PVOID NormalContext,
|
||||
PKTHREAD TargetThread)
|
||||
VOID KeInitializeApc(PKAPC Apc,
|
||||
PKTHREAD Thread,
|
||||
UCHAR StateIndex,
|
||||
PKKERNEL_ROUTINE KernelRoutine,
|
||||
PKRUNDOWN_ROUTINE RundownRoutine,
|
||||
PKNORMAL_ROUTINE NormalRoutine,
|
||||
UCHAR Mode,
|
||||
PVOID Context)
|
||||
{
|
||||
memset(Apc,0,sizeof(KAPC));
|
||||
Apc->Thread = TargetThread;
|
||||
Apc->Thread = Thread;
|
||||
Apc->ApcListEntry.Flink=NULL;
|
||||
Apc->ApcListEntry.Blink=NULL;
|
||||
Apc->KernelRoutine=KernelRoutine;
|
||||
Apc->RundownRoutine=RundownRoutine;
|
||||
Apc->NormalRoutine=NormalRoutine;
|
||||
Apc->NormalContext=NormalContext;
|
||||
Apc->NormalContext=Context;
|
||||
Apc->Inserted=FALSE;
|
||||
Apc->ApcStateIndex=StateIndex;
|
||||
Apc->ApcMode=Mode;
|
||||
}
|
||||
|
||||
BOOLEAN KeInsertQueueApc(PKAPC Apc)
|
||||
void KeInsertQueueApc(PKAPC Apc, PVOID SystemArgument1,
|
||||
PVOID SystemArgument2, UCHAR Mode)
|
||||
{
|
||||
Apc->SystemArgument1=SystemArgument1;
|
||||
Apc->SystemArgument2=SystemArgument2;
|
||||
Apc->ApcMode=Mode;
|
||||
if (Apc->Inserted)
|
||||
{
|
||||
return(FALSE);
|
||||
return;
|
||||
}
|
||||
Apc->Inserted=TRUE;
|
||||
InsertTailList(&Apc->Thread->ApcQueueHead,&Apc->ApcListEntry);
|
||||
return(TRUE);
|
||||
InsertTailList(Apc->Thread->ApcList,&Apc->ApcListEntry);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
@@ -49,7 +47,7 @@ BOOLEAN KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
|
||||
CallbackRecord->CallbackRoutine=CallbackRoutine;
|
||||
}
|
||||
|
||||
asmlinkage VOID KeBugCheckEx(ULONG BugCheckCode,
|
||||
VOID KeBugCheckEx(ULONG BugCheckCode,
|
||||
ULONG BugCheckParameter1,
|
||||
ULONG BugCheckParameter2,
|
||||
ULONG BugCheckParameter3,
|
||||
@@ -63,13 +61,13 @@ asmlinkage VOID KeBugCheckEx(ULONG BugCheckCode,
|
||||
* RETURNS: Doesn't
|
||||
*/
|
||||
{
|
||||
printk("Bug detected (code %x param %x %x %x %x)\n",BugCheckCode,
|
||||
DbgPrint("Bug detected (code %x param %x %x %x %x)\n",BugCheckCode,
|
||||
BugCheckParameter1,BugCheckParameter2,BugCheckParameter3,
|
||||
BugCheckParameter4);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
asmlinkage VOID KeBugCheck(ULONG BugCheckCode)
|
||||
VOID KeBugCheck(ULONG BugCheckCode)
|
||||
/*
|
||||
* FUNCTION: Brings the system down in a controlled manner when an
|
||||
* inconsistency that might otherwise cause corruption has been detected
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: mkernel/kernel/catch.c
|
||||
* FILE: ntoskrnl/ke/catch.c
|
||||
* PURPOSE: Exception handling
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
*/
|
||||
@@ -10,12 +10,11 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
VOID ExRaiseStatus(NTSTATUS Status)
|
||||
{
|
||||
printk("ExRaiseStatus(%d)\n",Status);
|
||||
DbgPrint("ExRaiseStatus(%d)\n",Status);
|
||||
for(;;);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/base/critical.c
|
||||
* FILE: ntoskrnl/ke/critical.c
|
||||
* PURPOSE: Implement critical regions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: mkernel/kernel/dispatch.c
|
||||
* FILE: ntoskrnl/ke/dispatch.c
|
||||
* PURPOSE: Handles a dispatch interrupt
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
*/
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/ke.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
void KiDispatchInterrupt(unsigned int irq)
|
||||
VOID KiDispatchInterrupt(ULONG irq)
|
||||
/*
|
||||
* FUNCTION: Called after an irq when the interrupted processor was at a lower
|
||||
* level than DISPATCH_LEVEL
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: mkernel/kernel/dpc.cc
|
||||
* FILE: ntoskrnl/ke/dpc.c
|
||||
* PURPOSE: Handle DPCs (Delayed Procedure Calls)
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -9,20 +9,22 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: See also the higher level support routines in mkernel/iomgr/iodpc.cc
|
||||
* NOTE: See also the higher level support routines in ntoskrnl/io/dpc.c
|
||||
*/
|
||||
|
||||
/* INCLUDES ***************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* TYPES *******************************************************************/
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
LIST_ENTRY DpcQueueHead;
|
||||
static LIST_ENTRY DpcQueueHead={NULL,NULL};
|
||||
static KSPIN_LOCK DpcQueueLock={0,};
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
@@ -48,17 +50,25 @@ void KeDrainDpcQueue(void)
|
||||
* FUNCTION: Called to execute queued dpcs
|
||||
*/
|
||||
{
|
||||
PLIST_ENTRY current_entry = ExInterlockedRemoveHeadList(&DpcQueueHead,NULL);
|
||||
PKDPC current = CONTAINING_RECORD(¤t_entry,KDPC,DpcListEntry);
|
||||
PLIST_ENTRY current_entry;
|
||||
PKDPC current;
|
||||
|
||||
while (current_entry!=NULL)
|
||||
|
||||
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
|
||||
current_entry = RemoveHeadList(&DpcQueueHead);
|
||||
current = CONTAINING_RECORD(current_entry,KDPC,DpcListEntry);
|
||||
while (current_entry!=(&DpcQueueHead))
|
||||
{
|
||||
CHECKPOINT;
|
||||
current->DeferredRoutine(current,current->DeferredContext,
|
||||
current->SystemArgument1,
|
||||
current->SystemArgument2);
|
||||
current_entry = ExInterlockedRemoveHeadList(&DpcQueueHead,NULL);
|
||||
current->Lock=FALSE;
|
||||
current_entry = RemoveHeadList(&DpcQueueHead);
|
||||
current = CONTAINING_RECORD(¤t_entry,KDPC,DpcListEntry);
|
||||
}
|
||||
KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
|
||||
// DPRINT("Finished KeDrainDpcQueue()\n",0);
|
||||
}
|
||||
|
||||
BOOLEAN KeRemoveQueueDpc(PKDPC Dpc)
|
||||
@@ -74,8 +84,9 @@ BOOLEAN KeRemoveQueueDpc(PKDPC Dpc)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
ExInterlockedRemoveEntryList(&DpcQueueHead,&Dpc->DpcListEntry,NULL);
|
||||
RemoveEntryList(&Dpc->DpcListEntry);
|
||||
Dpc->Lock=0;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
BOOLEAN KeInsertQueueDpc(PKDPC dpc, PVOID SystemArgument1,
|
||||
@@ -90,6 +101,9 @@ BOOLEAN KeInsertQueueDpc(PKDPC dpc, PVOID SystemArgument1,
|
||||
* FALSE otherwise
|
||||
*/
|
||||
{
|
||||
DPRINT("KeInsertQueueDpc()\n",0);
|
||||
assert(KeGetCurrentIrql()==DISPATCH_LEVEL);
|
||||
|
||||
dpc->Number=0;
|
||||
dpc->Importance=Medium;
|
||||
dpc->SystemArgument1=SystemArgument1;
|
||||
@@ -98,8 +112,12 @@ BOOLEAN KeInsertQueueDpc(PKDPC dpc, PVOID SystemArgument1,
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
ExInterlockedInsertHeadList(&DpcQueueHead,&dpc->DpcListEntry,NULL);
|
||||
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
|
||||
InsertHeadList(&DpcQueueHead,&dpc->DpcListEntry);
|
||||
KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
|
||||
dpc->Lock=1;
|
||||
DPRINT("DpcQueueHead.Flink %x\n",DpcQueueHead.Flink);
|
||||
DPRINT("Leaving KeInsertQueueDpc()\n",0);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
/*
|
||||
* Last error code (this should be per process)
|
||||
*/
|
||||
DWORD error_code;
|
||||
DWORD error_code = 0;
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/event.c
|
||||
* PURPOSE: Implements event
|
||||
* PURPOSE: Implements events
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
@@ -10,27 +10,22 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/wait.h>
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
VOID KeClearEvent(PKEVENT Event)
|
||||
{
|
||||
Event->Header.SignalState=FALSE; // (??) Is this atomic
|
||||
Event->Header.SignalState=FALSE;
|
||||
}
|
||||
|
||||
VOID KeInitializeEvent(PKEVENT Event, EVENT_TYPE Type, BOOLEAN State)
|
||||
{
|
||||
Event->Header.Type = Type;
|
||||
Event->Header.Absolute = 0;
|
||||
Event->Header.Inserted = 0;
|
||||
Event->Header.Size = sizeof(KEVENT) / sizeof(ULONG);
|
||||
Event->Header.SignalState = State;
|
||||
KeInitializeDispatcherHeader(&(Event->Header),Type,
|
||||
sizeof(Event)/sizeof(ULONG),State);
|
||||
InitializeListHead(&(Event->Header.WaitListHead));
|
||||
}
|
||||
|
||||
@@ -47,10 +42,11 @@ LONG KeResetEvent(PKEVENT Event)
|
||||
LONG KeSetEvent(PKEVENT Event, KPRIORITY Increment, BOOLEAN Wait)
|
||||
{
|
||||
int ret;
|
||||
KIRQL oldlvl;
|
||||
|
||||
KeAcquireSpinLock(&DispatcherDatabaseLock,&oldlvl);
|
||||
ret = InterlockedExchange(&(Event->Header.SignalState),1);
|
||||
DPRINT("KeSetEvent(Event %x, Wait %x)\n",Event,Wait);
|
||||
KeAcquireDispatcherDatabaseLock(Wait);
|
||||
// ret = InterlockedExchange(&(Event->Header.SignalState),1);
|
||||
Event->Header.SignalState=1;
|
||||
KeDispatcherObjectWake((DISPATCHER_HEADER *)Event);
|
||||
KeReleaseSpinLock(&DispatcherDatabaseLock,oldlvl);
|
||||
KeReleaseDispatcherDatabaseLock(Wait);
|
||||
}
|
||||
|
@@ -12,8 +12,8 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/kernel.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
@@ -54,7 +54,7 @@ BOOLEAN KeInsertByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
|
||||
}
|
||||
|
||||
current=DeviceQueue->ListHead.Flink;
|
||||
while (current!=NULL)
|
||||
while (current!=(&DeviceQueue->ListHead))
|
||||
{
|
||||
entry = CONTAINING_RECORD(current,KDEVICE_QUEUE_ENTRY,Entry);
|
||||
if (entry->Key < SortKey)
|
||||
@@ -98,7 +98,7 @@ PKDEVICE_QUEUE_ENTRY KeRemoveByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
|
||||
entry = CONTAINING_RECORD(current,KDEVICE_QUEUE_ENTRY,Entry);
|
||||
if (entry->Key < SortKey || current->Flink == NULL)
|
||||
{
|
||||
RemoveEntryFromList(&DeviceQueue->ListHead,current);
|
||||
RemoveEntryList(current);
|
||||
KeReleaseSpinLock(&DeviceQueue->Lock,oldlvl);
|
||||
return(entry);
|
||||
}
|
||||
@@ -118,6 +118,8 @@ PKDEVICE_QUEUE_ENTRY KeRemoveDeviceQueue(PKDEVICE_QUEUE DeviceQueue)
|
||||
PLIST_ENTRY list_entry;
|
||||
PKDEVICE_QUEUE_ENTRY entry;
|
||||
|
||||
DPRINT("KeRemoveDeviceQueue(DeviceQueue %x)\n",DeviceQueue);
|
||||
|
||||
assert_irql(DISPATCH_LEVEL);
|
||||
assert(DeviceQueue!=NULL);
|
||||
assert(DeviceQueue->Busy);
|
||||
@@ -125,7 +127,7 @@ PKDEVICE_QUEUE_ENTRY KeRemoveDeviceQueue(PKDEVICE_QUEUE DeviceQueue)
|
||||
KeAcquireSpinLock(&DeviceQueue->Lock,&oldlvl);
|
||||
|
||||
list_entry = RemoveHeadList(&DeviceQueue->ListHead);
|
||||
if (list_entry==NULL)
|
||||
if (list_entry==(&DeviceQueue->ListHead))
|
||||
{
|
||||
DeviceQueue->Busy=FALSE;
|
||||
KeReleaseSpinLock(&DeviceQueue->Lock,oldlvl);
|
||||
|
@@ -11,9 +11,8 @@
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <coff.h>
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/version.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/string.h>
|
||||
@@ -101,6 +100,9 @@ void set_breakpoint(unsigned int i, unsigned int addr, unsigned int type,
|
||||
: "ax");
|
||||
}
|
||||
|
||||
extern int edata;
|
||||
extern int end;
|
||||
|
||||
asmlinkage void _main(boot_param* _bp)
|
||||
/*
|
||||
* FUNCTION: Called by the boot loader to start the kernel
|
||||
@@ -112,11 +114,14 @@ asmlinkage void _main(boot_param* _bp)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int start;
|
||||
unsigned int start1;
|
||||
boot_param bp;
|
||||
|
||||
// memset((void *)&edata,0,((int)&end)-((int)&edata));
|
||||
|
||||
/*
|
||||
* Copy the parameters to a local buffer because lowmem will go away
|
||||
*/
|
||||
boot_param bp;
|
||||
memcpy(&bp,_bp,sizeof(bp));
|
||||
|
||||
/*
|
||||
@@ -126,44 +131,51 @@ asmlinkage void _main(boot_param* _bp)
|
||||
|
||||
printk("Starting ReactOS "KERNEL_VERSION"\n");
|
||||
|
||||
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
||||
DPRINT("MmGetPhysicalAddress(start) = %x\n",MmGetPhysicalAddress(start));
|
||||
DPRINT("bp.module_length[0] %x PAGE_ROUND_UP(bp.module_length[0]) %x\n",
|
||||
bp.module_length[0],PAGE_ROUND_UP(bp.module_length[0]));
|
||||
start1 = start+PAGE_ROUND_UP(bp.module_length[1]);
|
||||
DPRINT("bp.module_length[1] %x PAGE_ROUND_UP(bp.module_length[1]) %x\n",
|
||||
bp.module_length[1],PAGE_ROUND_UP(bp.module_length[1]));
|
||||
|
||||
DPRINT("start %x *start %x\n",start,*((unsigned int *)start));
|
||||
DPRINT("start1 %x *start1 %x\n",start1,*((unsigned int *)start1));
|
||||
|
||||
|
||||
/*
|
||||
* Initalize various critical subsystems
|
||||
*/
|
||||
HalInit(&bp);
|
||||
// set_breakpoint(0,start,HBP_READWRITE,HBP_DWORD);
|
||||
MmInitalize(&bp);
|
||||
KeInitDpc();
|
||||
KeInitializeBugCheck();
|
||||
KeInitializeDispatcher();
|
||||
InitializeTimer();
|
||||
|
||||
/*
|
||||
* Allow interrupts
|
||||
*/
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
|
||||
KeCalibrateTimerLoop();
|
||||
ObjNamespcInit();
|
||||
PsMgrInit();
|
||||
CHECKPOINT;
|
||||
KeInit();
|
||||
CHECKPOINT;
|
||||
ObInit();
|
||||
CHECKPOINT;
|
||||
PsInit();
|
||||
CHECKPOINT;
|
||||
IoInit();
|
||||
CHECKPOINT;
|
||||
|
||||
/*
|
||||
* Initalize loaded modules
|
||||
* Initalize services loaded at boot time
|
||||
*/
|
||||
DPRINT("%d files loaded\n",bp.nr_files);
|
||||
|
||||
|
||||
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]) +
|
||||
PAGESIZE;
|
||||
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
||||
for (i=1;i<bp.nr_files;i++)
|
||||
{
|
||||
DPRINT("start %x length %d\n",start,bp.module_length[i]);
|
||||
DPRINT("start %x *start %x\n",start,*((unsigned int *)start));
|
||||
CHECKPOINT;
|
||||
process_boot_module(start);
|
||||
start=start+PAGE_ROUND_UP(bp.module_length[i])+PAGESIZE;
|
||||
CHECKPOINT;
|
||||
start=start+PAGE_ROUND_UP(bp.module_length[i]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Enter shell
|
||||
* Test various features of the kernel
|
||||
*/
|
||||
TstBegin();
|
||||
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/iomgr.h>
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/symbol.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/mm.h>
|
||||
@@ -120,7 +119,7 @@ static int do_reloc32_reloc(module* mod, SCNHDR* scn, RELOC* reloc)
|
||||
val = get_kernel_symbol_addr(name);
|
||||
if (val==0)
|
||||
{
|
||||
printk("Undefined symbol %s in module\n",name);
|
||||
DbgPrint("Undefined symbol %s in module\n",name);
|
||||
return(0);
|
||||
}
|
||||
// DPRINT("REL32 value %x name %s\n",val,name);
|
||||
@@ -204,7 +203,7 @@ static BOOLEAN do_reloc(module* mod, unsigned int scn_idx)
|
||||
break;
|
||||
|
||||
default:
|
||||
printk("Unknown relocation type %x at %d in module\n",
|
||||
DbgPrint("Unknown relocation type %x at %d in module\n",
|
||||
reloc->r_type,j);
|
||||
return(0);
|
||||
}
|
||||
@@ -234,8 +233,8 @@ BOOLEAN process_boot_module(unsigned int start)
|
||||
PDRIVER_INITIALIZE func;
|
||||
int i;
|
||||
|
||||
DPRINT("process_boot_module(start %x)\n",start);
|
||||
DPRINT("n = %x\n",*((unsigned int *)start));
|
||||
|
||||
mod=(module *)ExAllocatePool(NonPagedPool,sizeof(module));
|
||||
|
||||
DPRINT("magic %x\n",((FILHDR *)start)->f_magic);
|
||||
@@ -244,7 +243,7 @@ BOOLEAN process_boot_module(unsigned int start)
|
||||
|
||||
if (I386BADMAG(hdr))
|
||||
{
|
||||
printk("(%s:%d) Module has bad magic value (%x)\n",__FILE__,
|
||||
DbgPrint("(%s:%d) Module has bad magic value (%x)\n",__FILE__,
|
||||
__LINE__,hdr.f_magic);
|
||||
return(0);
|
||||
}
|
||||
@@ -288,14 +287,14 @@ BOOLEAN process_boot_module(unsigned int start)
|
||||
}
|
||||
}
|
||||
|
||||
mod->base = (unsigned int)VirtualAlloc((LPVOID)0,mod->size,MEM_COMMIT,
|
||||
PAGE_SYSTEM + PAGE_EXECUTE_READWRITE);
|
||||
CHECKPOINT;
|
||||
mod->base = (unsigned int)MmAllocateSection(mod->size);
|
||||
if (mod->base == 0)
|
||||
{
|
||||
printk("Failed to allocated section for module\n");
|
||||
DbgPrint("Failed to alloc section for module\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
/*
|
||||
* Adjust section vaddrs for allocated area
|
||||
@@ -349,7 +348,7 @@ BOOLEAN process_boot_module(unsigned int start)
|
||||
|
||||
if (!found_entry)
|
||||
{
|
||||
printk("No module entry point defined\n");
|
||||
DbgPrint("No module entry point defined\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/base/mutex.c
|
||||
* FILE: ntoskrnl/ke/mutex.c
|
||||
* PURPOSE: Implements mutex
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/base/sem.c
|
||||
* FILE: ntoskrnl/ke/sem.c
|
||||
* PURPOSE: Implements kernel semaphores
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
@@ -10,9 +10,8 @@
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/kernel.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ke.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
@@ -22,12 +21,15 @@ VOID KeInitializeSemaphore(PKSEMAPHORE Semaphore,
|
||||
LONG Count,
|
||||
LONG Limit)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
KeInitializeDispatcherHeader(&Semaphore->Header,SemaphoreType,
|
||||
sizeof(KSEMAPHORE)/sizeof(ULONG),
|
||||
Count);
|
||||
Semaphore->Limit=Limit;
|
||||
}
|
||||
|
||||
LONG KeReadStateSemaphore(PKSEMAPHORE Semaphore)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return(Semaphore->Header.SignalState);
|
||||
}
|
||||
|
||||
LONG KeReleaseSemaphore(PKSEMAPHORE Semaphore,
|
||||
@@ -35,6 +37,5 @@ LONG KeReleaseSemaphore(PKSEMAPHORE Semaphore,
|
||||
LONG Adjustment,
|
||||
BOOLEAN Wait)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user