mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
All task switching is done in software.
Beginnings of v86 mode support. Corrected locking bug when terminating multithreaded process. svn path=/trunk/; revision=1475
This commit is contained in:
parent
b6c91b703e
commit
8445b12452
59 changed files with 1885 additions and 1992 deletions
|
@ -1,5 +1,5 @@
|
||||||
file ntoskrnl/ntoskrnl.nostrip.exe
|
file ntoskrnl/ntoskrnl.nostrip.exe
|
||||||
add-symbol-file lib/ntdll/ntdll.dll 0x77f61000
|
#add-symbol-file lib/ntdll/ntdll.dll 0x77f61000
|
||||||
add-symbol-file apps/apc/apc.exe 0x401000
|
#add-symbol-file apps/apc/apc.exe 0x401000
|
||||||
#add-symbol-file subsys/csrss/csrss.exe 0x401000
|
#add-symbol-file subsys/csrss/csrss.exe 0x401000
|
||||||
break exp.c:156
|
break exp.c:154
|
||||||
|
|
|
@ -1,3 +1,33 @@
|
||||||
|
2000-12-23 David Welch <welch@cwcom.net>
|
||||||
|
|
||||||
|
* All task switching is done in software.
|
||||||
|
* Beginnings of v86 mode support.
|
||||||
|
|
||||||
|
2000-12-22 David Welch <welch@cwcom.net>
|
||||||
|
|
||||||
|
* ntoskrnl/ps/kill.c (PiTerminateProcessThreads): Drop
|
||||||
|
PiThreadListLock before calling PsTerminateOtherThread
|
||||||
|
|
||||||
|
2000-12-16 David Welch <welch@cwcom.net>
|
||||||
|
|
||||||
|
* ntoskrnl/ex/fmutex.c (ExReleaseFastMutexUnsafe): Only set the
|
||||||
|
fast mutex's owner back to NULL if it is being released
|
||||||
|
|
||||||
|
2000-12-10 David Welch <welch@cwcom.net>
|
||||||
|
|
||||||
|
* ntoskrnl/ke/i386/vm86_sup.S (Ki386RetToV86Mode): Added function
|
||||||
|
to do the raw switch to v86 mode.
|
||||||
|
* ntoskrnl/include/internal/vm86.h: Definitions for the v86 mode
|
||||||
|
support.
|
||||||
|
|
||||||
|
2000-12-10 David Welch <welch@cwcom.net>
|
||||||
|
|
||||||
|
* ntoskrnl/ke/i386/trap.s (PsBeginThreadWithContextInternal): Moved
|
||||||
|
to ntoskrnl/ke/i386/bswitch.S.
|
||||||
|
* ntoskrnl/ke/i386/trap.s (interrupt_handler2e): Moved to
|
||||||
|
ntoskrnl/ke/i386/syscall.S.
|
||||||
|
* ntoskrnl/ke/i386/trap.s (old_interrupt_handler2e): Removed.
|
||||||
|
|
||||||
2000-12-04 David Welch <welch@cwcom.net>
|
2000-12-04 David Welch <welch@cwcom.net>
|
||||||
|
|
||||||
* ntoskrnl/ke/i386/irq.c (KiInterruptDispatch): Record the last PC
|
* ntoskrnl/ke/i386/irq.c (KiInterruptDispatch): Record the last PC
|
||||||
|
@ -50,3 +80,13 @@
|
||||||
APC).
|
APC).
|
||||||
|
|
||||||
* Disabled broken code in kernel32.
|
* Disabled broken code in kernel32.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
\input texinfo @c -*-texinfo-*-
|
|
||||||
@c %**start of header
|
|
||||||
@setfilename psmgr.info
|
|
||||||
@settitle Reactos Process Manager: Design and Implementation
|
|
||||||
@setchapternewpage odd
|
|
||||||
@c %**end of header
|
|
||||||
|
|
||||||
@ifinfo
|
|
||||||
This file documents the ReactOS Process Manager.
|
|
||||||
|
|
||||||
Copyright 2000 David Welch
|
|
||||||
@end ifinfo
|
|
||||||
|
|
||||||
@titlepage
|
|
||||||
@title ReactOS Process Manager: Design and Implementation
|
|
||||||
@author David Welch
|
|
||||||
|
|
||||||
@page
|
|
||||||
@vskip 0pt plus 1filll
|
|
||||||
Copyright @copyright{} 2000 David Welch
|
|
||||||
@end titlepage
|
|
||||||
|
|
||||||
@node Top, Copyright, , (dir)
|
|
||||||
|
|
||||||
@ifinfo
|
|
||||||
This document describes the ReactOS Process Manager.
|
|
||||||
|
|
||||||
This document applies to version 0.0.16.
|
|
||||||
@end ifinfo
|
|
||||||
|
|
||||||
@menu
|
|
||||||
* Copyright:: Your rights and freedoms
|
|
||||||
* Overview:: Introduction
|
|
||||||
@end menu
|
|
||||||
|
|
||||||
@node Copyright, Overview, Top, Top
|
|
||||||
@chapter Copyright
|
|
||||||
@cindex Index entry for Copyright
|
|
||||||
ReactOS is distributed under the terms of the GNU General Public License,
|
|
||||||
this basically means that you can give it to anyone for any price as long
|
|
||||||
as full source code is included; you also have the right to distribute
|
|
||||||
modified copies in the same way. For the actual legalese see the file
|
|
||||||
'COPYING' in the distribution.
|
|
||||||
|
|
||||||
@node Overview, ,Copyright, Top
|
|
||||||
@chapter Overview
|
|
||||||
@cindex Index entry for Overview
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@contents
|
|
||||||
@bye
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
* Critical path tasks
|
* Critical path tasks
|
||||||
Test and debug Registry routines
|
Test and debug Registry routines
|
||||||
Finish multiple system service table support (HalRegisterServiceTable)
|
Implement file cache
|
||||||
Modify GENNTDLL to generate all needed system service tables
|
Implement paging
|
||||||
|
|
||||||
* These tasks would be nice
|
* These tasks would be nice
|
||||||
Separate HAL into KM DLL
|
Separate HAL into KM DLL
|
||||||
|
@ -26,13 +26,10 @@
|
||||||
Named pipes (see io/npipe.c)
|
Named pipes (see io/npipe.c)
|
||||||
Hardware resource management (see io/resource.c)
|
Hardware resource management (see io/resource.c)
|
||||||
File access checking (see io/share.c)
|
File access checking (see io/share.c)
|
||||||
APCs to user-mode (see ke/apc.c, ke/apchelp.asm)
|
|
||||||
Exception support (see ke/catch.c)
|
Exception support (see ke/catch.c)
|
||||||
Mutex support (see ke/mutex.c)
|
Mutex support (see ke/mutex.c)
|
||||||
Semaphore support (see ke/sem.c)
|
Semaphore support (see ke/sem.c)
|
||||||
Timer support (see ke/timer.c)
|
Timer support (see ke/timer.c)
|
||||||
Properly calibrate delay loop (see ke/timer.c)
|
|
||||||
Waiting for multiple objects (see ke/wait.c)
|
|
||||||
Single linked lists (see rtl/slist.c)
|
Single linked lists (see rtl/slist.c)
|
||||||
Sequenced lists (see rtl/seqlist.c)
|
Sequenced lists (see rtl/seqlist.c)
|
||||||
|
|
||||||
|
@ -43,13 +40,7 @@
|
||||||
* Major areas
|
* Major areas
|
||||||
|
|
||||||
Security support (see se/*.c)
|
Security support (see se/*.c)
|
||||||
Registry support (see cm/*.c)
|
|
||||||
Paging support
|
|
||||||
File system cache support
|
|
||||||
SCSI miniport driver
|
SCSI miniport driver
|
||||||
Network support
|
|
||||||
Video drivers
|
|
||||||
USER and GDI modules
|
|
||||||
|
|
||||||
* Drivers
|
* Drivers
|
||||||
NTFS, EXT2 filesystems
|
NTFS, EXT2 filesystems
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
# $Id: Makefile,v 1.1 2000/12/10 23:42:01 dwelch Exp $
|
# $Id: Makefile,v 1.2 2000/12/23 02:37:41 dwelch Exp $
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
PATH_TO_TOP = ../../..
|
PATH_TO_TOP = ../../..
|
||||||
|
|
||||||
TARGET = minixfs
|
TARGET=minixfs
|
||||||
|
|
||||||
BASE_CFLAGS = -I../../../include
|
OBJECTS = $(TARGET).o $(TARGET).coff ../../../ntoskrnl/ntoskrnl.a
|
||||||
|
|
||||||
OBJECTS = block.o rw.o inode.o dir.o mount.o blockdev.o cache.o bitops.o \
|
CFLAGS = -I. -g
|
||||||
$(TARGET).coff ../../../ntoskrnl/ntoskrnl.a
|
|
||||||
|
|
||||||
all: $(TARGET).sys $(TARGET).sys.unstripped
|
all: $(TARGET).sys
|
||||||
|
|
||||||
.phony: all
|
.phony: all
|
||||||
|
|
||||||
|
@ -35,7 +34,12 @@ dist: ../../../$(DIST_DIR)/drivers/$(TARGET).sys
|
||||||
../../../$(DIST_DIR)/drivers/$(TARGET).sys: $(TARGET).sys
|
../../../$(DIST_DIR)/drivers/$(TARGET).sys: $(TARGET).sys
|
||||||
$(CP) $(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys
|
$(CP) $(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys
|
||||||
|
|
||||||
$(TARGET).sys $(TARGET).sys.unstripped: $(OBJECTS)
|
MOBJECTS = block.o blockdev.o cache.o dir.o inode.o mount.o rw.o bitops.o
|
||||||
|
|
||||||
WARNINGS_ARE_ERRORS = yes
|
minixfs.o: $(MOBJECTS)
|
||||||
|
$(LD) -r -o minixfs.o $(MOBJECTS)
|
||||||
|
|
||||||
|
$(TARGET).sys: $(OBJECTS)
|
||||||
|
|
||||||
|
WITH_DEBUGGING=yes
|
||||||
include ../../../rules.mak
|
include ../../../rules.mak
|
||||||
|
|
|
@ -120,7 +120,7 @@ NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
current_ino = MINIX_ROOT_INO;
|
current_ino = MINIX_ROOT_INO;
|
||||||
|
|
||||||
while (next!=NULL && current_ino!=0)
|
while (next != NULL && current_ino != 0)
|
||||||
{
|
{
|
||||||
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
||||||
¤t_dir,
|
¤t_dir,
|
||||||
current);
|
current);
|
||||||
}
|
}
|
||||||
if (next==NULL && current_ino!=0)
|
if (next == NULL && current_ino != 0)
|
||||||
{
|
{
|
||||||
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ NTSTATUS MinixCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
FileObject->FsContext=result;
|
FileObject->FsContext = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
|
|
|
@ -1,458 +0,0 @@
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: services/fs/minix/minix.c
|
|
||||||
* PURPOSE: Minix FSD
|
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
||||||
* UPDATE HISTORY:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
|
||||||
#include <wstring.h>
|
|
||||||
|
|
||||||
//#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "minix_fs.h"
|
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
|
||||||
|
|
||||||
static PDRIVER_OBJECT DriverObject;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT AttachedDevice;
|
|
||||||
struct minix_inode root_inode;
|
|
||||||
char superblock_buf[BLOCKSIZE];
|
|
||||||
struct minix_super_block* sb;
|
|
||||||
} MINIX_DEVICE_EXTENSION;
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned int MinixGetIndirectBlock(struct minix_inode* inode,
|
|
||||||
unsigned char* buffer, int blk)
|
|
||||||
{
|
|
||||||
unsigned short int* buf = (unsigned short int *)buffer;
|
|
||||||
return(buf[blk]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int MinixGetBlock(PDEVICE_OBJECT DeviceObject,
|
|
||||||
struct minix_inode* inode,
|
|
||||||
int blk)
|
|
||||||
{
|
|
||||||
int block;
|
|
||||||
char* buffer;
|
|
||||||
|
|
||||||
|
|
||||||
DPRINT("MinixGetBlock(inode %x, blk %d)\n",inode,blk);
|
|
||||||
|
|
||||||
if (blk < 7)
|
|
||||||
{
|
|
||||||
block = inode->i_zone[blk];
|
|
||||||
return(block);
|
|
||||||
}
|
|
||||||
blk = blk - 7;
|
|
||||||
|
|
||||||
buffer = ExAllocatePool(NonPagedPool,1024);
|
|
||||||
|
|
||||||
if (blk < 512)
|
|
||||||
{
|
|
||||||
block = inode->i_zone[7];
|
|
||||||
MinixReadSector(DeviceObject,block,buffer);
|
|
||||||
block = MinixGetIndirectBlock(inode,buffer,blk);
|
|
||||||
ExFreePool(buffer);
|
|
||||||
return(block);
|
|
||||||
}
|
|
||||||
blk = blk - 512;
|
|
||||||
block = inode->i_zone[8];
|
|
||||||
MinixReadSector(DeviceObject,block,buffer);
|
|
||||||
block = MinixGetIndirectBlock(inode,buffer,(blk>>9)&511);
|
|
||||||
MinixReadSector(DeviceObject,block,buffer);
|
|
||||||
block = MinixGetIndirectBlock(inode,buffer,blk&511);
|
|
||||||
ExFreePool(buffer);
|
|
||||||
return(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
|
|
||||||
struct minix_inode* inode,
|
|
||||||
int blk,
|
|
||||||
PVOID buffer)
|
|
||||||
{
|
|
||||||
unsigned int block;
|
|
||||||
|
|
||||||
DPRINT("MinixReadBlock(inode %x, blk %d, buffer %x)\n",inode,blk,buffer);
|
|
||||||
block = MinixGetBlock(DeviceObject,inode,blk);
|
|
||||||
DPRINT("block %d\n",block);
|
|
||||||
return(MinixReadSector(DeviceObject,block,buffer));
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID MinixMount(PDEVICE_OBJECT DeviceToMount)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT DeviceObject;
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt;
|
|
||||||
|
|
||||||
IoCreateDevice(DriverObject,
|
|
||||||
sizeof(MINIX_DEVICE_EXTENSION),
|
|
||||||
NULL,
|
|
||||||
FILE_DEVICE_FILE_SYSTEM,
|
|
||||||
0,
|
|
||||||
FALSE,
|
|
||||||
&DeviceObject);
|
|
||||||
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
|
||||||
DeviceExt = DeviceObject->DeviceExtension;
|
|
||||||
|
|
||||||
MinixReadSector(DeviceToMount,1,DeviceExt->superblock_buf);
|
|
||||||
DeviceExt->sb = (struct minix_super_block *)(DeviceExt->superblock_buf);
|
|
||||||
|
|
||||||
DeviceExt->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
|
||||||
DeviceToMount);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
PVPB vpb = Stack->Parameters.Mount.Vpb;
|
|
||||||
PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
|
|
||||||
NTSTATUS Status;
|
|
||||||
char* superblock_buf;
|
|
||||||
struct minix_super_block* sb;
|
|
||||||
|
|
||||||
DbgPrint("MinixFileSystemControl(DeviceObject %x, Irp %x)\n",DeviceObject,
|
|
||||||
Irp);
|
|
||||||
DPRINT("DeviceToMount %x\n",DeviceToMount);
|
|
||||||
|
|
||||||
superblock_buf = ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
|
||||||
|
|
||||||
DPRINT("MinixReadSector %x\n",MinixReadSector);
|
|
||||||
MinixReadSector(DeviceToMount,1,superblock_buf);
|
|
||||||
sb = (struct minix_super_block *)superblock_buf;
|
|
||||||
DPRINT("Magic %x\n",sb->s_magic);
|
|
||||||
DPRINT("Imap blocks %x\n",sb->s_imap_blocks);
|
|
||||||
DPRINT("Zmap blocks %x\n",sb->s_zmap_blocks);
|
|
||||||
if (sb->s_magic==MINIX_SUPER_MAGIC2)
|
|
||||||
{
|
|
||||||
DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
|
|
||||||
MinixMount(DeviceToMount);
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("%s() = STATUS_UNRECOGNIZED_VOLUME\n",__FUNCTION__);
|
|
||||||
Status = STATUS_UNRECOGNIZED_VOLUME;
|
|
||||||
}
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS MinixReadInode(PDEVICE_OBJECT DeviceObject,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
ULONG ino,
|
|
||||||
struct minix_inode* result)
|
|
||||||
{
|
|
||||||
int block;
|
|
||||||
char* buffer;
|
|
||||||
struct minix_inode* inodes;
|
|
||||||
|
|
||||||
DPRINT("MinixReadInode(ino %x, result %x)\n",ino,result);
|
|
||||||
|
|
||||||
buffer = ExAllocatePool(NonPagedPool,1024);
|
|
||||||
inodes = (struct minix_inode *)buffer;
|
|
||||||
|
|
||||||
block = 2 + DeviceExt->sb->s_imap_blocks + DeviceExt->sb->s_zmap_blocks
|
|
||||||
+ ((ino-1) / MINIX_INODES_PER_BLOCK);
|
|
||||||
DPRINT("Reading block %x offset %x\n",block,block*BLOCKSIZE);
|
|
||||||
DPRINT("Index %x\n",(ino-1)%MINIX_INODES_PER_BLOCK);
|
|
||||||
MinixReadSector(DeviceObject,block,buffer);
|
|
||||||
memcpy(result,&inodes[(ino-1)%MINIX_INODES_PER_BLOCK],
|
|
||||||
sizeof(struct minix_inode));
|
|
||||||
DPRINT("result->i_uid %x\n",result->i_uid);
|
|
||||||
DPRINT("result->i_size %x\n",result->i_size);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN MinixCompareUnicodeStringToAnsi(PCH AnsiStr, PWCHAR UnicodeStr,
|
|
||||||
ULONG MaxLen)
|
|
||||||
{
|
|
||||||
unsigned int i = 0;
|
|
||||||
|
|
||||||
while (i<MaxLen)
|
|
||||||
{
|
|
||||||
if ((*AnsiStr)!=(*UnicodeStr))
|
|
||||||
{
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
if ((*AnsiStr)==0 && (*UnicodeStr)==0)
|
|
||||||
{
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
AnsiStr++;
|
|
||||||
UnicodeStr++;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG MinixDirLookup(PDEVICE_OBJECT DeviceObject,
|
|
||||||
struct minix_inode* dir,
|
|
||||||
PWCHAR Name)
|
|
||||||
{
|
|
||||||
char* buffer;
|
|
||||||
struct minix_dir_entry* entry;
|
|
||||||
unsigned int offset;
|
|
||||||
unsigned int i;
|
|
||||||
unsigned int inode;
|
|
||||||
|
|
||||||
buffer=ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
|
||||||
|
|
||||||
for (i=0;i<(dir->i_size/MINIX_DIR_ENTRY_SIZE);i++)
|
|
||||||
{
|
|
||||||
offset = i*MINIX_DIR_ENTRY_SIZE;
|
|
||||||
if ((offset%BLOCKSIZE)==0)
|
|
||||||
{
|
|
||||||
MinixReadBlock(DeviceObject,
|
|
||||||
dir,
|
|
||||||
offset/BLOCKSIZE,
|
|
||||||
buffer);
|
|
||||||
}
|
|
||||||
entry = (struct minix_dir_entry *)&buffer[offset%BLOCKSIZE];
|
|
||||||
DPRINT("Inode %x Name %.30s\n",entry->inode,entry->name);
|
|
||||||
if (MinixCompareUnicodeStringToAnsi(entry->name,Name,30))
|
|
||||||
{
|
|
||||||
inode = entry->inode;
|
|
||||||
ExFreePool(buffer);
|
|
||||||
DPRINT("MinixDirLookup() = %d\n",inode);
|
|
||||||
return(inode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ExFreePool(buffer);
|
|
||||||
DPRINT("MinixDirLookup() = %d\n",0);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
PWSTR DeviceName,
|
|
||||||
struct minix_inode* result)
|
|
||||||
{
|
|
||||||
PWSTR current;
|
|
||||||
PWSTR next;
|
|
||||||
PWSTR string = DeviceName;
|
|
||||||
struct minix_inode current_dir;
|
|
||||||
unsigned int current_ino;
|
|
||||||
|
|
||||||
DbgPrint("MinixOpen(DeviceObject %x, DeviceName %S, result %x)\n",
|
|
||||||
DeviceObject,DeviceName,result);
|
|
||||||
DPRINT("DeviceName %x\n",DeviceName);
|
|
||||||
|
|
||||||
next = &string[0];
|
|
||||||
current = next+1;
|
|
||||||
|
|
||||||
current_ino = MINIX_ROOT_INO;
|
|
||||||
|
|
||||||
while (next!=NULL && current_ino!=0)
|
|
||||||
{
|
|
||||||
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
|
||||||
|
|
||||||
DPRINT("current %S next %x\n",current,next);
|
|
||||||
|
|
||||||
*next = '\\';
|
|
||||||
current = next+1;
|
|
||||||
next = wcschr(next+1,'\\');
|
|
||||||
if (next!=NULL)
|
|
||||||
{
|
|
||||||
*next=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
current_ino = MinixDirLookup(DeviceObject,¤t_dir,current);
|
|
||||||
}
|
|
||||||
if (next==NULL && current_ino!=0)
|
|
||||||
{
|
|
||||||
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
|
||||||
}
|
|
||||||
memcpy(result,¤t_dir,sizeof(struct minix_inode));
|
|
||||||
DPRINT("MinxOpen() = STATUS_SUCCESS\n",0);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
DPRINT("MinixWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
ULONG Length;
|
|
||||||
PVOID Buffer;
|
|
||||||
ULONG Offset;
|
|
||||||
ULONG CurrentOffset;
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt = DeviceObject->DeviceExtension;
|
|
||||||
struct minix_inode* inode = (struct minix_inode *)FileObject->FsContext;
|
|
||||||
PVOID TempBuffer;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
DPRINT("MinixRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
|
||||||
|
|
||||||
Length = Stack->Parameters.Read.Length;
|
|
||||||
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
|
||||||
Offset = Stack->Parameters.Read.ByteOffset.LowPart;
|
|
||||||
|
|
||||||
TempBuffer = ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
|
||||||
|
|
||||||
DPRINT("Length %x Buffer %x Offset %x\n",Length,Buffer,Offset);
|
|
||||||
|
|
||||||
CurrentOffset=Offset;
|
|
||||||
|
|
||||||
if ((Offset%BLOCKSIZE)!=0)
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
CurrentOffset = Offset - (Offset%BLOCKSIZE);
|
|
||||||
|
|
||||||
MinixReadBlock(DeviceExt->AttachedDevice,inode,
|
|
||||||
CurrentOffset/BLOCKSIZE,
|
|
||||||
TempBuffer);
|
|
||||||
memcpy(Buffer,TempBuffer+(Offset%BLOCKSIZE),
|
|
||||||
min(BLOCKSIZE - (Offset%BLOCKSIZE),Length));
|
|
||||||
DPRINT("(BLOCKSIZE - (Offset%BLOCKSIZE)) %d\n",
|
|
||||||
(BLOCKSIZE - (Offset%BLOCKSIZE)));
|
|
||||||
DPRINT("Length %d\n",Length);
|
|
||||||
CurrentOffset = CurrentOffset + BLOCKSIZE;
|
|
||||||
Buffer = Buffer + BLOCKSIZE - (Offset%BLOCKSIZE);
|
|
||||||
Length = Length - min(BLOCKSIZE - (Offset%BLOCKSIZE),Length);
|
|
||||||
DPRINT("CurrentOffset %d Buffer %x Length %d\n",CurrentOffset,Buffer,
|
|
||||||
Length);
|
|
||||||
}
|
|
||||||
for (i=0;i<(Length/BLOCKSIZE);i++)
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
MinixReadBlock(DeviceExt->AttachedDevice,inode,
|
|
||||||
CurrentOffset/BLOCKSIZE,Buffer);
|
|
||||||
CurrentOffset = CurrentOffset + BLOCKSIZE;
|
|
||||||
Buffer = Buffer + BLOCKSIZE;
|
|
||||||
Length = Length - BLOCKSIZE;
|
|
||||||
}
|
|
||||||
if (Length > 0)
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
MinixReadBlock(DeviceExt->AttachedDevice,inode,
|
|
||||||
CurrentOffset/BLOCKSIZE,
|
|
||||||
TempBuffer);
|
|
||||||
memcpy(Buffer,TempBuffer,Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
|
||||||
Irp->IoStatus.Information = Length;
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
|
||||||
|
|
||||||
DPRINT("MinixClose(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
|
||||||
|
|
||||||
ExFreePool(FileObject->FsContext);
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
|
||||||
NTSTATUS Status;
|
|
||||||
struct minix_inode* result;
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt;
|
|
||||||
|
|
||||||
DPRINT("MinixCreate(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
|
||||||
DPRINT("Opening file %x %S\n",FileObject->FileName.Buffer,
|
|
||||||
FileObject->FileName.Buffer);
|
|
||||||
DPRINT("FileObject->FileName.Buffer %x\n",
|
|
||||||
FileObject->FileName.Buffer);
|
|
||||||
|
|
||||||
DeviceExt = (MINIX_DEVICE_EXTENSION *)DeviceObject->DeviceExtension;
|
|
||||||
result = ExAllocatePool(NonPagedPool,sizeof(struct minix_inode));
|
|
||||||
DPRINT("result %x\n",result);
|
|
||||||
Status = MinixOpen(DeviceExt->AttachedDevice,DeviceExt,
|
|
||||||
FileObject->FileName.Buffer,result);
|
|
||||||
|
|
||||||
if (Status==STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
FileObject->FsContext=result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
|
|
||||||
PUNICODE_STRING RegistryPath)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Called by the system to initalize the driver
|
|
||||||
* ARGUMENTS:
|
|
||||||
* DriverObject = object describing this driver
|
|
||||||
* RegistryPath = path to our configuration entries
|
|
||||||
* RETURNS: Success or failure
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT DeviceObject;
|
|
||||||
NTSTATUS Status;
|
|
||||||
UNICODE_STRING DeviceName;
|
|
||||||
|
|
||||||
DbgPrint("Minix FSD 0.0.1\n");
|
|
||||||
|
|
||||||
DriverObject = _DriverObject;
|
|
||||||
|
|
||||||
RtlInitUnicodeString(&DeviceName, "\\Device\\Minix");
|
|
||||||
Status = IoCreateDevice(DriverObject,
|
|
||||||
0,
|
|
||||||
&DeviceName,
|
|
||||||
FILE_DEVICE_FILE_SYSTEM,
|
|
||||||
0,
|
|
||||||
FALSE,
|
|
||||||
&DeviceObject);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceObject->Flags = DO_DIRECT_IO;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MinixClose;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = MinixCreate;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = MinixRead;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = MinixWrite;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
|
|
||||||
MinixFileSystemControl;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
|
|
||||||
MinixDirectoryControl;
|
|
||||||
DriverObject->DriverUnload = NULL;
|
|
||||||
|
|
||||||
IoRegisterFileSystem(DeviceObject);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,22 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: services/fs/minix/minix.c
|
* FILE: services/fs/minix/minix.c
|
||||||
* PURPOSE: Minix FSD
|
* PURPOSE: Minix FSD
|
||||||
|
@ -105,14 +122,19 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT _DriverObject,
|
||||||
DriverObject = _DriverObject;
|
DriverObject = _DriverObject;
|
||||||
|
|
||||||
RtlInitUnicodeString(&ustr, L"\\Device\\Minix");
|
RtlInitUnicodeString(&ustr, L"\\Device\\Minix");
|
||||||
ret = IoCreateDevice(DriverObject,0,&ustr,
|
ret = IoCreateDevice(DriverObject,
|
||||||
FILE_DEVICE_PARALLEL_PORT,0,FALSE,&DeviceObject);
|
0,
|
||||||
if (ret!=STATUS_SUCCESS)
|
&ustr,
|
||||||
|
FILE_DEVICE_FILE_SYSTEM,
|
||||||
|
0,
|
||||||
|
FALSE,
|
||||||
|
&DeviceObject);
|
||||||
|
if (!NT_SUCCESS(ret))
|
||||||
{
|
{
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceObject->Flags=0;
|
DeviceObject->Flags = 0;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MinixClose;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MinixClose;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = MinixCreate;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = MinixCreate;
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = MinixRead;
|
DriverObject->MajorFunction[IRP_MJ_READ] = MinixRead;
|
||||||
|
|
|
@ -5,54 +5,51 @@
|
||||||
#ifndef __INCLUDE_DDK_I386_TSS_H
|
#ifndef __INCLUDE_DDK_I386_TSS_H
|
||||||
#define __INCLUDE_DDK_I386_TSS_H
|
#define __INCLUDE_DDK_I386_TSS_H
|
||||||
|
|
||||||
typedef struct
|
#define KTSS_ESP0 (0x4)
|
||||||
|
|
||||||
|
#ifndef __ASM__
|
||||||
|
|
||||||
|
typedef struct _KTSS
|
||||||
{
|
{
|
||||||
unsigned short previous_task;
|
USHORT PreviousTask;
|
||||||
unsigned short reserved1;
|
USHORT Reserved1;
|
||||||
unsigned long esp0;
|
ULONG Esp0;
|
||||||
unsigned short ss0;
|
USHORT Ss0;
|
||||||
unsigned short reserved2;
|
USHORT Reserved2;
|
||||||
unsigned long esp1;
|
ULONG Esp1;
|
||||||
unsigned short ss1;
|
USHORT Ss1;
|
||||||
unsigned short reserved3;
|
USHORT Reserved3;
|
||||||
unsigned long esp2;
|
ULONG Esp2;
|
||||||
unsigned short ss2;
|
USHORT Ss2;
|
||||||
unsigned short reserved4;
|
USHORT Reserved4;
|
||||||
unsigned long cr3;
|
ULONG Cr3;
|
||||||
unsigned long eip;
|
ULONG Eip;
|
||||||
unsigned long eflags;
|
ULONG Eflags;
|
||||||
unsigned long eax;
|
ULONG Eax;
|
||||||
unsigned long ecx;
|
ULONG Ecx;
|
||||||
unsigned long edx;
|
ULONG Edx;
|
||||||
unsigned long ebx;
|
ULONG Ebx;
|
||||||
unsigned long esp;
|
ULONG Esp;
|
||||||
unsigned long ebp;
|
ULONG Ebp;
|
||||||
unsigned long esi;
|
ULONG Esi;
|
||||||
unsigned long edi;
|
ULONG Edi;
|
||||||
unsigned short es;
|
USHORT Es;
|
||||||
unsigned short reserved5;
|
USHORT Reserved5;
|
||||||
unsigned short cs;
|
USHORT Cs;
|
||||||
unsigned short reserved6;
|
USHORT Reserved6;
|
||||||
unsigned short ss;
|
USHORT Ss;
|
||||||
unsigned short reserved7;
|
USHORT Reserved7;
|
||||||
unsigned short ds;
|
USHORT Fs;
|
||||||
unsigned short reserved8;
|
USHORT Reserved8;
|
||||||
unsigned short fs;
|
USHORT Gs;
|
||||||
unsigned short reserved9;
|
USHORT Reserved9;
|
||||||
unsigned short gs;
|
USHORT Ldt;
|
||||||
unsigned short reserved10;
|
USHORT Reserved10;
|
||||||
unsigned short ldt;
|
USHORT Trap;
|
||||||
unsigned short reserved11;
|
USHORT IoMapBase;
|
||||||
unsigned short trap;
|
UCHAR IoBitmap[1];
|
||||||
unsigned short iomap_base;
|
} KTSS;
|
||||||
|
|
||||||
unsigned short nr;
|
|
||||||
PVOID KernelStackBase;
|
|
||||||
PVOID SavedKernelEsp;
|
|
||||||
PVOID SavedKernelStackBase;
|
|
||||||
|
|
||||||
unsigned char io_bitmap[1];
|
|
||||||
} hal_thread_state;
|
|
||||||
|
|
||||||
|
#endif /* not __ASM__ */
|
||||||
|
|
||||||
#endif /* __INCLUDE_DDK_I386_TSS_H */
|
#endif /* __INCLUDE_DDK_I386_TSS_H */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef _INCLUDE_DDK_IOFUNCS_H
|
#ifndef _INCLUDE_DDK_IOFUNCS_H
|
||||||
#define _INCLUDE_DDK_IOFUNCS_H
|
#define _INCLUDE_DDK_IOFUNCS_H
|
||||||
/* $Id: iofuncs.h,v 1.21 2000/12/11 18:20:02 ekohl Exp $ */
|
/* $Id: iofuncs.h,v 1.22 2000/12/23 02:37:36 dwelch Exp $ */
|
||||||
|
|
||||||
/* --- EXPORTED BY NTOSKRNL --- */
|
/* --- EXPORTED BY NTOSKRNL --- */
|
||||||
|
|
||||||
|
@ -917,12 +917,9 @@ IoReportResourceUsage (
|
||||||
param->Control |= SL_INVOKE_ON_CANCEL; \
|
param->Control |= SL_INVOKE_ON_CANCEL; \
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
IoSetDeviceToVerify (IN struct _ETHREAD* Thread,
|
||||||
IoSetDeviceToVerify (
|
IN PDEVICE_OBJECT DeviceObject);
|
||||||
IN struct _ETHREAD* Thread,
|
|
||||||
IN PDEVICE_OBJECT DeviceObject
|
|
||||||
);
|
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
IoSetHardErrorOrVerifyDevice (
|
IoSetHardErrorOrVerifyDevice (
|
||||||
|
|
|
@ -132,7 +132,7 @@ typedef struct _DISPATCHER_HEADER
|
||||||
UCHAR Inserted;
|
UCHAR Inserted;
|
||||||
LONG SignalState;
|
LONG SignalState;
|
||||||
LIST_ENTRY WaitListHead;
|
LIST_ENTRY WaitListHead;
|
||||||
} DISPATCHER_HEADER;
|
} __attribute__((packed)) DISPATCHER_HEADER;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _KQUEUE
|
typedef struct _KQUEUE
|
||||||
|
@ -155,19 +155,6 @@ typedef struct _KTIMER
|
||||||
LONG Period;
|
LONG Period;
|
||||||
} KTIMER, *PKTIMER;
|
} KTIMER, *PKTIMER;
|
||||||
|
|
||||||
/*
|
|
||||||
typedef struct _KTIMER
|
|
||||||
{
|
|
||||||
LIST_ENTRY entry;
|
|
||||||
signed long long expire_time;
|
|
||||||
struct _KDPC* dpc;
|
|
||||||
BOOLEAN signaled;
|
|
||||||
BOOLEAN running;
|
|
||||||
TIMER_TYPE type;
|
|
||||||
ULONG period;
|
|
||||||
} KTIMER, *PKTIMER;
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct _KSPIN_LOCK;
|
struct _KSPIN_LOCK;
|
||||||
|
|
||||||
typedef struct _KSPIN_LOCK
|
typedef struct _KSPIN_LOCK
|
||||||
|
@ -225,7 +212,7 @@ typedef struct _KSEMAPHORE
|
||||||
{
|
{
|
||||||
DISPATCHER_HEADER Header;
|
DISPATCHER_HEADER Header;
|
||||||
LONG Limit;
|
LONG Limit;
|
||||||
} KSEMAPHORE, *PKSEMAPHORE;
|
} __attribute__((packed)) KSEMAPHORE, *PKSEMAPHORE;
|
||||||
|
|
||||||
typedef struct _KEVENT
|
typedef struct _KEVENT
|
||||||
{
|
{
|
||||||
|
@ -270,7 +257,7 @@ typedef struct _KDPC
|
||||||
PVOID SystemArgument1;
|
PVOID SystemArgument1;
|
||||||
PVOID SystemArgument2;
|
PVOID SystemArgument2;
|
||||||
PULONG Lock;
|
PULONG Lock;
|
||||||
} KDPC, *PKDPC;
|
} __attribute__((packed)) KDPC, *PKDPC;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
/* $Id: zw.h,v 1.38 2000/10/11 13:20:33 jean Exp $
|
/* $Id: zw.h,v 1.39 2000/12/23 02:37:36 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -5248,11 +5248,12 @@ NtVdmControl (
|
||||||
|
|
||||||
/* --- WIN32 --- */
|
/* --- WIN32 --- */
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
NtW32Call(IN ULONG RoutineIndex,
|
||||||
NtW32Call (
|
IN PVOID Argument,
|
||||||
VOID
|
IN ULONG ArgumentLength,
|
||||||
);
|
OUT PVOID* Result OPTIONAL,
|
||||||
|
OUT PULONG ResultLength OPTIONAL);
|
||||||
|
|
||||||
/* --- CHANNELS --- */
|
/* --- CHANNELS --- */
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ cp apps/cat/cat.exe $1/reactos/bin
|
||||||
cp subsys/smss/smss.exe $1/reactos/system32
|
cp subsys/smss/smss.exe $1/reactos/system32
|
||||||
cp subsys/csrss/csrss.exe $1/reactos/system32
|
cp subsys/csrss/csrss.exe $1/reactos/system32
|
||||||
cp subsys/win32k/win32k.sys $1/reactos/system32/drivers
|
cp subsys/win32k/win32k.sys $1/reactos/system32/drivers
|
||||||
|
#cp apps/system/winlogon/winlogon.exe $1/reactos/system32/
|
||||||
cp apps/apc/apc.exe $1/reactos/bin
|
cp apps/apc/apc.exe $1/reactos/bin
|
||||||
cp apps/shm/shmsrv.exe $1/reactos/bin
|
cp apps/shm/shmsrv.exe $1/reactos/bin
|
||||||
cp apps/shm/shmclt.exe $1/reactos/bin
|
cp apps/shm/shmclt.exe $1/reactos/bin
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntdll.def,v 1.65 2000/10/11 20:50:32 dwelch Exp $
|
; $Id: ntdll.def,v 1.66 2000/12/23 02:37:37 dwelch Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
|
@ -28,9 +28,9 @@ DbgUiConnectToDbg@0
|
||||||
DbgUiContinue@8
|
DbgUiContinue@8
|
||||||
DbgUiWaitStateChange@8
|
DbgUiWaitStateChange@8
|
||||||
DbgUserBreakPoint@0
|
DbgUserBreakPoint@0
|
||||||
;KiRaiseUserExceptionDispatcher
|
KiRaiseUserExceptionDispatcher
|
||||||
KiUserApcDispatcher
|
KiUserApcDispatcher
|
||||||
;KiUserCallbackDispatcher
|
KiUserCallbackDispatcher
|
||||||
;KiUserExceptionDispatcher
|
;KiUserExceptionDispatcher
|
||||||
LdrAccessResource@16
|
LdrAccessResource@16
|
||||||
LdrDisableThreadCalloutsForDll@4
|
LdrDisableThreadCalloutsForDll@4
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntdll.edf,v 1.54 2000/10/11 20:50:32 dwelch Exp $
|
; $Id: ntdll.edf,v 1.55 2000/12/23 02:37:37 dwelch Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
|
@ -30,8 +30,8 @@ DbgUiWaitStateChange=DbgUiWaitStateChange@8
|
||||||
DbgUserBreakPoint=DbgUserBreakPoint@0
|
DbgUserBreakPoint=DbgUserBreakPoint@0
|
||||||
;KiRaiseUserExceptionDispatcher
|
;KiRaiseUserExceptionDispatcher
|
||||||
KiUserApcDispatcher=KiUserApcDispatcher@20
|
KiUserApcDispatcher=KiUserApcDispatcher@20
|
||||||
;KiUserCallbackDispatcher
|
KiUserCallbackDispatcher=KiUserCallbackDispatcher@12
|
||||||
;KiUserExceptionDispatcher
|
KiUserExceptionDispatcher=KiUserExceptionDispatcher@8
|
||||||
LdrAccessResource=LdrAccessResource@16
|
LdrAccessResource=LdrAccessResource@16
|
||||||
LdrDisableThreadCalloutsForDll=LdrDisableThreadCalloutsForDll@4
|
LdrDisableThreadCalloutsForDll=LdrDisableThreadCalloutsForDll@4
|
||||||
;LdrEnumResources
|
;LdrEnumResources
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.55 2000/11/20 19:59:09 ekohl Exp $
|
# $Id: makefile,v 1.56 2000/12/23 02:37:37 dwelch Exp $
|
||||||
#
|
#
|
||||||
# ReactOS Operating System
|
# ReactOS Operating System
|
||||||
#
|
#
|
||||||
|
@ -24,7 +24,7 @@ RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
|
||||||
rtl/thread.o rtl/unicode.o rtl/env.o rtl/path.o rtl/ppb.o \
|
rtl/thread.o rtl/unicode.o rtl/env.o rtl/path.o rtl/ppb.o \
|
||||||
rtl/bitmap.o rtl/time.o rtl/acl.o rtl/sid.o rtl/image.o \
|
rtl/bitmap.o rtl/time.o rtl/acl.o rtl/sid.o rtl/image.o \
|
||||||
rtl/access.o rtl/apc.o rtl/callback.o rtl/luid.o rtl/misc.o \
|
rtl/access.o rtl/apc.o rtl/callback.o rtl/luid.o rtl/misc.o \
|
||||||
rtl/registry.o
|
rtl/registry.o rtl/exception.o
|
||||||
|
|
||||||
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o
|
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,23 @@
|
||||||
/* $Id: apc.c,v 1.4 2000/10/11 20:50:32 dwelch Exp $
|
/*
|
||||||
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/* $Id: apc.c,v 1.5 2000/12/23 02:37:38 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: User-mode APC support
|
* PURPOSE: User-mode APC support
|
||||||
* FILE: lib/ntdll/rtl/apc.c
|
* FILE: lib/ntdll/rtl/apc.c
|
||||||
|
@ -14,20 +31,22 @@
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
VOID STDCALL KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine,
|
VOID STDCALL
|
||||||
PVOID ApcContext,
|
KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine,
|
||||||
PIO_STATUS_BLOCK Iosb,
|
PVOID ApcContext,
|
||||||
ULONG Reserved,
|
PIO_STATUS_BLOCK Iosb,
|
||||||
PCONTEXT Context)
|
ULONG Reserved,
|
||||||
|
PCONTEXT Context)
|
||||||
{
|
{
|
||||||
DbgPrint("KiUserApcDispatcher(ApcRoutine %x, ApcContext %x, Context %x)\n",
|
/*
|
||||||
ApcRoutine, ApcContext, Context);
|
* Call the APC
|
||||||
|
*/
|
||||||
ApcRoutine(ApcContext,
|
ApcRoutine(ApcContext,
|
||||||
Iosb,
|
Iosb,
|
||||||
Reserved);
|
Reserved);
|
||||||
DbgPrint("Done ApcRoutine, Context %x, Context->Eip %x\n",
|
/*
|
||||||
Context, Context->Eip);
|
* Switch back to the interrupted context
|
||||||
|
*/
|
||||||
NtContinue(Context, 1);
|
NtContinue(Context, 1);
|
||||||
DbgPrint("Returned from NtContinue, aargh\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: callback.c,v 1.2 2000/06/29 23:35:29 dwelch Exp $
|
/* $Id: callback.c,v 1.3 2000/12/23 02:37:38 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -20,9 +20,10 @@ typedef NTSTATUS (*CALLBACK_FUNCTION)(PVOID Argument, ULONG ArgumentLength);
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID KiUserCallbackDispatcher(ULONG RoutineIndex,
|
VOID STDCALL
|
||||||
PVOID Argument,
|
KiUserCallbackDispatcher(ULONG RoutineIndex,
|
||||||
ULONG ArgumentLength)
|
PVOID Argument,
|
||||||
|
ULONG ArgumentLength)
|
||||||
{
|
{
|
||||||
PPEB Peb;
|
PPEB Peb;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: exception.c,v 1.1 2000/05/13 13:50:57 dwelch Exp $
|
/* $Id: exception.c,v 1.2 2000/12/23 02:37:38 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -12,12 +12,11 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
VOID KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
|
VOID STDCALL
|
||||||
PCONTEXT Context)
|
KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
|
PCONTEXT Context)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ STUB(CsrProbeForWrite)
|
||||||
STUB(CsrSetPriorityClass)
|
STUB(CsrSetPriorityClass)
|
||||||
|
|
||||||
STUB(KiRaiseUserExceptionDispatcher)
|
STUB(KiRaiseUserExceptionDispatcher)
|
||||||
STUB(KiUserExceptionDispatcher)
|
|
||||||
|
|
||||||
STUB(LdrEnumResources)
|
STUB(LdrEnumResources)
|
||||||
STUB(LdrFindEntryForAddress)
|
STUB(LdrFindEntryForAddress)
|
||||||
|
|
|
@ -343,11 +343,11 @@ entry:
|
||||||
mov cx, 0600h
|
mov cx, 0600h
|
||||||
int 10h
|
int 10h
|
||||||
|
|
||||||
mov ah, 6 ; SCROLL ACTIVE PAGE UP
|
mov ah, 6 ; Scroll active page up
|
||||||
mov al, 32h ; CLEAR 50 LINES
|
mov al, 32h ; Clear 50 lines
|
||||||
mov cx, 0 ; UPPER LEFT OF SCROLL
|
mov cx, 0 ; Upper left of scroll
|
||||||
mov dx, 314fh ; LOWER RIGHT OF SCROLL
|
mov dx, 314fh ; Lower right of scroll
|
||||||
mov bh, 1*10h+1 ; USE NORMAL ATTRIBUTE ON BLANKED LINE
|
mov bh, 1*10h+1 ; Use normal attribute on blanked lines
|
||||||
int 10h
|
int 10h
|
||||||
|
|
||||||
mov dx, 0
|
mov dx, 0
|
||||||
|
@ -581,77 +581,9 @@ e_res2: resw 10
|
||||||
e_lfanew: resd 1
|
e_lfanew: resd 1
|
||||||
ENDSTRUC
|
ENDSTRUC
|
||||||
|
|
||||||
STRUC pe_filehdr
|
|
||||||
nth_sig: resd 1
|
|
||||||
ntf_mach: resw 1
|
|
||||||
ntf_num_secs: resw 1
|
|
||||||
ntf_timestamp: resd 1
|
|
||||||
ntf_symtab_ptr: resd 1
|
|
||||||
ntf_num_syms: resd 1
|
|
||||||
ntf_opt_hdr_sz: resw 1
|
|
||||||
ntf_chars: resw 1
|
|
||||||
|
|
||||||
nto_magic: resw 1
|
|
||||||
nto_mjr_lnk_vr: resb 1
|
|
||||||
nto_mnr_lnk_vr: resb 1
|
|
||||||
nto_code_sz: resd 1
|
|
||||||
nto_data_sz: resd 1
|
|
||||||
nto_bss_sz: resd 1
|
|
||||||
nto_entry_offs: resd 1
|
|
||||||
nto_code_offs: resd 1
|
|
||||||
nto_data_offs: resd 1
|
|
||||||
nto_image_base: resd 1
|
|
||||||
nto_sec_align: resd 1
|
|
||||||
nto_file_align: resd 1
|
|
||||||
nto_mjr_os_ver: resw 1
|
|
||||||
nto_Mnr_os_ver: resw 1
|
|
||||||
nto_mjr_img_vr: resw 1
|
|
||||||
nto_Mnr_img_vr: resw 1
|
|
||||||
nto_mjr_subsys: resw 1
|
|
||||||
nto_mnr_subsys: resw 1
|
|
||||||
nto_w32_ver: resd 1
|
|
||||||
nto_image_sz: resd 1
|
|
||||||
nto_hdr_sz: resd 1
|
|
||||||
nto_chksum: resd 1
|
|
||||||
nto_subsys: resw 1
|
|
||||||
nto_dll_chars: resw 1
|
|
||||||
nto_stk_res_sz: resd 1
|
|
||||||
nto_stk_cmt_sz: resd 1
|
|
||||||
nto_hp_res_sz: resd 1
|
|
||||||
nto_hp_cmt_sz: resd 1
|
|
||||||
nto_ldr_flags: resd 1
|
|
||||||
nto_dir_cnt: resd 1
|
|
||||||
nto_dir_ent: resq 16
|
|
||||||
ENDSTRUC
|
|
||||||
|
|
||||||
STRUC DATA_DIR
|
|
||||||
dd_rva: resd 1
|
|
||||||
dd_sz: resd 1
|
|
||||||
ENDSTRUC
|
|
||||||
|
|
||||||
STRUC pe_scnhdr
|
|
||||||
se_name: resb 8
|
|
||||||
se_vsz: resd 1
|
|
||||||
se_vaddr: resd 1
|
|
||||||
se_rawsz: resd 1
|
|
||||||
se_raw_ofs: resd 1
|
|
||||||
se_reloc_ofs: resd 1
|
|
||||||
se_lnum_ofs: resd 1
|
|
||||||
se_num_relocs: resw 1
|
|
||||||
se_num_lnums: resw 1
|
|
||||||
se_chars: resd 1
|
|
||||||
ENDSTRUC
|
|
||||||
|
|
||||||
_cpe_doshdr:
|
_cpe_doshdr:
|
||||||
times pe_doshdr_size db 0
|
times pe_doshdr_size db 0
|
||||||
_cpe_filehdr
|
|
||||||
times pe_filehdr_size db 0
|
|
||||||
_cpe_scnhdr:
|
|
||||||
times pe_scnhdr_size db 0
|
|
||||||
_cscn:
|
|
||||||
dw 0
|
|
||||||
_cscn_offset:
|
|
||||||
dd 0
|
|
||||||
_current_filehandle:
|
_current_filehandle:
|
||||||
dw 0
|
dw 0
|
||||||
_current_size:
|
_current_size:
|
||||||
|
@ -783,7 +715,7 @@ pe_load_module:
|
||||||
|
|
||||||
.read_tail
|
.read_tail
|
||||||
;;
|
;;
|
||||||
;; Read in the tailing part of the section data
|
;; Read in the tailing part of the file data
|
||||||
;;
|
;;
|
||||||
push ds
|
push ds
|
||||||
mov eax, [_current_size]
|
mov eax, [_current_size]
|
||||||
|
@ -794,11 +726,11 @@ pe_load_module:
|
||||||
mov ds, dx
|
mov ds, dx
|
||||||
mov dx, 0
|
mov dx, 0
|
||||||
int 0x21
|
int 0x21
|
||||||
jnc .section_read_last_data_succeeded
|
jnc .read_last_data_succeeded
|
||||||
pop ds
|
pop ds
|
||||||
mov dx, error_file_read_failed
|
mov dx, error_file_read_failed
|
||||||
jmp .error
|
jmp .error
|
||||||
.section_read_last_data_succeeded:
|
.read_last_data_succeeded:
|
||||||
mov ah,02h
|
mov ah,02h
|
||||||
mov dl,'#'
|
mov dl,'#'
|
||||||
int 021h
|
int 021h
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: Makefile,v 1.4 2000/12/10 23:41:59 dwelch Exp $
|
# $Id: Makefile,v 1.5 2000/12/23 02:37:38 dwelch Exp $
|
||||||
#
|
#
|
||||||
# ReactOS Operating System
|
# ReactOS Operating System
|
||||||
#
|
#
|
||||||
|
@ -94,7 +94,10 @@ OBJECTS_KE_I386 = \
|
||||||
ke/i386/usercall.o \
|
ke/i386/usercall.o \
|
||||||
ke/i386/trap.o \
|
ke/i386/trap.o \
|
||||||
ke/i386/bthread.o \
|
ke/i386/bthread.o \
|
||||||
ke/i386/syscall.o
|
ke/i386/syscall.o \
|
||||||
|
ke/i386/tskswitch.o \
|
||||||
|
ke/i386/v86m.o \
|
||||||
|
ke/i386/v86m_sup.o
|
||||||
|
|
||||||
# Memory Manager (Mm)
|
# Memory Manager (Mm)
|
||||||
OBJECTS_MM = \
|
OBJECTS_MM = \
|
||||||
|
|
|
@ -1,9 +1,26 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/cc/cacheman.c
|
* FILE: ntoskrnl/cc/cacheman.c
|
||||||
* PURPOSE: Cache manager
|
* PURPOSE: Cache manager
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: view.c,v 1.11 2000/12/10 23:42:00 dwelch Exp $
|
/* $Id: view.c,v 1.12 2000/12/23 02:37:38 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -72,7 +72,7 @@ CcFlushCachePage(PCACHE_SEGMENT CacheSeg)
|
||||||
KernelMode,
|
KernelMode,
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
/* Build an IRP_MJ_WRITE and send it to the filesystem */
|
/* FIXME: Build an IRP_MJ_WRITE and send it to the filesystem */
|
||||||
KeSetEvent(&CacheSeg->Lock, IO_NO_INCREMENT, 0);
|
KeSetEvent(&CacheSeg->Lock, IO_NO_INCREMENT, 0);
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
@ -256,12 +256,9 @@ CcInitializeFileCache(PFILE_OBJECT FileObject,
|
||||||
* NOTE
|
* NOTE
|
||||||
* Used by CcMdlReadComplete@8 and FsRtl
|
* Used by CcMdlReadComplete@8 and FsRtl
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
CcMdlReadCompleteDev (IN PMDL MdlChain,
|
||||||
CcMdlReadCompleteDev (
|
IN PDEVICE_OBJECT DeviceObject)
|
||||||
IN PMDL MdlChain,
|
|
||||||
IN PDEVICE_OBJECT DeviceObject
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
@ -281,21 +278,16 @@ CcMdlReadCompleteDev (
|
||||||
* NOTE
|
* NOTE
|
||||||
* From Bo Branten's ntifs.h v13.
|
* From Bo Branten's ntifs.h v13.
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
CcMdlReadComplete (IN PFILE_OBJECT FileObject,
|
||||||
CcMdlReadComplete (
|
IN PMDL MdlChain)
|
||||||
IN PFILE_OBJECT FileObject,
|
|
||||||
IN PMDL MdlChain
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject = NULL;
|
PDEVICE_OBJECT DeviceObject = NULL;
|
||||||
|
|
||||||
DeviceObject = IoGetRelatedDeviceObject (FileObject);
|
DeviceObject = IoGetRelatedDeviceObject (FileObject);
|
||||||
/* FIXME: try fast I/O first */
|
/* FIXME: try fast I/O first */
|
||||||
CcMdlReadCompleteDev (
|
CcMdlReadCompleteDev (MdlChain,
|
||||||
MdlChain,
|
DeviceObject);
|
||||||
DeviceObject
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/dbg/brkpoints.c
|
* FILE: ntoskrnl/dbg/brkpoints.c
|
||||||
* PURPOSE: Handles breakpoints
|
* PURPOSE: Handles breakpoints
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER:
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
@ -16,17 +16,20 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL NtSystemDebugControl(VOID)
|
NTSTATUS STDCALL
|
||||||
|
NtSystemDebugControl(VOID)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID STDCALL DbgBreakPoint(VOID)
|
VOID STDCALL
|
||||||
|
DbgBreakPoint(VOID)
|
||||||
{
|
{
|
||||||
__asm__("int $3\n\t");
|
__asm__("int $3\n\t");
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID STDCALL DbgBreakPointWithStatus(ULONG Status)
|
VOID STDCALL
|
||||||
|
DbgBreakPointWithStatus(ULONG Status)
|
||||||
{
|
{
|
||||||
__asm__("mov %0, %%eax\n\t"
|
__asm__("mov %0, %%eax\n\t"
|
||||||
"int $3\n\t"
|
"int $3\n\t"
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/dbg/brkpoints.c
|
* FILE: ntoskrnl/dbg/errinfo.c
|
||||||
* PURPOSE: Handles breakpoints
|
* PURPOSE: Print information descriptions of error messages
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
static PCHAR SeverityCodes[] = {"SUC", "INF", "ERR", "WRN"};
|
static PCHAR SeverityCodes[] = {"SUC", "INF", "ERR", "WRN"};
|
||||||
|
|
||||||
|
@ -172,7 +173,10 @@ static struct _ERRLIST
|
||||||
{0, NULL, NULL}
|
{0, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
VOID DbgGetErrorText(NTSTATUS ErrorCode, PUNICODE_STRING ErrorText, ULONG Flags)
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID
|
||||||
|
DbgGetErrorText(NTSTATUS ErrorCode, PUNICODE_STRING ErrorText, ULONG Flags)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char TempBuf[255], NumBuf[32];
|
char TempBuf[255], NumBuf[32];
|
||||||
|
@ -247,7 +251,8 @@ VOID DbgGetErrorText(NTSTATUS ErrorCode, PUNICODE_STRING ErrorText, ULONG Flags)
|
||||||
RtlAnsiStringToUnicodeString(ErrorText, &AnsiString, TRUE);
|
RtlAnsiStringToUnicodeString(ErrorText, &AnsiString, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID DbgPrintErrorMessage(NTSTATUS ErrorCode)
|
VOID
|
||||||
|
DbgPrintErrorMessage(NTSTATUS ErrorCode)
|
||||||
{
|
{
|
||||||
UNICODE_STRING ErrorText;
|
UNICODE_STRING ErrorText;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: print.c,v 1.10 2000/10/22 16:36:49 ekohl Exp $
|
/* $Id: print.c,v 1.11 2000/12/23 02:37:38 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -34,7 +34,8 @@ __asm__ ("\n\t.global _DbgService\n\t"
|
||||||
* You'll only break the serial/bochs debugging feature!!!
|
* You'll only break the serial/bochs debugging feature!!!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ULONG DbgPrint(PCH Format, ...)
|
ULONG
|
||||||
|
DbgPrint(PCH Format, ...)
|
||||||
{
|
{
|
||||||
ANSI_STRING DebugString;
|
ANSI_STRING DebugString;
|
||||||
CHAR Buffer[512];
|
CHAR Buffer[512];
|
||||||
|
@ -54,28 +55,25 @@ ULONG DbgPrint(PCH Format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
DbgPrompt (PCH OutputString,
|
||||||
DbgPrompt (
|
PCH InputString,
|
||||||
PCH OutputString,
|
USHORT InputSize)
|
||||||
PCH InputString,
|
|
||||||
USHORT InputSize
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ANSI_STRING Output;
|
ANSI_STRING Output;
|
||||||
ANSI_STRING Input;
|
ANSI_STRING Input;
|
||||||
|
|
||||||
Input.Length = 0;
|
Input.Length = 0;
|
||||||
Input.MaximumLength = InputSize;
|
Input.MaximumLength = InputSize;
|
||||||
Input.Buffer = InputString;
|
Input.Buffer = InputString;
|
||||||
|
|
||||||
Output.Length = strlen (OutputString);
|
Output.Length = strlen (OutputString);
|
||||||
Output.MaximumLength = Output.Length + 1;
|
Output.MaximumLength = Output.Length + 1;
|
||||||
Output.Buffer = OutputString;
|
Output.Buffer = OutputString;
|
||||||
|
|
||||||
/* FIXME: Not implemented yet! */
|
/* FIXME: Not implemented yet! */
|
||||||
// KdpPromptString (&Output,
|
// KdpPromptString (&Output,
|
||||||
// &Input);
|
// &Input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: callback.c,v 1.4 2000/07/04 01:27:58 ekohl Exp $
|
/* $Id: callback.c,v 1.5 2000/12/23 02:37:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -66,40 +66,4 @@ ExUnregisterCallback (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME:
|
|
||||||
* The following functions don't belong here.
|
|
||||||
* Move them somewhere else.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
VOID ExCallUserCallBack(PVOID fn)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Transfer control to a user callback
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
NtCallbackReturn (
|
|
||||||
PVOID Result,
|
|
||||||
ULONG ResultLength,
|
|
||||||
NTSTATUS Status
|
|
||||||
)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
NtW32Call (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: fmutex.c,v 1.7 2000/07/06 14:34:49 dwelch Exp $
|
/* $Id: fmutex.c,v 1.8 2000/12/23 02:37:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -18,7 +18,8 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID FASTCALL EXPORTED ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
VOID FASTCALL EXPORTED
|
||||||
|
ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
||||||
{
|
{
|
||||||
if (InterlockedDecrement(&FastMutex->Count) == 0)
|
if (InterlockedDecrement(&FastMutex->Count) == 0)
|
||||||
{
|
{
|
||||||
|
@ -33,14 +34,15 @@ VOID FASTCALL EXPORTED ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
||||||
FastMutex->Owner = KeGetCurrentThread();
|
FastMutex->Owner = KeGetCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID FASTCALL EXPORTED ExReleaseFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
VOID FASTCALL EXPORTED
|
||||||
|
ExReleaseFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
||||||
{
|
{
|
||||||
assert(FastMutex->Owner == KeGetCurrentThread());
|
assert(FastMutex->Owner == KeGetCurrentThread());
|
||||||
FastMutex->Owner = NULL;
|
|
||||||
if (InterlockedIncrement(&FastMutex->Count) <= 0)
|
if (InterlockedIncrement(&FastMutex->Count) <= 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
FastMutex->Owner = NULL;
|
||||||
KeSetEvent(&FastMutex->Event, 0, FALSE);
|
KeSetEvent(&FastMutex->Event, 0, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: interlck.c,v 1.5 2000/07/04 01:27:58 ekohl Exp $
|
/* $Id: interlck.c,v 1.6 2000/12/23 02:37:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -16,12 +16,12 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
INTERLOCKED_RESULT
|
INTERLOCKED_RESULT STDCALL
|
||||||
STDCALL
|
ExInterlockedDecrementLong (PLONG Addend,
|
||||||
ExInterlockedDecrementLong (
|
PKSPIN_LOCK Lock)
|
||||||
PLONG Addend,
|
/*
|
||||||
PKSPIN_LOCK Lock
|
* Obsolete, use InterlockedDecrement instead
|
||||||
)
|
*/
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
LONG oldval;
|
LONG oldval;
|
||||||
|
@ -37,13 +37,13 @@ ExInterlockedDecrementLong (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ULONG
|
ULONG STDCALL
|
||||||
STDCALL
|
ExInterlockedExchangeUlong (PULONG Target,
|
||||||
ExInterlockedExchangeUlong (
|
ULONG Value,
|
||||||
PULONG Target,
|
PKSPIN_LOCK Lock)
|
||||||
ULONG Value,
|
/*
|
||||||
PKSPIN_LOCK Lock
|
* Obsolete, use InterlockedExchange instead
|
||||||
)
|
*/
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
LONG oldval;
|
LONG oldval;
|
||||||
|
@ -59,13 +59,25 @@ ExInterlockedExchangeUlong (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ULONG
|
ULONG STDCALL
|
||||||
STDCALL
|
ExInterlockedAddUlong (PULONG Addend,
|
||||||
ExInterlockedAddUlong (
|
ULONG Increment,
|
||||||
PULONG Addend,
|
PKSPIN_LOCK Lock)
|
||||||
ULONG Increment,
|
/*
|
||||||
PKSPIN_LOCK Lock
|
* ExInterlockedAddUlong adds an unsigned long value to a given unsigned
|
||||||
)
|
* integer as an atomic operation.
|
||||||
|
*
|
||||||
|
* ADDEND = Points to an unsigned long integer whose value is to be adjusted
|
||||||
|
* by the Increment value.
|
||||||
|
*
|
||||||
|
* INCREMENT = Is an unsigned long integer to be added.
|
||||||
|
*
|
||||||
|
* LOCK = Points to a spinlock to be used to synchronize access to ADDEND.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*
|
||||||
|
* The original value of the unsigned integer pointed to by ADDEND.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
ULONG oldval;
|
ULONG oldval;
|
||||||
|
@ -80,13 +92,23 @@ ExInterlockedAddUlong (
|
||||||
return oldval;
|
return oldval;
|
||||||
}
|
}
|
||||||
|
|
||||||
LARGE_INTEGER
|
LARGE_INTEGER STDCALL
|
||||||
STDCALL
|
ExInterlockedAddLargeInteger (PLARGE_INTEGER Addend,
|
||||||
ExInterlockedAddLargeInteger (
|
LARGE_INTEGER Increment,
|
||||||
PLARGE_INTEGER Addend,
|
PKSPIN_LOCK Lock)
|
||||||
LARGE_INTEGER Increment,
|
/*
|
||||||
PKSPIN_LOCK Lock
|
* Adds two large integer values as an atomic operation.
|
||||||
)
|
*
|
||||||
|
* ADDEND = Pointer to a large integer value that will have INCREMENT added.
|
||||||
|
*
|
||||||
|
* INCREMENT = Value to be added.
|
||||||
|
*
|
||||||
|
* LOCK = Spinlock used to synchronize access to ADDEND.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*
|
||||||
|
* The original value of the large integer pointed to by ADDEND.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
LARGE_INTEGER oldval;
|
LARGE_INTEGER oldval;
|
||||||
|
@ -103,12 +125,12 @@ ExInterlockedAddLargeInteger (
|
||||||
return oldval;
|
return oldval;
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERLOCKED_RESULT
|
INTERLOCKED_RESULT STDCALL
|
||||||
STDCALL
|
ExInterlockedIncrementLong (PLONG Addend,
|
||||||
ExInterlockedIncrementLong (
|
PKSPIN_LOCK Lock)
|
||||||
PLONG Addend,
|
/*
|
||||||
PKSPIN_LOCK Lock
|
* Obsolete, use InterlockedIncrement instead.
|
||||||
)
|
*/
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
LONG oldval;
|
LONG oldval;
|
||||||
|
@ -123,24 +145,24 @@ ExInterlockedIncrementLong (
|
||||||
return oldval;
|
return oldval;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID FASTCALL
|
||||||
FASTCALL
|
ExInterlockedAddLargeStatistic (IN PLARGE_INTEGER Addend,
|
||||||
ExInterlockedAddLargeStatistic (
|
IN ULONG Increment)
|
||||||
IN PLARGE_INTEGER Addend,
|
/*
|
||||||
IN ULONG Increment
|
* Undocumented in DDK.
|
||||||
)
|
*/
|
||||||
{
|
{
|
||||||
Addend->QuadPart += Increment;
|
Addend->QuadPart += Increment;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONGLONG
|
LONGLONG FASTCALL
|
||||||
FASTCALL
|
ExInterlockedCompareExchange64 (IN OUT PLONGLONG Destination,
|
||||||
ExInterlockedCompareExchange64 (
|
IN PLONGLONG Exchange,
|
||||||
IN OUT PLONGLONG Destination,
|
IN PLONGLONG Comparand,
|
||||||
IN PLONGLONG Exchange,
|
IN PKSPIN_LOCK Lock)
|
||||||
IN PLONGLONG Comparand,
|
/*
|
||||||
IN PKSPIN_LOCK Lock
|
* Undocumented in DDK.
|
||||||
)
|
*/
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
LONGLONG oldval;
|
LONGLONG oldval;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: locale.c,v 1.3 2000/10/06 22:54:41 ekohl Exp $
|
/* $Id: locale.c,v 1.4 2000/12/23 02:37:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -15,19 +15,42 @@
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtQueryDefaultLocale(IN BOOLEAN UserProfile,
|
NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
|
||||||
OUT PLCID DefaultLocaleId)
|
OUT PLCID DefaultLocaleId)
|
||||||
|
/*
|
||||||
|
* Returns the default locale.
|
||||||
|
*
|
||||||
|
* THREADORSYSTEM = If TRUE then the locale for this thread is returned,
|
||||||
|
* otherwise the locale for the system is returned.
|
||||||
|
*
|
||||||
|
* DEFAUTLOCALEID = Points to a variable that receives the locale id.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*
|
||||||
|
* Status.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtSetDefaultLocale(IN BOOLEAN UserProfile,
|
NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
|
||||||
IN LCID DefaultLocaleId)
|
IN LCID DefaultLocaleId)
|
||||||
|
/*
|
||||||
|
* Sets the default locale.
|
||||||
|
*
|
||||||
|
* THREADORSYSTEM = If TRUE then the thread's locale is set, otherwise the
|
||||||
|
* sytem locale is set.
|
||||||
|
*
|
||||||
|
* DEFAUTLOCALEID = The locale id to be set
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*
|
||||||
|
* Status
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,7 @@
|
||||||
#include <ddk/service.h>
|
#include <ddk/service.h>
|
||||||
#include <ntdll/napi.h>
|
#include <ntdll/napi.h>
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* GLOBALS *****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
KE_SERVICE_DESCRIPTOR_TABLE_ENTRY
|
KE_SERVICE_DESCRIPTOR_TABLE_ENTRY
|
||||||
__declspec(dllexport)
|
__declspec(dllexport)
|
||||||
|
@ -32,7 +29,8 @@ KeServiceDescriptorTable[SSDT_MAX_ENTRIES] =
|
||||||
{ NULL, NULL, 0, NULL }
|
{ NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
KE_SERVICE_DESCRIPTOR_TABLE_ENTRY KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES] =
|
KE_SERVICE_DESCRIPTOR_TABLE_ENTRY
|
||||||
|
KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES] =
|
||||||
{
|
{
|
||||||
{ MainSSDT, NULL, NUMBER_OF_SYSCALLS, MainSSPT },
|
{ MainSSDT, NULL, NUMBER_OF_SYSCALLS, MainSSPT },
|
||||||
{ NULL, NULL, 0, NULL },
|
{ NULL, NULL, 0, NULL },
|
||||||
|
|
|
@ -20,13 +20,15 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL NtSetSystemPowerState(VOID)
|
NTSTATUS STDCALL
|
||||||
|
NtSetSystemPowerState(VOID)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
NTSTATUS STDCALL
|
||||||
|
NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
||||||
{
|
{
|
||||||
if (Action > ShutdownPowerOff)
|
if (Action > ShutdownPowerOff)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
|
@ -38,7 +38,7 @@ VOID HalpInitPICs(VOID)
|
||||||
/* Initialization sequence */
|
/* Initialization sequence */
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0x20, 0x11);
|
WRITE_PORT_UCHAR((PUCHAR)0x20, 0x11);
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0xa0, 0x11);
|
WRITE_PORT_UCHAR((PUCHAR)0xa0, 0x11);
|
||||||
/* Start of hardware irqs (0x20) */
|
/* Start of hardware irqs (0x24) */
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0x21, 0x40);
|
WRITE_PORT_UCHAR((PUCHAR)0x21, 0x40);
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0xa1, 0x48);
|
WRITE_PORT_UCHAR((PUCHAR)0xa1, 0x48);
|
||||||
/* 8259-1 is master */
|
/* 8259-1 is master */
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
/*
|
/*
|
||||||
* FIXME: We actually have one TSS per thread
|
* FIXME: We actually have one TSS per thread
|
||||||
*/
|
*/
|
||||||
#define RESERVED_FOR_TSS (0x28)
|
#define TSS_SELECTOR (0x28)
|
||||||
#define PCR_SELECTOR (0x30)
|
#define PCR_SELECTOR (0x30)
|
||||||
#define TEB_SELECTOR (0x38 + 0x3)
|
#define TEB_SELECTOR (0x38 + 0x3)
|
||||||
#define RESERVED1_SELECTOR (0x40)
|
#define RESERVED1_SELECTOR (0x40)
|
||||||
|
|
|
@ -3,56 +3,20 @@
|
||||||
#define __MODULE_H
|
#define __MODULE_H
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <coff.h>
|
|
||||||
#include <pe.h>
|
#include <pe.h>
|
||||||
|
|
||||||
/* FIXME: replace this struct with struct below in all code */
|
|
||||||
typedef struct _module
|
|
||||||
{
|
|
||||||
unsigned int nsyms;
|
|
||||||
unsigned int text_base;
|
|
||||||
unsigned int data_base;
|
|
||||||
unsigned int bss_base;
|
|
||||||
SCNHDR* scn_list;
|
|
||||||
char* str_tab;
|
|
||||||
SYMENT* sym_list;
|
|
||||||
unsigned int size;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Base address of the module in memory
|
|
||||||
*/
|
|
||||||
unsigned int base;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Offset of the raw data in memory
|
|
||||||
*/
|
|
||||||
unsigned int raw_data_off;
|
|
||||||
} module;
|
|
||||||
|
|
||||||
typedef SCNHDR COFF_SECTION_HEADER, *PCOFF_SECTION_HEADER;
|
|
||||||
|
|
||||||
typedef struct _MODULE_OBJECT
|
typedef struct _MODULE_OBJECT
|
||||||
{
|
{
|
||||||
CSHORT ObjectType;
|
CSHORT ObjectType;
|
||||||
CSHORT ObjectSize;
|
CSHORT ObjectSize;
|
||||||
PVOID Base;
|
PVOID Base;
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
unsigned int Flags;
|
ULONG Flags;
|
||||||
PVOID EntryPoint;
|
PVOID EntryPoint;
|
||||||
LIST_ENTRY ListEntry;
|
LIST_ENTRY ListEntry;
|
||||||
UNICODE_STRING Name;
|
UNICODE_STRING Name;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int NumberOfSyms;
|
|
||||||
PVOID TextBase;
|
|
||||||
PVOID DataBase;
|
|
||||||
PVOID BSSBase;
|
|
||||||
SCNHDR *SectionList;
|
|
||||||
char *StringTable;
|
|
||||||
SYMENT *SymbolList;
|
|
||||||
} COFF;
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
PIMAGE_FILE_HEADER FileHeader;
|
PIMAGE_FILE_HEADER FileHeader;
|
||||||
|
|
|
@ -30,10 +30,16 @@
|
||||||
/*
|
/*
|
||||||
* Defines for accessing KPCR and KTHREAD structure members
|
* Defines for accessing KPCR and KTHREAD structure members
|
||||||
*/
|
*/
|
||||||
|
#define KTHREAD_INITIAL_STACK 0x18
|
||||||
|
#define KTHREAD_TEB 0x20
|
||||||
#define KTHREAD_KERNEL_STACK 0x28
|
#define KTHREAD_KERNEL_STACK 0x28
|
||||||
#define KTHREAD_PREVIOUS_MODE 0x137
|
#define KTHREAD_PREVIOUS_MODE 0x137
|
||||||
#define KTHREAD_TRAP_FRAME 0x128
|
#define KTHREAD_TRAP_FRAME 0x128
|
||||||
|
|
||||||
|
#define ETHREAD_THREADS_PROCESS 0x258
|
||||||
|
|
||||||
|
#define KPROCESS_PAGE_TABLE_DIRECTORY 0x10
|
||||||
|
|
||||||
#define KPCR_BASE 0xFFDFF000
|
#define KPCR_BASE 0xFFDFF000
|
||||||
|
|
||||||
#define KPCR_EXCEPTION_LIST 0x0
|
#define KPCR_EXCEPTION_LIST 0x0
|
||||||
|
@ -138,8 +144,8 @@ typedef struct _KTHREAD
|
||||||
UCHAR LargeStack; /* 135 */
|
UCHAR LargeStack; /* 135 */
|
||||||
UCHAR ResourceIndex; /* 136 */
|
UCHAR ResourceIndex; /* 136 */
|
||||||
UCHAR PreviousMode; /* 137 */
|
UCHAR PreviousMode; /* 137 */
|
||||||
TIME KernelTime; /* 138 */
|
ULONG KernelTime; /* 138 */
|
||||||
TIME UserTime; /* 13C */
|
ULONG UserTime; /* 13C */
|
||||||
KAPC_STATE SavedApcState; /* 140 */
|
KAPC_STATE SavedApcState; /* 140 */
|
||||||
UCHAR Alertable; /* 158 */
|
UCHAR Alertable; /* 158 */
|
||||||
UCHAR ApcStateIndex; /* 159 */
|
UCHAR ApcStateIndex; /* 159 */
|
||||||
|
@ -159,16 +165,13 @@ typedef struct _KTHREAD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Added by Phillip Susi for list of threads in a process */
|
/* Added by Phillip Susi for list of threads in a process */
|
||||||
LIST_ENTRY ProcessThreadListEntry;
|
LIST_ENTRY ProcessThreadListEntry; /* 1B0 */
|
||||||
|
|
||||||
|
|
||||||
/* Provisionally added by David Welch */
|
|
||||||
hal_thread_state Context;
|
|
||||||
/* Added by Phillip Susi for internal KeAddThreadTimeout() implementation */
|
/* Added by Phillip Susi for internal KeAddThreadTimeout() implementation */
|
||||||
|
KDPC TimerDpc; /* 1B8 */
|
||||||
|
|
||||||
KDPC TimerDpc;
|
|
||||||
/* Record the last EIP value when the thread is suspended */
|
/* Record the last EIP value when the thread is suspended */
|
||||||
ULONG LastEip;
|
ULONG LastEip; /* 1D8 */
|
||||||
} __attribute__((packed)) KTHREAD, *PKTHREAD;
|
} __attribute__((packed)) KTHREAD, *PKTHREAD;
|
||||||
|
|
||||||
// According to documentation the stack should have a commited [ 1 page ] and
|
// According to documentation the stack should have a commited [ 1 page ] and
|
||||||
|
@ -208,50 +211,60 @@ struct _WIN32THREADDATA;
|
||||||
|
|
||||||
typedef struct _ETHREAD
|
typedef struct _ETHREAD
|
||||||
{
|
{
|
||||||
KTHREAD Tcb;
|
KTHREAD Tcb; /* 000 */
|
||||||
TIME CreateTime;
|
TIME CreateTime; /* 1B0/1DC */
|
||||||
TIME ExitTime;
|
union
|
||||||
NTSTATUS ExitStatus;
|
{
|
||||||
LIST_ENTRY PostBlockList;
|
TIME ExitTime; /* 1B8/1E4 */
|
||||||
LIST_ENTRY TerminationPortList;
|
LIST_ENTRY LpcReplyChain; /* 1B8/1E4 */
|
||||||
KSPIN_LOCK ActiveTimerListLock;
|
} u1;
|
||||||
PVOID ActiveTimerListHead;
|
NTSTATUS ExitStatus; /* 1C0/1EC */
|
||||||
CLIENT_ID Cid;
|
LIST_ENTRY PostBlockList; /* 1C4/1F0 */
|
||||||
PLARGE_INTEGER LpcReplySemaphore;
|
LIST_ENTRY TerminationPortList; /* 1CC/1F8 */
|
||||||
PVOID LpcReplyMessage;
|
KSPIN_LOCK ActiveTimerListLock; /* 1D4/200 */
|
||||||
PLARGE_INTEGER LpcReplyMessageId;
|
LIST_ENTRY ActiveTimerListHead; /* 1D8/204 */
|
||||||
PPS_IMPERSONATION_INFO ImpersonationInfo;
|
CLIENT_ID Cid; /* 1E0/20C */
|
||||||
LIST_ENTRY IrpList;
|
KSEMAPHORE LpcReplySemaphore; /* 1E8/214 */
|
||||||
TOP_LEVEL_IRP TopLevelIrp;
|
PVOID LpcReplyMessage; /* 1FC/228 */
|
||||||
PDEVICE_OBJECT DeviceToVerify;
|
PLARGE_INTEGER LpcReplyMessageId; /* 200/22C */
|
||||||
ULONG ReadClusterSize;
|
ULONG PerformanceCounterLow; /* 204/230 */
|
||||||
UCHAR ForwardClusterOnly;
|
PPS_IMPERSONATION_INFO ImpersonationInfo; /* 208/234 */
|
||||||
UCHAR DisablePageFaultClustering;
|
LIST_ENTRY IrpList; /* 20C/238 */
|
||||||
UCHAR DeadThread;
|
TOP_LEVEL_IRP* TopLevelIrp; /* 214/240 */
|
||||||
UCHAR HasTerminated;
|
PDEVICE_OBJECT DeviceToVerify; /* 218/244 */
|
||||||
ACCESS_MASK GrantedAccess;
|
ULONG ReadClusterSize; /* 21C/248 */
|
||||||
struct _EPROCESS* ThreadsProcess;
|
UCHAR ForwardClusterOnly; /* 220/24C */
|
||||||
PKSTART_ROUTINE StartAddress;
|
UCHAR DisablePageFaultClustering; /* 221/24D */
|
||||||
LPTHREAD_START_ROUTINE Win32StartAddress;
|
UCHAR DeadThread; /* 222/24E */
|
||||||
UCHAR LpcExitThreadCalled;
|
UCHAR HasTerminated; /* 223/24F */
|
||||||
UCHAR HardErrorsAreDisabled;
|
PVOID EventPair; /* 224/250 */
|
||||||
UCHAR LpcReceivedMsgIdValid;
|
ACCESS_MASK GrantedAccess; /* 228/254 */
|
||||||
UCHAR ActiveImpersonationInfo;
|
struct _EPROCESS* ThreadsProcess; /* 22C/258 */
|
||||||
ULONG PerformanceCountHigh;
|
PKSTART_ROUTINE StartAddress; /* 230/25C */
|
||||||
|
union
|
||||||
|
{
|
||||||
|
LPTHREAD_START_ROUTINE Win32StartAddress; /* 234/260 */
|
||||||
|
ULONG LpcReceiveMessageId; /* 234/260 */
|
||||||
|
} u2;
|
||||||
|
UCHAR LpcExitThreadCalled; /* 238/264 */
|
||||||
|
UCHAR HardErrorsAreDisabled; /* 239/265 */
|
||||||
|
UCHAR LpcReceivedMsgIdValid; /* 23A/266 */
|
||||||
|
UCHAR ActiveImpersonationInfo; /* 23B/267 */
|
||||||
|
ULONG PerformanceCountHigh; /* 23C/268 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Added by David Welch (welch@cwcom.net)
|
* Added by David Welch (welch@cwcom.net)
|
||||||
*/
|
*/
|
||||||
struct _EPROCESS* OldProcess;
|
struct _EPROCESS* OldProcess; /* 240/26C */
|
||||||
struct _WIN32THREADDATA *Win32ThreadData; // Pointer to win32 private thread data
|
struct _WIN32THREADDATA *Win32ThreadData; // Pointer to win32 private thread data
|
||||||
|
|
||||||
} ETHREAD, *PETHREAD;
|
} __attribute__((packed)) ETHREAD, *PETHREAD;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _KPROCESS
|
typedef struct _KPROCESS
|
||||||
{
|
{
|
||||||
DISPATCHER_HEADER DispatcherHeader;
|
DISPATCHER_HEADER DispatcherHeader; /* 000 */
|
||||||
PVOID PageTableDirectory; // FIXME: I should point to a PTD
|
PVOID PageTableDirectory; /* 010 */
|
||||||
TIME ElapsedTime;
|
TIME ElapsedTime;
|
||||||
TIME KernelTime;
|
TIME KernelTime;
|
||||||
TIME UserTime;
|
TIME UserTime;
|
||||||
|
@ -367,11 +380,13 @@ VOID PiInitApcManagement(VOID);
|
||||||
VOID PiDeleteThread(PVOID ObjectBody);
|
VOID PiDeleteThread(PVOID ObjectBody);
|
||||||
VOID PiCloseThread(PVOID ObjectBody, ULONG HandleCount);
|
VOID PiCloseThread(PVOID ObjectBody, ULONG HandleCount);
|
||||||
VOID PsReapThreads(VOID);
|
VOID PsReapThreads(VOID);
|
||||||
NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
NTSTATUS
|
||||||
PETHREAD* ThreadPtr,
|
PsInitializeThread(HANDLE ProcessHandle,
|
||||||
PHANDLE ThreadHandle,
|
PETHREAD* ThreadPtr,
|
||||||
ACCESS_MASK DesiredAccess,
|
PHANDLE ThreadHandle,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes);
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
BOOLEAN First);
|
||||||
|
|
||||||
PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
|
PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
|
||||||
PTOKEN_TYPE TokenType,
|
PTOKEN_TYPE TokenType,
|
||||||
|
@ -412,16 +427,16 @@ ULONG PsResumeThread(PETHREAD Thread);
|
||||||
#define PROCESS_PRIO_HIGH 13
|
#define PROCESS_PRIO_HIGH 13
|
||||||
#define PROCESS_PRIO_RT 18
|
#define PROCESS_PRIO_RT 18
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions the HAL must provide
|
|
||||||
*/
|
|
||||||
|
|
||||||
VOID KeInitializeThread(PKPROCESS Process, PKTHREAD Thread);
|
VOID
|
||||||
|
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First);
|
||||||
|
|
||||||
VOID HalInitFirstTask(PETHREAD thread);
|
VOID HalInitFirstTask(PETHREAD thread);
|
||||||
NTSTATUS HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
|
NTSTATUS
|
||||||
|
Ke386InitThread(PKTHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
|
||||||
VOID HalTaskSwitch(PKTHREAD thread);
|
VOID HalTaskSwitch(PKTHREAD thread);
|
||||||
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context);
|
NTSTATUS
|
||||||
|
Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context);
|
||||||
NTSTATUS HalReleaseTask(PETHREAD Thread);
|
NTSTATUS HalReleaseTask(PETHREAD Thread);
|
||||||
VOID PiDeleteProcess(PVOID ObjectBody);
|
VOID PiDeleteProcess(PVOID ObjectBody);
|
||||||
VOID PsReapThreads(VOID);
|
VOID PsReapThreads(VOID);
|
||||||
|
@ -430,6 +445,8 @@ VOID PsFreezeOtherThread(PETHREAD Thread);
|
||||||
VOID PsFreezeProcessThreads(PEPROCESS Process);
|
VOID PsFreezeProcessThreads(PEPROCESS Process);
|
||||||
VOID PsUnfreezeProcessThreads(PEPROCESS Process);
|
VOID PsUnfreezeProcessThreads(PEPROCESS Process);
|
||||||
PEPROCESS PsGetNextProcess(PEPROCESS OldProcess);
|
PEPROCESS PsGetNextProcess(PEPROCESS OldProcess);
|
||||||
|
VOID
|
||||||
|
Ki386ContextSwitch(PKTHREAD NewThread, PKTHREAD OldThread);
|
||||||
|
|
||||||
#endif /* ASSEMBLER */
|
#endif /* ASSEMBLER */
|
||||||
|
|
||||||
|
|
101
reactos/ntoskrnl/include/internal/trap.h
Normal file
101
reactos/ntoskrnl/include/internal/trap.h
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* FILE: ntoskrnl/include/internal/trap.h
|
||||||
|
* PURPOSE: Trap definitions
|
||||||
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 10/12/00
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_TRAP_H
|
||||||
|
#define __NTOSKRNL_INCLUDE_INTERNAL_TRAP_H
|
||||||
|
|
||||||
|
#define TF_EDI (0x0)
|
||||||
|
#define TF_ESI (0x4)
|
||||||
|
#define TF_EBP (0x8)
|
||||||
|
#define TF_ESP (0xC)
|
||||||
|
#define TF_EBX (0x10)
|
||||||
|
#define TF_EDX (0x14)
|
||||||
|
#define TF_ECX (0x18)
|
||||||
|
#define TF_EAX (0x1C)
|
||||||
|
#define TF_TYPE (0x20)
|
||||||
|
#define TF_DS (0x24)
|
||||||
|
#define TF_ES (0x28)
|
||||||
|
#define TF_FS (0x2C)
|
||||||
|
#define TF_GS (0x30)
|
||||||
|
#define TF_ERROR_CODE (0x34)
|
||||||
|
#define TF_EIP (0x38)
|
||||||
|
#define TF_CS (0x3C)
|
||||||
|
#define TF_EFLAGS (0x40)
|
||||||
|
#define TF_ESP0 (0x44)
|
||||||
|
#define TF_SS0 (0x48)
|
||||||
|
#define TF_V86_ES (0x4C)
|
||||||
|
#define TF_V86_DS (0x50)
|
||||||
|
#define TF_V86_FS (0x54)
|
||||||
|
#define TF_V86_GS (0x58)
|
||||||
|
#define TF_REGS (0x5C)
|
||||||
|
#define TF_ORIG_EBP (0x60)
|
||||||
|
|
||||||
|
#ifndef __ASM__
|
||||||
|
|
||||||
|
struct trap_frame
|
||||||
|
{
|
||||||
|
ULONG edi;
|
||||||
|
ULONG esi;
|
||||||
|
ULONG ebp;
|
||||||
|
ULONG esp;
|
||||||
|
ULONG ebx;
|
||||||
|
ULONG edx;
|
||||||
|
ULONG ecx;
|
||||||
|
ULONG eax;
|
||||||
|
ULONG type;
|
||||||
|
ULONG ds;
|
||||||
|
ULONG es;
|
||||||
|
ULONG fs;
|
||||||
|
ULONG gs;
|
||||||
|
ULONG error_code;
|
||||||
|
ULONG eip;
|
||||||
|
ULONG cs;
|
||||||
|
ULONG eflags;
|
||||||
|
ULONG esp0;
|
||||||
|
ULONG ss0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These members are only valid in v86 mode
|
||||||
|
*/
|
||||||
|
ULONG v86_es;
|
||||||
|
ULONG v86_ds;
|
||||||
|
ULONG v86_fs;
|
||||||
|
ULONG v86_gs;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These are put on the top of the stack by the routine that entered
|
||||||
|
* v86 mode so the exception handlers can find the control information
|
||||||
|
*/
|
||||||
|
struct _KV86M_REGISTERS* regs;
|
||||||
|
ULONG orig_ebp;
|
||||||
|
};
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
KeV86Exception(struct trap_frame* tf, ULONG address);
|
||||||
|
|
||||||
|
#endif /* not __ASM__ */
|
||||||
|
|
||||||
|
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_TRAP_H */
|
|
@ -17,39 +17,61 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* FILE: ntoskrnl/ke/i386/vm86_sup.S
|
* FILE: ntoskrnl/include/internal/v86m.h
|
||||||
* PURPOSE: V86 mode support
|
* PURPOSE: V86 mode support
|
||||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 10/12/00
|
* Created 10/12/00
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_VM86_H
|
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_V86M_H
|
||||||
#define __NTOSKRNL_INCLUDE_INTERNAL_VM86_H
|
#define __NTOSKRNL_INCLUDE_INTERNAL_V86M_H
|
||||||
|
|
||||||
#ifndef ASSEMBLER
|
#ifndef __ASM__
|
||||||
|
|
||||||
typedef struct
|
/* Emulate cli/sti instructions */
|
||||||
|
#define KV86M_EMULATE_CLI_STI (0x1)
|
||||||
|
/* Allow the v86 mode code to access i/o ports */
|
||||||
|
#define KV86M_ALLOW_IO_PORT_ACCESS (0x2)
|
||||||
|
|
||||||
|
typedef struct _KV86M_REGISTERS
|
||||||
{
|
{
|
||||||
ULONG Ebp;
|
/*
|
||||||
ULONG Edi;
|
* General purpose registers
|
||||||
ULONG Esi;
|
*/
|
||||||
ULONG Edx;
|
|
||||||
ULONG Ecx;
|
ULONG Ebp;
|
||||||
ULONG Ebx;
|
ULONG Edi;
|
||||||
ULONG Eax;
|
ULONG Esi;
|
||||||
ULONG Ds;
|
ULONG Edx;
|
||||||
ULONG Es;
|
ULONG Ecx;
|
||||||
ULONG Fs;
|
ULONG Ebx;
|
||||||
ULONG Gs;
|
ULONG Eax;
|
||||||
ULONG Eip;
|
ULONG Ds;
|
||||||
ULONG Cs;
|
ULONG Es;
|
||||||
ULONG Eflags;
|
ULONG Fs;
|
||||||
ULONG Esp;
|
ULONG Gs;
|
||||||
ULONG Ss;
|
|
||||||
|
/*
|
||||||
|
* Control registers
|
||||||
|
*/
|
||||||
|
ULONG Eip;
|
||||||
|
ULONG Cs;
|
||||||
|
ULONG Eflags;
|
||||||
|
ULONG Esp;
|
||||||
|
ULONG Ss;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Control structures
|
||||||
|
*/
|
||||||
|
ULONG RecoveryAddress;
|
||||||
|
UCHAR RecoveryInstruction[4];
|
||||||
|
ULONG Vif;
|
||||||
|
ULONG Flags;
|
||||||
|
PNTSTATUS PStatus;
|
||||||
} KV86M_REGISTERS;
|
} KV86M_REGISTERS;
|
||||||
|
|
||||||
#else
|
#else /* ASSEMBLER */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Definitions for the offsets of members in the KV86M_REGISTERS
|
* Definitions for the offsets of members in the KV86M_REGISTERS
|
||||||
|
@ -73,4 +95,4 @@ typedef struct
|
||||||
|
|
||||||
#endif /* ASSEMBLER */
|
#endif /* ASSEMBLER */
|
||||||
|
|
||||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_VM86_H */
|
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_V86M_H */
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.33 2000/10/22 16:36:50 ekohl Exp $
|
/* $Id: create.c,v 1.34 2000/12/23 02:37:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -57,102 +57,90 @@ NtDeleteFile (IN POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
IopCreateFile (
|
IopCreateFile (PVOID ObjectBody,
|
||||||
PVOID ObjectBody,
|
PVOID Parent,
|
||||||
PVOID Parent,
|
PWSTR RemainingPath,
|
||||||
PWSTR RemainingPath,
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT) Parent;
|
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT) Parent;
|
||||||
PFILE_OBJECT FileObject = (PFILE_OBJECT) ObjectBody;
|
PFILE_OBJECT FileObject = (PFILE_OBJECT) ObjectBody;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT(
|
DPRINT("IopCreateFile(ObjectBody %x, Parent %x, RemainingPath %S)\n",
|
||||||
"IopCreateFile(ObjectBody %x, Parent %x, RemainingPath %S)\n",
|
ObjectBody,
|
||||||
ObjectBody,
|
Parent,
|
||||||
Parent,
|
RemainingPath);
|
||||||
RemainingPath
|
|
||||||
);
|
|
||||||
|
|
||||||
if (NULL == DeviceObject)
|
if (NULL == DeviceObject)
|
||||||
{
|
{
|
||||||
DPRINT("DeviceObject was NULL\n");
|
DPRINT("DeviceObject was NULL\n");
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
if (IoDeviceObjectType != BODY_TO_HEADER(Parent)->ObjectType)
|
if (IoDeviceObjectType != BODY_TO_HEADER(Parent)->ObjectType)
|
||||||
{
|
{
|
||||||
DPRINT ("Parent is not a device type\n");
|
DPRINT ("Parent is not a device type\n");
|
||||||
return (STATUS_UNSUCCESSFUL);
|
return (STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
Status = ObReferenceObjectByPointer (
|
Status = ObReferenceObjectByPointer (DeviceObject,
|
||||||
DeviceObject,
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
STANDARD_RIGHTS_REQUIRED,
|
IoDeviceObjectType,
|
||||||
IoDeviceObjectType,
|
UserMode);
|
||||||
UserMode
|
if (STATUS_SUCCESS != Status)
|
||||||
);
|
{
|
||||||
if (STATUS_SUCCESS != Status)
|
CHECKPOINT;
|
||||||
{
|
return (Status);
|
||||||
CHECKPOINT;
|
}
|
||||||
return (Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceObject = IoGetAttachedDevice (DeviceObject);
|
DeviceObject = IoGetAttachedDevice (DeviceObject);
|
||||||
|
|
||||||
DPRINT ("DeviceObject %x\n", DeviceObject);
|
DPRINT ("DeviceObject %x\n", DeviceObject);
|
||||||
|
|
||||||
if (NULL == RemainingPath)
|
if (NULL == RemainingPath)
|
||||||
{
|
{
|
||||||
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
|
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
|
||||||
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
||||||
(ObjectAttributes->ObjectName->Length+1)*2);
|
(ObjectAttributes->ObjectName->Length+1)*2);
|
||||||
FileObject->FileName.Length = ObjectAttributes->ObjectName->Length;
|
FileObject->FileName.Length = ObjectAttributes->ObjectName->Length;
|
||||||
FileObject->FileName.MaximumLength =
|
FileObject->FileName.MaximumLength =
|
||||||
ObjectAttributes->ObjectName->MaximumLength;
|
ObjectAttributes->ObjectName->MaximumLength;
|
||||||
RtlCopyUnicodeString(&(FileObject->FileName),
|
RtlCopyUnicodeString(&(FileObject->FileName),
|
||||||
ObjectAttributes->ObjectName);
|
ObjectAttributes->ObjectName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM)
|
if ( (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM)
|
||||||
&& (DeviceObject->DeviceType != FILE_DEVICE_DISK)
|
&& (DeviceObject->DeviceType != FILE_DEVICE_DISK)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DPRINT ("Device was wrong type\n");
|
DPRINT ("Device was wrong type\n");
|
||||||
return (STATUS_UNSUCCESSFUL);
|
return (STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
|
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
|
||||||
{
|
{
|
||||||
DPRINT("Trying to mount storage device\n");
|
DPRINT("Trying to mount storage device\n");
|
||||||
Status = IoTryToMountStorageDevice (DeviceObject);
|
Status = IoTryToMountStorageDevice (DeviceObject);
|
||||||
DPRINT("Status %x\n", Status);
|
DPRINT("Status %x\n", Status);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT(
|
DPRINT("Failed to mount storage device (statux %x)\n",
|
||||||
"Failed to mount storage device (statux %x)\n",
|
Status);
|
||||||
Status
|
return (Status);
|
||||||
);
|
}
|
||||||
return (Status);
|
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||||
}
|
}
|
||||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
RtlCreateUnicodeString(&(FileObject->FileName),
|
||||||
}
|
RemainingPath);
|
||||||
RtlCreateUnicodeString(&(FileObject->FileName),
|
}
|
||||||
RemainingPath);
|
DPRINT("FileObject->FileName.Buffer %S\n",
|
||||||
}
|
FileObject->FileName.Buffer);
|
||||||
DPRINT(
|
FileObject->DeviceObject = DeviceObject;
|
||||||
"FileObject->FileName.Buffer %S\n",
|
DPRINT("FileObject %x DeviceObject %x\n",
|
||||||
FileObject->FileName.Buffer
|
FileObject,
|
||||||
);
|
DeviceObject);
|
||||||
FileObject->DeviceObject = DeviceObject;
|
FileObject->Vpb = DeviceObject->Vpb;
|
||||||
DPRINT(
|
FileObject->Type = InternalFileType;
|
||||||
"FileObject %x DeviceObject %x\n",
|
|
||||||
FileObject,
|
|
||||||
DeviceObject
|
|
||||||
);
|
|
||||||
FileObject->Vpb = DeviceObject->Vpb;
|
|
||||||
FileObject->Type = InternalFileType;
|
|
||||||
|
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: device.c,v 1.24 2000/12/10 19:15:45 ekohl Exp $
|
/* $Id: device.c,v 1.25 2000/12/23 02:37:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -205,8 +205,7 @@ IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
|
||||||
return(Current);
|
return(Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
PDEVICE_OBJECT
|
PDEVICE_OBJECT STDCALL
|
||||||
STDCALL
|
|
||||||
IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
|
IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
|
||||||
PDEVICE_OBJECT TargetDevice)
|
PDEVICE_OBJECT TargetDevice)
|
||||||
{
|
{
|
||||||
|
@ -223,8 +222,7 @@ IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
|
||||||
return(AttachedDevice);
|
return(AttachedDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
|
||||||
IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
|
IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
|
||||||
PDRIVER_REINITIALIZE ReinitRoutine,
|
PDRIVER_REINITIALIZE ReinitRoutine,
|
||||||
PVOID Context)
|
PVOID Context)
|
||||||
|
@ -232,8 +230,9 @@ IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject,
|
NTSTATUS STDCALL
|
||||||
PIRP Irp)
|
IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject,
|
||||||
|
PIRP Irp)
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
|
@ -242,7 +241,8 @@ NTSTATUS STDCALL IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject,
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry)
|
NTSTATUS
|
||||||
|
IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Called to initalize a loaded driver
|
* FUNCTION: Called to initalize a loaded driver
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -277,8 +277,7 @@ NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry)
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
|
||||||
IoAttachDevice(PDEVICE_OBJECT SourceDevice,
|
IoAttachDevice(PDEVICE_OBJECT SourceDevice,
|
||||||
PUNICODE_STRING TargetDevice,
|
PUNICODE_STRING TargetDevice,
|
||||||
PDEVICE_OBJECT* AttachedDevice)
|
PDEVICE_OBJECT* AttachedDevice)
|
||||||
|
@ -293,10 +292,11 @@ IoAttachDevice(PDEVICE_OBJECT SourceDevice,
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
NTSTATUS
|
||||||
PVOID Parent,
|
IopCreateDevice(PVOID ObjectBody,
|
||||||
PWSTR RemainingPath,
|
PVOID Parent,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
PWSTR RemainingPath,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
{
|
{
|
||||||
|
|
||||||
DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %S)\n",
|
DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %S)\n",
|
||||||
|
@ -315,15 +315,14 @@ NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
|
||||||
IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||||
ULONG DeviceExtensionSize,
|
ULONG DeviceExtensionSize,
|
||||||
PUNICODE_STRING DeviceName,
|
PUNICODE_STRING DeviceName,
|
||||||
DEVICE_TYPE DeviceType,
|
DEVICE_TYPE DeviceType,
|
||||||
ULONG DeviceCharacteristics,
|
ULONG DeviceCharacteristics,
|
||||||
BOOLEAN Exclusive,
|
BOOLEAN Exclusive,
|
||||||
PDEVICE_OBJECT* DeviceObject)
|
PDEVICE_OBJECT* DeviceObject)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Allocates memory for and intializes a device object for use for
|
* FUNCTION: Allocates memory for and intializes a device object for use for
|
||||||
* a driver
|
* a driver
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: irp.c,v 1.32 2000/12/10 19:15:45 ekohl Exp $
|
/* $Id: irp.c,v 1.33 2000/12/23 02:37:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -337,7 +337,7 @@ IoSetTopLevelIrp (
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
|
|
||||||
Thread = PsGetCurrentThread ();
|
Thread = PsGetCurrentThread ();
|
||||||
Thread->TopLevelIrp.TopLevelIrp = Irp;
|
Thread->TopLevelIrp->TopLevelIrp = Irp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ IoGetTopLevelIrp (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (PsGetCurrentThread ()->TopLevelIrp.TopLevelIrp);
|
return (PsGetCurrentThread ()->TopLevelIrp->TopLevelIrp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,22 @@
|
||||||
/* $Id: catch.c,v 1.7 2000/03/03 00:47:06 ekohl Exp $
|
/*
|
||||||
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/* $Id: catch.c,v 1.8 2000/12/23 02:37:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -15,44 +33,33 @@
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
ExRaiseAccessViolation (VOID)
|
||||||
ExRaiseAccessViolation (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ExRaiseStatus (STATUS_ACCESS_VIOLATION);
|
ExRaiseStatus (STATUS_ACCESS_VIOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
ExRaiseDatatypeMisalignment (VOID)
|
||||||
ExRaiseDatatypeMisalignment (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT);
|
ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
ExRaiseStatus (IN NTSTATUS Status)
|
||||||
ExRaiseStatus (
|
|
||||||
IN NTSTATUS Status
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
DbgPrint("ExRaiseStatus(%x)\n",Status);
|
DbgPrint("ExRaiseStatus(%x)\n",Status);
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
NTSTATUS STDCALL
|
||||||
NtRaiseException (
|
NtRaiseException (IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
IN PEXCEPTION_RECORD ExceptionRecord,
|
IN PCONTEXT Context,
|
||||||
IN PCONTEXT Context,
|
IN BOOL IsDebugger OPTIONAL)
|
||||||
IN BOOL IsDebugger OPTIONAL
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -45,7 +45,9 @@ USHORT KiGdt[(8 + NR_TASKS) * 4] =
|
||||||
0x0, 0x0, 0xf200, 0xcc, /* User DS */
|
0x0, 0x0, 0xf200, 0xcc, /* User DS */
|
||||||
0x0, 0x0, 0x0, 0x0, /* TSS */
|
0x0, 0x0, 0x0, 0x0, /* TSS */
|
||||||
0x1000, 0xf000, 0x92df, 0xff00, /* PCR */
|
0x1000, 0xf000, 0x92df, 0xff00, /* PCR */
|
||||||
0x1000, 0x0, 0xf200, 0x0}; /* TEB */
|
0x1000, 0x0, 0xf200, 0x0, /* TEB */
|
||||||
|
0x0, 0x0, 0x0, 0x0, /* Reserved */
|
||||||
|
0x0, 0x0, 0x0, 0x0}; /* LDT */
|
||||||
|
|
||||||
static KSPIN_LOCK GdtLock;
|
static KSPIN_LOCK GdtLock;
|
||||||
|
|
||||||
|
@ -113,6 +115,7 @@ VOID KeDumpGdtSelector(ULONG Entry)
|
||||||
DbgPrint("G: %d\n", (d & 0x80) >> 7);
|
DbgPrint("G: %d\n", (d & 0x80) >> 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
VOID KeFreeGdtSelector(ULONG Entry)
|
VOID KeFreeGdtSelector(ULONG Entry)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Free a gdt selector
|
* FUNCTION: Free a gdt selector
|
||||||
|
@ -137,7 +140,9 @@ VOID KeFreeGdtSelector(ULONG Entry)
|
||||||
KiGdt[Entry*4 + 3] = 0;
|
KiGdt[Entry*4 + 3] = 0;
|
||||||
KeReleaseSpinLock(&GdtLock, oldIrql);
|
KeReleaseSpinLock(&GdtLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
ULONG KeAllocateGdtSelector(ULONG Desc[2])
|
ULONG KeAllocateGdtSelector(ULONG Desc[2])
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Allocate a gdt selector
|
* FUNCTION: Allocate a gdt selector
|
||||||
|
@ -170,3 +175,4 @@ ULONG KeAllocateGdtSelector(ULONG Desc[2])
|
||||||
KeReleaseSpinLock(&GdtLock, oldIrql);
|
KeReleaseSpinLock(&GdtLock, oldIrql);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
91
reactos/ntoskrnl/ke/i386/bios.c
Normal file
91
reactos/ntoskrnl/ke/i386/bios.c
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/ke/i386/bios.c
|
||||||
|
* PURPOSE: Support for calling the BIOS in v86 mode
|
||||||
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/v86m.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
#define TRAMPOLINE_BASE (0x10000)
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID
|
||||||
|
Ke386CallBios(UCHAR Int, PKV86M_REGISTERS Regs)
|
||||||
|
{
|
||||||
|
PUCHAR Ip;
|
||||||
|
KVM86_REGISTERS ORegs;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up a trampoline for executing the BIOS interrupt
|
||||||
|
*/
|
||||||
|
Ip = (PUCHAR)TRAMPOLINE_BASE;
|
||||||
|
Ip[0] = 0xCD; /* int XX */
|
||||||
|
Ip[1] = Int;
|
||||||
|
Ip[2] = 0x63; /* arpl ax, ax */
|
||||||
|
Ip[3] = 0xC0;
|
||||||
|
Ip[4] = 0x90; /* nop */
|
||||||
|
Ip[5] = 0x90; /* nop */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Munge the registers
|
||||||
|
*/
|
||||||
|
Regs->Eip = 0;
|
||||||
|
Regs->Cs = TRAMPOLINE_BASE / 16;
|
||||||
|
Regs->Esp = 0xFFFF;
|
||||||
|
Regs->Ss = TRAMPOLINE_BASE / 16;
|
||||||
|
Regs->Eflags = (1 << 1) | (1 << 17) | (1 << 9); /* VM, IF */
|
||||||
|
Regs->RecoveryAddress = TRAMPOLINE_BASE + 2;
|
||||||
|
Regs->RecoveryInstruction[0] = 0x63; /* arpl ax, ax */
|
||||||
|
Regs->RecoveryInstruction[1] = 0xC0;
|
||||||
|
Regs->RecoveryInstruction[2] = 0x90; /* nop */
|
||||||
|
Regs->RecoveryInstruction[3] = 0x90; /* nop */
|
||||||
|
Regs->Flags = KV86M_EMULATE_CLI_STI | KV86M_ALLOW_IO_PORT_ACCESS;
|
||||||
|
Regs->Vif = 0;
|
||||||
|
Regs->PStatus = &Status;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Execute the BIOS interrupt
|
||||||
|
*/
|
||||||
|
Ki386RetToV86Mode(Regs, &ORegs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy the return values back to the caller
|
||||||
|
*/
|
||||||
|
memcpy(Regs, &ORegs, sizeof(Regs));
|
||||||
|
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,49 +16,110 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: bthread.S,v 1.1 2000/12/10 23:42:00 dwelch Exp $
|
/* $Id: bthread.S,v 1.2 2000/12/23 02:37:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/hal/x86/bthread.s
|
* FILE: ntoskrnl/ke/i386/bthread.S
|
||||||
* PURPOSE: Trap handlers
|
* PURPOSE: Trap handlers
|
||||||
* PROGRAMMER: David Welch (david.welch@seh.ox.ac.uk)
|
* PROGRAMMER: David Welch (david.welch@seh.ox.ac.uk)
|
||||||
* UPDATE HISTORY:
|
|
||||||
* ???
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <ddk/status.h>
|
#include <ddk/status.h>
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
#include <ddk/defines.h>
|
#include <ddk/defines.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.globl _PsBeginThreadWithContextInternal
|
.globl _PsBeginThreadWithContextInternal
|
||||||
|
.globl _PsBeginThread
|
||||||
|
|
||||||
|
_PsBeginThread:
|
||||||
|
/*
|
||||||
|
* This isn't really a function, we are called as the return address
|
||||||
|
* of the context switch function
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do the necessary prolog after a context switch
|
||||||
|
*/
|
||||||
|
call _PiBeforeBeginThread
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call the actual start of the thread
|
||||||
|
*/
|
||||||
|
movl 4(%esp), %ebx /* Start routine */
|
||||||
|
movl 8(%esp), %eax /* Start context */
|
||||||
|
pushl %eax
|
||||||
|
call *%ebx /* Call the start routine */
|
||||||
|
addl $4, %esp
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Terminate the thread
|
||||||
|
*/
|
||||||
|
pushl %eax
|
||||||
|
call _PsTerminateSystemThread@4
|
||||||
|
addl $4, %esp
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If that fails then bug check
|
||||||
|
*/
|
||||||
|
pushl $0
|
||||||
|
call _KeBugCheck@4
|
||||||
|
addl $4, %esp
|
||||||
|
|
||||||
|
/*
|
||||||
|
* And if that fails then loop
|
||||||
|
*/
|
||||||
|
.1:
|
||||||
|
jmp .1
|
||||||
|
|
||||||
|
|
||||||
_PsBeginThreadWithContextInternal:
|
_PsBeginThreadWithContextInternal:
|
||||||
call _PiBeforeBeginThread
|
/*
|
||||||
popl %eax
|
* This isn't really a function, we are called as the return
|
||||||
popl %eax
|
* address of a context switch
|
||||||
popl %eax
|
*/
|
||||||
popl %eax
|
|
||||||
popl %eax
|
/*
|
||||||
popl %eax
|
* Do the necessary prolog before the context switch
|
||||||
popl %eax
|
*/
|
||||||
addl $112,%esp
|
call _PiBeforeBeginThread
|
||||||
popl %gs
|
|
||||||
; popl %fs
|
/*
|
||||||
movl $TEB_SELECTOR, %ax
|
* Jump to the desired context
|
||||||
movl %ax, %fs
|
*/
|
||||||
popl %es
|
popl %eax /* ContextFlags */
|
||||||
popl %ds
|
popl %eax /* Dr0 */
|
||||||
popl %edi
|
popl %eax /* Dr1 */
|
||||||
popl %esi
|
popl %eax /* Dr2 */
|
||||||
popl %ebx
|
popl %eax /* Dr3 */
|
||||||
popl %edx
|
popl %eax /* Dr6 */
|
||||||
popl %ecx
|
popl %eax /* Dr7 */
|
||||||
popl %eax
|
addl $112,%esp /* FloatSave */
|
||||||
popl %ebp
|
popl %gs
|
||||||
iret
|
addl $4, %esp /* Ignore SegFs */
|
||||||
|
movl $TEB_SELECTOR, %eax /* Set the FS selector */
|
||||||
|
movl %eax, %fs
|
||||||
|
popl %es
|
||||||
|
popl %ds
|
||||||
|
popl %edi
|
||||||
|
popl %esi
|
||||||
|
popl %ebx
|
||||||
|
popl %edx
|
||||||
|
popl %ecx
|
||||||
|
popl %eax
|
||||||
|
popl %ebp
|
||||||
|
iret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <internal/module.h>
|
#include <internal/module.h>
|
||||||
#include <internal/mm.h>
|
#include <internal/mm.h>
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
|
#include <internal/trap.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -72,7 +73,7 @@ static void print_address(PVOID address)
|
||||||
if (address >= current->Base &&
|
if (address >= current->Base &&
|
||||||
address < (current->Base + current->Length))
|
address < (current->Base + current->Length))
|
||||||
{
|
{
|
||||||
DbgPrint("<%S: %x>", current->Name,
|
DbgPrint("<%wZ: %x>", ¤t->Name,
|
||||||
address - current->Base);
|
address - current->Base);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -82,20 +83,8 @@ static void print_address(PVOID address)
|
||||||
DbgPrint("<%x>", address);
|
DbgPrint("<%x>", address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exception_handler(unsigned int edi,
|
ULONG
|
||||||
unsigned int esi, unsigned int ebp,
|
exception_handler(struct trap_frame* tf)
|
||||||
unsigned int esp, unsigned int ebx,
|
|
||||||
unsigned int edx, unsigned int ecx,
|
|
||||||
ULONG eax,
|
|
||||||
unsigned int type,
|
|
||||||
unsigned int ds,
|
|
||||||
unsigned int es,
|
|
||||||
unsigned int fs,
|
|
||||||
unsigned int gs,
|
|
||||||
unsigned int error_code,
|
|
||||||
ULONG eip,
|
|
||||||
unsigned int cs, unsigned int eflags,
|
|
||||||
unsigned int esp0, unsigned int ss0)
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Called by the lowlevel execption handlers to print an amusing
|
* FUNCTION: Called by the lowlevel execption handlers to print an amusing
|
||||||
* message and halt the computer
|
* message and halt the computer
|
||||||
|
@ -133,46 +122,55 @@ static void print_address(PVOID address)
|
||||||
__asm__("movl %%cr2,%0\n\t"
|
__asm__("movl %%cr2,%0\n\t"
|
||||||
: "=d" (cr2));
|
: "=d" (cr2));
|
||||||
|
|
||||||
if (PsGetCurrentThread() != NULL &&
|
if (tf->eflags & (1 << 17))
|
||||||
esp < (ULONG)PsGetCurrentThread()->Tcb.Context.KernelStackBase)
|
|
||||||
{
|
{
|
||||||
DbgPrint("Stack underflow\n");
|
return(KeV86Exception(tf, cr2));
|
||||||
type = 12;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 14)
|
if (PsGetCurrentThread() != NULL &&
|
||||||
|
tf->esp < (ULONG)PsGetCurrentThread()->Tcb.StackLimit)
|
||||||
|
{
|
||||||
|
DbgPrint("Stack underflow\n");
|
||||||
|
tf->type = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tf->type == 14)
|
||||||
{
|
{
|
||||||
__asm__("sti\n\t");
|
__asm__("sti\n\t");
|
||||||
Status = MmPageFault(cs&0xffff,
|
Status = MmPageFault(tf->cs&0xffff,
|
||||||
&eip,
|
&tf->eip,
|
||||||
&eax,
|
&tf->eax,
|
||||||
cr2,
|
cr2,
|
||||||
error_code);
|
tf->error_code);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type==1)
|
|
||||||
|
/*
|
||||||
|
* FIXME: Something better
|
||||||
|
*/
|
||||||
|
if (tf->type==1)
|
||||||
{
|
{
|
||||||
DbgPrint("Trap at CS:EIP %x:%x\n",cs&0xffff,eip);
|
DbgPrint("Trap at CS:EIP %x:%x\n",tf->cs&0xffff,tf->eip);
|
||||||
return;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print out the CPU registers
|
* Print out the CPU registers
|
||||||
*/
|
*/
|
||||||
if (type < 19)
|
if (tf->type < 19)
|
||||||
{
|
{
|
||||||
DbgPrint("%s Exception: %d(%x)\n",TypeStrings[type],type,
|
DbgPrint("%s Exception: %d(%x)\n",TypeStrings[tf->type],tf->type,
|
||||||
error_code&0xffff);
|
tf->error_code&0xffff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("Exception: %d(%x)\n",type,error_code&0xffff);
|
DbgPrint("Exception: %d(%x)\n",tf->type,tf->error_code&0xffff);
|
||||||
}
|
}
|
||||||
DbgPrint("CS:EIP %x:%x ",cs&0xffff,eip);
|
DbgPrint("CS:EIP %x:%x ",tf->cs&0xffff,tf->eip);
|
||||||
print_address((PVOID)eip);
|
print_address((PVOID)tf->eip);
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
__asm__("movl %%cr3,%0\n\t"
|
__asm__("movl %%cr3,%0\n\t"
|
||||||
: "=d" (cr3));
|
: "=d" (cr3));
|
||||||
|
@ -191,29 +189,29 @@ static void print_address(PVOID address)
|
||||||
PsGetCurrentThread()->Cid.UniqueThread);
|
PsGetCurrentThread()->Cid.UniqueThread);
|
||||||
}
|
}
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
DbgPrint("DS %x ES %x FS %x GS %x\n",ds&0xffff,es&0xffff,fs&0xffff,
|
DbgPrint("DS %x ES %x FS %x GS %x\n", tf->ds&0xffff, tf->es&0xffff,
|
||||||
gs&0xfff);
|
tf->fs&0xffff, tf->gs&0xfff);
|
||||||
DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n",eax,ebx,ecx);
|
DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n", tf->eax, tf->ebx, tf->ecx);
|
||||||
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x\n",edx,ebp,esi);
|
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x\n", tf->edx, tf->ebp, tf->esi);
|
||||||
DbgPrint("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
|
DbgPrint("EDI: %.8x EFLAGS: %.8x ", tf->edi, tf->eflags);
|
||||||
if ((cs&0xffff) == KERNEL_CS)
|
if ((tf->cs&0xffff) == KERNEL_CS)
|
||||||
{
|
{
|
||||||
DbgPrint("kESP %.8x ",esp);
|
DbgPrint("kESP %.8x ", tf->esp);
|
||||||
if (PsGetCurrentThread() != NULL)
|
if (PsGetCurrentThread() != NULL)
|
||||||
{
|
{
|
||||||
DbgPrint("kernel stack base %x\n",
|
DbgPrint("kernel stack base %x\n",
|
||||||
PsGetCurrentThread()->Tcb.Context.KernelStackBase);
|
PsGetCurrentThread()->Tcb.StackLimit);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("kernel ESP %.8x\n",esp);
|
DbgPrint("kernel ESP %.8x\n", tf->esp);
|
||||||
}
|
}
|
||||||
if ((cs & 0xffff) == KERNEL_CS)
|
if ((tf->cs & 0xffff) == KERNEL_CS)
|
||||||
{
|
{
|
||||||
DbgPrint("ESP %x\n",esp);
|
DbgPrint("ESP %x\n", tf->esp);
|
||||||
stack = (PULONG) (esp + 24);
|
stack = (PULONG) (tf->esp + 24);
|
||||||
stack = (PULONG)(((ULONG)stack) & (~0x3));
|
stack = (PULONG)(((ULONG)stack) & (~0x3));
|
||||||
|
|
||||||
DbgPrint("stack<%p>: ", stack);
|
DbgPrint("stack<%p>: ", stack);
|
||||||
|
@ -242,8 +240,8 @@ static void print_address(PVOID address)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
DbgPrint("SS:ESP %x:%x\n",ss0,esp0);
|
DbgPrint("SS:ESP %x:%x\n", tf->ss0, tf->esp0);
|
||||||
stack=(PULONG)(esp0);
|
stack=(PULONG)(tf->esp0);
|
||||||
|
|
||||||
DbgPrint("Stack:\n");
|
DbgPrint("Stack:\n");
|
||||||
for (i=0; i<64; i++)
|
for (i=0; i<64; i++)
|
||||||
|
@ -258,11 +256,11 @@ static void print_address(PVOID address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MmIsPagePresent(NULL, (PVOID)eip))
|
if (MmIsPagePresent(NULL, (PVOID)tf->eip))
|
||||||
{
|
{
|
||||||
char instrs[512];
|
char instrs[512];
|
||||||
|
|
||||||
memcpy(instrs, (PVOID)eip, 512);
|
memcpy(instrs, (PVOID)tf->eip, 512);
|
||||||
|
|
||||||
DbgPrint("Instrs: ");
|
DbgPrint("Instrs: ");
|
||||||
|
|
||||||
|
@ -275,13 +273,13 @@ static void print_address(PVOID address)
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
if ((cs&0xffff) == USER_CS &&
|
if ((tf->cs&0xffff) == USER_CS &&
|
||||||
eip < KERNEL_BASE)
|
tf->eip < KERNEL_BASE)
|
||||||
{
|
{
|
||||||
DbgPrint("Killing current task\n");
|
DbgPrint("Killing current task\n");
|
||||||
// for(;;);
|
// for(;;);
|
||||||
KeLowerIrql(PASSIVE_LEVEL);
|
KeLowerIrql(PASSIVE_LEVEL);
|
||||||
if ((cs&0xffff) == USER_CS)
|
if ((tf->cs&0xffff) == USER_CS)
|
||||||
{
|
{
|
||||||
ZwTerminateProcess(NtCurrentProcess(),
|
ZwTerminateProcess(NtCurrentProcess(),
|
||||||
STATUS_NONCONTINUABLE_EXCEPTION);
|
STATUS_NONCONTINUABLE_EXCEPTION);
|
||||||
|
@ -300,7 +298,7 @@ VOID KeDumpStackFrames(PVOID _Stack, ULONG NrFrames)
|
||||||
if (PsGetCurrentThread() != NULL)
|
if (PsGetCurrentThread() != NULL)
|
||||||
{
|
{
|
||||||
DbgPrint("kernel stack base %x\n",
|
DbgPrint("kernel stack base %x\n",
|
||||||
PsGetCurrentThread()->Tcb.Context.KernelStackBase);
|
PsGetCurrentThread()->Tcb.StackLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgPrint("Frames:\n");
|
DbgPrint("Frames:\n");
|
||||||
|
@ -324,18 +322,18 @@ VOID KeDumpStackFrames(PVOID _Stack, ULONG NrFrames)
|
||||||
static void set_system_call_gate(unsigned int sel, unsigned int func)
|
static void set_system_call_gate(unsigned int sel, unsigned int func)
|
||||||
{
|
{
|
||||||
DPRINT("sel %x %d\n",sel,sel);
|
DPRINT("sel %x %d\n",sel,sel);
|
||||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||||
(KERNEL_CS << 16);
|
(KERNEL_CS << 16);
|
||||||
KiIdt[sel].b = 0xef00 + (((int)func)&0xffff0000);
|
KiIdt[sel].b = 0xef00 + (((int)func)&0xffff0000);
|
||||||
DPRINT("idt[sel].b %x\n",KiIdt[sel].b);
|
DPRINT("idt[sel].b %x\n",KiIdt[sel].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_interrupt_gate(unsigned int sel, unsigned int func)
|
static void set_interrupt_gate(unsigned int sel, unsigned int func)
|
||||||
{
|
{
|
||||||
DPRINT("set_interrupt_gate(sel %d, func %x)\n",sel,func);
|
DPRINT("set_interrupt_gate(sel %d, func %x)\n",sel,func);
|
||||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||||
(KERNEL_CS << 16);
|
(KERNEL_CS << 16);
|
||||||
KiIdt[sel].b = 0x8f00 + (((int)func)&0xffff0000);
|
KiIdt[sel].b = 0x8f00 + (((int)func)&0xffff0000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeInitExceptions(void)
|
void KeInitExceptions(void)
|
||||||
|
|
|
@ -23,81 +23,26 @@
|
||||||
|
|
||||||
/* GLOBALS ***************************************************************/
|
/* GLOBALS ***************************************************************/
|
||||||
|
|
||||||
#define NR_TASKS 128
|
|
||||||
|
|
||||||
#define FIRST_TSS_SELECTOR (KERNEL_DS + 0x8)
|
|
||||||
#define FIRST_TSS_OFFSET (FIRST_TSS_SELECTOR / 8)
|
|
||||||
|
|
||||||
static char KiNullLdt[8] = {0,};
|
static char KiNullLdt[8] = {0,};
|
||||||
static unsigned int KiNullLdtSel = 0;
|
|
||||||
static PETHREAD FirstThread = NULL;
|
static PETHREAD FirstThread = NULL;
|
||||||
|
|
||||||
extern ULONG KeSetBaseGdtSelector(ULONG Entry, PVOID Base);
|
extern ULONG KeSetBaseGdtSelector(ULONG Entry, PVOID Base);
|
||||||
|
|
||||||
|
KTSS KiTss;
|
||||||
|
|
||||||
|
extern USHORT KiGdt[];
|
||||||
|
|
||||||
|
extern unsigned int init_stack_top;
|
||||||
|
|
||||||
/* FUNCTIONS **************************************************************/
|
/* FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
VOID HalTaskSwitch(PKTHREAD thread)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Switch tasks
|
|
||||||
* ARGUMENTS:
|
|
||||||
* thread = Thread to switch to
|
|
||||||
* NOTE: This function will not return until the current thread is scheduled
|
|
||||||
* again (possibly never)
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
if (KeGetCurrentIrql() != DISPATCH_LEVEL)
|
|
||||||
{
|
|
||||||
DPRINT1("HalTaskSwitch: Bad IRQL on entry\n");
|
|
||||||
KeBugCheck(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This sequence must be atomic with respect to interrupts on the local
|
|
||||||
* processor because an interrupt handler might want to use current thread
|
|
||||||
* information in the PCR. We wouldn't switch processors because we are
|
|
||||||
* at DISPATCH_LEVEL.
|
|
||||||
*/
|
|
||||||
__asm__("cli\n\t");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the base of the TEB selector to the base of the TEB for the
|
|
||||||
* new thread. This can't be done on the other side of the TSS jump
|
|
||||||
* because the new thread might be starting at different point.
|
|
||||||
*/
|
|
||||||
KeSetBaseGdtSelector(TEB_SELECTOR, thread->Teb);
|
|
||||||
/*
|
|
||||||
* Set the current thread information in the PCR.
|
|
||||||
*/
|
|
||||||
CURRENT_KPCR->CurrentThread = (PVOID)thread;
|
|
||||||
/* Switch to the new thread's context and stack */
|
|
||||||
__asm__("ljmp %0\n\t"
|
|
||||||
: /* No outputs */
|
|
||||||
: "m" (*(((unsigned char *)(&(thread->Context.nr)))-4) )
|
|
||||||
: "ax","dx");
|
|
||||||
/*
|
|
||||||
* Load the PCR selector.
|
|
||||||
*/
|
|
||||||
__asm__("movw %0, %%ax\n\t"
|
|
||||||
"movw %%ax, %%fs\n\t"
|
|
||||||
: /* No outputs */
|
|
||||||
: "i" (PCR_SELECTOR)
|
|
||||||
: "ax");
|
|
||||||
/*
|
|
||||||
* Allow the new thread to use the FPU
|
|
||||||
*/
|
|
||||||
__asm__("clts\n\t");
|
|
||||||
/*
|
|
||||||
* Allow local interrupts again
|
|
||||||
*/
|
|
||||||
__asm__("sti\n\t");
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FLAG_NT (1<<14)
|
#define FLAG_NT (1<<14)
|
||||||
#define FLAG_VM (1<<17)
|
#define FLAG_VM (1<<17)
|
||||||
#define FLAG_IF (1<<9)
|
#define FLAG_IF (1<<9)
|
||||||
#define FLAG_IOPL ((1<<12)+(1<<13))
|
#define FLAG_IOPL ((1<<12)+(1<<13))
|
||||||
|
|
||||||
NTSTATUS KeValidateUserContext(PCONTEXT Context)
|
NTSTATUS
|
||||||
|
KeValidateUserContext(PCONTEXT Context)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Validates a processor context
|
* FUNCTION: Validates a processor context
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -143,13 +88,15 @@ NTSTATUS KeValidateUserContext(PCONTEXT Context)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS HalReleaseTask(PETHREAD Thread)
|
NTSTATUS
|
||||||
|
HalReleaseTask(PETHREAD Thread)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Releases the resource allocated for a thread by
|
* FUNCTION: Releases the resource allocated for a thread by
|
||||||
* HalInitTaskWithContext or HalInitTask
|
* HalInitTaskWithContext or HalInitTask
|
||||||
* NOTE: The thread had better not be running when this is called
|
* NOTE: The thread had better not be running when this is called
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
extern BYTE init_stack[MM_STACK_SIZE];
|
extern BYTE init_stack[MM_STACK_SIZE];
|
||||||
|
|
||||||
KeFreeGdtSelector(Thread->Tcb.Context.nr / 8);
|
KeFreeGdtSelector(Thread->Tcb.Context.nr / 8);
|
||||||
|
@ -161,186 +108,65 @@ NTSTATUS HalReleaseTask(PETHREAD Thread)
|
||||||
{
|
{
|
||||||
ExFreePool(Thread->Tcb.Context.SavedKernelStackBase);
|
ExFreePool(Thread->Tcb.Context.SavedKernelStackBase);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
|
NTSTATUS
|
||||||
/*
|
Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context)
|
||||||
* FUNCTION: Initialize a task with a user mode context
|
|
||||||
* ARGUMENTS:
|
|
||||||
* Thread = Thread to initialize
|
|
||||||
* Context = Processor context to initialize it with
|
|
||||||
* RETURNS: Status
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
unsigned int desc;
|
|
||||||
unsigned int length;
|
|
||||||
unsigned int base;
|
|
||||||
PVOID kernel_stack;
|
|
||||||
NTSTATUS Status;
|
|
||||||
PVOID stack_start;
|
|
||||||
ULONG GdtDesc[2];
|
|
||||||
|
|
||||||
DPRINT("HalInitTaskWithContext(Thread %x, Context %x)\n",
|
|
||||||
Thread,Context);
|
|
||||||
|
|
||||||
assert(sizeof(hal_thread_state)>=0x68);
|
|
||||||
|
|
||||||
if ((Status=KeValidateUserContext(Context))!=STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
length = sizeof(hal_thread_state) - 1;
|
|
||||||
base = (unsigned int)(&(Thread->Tcb.Context));
|
|
||||||
kernel_stack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Setup a TSS descriptor
|
|
||||||
*/
|
|
||||||
GdtDesc[0] = (length & 0xffff) | ((base & 0xffff) << 16);
|
|
||||||
GdtDesc[1] = ((base & 0xff0000)>>16) | 0x8900 | (length & 0xf0000)
|
|
||||||
| (base & 0xff000000);
|
|
||||||
desc = KeAllocateGdtSelector(GdtDesc);
|
|
||||||
if (desc == 0)
|
|
||||||
{
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
stack_start = kernel_stack + MM_STACK_SIZE - sizeof(CONTEXT);
|
|
||||||
|
|
||||||
DPRINT("stack_start %x kernel_stack %x\n",
|
|
||||||
stack_start, kernel_stack);
|
|
||||||
|
|
||||||
Context->SegFs = TEB_SELECTOR;
|
|
||||||
memcpy(stack_start, Context, sizeof(CONTEXT));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the thread context
|
|
||||||
*/
|
|
||||||
memset(&Thread->Tcb.Context,0,sizeof(hal_thread_state));
|
|
||||||
Thread->Tcb.Context.ldt = KiNullLdtSel;
|
|
||||||
Thread->Tcb.Context.eflags = (1<<1) + (1<<9);
|
|
||||||
Thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
|
|
||||||
Thread->Tcb.Context.esp0 = (ULONG)stack_start;
|
|
||||||
Thread->Tcb.Context.ss0 = KERNEL_DS;
|
|
||||||
Thread->Tcb.Context.esp = (ULONG)stack_start;
|
|
||||||
Thread->Tcb.Context.ss = KERNEL_DS;
|
|
||||||
Thread->Tcb.Context.cs = KERNEL_CS;
|
|
||||||
Thread->Tcb.Context.eip = (ULONG)PsBeginThreadWithContextInternal;
|
|
||||||
Thread->Tcb.Context.io_bitmap[0] = 0xff;
|
|
||||||
Thread->Tcb.Context.cr3 = (ULONG)
|
|
||||||
Thread->ThreadsProcess->Pcb.PageTableDirectory;
|
|
||||||
Thread->Tcb.Context.ds = KERNEL_DS;
|
|
||||||
Thread->Tcb.Context.es = KERNEL_DS;
|
|
||||||
Thread->Tcb.Context.fs = KERNEL_DS;
|
|
||||||
Thread->Tcb.Context.gs = KERNEL_DS;
|
|
||||||
|
|
||||||
Thread->Tcb.Context.nr = desc * 8;
|
|
||||||
Thread->Tcb.Context.KernelStackBase = kernel_stack;
|
|
||||||
Thread->Tcb.Context.SavedKernelEsp = 0;
|
|
||||||
Thread->Tcb.Context.SavedKernelStackBase = NULL;
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
PULONG KeGetStackTopThread(PETHREAD Thread)
|
|
||||||
{
|
|
||||||
return((PULONG)(Thread->Tcb.Context.KernelStackBase + MM_STACK_SIZE));
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Initializes the HAL portion of a thread object
|
|
||||||
* ARGUMENTS:
|
|
||||||
* thread = Object describes the thread
|
|
||||||
* fn = Entrypoint for the thread
|
|
||||||
* StartContext = parameter to pass to the thread entrypoint
|
|
||||||
* RETURNS: True if the function succeeded
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
unsigned int desc;
|
|
||||||
unsigned int length = sizeof(hal_thread_state) - 1;
|
|
||||||
unsigned int base = (unsigned int)(&(thread->Tcb.Context));
|
|
||||||
PULONG KernelStack;
|
PULONG KernelStack;
|
||||||
ULONG GdtDesc[2];
|
|
||||||
extern BYTE init_stack[16384];
|
|
||||||
|
|
||||||
DPRINT("HalInitTask(Thread %x, fn %x, StartContext %x)\n",
|
/*
|
||||||
thread,fn,StartContext);
|
* Setup a stack frame for exit from the task switching routine
|
||||||
DPRINT("thread->ThreadsProcess %x\n",thread->ThreadsProcess);
|
*/
|
||||||
|
|
||||||
if (fn != NULL)
|
KernelStack = (PULONG)(Thread->KernelStack - ((4 * 5) + sizeof(CONTEXT)));
|
||||||
{
|
/* FIXME: Add initial floating point information */
|
||||||
KernelStack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
|
/* FIXME: Add initial debugging information */
|
||||||
}
|
KernelStack[0] = 0; /* EDI */
|
||||||
else
|
KernelStack[1] = 0; /* ESI */
|
||||||
{
|
KernelStack[2] = 0; /* EBX */
|
||||||
KernelStack = (PULONG)init_stack;
|
KernelStack[3] = 0; /* EBP */
|
||||||
}
|
KernelStack[4] = (ULONG)PsBeginThreadWithContextInternal; /* EIP */
|
||||||
|
memcpy((VOID*)&KernelStack[5], (VOID*)Context, sizeof(CONTEXT));
|
||||||
|
Thread->KernelStack = (VOID*)KernelStack;
|
||||||
|
|
||||||
/*
|
return(STATUS_SUCCESS);
|
||||||
* Make sure
|
|
||||||
*/
|
|
||||||
assert(sizeof(hal_thread_state)>=0x68);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Setup a TSS descriptor
|
|
||||||
*/
|
|
||||||
GdtDesc[0] = (length & 0xffff) | ((base & 0xffff) << 16);
|
|
||||||
GdtDesc[1] = ((base & 0xff0000)>>16) | 0x8900 | (length & 0xf0000)
|
|
||||||
| (base & 0xff000000);
|
|
||||||
desc = KeAllocateGdtSelector(GdtDesc);
|
|
||||||
if (desc == 0)
|
|
||||||
{
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// DPRINT("sizeof(descriptor) %d\n",sizeof(descriptor));
|
|
||||||
// DPRINT("desc %d\n",desc);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the stack for the thread (including the two arguments to
|
|
||||||
* the general start routine).
|
|
||||||
*/
|
|
||||||
if (fn != NULL)
|
|
||||||
{
|
|
||||||
KernelStack[3071] = (unsigned int)StartContext;
|
|
||||||
KernelStack[3070] = (unsigned int)fn;
|
|
||||||
KernelStack[3069] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the thread context
|
|
||||||
*/
|
|
||||||
memset(&thread->Tcb.Context,0,sizeof(hal_thread_state));
|
|
||||||
thread->Tcb.Context.ldt = KiNullLdtSel;
|
|
||||||
thread->Tcb.Context.eflags = (1<<1)+(1<<9);
|
|
||||||
thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
|
|
||||||
thread->Tcb.Context.esp0 = (ULONG)&KernelStack[3069];
|
|
||||||
thread->Tcb.Context.ss0 = KERNEL_DS;
|
|
||||||
thread->Tcb.Context.esp = (ULONG)&KernelStack[3069];
|
|
||||||
thread->Tcb.Context.ss = KERNEL_DS;
|
|
||||||
thread->Tcb.Context.cs = KERNEL_CS;
|
|
||||||
thread->Tcb.Context.eip = (ULONG)PsBeginThread;
|
|
||||||
thread->Tcb.Context.io_bitmap[0] = 0xff;
|
|
||||||
thread->Tcb.Context.cr3 = (ULONG)
|
|
||||||
thread->ThreadsProcess->Pcb.PageTableDirectory;
|
|
||||||
thread->Tcb.Context.ds = KERNEL_DS;
|
|
||||||
thread->Tcb.Context.es = KERNEL_DS;
|
|
||||||
thread->Tcb.Context.fs = KERNEL_DS;
|
|
||||||
thread->Tcb.Context.gs = KERNEL_DS;
|
|
||||||
thread->Tcb.Context.nr = desc * 8;
|
|
||||||
thread->Tcb.Context.KernelStackBase = KernelStack;
|
|
||||||
thread->Tcb.Context.SavedKernelEsp = 0;
|
|
||||||
thread->Tcb.Context.SavedKernelStackBase = NULL;
|
|
||||||
DPRINT("Allocated %x\n",desc*8);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HalInitFirstTask(PETHREAD thread)
|
NTSTATUS
|
||||||
|
Ke386InitThread(PKTHREAD Thread,
|
||||||
|
PKSTART_ROUTINE StartRoutine,
|
||||||
|
PVOID StartContext)
|
||||||
|
/*
|
||||||
|
* Initialize a thread
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PULONG KernelStack;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup a stack frame for exit from the task switching routine
|
||||||
|
*/
|
||||||
|
|
||||||
|
KernelStack = (PULONG)(Thread->KernelStack - (8*4));
|
||||||
|
/* FIXME: Add initial floating point information */
|
||||||
|
/* FIXME: Add initial debugging information */
|
||||||
|
KernelStack[0] = 0; /* EDI */
|
||||||
|
KernelStack[1] = 0; /* ESI */
|
||||||
|
KernelStack[2] = 0; /* EBX */
|
||||||
|
KernelStack[3] = 0; /* EBP */
|
||||||
|
KernelStack[4] = (ULONG)PsBeginThread; /* EIP */
|
||||||
|
KernelStack[5] = 0; /* Return EIP */
|
||||||
|
KernelStack[6] = (ULONG)StartRoutine; /* First argument to PsBeginThread */
|
||||||
|
KernelStack[7] = (ULONG)StartContext; /* Second argument to PsBeginThread */
|
||||||
|
Thread->KernelStack = (VOID*)KernelStack;
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
HalInitFirstTask(PETHREAD thread)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Called to setup the HAL portion of a thread object for the
|
* FUNCTION: Called to setup the HAL portion of a thread object for the
|
||||||
* initial thread
|
* initial thread
|
||||||
|
@ -348,28 +174,52 @@ void HalInitFirstTask(PETHREAD thread)
|
||||||
{
|
{
|
||||||
ULONG base;
|
ULONG base;
|
||||||
ULONG length;
|
ULONG length;
|
||||||
ULONG desc;
|
|
||||||
ULONG GdtDesc[2];
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up an a descriptor for the LDT
|
||||||
|
*/
|
||||||
memset(KiNullLdt, 0, sizeof(KiNullLdt));
|
memset(KiNullLdt, 0, sizeof(KiNullLdt));
|
||||||
base = (unsigned int)&KiNullLdt;
|
base = (unsigned int)&KiNullLdt;
|
||||||
length = sizeof(KiNullLdt) - 1;
|
length = sizeof(KiNullLdt) - 1;
|
||||||
GdtDesc[0] = (length & 0xffff) | ((base & 0xffff) << 16);
|
|
||||||
GdtDesc[1] = ((base & 0xff0000)>>16) | 0x8200 | (length & 0xf0000)
|
KiGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
|
||||||
| (base & 0xff000000);
|
KiGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
|
||||||
desc = KeAllocateGdtSelector(GdtDesc);
|
KiGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200;
|
||||||
KiNullLdtSel = desc*8;
|
KiGdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
|
||||||
|
((base & 0xFF000000) >> 16);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the thread context
|
* Set up a descriptor for the TSS
|
||||||
*/
|
*/
|
||||||
HalInitTask(thread,NULL,NULL);
|
memset(&KiTss, 0, sizeof(KiTss));
|
||||||
|
base = (unsigned int)&KiTss;
|
||||||
|
length = sizeof(KiTss) - 1;
|
||||||
|
|
||||||
|
KiGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
|
||||||
|
KiGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
|
||||||
|
KiGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900;
|
||||||
|
KiGdt[(TSS_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
|
||||||
|
((base & 0xFF000000) >> 16);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the TSS
|
||||||
|
*/
|
||||||
|
KiTss.Esp0 = (ULONG)&init_stack_top;
|
||||||
|
KiTss.Ss0 = KERNEL_DS;
|
||||||
|
KiTss.IoMapBase = FIELD_OFFSET(KTSS, IoBitmap);
|
||||||
|
KiTss.IoBitmap[0] = 0xFF;
|
||||||
|
KiTss.Ldt = LDT_SELECTOR;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load the task register
|
* Load the task register
|
||||||
*/
|
*/
|
||||||
__asm__("ltr %%ax"
|
__asm__("ltr %%ax"
|
||||||
: /* no output */
|
: /* no output */
|
||||||
: "a" (thread->Tcb.Context.nr));
|
: "a" (TSS_SELECTOR));
|
||||||
FirstThread = thread;
|
FirstThread = thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,34 +16,40 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: trap.s,v 1.5 2000/12/10 23:42:00 dwelch Exp $
|
/* $Id: trap.s,v 1.6 2000/12/23 02:37:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/hal/x86/trap.s
|
* FILE: ntoskrnl/ke/i386/trap.s
|
||||||
* PURPOSE: Exception handlers
|
* PURPOSE: Exception handlers
|
||||||
* PROGRAMMER: David Welch (david.welch@seh.ox.ac.uk)
|
* PROGRAMMER: David Welch <welch@cwcom.net>
|
||||||
* UPDATE HISTORY:
|
|
||||||
* ???
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <ddk/status.h>
|
#include <ddk/status.h>
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
#include <ddk/defines.h>
|
#include <ddk/defines.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Epilog for exception handlers
|
* Epilog for exception handlers
|
||||||
*/
|
*/
|
||||||
_exception_handler_epilog:
|
_exception_handler_epilog:
|
||||||
popa
|
cmpl $1, %eax /* Check for v86 recovery */
|
||||||
addl $4, %esp
|
jne _exception_handler_ret
|
||||||
popl %ds
|
jmp _KiV86Complete
|
||||||
|
_exception_handler_ret:
|
||||||
|
addl $4, %esp /* Ignore pointer to trap frame */
|
||||||
|
popa /* Restore general purpose registers */
|
||||||
|
addl $4, %esp /* Ignore trap code */
|
||||||
|
popl %ds /* Restore segment registers */
|
||||||
popl %es
|
popl %es
|
||||||
popl %fs
|
popl %fs
|
||||||
popl %gs
|
popl %gs
|
||||||
addl $4, %esp
|
addl $4, %esp /* Ignore error code */
|
||||||
iret
|
iret /* Return from interrupt */
|
||||||
|
|
||||||
.globl _exception_handler0
|
.globl _exception_handler0
|
||||||
_exception_handler0:
|
_exception_handler0:
|
||||||
|
@ -59,405 +65,307 @@ _exception_handler0:
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
|
pushl %esp
|
||||||
call _exception_handler
|
call _exception_handler
|
||||||
jmp _exception_handler_epilog
|
jmp _exception_handler_epilog
|
||||||
|
|
||||||
.globl _exception_handler1
|
.globl _exception_handler1
|
||||||
_exception_handler1:
|
_exception_handler1:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $1
|
pushl $1
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
|
|
||||||
.globl _exception_handler2
|
.globl _exception_handler2
|
||||||
_exception_handler2:
|
_exception_handler2:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $2
|
pushl $2
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler3
|
.globl _exception_handler3
|
||||||
_exception_handler3:
|
_exception_handler3:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $3
|
pushl $3
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler4
|
.globl _exception_handler4
|
||||||
_exception_handler4:
|
_exception_handler4:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $4
|
pushl $4
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler5
|
.globl _exception_handler5
|
||||||
_exception_handler5:
|
_exception_handler5:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $5
|
pushl $5
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler6
|
.globl _exception_handler6
|
||||||
_exception_handler6:
|
_exception_handler6:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $6
|
pushl $6
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler7
|
.globl _exception_handler7
|
||||||
_exception_handler7:
|
_exception_handler7:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $7
|
pushl $7
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler8
|
.globl _exception_handler8
|
||||||
_exception_handler8:
|
_exception_handler8:
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $8
|
pushl $8
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler9
|
.globl _exception_handler9
|
||||||
_exception_handler9:
|
_exception_handler9:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $1
|
pushl $9
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler10
|
.globl _exception_handler10
|
||||||
_exception_handler10:
|
_exception_handler10:
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $10
|
pushl $10
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler11
|
.globl _exception_handler11
|
||||||
_exception_handler11:
|
_exception_handler11:
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $1
|
pushl $11
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler12
|
.globl _exception_handler12
|
||||||
_exception_handler12:
|
_exception_handler12:
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $1
|
pushl $12
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler13
|
.globl _exception_handler13
|
||||||
_exception_handler13:
|
_exception_handler13:
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $1
|
pushl $13
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler14
|
.globl _exception_handler14
|
||||||
_exception_handler14:
|
_exception_handler14:
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $14
|
pushl $14
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler15
|
.globl _exception_handler15
|
||||||
_exception_handler15:
|
_exception_handler15:
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $15
|
pushl $15
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler16
|
.globl _exception_handler16
|
||||||
_exception_handler16:
|
_exception_handler16:
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl $16
|
pushl $16
|
||||||
pusha
|
pusha
|
||||||
movw $KERNEL_DS,%ax
|
movw $KERNEL_DS,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %ax,%es
|
movw %ax,%es
|
||||||
movw %ax,%fs
|
movw %ax,%fs
|
||||||
movw %ax,%gs
|
movw %ax,%gs
|
||||||
call _exception_handler
|
pushl %esp
|
||||||
popa
|
call _exception_handler
|
||||||
addl $4,%esp
|
jmp _exception_handler_epilog
|
||||||
popl %ds
|
|
||||||
popl %es
|
|
||||||
popl %fs
|
|
||||||
popl %gs
|
|
||||||
addl $4,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
.globl _exception_handler_unknown
|
.globl _exception_handler_unknown
|
||||||
_exception_handler_unknown:
|
_exception_handler_unknown:
|
||||||
pushl $0
|
pushl $0
|
||||||
pushl %gs
|
pushl %gs
|
||||||
pushl %fs
|
pushl %fs
|
||||||
pushl %es
|
pushl %es
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl %ds
|
pushl $0xff
|
||||||
pushl $0xff
|
pusha
|
||||||
pusha
|
movw $KERNEL_DS,%ax
|
||||||
movw $KERNEL_DS,%ax
|
movw %ax,%ds
|
||||||
movw %ax,%ds
|
movw %ax,%es
|
||||||
movw %ax,%es
|
movw %ax,%fs
|
||||||
movw %ax,%fs
|
movw %ax,%gs
|
||||||
movw %ax,%gs
|
pushl %esp
|
||||||
call _exception_handler
|
call _exception_handler
|
||||||
popa
|
jmp _exception_handler_epilog
|
||||||
addl $8,%esp
|
|
||||||
iret
|
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
|
#include <ddk/i386/tss.h>
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
@ -50,11 +51,35 @@ _Ki386ContextSwitch:
|
||||||
pushl %edi
|
pushl %edi
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: Save debugging state
|
* This is a critical section for this processor.
|
||||||
|
*/
|
||||||
|
cli
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the pointer to the new thread
|
||||||
|
*/
|
||||||
|
movl 8(%ebp), %ebx
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the base of the TEB selector to the base of the TEB for
|
||||||
|
* this thread.
|
||||||
|
*/
|
||||||
|
pushl KTHREAD_TEB(%ebx)
|
||||||
|
pushl $TEB_SELECTOR
|
||||||
|
call _KeSetBaseGdtSelector
|
||||||
|
addl $8, %esp
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the current thread information in the PCR
|
||||||
|
*/
|
||||||
|
movl %ebx, (KPCR_BASE + KPCR_CURRENT_THREAD)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME: Save debugging state.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: Save floating point state
|
* FIXME: Save floating point state.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -65,6 +90,25 @@ _Ki386ContextSwitch:
|
||||||
movl 8(%ebp), %ebx
|
movl 8(%ebp), %ebx
|
||||||
movl KTHREAD_KERNEL_STACK(%ebx), %esp
|
movl KTHREAD_KERNEL_STACK(%ebx), %esp
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the stack pointer in this processors TSS
|
||||||
|
*/
|
||||||
|
movl KTHREAD_INITIAL_STACK(%ebx), %eax
|
||||||
|
movl %eax, (_KiTss + KTSS_ESP0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change the address space
|
||||||
|
*/
|
||||||
|
movl ETHREAD_THREADS_PROCESS(%ebx), %ebx
|
||||||
|
movl KPROCESS_PAGE_TABLE_DIRECTORY(%ebx), %eax
|
||||||
|
movl %eax, %cr3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the PCR selector
|
||||||
|
*/
|
||||||
|
movl $PCR_SELECTOR, %eax
|
||||||
|
movl %eax, %fs
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: Restore floating point state
|
* FIXME: Restore floating point state
|
||||||
*/
|
*/
|
||||||
|
@ -73,12 +117,17 @@ _Ki386ContextSwitch:
|
||||||
* FIXME: Restore debugging state
|
* FIXME: Restore debugging state
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exit the critical section
|
||||||
|
*/
|
||||||
|
sti
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Restore the saved register and exit
|
* Restore the saved register and exit
|
||||||
*/
|
*/
|
||||||
popl %edi
|
popl %edi
|
||||||
popl %esi
|
popl %esi
|
||||||
popl %ebx
|
popl %ebx
|
||||||
movl %ebp, %esp
|
|
||||||
popl %esp
|
popl %ebp
|
||||||
ret
|
ret
|
||||||
|
|
211
reactos/ntoskrnl/ke/i386/v86m.c
Normal file
211
reactos/ntoskrnl/ke/i386/v86m.c
Normal file
|
@ -0,0 +1,211 @@
|
||||||
|
/*
|
||||||
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/ke/i386/v86m.c
|
||||||
|
* PURPOSE: Support for v86 mode
|
||||||
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/v86m.h>
|
||||||
|
#include <internal/trap.h>
|
||||||
|
#include <internal/mm.h>
|
||||||
|
#include <internal/i386/segment.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
#define INTERRUPT_FLAG (1 << 9)
|
||||||
|
#define TRAP_FLAG (1 << 8)
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
KeV86GPF(struct trap_frame* tf)
|
||||||
|
{
|
||||||
|
PUCHAR ip;
|
||||||
|
PUSHORT sp;
|
||||||
|
|
||||||
|
ip = (PUCHAR)((tf->cs & 0xFFFF) * 16 + (tf->eip & 0xFFFF));
|
||||||
|
sp = (PUSHORT)((tf->ss0 & 0xFFFF) * 16 + (tf->esp & 0xFFFF));
|
||||||
|
|
||||||
|
switch (ip[0])
|
||||||
|
{
|
||||||
|
/* Int nn */
|
||||||
|
case 0xCD:
|
||||||
|
{
|
||||||
|
unsigned int inum;
|
||||||
|
unsigned int entry;
|
||||||
|
|
||||||
|
inum = ip[1];
|
||||||
|
entry = ((unsigned int *)0)[inum];
|
||||||
|
|
||||||
|
tf->esp0 = tf->esp0 - 6;
|
||||||
|
sp = sp - 6;
|
||||||
|
|
||||||
|
sp[0] = (tf->eip & 0xFFFF) + 2;
|
||||||
|
sp[1] = tf->cs & 0xFFFF;
|
||||||
|
sp[2] = tf->eflags & 0xFFFF;
|
||||||
|
if (tf->regs->Vif == 1)
|
||||||
|
{
|
||||||
|
sp[2] = sp[2] | INTERRUPT_FLAG;
|
||||||
|
}
|
||||||
|
tf->eip = entry & 0xFFFF;
|
||||||
|
tf->cs = entry >> 16;
|
||||||
|
tf->eflags = tf->eflags & (~TRAP_FLAG);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
KeV86Exception(struct trap_frame* tf, ULONG address)
|
||||||
|
{
|
||||||
|
PVOID Ip;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if we have reached the recovery instruction
|
||||||
|
*/
|
||||||
|
Ip = (PVOID)((tf->cs & 0xFFFF) * 16 + (tf->eip & 0xFFFF));
|
||||||
|
if (tf->type == 6 &&
|
||||||
|
memcmp(Ip, tf->regs->RecoveryInstruction, 4) == 0 &&
|
||||||
|
(tf->cs * 16 + tf->eip) == tf->regs->RecoveryAddress)
|
||||||
|
{
|
||||||
|
*tf->regs->PStatus = STATUS_SUCCESS;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle the exceptions
|
||||||
|
*/
|
||||||
|
switch (tf->type)
|
||||||
|
{
|
||||||
|
/* Divide error */
|
||||||
|
case 0:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Single step */
|
||||||
|
case 1:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* NMI */
|
||||||
|
case 2:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Breakpoint */
|
||||||
|
case 3:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Overflow */
|
||||||
|
case 4:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Array bounds check */
|
||||||
|
case 5:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Invalid opcode */
|
||||||
|
case 6:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Device not available */
|
||||||
|
case 7:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Double fault */
|
||||||
|
case 8:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Intel reserved */
|
||||||
|
case 9:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Invalid TSS */
|
||||||
|
case 10:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Segment not present */
|
||||||
|
case 11:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Stack fault */
|
||||||
|
case 12:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* General protection fault */
|
||||||
|
case 13:
|
||||||
|
return(KeV86GPF(tf));
|
||||||
|
|
||||||
|
/* Page fault */
|
||||||
|
case 14:
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = MmPageFault(USER_CS,
|
||||||
|
&tf->eip,
|
||||||
|
NULL,
|
||||||
|
address,
|
||||||
|
tf->error_code);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Intel reserved */
|
||||||
|
case 15:
|
||||||
|
case 16:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
/* Alignment check */
|
||||||
|
case 17:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
default:
|
||||||
|
*tf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,13 +24,16 @@
|
||||||
* Created 09/10/00
|
* Created 09/10/00
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <internal/vm86.h>
|
#include <internal/v86m.h>
|
||||||
|
#include <ddk/i386/tss.h>
|
||||||
|
#include <internal/trap.h>
|
||||||
|
|
||||||
.globl _Ki386RetToV86Mode
|
.globl _Ki386RetToV86Mode
|
||||||
|
.globl _KiV86Complete
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NTSTATUS Ki386RetToV86Mode(KV86M_REGISTERS* in_regs,
|
* VOID Ki386RetToV86Mode(KV86M_REGISTERS* InRegs,
|
||||||
* KV86M_REGISTERS* out_regs);
|
* KV86M_REGISTERS* OutRegs);
|
||||||
*
|
*
|
||||||
* Starts in v86 mode with the registers set to the
|
* Starts in v86 mode with the registers set to the
|
||||||
* specified values.
|
* specified values.
|
||||||
|
@ -57,36 +60,42 @@ _Ki386RetToV86Mode:
|
||||||
*/
|
*/
|
||||||
pushl %ebp
|
pushl %ebp
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Save a pointer to IN_REGS which the v86m exception handler will
|
||||||
|
* use to handle exceptions
|
||||||
|
*/
|
||||||
|
pushl %ebx
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The stack used for handling exceptions from v86 mode in this thread
|
* The stack used for handling exceptions from v86 mode in this thread
|
||||||
* will be the current stack adjusted so we don't overwrite the
|
* will be the current stack adjusted so we don't overwrite the
|
||||||
* existing stack frames
|
* existing stack frames
|
||||||
*/
|
*/
|
||||||
movl %esp, TSS_ESP0(%esi)
|
movl %esp, KTSS_ESP0(%esi)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create the stack frame for an iret to v86 mode
|
* Create the stack frame for an iret to v86 mode
|
||||||
*/
|
*/
|
||||||
pushl GS(%ebx)
|
pushl KV86M_REGISTERS_GS(%ebx)
|
||||||
pushl FS(%ebx)
|
pushl KV86M_REGISTERS_FS(%ebx)
|
||||||
pushl DS(%ebx)
|
pushl KV86M_REGISTERS_DS(%ebx)
|
||||||
pushl ES(%ebx)
|
pushl KV86M_REGISTERS_ES(%ebx)
|
||||||
pushl SS(%ebx)
|
pushl KV86M_REGISTERS_SS(%ebx)
|
||||||
pushl ESP(%ebx)
|
pushl KV86M_REGISTERS_ESP(%ebx)
|
||||||
pushl EFLAGS(%ebx)
|
pushl KV86M_REGISTERS_EFLAGS(%ebx)
|
||||||
pushl CS(%ebx)
|
pushl KV86M_REGISTERS_CS(%ebx)
|
||||||
pushl EIP(%ebx)
|
pushl KV86M_REGISTERS_EIP(%ebx)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the CPU registers
|
* Setup the CPU registers
|
||||||
*/
|
*/
|
||||||
movl EAX(%ebx), %eax
|
movl KV86M_REGISTERS_EAX(%ebx), %eax
|
||||||
movl ECX(%ebx), %ecx
|
movl KV86M_REGISTERS_ECX(%ebx), %ecx
|
||||||
movl EDX(%ebx), %edx
|
movl KV86M_REGISTERS_EDX(%ebx), %edx
|
||||||
movl ESI(%ebx), %esi
|
movl KV86M_REGISTERS_ESI(%ebx), %esi
|
||||||
movl EDI(%ebx), %edi
|
movl KV86M_REGISTERS_EDI(%ebx), %edi
|
||||||
movl EBP(%ebx), %ebp
|
movl KV86M_REGISTERS_EBP(%ebx), %ebp
|
||||||
movl EBX(%ebx), %ebx
|
movl KV86M_REGISTERS_EBX(%ebx), %ebx
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go to v86 mode
|
* Go to v86 mode
|
||||||
|
@ -98,40 +107,41 @@ _Ki386RetToV86Mode:
|
||||||
* an exception handler with the registers at the point of the
|
* an exception handler with the registers at the point of the
|
||||||
* exception on the stack.
|
* exception on the stack.
|
||||||
*/
|
*/
|
||||||
_vm86_complete:
|
_KiV86Complete:
|
||||||
addl $4, %esp /* Ignore pointer to registers */
|
addl $4, %esp /* Ignore pointer to trap frame */
|
||||||
addl $4, %esp /* Ignore exception number */
|
|
||||||
|
|
||||||
/* Get a pointer to the vm86_registers structure */
|
/* Restore the original ebp */
|
||||||
movl _vm86_old_ebp, %ebp
|
movl TF_ORIG_EBP(%esp), %ebp
|
||||||
movl 8(%ebp), %ebx
|
|
||||||
|
|
||||||
/* Save the vm86 registers into the vm86_registers structure */
|
/* Get a pointer to the OUT_REGS structure */
|
||||||
popl EBP(%ebx)
|
movl 12(%ebp), %ebx
|
||||||
popl EDI(%ebx)
|
|
||||||
popl ESI(%ebx)
|
/* Save the vm86 registers into the OUT_REGS structure */
|
||||||
popl EDX(%ebx)
|
popl KV86M_REGISTERS_EDI(%ebx)
|
||||||
popl ECX(%ebx)
|
popl KV86M_REGISTERS_ESI(%ebx)
|
||||||
popl EBX(%ebx)
|
popl KV86M_REGISTERS_EBP(%ebx)
|
||||||
popl EAX(%ebx)
|
popl KV86M_REGISTERS_EBX(%ebx)
|
||||||
|
popl KV86M_REGISTERS_EDX(%ebx)
|
||||||
|
popl KV86M_REGISTERS_ECX(%ebx)
|
||||||
|
popl KV86M_REGISTERS_EAX(%ebx)
|
||||||
addl $16, %esp /* Ignore 32-bit segment registers */
|
addl $16, %esp /* Ignore 32-bit segment registers */
|
||||||
addl $4, %esp /* Ignore error code */
|
addl $4, %esp /* Ignore error code */
|
||||||
|
|
||||||
popl EIP(%ebx)
|
popl KV86M_REGISTERS_EIP(%ebx)
|
||||||
popl CS(%ebx)
|
popl KV86M_REGISTERS_CS(%ebx)
|
||||||
popl EFLAGS(%ebx)
|
popl KV86M_REGISTERS_EFLAGS(%ebx)
|
||||||
popl ESP(%ebx)
|
popl KV86M_REGISTERS_ESP(%ebx)
|
||||||
popl SS(%ebx)
|
popl KV86M_REGISTERS_SS(%ebx)
|
||||||
popl ES(%ebx)
|
popl KV86M_REGISTERS_ES(%ebx)
|
||||||
popl DS(%ebx)
|
popl KV86M_REGISTERS_DS(%ebx)
|
||||||
popl FS(%ebx)
|
popl KV86M_REGISTERS_FS(%ebx)
|
||||||
popl GS(%ebx)
|
popl KV86M_REGISTERS_GS(%ebx)
|
||||||
|
|
||||||
/* Swap back to the stack */
|
/* Ignore IN_REGS pointer */
|
||||||
cli
|
addl $4, %esp
|
||||||
movl _vm86_old_esp, %esp
|
|
||||||
sti
|
/* Ignore ebp restored above */
|
||||||
movl _vm86_old_ebp, %ebp
|
addl $4, %esp
|
||||||
|
|
||||||
/* Return to caller */
|
/* Return to caller */
|
||||||
popa
|
popa
|
||||||
|
@ -140,3 +150,7 @@ _vm86_complete:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS kernel
|
* ReactOS kernel
|
||||||
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -42,12 +42,14 @@ PiTimeoutThread(struct _KDPC Dpc, PVOID Context, PVOID Arg1, PVOID Arg2);
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread)
|
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Initialize the microkernel state of the thread
|
* FUNCTION: Initialize the microkernel state of the thread
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PVOID KernelStack;
|
PVOID KernelStack;
|
||||||
|
extern unsigned int init_stack_top;
|
||||||
|
extern unsigned int init_stack;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
DbgPrint("Thread %x &Thread->MutantListHead %x &Thread->TrapFrame %x "
|
DbgPrint("Thread %x &Thread->MutantListHead %x &Thread->TrapFrame %x "
|
||||||
|
@ -61,15 +63,26 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread)
|
||||||
sizeof(ETHREAD),
|
sizeof(ETHREAD),
|
||||||
FALSE);
|
FALSE);
|
||||||
InitializeListHead(&Thread->MutantListHead);
|
InitializeListHead(&Thread->MutantListHead);
|
||||||
KernelStack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
|
if (!First)
|
||||||
Thread->InitialStack = KernelStack + MM_STACK_SIZE;
|
{
|
||||||
Thread->StackLimit = (ULONG)KernelStack;
|
KernelStack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
|
||||||
|
Thread->InitialStack = KernelStack + MM_STACK_SIZE;
|
||||||
|
Thread->StackBase = KernelStack + MM_STACK_SIZE;
|
||||||
|
Thread->StackLimit = (ULONG)KernelStack;
|
||||||
|
Thread->KernelStack = KernelStack + MM_STACK_SIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread->InitialStack = (PVOID)&init_stack_top;
|
||||||
|
Thread->StackBase = (PVOID)&init_stack_top;
|
||||||
|
Thread->StackLimit = (ULONG)&init_stack;
|
||||||
|
Thread->KernelStack = (PVOID)&init_stack;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* The Native API function will initialize the TEB field later
|
* The Native API function will initialize the TEB field later
|
||||||
*/
|
*/
|
||||||
Thread->Teb = NULL;
|
Thread->Teb = NULL;
|
||||||
Thread->TlsArray = NULL;
|
Thread->TlsArray = NULL;
|
||||||
Thread->KernelStack = KernelStack + MM_STACK_SIZE;
|
|
||||||
Thread->DebugActive = 0;
|
Thread->DebugActive = 0;
|
||||||
Thread->State = THREAD_STATE_SUSPENDED;
|
Thread->State = THREAD_STATE_SUSPENDED;
|
||||||
Thread->Alerted[0] = 0;
|
Thread->Alerted[0] = 0;
|
||||||
|
@ -127,8 +140,8 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread)
|
||||||
Thread->LargeStack = 0;
|
Thread->LargeStack = 0;
|
||||||
Thread->ResourceIndex = 0;
|
Thread->ResourceIndex = 0;
|
||||||
Thread->PreviousMode = KernelMode;
|
Thread->PreviousMode = KernelMode;
|
||||||
Thread->KernelTime.QuadPart = 0;
|
Thread->KernelTime = 0;
|
||||||
Thread->UserTime.QuadPart = 0;
|
Thread->UserTime = 0;
|
||||||
memset(&Thread->SavedApcState, 0, sizeof(KAPC_STATE));
|
memset(&Thread->SavedApcState, 0, sizeof(KAPC_STATE));
|
||||||
Thread->Alertable = 1;
|
Thread->Alertable = 1;
|
||||||
Thread->ApcStateIndex = 0;
|
Thread->ApcStateIndex = 0;
|
||||||
|
@ -156,3 +169,4 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: main.c,v 1.67 2000/12/20 18:43:13 jean Exp $
|
/* $Id: main.c,v 1.68 2000/12/23 02:37:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -361,7 +361,8 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
|
void
|
||||||
|
_main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Called by the boot loader to start the kernel
|
* FUNCTION: Called by the boot loader to start the kernel
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.5 2000/07/04 08:52:40 dwelch Exp $
|
/* $Id: process.c,v 1.6 2000/12/23 02:37:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -21,11 +21,8 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
KeAttachProcess (PEPROCESS Process)
|
||||||
KeAttachProcess (
|
|
||||||
PEPROCESS Process
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
PETHREAD CurrentThread;
|
PETHREAD CurrentThread;
|
||||||
|
@ -46,7 +43,6 @@ KeAttachProcess (
|
||||||
CurrentThread->OldProcess = PsGetCurrentProcess();
|
CurrentThread->OldProcess = PsGetCurrentProcess();
|
||||||
CurrentThread->ThreadsProcess = Process;
|
CurrentThread->ThreadsProcess = Process;
|
||||||
PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.PageTableDirectory;
|
PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.PageTableDirectory;
|
||||||
CurrentThread->Tcb.Context.cr3 = PageDir;
|
|
||||||
DPRINT("Switching process context to %x\n",PageDir)
|
DPRINT("Switching process context to %x\n",PageDir)
|
||||||
__asm__("movl %0,%%cr3\n\t"
|
__asm__("movl %0,%%cr3\n\t"
|
||||||
: /* no inputs */
|
: /* no inputs */
|
||||||
|
@ -56,11 +52,8 @@ KeAttachProcess (
|
||||||
KeLowerIrql(oldlvl);
|
KeLowerIrql(oldlvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
KeDetachProcess (VOID)
|
||||||
KeDetachProcess (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
PETHREAD CurrentThread;
|
PETHREAD CurrentThread;
|
||||||
|
@ -81,7 +74,6 @@ KeDetachProcess (
|
||||||
CurrentThread->ThreadsProcess = CurrentThread->OldProcess;
|
CurrentThread->ThreadsProcess = CurrentThread->OldProcess;
|
||||||
CurrentThread->OldProcess = NULL;
|
CurrentThread->OldProcess = NULL;
|
||||||
PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.PageTableDirectory;
|
PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.PageTableDirectory;
|
||||||
CurrentThread->Tcb.Context.cr3 = PageDir;
|
|
||||||
__asm__("movl %0,%%cr3\n\t"
|
__asm__("movl %0,%%cr3\n\t"
|
||||||
: /* no inputs */
|
: /* no inputs */
|
||||||
: "r" (PageDir));
|
: "r" (PageDir));
|
||||||
|
|
|
@ -25,11 +25,21 @@
|
||||||
|
|
||||||
static PVOID SystemDllEntryPoint = NULL;
|
static PVOID SystemDllEntryPoint = NULL;
|
||||||
static PVOID SystemDllApcDispatcher = NULL;
|
static PVOID SystemDllApcDispatcher = NULL;
|
||||||
//static PVOID SystemDllCallbackDispatcher = NULL;
|
static PVOID SystemDllCallbackDispatcher = NULL;
|
||||||
//static PVOID SystemDllExceptionDispatcher = NULL;
|
static PVOID SystemDllExceptionDispatcher = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
PVOID LdrpGetSystemDllExceptionDispatcher(VOID)
|
||||||
|
{
|
||||||
|
return(SystemDllExceptionDispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID LdrpGetSystemDllCallbackDispatcher(VOID)
|
||||||
|
{
|
||||||
|
return(SystemDllCallbackDispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
PVOID LdrpGetSystemDllEntryPoint(VOID)
|
PVOID LdrpGetSystemDllEntryPoint(VOID)
|
||||||
{
|
{
|
||||||
return(SystemDllEntryPoint);
|
return(SystemDllEntryPoint);
|
||||||
|
@ -242,7 +252,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
*LdrStartupAddr = SystemDllEntryPoint;
|
*LdrStartupAddr = SystemDllEntryPoint;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: retrieve the offset of the APC dispatcher from NTDLL
|
* Retrieve the offset of the APC dispatcher from NTDLL
|
||||||
*/
|
*/
|
||||||
RtlInitAnsiString (&ProcedureName,
|
RtlInitAnsiString (&ProcedureName,
|
||||||
"KiUserApcDispatcher");
|
"KiUserApcDispatcher");
|
||||||
|
@ -259,6 +269,42 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve the offset of the exception dispatcher from NTDLL
|
||||||
|
*/
|
||||||
|
RtlInitAnsiString (&ProcedureName,
|
||||||
|
"KiUserExceptionDispatcher");
|
||||||
|
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
||||||
|
&ProcedureName,
|
||||||
|
0,
|
||||||
|
&SystemDllExceptionDispatcher);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
|
KeDetachProcess();
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
ZwClose(NTDllSectionHandle);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve the offset of the callback dispatcher from NTDLL
|
||||||
|
*/
|
||||||
|
RtlInitAnsiString (&ProcedureName,
|
||||||
|
"KiUserCallbackDispatcher");
|
||||||
|
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
||||||
|
&ProcedureName,
|
||||||
|
0,
|
||||||
|
&SystemDllCallbackDispatcher);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
|
KeDetachProcess();
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
ZwClose(NTDllSectionHandle);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
|
||||||
KeDetachProcess();
|
KeDetachProcess();
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.25 2000/12/22 13:37:41 ekohl Exp $
|
/* $Id: create.c,v 1.26 2000/12/23 02:37:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -82,7 +82,8 @@ PsAssignImpersonationToken(PETHREAD Thread,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID STDCALL PsRevertToSelf(PETHREAD Thread)
|
VOID STDCALL
|
||||||
|
PsRevertToSelf(PETHREAD Thread)
|
||||||
{
|
{
|
||||||
if (Thread->ActiveImpersonationInfo != 0)
|
if (Thread->ActiveImpersonationInfo != 0)
|
||||||
{
|
{
|
||||||
|
@ -91,11 +92,12 @@ VOID STDCALL PsRevertToSelf(PETHREAD Thread)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID STDCALL PsImpersonateClient(PETHREAD Thread,
|
VOID STDCALL
|
||||||
PACCESS_TOKEN Token,
|
PsImpersonateClient(PETHREAD Thread,
|
||||||
UCHAR b,
|
PACCESS_TOKEN Token,
|
||||||
UCHAR c,
|
UCHAR b,
|
||||||
SECURITY_IMPERSONATION_LEVEL Level)
|
UCHAR c,
|
||||||
|
SECURITY_IMPERSONATION_LEVEL Level)
|
||||||
{
|
{
|
||||||
if (Token == 0)
|
if (Token == 0)
|
||||||
{
|
{
|
||||||
|
@ -126,10 +128,11 @@ VOID STDCALL PsImpersonateClient(PETHREAD Thread,
|
||||||
Thread->ActiveImpersonationInfo = 1;
|
Thread->ActiveImpersonationInfo = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
|
PACCESS_TOKEN
|
||||||
PTOKEN_TYPE TokenType,
|
PsReferenceEffectiveToken(PETHREAD Thread,
|
||||||
PUCHAR b,
|
PTOKEN_TYPE TokenType,
|
||||||
PSECURITY_IMPERSONATION_LEVEL Level)
|
PUCHAR b,
|
||||||
|
PSECURITY_IMPERSONATION_LEVEL Level)
|
||||||
{
|
{
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
PACCESS_TOKEN Token;
|
PACCESS_TOKEN Token;
|
||||||
|
@ -151,10 +154,11 @@ PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
|
||||||
return(Token);
|
return(Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtImpersonateThread (IN HANDLE ThreadHandle,
|
NTSTATUS STDCALL
|
||||||
IN HANDLE ThreadToImpersonateHandle,
|
NtImpersonateThread (IN HANDLE ThreadHandle,
|
||||||
IN PSECURITY_QUALITY_OF_SERVICE
|
IN HANDLE ThreadToImpersonateHandle,
|
||||||
SecurityQualityOfService)
|
IN PSECURITY_QUALITY_OF_SERVICE
|
||||||
|
SecurityQualityOfService)
|
||||||
{
|
{
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
PETHREAD ThreadToImpersonate;
|
PETHREAD ThreadToImpersonate;
|
||||||
|
@ -203,10 +207,11 @@ NTSTATUS STDCALL NtImpersonateThread (IN HANDLE ThreadHandle,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtOpenThreadToken(IN HANDLE ThreadHandle,
|
NTSTATUS STDCALL
|
||||||
IN ACCESS_MASK DesiredAccess,
|
NtOpenThreadToken(IN HANDLE ThreadHandle,
|
||||||
IN BOOLEAN OpenAsSelf,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
OUT PHANDLE TokenHandle)
|
IN BOOLEAN OpenAsSelf,
|
||||||
|
OUT PHANDLE TokenHandle)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
|
@ -230,11 +235,11 @@ NTSTATUS STDCALL NtOpenThreadToken(IN HANDLE ThreadHandle,
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(PETHREAD Thread,
|
PACCESS_TOKEN STDCALL
|
||||||
PULONG Unknown1,
|
PsReferenceImpersonationToken(PETHREAD Thread,
|
||||||
PULONG Unknown2,
|
PULONG Unknown1,
|
||||||
SECURITY_IMPERSONATION_LEVEL*
|
PULONG Unknown2,
|
||||||
Level)
|
SECURITY_IMPERSONATION_LEVEL* Level)
|
||||||
{
|
{
|
||||||
if (Thread->ActiveImpersonationInfo == 0)
|
if (Thread->ActiveImpersonationInfo == 0)
|
||||||
{
|
{
|
||||||
|
@ -251,10 +256,11 @@ PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(PETHREAD Thread,
|
||||||
return(Thread->ImpersonationInfo->Token);
|
return(Thread->ImpersonationInfo->Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID PiTimeoutThread(struct _KDPC *dpc,
|
VOID
|
||||||
PVOID Context,
|
PiTimeoutThread(struct _KDPC *dpc,
|
||||||
PVOID arg1,
|
PVOID Context,
|
||||||
PVOID arg2)
|
PVOID arg1,
|
||||||
|
PVOID arg2)
|
||||||
{
|
{
|
||||||
// wake up the thread, and tell it it timed out
|
// wake up the thread, and tell it it timed out
|
||||||
NTSTATUS Status = STATUS_TIMEOUT;
|
NTSTATUS Status = STATUS_TIMEOUT;
|
||||||
|
@ -264,23 +270,27 @@ VOID PiTimeoutThread(struct _KDPC *dpc,
|
||||||
KeRemoveAllWaitsThread((PETHREAD)Context, Status);
|
KeRemoveAllWaitsThread((PETHREAD)Context, Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID PiBeforeBeginThread(CONTEXT c)
|
VOID
|
||||||
|
PiBeforeBeginThread(CONTEXT c)
|
||||||
{
|
{
|
||||||
DPRINT("PiBeforeBeginThread(Eip %x)\n", c.Eip);
|
DPRINT("PiBeforeBeginThread(Eip %x)\n", c.Eip);
|
||||||
//KeReleaseSpinLock(&PiThreadListLock, PASSIVE_LEVEL);
|
//KeReleaseSpinLock(&PiThreadListLock, PASSIVE_LEVEL);
|
||||||
KeLowerIrql(PASSIVE_LEVEL);
|
KeLowerIrql(PASSIVE_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
|
#if 0
|
||||||
|
VOID
|
||||||
|
PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
|
||||||
{
|
{
|
||||||
NTSTATUS Ret;
|
NTSTATUS Ret;
|
||||||
|
|
||||||
// KeReleaseSpinLock(&PiThreadListLock,PASSIVE_LEVEL);
|
// KeReleaseSpinLock(&PiThreadListLock,PASSIVE_LEVEL);
|
||||||
KeLowerIrql(PASSIVE_LEVEL);
|
KeLowerIrql(PASSIVE_LEVEL);
|
||||||
Ret = StartRoutine(StartContext);
|
Ret = StartRoutine(StartContext);
|
||||||
PsTerminateSystemThread(Ret);
|
PsTerminateSystemThread(Ret);
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VOID PiDeleteThread(PVOID ObjectBody)
|
VOID PiDeleteThread(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
|
@ -313,7 +323,8 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
PETHREAD* ThreadPtr,
|
PETHREAD* ThreadPtr,
|
||||||
PHANDLE ThreadHandle,
|
PHANDLE ThreadHandle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_ATTRIBUTES ThreadAttributes)
|
POBJECT_ATTRIBUTES ThreadAttributes,
|
||||||
|
BOOLEAN First)
|
||||||
{
|
{
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -358,7 +369,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
|
|
||||||
PiNrThreads++;
|
PiNrThreads++;
|
||||||
|
|
||||||
KeInitializeThread(&Process->Pcb, &Thread->Tcb);
|
KeInitializeThread(&Process->Pcb, &Thread->Tcb, First);
|
||||||
Thread->ThreadsProcess = Process;
|
Thread->ThreadsProcess = Process;
|
||||||
/*
|
/*
|
||||||
* FIXME: What lock protects this?
|
* FIXME: What lock protects this?
|
||||||
|
@ -418,6 +429,7 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
|
||||||
DbgPrint("NtQueryVirtualMemory (Status %x)\n", Status);
|
DbgPrint("NtQueryVirtualMemory (Status %x)\n", Status);
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
/* FIXME: Race between this and the above check */
|
||||||
if (Info.State == MEM_FREE)
|
if (Info.State == MEM_FREE)
|
||||||
{
|
{
|
||||||
/* The TEB must reside in user space */
|
/* The TEB must reside in user space */
|
||||||
|
@ -517,7 +529,7 @@ NTSTATUS STDCALL NtCreateThread (PHANDLE ThreadHandle,
|
||||||
ThreadHandle,ThreadContext);
|
ThreadHandle,ThreadContext);
|
||||||
|
|
||||||
Status = PsInitializeThread(ProcessHandle,&Thread,ThreadHandle,
|
Status = PsInitializeThread(ProcessHandle,&Thread,ThreadHandle,
|
||||||
DesiredAccess,ObjectAttributes);
|
DesiredAccess,ObjectAttributes, FALSE);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
|
@ -537,7 +549,8 @@ NTSTATUS STDCALL NtCreateThread (PHANDLE ThreadHandle,
|
||||||
ThreadContext->Eip = LdrpGetSystemDllEntryPoint;
|
ThreadContext->Eip = LdrpGetSystemDllEntryPoint;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Status = HalInitTaskWithContext(Thread,ThreadContext);
|
// Status = HalInitTaskWithContext(Thread,ThreadContext);
|
||||||
|
Status = Ke386InitThreadWithContext(&Thread->Tcb, ThreadContext);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
|
@ -630,14 +643,15 @@ NTSTATUS STDCALL PsCreateSystemThread(PHANDLE ThreadHandle,
|
||||||
ThreadHandle,ProcessHandle);
|
ThreadHandle,ProcessHandle);
|
||||||
|
|
||||||
Status = PsInitializeThread(ProcessHandle,&Thread,ThreadHandle,
|
Status = PsInitializeThread(ProcessHandle,&Thread,ThreadHandle,
|
||||||
DesiredAccess,ObjectAttributes);
|
DesiredAccess,ObjectAttributes, FALSE);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread->StartAddress=StartRoutine;
|
Thread->StartAddress=StartRoutine;
|
||||||
Status = HalInitTask(Thread,StartRoutine,StartContext);
|
// Status = HalInitTask(Thread,StartRoutine,StartContext);
|
||||||
|
Status = Ke386InitThread(&Thread->Tcb, StartRoutine, StartContext);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
|
|
|
@ -32,7 +32,8 @@ VOID PsTerminateCurrentThread(NTSTATUS ExitStatus);
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
|
VOID
|
||||||
|
PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -46,19 +47,30 @@ VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
|
||||||
current_entry = Process->ThreadListHead.Flink;
|
current_entry = Process->ThreadListHead.Flink;
|
||||||
while (current_entry != &Process->ThreadListHead)
|
while (current_entry != &Process->ThreadListHead)
|
||||||
{
|
{
|
||||||
current = CONTAINING_RECORD(current_entry,ETHREAD,Tcb.ProcessThreadListEntry);
|
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
||||||
if (current != PsGetCurrentThread())
|
Tcb.ProcessThreadListEntry);
|
||||||
|
if (current != PsGetCurrentThread() &&
|
||||||
|
current->DeadThread == 0)
|
||||||
{
|
{
|
||||||
DPRINT("Terminating %x, current thread: %x, thread's process: %x\n", current, PsGetCurrentThread(), current->ThreadsProcess );
|
DPRINT("Terminating %x, current thread: %x, "
|
||||||
|
"thread's process: %x\n", current, PsGetCurrentThread(),
|
||||||
|
current->ThreadsProcess);
|
||||||
|
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
|
||||||
PsTerminateOtherThread(current, ExitStatus);
|
PsTerminateOtherThread(current, ExitStatus);
|
||||||
|
KeAcquireSpinLock(&PiThreadListLock, &oldlvl);
|
||||||
|
current_entry = Process->ThreadListHead.Flink;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
|
||||||
}
|
}
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
|
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
|
||||||
DPRINT("Finished PiTerminateProcessThreads()\n");
|
DPRINT("Finished PiTerminateProcessThreads()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID PsReapThreads(VOID)
|
VOID
|
||||||
|
PsReapThreads(VOID)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
PETHREAD current;
|
PETHREAD current;
|
||||||
|
@ -127,26 +139,27 @@ VOID PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus)
|
VOID
|
||||||
|
PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Terminate a thread when calling from another thread's context
|
* FUNCTION: Terminate a thread when calling from another thread's context
|
||||||
|
* NOTES: This function must be called with PiThreadListLock held
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
|
||||||
|
|
||||||
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
||||||
Thread, ExitStatus);
|
Thread, ExitStatus);
|
||||||
|
|
||||||
KeAcquireSpinLock( &PiThreadListLock, &oldIrql );
|
|
||||||
Thread->DeadThread = 1;
|
Thread->DeadThread = 1;
|
||||||
Thread->ExitStatus = ExitStatus;
|
Thread->ExitStatus = ExitStatus;
|
||||||
if( Thread->Tcb.State == THREAD_STATE_FROZEN && (Thread->Tcb.Alertable || Thread->Tcb.WaitMode == UserMode) )
|
if (Thread->Tcb.State == THREAD_STATE_FROZEN &&
|
||||||
KeRemoveAllWaitsThread( Thread, STATUS_ALERTED );
|
(Thread->Tcb.Alertable || Thread->Tcb.WaitMode == UserMode))
|
||||||
KeReleaseSpinLock( &PiThreadListLock, oldIrql );
|
{
|
||||||
|
KeRemoveAllWaitsThread(Thread, STATUS_ALERTED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process,
|
NTSTATUS STDCALL
|
||||||
NTSTATUS ExitStatus)
|
PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus)
|
||||||
{
|
{
|
||||||
DPRINT("PiTerminateProcess(Process %x, ExitStatus %x) RC %d HC %d\n",
|
DPRINT("PiTerminateProcess(Process %x, ExitStatus %x) RC %d HC %d\n",
|
||||||
Process, ExitStatus, ObGetReferenceCount(Process),
|
Process, ExitStatus, ObGetReferenceCount(Process),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: thread.c,v 1.61 2000/12/22 13:37:41 ekohl Exp $
|
/* $Id: thread.c,v 1.62 2000/12/23 02:37:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -53,25 +53,11 @@ static PETHREAD CurrentThread = NULL;
|
||||||
|
|
||||||
PKTHREAD STDCALL KeGetCurrentThread(VOID)
|
PKTHREAD STDCALL KeGetCurrentThread(VOID)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if (CurrentThread != NULL)
|
|
||||||
{
|
|
||||||
DbgPrint("KeGetCurrentThread() called before initialization\n");
|
|
||||||
KeBugCheck(0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return(&(CurrentThread->Tcb));
|
return(&(CurrentThread->Tcb));
|
||||||
}
|
}
|
||||||
|
|
||||||
PETHREAD STDCALL PsGetCurrentThread(VOID)
|
PETHREAD STDCALL PsGetCurrentThread(VOID)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if (CurrentThread != NULL)
|
|
||||||
{
|
|
||||||
DbgPrint("PsGetCurrentThread() called before initialization\n");
|
|
||||||
KeBugCheck(0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return(CurrentThread);
|
return(CurrentThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +108,7 @@ VOID PsDumpThreads(VOID)
|
||||||
}
|
}
|
||||||
DbgPrint("current %x current->Tcb.State %d eip %x/%x ",
|
DbgPrint("current %x current->Tcb.State %d eip %x/%x ",
|
||||||
current, current->Tcb.State,
|
current, current->Tcb.State,
|
||||||
current->Tcb.Context.eip, current->Tcb.LastEip);
|
0, current->Tcb.LastEip);
|
||||||
// KeDumpStackFrames((PVOID)current->Tcb.Context.esp0,
|
// KeDumpStackFrames((PVOID)current->Tcb.Context.esp0,
|
||||||
// 16);
|
// 16);
|
||||||
DbgPrint("PID %d ", current->ThreadsProcess->UniqueProcessId);
|
DbgPrint("PID %d ", current->ThreadsProcess->UniqueProcessId);
|
||||||
|
@ -182,14 +168,18 @@ VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
|
||||||
}
|
}
|
||||||
if (Candidate != NULL)
|
if (Candidate != NULL)
|
||||||
{
|
{
|
||||||
|
PETHREAD OldThread;
|
||||||
|
|
||||||
DPRINT("Scheduling %x(%d)\n",Candidate, CurrentPriority);
|
DPRINT("Scheduling %x(%d)\n",Candidate, CurrentPriority);
|
||||||
|
|
||||||
Candidate->Tcb.State = THREAD_STATE_RUNNING;
|
Candidate->Tcb.State = THREAD_STATE_RUNNING;
|
||||||
|
|
||||||
|
OldThread = CurrentThread;
|
||||||
CurrentThread = Candidate;
|
CurrentThread = Candidate;
|
||||||
|
|
||||||
KeReleaseSpinLockFromDpcLevel(&PiThreadListLock);
|
KeReleaseSpinLockFromDpcLevel(&PiThreadListLock);
|
||||||
HalTaskSwitch(&CurrentThread->Tcb);
|
// HalTaskSwitch(&CurrentThread->Tcb);
|
||||||
|
Ki386ContextSwitch(&CurrentThread->Tcb, &OldThread->Tcb);
|
||||||
PsReapThreads();
|
PsReapThreads();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +207,8 @@ VOID PsDispatchThread(ULONG NewThreadStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Suspend and resume may only be called to suspend the current thread, except by apc.c
|
* Suspend and resume may only be called to suspend the current thread, except
|
||||||
|
* by apc.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ULONG PsUnfreezeThread(PETHREAD Thread, PNTSTATUS WaitStatus)
|
ULONG PsUnfreezeThread(PETHREAD Thread, PNTSTATUS WaitStatus)
|
||||||
|
@ -352,7 +343,8 @@ ULONG PsSuspendThread(PETHREAD Thread)
|
||||||
return PreviousSuspendCount;
|
return PreviousSuspendCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID PsInitThreadManagment(VOID)
|
VOID
|
||||||
|
PsInitThreadManagment(VOID)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Initialize thread managment
|
* FUNCTION: Initialize thread managment
|
||||||
*/
|
*/
|
||||||
|
@ -389,7 +381,7 @@ VOID PsInitThreadManagment(VOID)
|
||||||
PsThreadType->Create = NULL;
|
PsThreadType->Create = NULL;
|
||||||
|
|
||||||
PsInitializeThread(NULL,&FirstThread,&FirstThreadHandle,
|
PsInitializeThread(NULL,&FirstThread,&FirstThreadHandle,
|
||||||
THREAD_ALL_ACCESS,NULL);
|
THREAD_ALL_ACCESS,NULL, TRUE);
|
||||||
HalInitFirstTask(FirstThread);
|
HalInitFirstTask(FirstThread);
|
||||||
FirstThread->Tcb.State = THREAD_STATE_RUNNING;
|
FirstThread->Tcb.State = THREAD_STATE_RUNNING;
|
||||||
FirstThread->Tcb.FreezeCount = 0;
|
FirstThread->Tcb.FreezeCount = 0;
|
||||||
|
@ -479,16 +471,18 @@ NTSTATUS STDCALL NtAlertThread (IN HANDLE ThreadHandle)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtOpenThread(OUT PHANDLE ThreadHandle,
|
NTSTATUS STDCALL
|
||||||
IN ACCESS_MASK DesiredAccess,
|
NtOpenThread(OUT PHANDLE ThreadHandle,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN PCLIENT_ID ClientId)
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
IN PCLIENT_ID ClientId)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtResumeThread (IN HANDLE ThreadHandle,
|
NTSTATUS STDCALL
|
||||||
IN PULONG SuspendCount)
|
NtResumeThread (IN HANDLE ThreadHandle,
|
||||||
|
IN PULONG SuspendCount)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Decrements a thread's resume count
|
* FUNCTION: Decrements a thread's resume count
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -528,8 +522,9 @@ NTSTATUS STDCALL NtResumeThread (IN HANDLE ThreadHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtSuspendThread (IN HANDLE ThreadHandle,
|
NTSTATUS STDCALL
|
||||||
IN PULONG PreviousSuspendCount)
|
NtSuspendThread (IN HANDLE ThreadHandle,
|
||||||
|
IN PULONG PreviousSuspendCount)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Increments a thread's suspend count
|
* FUNCTION: Increments a thread's suspend count
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -570,12 +565,35 @@ NTSTATUS STDCALL NtSuspendThread (IN HANDLE ThreadHandle,
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
NtCallbackReturn (PVOID Result,
|
||||||
|
ULONG ResultLength,
|
||||||
|
NTSTATUS Status)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtContinue(IN PCONTEXT Context,
|
NTSTATUS STDCALL
|
||||||
IN BOOLEAN TestAlert)
|
NtW32Call (IN ULONG RoutineIndex,
|
||||||
|
IN PVOID Argument,
|
||||||
|
IN ULONG ArgumentLength,
|
||||||
|
OUT PVOID* Result OPTIONAL,
|
||||||
|
OUT PULONG ResultLength OPTIONAL)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
NtContinue(IN PCONTEXT Context,
|
||||||
|
IN BOOLEAN TestAlert)
|
||||||
{
|
{
|
||||||
PKTRAP_FRAME TrapFrame;
|
PKTRAP_FRAME TrapFrame;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy the supplied context over the register information that was saved
|
||||||
|
* on entry to kernel mode, it will then be restored on exit
|
||||||
|
* FIXME: Validate the context
|
||||||
|
*/
|
||||||
TrapFrame = KeGetCurrentThread()->TrapFrame;
|
TrapFrame = KeGetCurrentThread()->TrapFrame;
|
||||||
if (TrapFrame == NULL)
|
if (TrapFrame == NULL)
|
||||||
{
|
{
|
||||||
|
@ -587,8 +605,8 @@ NTSTATUS STDCALL NtContinue(IN PCONTEXT Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtYieldExecution(VOID)
|
NTSTATUS STDCALL
|
||||||
{
|
NtYieldExecution(VOID)
|
||||||
PsDispatchThread(THREAD_STATE_RUNNABLE);
|
PsDispatchThread(THREAD_STATE_RUNNABLE);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue