mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +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
|
||||
add-symbol-file lib/ntdll/ntdll.dll 0x77f61000
|
||||
add-symbol-file apps/apc/apc.exe 0x401000
|
||||
#add-symbol-file lib/ntdll/ntdll.dll 0x77f61000
|
||||
#add-symbol-file apps/apc/apc.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>
|
||||
|
||||
* ntoskrnl/ke/i386/irq.c (KiInterruptDispatch): Record the last PC
|
||||
|
@ -50,3 +80,13 @@
|
|||
APC).
|
||||
|
||||
* 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
|
||||
Test and debug Registry routines
|
||||
Finish multiple system service table support (HalRegisterServiceTable)
|
||||
Modify GENNTDLL to generate all needed system service tables
|
||||
Test and debug Registry routines
|
||||
Implement file cache
|
||||
Implement paging
|
||||
|
||||
* These tasks would be nice
|
||||
Separate HAL into KM DLL
|
||||
|
@ -26,13 +26,10 @@
|
|||
Named pipes (see io/npipe.c)
|
||||
Hardware resource management (see io/resource.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)
|
||||
Mutex support (see ke/mutex.c)
|
||||
Semaphore support (see ke/sem.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)
|
||||
Sequenced lists (see rtl/seqlist.c)
|
||||
|
||||
|
@ -43,13 +40,7 @@
|
|||
* Major areas
|
||||
|
||||
Security support (see se/*.c)
|
||||
Registry support (see cm/*.c)
|
||||
Paging support
|
||||
File system cache support
|
||||
SCSI miniport driver
|
||||
Network support
|
||||
Video drivers
|
||||
USER and GDI modules
|
||||
|
||||
* Drivers
|
||||
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 = ../../..
|
||||
|
||||
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 \
|
||||
$(TARGET).coff ../../../ntoskrnl/ntoskrnl.a
|
||||
CFLAGS = -I. -g
|
||||
|
||||
all: $(TARGET).sys $(TARGET).sys.unstripped
|
||||
all: $(TARGET).sys
|
||||
|
||||
.phony: all
|
||||
|
||||
|
@ -35,7 +34,12 @@ dist: ../../../$(DIST_DIR)/drivers/$(TARGET).sys
|
|||
../../../$(DIST_DIR)/drivers/$(TARGET).sys: $(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
|
||||
|
|
|
@ -120,7 +120,7 @@ NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
current_ino = MINIX_ROOT_INO;
|
||||
|
||||
while (next!=NULL && current_ino!=0)
|
||||
while (next != NULL && current_ino != 0)
|
||||
{
|
||||
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
||||
|
||||
|
@ -139,7 +139,7 @@ NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
|||
¤t_dir,
|
||||
current);
|
||||
}
|
||||
if (next==NULL && current_ino!=0)
|
||||
if (next == NULL && current_ino != 0)
|
||||
{
|
||||
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ NTSTATUS MinixCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
FileObject->FsContext=result;
|
||||
FileObject->FsContext = result;
|
||||
}
|
||||
|
||||
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
|
||||
* FILE: services/fs/minix/minix.c
|
||||
* PURPOSE: Minix FSD
|
||||
|
@ -105,14 +122,19 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT _DriverObject,
|
|||
DriverObject = _DriverObject;
|
||||
|
||||
RtlInitUnicodeString(&ustr, L"\\Device\\Minix");
|
||||
ret = IoCreateDevice(DriverObject,0,&ustr,
|
||||
FILE_DEVICE_PARALLEL_PORT,0,FALSE,&DeviceObject);
|
||||
if (ret!=STATUS_SUCCESS)
|
||||
ret = IoCreateDevice(DriverObject,
|
||||
0,
|
||||
&ustr,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (!NT_SUCCESS(ret))
|
||||
{
|
||||
return(ret);
|
||||
}
|
||||
|
||||
DeviceObject->Flags=0;
|
||||
DeviceObject->Flags = 0;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MinixClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = MinixCreate;
|
||||
DriverObject->MajorFunction[IRP_MJ_READ] = MinixRead;
|
||||
|
|
|
@ -5,54 +5,51 @@
|
|||
#ifndef __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;
|
||||
unsigned short reserved1;
|
||||
unsigned long esp0;
|
||||
unsigned short ss0;
|
||||
unsigned short reserved2;
|
||||
unsigned long esp1;
|
||||
unsigned short ss1;
|
||||
unsigned short reserved3;
|
||||
unsigned long esp2;
|
||||
unsigned short ss2;
|
||||
unsigned short reserved4;
|
||||
unsigned long cr3;
|
||||
unsigned long eip;
|
||||
unsigned long eflags;
|
||||
unsigned long eax;
|
||||
unsigned long ecx;
|
||||
unsigned long edx;
|
||||
unsigned long ebx;
|
||||
unsigned long esp;
|
||||
unsigned long ebp;
|
||||
unsigned long esi;
|
||||
unsigned long edi;
|
||||
unsigned short es;
|
||||
unsigned short reserved5;
|
||||
unsigned short cs;
|
||||
unsigned short reserved6;
|
||||
unsigned short ss;
|
||||
unsigned short reserved7;
|
||||
unsigned short ds;
|
||||
unsigned short reserved8;
|
||||
unsigned short fs;
|
||||
unsigned short reserved9;
|
||||
unsigned short gs;
|
||||
unsigned short reserved10;
|
||||
unsigned short ldt;
|
||||
unsigned short reserved11;
|
||||
unsigned short trap;
|
||||
unsigned short iomap_base;
|
||||
|
||||
unsigned short nr;
|
||||
PVOID KernelStackBase;
|
||||
PVOID SavedKernelEsp;
|
||||
PVOID SavedKernelStackBase;
|
||||
|
||||
unsigned char io_bitmap[1];
|
||||
} hal_thread_state;
|
||||
USHORT PreviousTask;
|
||||
USHORT Reserved1;
|
||||
ULONG Esp0;
|
||||
USHORT Ss0;
|
||||
USHORT Reserved2;
|
||||
ULONG Esp1;
|
||||
USHORT Ss1;
|
||||
USHORT Reserved3;
|
||||
ULONG Esp2;
|
||||
USHORT Ss2;
|
||||
USHORT Reserved4;
|
||||
ULONG Cr3;
|
||||
ULONG Eip;
|
||||
ULONG Eflags;
|
||||
ULONG Eax;
|
||||
ULONG Ecx;
|
||||
ULONG Edx;
|
||||
ULONG Ebx;
|
||||
ULONG Esp;
|
||||
ULONG Ebp;
|
||||
ULONG Esi;
|
||||
ULONG Edi;
|
||||
USHORT Es;
|
||||
USHORT Reserved5;
|
||||
USHORT Cs;
|
||||
USHORT Reserved6;
|
||||
USHORT Ss;
|
||||
USHORT Reserved7;
|
||||
USHORT Fs;
|
||||
USHORT Reserved8;
|
||||
USHORT Gs;
|
||||
USHORT Reserved9;
|
||||
USHORT Ldt;
|
||||
USHORT Reserved10;
|
||||
USHORT Trap;
|
||||
USHORT IoMapBase;
|
||||
UCHAR IoBitmap[1];
|
||||
} KTSS;
|
||||
|
||||
#endif /* not __ASM__ */
|
||||
|
||||
#endif /* __INCLUDE_DDK_I386_TSS_H */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef _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 --- */
|
||||
|
||||
|
@ -917,12 +917,9 @@ IoReportResourceUsage (
|
|||
param->Control |= SL_INVOKE_ON_CANCEL; \
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
IoSetDeviceToVerify (
|
||||
IN struct _ETHREAD* Thread,
|
||||
IN PDEVICE_OBJECT DeviceObject
|
||||
);
|
||||
VOID STDCALL
|
||||
IoSetDeviceToVerify (IN struct _ETHREAD* Thread,
|
||||
IN PDEVICE_OBJECT DeviceObject);
|
||||
VOID
|
||||
STDCALL
|
||||
IoSetHardErrorOrVerifyDevice (
|
||||
|
|
|
@ -132,7 +132,7 @@ typedef struct _DISPATCHER_HEADER
|
|||
UCHAR Inserted;
|
||||
LONG SignalState;
|
||||
LIST_ENTRY WaitListHead;
|
||||
} DISPATCHER_HEADER;
|
||||
} __attribute__((packed)) DISPATCHER_HEADER;
|
||||
|
||||
|
||||
typedef struct _KQUEUE
|
||||
|
@ -155,19 +155,6 @@ typedef struct _KTIMER
|
|||
LONG Period;
|
||||
} 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;
|
||||
|
||||
typedef struct _KSPIN_LOCK
|
||||
|
@ -225,7 +212,7 @@ typedef struct _KSEMAPHORE
|
|||
{
|
||||
DISPATCHER_HEADER Header;
|
||||
LONG Limit;
|
||||
} KSEMAPHORE, *PKSEMAPHORE;
|
||||
} __attribute__((packed)) KSEMAPHORE, *PKSEMAPHORE;
|
||||
|
||||
typedef struct _KEVENT
|
||||
{
|
||||
|
@ -270,7 +257,7 @@ typedef struct _KDPC
|
|||
PVOID SystemArgument1;
|
||||
PVOID SystemArgument2;
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -5248,11 +5248,12 @@ NtVdmControl (
|
|||
|
||||
/* --- WIN32 --- */
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtW32Call (
|
||||
VOID
|
||||
);
|
||||
NTSTATUS STDCALL
|
||||
NtW32Call(IN ULONG RoutineIndex,
|
||||
IN PVOID Argument,
|
||||
IN ULONG ArgumentLength,
|
||||
OUT PVOID* Result OPTIONAL,
|
||||
OUT PULONG ResultLength OPTIONAL);
|
||||
|
||||
/* --- CHANNELS --- */
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ cp apps/cat/cat.exe $1/reactos/bin
|
|||
cp subsys/smss/smss.exe $1/reactos/system32
|
||||
cp subsys/csrss/csrss.exe $1/reactos/system32
|
||||
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/shm/shmsrv.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
|
||||
;
|
||||
|
@ -28,9 +28,9 @@ DbgUiConnectToDbg@0
|
|||
DbgUiContinue@8
|
||||
DbgUiWaitStateChange@8
|
||||
DbgUserBreakPoint@0
|
||||
;KiRaiseUserExceptionDispatcher
|
||||
KiRaiseUserExceptionDispatcher
|
||||
KiUserApcDispatcher
|
||||
;KiUserCallbackDispatcher
|
||||
KiUserCallbackDispatcher
|
||||
;KiUserExceptionDispatcher
|
||||
LdrAccessResource@16
|
||||
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
|
||||
;
|
||||
|
@ -30,8 +30,8 @@ DbgUiWaitStateChange=DbgUiWaitStateChange@8
|
|||
DbgUserBreakPoint=DbgUserBreakPoint@0
|
||||
;KiRaiseUserExceptionDispatcher
|
||||
KiUserApcDispatcher=KiUserApcDispatcher@20
|
||||
;KiUserCallbackDispatcher
|
||||
;KiUserExceptionDispatcher
|
||||
KiUserCallbackDispatcher=KiUserCallbackDispatcher@12
|
||||
KiUserExceptionDispatcher=KiUserExceptionDispatcher@8
|
||||
LdrAccessResource=LdrAccessResource@16
|
||||
LdrDisableThreadCalloutsForDll=LdrDisableThreadCalloutsForDll@4
|
||||
;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
|
||||
#
|
||||
|
@ -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/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/registry.o
|
||||
rtl/registry.o rtl/exception.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
|
||||
* PURPOSE: User-mode APC support
|
||||
* FILE: lib/ntdll/rtl/apc.c
|
||||
|
@ -14,20 +31,22 @@
|
|||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID STDCALL KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK Iosb,
|
||||
ULONG Reserved,
|
||||
PCONTEXT Context)
|
||||
VOID STDCALL
|
||||
KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK Iosb,
|
||||
ULONG Reserved,
|
||||
PCONTEXT Context)
|
||||
{
|
||||
DbgPrint("KiUserApcDispatcher(ApcRoutine %x, ApcContext %x, Context %x)\n",
|
||||
ApcRoutine, ApcContext, Context);
|
||||
/*
|
||||
* Call the APC
|
||||
*/
|
||||
ApcRoutine(ApcContext,
|
||||
Iosb,
|
||||
Reserved);
|
||||
DbgPrint("Done ApcRoutine, Context %x, Context->Eip %x\n",
|
||||
Context, Context->Eip);
|
||||
/*
|
||||
* Switch back to the interrupted context
|
||||
*/
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -20,9 +20,10 @@ typedef NTSTATUS (*CALLBACK_FUNCTION)(PVOID Argument, ULONG ArgumentLength);
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID KiUserCallbackDispatcher(ULONG RoutineIndex,
|
||||
PVOID Argument,
|
||||
ULONG ArgumentLength)
|
||||
VOID STDCALL
|
||||
KiUserCallbackDispatcher(ULONG RoutineIndex,
|
||||
PVOID Argument,
|
||||
ULONG ArgumentLength)
|
||||
{
|
||||
PPEB Peb;
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -12,12 +12,11 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
|
||||
PCONTEXT Context)
|
||||
VOID STDCALL
|
||||
KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
|
||||
PCONTEXT Context)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ STUB(CsrProbeForWrite)
|
|||
STUB(CsrSetPriorityClass)
|
||||
|
||||
STUB(KiRaiseUserExceptionDispatcher)
|
||||
STUB(KiUserExceptionDispatcher)
|
||||
|
||||
STUB(LdrEnumResources)
|
||||
STUB(LdrFindEntryForAddress)
|
||||
|
|
|
@ -343,11 +343,11 @@ entry:
|
|||
mov cx, 0600h
|
||||
int 10h
|
||||
|
||||
mov ah, 6 ; SCROLL ACTIVE PAGE UP
|
||||
mov al, 32h ; CLEAR 50 LINES
|
||||
mov cx, 0 ; UPPER LEFT OF SCROLL
|
||||
mov dx, 314fh ; LOWER RIGHT OF SCROLL
|
||||
mov bh, 1*10h+1 ; USE NORMAL ATTRIBUTE ON BLANKED LINE
|
||||
mov ah, 6 ; Scroll active page up
|
||||
mov al, 32h ; Clear 50 lines
|
||||
mov cx, 0 ; Upper left of scroll
|
||||
mov dx, 314fh ; Lower right of scroll
|
||||
mov bh, 1*10h+1 ; Use normal attribute on blanked lines
|
||||
int 10h
|
||||
|
||||
mov dx, 0
|
||||
|
@ -581,77 +581,9 @@ e_res2: resw 10
|
|||
e_lfanew: resd 1
|
||||
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:
|
||||
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:
|
||||
dw 0
|
||||
_current_size:
|
||||
|
@ -783,7 +715,7 @@ pe_load_module:
|
|||
|
||||
.read_tail
|
||||
;;
|
||||
;; Read in the tailing part of the section data
|
||||
;; Read in the tailing part of the file data
|
||||
;;
|
||||
push ds
|
||||
mov eax, [_current_size]
|
||||
|
@ -794,11 +726,11 @@ pe_load_module:
|
|||
mov ds, dx
|
||||
mov dx, 0
|
||||
int 0x21
|
||||
jnc .section_read_last_data_succeeded
|
||||
jnc .read_last_data_succeeded
|
||||
pop ds
|
||||
mov dx, error_file_read_failed
|
||||
jmp .error
|
||||
.section_read_last_data_succeeded:
|
||||
.read_last_data_succeeded:
|
||||
mov ah,02h
|
||||
mov dl,'#'
|
||||
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
|
||||
#
|
||||
|
@ -94,7 +94,10 @@ OBJECTS_KE_I386 = \
|
|||
ke/i386/usercall.o \
|
||||
ke/i386/trap.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)
|
||||
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
|
||||
* FILE: ntoskrnl/cc/cacheman.c
|
||||
* PURPOSE: Cache manager
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -72,7 +72,7 @@ CcFlushCachePage(PCACHE_SEGMENT CacheSeg)
|
|||
KernelMode,
|
||||
FALSE,
|
||||
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);
|
||||
return(STATUS_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
@ -256,12 +256,9 @@ CcInitializeFileCache(PFILE_OBJECT FileObject,
|
|||
* NOTE
|
||||
* Used by CcMdlReadComplete@8 and FsRtl
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
CcMdlReadCompleteDev (
|
||||
IN PMDL MdlChain,
|
||||
IN PDEVICE_OBJECT DeviceObject
|
||||
)
|
||||
VOID STDCALL
|
||||
CcMdlReadCompleteDev (IN PMDL MdlChain,
|
||||
IN PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
@ -281,21 +278,16 @@ CcMdlReadCompleteDev (
|
|||
* NOTE
|
||||
* From Bo Branten's ntifs.h v13.
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
CcMdlReadComplete (
|
||||
IN PFILE_OBJECT FileObject,
|
||||
IN PMDL MdlChain
|
||||
)
|
||||
VOID STDCALL
|
||||
CcMdlReadComplete (IN PFILE_OBJECT FileObject,
|
||||
IN PMDL MdlChain)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject = NULL;
|
||||
PDEVICE_OBJECT DeviceObject = NULL;
|
||||
|
||||
DeviceObject = IoGetRelatedDeviceObject (FileObject);
|
||||
/* FIXME: try fast I/O first */
|
||||
CcMdlReadCompleteDev (
|
||||
MdlChain,
|
||||
DeviceObject
|
||||
);
|
||||
DeviceObject = IoGetRelatedDeviceObject (FileObject);
|
||||
/* FIXME: try fast I/O first */
|
||||
CcMdlReadCompleteDev (MdlChain,
|
||||
DeviceObject);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/dbg/brkpoints.c
|
||||
* PURPOSE: Handles breakpoints
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* PROGRAMMER:
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
@ -16,17 +16,20 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL NtSystemDebugControl(VOID)
|
||||
NTSTATUS STDCALL
|
||||
NtSystemDebugControl(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
VOID STDCALL DbgBreakPoint(VOID)
|
||||
VOID STDCALL
|
||||
DbgBreakPoint(VOID)
|
||||
{
|
||||
__asm__("int $3\n\t");
|
||||
}
|
||||
|
||||
VOID STDCALL DbgBreakPointWithStatus(ULONG Status)
|
||||
VOID STDCALL
|
||||
DbgBreakPointWithStatus(ULONG Status)
|
||||
{
|
||||
__asm__("mov %0, %%eax\n\t"
|
||||
"int $3\n\t"
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/dbg/brkpoints.c
|
||||
* PURPOSE: Handles breakpoints
|
||||
* FILE: ntoskrnl/dbg/errinfo.c
|
||||
* PURPOSE: Print information descriptions of error messages
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
static PCHAR SeverityCodes[] = {"SUC", "INF", "ERR", "WRN"};
|
||||
|
||||
|
@ -172,7 +173,10 @@ static struct _ERRLIST
|
|||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
VOID DbgGetErrorText(NTSTATUS ErrorCode, PUNICODE_STRING ErrorText, ULONG Flags)
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID
|
||||
DbgGetErrorText(NTSTATUS ErrorCode, PUNICODE_STRING ErrorText, ULONG Flags)
|
||||
{
|
||||
int i;
|
||||
char TempBuf[255], NumBuf[32];
|
||||
|
@ -247,7 +251,8 @@ VOID DbgGetErrorText(NTSTATUS ErrorCode, PUNICODE_STRING ErrorText, ULONG Flags)
|
|||
RtlAnsiStringToUnicodeString(ErrorText, &AnsiString, TRUE);
|
||||
}
|
||||
|
||||
VOID DbgPrintErrorMessage(NTSTATUS ErrorCode)
|
||||
VOID
|
||||
DbgPrintErrorMessage(NTSTATUS ErrorCode)
|
||||
{
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -34,7 +34,8 @@ __asm__ ("\n\t.global _DbgService\n\t"
|
|||
* You'll only break the serial/bochs debugging feature!!!
|
||||
*/
|
||||
|
||||
ULONG DbgPrint(PCH Format, ...)
|
||||
ULONG
|
||||
DbgPrint(PCH Format, ...)
|
||||
{
|
||||
ANSI_STRING DebugString;
|
||||
CHAR Buffer[512];
|
||||
|
@ -54,28 +55,25 @@ ULONG DbgPrint(PCH Format, ...)
|
|||
}
|
||||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
DbgPrompt (
|
||||
PCH OutputString,
|
||||
PCH InputString,
|
||||
USHORT InputSize
|
||||
)
|
||||
VOID STDCALL
|
||||
DbgPrompt (PCH OutputString,
|
||||
PCH InputString,
|
||||
USHORT InputSize)
|
||||
{
|
||||
ANSI_STRING Output;
|
||||
ANSI_STRING Input;
|
||||
ANSI_STRING Output;
|
||||
ANSI_STRING Input;
|
||||
|
||||
Input.Length = 0;
|
||||
Input.MaximumLength = InputSize;
|
||||
Input.Buffer = InputString;
|
||||
Input.Length = 0;
|
||||
Input.MaximumLength = InputSize;
|
||||
Input.Buffer = InputString;
|
||||
|
||||
Output.Length = strlen (OutputString);
|
||||
Output.MaximumLength = Output.Length + 1;
|
||||
Output.Buffer = OutputString;
|
||||
Output.Length = strlen (OutputString);
|
||||
Output.MaximumLength = Output.Length + 1;
|
||||
Output.Buffer = OutputString;
|
||||
|
||||
/* FIXME: Not implemented yet! */
|
||||
// KdpPromptString (&Output,
|
||||
// &Input);
|
||||
/* FIXME: Not implemented yet! */
|
||||
// KdpPromptString (&Output,
|
||||
// &Input);
|
||||
}
|
||||
|
||||
/* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -66,40 +66,4 @@ ExUnregisterCallback (
|
|||
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 */
|
||||
|
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -18,7 +18,8 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID FASTCALL EXPORTED ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
||||
VOID FASTCALL EXPORTED
|
||||
ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
||||
{
|
||||
if (InterlockedDecrement(&FastMutex->Count) == 0)
|
||||
{
|
||||
|
@ -33,14 +34,15 @@ VOID FASTCALL EXPORTED ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
|||
FastMutex->Owner = KeGetCurrentThread();
|
||||
}
|
||||
|
||||
VOID FASTCALL EXPORTED ExReleaseFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
||||
VOID FASTCALL EXPORTED
|
||||
ExReleaseFastMutexUnsafe (PFAST_MUTEX FastMutex)
|
||||
{
|
||||
assert(FastMutex->Owner == KeGetCurrentThread());
|
||||
FastMutex->Owner = NULL;
|
||||
if (InterlockedIncrement(&FastMutex->Count) <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FastMutex->Owner = NULL;
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -16,12 +16,12 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
INTERLOCKED_RESULT
|
||||
STDCALL
|
||||
ExInterlockedDecrementLong (
|
||||
PLONG Addend,
|
||||
PKSPIN_LOCK Lock
|
||||
)
|
||||
INTERLOCKED_RESULT STDCALL
|
||||
ExInterlockedDecrementLong (PLONG Addend,
|
||||
PKSPIN_LOCK Lock)
|
||||
/*
|
||||
* Obsolete, use InterlockedDecrement instead
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
LONG oldval;
|
||||
|
@ -37,13 +37,13 @@ ExInterlockedDecrementLong (
|
|||
}
|
||||
|
||||
|
||||
ULONG
|
||||
STDCALL
|
||||
ExInterlockedExchangeUlong (
|
||||
PULONG Target,
|
||||
ULONG Value,
|
||||
PKSPIN_LOCK Lock
|
||||
)
|
||||
ULONG STDCALL
|
||||
ExInterlockedExchangeUlong (PULONG Target,
|
||||
ULONG Value,
|
||||
PKSPIN_LOCK Lock)
|
||||
/*
|
||||
* Obsolete, use InterlockedExchange instead
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
LONG oldval;
|
||||
|
@ -59,13 +59,25 @@ ExInterlockedExchangeUlong (
|
|||
}
|
||||
|
||||
|
||||
ULONG
|
||||
STDCALL
|
||||
ExInterlockedAddUlong (
|
||||
PULONG Addend,
|
||||
ULONG Increment,
|
||||
PKSPIN_LOCK Lock
|
||||
)
|
||||
ULONG STDCALL
|
||||
ExInterlockedAddUlong (PULONG Addend,
|
||||
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;
|
||||
ULONG oldval;
|
||||
|
@ -80,13 +92,23 @@ ExInterlockedAddUlong (
|
|||
return oldval;
|
||||
}
|
||||
|
||||
LARGE_INTEGER
|
||||
STDCALL
|
||||
ExInterlockedAddLargeInteger (
|
||||
PLARGE_INTEGER Addend,
|
||||
LARGE_INTEGER Increment,
|
||||
PKSPIN_LOCK Lock
|
||||
)
|
||||
LARGE_INTEGER STDCALL
|
||||
ExInterlockedAddLargeInteger (PLARGE_INTEGER Addend,
|
||||
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;
|
||||
LARGE_INTEGER oldval;
|
||||
|
@ -103,12 +125,12 @@ ExInterlockedAddLargeInteger (
|
|||
return oldval;
|
||||
}
|
||||
|
||||
INTERLOCKED_RESULT
|
||||
STDCALL
|
||||
ExInterlockedIncrementLong (
|
||||
PLONG Addend,
|
||||
PKSPIN_LOCK Lock
|
||||
)
|
||||
INTERLOCKED_RESULT STDCALL
|
||||
ExInterlockedIncrementLong (PLONG Addend,
|
||||
PKSPIN_LOCK Lock)
|
||||
/*
|
||||
* Obsolete, use InterlockedIncrement instead.
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
LONG oldval;
|
||||
|
@ -123,24 +145,24 @@ ExInterlockedIncrementLong (
|
|||
return oldval;
|
||||
}
|
||||
|
||||
VOID
|
||||
FASTCALL
|
||||
ExInterlockedAddLargeStatistic (
|
||||
IN PLARGE_INTEGER Addend,
|
||||
IN ULONG Increment
|
||||
)
|
||||
VOID FASTCALL
|
||||
ExInterlockedAddLargeStatistic (IN PLARGE_INTEGER Addend,
|
||||
IN ULONG Increment)
|
||||
/*
|
||||
* Undocumented in DDK.
|
||||
*/
|
||||
{
|
||||
Addend->QuadPart += Increment;
|
||||
}
|
||||
|
||||
LONGLONG
|
||||
FASTCALL
|
||||
ExInterlockedCompareExchange64 (
|
||||
IN OUT PLONGLONG Destination,
|
||||
IN PLONGLONG Exchange,
|
||||
IN PLONGLONG Comparand,
|
||||
IN PKSPIN_LOCK Lock
|
||||
)
|
||||
LONGLONG FASTCALL
|
||||
ExInterlockedCompareExchange64 (IN OUT PLONGLONG Destination,
|
||||
IN PLONGLONG Exchange,
|
||||
IN PLONGLONG Comparand,
|
||||
IN PKSPIN_LOCK Lock)
|
||||
/*
|
||||
* Undocumented in DDK.
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -15,19 +15,42 @@
|
|||
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtQueryDefaultLocale(IN BOOLEAN UserProfile,
|
||||
NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
|
||||
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;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtSetDefaultLocale(IN BOOLEAN UserProfile,
|
||||
NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -17,10 +17,7 @@
|
|||
#include <ddk/service.h>
|
||||
#include <ntdll/napi.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
KE_SERVICE_DESCRIPTOR_TABLE_ENTRY
|
||||
__declspec(dllexport)
|
||||
|
@ -32,7 +29,8 @@ KeServiceDescriptorTable[SSDT_MAX_ENTRIES] =
|
|||
{ 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 },
|
||||
{ NULL, NULL, 0, NULL },
|
||||
|
|
|
@ -20,13 +20,15 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL NtSetSystemPowerState(VOID)
|
||||
NTSTATUS STDCALL
|
||||
NtSetSystemPowerState(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
||||
NTSTATUS STDCALL
|
||||
NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
||||
{
|
||||
if (Action > ShutdownPowerOff)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
|
|
@ -38,7 +38,7 @@ VOID HalpInitPICs(VOID)
|
|||
/* Initialization sequence */
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x20, 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)0xa1, 0x48);
|
||||
/* 8259-1 is master */
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
/*
|
||||
* FIXME: We actually have one TSS per thread
|
||||
*/
|
||||
#define RESERVED_FOR_TSS (0x28)
|
||||
#define TSS_SELECTOR (0x28)
|
||||
#define PCR_SELECTOR (0x30)
|
||||
#define TEB_SELECTOR (0x38 + 0x3)
|
||||
#define RESERVED1_SELECTOR (0x40)
|
||||
|
|
|
@ -3,56 +3,20 @@
|
|||
#define __MODULE_H
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <coff.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
|
||||
{
|
||||
CSHORT ObjectType;
|
||||
CSHORT ObjectSize;
|
||||
PVOID Base;
|
||||
ULONG Length;
|
||||
unsigned int Flags;
|
||||
ULONG Flags;
|
||||
PVOID EntryPoint;
|
||||
LIST_ENTRY ListEntry;
|
||||
UNICODE_STRING Name;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned int NumberOfSyms;
|
||||
PVOID TextBase;
|
||||
PVOID DataBase;
|
||||
PVOID BSSBase;
|
||||
SCNHDR *SectionList;
|
||||
char *StringTable;
|
||||
SYMENT *SymbolList;
|
||||
} COFF;
|
||||
struct
|
||||
{
|
||||
PIMAGE_FILE_HEADER FileHeader;
|
||||
|
|
|
@ -30,10 +30,16 @@
|
|||
/*
|
||||
* Defines for accessing KPCR and KTHREAD structure members
|
||||
*/
|
||||
#define KTHREAD_INITIAL_STACK 0x18
|
||||
#define KTHREAD_TEB 0x20
|
||||
#define KTHREAD_KERNEL_STACK 0x28
|
||||
#define KTHREAD_PREVIOUS_MODE 0x137
|
||||
#define KTHREAD_TRAP_FRAME 0x128
|
||||
|
||||
#define ETHREAD_THREADS_PROCESS 0x258
|
||||
|
||||
#define KPROCESS_PAGE_TABLE_DIRECTORY 0x10
|
||||
|
||||
#define KPCR_BASE 0xFFDFF000
|
||||
|
||||
#define KPCR_EXCEPTION_LIST 0x0
|
||||
|
@ -138,8 +144,8 @@ typedef struct _KTHREAD
|
|||
UCHAR LargeStack; /* 135 */
|
||||
UCHAR ResourceIndex; /* 136 */
|
||||
UCHAR PreviousMode; /* 137 */
|
||||
TIME KernelTime; /* 138 */
|
||||
TIME UserTime; /* 13C */
|
||||
ULONG KernelTime; /* 138 */
|
||||
ULONG UserTime; /* 13C */
|
||||
KAPC_STATE SavedApcState; /* 140 */
|
||||
UCHAR Alertable; /* 158 */
|
||||
UCHAR ApcStateIndex; /* 159 */
|
||||
|
@ -159,16 +165,13 @@ typedef struct _KTHREAD
|
|||
*/
|
||||
|
||||
/* 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 */
|
||||
KDPC TimerDpc; /* 1B8 */
|
||||
|
||||
KDPC TimerDpc;
|
||||
/* Record the last EIP value when the thread is suspended */
|
||||
ULONG LastEip;
|
||||
ULONG LastEip; /* 1D8 */
|
||||
} __attribute__((packed)) KTHREAD, *PKTHREAD;
|
||||
|
||||
// According to documentation the stack should have a commited [ 1 page ] and
|
||||
|
@ -208,50 +211,60 @@ struct _WIN32THREADDATA;
|
|||
|
||||
typedef struct _ETHREAD
|
||||
{
|
||||
KTHREAD Tcb;
|
||||
TIME CreateTime;
|
||||
TIME ExitTime;
|
||||
NTSTATUS ExitStatus;
|
||||
LIST_ENTRY PostBlockList;
|
||||
LIST_ENTRY TerminationPortList;
|
||||
KSPIN_LOCK ActiveTimerListLock;
|
||||
PVOID ActiveTimerListHead;
|
||||
CLIENT_ID Cid;
|
||||
PLARGE_INTEGER LpcReplySemaphore;
|
||||
PVOID LpcReplyMessage;
|
||||
PLARGE_INTEGER LpcReplyMessageId;
|
||||
PPS_IMPERSONATION_INFO ImpersonationInfo;
|
||||
LIST_ENTRY IrpList;
|
||||
TOP_LEVEL_IRP TopLevelIrp;
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
ULONG ReadClusterSize;
|
||||
UCHAR ForwardClusterOnly;
|
||||
UCHAR DisablePageFaultClustering;
|
||||
UCHAR DeadThread;
|
||||
UCHAR HasTerminated;
|
||||
ACCESS_MASK GrantedAccess;
|
||||
struct _EPROCESS* ThreadsProcess;
|
||||
PKSTART_ROUTINE StartAddress;
|
||||
LPTHREAD_START_ROUTINE Win32StartAddress;
|
||||
UCHAR LpcExitThreadCalled;
|
||||
UCHAR HardErrorsAreDisabled;
|
||||
UCHAR LpcReceivedMsgIdValid;
|
||||
UCHAR ActiveImpersonationInfo;
|
||||
ULONG PerformanceCountHigh;
|
||||
KTHREAD Tcb; /* 000 */
|
||||
TIME CreateTime; /* 1B0/1DC */
|
||||
union
|
||||
{
|
||||
TIME ExitTime; /* 1B8/1E4 */
|
||||
LIST_ENTRY LpcReplyChain; /* 1B8/1E4 */
|
||||
} u1;
|
||||
NTSTATUS ExitStatus; /* 1C0/1EC */
|
||||
LIST_ENTRY PostBlockList; /* 1C4/1F0 */
|
||||
LIST_ENTRY TerminationPortList; /* 1CC/1F8 */
|
||||
KSPIN_LOCK ActiveTimerListLock; /* 1D4/200 */
|
||||
LIST_ENTRY ActiveTimerListHead; /* 1D8/204 */
|
||||
CLIENT_ID Cid; /* 1E0/20C */
|
||||
KSEMAPHORE LpcReplySemaphore; /* 1E8/214 */
|
||||
PVOID LpcReplyMessage; /* 1FC/228 */
|
||||
PLARGE_INTEGER LpcReplyMessageId; /* 200/22C */
|
||||
ULONG PerformanceCounterLow; /* 204/230 */
|
||||
PPS_IMPERSONATION_INFO ImpersonationInfo; /* 208/234 */
|
||||
LIST_ENTRY IrpList; /* 20C/238 */
|
||||
TOP_LEVEL_IRP* TopLevelIrp; /* 214/240 */
|
||||
PDEVICE_OBJECT DeviceToVerify; /* 218/244 */
|
||||
ULONG ReadClusterSize; /* 21C/248 */
|
||||
UCHAR ForwardClusterOnly; /* 220/24C */
|
||||
UCHAR DisablePageFaultClustering; /* 221/24D */
|
||||
UCHAR DeadThread; /* 222/24E */
|
||||
UCHAR HasTerminated; /* 223/24F */
|
||||
PVOID EventPair; /* 224/250 */
|
||||
ACCESS_MASK GrantedAccess; /* 228/254 */
|
||||
struct _EPROCESS* ThreadsProcess; /* 22C/258 */
|
||||
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)
|
||||
*/
|
||||
struct _EPROCESS* OldProcess;
|
||||
struct _WIN32THREADDATA *Win32ThreadData; // Pointer to win32 private thread data
|
||||
/*
|
||||
* Added by David Welch (welch@cwcom.net)
|
||||
*/
|
||||
struct _EPROCESS* OldProcess; /* 240/26C */
|
||||
struct _WIN32THREADDATA *Win32ThreadData; // Pointer to win32 private thread data
|
||||
|
||||
} ETHREAD, *PETHREAD;
|
||||
} __attribute__((packed)) ETHREAD, *PETHREAD;
|
||||
|
||||
|
||||
typedef struct _KPROCESS
|
||||
{
|
||||
DISPATCHER_HEADER DispatcherHeader;
|
||||
PVOID PageTableDirectory; // FIXME: I should point to a PTD
|
||||
DISPATCHER_HEADER DispatcherHeader; /* 000 */
|
||||
PVOID PageTableDirectory; /* 010 */
|
||||
TIME ElapsedTime;
|
||||
TIME KernelTime;
|
||||
TIME UserTime;
|
||||
|
@ -367,11 +380,13 @@ VOID PiInitApcManagement(VOID);
|
|||
VOID PiDeleteThread(PVOID ObjectBody);
|
||||
VOID PiCloseThread(PVOID ObjectBody, ULONG HandleCount);
|
||||
VOID PsReapThreads(VOID);
|
||||
NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||
PETHREAD* ThreadPtr,
|
||||
PHANDLE ThreadHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||
NTSTATUS
|
||||
PsInitializeThread(HANDLE ProcessHandle,
|
||||
PETHREAD* ThreadPtr,
|
||||
PHANDLE ThreadHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
BOOLEAN First);
|
||||
|
||||
PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
|
||||
PTOKEN_TYPE TokenType,
|
||||
|
@ -412,16 +427,16 @@ ULONG PsResumeThread(PETHREAD Thread);
|
|||
#define PROCESS_PRIO_HIGH 13
|
||||
#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);
|
||||
NTSTATUS HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
|
||||
NTSTATUS
|
||||
Ke386InitThread(PKTHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
|
||||
VOID HalTaskSwitch(PKTHREAD thread);
|
||||
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context);
|
||||
NTSTATUS
|
||||
Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context);
|
||||
NTSTATUS HalReleaseTask(PETHREAD Thread);
|
||||
VOID PiDeleteProcess(PVOID ObjectBody);
|
||||
VOID PsReapThreads(VOID);
|
||||
|
@ -430,6 +445,8 @@ VOID PsFreezeOtherThread(PETHREAD Thread);
|
|||
VOID PsFreezeProcessThreads(PEPROCESS Process);
|
||||
VOID PsUnfreezeProcessThreads(PEPROCESS Process);
|
||||
PEPROCESS PsGetNextProcess(PEPROCESS OldProcess);
|
||||
VOID
|
||||
Ki386ContextSwitch(PKTHREAD NewThread, PKTHREAD OldThread);
|
||||
|
||||
#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.
|
||||
*/
|
||||
/*
|
||||
* FILE: ntoskrnl/ke/i386/vm86_sup.S
|
||||
* FILE: ntoskrnl/include/internal/v86m.h
|
||||
* PURPOSE: V86 mode support
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* Created 10/12/00
|
||||
*/
|
||||
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_VM86_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_VM86_H
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_V86M_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;
|
||||
ULONG Esi;
|
||||
ULONG Edx;
|
||||
ULONG Ecx;
|
||||
ULONG Ebx;
|
||||
ULONG Eax;
|
||||
ULONG Ds;
|
||||
ULONG Es;
|
||||
ULONG Fs;
|
||||
ULONG Gs;
|
||||
ULONG Eip;
|
||||
ULONG Cs;
|
||||
ULONG Eflags;
|
||||
ULONG Esp;
|
||||
ULONG Ss;
|
||||
/*
|
||||
* General purpose registers
|
||||
*/
|
||||
|
||||
ULONG Ebp;
|
||||
ULONG Edi;
|
||||
ULONG Esi;
|
||||
ULONG Edx;
|
||||
ULONG Ecx;
|
||||
ULONG Ebx;
|
||||
ULONG Eax;
|
||||
ULONG Ds;
|
||||
ULONG Es;
|
||||
ULONG Fs;
|
||||
ULONG Gs;
|
||||
|
||||
/*
|
||||
* Control registers
|
||||
*/
|
||||
ULONG Eip;
|
||||
ULONG Cs;
|
||||
ULONG Eflags;
|
||||
ULONG Esp;
|
||||
ULONG Ss;
|
||||
|
||||
/*
|
||||
* Control structures
|
||||
*/
|
||||
ULONG RecoveryAddress;
|
||||
UCHAR RecoveryInstruction[4];
|
||||
ULONG Vif;
|
||||
ULONG Flags;
|
||||
PNTSTATUS PStatus;
|
||||
} KV86M_REGISTERS;
|
||||
|
||||
#else
|
||||
#else /* ASSEMBLER */
|
||||
|
||||
/*
|
||||
* Definitions for the offsets of members in the KV86M_REGISTERS
|
||||
|
@ -73,4 +95,4 @@ typedef struct
|
|||
|
||||
#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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -57,102 +57,90 @@ NtDeleteFile (IN POBJECT_ATTRIBUTES ObjectAttributes)
|
|||
*
|
||||
*/
|
||||
NTSTATUS
|
||||
IopCreateFile (
|
||||
PVOID ObjectBody,
|
||||
PVOID Parent,
|
||||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes
|
||||
)
|
||||
IopCreateFile (PVOID ObjectBody,
|
||||
PVOID Parent,
|
||||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT) Parent;
|
||||
PFILE_OBJECT FileObject = (PFILE_OBJECT) ObjectBody;
|
||||
NTSTATUS Status;
|
||||
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT) Parent;
|
||||
PFILE_OBJECT FileObject = (PFILE_OBJECT) ObjectBody;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT(
|
||||
"IopCreateFile(ObjectBody %x, Parent %x, RemainingPath %S)\n",
|
||||
ObjectBody,
|
||||
Parent,
|
||||
RemainingPath
|
||||
);
|
||||
DPRINT("IopCreateFile(ObjectBody %x, Parent %x, RemainingPath %S)\n",
|
||||
ObjectBody,
|
||||
Parent,
|
||||
RemainingPath);
|
||||
|
||||
if (NULL == DeviceObject)
|
||||
{
|
||||
DPRINT("DeviceObject was NULL\n");
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
if (NULL == DeviceObject)
|
||||
{
|
||||
DPRINT("DeviceObject was NULL\n");
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
if (IoDeviceObjectType != BODY_TO_HEADER(Parent)->ObjectType)
|
||||
{
|
||||
DPRINT ("Parent is not a device type\n");
|
||||
return (STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
Status = ObReferenceObjectByPointer (
|
||||
DeviceObject,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
IoDeviceObjectType,
|
||||
UserMode
|
||||
);
|
||||
if (STATUS_SUCCESS != Status)
|
||||
{
|
||||
CHECKPOINT;
|
||||
return (Status);
|
||||
}
|
||||
Status = ObReferenceObjectByPointer (DeviceObject,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
IoDeviceObjectType,
|
||||
UserMode);
|
||||
if (STATUS_SUCCESS != 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->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
||||
(ObjectAttributes->ObjectName->Length+1)*2);
|
||||
(ObjectAttributes->ObjectName->Length+1)*2);
|
||||
FileObject->FileName.Length = ObjectAttributes->ObjectName->Length;
|
||||
FileObject->FileName.MaximumLength =
|
||||
ObjectAttributes->ObjectName->MaximumLength;
|
||||
RtlCopyUnicodeString(&(FileObject->FileName),
|
||||
ObjectAttributes->ObjectName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM)
|
||||
&& (DeviceObject->DeviceType != FILE_DEVICE_DISK)
|
||||
)
|
||||
{
|
||||
DPRINT ("Device was wrong type\n");
|
||||
return (STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
|
||||
{
|
||||
DPRINT("Trying to mount storage device\n");
|
||||
Status = IoTryToMountStorageDevice (DeviceObject);
|
||||
DPRINT("Status %x\n", Status);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT(
|
||||
"Failed to mount storage device (statux %x)\n",
|
||||
Status
|
||||
);
|
||||
return (Status);
|
||||
}
|
||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||
}
|
||||
RtlCreateUnicodeString(&(FileObject->FileName),
|
||||
RemainingPath);
|
||||
}
|
||||
DPRINT(
|
||||
"FileObject->FileName.Buffer %S\n",
|
||||
FileObject->FileName.Buffer
|
||||
);
|
||||
FileObject->DeviceObject = DeviceObject;
|
||||
DPRINT(
|
||||
"FileObject %x DeviceObject %x\n",
|
||||
FileObject,
|
||||
DeviceObject
|
||||
);
|
||||
FileObject->Vpb = DeviceObject->Vpb;
|
||||
FileObject->Type = InternalFileType;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM)
|
||||
&& (DeviceObject->DeviceType != FILE_DEVICE_DISK)
|
||||
)
|
||||
{
|
||||
DPRINT ("Device was wrong type\n");
|
||||
return (STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
|
||||
{
|
||||
DPRINT("Trying to mount storage device\n");
|
||||
Status = IoTryToMountStorageDevice (DeviceObject);
|
||||
DPRINT("Status %x\n", Status);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Failed to mount storage device (statux %x)\n",
|
||||
Status);
|
||||
return (Status);
|
||||
}
|
||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||
}
|
||||
RtlCreateUnicodeString(&(FileObject->FileName),
|
||||
RemainingPath);
|
||||
}
|
||||
DPRINT("FileObject->FileName.Buffer %S\n",
|
||||
FileObject->FileName.Buffer);
|
||||
FileObject->DeviceObject = DeviceObject;
|
||||
DPRINT("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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -205,8 +205,7 @@ IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
|
|||
return(Current);
|
||||
}
|
||||
|
||||
PDEVICE_OBJECT
|
||||
STDCALL
|
||||
PDEVICE_OBJECT STDCALL
|
||||
IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
|
||||
PDEVICE_OBJECT TargetDevice)
|
||||
{
|
||||
|
@ -223,8 +222,7 @@ IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
|
|||
return(AttachedDevice);
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
VOID STDCALL
|
||||
IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
|
||||
PDRIVER_REINITIALIZE ReinitRoutine,
|
||||
PVOID Context)
|
||||
|
@ -232,8 +230,9 @@ IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
|
|||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
@ -242,7 +241,8 @@ NTSTATUS STDCALL IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject,
|
|||
return(STATUS_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry)
|
||||
NTSTATUS
|
||||
IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry)
|
||||
/*
|
||||
* FUNCTION: Called to initalize a loaded driver
|
||||
* ARGUMENTS:
|
||||
|
@ -277,8 +277,7 @@ NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry)
|
|||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NTSTATUS STDCALL
|
||||
IoAttachDevice(PDEVICE_OBJECT SourceDevice,
|
||||
PUNICODE_STRING TargetDevice,
|
||||
PDEVICE_OBJECT* AttachedDevice)
|
||||
|
@ -293,10 +292,11 @@ IoAttachDevice(PDEVICE_OBJECT SourceDevice,
|
|||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
||||
PVOID Parent,
|
||||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
NTSTATUS
|
||||
IopCreateDevice(PVOID ObjectBody,
|
||||
PVOID Parent,
|
||||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
|
||||
DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %S)\n",
|
||||
|
@ -315,15 +315,14 @@ NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NTSTATUS STDCALL
|
||||
IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||
ULONG DeviceExtensionSize,
|
||||
PUNICODE_STRING DeviceName,
|
||||
DEVICE_TYPE DeviceType,
|
||||
ULONG DeviceCharacteristics,
|
||||
BOOLEAN Exclusive,
|
||||
PDEVICE_OBJECT* DeviceObject)
|
||||
ULONG DeviceExtensionSize,
|
||||
PUNICODE_STRING DeviceName,
|
||||
DEVICE_TYPE DeviceType,
|
||||
ULONG DeviceCharacteristics,
|
||||
BOOLEAN Exclusive,
|
||||
PDEVICE_OBJECT* DeviceObject)
|
||||
/*
|
||||
* FUNCTION: Allocates memory for and intializes a device object for use for
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -337,7 +337,7 @@ IoSetTopLevelIrp (
|
|||
PETHREAD Thread;
|
||||
|
||||
Thread = PsGetCurrentThread ();
|
||||
Thread->TopLevelIrp.TopLevelIrp = Irp;
|
||||
Thread->TopLevelIrp->TopLevelIrp = Irp;
|
||||
}
|
||||
|
||||
|
||||
|
@ -347,7 +347,7 @@ IoGetTopLevelIrp (
|
|||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -15,44 +33,33 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
ExRaiseAccessViolation (
|
||||
VOID
|
||||
)
|
||||
VOID STDCALL
|
||||
ExRaiseAccessViolation (VOID)
|
||||
{
|
||||
ExRaiseStatus (STATUS_ACCESS_VIOLATION);
|
||||
ExRaiseStatus (STATUS_ACCESS_VIOLATION);
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
ExRaiseDatatypeMisalignment (
|
||||
VOID
|
||||
)
|
||||
VOID STDCALL
|
||||
ExRaiseDatatypeMisalignment (VOID)
|
||||
{
|
||||
ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT);
|
||||
ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT);
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
ExRaiseStatus (
|
||||
IN NTSTATUS Status
|
||||
)
|
||||
VOID STDCALL
|
||||
ExRaiseStatus (IN NTSTATUS Status)
|
||||
{
|
||||
DbgPrint("ExRaiseStatus(%x)\n",Status);
|
||||
for(;;);
|
||||
DbgPrint("ExRaiseStatus(%x)\n",Status);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtRaiseException (
|
||||
IN PEXCEPTION_RECORD ExceptionRecord,
|
||||
IN PCONTEXT Context,
|
||||
IN BOOL IsDebugger OPTIONAL
|
||||
)
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtRaiseException (IN PEXCEPTION_RECORD ExceptionRecord,
|
||||
IN PCONTEXT Context,
|
||||
IN BOOL IsDebugger OPTIONAL)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -45,7 +45,9 @@ USHORT KiGdt[(8 + NR_TASKS) * 4] =
|
|||
0x0, 0x0, 0xf200, 0xcc, /* User DS */
|
||||
0x0, 0x0, 0x0, 0x0, /* TSS */
|
||||
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;
|
||||
|
||||
|
@ -113,6 +115,7 @@ VOID KeDumpGdtSelector(ULONG Entry)
|
|||
DbgPrint("G: %d\n", (d & 0x80) >> 7);
|
||||
}
|
||||
|
||||
#if 0
|
||||
VOID KeFreeGdtSelector(ULONG Entry)
|
||||
/*
|
||||
* FUNCTION: Free a gdt selector
|
||||
|
@ -137,7 +140,9 @@ VOID KeFreeGdtSelector(ULONG Entry)
|
|||
KiGdt[Entry*4 + 3] = 0;
|
||||
KeReleaseSpinLock(&GdtLock, oldIrql);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
ULONG KeAllocateGdtSelector(ULONG Desc[2])
|
||||
/*
|
||||
* FUNCTION: Allocate a gdt selector
|
||||
|
@ -170,3 +175,4 @@ ULONG KeAllocateGdtSelector(ULONG Desc[2])
|
|||
KeReleaseSpinLock(&GdtLock, oldIrql);
|
||||
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
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/hal/x86/bthread.s
|
||||
* FILE: ntoskrnl/ke/i386/bthread.S
|
||||
* PURPOSE: Trap handlers
|
||||
* PROGRAMMER: David Welch (david.welch@seh.ox.ac.uk)
|
||||
* UPDATE HISTORY:
|
||||
* ???
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ddk/status.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/ps.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:
|
||||
call _PiBeforeBeginThread
|
||||
popl %eax
|
||||
popl %eax
|
||||
popl %eax
|
||||
popl %eax
|
||||
popl %eax
|
||||
popl %eax
|
||||
popl %eax
|
||||
addl $112,%esp
|
||||
popl %gs
|
||||
; popl %fs
|
||||
movl $TEB_SELECTOR, %ax
|
||||
movl %ax, %fs
|
||||
popl %es
|
||||
popl %ds
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
popl %edx
|
||||
popl %ecx
|
||||
popl %eax
|
||||
popl %ebp
|
||||
iret
|
||||
/*
|
||||
* This isn't really a function, we are called as the return
|
||||
* address of a context switch
|
||||
*/
|
||||
|
||||
/*
|
||||
* Do the necessary prolog before the context switch
|
||||
*/
|
||||
call _PiBeforeBeginThread
|
||||
|
||||
/*
|
||||
* Jump to the desired context
|
||||
*/
|
||||
popl %eax /* ContextFlags */
|
||||
popl %eax /* Dr0 */
|
||||
popl %eax /* Dr1 */
|
||||
popl %eax /* Dr2 */
|
||||
popl %eax /* Dr3 */
|
||||
popl %eax /* Dr6 */
|
||||
popl %eax /* Dr7 */
|
||||
addl $112,%esp /* FloatSave */
|
||||
popl %gs
|
||||
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/mm.h>
|
||||
#include <internal/ps.h>
|
||||
#include <internal/trap.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -72,7 +73,7 @@ static void print_address(PVOID address)
|
|||
if (address >= current->Base &&
|
||||
address < (current->Base + current->Length))
|
||||
{
|
||||
DbgPrint("<%S: %x>", current->Name,
|
||||
DbgPrint("<%wZ: %x>", ¤t->Name,
|
||||
address - current->Base);
|
||||
return;
|
||||
}
|
||||
|
@ -82,20 +83,8 @@ static void print_address(PVOID address)
|
|||
DbgPrint("<%x>", address);
|
||||
}
|
||||
|
||||
void exception_handler(unsigned int edi,
|
||||
unsigned int esi, unsigned int ebp,
|
||||
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)
|
||||
ULONG
|
||||
exception_handler(struct trap_frame* tf)
|
||||
/*
|
||||
* FUNCTION: Called by the lowlevel execption handlers to print an amusing
|
||||
* message and halt the computer
|
||||
|
@ -133,46 +122,55 @@ static void print_address(PVOID address)
|
|||
__asm__("movl %%cr2,%0\n\t"
|
||||
: "=d" (cr2));
|
||||
|
||||
if (PsGetCurrentThread() != NULL &&
|
||||
esp < (ULONG)PsGetCurrentThread()->Tcb.Context.KernelStackBase)
|
||||
if (tf->eflags & (1 << 17))
|
||||
{
|
||||
DbgPrint("Stack underflow\n");
|
||||
type = 12;
|
||||
return(KeV86Exception(tf, cr2));
|
||||
}
|
||||
|
||||
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");
|
||||
Status = MmPageFault(cs&0xffff,
|
||||
&eip,
|
||||
&eax,
|
||||
Status = MmPageFault(tf->cs&0xffff,
|
||||
&tf->eip,
|
||||
&tf->eax,
|
||||
cr2,
|
||||
error_code);
|
||||
tf->error_code);
|
||||
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);
|
||||
return;
|
||||
DbgPrint("Trap at CS:EIP %x:%x\n",tf->cs&0xffff,tf->eip);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out the CPU registers
|
||||
*/
|
||||
if (type < 19)
|
||||
if (tf->type < 19)
|
||||
{
|
||||
DbgPrint("%s Exception: %d(%x)\n",TypeStrings[type],type,
|
||||
error_code&0xffff);
|
||||
DbgPrint("%s Exception: %d(%x)\n",TypeStrings[tf->type],tf->type,
|
||||
tf->error_code&0xffff);
|
||||
}
|
||||
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);
|
||||
print_address((PVOID)eip);
|
||||
DbgPrint("CS:EIP %x:%x ",tf->cs&0xffff,tf->eip);
|
||||
print_address((PVOID)tf->eip);
|
||||
DbgPrint("\n");
|
||||
__asm__("movl %%cr3,%0\n\t"
|
||||
: "=d" (cr3));
|
||||
|
@ -191,29 +189,29 @@ static void print_address(PVOID address)
|
|||
PsGetCurrentThread()->Cid.UniqueThread);
|
||||
}
|
||||
DbgPrint("\n");
|
||||
DbgPrint("DS %x ES %x FS %x GS %x\n",ds&0xffff,es&0xffff,fs&0xffff,
|
||||
gs&0xfff);
|
||||
DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n",eax,ebx,ecx);
|
||||
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x\n",edx,ebp,esi);
|
||||
DbgPrint("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
|
||||
if ((cs&0xffff) == KERNEL_CS)
|
||||
DbgPrint("DS %x ES %x FS %x GS %x\n", tf->ds&0xffff, tf->es&0xffff,
|
||||
tf->fs&0xffff, tf->gs&0xfff);
|
||||
DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n", tf->eax, tf->ebx, tf->ecx);
|
||||
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x\n", tf->edx, tf->ebp, tf->esi);
|
||||
DbgPrint("EDI: %.8x EFLAGS: %.8x ", tf->edi, tf->eflags);
|
||||
if ((tf->cs&0xffff) == KERNEL_CS)
|
||||
{
|
||||
DbgPrint("kESP %.8x ",esp);
|
||||
DbgPrint("kESP %.8x ", tf->esp);
|
||||
if (PsGetCurrentThread() != NULL)
|
||||
{
|
||||
DbgPrint("kernel stack base %x\n",
|
||||
PsGetCurrentThread()->Tcb.Context.KernelStackBase);
|
||||
PsGetCurrentThread()->Tcb.StackLimit);
|
||||
|
||||
}
|
||||
}
|
||||
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);
|
||||
stack = (PULONG) (esp + 24);
|
||||
DbgPrint("ESP %x\n", tf->esp);
|
||||
stack = (PULONG) (tf->esp + 24);
|
||||
stack = (PULONG)(((ULONG)stack) & (~0x3));
|
||||
|
||||
DbgPrint("stack<%p>: ", stack);
|
||||
|
@ -242,8 +240,8 @@ static void print_address(PVOID address)
|
|||
else
|
||||
{
|
||||
#if 1
|
||||
DbgPrint("SS:ESP %x:%x\n",ss0,esp0);
|
||||
stack=(PULONG)(esp0);
|
||||
DbgPrint("SS:ESP %x:%x\n", tf->ss0, tf->esp0);
|
||||
stack=(PULONG)(tf->esp0);
|
||||
|
||||
DbgPrint("Stack:\n");
|
||||
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];
|
||||
|
||||
memcpy(instrs, (PVOID)eip, 512);
|
||||
memcpy(instrs, (PVOID)tf->eip, 512);
|
||||
|
||||
DbgPrint("Instrs: ");
|
||||
|
||||
|
@ -275,13 +273,13 @@ static void print_address(PVOID address)
|
|||
}
|
||||
|
||||
DbgPrint("\n");
|
||||
if ((cs&0xffff) == USER_CS &&
|
||||
eip < KERNEL_BASE)
|
||||
if ((tf->cs&0xffff) == USER_CS &&
|
||||
tf->eip < KERNEL_BASE)
|
||||
{
|
||||
DbgPrint("Killing current task\n");
|
||||
// for(;;);
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
if ((cs&0xffff) == USER_CS)
|
||||
if ((tf->cs&0xffff) == USER_CS)
|
||||
{
|
||||
ZwTerminateProcess(NtCurrentProcess(),
|
||||
STATUS_NONCONTINUABLE_EXCEPTION);
|
||||
|
@ -300,7 +298,7 @@ VOID KeDumpStackFrames(PVOID _Stack, ULONG NrFrames)
|
|||
if (PsGetCurrentThread() != NULL)
|
||||
{
|
||||
DbgPrint("kernel stack base %x\n",
|
||||
PsGetCurrentThread()->Tcb.Context.KernelStackBase);
|
||||
PsGetCurrentThread()->Tcb.StackLimit);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
DPRINT("sel %x %d\n",sel,sel);
|
||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||
(KERNEL_CS << 16);
|
||||
KiIdt[sel].b = 0xef00 + (((int)func)&0xffff0000);
|
||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||
(KERNEL_CS << 16);
|
||||
KiIdt[sel].b = 0xef00 + (((int)func)&0xffff0000);
|
||||
DPRINT("idt[sel].b %x\n",KiIdt[sel].b);
|
||||
}
|
||||
|
||||
static void set_interrupt_gate(unsigned int sel, unsigned int func)
|
||||
{
|
||||
DPRINT("set_interrupt_gate(sel %d, func %x)\n",sel,func);
|
||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||
(KERNEL_CS << 16);
|
||||
KiIdt[sel].b = 0x8f00 + (((int)func)&0xffff0000);
|
||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||
(KERNEL_CS << 16);
|
||||
KiIdt[sel].b = 0x8f00 + (((int)func)&0xffff0000);
|
||||
}
|
||||
|
||||
void KeInitExceptions(void)
|
||||
|
|
|
@ -23,81 +23,26 @@
|
|||
|
||||
/* 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 unsigned int KiNullLdtSel = 0;
|
||||
static PETHREAD FirstThread = NULL;
|
||||
|
||||
extern ULONG KeSetBaseGdtSelector(ULONG Entry, PVOID Base);
|
||||
|
||||
KTSS KiTss;
|
||||
|
||||
extern USHORT KiGdt[];
|
||||
|
||||
extern unsigned int init_stack_top;
|
||||
|
||||
/* 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_VM (1<<17)
|
||||
#define FLAG_IF (1<<9)
|
||||
#define FLAG_IOPL ((1<<12)+(1<<13))
|
||||
|
||||
NTSTATUS KeValidateUserContext(PCONTEXT Context)
|
||||
NTSTATUS
|
||||
KeValidateUserContext(PCONTEXT Context)
|
||||
/*
|
||||
* FUNCTION: Validates a processor context
|
||||
* ARGUMENTS:
|
||||
|
@ -143,13 +88,15 @@ NTSTATUS KeValidateUserContext(PCONTEXT Context)
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS HalReleaseTask(PETHREAD Thread)
|
||||
NTSTATUS
|
||||
HalReleaseTask(PETHREAD Thread)
|
||||
/*
|
||||
* FUNCTION: Releases the resource allocated for a thread by
|
||||
* HalInitTaskWithContext or HalInitTask
|
||||
* NOTE: The thread had better not be running when this is called
|
||||
*/
|
||||
{
|
||||
#if 0
|
||||
extern BYTE init_stack[MM_STACK_SIZE];
|
||||
|
||||
KeFreeGdtSelector(Thread->Tcb.Context.nr / 8);
|
||||
|
@ -161,186 +108,65 @@ NTSTATUS HalReleaseTask(PETHREAD Thread)
|
|||
{
|
||||
ExFreePool(Thread->Tcb.Context.SavedKernelStackBase);
|
||||
}
|
||||
#endif
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS HalInitTaskWithContext(PETHREAD 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
|
||||
*/
|
||||
NTSTATUS
|
||||
Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context)
|
||||
{
|
||||
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;
|
||||
ULONG GdtDesc[2];
|
||||
extern BYTE init_stack[16384];
|
||||
|
||||
DPRINT("HalInitTask(Thread %x, fn %x, StartContext %x)\n",
|
||||
thread,fn,StartContext);
|
||||
DPRINT("thread->ThreadsProcess %x\n",thread->ThreadsProcess);
|
||||
/*
|
||||
* Setup a stack frame for exit from the task switching routine
|
||||
*/
|
||||
|
||||
if (fn != NULL)
|
||||
{
|
||||
KernelStack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
KernelStack = (PULONG)init_stack;
|
||||
}
|
||||
KernelStack = (PULONG)(Thread->KernelStack - ((4 * 5) + sizeof(CONTEXT)));
|
||||
/* 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)PsBeginThreadWithContextInternal; /* EIP */
|
||||
memcpy((VOID*)&KernelStack[5], (VOID*)Context, sizeof(CONTEXT));
|
||||
Thread->KernelStack = (VOID*)KernelStack;
|
||||
|
||||
/*
|
||||
* 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);
|
||||
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
|
||||
* initial thread
|
||||
|
@ -348,28 +174,52 @@ void HalInitFirstTask(PETHREAD thread)
|
|||
{
|
||||
ULONG base;
|
||||
ULONG length;
|
||||
ULONG desc;
|
||||
ULONG GdtDesc[2];
|
||||
|
||||
/*
|
||||
* Set up an a descriptor for the LDT
|
||||
*/
|
||||
memset(KiNullLdt, 0, sizeof(KiNullLdt));
|
||||
base = (unsigned int)&KiNullLdt;
|
||||
length = sizeof(KiNullLdt) - 1;
|
||||
GdtDesc[0] = (length & 0xffff) | ((base & 0xffff) << 16);
|
||||
GdtDesc[1] = ((base & 0xff0000)>>16) | 0x8200 | (length & 0xf0000)
|
||||
| (base & 0xff000000);
|
||||
desc = KeAllocateGdtSelector(GdtDesc);
|
||||
KiNullLdtSel = desc*8;
|
||||
|
||||
KiGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF);
|
||||
KiGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF);
|
||||
KiGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200;
|
||||
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
|
||||
*/
|
||||
__asm__("ltr %%ax"
|
||||
: /* no output */
|
||||
: "a" (thread->Tcb.Context.nr));
|
||||
: "a" (TSS_SELECTOR));
|
||||
FirstThread = thread;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,34 +16,40 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* FILE: ntoskrnl/hal/x86/trap.s
|
||||
* FILE: ntoskrnl/ke/i386/trap.s
|
||||
* PURPOSE: Exception handlers
|
||||
* PROGRAMMER: David Welch (david.welch@seh.ox.ac.uk)
|
||||
* UPDATE HISTORY:
|
||||
* ???
|
||||
* PROGRAMMER: David Welch <welch@cwcom.net>
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ddk/status.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/ps.h>
|
||||
#include <ddk/defines.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
/*
|
||||
* Epilog for exception handlers
|
||||
*/
|
||||
_exception_handler_epilog:
|
||||
popa
|
||||
addl $4, %esp
|
||||
popl %ds
|
||||
cmpl $1, %eax /* Check for v86 recovery */
|
||||
jne _exception_handler_ret
|
||||
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 %fs
|
||||
popl %gs
|
||||
addl $4, %esp
|
||||
iret
|
||||
addl $4, %esp /* Ignore error code */
|
||||
iret /* Return from interrupt */
|
||||
|
||||
.globl _exception_handler0
|
||||
_exception_handler0:
|
||||
|
@ -59,405 +65,307 @@ _exception_handler0:
|
|||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler1
|
||||
_exception_handler1:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $1
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $1
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
|
||||
.globl _exception_handler2
|
||||
_exception_handler2:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $2
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $2
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler3
|
||||
_exception_handler3:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $3
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $3
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
|
||||
.globl _exception_handler4
|
||||
_exception_handler4:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $4
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $4
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler5
|
||||
_exception_handler5:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $5
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $5
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler6
|
||||
_exception_handler6:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $6
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $6
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler7
|
||||
_exception_handler7:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $7
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $7
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler8
|
||||
_exception_handler8:
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $8
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $8
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler9
|
||||
_exception_handler9:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $1
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $9
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler10
|
||||
_exception_handler10:
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $10
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $10
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler11
|
||||
_exception_handler11:
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $1
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $11
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler12
|
||||
_exception_handler12:
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $1
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $12
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler13
|
||||
_exception_handler13:
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $1
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $13
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler14
|
||||
_exception_handler14:
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $14
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $14
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler15
|
||||
_exception_handler15:
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $15
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $15
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler16
|
||||
_exception_handler16:
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $16
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $4,%esp
|
||||
popl %ds
|
||||
popl %es
|
||||
popl %fs
|
||||
popl %gs
|
||||
addl $4,%esp
|
||||
iret
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $16
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
.globl _exception_handler_unknown
|
||||
_exception_handler_unknown:
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl %ds
|
||||
pushl $0xff
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
call _exception_handler
|
||||
popa
|
||||
addl $8,%esp
|
||||
iret
|
||||
pushl $0
|
||||
pushl %gs
|
||||
pushl %fs
|
||||
pushl %es
|
||||
pushl %ds
|
||||
pushl $0xff
|
||||
pusha
|
||||
movw $KERNEL_DS,%ax
|
||||
movw %ax,%ds
|
||||
movw %ax,%es
|
||||
movw %ax,%fs
|
||||
movw %ax,%gs
|
||||
pushl %esp
|
||||
call _exception_handler
|
||||
jmp _exception_handler_epilog
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/ps.h>
|
||||
#include <ddk/i386/tss.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
@ -50,11 +51,35 @@ _Ki386ContextSwitch:
|
|||
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 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
|
||||
*/
|
||||
|
@ -73,12 +117,17 @@ _Ki386ContextSwitch:
|
|||
* FIXME: Restore debugging state
|
||||
*/
|
||||
|
||||
/*
|
||||
* Exit the critical section
|
||||
*/
|
||||
sti
|
||||
|
||||
/*
|
||||
* Restore the saved register and exit
|
||||
*/
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
movl %ebp, %esp
|
||||
popl %esp
|
||||
|
||||
popl %ebp
|
||||
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
|
||||
*/
|
||||
|
||||
#include <internal/vm86.h>
|
||||
#include <internal/v86m.h>
|
||||
#include <ddk/i386/tss.h>
|
||||
#include <internal/trap.h>
|
||||
|
||||
.globl _Ki386RetToV86Mode
|
||||
.globl _KiV86Complete
|
||||
|
||||
/*
|
||||
* NTSTATUS Ki386RetToV86Mode(KV86M_REGISTERS* in_regs,
|
||||
* KV86M_REGISTERS* out_regs);
|
||||
* VOID Ki386RetToV86Mode(KV86M_REGISTERS* InRegs,
|
||||
* KV86M_REGISTERS* OutRegs);
|
||||
*
|
||||
* Starts in v86 mode with the registers set to the
|
||||
* specified values.
|
||||
|
@ -57,36 +60,42 @@ _Ki386RetToV86Mode:
|
|||
*/
|
||||
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
|
||||
* will be the current stack adjusted so we don't overwrite the
|
||||
* existing stack frames
|
||||
*/
|
||||
movl %esp, TSS_ESP0(%esi)
|
||||
movl %esp, KTSS_ESP0(%esi)
|
||||
|
||||
/*
|
||||
* Create the stack frame for an iret to v86 mode
|
||||
*/
|
||||
pushl GS(%ebx)
|
||||
pushl FS(%ebx)
|
||||
pushl DS(%ebx)
|
||||
pushl ES(%ebx)
|
||||
pushl SS(%ebx)
|
||||
pushl ESP(%ebx)
|
||||
pushl EFLAGS(%ebx)
|
||||
pushl CS(%ebx)
|
||||
pushl EIP(%ebx)
|
||||
pushl KV86M_REGISTERS_GS(%ebx)
|
||||
pushl KV86M_REGISTERS_FS(%ebx)
|
||||
pushl KV86M_REGISTERS_DS(%ebx)
|
||||
pushl KV86M_REGISTERS_ES(%ebx)
|
||||
pushl KV86M_REGISTERS_SS(%ebx)
|
||||
pushl KV86M_REGISTERS_ESP(%ebx)
|
||||
pushl KV86M_REGISTERS_EFLAGS(%ebx)
|
||||
pushl KV86M_REGISTERS_CS(%ebx)
|
||||
pushl KV86M_REGISTERS_EIP(%ebx)
|
||||
|
||||
/*
|
||||
* Setup the CPU registers
|
||||
*/
|
||||
movl EAX(%ebx), %eax
|
||||
movl ECX(%ebx), %ecx
|
||||
movl EDX(%ebx), %edx
|
||||
movl ESI(%ebx), %esi
|
||||
movl EDI(%ebx), %edi
|
||||
movl EBP(%ebx), %ebp
|
||||
movl EBX(%ebx), %ebx
|
||||
movl KV86M_REGISTERS_EAX(%ebx), %eax
|
||||
movl KV86M_REGISTERS_ECX(%ebx), %ecx
|
||||
movl KV86M_REGISTERS_EDX(%ebx), %edx
|
||||
movl KV86M_REGISTERS_ESI(%ebx), %esi
|
||||
movl KV86M_REGISTERS_EDI(%ebx), %edi
|
||||
movl KV86M_REGISTERS_EBP(%ebx), %ebp
|
||||
movl KV86M_REGISTERS_EBX(%ebx), %ebx
|
||||
|
||||
/*
|
||||
* Go to v86 mode
|
||||
|
@ -98,40 +107,41 @@ _Ki386RetToV86Mode:
|
|||
* an exception handler with the registers at the point of the
|
||||
* exception on the stack.
|
||||
*/
|
||||
_vm86_complete:
|
||||
addl $4, %esp /* Ignore pointer to registers */
|
||||
addl $4, %esp /* Ignore exception number */
|
||||
_KiV86Complete:
|
||||
addl $4, %esp /* Ignore pointer to trap frame */
|
||||
|
||||
/* Get a pointer to the vm86_registers structure */
|
||||
movl _vm86_old_ebp, %ebp
|
||||
movl 8(%ebp), %ebx
|
||||
/* Restore the original ebp */
|
||||
movl TF_ORIG_EBP(%esp), %ebp
|
||||
|
||||
/* Save the vm86 registers into the vm86_registers structure */
|
||||
popl EBP(%ebx)
|
||||
popl EDI(%ebx)
|
||||
popl ESI(%ebx)
|
||||
popl EDX(%ebx)
|
||||
popl ECX(%ebx)
|
||||
popl EBX(%ebx)
|
||||
popl EAX(%ebx)
|
||||
/* Get a pointer to the OUT_REGS structure */
|
||||
movl 12(%ebp), %ebx
|
||||
|
||||
/* Save the vm86 registers into the OUT_REGS structure */
|
||||
popl KV86M_REGISTERS_EDI(%ebx)
|
||||
popl KV86M_REGISTERS_ESI(%ebx)
|
||||
popl KV86M_REGISTERS_EBP(%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 $4, %esp /* Ignore error code */
|
||||
|
||||
popl EIP(%ebx)
|
||||
popl CS(%ebx)
|
||||
popl EFLAGS(%ebx)
|
||||
popl ESP(%ebx)
|
||||
popl SS(%ebx)
|
||||
popl ES(%ebx)
|
||||
popl DS(%ebx)
|
||||
popl FS(%ebx)
|
||||
popl GS(%ebx)
|
||||
popl KV86M_REGISTERS_EIP(%ebx)
|
||||
popl KV86M_REGISTERS_CS(%ebx)
|
||||
popl KV86M_REGISTERS_EFLAGS(%ebx)
|
||||
popl KV86M_REGISTERS_ESP(%ebx)
|
||||
popl KV86M_REGISTERS_SS(%ebx)
|
||||
popl KV86M_REGISTERS_ES(%ebx)
|
||||
popl KV86M_REGISTERS_DS(%ebx)
|
||||
popl KV86M_REGISTERS_FS(%ebx)
|
||||
popl KV86M_REGISTERS_GS(%ebx)
|
||||
|
||||
/* Swap back to the stack */
|
||||
cli
|
||||
movl _vm86_old_esp, %esp
|
||||
sti
|
||||
movl _vm86_old_ebp, %ebp
|
||||
/* Ignore IN_REGS pointer */
|
||||
addl $4, %esp
|
||||
|
||||
/* Ignore ebp restored above */
|
||||
addl $4, %esp
|
||||
|
||||
/* Return to caller */
|
||||
popa
|
||||
|
@ -140,3 +150,7 @@ _vm86_complete:
|
|||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* 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
|
||||
* 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 *****************************************************************/
|
||||
|
||||
VOID
|
||||
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread)
|
||||
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First)
|
||||
/*
|
||||
* FUNCTION: Initialize the microkernel state of the thread
|
||||
*/
|
||||
{
|
||||
PVOID KernelStack;
|
||||
extern unsigned int init_stack_top;
|
||||
extern unsigned int init_stack;
|
||||
|
||||
#if 0
|
||||
DbgPrint("Thread %x &Thread->MutantListHead %x &Thread->TrapFrame %x "
|
||||
|
@ -61,15 +63,26 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread)
|
|||
sizeof(ETHREAD),
|
||||
FALSE);
|
||||
InitializeListHead(&Thread->MutantListHead);
|
||||
KernelStack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
|
||||
Thread->InitialStack = KernelStack + MM_STACK_SIZE;
|
||||
Thread->StackLimit = (ULONG)KernelStack;
|
||||
if (!First)
|
||||
{
|
||||
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
|
||||
*/
|
||||
Thread->Teb = NULL;
|
||||
Thread->TlsArray = NULL;
|
||||
Thread->KernelStack = KernelStack + MM_STACK_SIZE;
|
||||
Thread->DebugActive = 0;
|
||||
Thread->State = THREAD_STATE_SUSPENDED;
|
||||
Thread->Alerted[0] = 0;
|
||||
|
@ -127,8 +140,8 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread)
|
|||
Thread->LargeStack = 0;
|
||||
Thread->ResourceIndex = 0;
|
||||
Thread->PreviousMode = KernelMode;
|
||||
Thread->KernelTime.QuadPart = 0;
|
||||
Thread->UserTime.QuadPart = 0;
|
||||
Thread->KernelTime = 0;
|
||||
Thread->UserTime = 0;
|
||||
memset(&Thread->SavedApcState, 0, sizeof(KAPC_STATE));
|
||||
Thread->Alertable = 1;
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -21,11 +21,8 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
KeAttachProcess (
|
||||
PEPROCESS Process
|
||||
)
|
||||
VOID STDCALL
|
||||
KeAttachProcess (PEPROCESS Process)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PETHREAD CurrentThread;
|
||||
|
@ -46,7 +43,6 @@ KeAttachProcess (
|
|||
CurrentThread->OldProcess = PsGetCurrentProcess();
|
||||
CurrentThread->ThreadsProcess = Process;
|
||||
PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.PageTableDirectory;
|
||||
CurrentThread->Tcb.Context.cr3 = PageDir;
|
||||
DPRINT("Switching process context to %x\n",PageDir)
|
||||
__asm__("movl %0,%%cr3\n\t"
|
||||
: /* no inputs */
|
||||
|
@ -56,11 +52,8 @@ KeAttachProcess (
|
|||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
KeDetachProcess (
|
||||
VOID
|
||||
)
|
||||
VOID STDCALL
|
||||
KeDetachProcess (VOID)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PETHREAD CurrentThread;
|
||||
|
@ -81,7 +74,6 @@ KeDetachProcess (
|
|||
CurrentThread->ThreadsProcess = CurrentThread->OldProcess;
|
||||
CurrentThread->OldProcess = NULL;
|
||||
PageDir = (ULONG)CurrentThread->ThreadsProcess->Pcb.PageTableDirectory;
|
||||
CurrentThread->Tcb.Context.cr3 = PageDir;
|
||||
__asm__("movl %0,%%cr3\n\t"
|
||||
: /* no inputs */
|
||||
: "r" (PageDir));
|
||||
|
|
|
@ -25,11 +25,21 @@
|
|||
|
||||
static PVOID SystemDllEntryPoint = NULL;
|
||||
static PVOID SystemDllApcDispatcher = NULL;
|
||||
//static PVOID SystemDllCallbackDispatcher = NULL;
|
||||
//static PVOID SystemDllExceptionDispatcher = NULL;
|
||||
static PVOID SystemDllCallbackDispatcher = NULL;
|
||||
static PVOID SystemDllExceptionDispatcher = NULL;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
PVOID LdrpGetSystemDllExceptionDispatcher(VOID)
|
||||
{
|
||||
return(SystemDllExceptionDispatcher);
|
||||
}
|
||||
|
||||
PVOID LdrpGetSystemDllCallbackDispatcher(VOID)
|
||||
{
|
||||
return(SystemDllCallbackDispatcher);
|
||||
}
|
||||
|
||||
PVOID LdrpGetSystemDllEntryPoint(VOID)
|
||||
{
|
||||
return(SystemDllEntryPoint);
|
||||
|
@ -242,7 +252,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
|||
*LdrStartupAddr = SystemDllEntryPoint;
|
||||
|
||||
/*
|
||||
* FIXME: retrieve the offset of the APC dispatcher from NTDLL
|
||||
* Retrieve the offset of the APC dispatcher from NTDLL
|
||||
*/
|
||||
RtlInitAnsiString (&ProcedureName,
|
||||
"KiUserApcDispatcher");
|
||||
|
@ -259,6 +269,42 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
|||
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();
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -82,7 +82,8 @@ PsAssignImpersonationToken(PETHREAD Thread,
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
VOID STDCALL PsRevertToSelf(PETHREAD Thread)
|
||||
VOID STDCALL
|
||||
PsRevertToSelf(PETHREAD Thread)
|
||||
{
|
||||
if (Thread->ActiveImpersonationInfo != 0)
|
||||
{
|
||||
|
@ -91,11 +92,12 @@ VOID STDCALL PsRevertToSelf(PETHREAD Thread)
|
|||
}
|
||||
}
|
||||
|
||||
VOID STDCALL PsImpersonateClient(PETHREAD Thread,
|
||||
PACCESS_TOKEN Token,
|
||||
UCHAR b,
|
||||
UCHAR c,
|
||||
SECURITY_IMPERSONATION_LEVEL Level)
|
||||
VOID STDCALL
|
||||
PsImpersonateClient(PETHREAD Thread,
|
||||
PACCESS_TOKEN Token,
|
||||
UCHAR b,
|
||||
UCHAR c,
|
||||
SECURITY_IMPERSONATION_LEVEL Level)
|
||||
{
|
||||
if (Token == 0)
|
||||
{
|
||||
|
@ -126,10 +128,11 @@ VOID STDCALL PsImpersonateClient(PETHREAD Thread,
|
|||
Thread->ActiveImpersonationInfo = 1;
|
||||
}
|
||||
|
||||
PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
|
||||
PTOKEN_TYPE TokenType,
|
||||
PUCHAR b,
|
||||
PSECURITY_IMPERSONATION_LEVEL Level)
|
||||
PACCESS_TOKEN
|
||||
PsReferenceEffectiveToken(PETHREAD Thread,
|
||||
PTOKEN_TYPE TokenType,
|
||||
PUCHAR b,
|
||||
PSECURITY_IMPERSONATION_LEVEL Level)
|
||||
{
|
||||
PEPROCESS Process;
|
||||
PACCESS_TOKEN Token;
|
||||
|
@ -151,10 +154,11 @@ PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
|
|||
return(Token);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtImpersonateThread (IN HANDLE ThreadHandle,
|
||||
IN HANDLE ThreadToImpersonateHandle,
|
||||
IN PSECURITY_QUALITY_OF_SERVICE
|
||||
SecurityQualityOfService)
|
||||
NTSTATUS STDCALL
|
||||
NtImpersonateThread (IN HANDLE ThreadHandle,
|
||||
IN HANDLE ThreadToImpersonateHandle,
|
||||
IN PSECURITY_QUALITY_OF_SERVICE
|
||||
SecurityQualityOfService)
|
||||
{
|
||||
PETHREAD Thread;
|
||||
PETHREAD ThreadToImpersonate;
|
||||
|
@ -203,10 +207,11 @@ NTSTATUS STDCALL NtImpersonateThread (IN HANDLE ThreadHandle,
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtOpenThreadToken(IN HANDLE ThreadHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN BOOLEAN OpenAsSelf,
|
||||
OUT PHANDLE TokenHandle)
|
||||
NTSTATUS STDCALL
|
||||
NtOpenThreadToken(IN HANDLE ThreadHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN BOOLEAN OpenAsSelf,
|
||||
OUT PHANDLE TokenHandle)
|
||||
{
|
||||
#if 0
|
||||
PETHREAD Thread;
|
||||
|
@ -230,11 +235,11 @@ NTSTATUS STDCALL NtOpenThreadToken(IN HANDLE ThreadHandle,
|
|||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(PETHREAD Thread,
|
||||
PULONG Unknown1,
|
||||
PULONG Unknown2,
|
||||
SECURITY_IMPERSONATION_LEVEL*
|
||||
Level)
|
||||
PACCESS_TOKEN STDCALL
|
||||
PsReferenceImpersonationToken(PETHREAD Thread,
|
||||
PULONG Unknown1,
|
||||
PULONG Unknown2,
|
||||
SECURITY_IMPERSONATION_LEVEL* Level)
|
||||
{
|
||||
if (Thread->ActiveImpersonationInfo == 0)
|
||||
{
|
||||
|
@ -251,10 +256,11 @@ PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(PETHREAD Thread,
|
|||
return(Thread->ImpersonationInfo->Token);
|
||||
}
|
||||
|
||||
VOID PiTimeoutThread(struct _KDPC *dpc,
|
||||
PVOID Context,
|
||||
PVOID arg1,
|
||||
PVOID arg2)
|
||||
VOID
|
||||
PiTimeoutThread(struct _KDPC *dpc,
|
||||
PVOID Context,
|
||||
PVOID arg1,
|
||||
PVOID arg2)
|
||||
{
|
||||
// wake up the thread, and tell it it timed out
|
||||
NTSTATUS Status = STATUS_TIMEOUT;
|
||||
|
@ -264,23 +270,27 @@ VOID PiTimeoutThread(struct _KDPC *dpc,
|
|||
KeRemoveAllWaitsThread((PETHREAD)Context, Status);
|
||||
}
|
||||
|
||||
VOID PiBeforeBeginThread(CONTEXT c)
|
||||
VOID
|
||||
PiBeforeBeginThread(CONTEXT c)
|
||||
{
|
||||
DPRINT("PiBeforeBeginThread(Eip %x)\n", c.Eip);
|
||||
//KeReleaseSpinLock(&PiThreadListLock, PASSIVE_LEVEL);
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
}
|
||||
|
||||
VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
|
||||
#if 0
|
||||
VOID
|
||||
PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
|
||||
{
|
||||
NTSTATUS Ret;
|
||||
|
||||
// KeReleaseSpinLock(&PiThreadListLock,PASSIVE_LEVEL);
|
||||
// KeReleaseSpinLock(&PiThreadListLock,PASSIVE_LEVEL);
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
Ret = StartRoutine(StartContext);
|
||||
PsTerminateSystemThread(Ret);
|
||||
KeBugCheck(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID PiDeleteThread(PVOID ObjectBody)
|
||||
{
|
||||
|
@ -313,7 +323,8 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
|||
PETHREAD* ThreadPtr,
|
||||
PHANDLE ThreadHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ThreadAttributes)
|
||||
POBJECT_ATTRIBUTES ThreadAttributes,
|
||||
BOOLEAN First)
|
||||
{
|
||||
PETHREAD Thread;
|
||||
NTSTATUS Status;
|
||||
|
@ -358,7 +369,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
|||
|
||||
PiNrThreads++;
|
||||
|
||||
KeInitializeThread(&Process->Pcb, &Thread->Tcb);
|
||||
KeInitializeThread(&Process->Pcb, &Thread->Tcb, First);
|
||||
Thread->ThreadsProcess = Process;
|
||||
/*
|
||||
* FIXME: What lock protects this?
|
||||
|
@ -418,6 +429,7 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
|
|||
DbgPrint("NtQueryVirtualMemory (Status %x)\n", Status);
|
||||
KeBugCheck(0);
|
||||
}
|
||||
/* FIXME: Race between this and the above check */
|
||||
if (Info.State == MEM_FREE)
|
||||
{
|
||||
/* The TEB must reside in user space */
|
||||
|
@ -517,7 +529,7 @@ NTSTATUS STDCALL NtCreateThread (PHANDLE ThreadHandle,
|
|||
ThreadHandle,ThreadContext);
|
||||
|
||||
Status = PsInitializeThread(ProcessHandle,&Thread,ThreadHandle,
|
||||
DesiredAccess,ObjectAttributes);
|
||||
DesiredAccess,ObjectAttributes, FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
|
@ -537,7 +549,8 @@ NTSTATUS STDCALL NtCreateThread (PHANDLE ThreadHandle,
|
|||
ThreadContext->Eip = LdrpGetSystemDllEntryPoint;
|
||||
#endif
|
||||
|
||||
Status = HalInitTaskWithContext(Thread,ThreadContext);
|
||||
// Status = HalInitTaskWithContext(Thread,ThreadContext);
|
||||
Status = Ke386InitThreadWithContext(&Thread->Tcb, ThreadContext);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
|
@ -630,14 +643,15 @@ NTSTATUS STDCALL PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
ThreadHandle,ProcessHandle);
|
||||
|
||||
Status = PsInitializeThread(ProcessHandle,&Thread,ThreadHandle,
|
||||
DesiredAccess,ObjectAttributes);
|
||||
DesiredAccess,ObjectAttributes, FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
Thread->StartAddress=StartRoutine;
|
||||
Status = HalInitTask(Thread,StartRoutine,StartContext);
|
||||
// Status = HalInitTask(Thread,StartRoutine,StartContext);
|
||||
Status = Ke386InitThread(&Thread->Tcb, StartRoutine, StartContext);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
|
|
|
@ -32,7 +32,8 @@ VOID PsTerminateCurrentThread(NTSTATUS ExitStatus);
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
|
||||
VOID
|
||||
PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PLIST_ENTRY current_entry;
|
||||
|
@ -46,19 +47,30 @@ VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
|
|||
current_entry = Process->ThreadListHead.Flink;
|
||||
while (current_entry != &Process->ThreadListHead)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry,ETHREAD,Tcb.ProcessThreadListEntry);
|
||||
if (current != PsGetCurrentThread())
|
||||
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
||||
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);
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldlvl);
|
||||
current_entry = Process->ThreadListHead.Flink;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
|
||||
DPRINT("Finished PiTerminateProcessThreads()\n");
|
||||
}
|
||||
|
||||
VOID PsReapThreads(VOID)
|
||||
VOID
|
||||
PsReapThreads(VOID)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
PETHREAD current;
|
||||
|
@ -127,26 +139,27 @@ VOID PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
|||
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
|
||||
* NOTES: This function must be called with PiThreadListLock held
|
||||
*/
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
|
||||
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
||||
Thread, ExitStatus);
|
||||
|
||||
KeAcquireSpinLock( &PiThreadListLock, &oldIrql );
|
||||
Thread->DeadThread = 1;
|
||||
Thread->ExitStatus = ExitStatus;
|
||||
if( Thread->Tcb.State == THREAD_STATE_FROZEN && (Thread->Tcb.Alertable || Thread->Tcb.WaitMode == UserMode) )
|
||||
KeRemoveAllWaitsThread( Thread, STATUS_ALERTED );
|
||||
KeReleaseSpinLock( &PiThreadListLock, oldIrql );
|
||||
if (Thread->Tcb.State == THREAD_STATE_FROZEN &&
|
||||
(Thread->Tcb.Alertable || Thread->Tcb.WaitMode == UserMode))
|
||||
{
|
||||
KeRemoveAllWaitsThread(Thread, STATUS_ALERTED);
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process,
|
||||
NTSTATUS ExitStatus)
|
||||
NTSTATUS STDCALL
|
||||
PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus)
|
||||
{
|
||||
DPRINT("PiTerminateProcess(Process %x, ExitStatus %x) RC %d HC %d\n",
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -53,25 +53,11 @@ static PETHREAD CurrentThread = NULL;
|
|||
|
||||
PKTHREAD STDCALL KeGetCurrentThread(VOID)
|
||||
{
|
||||
#if 0
|
||||
if (CurrentThread != NULL)
|
||||
{
|
||||
DbgPrint("KeGetCurrentThread() called before initialization\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
#endif
|
||||
return(&(CurrentThread->Tcb));
|
||||
}
|
||||
|
||||
PETHREAD STDCALL PsGetCurrentThread(VOID)
|
||||
{
|
||||
#if 0
|
||||
if (CurrentThread != NULL)
|
||||
{
|
||||
DbgPrint("PsGetCurrentThread() called before initialization\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
#endif
|
||||
return(CurrentThread);
|
||||
}
|
||||
|
||||
|
@ -122,7 +108,7 @@ VOID PsDumpThreads(VOID)
|
|||
}
|
||||
DbgPrint("current %x current->Tcb.State %d eip %x/%x ",
|
||||
current, current->Tcb.State,
|
||||
current->Tcb.Context.eip, current->Tcb.LastEip);
|
||||
0, current->Tcb.LastEip);
|
||||
// KeDumpStackFrames((PVOID)current->Tcb.Context.esp0,
|
||||
// 16);
|
||||
DbgPrint("PID %d ", current->ThreadsProcess->UniqueProcessId);
|
||||
|
@ -182,14 +168,18 @@ VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
|
|||
}
|
||||
if (Candidate != NULL)
|
||||
{
|
||||
PETHREAD OldThread;
|
||||
|
||||
DPRINT("Scheduling %x(%d)\n",Candidate, CurrentPriority);
|
||||
|
||||
Candidate->Tcb.State = THREAD_STATE_RUNNING;
|
||||
|
||||
OldThread = CurrentThread;
|
||||
CurrentThread = Candidate;
|
||||
|
||||
KeReleaseSpinLockFromDpcLevel(&PiThreadListLock);
|
||||
HalTaskSwitch(&CurrentThread->Tcb);
|
||||
// HalTaskSwitch(&CurrentThread->Tcb);
|
||||
Ki386ContextSwitch(&CurrentThread->Tcb, &OldThread->Tcb);
|
||||
PsReapThreads();
|
||||
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)
|
||||
|
@ -352,7 +343,8 @@ ULONG PsSuspendThread(PETHREAD Thread)
|
|||
return PreviousSuspendCount;
|
||||
}
|
||||
|
||||
VOID PsInitThreadManagment(VOID)
|
||||
VOID
|
||||
PsInitThreadManagment(VOID)
|
||||
/*
|
||||
* FUNCTION: Initialize thread managment
|
||||
*/
|
||||
|
@ -389,7 +381,7 @@ VOID PsInitThreadManagment(VOID)
|
|||
PsThreadType->Create = NULL;
|
||||
|
||||
PsInitializeThread(NULL,&FirstThread,&FirstThreadHandle,
|
||||
THREAD_ALL_ACCESS,NULL);
|
||||
THREAD_ALL_ACCESS,NULL, TRUE);
|
||||
HalInitFirstTask(FirstThread);
|
||||
FirstThread->Tcb.State = THREAD_STATE_RUNNING;
|
||||
FirstThread->Tcb.FreezeCount = 0;
|
||||
|
@ -479,16 +471,18 @@ NTSTATUS STDCALL NtAlertThread (IN HANDLE ThreadHandle)
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtOpenThread(OUT PHANDLE ThreadHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN PCLIENT_ID ClientId)
|
||||
NTSTATUS STDCALL
|
||||
NtOpenThread(OUT PHANDLE ThreadHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN PCLIENT_ID ClientId)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtResumeThread (IN HANDLE ThreadHandle,
|
||||
IN PULONG SuspendCount)
|
||||
NTSTATUS STDCALL
|
||||
NtResumeThread (IN HANDLE ThreadHandle,
|
||||
IN PULONG SuspendCount)
|
||||
/*
|
||||
* FUNCTION: Decrements a thread's resume count
|
||||
* ARGUMENTS:
|
||||
|
@ -528,8 +522,9 @@ NTSTATUS STDCALL NtResumeThread (IN HANDLE ThreadHandle,
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtSuspendThread (IN HANDLE ThreadHandle,
|
||||
IN PULONG PreviousSuspendCount)
|
||||
NTSTATUS STDCALL
|
||||
NtSuspendThread (IN HANDLE ThreadHandle,
|
||||
IN PULONG PreviousSuspendCount)
|
||||
/*
|
||||
* FUNCTION: Increments a thread's suspend count
|
||||
* ARGUMENTS:
|
||||
|
@ -570,12 +565,35 @@ NTSTATUS STDCALL NtSuspendThread (IN HANDLE ThreadHandle,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtCallbackReturn (PVOID Result,
|
||||
ULONG ResultLength,
|
||||
NTSTATUS Status)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtContinue(IN PCONTEXT Context,
|
||||
IN BOOLEAN TestAlert)
|
||||
NTSTATUS STDCALL
|
||||
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;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
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);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue