Preparations for checked/free like builds (CPRINT == DbgPrint when DBG is defined).

Modified loadros to support loading symbol files early at startup.
Modified loadros to convey BIOS memory map to the kernel if available.
Began building PnP manager device tree.
Added shutdown command to shell.exe

svn path=/trunk/; revision=1852
This commit is contained in:
Casper Hornstrup 2001-05-01 23:08:21 +00:00
parent 58e60b3092
commit 87589daf4e
50 changed files with 2281 additions and 628 deletions

View file

@ -16,6 +16,7 @@ include rules.mak
# Required to run the system
#
COMPONENTS = iface_native iface_additional ntoskrnl
BUS = acpi isapnp
DLLS = ntdll kernel32 crtdll advapi32 fmifs gdi32 secur32 user32 ws2_32 msafd msvcrt
SUBSYS = smss win32k csrss
@ -66,11 +67,11 @@ NET_APPS = ping
KERNEL_SERVICES = $(DEVICE_DRIVERS) $(INPUT_DRIVERS) $(FS_DRIVERS) $(NET_DRIVERS) $(NET_DEVICE_DRIVERS)
all: buildno $(COMPONENTS) $(DLLS) $(SUBSYS) $(LOADERS) $(KERNEL_SERVICES) $(SYS_APPS) $(APPS) $(NET_APPS)
all: buildno $(COMPONENTS) $(BUS) $(DLLS) $(SUBSYS) $(LOADERS) $(KERNEL_SERVICES) $(SYS_APPS) $(APPS) $(NET_APPS)
.PHONY: all
clean: buildno_clean $(COMPONENTS:%=%_clean) $(DLLS:%=%_clean) $(LOADERS:%=%_clean) \
clean: buildno_clean $(COMPONENTS:%=%_clean) $(BUS:%=%_clean) $(DLLS:%=%_clean) $(LOADERS:%=%_clean) \
$(KERNEL_SERVICES:%=%_clean) $(SUBSYS:%=%_clean) $(SYS_APPS:%=%_clean) $(APPS:%=%_clean)
.PHONY: clean
@ -94,12 +95,14 @@ rmkdir$(EXE_POSTFIX): rmkdir.c
endif
install: rcopy$(EXE_POSTFIX) rmkdir$(EXE_POSTFIX) make_install_dirs autoexec_install $(COMPONENTS:%=%_install) \
install: rcopy$(EXE_POSTFIX) rmkdir$(EXE_POSTFIX) make_install_dirs autoexec_install \
$(COMPONENTS:%=%_install) $(BUS:%=%_install) \
$(DLLS:%=%_install) $(LOADERS:%=%_install) \
$(KERNEL_SERVICES:%=%_install) $(SUBSYS:%=%_install) \
$(SYS_APPS:%=%_install) $(APPS:%=%_install)
dist: rcopy$(EXE_POSTFIX) clean_dist_dir make_dist_dirs $(COMPONENTS:%=%_dist) $(DLLS:%=%_dist) \
dist: rcopy$(EXE_POSTFIX) clean_dist_dir make_dist_dirs $(COMPONENTS:%=%_dist) \
$(BUS:%=%_dist) $(DLLS:%=%_dist) \
$(LOADERS:%=%_dist) $(KERNEL_SERVICES:%=%_dist) $(SUBSYS:%=%_dist) \
$(SYS_APPS:%=%_dist) $(APPS:%=%_dist)
@ -197,6 +200,24 @@ iface_additional_dist:
iface_additional iface_additional_clean iface_additional_install \
iface_additional_dist
#
# Bus driver rules
#
$(BUS): %:
make -C services/bus/$*
$(BUS:%=%_clean): %_clean:
make -C services/bus/$* clean
$(BUS:%=%_install): %_install:
make -C services/bus/$* install
$(BUS:%=%_dist): %_dist:
make -C services/bus/$* dist
.PHONY: $(BUS) $(BUS:%=%_clean) \
$(BUS:%=%_install) $(BUS:%=%_dist)
#
# Device driver rules
#

View file

@ -1,4 +1,4 @@
/* $Id: ping.c,v 1.3 2001/01/27 22:38:42 ea Exp $
/* $Id: ping.c,v 1.4 2001/05/01 23:08:17 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS ping utility
@ -21,7 +21,9 @@
/* Should be in the header files somewhere (exported by ntdll.dll) */
long atol(const char *str);
#ifndef __int64
typedef long long __int64;
#endif
char * _i64toa(__int64 value, char *string, int radix);
@ -126,8 +128,8 @@ VOID Reset(VOID)
if (UsePerformanceCounter) {
/* Performance counters may return incorrect results on some multiprocessor
platforms so we restrict execution on the first processor. This may fail on
Windows NT so we fall back to GetCurrentTick() for timing */
platforms so we restrict execution on the first processor. This may fail
on Windows NT so we fall back to GetCurrentTick() for timing */
if (SetThreadAffinityMask (GetCurrentThread(), 1) == 0) {
UsePerformanceCounter = FALSE;
}
@ -187,7 +189,11 @@ BOOL ParseCmdline(int argc, char* argv[])
INT i;
BOOL ShowUsage;
BOOL FoundTarget;
#if 0
lstrcpy(TargetName, "127.0.0.1");
PingCount = 1;
return TRUE;
#endif
if (argc < 2) {
ShowUsage = TRUE;
} else {
@ -213,7 +219,7 @@ BOOL ParseCmdline(int argc, char* argv[])
case 'f': DontFragment = TRUE; break;
case 'i': TTLValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
case 'v': TOSValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
case 'w': Timeout = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
case 'w': Timeout = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
default:
printf("Bad option %s.\n", argv[i]);
Usage();
@ -228,7 +234,7 @@ BOOL ParseCmdline(int argc, char* argv[])
printf("Bad parameter %s.\n", argv[i]);
return FALSE;
} else {
strcpy(TargetName, argv[i]);
lstrcpy(TargetName, argv[i]);
FoundTarget = TRUE;
}
}
@ -268,11 +274,11 @@ WORD Checksum(PUSHORT data, UINT size)
/* Prepare to ping target */
BOOL Setup(VOID)
{
WORD wVersionRequested;
WSADATA WsaData;
INT Status;
ULONG Addr;
PHOSTENT phe;
WORD wVersionRequested;
WSADATA WsaData;
INT Status;
ULONG Addr;
PHOSTENT phe;
wVersionRequested = MAKEWORD(2, 2);
@ -311,14 +317,14 @@ BOOL Setup(VOID)
Target.sin_family = AF_INET;
}
TargetIP = inet_ntoa(Target.sin_addr);
CurrentSeqNum = 0;
SentCount = 0;
LostCount = 0;
MinRTT.QuadPart = 0;
MaxRTT.QuadPart = 0;
SumRTT.QuadPart = 0;
MinRTTSet = FALSE;
TargetIP = inet_ntoa(Target.sin_addr);
CurrentSeqNum = 0;
SentCount = 0;
LostCount = 0;
MinRTT.QuadPart = 0;
MaxRTT.QuadPart = 0;
SumRTT.QuadPart = 0;
MinRTTSet = FALSE;
return TRUE;
}
@ -443,11 +449,11 @@ BOOL Ping(VOID)
Packet = (PICMP_ECHO_PACKET)Buffer;
/* Assemble ICMP echo request packet */
Packet->Icmp.Type = ICMPMSG_ECHOREQUEST;
Packet->Icmp.Code = 0;
Packet->Icmp.Id = (USHORT)GetCurrentProcessId();
Packet->Icmp.SeqNum = (USHORT)CurrentSeqNum;
Packet->Icmp.Checksum = 0;
Packet->Icmp.Type = ICMPMSG_ECHOREQUEST;
Packet->Icmp.Code = 0;
Packet->Icmp.Id = (USHORT)GetCurrentProcessId();
Packet->Icmp.SeqNum = (USHORT)CurrentSeqNum;
Packet->Icmp.Checksum = 0;
/* Timestamp is part of data area */
QueryTime(&Packet->Timestamp);
@ -502,11 +508,13 @@ BOOL Ping(VOID)
if (Status == 0) {
printf("Request timed out.\n");
LostCount++;
GlobalFree(Buffer);
return TRUE;
}
if (!DecodeResponse(Buffer, Status, (PSOCKADDR_IN)&From)) {
/* FIXME: Wait again as it could be another ICMP message type */
printf("Request timed out.\n");
LostCount++;
}
@ -520,9 +528,9 @@ BOOL Ping(VOID)
int main(int argc, char* argv[])
{
UINT Count;
CHAR MinTime[20];
CHAR MaxTime[20];
CHAR AvgTime[20];
CHAR MinTime[20];
CHAR MaxTime[20];
CHAR AvgTime[20];
Reset();

View file

@ -1,4 +1,4 @@
/* $Id: shutdown.c,v 1.3 2001/01/14 15:28:50 ekohl Exp $
/* $Id: shutdown.c,v 1.4 2001/05/01 23:08:21 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -11,7 +11,7 @@
#include <ddk/ntddk.h>
//#define NDEBUG
#define NDEBUG
#include <debug.h>
#include "vfat.h"

View file

@ -53,18 +53,21 @@ enum
{
IRP_NOCACHE = 0x1,
IRP_PAGING_IO = 0x2,
IRP_MOUNT_COMPLETION = 0x4,
IRP_SYNCHRONOUS_API = 0x8,
IRP_ASSOCIATED_IRP = 0x10,
IRP_BUFFERED_IO = 0x20,
IRP_DEALLOCATE_BUFFER = 0x40,
IRP_INPUT_OPERATION = 0x80,
IRP_SYNCHRONOUS_PAGING_IO = 0x100,
IRP_CREATE_OPERATION = 0x200,
IRP_READ_OPERATION = 0x400,
IRP_WRITE_OPERATION = 0x800,
IRP_CLOSE_OPERATION = 0x1000,
IRP_DEFER_IO_COMPLETION = 0x2000,
IRP_MOUNT_COMPLETION = 0x2,
IRP_SYNCHRONOUS_API = 0x4,
IRP_ASSOCIATED_IRP = 0x8,
IRP_BUFFERED_IO = 0x10,
IRP_DEALLOCATE_BUFFER = 0x20,
IRP_INPUT_OPERATION = 0x40,
IRP_SYNCHRONOUS_PAGING_IO = 0x40,
IRP_CREATE_OPERATION = 0x80,
IRP_READ_OPERATION = 0x100,
IRP_WRITE_OPERATION = 0x200,
IRP_CLOSE_OPERATION = 0x400,
IRP_DEFER_IO_COMPLETION = 0x800,
IRP_OB_QUERY_NAME = 0x1000,
IRP_HOLD_DEVICE_QUEUE = 0x2000,
IRP_RETRY_IO_COMPLETION = 0x4000
};
#define SL_FORCE_ACCESS_CHECK (0x1)
@ -96,74 +99,93 @@ enum
/*
* Possible flags for the device object flags
*/
#define DO_UNLOAD_PENDING 0x00000001
#define DO_VERIFY_VOLUME 0x00000002
#define DO_BUFFERED_IO 0x00000004
#define DO_EXCLUSIVE 0x00000008
#define DO_DIRECT_IO 0x00000010
#define DO_MAP_IO_BUFFER 0x00000020
#define DO_DEVICE_HAS_NAME 0x00000040
#define DO_DEVICE_INITIALIZING 0x00000080
#define DO_SYSTEM_BOOT_PARTITION 0x00000100
#define DO_LONG_TERM_REQUESTS 0x00000200
#define DO_NEVER_LAST_DEVICE 0x00000400
#define DO_SHUTDOWN_REGISTERED 0x00000800
#define DO_UNLOAD_PENDING 0x00000001
#define DO_VERIFY_VOLUME 0x00000002
#define DO_BUFFERED_IO 0x00000004
#define DO_EXCLUSIVE 0x00000008
#define DO_DIRECT_IO 0x00000010
#define DO_MAP_IO_BUFFER 0x00000020
#define DO_DEVICE_HAS_NAME 0x00000040
#define DO_DEVICE_INITIALIZING 0x00000080
#define DO_SYSTEM_BOOT_PARTITION 0x00000100
#define DO_LONG_TERM_REQUESTS 0x00000200
#define DO_NEVER_LAST_DEVICE 0x00000400
#define DO_SHUTDOWN_REGISTERED 0x00000800
#define DO_BUS_ENUMERATED_DEVICE 0x00001000
#define DO_POWER_PAGABLE 0x00002000
#define DO_POWER_INRUSH 0x00004000
#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
/*
* Possible device types
*/
#define FILE_DEVICE_BEEP 0x00000001
#define FILE_DEVICE_CD_ROM 0x00000002
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
#define FILE_DEVICE_CONTROLLER 0x00000004
#define FILE_DEVICE_DATALINK 0x00000005
#define FILE_DEVICE_DFS 0x00000006
#define FILE_DEVICE_DISK 0x00000007
#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
#define FILE_DEVICE_FILE_SYSTEM 0x00000009
#define FILE_DEVICE_INPORT_PORT 0x0000000a
#define FILE_DEVICE_KEYBOARD 0x0000000b
#define FILE_DEVICE_MAILSLOT 0x0000000c
#define FILE_DEVICE_MIDI_IN 0x0000000d
#define FILE_DEVICE_MIDI_OUT 0x0000000e
#define FILE_DEVICE_MOUSE 0x0000000f
#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
#define FILE_DEVICE_NAMED_PIPE 0x00000011
#define FILE_DEVICE_NETWORK 0x00000012
#define FILE_DEVICE_NETWORK_BROWSER 0x00000013
#define FILE_DEVICE_BEEP 0x00000001
#define FILE_DEVICE_CD_ROM 0x00000002
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
#define FILE_DEVICE_CONTROLLER 0x00000004
#define FILE_DEVICE_DATALINK 0x00000005
#define FILE_DEVICE_DFS 0x00000006
#define FILE_DEVICE_DISK 0x00000007
#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
#define FILE_DEVICE_FILE_SYSTEM 0x00000009
#define FILE_DEVICE_INPORT_PORT 0x0000000a
#define FILE_DEVICE_KEYBOARD 0x0000000b
#define FILE_DEVICE_MAILSLOT 0x0000000c
#define FILE_DEVICE_MIDI_IN 0x0000000d
#define FILE_DEVICE_MIDI_OUT 0x0000000e
#define FILE_DEVICE_MOUSE 0x0000000f
#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
#define FILE_DEVICE_NAMED_PIPE 0x00000011
#define FILE_DEVICE_NETWORK 0x00000012
#define FILE_DEVICE_NETWORK_BROWSER 0x00000013
#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
#define FILE_DEVICE_NULL 0x00000015
#define FILE_DEVICE_PARALLEL_PORT 0x00000016
#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
#define FILE_DEVICE_PRINTER 0x00000018
#define FILE_DEVICE_SCANNER 0x00000019
#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
#define FILE_DEVICE_SERIAL_PORT 0x0000001b
#define FILE_DEVICE_SCREEN 0x0000001c
#define FILE_DEVICE_SOUND 0x0000001d
#define FILE_DEVICE_STREAMS 0x0000001e
#define FILE_DEVICE_TAPE 0x0000001f
#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
#define FILE_DEVICE_TRANSPORT 0x00000021
#define FILE_DEVICE_UNKNOWN 0x00000022
#define FILE_DEVICE_VIDEO 0x00000023
#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
#define FILE_DEVICE_WAVE_IN 0x00000025
#define FILE_DEVICE_WAVE_OUT 0x00000026
#define FILE_DEVICE_8042_PORT 0x00000027
#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
#define FILE_DEVICE_BATTERY 0x00000029
#define FILE_DEVICE_BUS_EXTENDER 0x0000002a
#define FILE_DEVICE_MODEM 0x0000002b
#define FILE_DEVICE_VDM 0x0000002c
#define FILE_DEVICE_NULL 0x00000015
#define FILE_DEVICE_PARALLEL_PORT 0x00000016
#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
#define FILE_DEVICE_PRINTER 0x00000018
#define FILE_DEVICE_SCANNER 0x00000019
#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
#define FILE_DEVICE_SERIAL_PORT 0x0000001b
#define FILE_DEVICE_SCREEN 0x0000001c
#define FILE_DEVICE_SOUND 0x0000001d
#define FILE_DEVICE_STREAMS 0x0000001e
#define FILE_DEVICE_TAPE 0x0000001f
#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
#define FILE_DEVICE_TRANSPORT 0x00000021
#define FILE_DEVICE_UNKNOWN 0x00000022
#define FILE_DEVICE_VIDEO 0x00000023
#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
#define FILE_DEVICE_WAVE_IN 0x00000025
#define FILE_DEVICE_WAVE_OUT 0x00000026
#define FILE_DEVICE_8042_PORT 0x00000027
#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
#define FILE_DEVICE_BATTERY 0x00000029
#define FILE_DEVICE_BUS_EXTENDER 0x0000002a
#define FILE_DEVICE_MODEM 0x0000002b
#define FILE_DEVICE_VDM 0x0000002c
#define FILE_DEVICE_MASS_STORAGE 0x0000002d
#define FILE_DEVICE_SMB 0x0000002e
#define FILE_DEVICE_KS 0x0000002f
#define FILE_DEVICE_CHANGER 0x00000030
#define FILE_DEVICE_SMARTCARD 0x00000031
#define FILE_DEVICE_ACPI 0x00000032
#define FILE_DEVICE_DVD 0x00000033
#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
#define FILE_DEVICE_DFS_VOLUME 0x00000036
#define FILE_DEVICE_SERENUM 0x00000037
#define FILE_DEVICE_TERMSRV 0x00000038
#define FILE_DEVICE_KSEC 0x00000039
#define FILE_REMOVABLE_MEDIA 0x00000001
#define FILE_REMOVABLE_MEDIA 0x00000001
#define FILE_READ_ONLY_DEVICE 0x00000002
#define FILE_FLOPPY_DISKETTE 0x00000004
#define FILE_WRITE_ONCE_MEDIA 0x00000008
#define FILE_REMOTE_DEVICE 0x00000010
#define FILE_DEVICE_IS_MOUNTED 0x00000020
#define FILE_VIRTUAL_VOLUME 0x00000040
#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
#define FILE_DEVICE_SECURE_OPEN 0x00000100
/*

View file

@ -1,6 +1,6 @@
#ifndef _INCLUDE_DDK_IOFUNCS_H
#define _INCLUDE_DDK_IOFUNCS_H
/* $Id: iofuncs.h,v 1.22 2000/12/23 02:37:36 dwelch Exp $ */
/* $Id: iofuncs.h,v 1.23 2001/05/01 23:08:17 chorns Exp $ */
/* --- EXPORTED BY NTOSKRNL --- */
@ -429,6 +429,7 @@ IoConnectInterrupt (
KAFFINITY ProcessorEnableMask,
BOOLEAN FloatingSave
);
PCONTROLLER_OBJECT
STDCALL
IoCreateController (
@ -590,6 +591,11 @@ IoGetAttachedDevice (
);
PDEVICE_OBJECT
STDCALL
IoGetAttachedDeviceReference (
PDEVICE_OBJECT DeviceObject
);
PDEVICE_OBJECT
STDCALL
IoGetBaseFileSystemDeviceObject (
IN PFILE_OBJECT FileObject
);
@ -618,6 +624,16 @@ IoGetConfigurationInformation (
#define IoGetCurrentIrpStackLocation(Irp) \
((Irp)->Tail.Overlay.CurrentStackLocation)
*/
#define IoCopyCurrentIrpStackLocationToNext(Irp) { \
PIO_STACK_LOCATION IrpSp; \
PIO_STACK_LOCATION NextIrpSp; \
IrpSp = IoGetCurrentIrpStackLocation((Irp)); \
NextIrpSp = IoGetNextIrpStackLocation((Irp)); \
RtlCopyMemory(NextIrpSp, IrpSp, \
FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \
NextIrpSp->Control = 0; }
struct _EPROCESS*
STDCALL
IoGetCurrentProcess (

View file

@ -1,4 +1,4 @@
/* $Id: iotypes.h,v 1.27 2001/05/01 11:04:52 ekohl Exp $
/* $Id: iotypes.h,v 1.28 2001/05/01 23:08:17 chorns Exp $
*
*/
@ -104,6 +104,147 @@ typedef struct _IO_SECURITY_CONTEXT
ULONG FullCreateOptions;
} IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
typedef struct _IO_RESOURCE_DESCRIPTOR
{
UCHAR Option;
UCHAR Type;
UCHAR ShareDisposition;
/*
* Reserved for system use
*/
UCHAR Spare1;
USHORT Flags;
/*
* Reserved for system use
*/
UCHAR Spare2;
union
{
struct
{
ULONG Length;
ULONG Alignment;
PHYSICAL_ADDRESS MinimumAddress;
PHYSICAL_ADDRESS MaximumAddress;
} Port;
struct
{
ULONG Length;
ULONG Alignment;
PHYSICAL_ADDRESS MinimumAddress;
PHYSICAL_ADDRESS MaximumAddress;
} Memory;
struct
{
ULONG MinimumVector;
ULONG MaximumVector;
} Interrupt;
struct
{
ULONG MinimumChannel;
ULONG MaximumChannel;
} Dma;
} u;
} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
// IO_RESOURCE_DESCRIPTOR Options
#define IO_RESOURCE_REQUIRED 0x00
#define IO_RESOURCE_PREFERRED 0x01
#define IO_RESOURCE_DEFAULT 0x02
#define IO_RESOURCE_ALTERNATIVE 0x08
typedef struct _IO_RESOURCE_LIST
{
USHORT Version;
USHORT Revision;
ULONG Count;
IO_RESOURCE_DESCRIPTOR Descriptors[1];
} IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
typedef struct _IO_RESOURCE_REQUIREMENTS_LIST
{
/*
* List size in bytes
*/
ULONG ListSize;
/*
* System defined enum for the bus
*/
INTERFACE_TYPE InterfaceType;
ULONG BusNumber;
ULONG SlotNumber;
ULONG Reserved[3];
ULONG AlternativeLists;
IO_RESOURCE_LIST List[1];
} IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
typedef struct
{
UCHAR Type;
UCHAR ShareDisposition;
USHORT Flags;
union
{
struct
{
PHYSICAL_ADDRESS Start;
ULONG Length;
} Port;
struct
{
ULONG Level;
ULONG Vector;
ULONG Affinity;
} Interrupt;
struct
{
PHYSICAL_ADDRESS Start;
ULONG Length;
} Memory;
struct
{
ULONG Channel;
ULONG Port;
ULONG Reserved1;
} Dma;
struct
{
ULONG DataSize;
ULONG Reserved1;
ULONG Reserved2;
} DeviceSpecificData;
} u;
} CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
typedef struct
{
USHORT Version;
USHORT Revision;
ULONG Count;
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
} CM_PARTIAL_RESOURCE_LIST;
typedef struct
{
INTERFACE_TYPE InterfaceType;
ULONG BusNumber;
CM_PARTIAL_RESOURCE_LIST PartialResourceList;
} CM_FULL_RESOURCE_DESCRIPTOR;
typedef struct
{
ULONG Count;
CM_FULL_RESOURCE_DESCRIPTOR List[1];
} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
/*
* PURPOSE: IRP stack location
*/
@ -193,7 +334,84 @@ typedef struct _IO_STACK_LOCATION
FILE_INFORMATION_CLASS FileInformationClass;
ULONG FileIndex;
} QueryDirectory;
} Parameters;
/*
struct
{
ULONG CreateDisposition;
ULONG CreateOptions;
ULONG ShareAccess;
BOOLEAN WriteModeMessage;
BOOLEAN ReadModeMessage;
BOOLEAN NonBlocking;
ULONG MaxInstances;
ULONG InBufferSize;
ULONG OutBufferSize;
LARGE_INTEGER TimeOut;
} CreateNamedPipe;
*/
// Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
struct {
DEVICE_RELATION_TYPE Type;
} QueryDeviceRelations;
// Parameters for IRP_MN_QUERY_INTERFACE
struct {
CONST GUID *InterfaceType;
USHORT Size;
USHORT Version;
PINTERFACE Interface;
PVOID InterfaceSpecificData;
} QueryInterface;
// Parameters for IRP_MN_QUERY_CAPABILITIES
struct {
PDEVICE_CAPABILITIES Capabilities;
} DeviceCapabilities;
// Parameters for IRP_MN_QUERY_ID
struct {
BUS_QUERY_ID_TYPE IdType;
} QueryId;
// Parameters for IRP_MN_QUERY_DEVICE_TEXT
struct {
DEVICE_TEXT_TYPE DeviceTextType;
LCID LocaleId;
} QueryDeviceText;
// Parameters for IRP_MN_DEVICE_USAGE_NOTIFICATION
struct {
BOOLEAN InPath;
BOOLEAN Reserved[3];
DEVICE_USAGE_NOTIFICATION_TYPE Type;
} UsageNotification;
// Parameters for IRP_MN_WAIT_WAKE
struct {
SYSTEM_POWER_STATE PowerState;
} WaitWake;
// Parameter for IRP_MN_POWER_SEQUENCE
struct {
PPOWER_SEQUENCE PowerSequence;
} PowerSequence;
// Parameters for IRP_MN_SET_POWER and IRP_MN_QUERY_POWER
struct {
ULONG SystemContext;
POWER_STATE_TYPE Type;
POWER_STATE State;
POWER_ACTION ShutdownType;
} Power;
// Parameters for IRP_MN_START_DEVICE
struct {
PCM_RESOURCE_LIST AllocatedResources;
PCM_RESOURCE_LIST AllocatedResourcesTranslated;
} StartDevice;
} Parameters;
struct _DEVICE_OBJECT* DeviceObject;
struct _FILE_OBJECT* FileObject;
@ -580,143 +798,6 @@ typedef struct _DRIVER_LAYOUT_INFORMATION
} DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
typedef struct _IO_RESOURCE_DESCRIPTOR
{
UCHAR Option;
UCHAR Type;
UCHAR SharedDisposition;
/*
* Reserved for system use
*/
UCHAR Spare1;
USHORT Flags;
/*
* Reserved for system use
*/
UCHAR Spare2;
union
{
struct
{
ULONG Length;
ULONG Alignment;
PHYSICAL_ADDRESS MinimumAddress;
PHYSICAL_ADDRESS MaximumAddress;
} Port;
struct
{
ULONG Length;
ULONG Alignment;
PHYSICAL_ADDRESS MinimumAddress;
PHYSICAL_ADDRESS MaximumAddress;
} Memory;
struct
{
ULONG MinimumVector;
ULONG MaximumVector;
} Interrupt;
struct
{
ULONG MinimumChannel;
ULONG MaximumChannel;
} Dma;
} u;
} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
typedef struct _IO_RESOURCE_LIST
{
USHORT Version;
USHORT Revision;
ULONG Count;
IO_RESOURCE_DESCRIPTOR Descriptors[1];
} IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
typedef struct _IO_RESOURCES_REQUIREMENTS_LIST
{
/*
* List size in bytes
*/
ULONG ListSize;
/*
* System defined enum for the bus
*/
INTERFACE_TYPE InterfaceType;
ULONG BusNumber;
ULONG SlotNumber;
ULONG Reserved[3];
ULONG AlternativeLists;
IO_RESOURCE_LIST List[1];
} IO_RESOURCES_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
typedef struct
{
UCHAR Type;
UCHAR ShareDisposition;
USHORT Flags;
union
{
struct
{
PHYSICAL_ADDRESS Start;
ULONG Length;
} Port;
struct
{
ULONG Level;
ULONG Vector;
ULONG Affinity;
} Interrupt;
struct
{
PHYSICAL_ADDRESS Start;
ULONG Length;
} Memory;
struct
{
ULONG Channel;
ULONG Port;
ULONG Reserved1;
} Dma;
struct
{
ULONG DataSize;
ULONG Reserved1;
ULONG Reserved2;
} DeviceSpecificData;
} u;
} CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
typedef struct
{
USHORT Version;
USHORT Revision;
ULONG Count;
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
} CM_PARTIAL_RESOURCE_LIST;
typedef struct
{
INTERFACE_TYPE InterfaceType;
ULONG BusNumber;
CM_PARTIAL_RESOURCE_LIST PartialResourceList;
} CM_FULL_RESOURCE_DESCRIPTOR;
typedef struct
{
ULONG Count;
CM_FULL_RESOURCE_DESCRIPTOR List[1];
} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
typedef
IO_ALLOCATION_ACTION
(*PDRIVER_CONTROL) (

View file

@ -24,6 +24,15 @@ typedef struct _LOADER_MODULE
ULONG Reserved;
} LOADER_MODULE, *PLOADER_MODULE;
typedef struct _ADDRESS_RANGE
{
ULONG BaseAddrLow;
ULONG BaseAddrHigh;
ULONG LengthLow;
ULONG LengthHigh;
ULONG Type;
} ADDRESS_RANGE, *PADDRESS_RANGE;
typedef struct _LOADER_PARAMETER_BLOCK
{
ULONG Flags;

View file

@ -1,4 +1,4 @@
/* $Id: ntddk.h,v 1.20 2001/04/16 00:44:54 chorns Exp $
/* $Id: ntddk.h,v 1.21 2001/05/01 23:08:17 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -43,9 +43,9 @@ extern "C"
#include <ddk/obtypes.h>
#include <ddk/setypes.h>
#include <ddk/mmtypes.h>
#include <ddk/iotypes.h>
#include <ddk/potypes.h>
#include <ddk/pnptypes.h>
#include <ddk/iotypes.h>
#include <ddk/extypes.h>
#include <ddk/pstypes.h>
#include <ddk/zwtypes.h>
@ -59,9 +59,9 @@ extern "C"
#include <ddk/mmfuncs.h>
#include <ddk/kdfuncs.h>
#include <ddk/kefuncs.h>
#include <ddk/iofuncs.h>
#include <ddk/pofuncs.h>
#include <ddk/pnpfuncs.h>
#include <ddk/iofuncs.h>
#include <ddk/psfuncs.h>
#include <ddk/obfuncs.h>
#include <ddk/dbgfuncs.h>

View file

@ -5,15 +5,23 @@ PVOID STDCALL ObCreateObject(PHANDLE Handle,
POBJECT_ATTRIBUTES ObjectAttributes,
POBJECT_TYPE Type);
/*
* FUNCTION: Decrements the object's reference count and performs retention
* checks
* ARGUMENTS:
* Object = Object's body
*/
VOID STDCALL ObDereferenceObject(PVOID Object);
VOID
FASTCALL
ObfDereferenceObject(IN PVOID Object);
VOID STDCALL ObMakeTemporaryObject(PVOID ObjectBody);
VOID
FASTCALL
ObfReferenceObject(IN PVOID Object);
#define ObDereferenceObject(Object) \
ObfDereferenceObject(Object)
#define ObReferenceObject(Object) \
ObfReferenceObject(Object)
VOID
STDCALL
ObMakeTemporaryObject(PVOID ObjectBody);
NTSTATUS STDCALL ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes,
IN POBJECT_TYPE ObjectType,

View file

@ -1,6 +1,9 @@
#ifndef __INCLUDE_DDK_PNPTYPES_H
#define __INCLUDE_DDK_PNPTYPES_H
struct _DEVICE_OBJECT;
struct _FILE_OBJECT;
// windows.h may be included before
#ifndef GUID_DEFINED
#define GUID_DEFINED
@ -14,6 +17,12 @@ typedef struct _GUID {
#endif
typedef struct _PNP_BUS_INFORMATION {
GUID BusTypeGuid;
INTERFACE_TYPE LegacyBusType;
ULONG BusNumber;
} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
typedef struct _DEVICE_CAPABILITIES {
USHORT Size;
USHORT Version;
@ -73,6 +82,13 @@ typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
#define PNP_DEVICE_DISABLED 0x00000001
#define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
#define PNP_DEVICE_FAILED 0x00000004
#define PNP_DEVICE_REMOVED 0x00000008
#define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
#define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
USHORT Version;
USHORT Size;
@ -80,7 +96,7 @@ typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
//
// Event-specific data
//
PFILE_OBJECT FileObject;
struct _FILE_OBJECT *FileObject;
LONG NameBufferOffset;
UCHAR CustomDataBuffer[1];
} TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
@ -92,7 +108,7 @@ typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
//
// Event-specific data
//
PFILE_OBJECT FileObject;
struct _FILE_OBJECT *FileObject;
} TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
@ -155,7 +171,7 @@ typedef enum _DEVICE_RELATION_TYPE {
typedef struct _DEVICE_RELATIONS {
ULONG Count;
PDEVICE_OBJECT Objects[1]; // variable length
struct _DEVICE_OBJECT *Objects[1];
} DEVICE_RELATIONS, *PDEVICE_RELATIONS;
typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {

View file

@ -1,6 +1,9 @@
#ifndef __INCLUDE_DDK_POTYPES_H
#define __INCLUDE_DDK_POTYPES_H
struct _DEVICE_OBJECT;
struct _IO_STATUS_BLOCK;
// Flags for PoSetSystemState
typedef ULONG EXECUTION_STATE;
@ -59,10 +62,41 @@ typedef enum _POWER_STATE_TYPE {
typedef
VOID
(*PREQUEST_POWER_COMPLETE) (
IN PDEVICE_OBJECT DeviceObject,
IN struct _DEVICE_OBJECT *DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PVOID Context,
IN PIO_STATUS_BLOCK IoStatus);
IN struct _IO_STATUS_BLOCK *IoStatus);
typedef struct _POWER_SEQUENCE {
ULONG SequenceD1;
ULONG SequenceD2;
ULONG SequenceD3;
} POWER_SEQUENCE, *PPOWER_SEQUENCE;
typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context);
typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context);
typedef struct _INTERFACE {
USHORT Size;
USHORT Version;
PVOID Context;
PINTERFACE_REFERENCE InterfaceReference;
PINTERFACE_DEREFERENCE InterfaceDereference;
} INTERFACE, *PINTERFACE;
typedef enum {
BusQueryDeviceID = 0,
BusQueryHardwareIDs = 1,
BusQueryCompatibleIDs = 2,
BusQueryInstanceID = 3,
BusQueryDeviceSerialNumber = 4
} BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
typedef enum {
DeviceTextDescription = 0,
DeviceTextLocationInformation = 1
} DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
#endif /* __INCLUDE_DDK_POTYPES_H */

View file

@ -8,6 +8,8 @@ copy boot.bat c:\reactos
copy loaders\dos\loadros.com c:\reactos
copy ntoskrnl\ntoskrnl.exe c:\reactos
copy services\fs\vfat\vfatfs.sys c:\reactos
copy services\bus\acpi\acpi.sys c:\reactos
copy services\bus\isapnp\isapnp.sys c:\reactos
copy services\dd\ide\ide.sys c:\reactos
copy services\dd\floppy\floppy.sys c:\reactos\system32\drivers
copy services\input\keyboard\keyboard.sys c:\reactos\system32\drivers

View file

@ -3,6 +3,8 @@ mkdir -p $1/reactos/system32
mkdir -p $1/reactos/system32/drivers
mkdir -p $1/reactos/bin
./install-system.sh $1
cp services/bus/acpi/acpi.sys $1/reactos/system32/drivers
cp services/bus/isapnp/isapnp.sys $1/reactos/system32/drivers
cp services/dd/floppy/floppy.sys $1/reactos/system32/drivers/
cp services/input/keyboard/keyboard.sys $1/reactos/system32/drivers
cp services/dd/blue/blue.sys $1/reactos/system32/drivers

View file

@ -23,6 +23,15 @@ mbm_string: resd 1
mbm_reserved: resd 1
endstruc
struc multiboot_address_range
mar_baselow: resd 1
mar_basehigh: resd 1
mar_lengthlow: resd 1
mar_lengthhigh: resd 1
mar_type: resd 1
mar_reserved: resd 3
endstruc
;
; We are a .com program
;
@ -179,7 +188,9 @@ entry:
;; Process the arguments
;;
cmp byte [di], '/'
je .next_module
jne .no_next_module
jmp .next_module
.no_next_module:
;;
;; Display a message saying we are loading the module
@ -221,7 +232,22 @@ entry:
;;
push di
mov dx, di
call pe_load_module
; Check if it is a symbol file
cmp byte [bx-5],'.'
jne .pe_copy
cmp byte [bx-4],'s'
jne .pe_copy
cmp byte [bx-3],'y'
jne .pe_copy
cmp byte [bx-2],'m'
jne .pe_copy
call sym_load_module
jmp .after_copy
.pe_copy:
call pe_load_module
.after_copy:
pop di
cmp eax, 0
jne .load_success
@ -262,7 +288,7 @@ entry:
add dword [_multiboot_info_base], _multiboot_info
mov dword [_multiboot_flags], 0xc
mov [_multiboot_cmdline], eax
add dword [_multiboot_cmdline], _multiboot_kernel_cmdline
@ -333,6 +359,50 @@ entry:
add [_multiboot_mem_lower],eax
.done_mem:
;;
;; Retrieve BIOS memory map if available
;;
xor ebx,ebx
mov edi, _multiboot_address_ranges
.mmap_next:
mov edx, 'PAMS'
mov ecx, multiboot_address_range_size
mov eax, 0E820h
int 15h
jc .done_mmap
cmp eax, 'PAMS'
jne .done_mmap
add edi, multiboot_address_range_size
cmp ebx, 0
jne .mmap_next
;;
;; Prepare multiboot memory map structures
;;
;; Fill in the address descriptor size field
mov dword [_multiboot_address_range_descriptor_size], multiboot_address_range_size
;; Set flag and base address and length of memory map
or dword [_multiboot_flags], 40h
mov eax, edi
sub eax, _multiboot_address_ranges
mov dword [_multiboot_mmap_length], eax
xor eax, eax
mov ax, ds
shl eax, 4
mov [_multiboot_mmap_addr], eax
add dword [_multiboot_mmap_addr], _multiboot_address_ranges
.done_mmap:
pop ebx
;;
@ -625,12 +695,107 @@ _current_filehandle:
dw 0
_current_size:
dd 0
_current_file_size:
dd 0
;;
;; Load a SYM file
;; DS:DX = Filename
;;
sym_load_module:
call load_module1
call load_module2
mov edi, [next_load_base]
add edi, [_current_file_size]
mov eax, edi
test di, 0xfff
jz .sym_no_round
and di, 0xf000
add edi, 0x1000
;;
;; Clear unused space in the last page
;;
mov esi, edi
mov ecx, edi
sub ecx, eax
.sym_clear:
mov byte [esi],0
inc esi
loop .sym_clear
.sym_no_round:
call load_module3
ret
;;
;; Load a PE file
;; DS:DX = Filename
;;
pe_load_module:
call load_module1
;;
;; Read in the DOS EXE header
;;
mov ah, 0x3f
mov bx, [_current_filehandle]
mov cx, pe_doshdr_size
mov dx, _cpe_doshdr
int 0x21
jnc .header_read
mov dx, error_file_read_failed
jmp error
.header_read
;;
;; Check the DOS EXE magic
;;
mov ax, word [_cpe_doshdr + e_magic]
cmp ax, 'MZ'
je .mz_hdr_good
mov dx, error_bad_mz
jmp error
.mz_hdr_good
;;
;; Find the BSS size
;;
mov ebx, dword [_multiboot_mods_count]
cmp ebx, 0
jne .not_first
mov edx, 0
mov ax, 0x4200
mov cx, 0
mov dx, 0x1004
mov bx, [_current_filehandle]
int 0x21
jnc .start_seek1
mov dx, error_file_seek_failed
jmp error
.start_seek1:
mov ah, 0x3F
mov bx, [_current_filehandle]
mov cx, 32
mov dx, _mb_magic
int 0x21
jnc .mb_header_read
mov dx, error_file_read_failed
jmp error
.mb_header_read:
jmp .first
.not_first:
mov dword [_mb_bss_end_addr], 0
.first:
call load_module2
call load_module3
ret
load_module1:
;;
;; Open file
;;
@ -638,7 +803,7 @@ pe_load_module:
int 0x21
jnc .file_opened
mov dx, error_file_open_failed
jmp .error
jmp error
.file_opened:
;;
@ -663,64 +828,11 @@ pe_load_module:
int 0x21
jnc .seek_start
mov dx, error_file_seek_failed
jmp .error
jmp error
.seek_start:
ret
;;
;; Read in the DOS EXE header
;;
mov ah, 0x3f
mov bx, [_current_filehandle]
mov cx, pe_doshdr_size
mov dx, _cpe_doshdr
int 0x21
jnc .header_read
mov dx, error_file_read_failed
jmp .error
.header_read
;;
;; Check the DOS EXE magic
;;
mov ax, word [_cpe_doshdr + e_magic]
cmp ax, 'MZ'
je .mz_hdr_good
mov dx, error_bad_mz
jmp .error
.mz_hdr_good
;;
;; Find the BSS size
;;
mov ebx, dword [_multiboot_mods_count]
cmp ebx, 0
jne .not_first
mov edx, 0
mov ax, 0x4200
mov cx, 0
mov dx, 0x1004
mov bx, [_current_filehandle]
int 0x21
jnc .start_seek1
mov dx, error_file_seek_failed
jmp .error
.start_seek1:
mov ah, 0x3F
mov bx, [_current_filehandle]
mov cx, 32
mov dx, _mb_magic
int 0x21
jnc .mb_header_read
mov dx, error_file_read_failed
jmp .error
.mb_header_read:
jmp .first
.not_first:
mov dword [_mb_bss_end_addr], 0
.first:
load_module2:
;;
;; Seek to the end of the file to get the file size
;;
@ -732,11 +844,12 @@ pe_load_module:
int 0x21
jnc .start_end
mov dx, error_file_seek_failed
jmp .error
jmp error
.start_end
shl edx, 16
mov dx, ax
mov [_current_size], edx
mov [_current_file_size], edx
mov edx, 0
mov ax, 0x4200
@ -746,7 +859,7 @@ pe_load_module:
int 0x21
jnc .start_seek
mov dx, error_file_seek_failed
jmp .error
jmp error
.start_seek
mov edi, [next_load_base]
@ -769,7 +882,7 @@ pe_load_module:
jnc .read_data_succeeded
pop ds
mov dx, error_file_read_failed
jmp .error
jmp error
.read_data_succeeded:
%ifndef NDEBUG
mov ah,02h
@ -813,7 +926,7 @@ pe_load_module:
jnc .read_last_data_succeeded
pop ds
mov dx, error_file_read_failed
jmp .error
jmp error
.read_last_data_succeeded:
%ifndef NDEBUG
mov ah,02h
@ -848,7 +961,9 @@ pe_load_module:
and di, 0xf000
add edi, 0x1000
.no_round:
ret
load_module3:
mov bx, [_multiboot_mods_count]
imul bx, bx, multiboot_module_size
add bx, _multiboot_modules
@ -868,7 +983,7 @@ pe_load_module:
;;
;; On error print a message and return zero
;;
.error:
error:
mov ah, 0x9
int 0x21
mov eax, 0
@ -1010,7 +1125,12 @@ _multiboot_modules:
times (64*multiboot_module_size) db 0
_multiboot_module_strings:
times (64*256) db 0
_multiboot_address_range_descriptor_size dd 0
_multiboot_address_ranges:
times (64*multiboot_address_range_size) db 0
_multiboot_kernel_cmdline:
times 255 db 0
@ -1067,4 +1187,3 @@ error_coff_load_failed:
error_bad_mz:
db 'Error: Bad DOS EXE magic'
db 0xa, 0xd, '$'

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.38 2001/04/28 22:59:16 dwelch Exp $
# $Id: Makefile,v 1.39 2001/05/01 23:08:17 chorns Exp $
#
# ReactOS Operating System
#
@ -43,6 +43,12 @@ else
CONFIG += UP
endif
ifeq ($(ACPI), 1)
CONFIG += ACPI
else
CONFIG +=
endif
TARGETNAME := ntoskrnl
OBJECTS_PATH = objects
@ -179,6 +185,7 @@ OBJECTS_IO = \
io/npipe.o \
io/page.o \
io/pnpmgr.o \
io/pnproot.o \
io/process.o \
io/queue.o \
io/resource.o \

View file

@ -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.24 2001/04/09 02:45:03 dwelch Exp $
/* $Id: view.c,v 1.25 2001/05/01 23:08:18 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -197,6 +197,8 @@ CcRequestCacheSegment(PBCB Bcb,
if ((FileOffset % Bcb->CacheSegmentSize) != 0)
{
CPRINT("Bad fileoffset %x should be multiple of %x",
FileOffset, Bcb->CacheSegmentSize);
KeBugCheck(0);
}

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.56 2001/04/07 15:06:17 jean Exp $
/* $Id: registry.c,v 1.57 2001/05/01 23:08:18 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -13,6 +13,7 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/config.h>
#include <internal/ob.h>
#include <limits.h>
#include <string.h>
@ -475,7 +476,7 @@ CmInitializeRegistry2(VOID)
if (!NT_SUCCESS(Status))
{
/* FIXME : search SYSTEM.alt, or create new */
DbgPrint(" warning : registry file %S not found\n",SYSTEM_REG_FILE);
CPRINT(" warning : registry file %S not found\n",SYSTEM_REG_FILE);
}
/* connect the SOFTWARE Hive */
Status=CmConnectHive(SOFTWARE_REG_FILE,REG_SOFTWARE_KEY_NAME
@ -483,7 +484,7 @@ CmInitializeRegistry2(VOID)
if (!NT_SUCCESS(Status))
{
/* FIXME : search SOFTWARE.alt, or create new */
DbgPrint(" warning : registry file %S not found\n",SOFTWARE_REG_FILE);
CPRINT(" warning : registry file %S not found\n",SOFTWARE_REG_FILE);
}
/* connect the SAM Hive */
Status=CmConnectHive(SAM_REG_FILE,REG_SAM_KEY_NAME
@ -491,7 +492,7 @@ CmInitializeRegistry2(VOID)
if (!NT_SUCCESS(Status))
{
/* FIXME : search SAM.alt, or create new */
DbgPrint(" warning : registry file %S not found\n",SAM_REG_FILE);
CPRINT(" warning : registry file %S not found\n",SAM_REG_FILE);
}
/* connect the SECURITY Hive */
Status=CmConnectHive(SEC_REG_FILE,REG_SEC_KEY_NAME
@ -499,7 +500,7 @@ CmInitializeRegistry2(VOID)
if (!NT_SUCCESS(Status))
{
/* FIXME : search SECURITY.alt, or create new */
DbgPrint(" warning : registry file %S not found\n",SEC_REG_FILE);
CPRINT(" warning : registry file %S not found\n",SEC_REG_FILE);
}
/* connect the DEFAULT Hive */
Status=CmConnectHive(USER_REG_FILE,REG_USER_KEY_NAME
@ -507,7 +508,7 @@ CmInitializeRegistry2(VOID)
if (!NT_SUCCESS(Status))
{
/* FIXME : search DEFAULT.alt, or create new */
DbgPrint(" warning : registry file %S not found\n",USER_REG_FILE);
CPRINT(" warning : registry file %S not found\n",USER_REG_FILE);
}
/* FIXME : initialize standards symbolic links */
/*
@ -528,7 +529,7 @@ CmImportHive(PCHAR Chunk)
VOID
CmShutdownRegistry(VOID)
{
DPRINT1("CmShutdownRegistry()...\n");
DPRINT("CmShutdownRegistry()...\n");
}
NTSTATUS

View file

@ -17,3 +17,8 @@ DBG := 1
# Whether to compile a multiprocessor or single processor version
#
MP := 0
#
# Whether to compile for ACPI compliant systems
#
ACPI := 0

View file

@ -12,9 +12,11 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/config.h>
#include <internal/ps.h>
#include <internal/io.h>
#include <internal/mm.h>
#include <internal/po.h>
#include <internal/debug.h>
@ -44,6 +46,8 @@ NtShutdownSystem(IN SHUTDOWN_ACTION Action)
#if 0
/* Switch off */
HalReturnToFirmware (FIRMWARE_OFF);
#else
PopSetSystemPowerState(PowerSystemShutdown);
#endif
}
else if (Action == ShutdownReboot)

View file

@ -0,0 +1,34 @@
/* $Id: enum.c,v 1.1 2001/05/01 23:08:18 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/hal/x86/enum.c
* PURPOSE: Motherboard device enumerator
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* UPDATE HISTORY:
* Created 01/05/2001
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/config.h>
#define NDEBUG
#include <internal/debug.h>
VOID
HalpStartEnumerator (VOID)
{
#ifdef ACPI
UNICODE_STRING DriverName;
RtlInitUnicodeString(&DriverName,
L"\\SystemRoot\\system32\\drivers\\acpi.sys");
NtLoadDriver(&DriverName);
#endif /* ACPI */
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: halinit.c,v 1.21 2001/04/26 14:26:22 phreak Exp $
/* $Id: halinit.c,v 1.22 2001/05/01 23:08:18 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -48,10 +48,15 @@ HalInitSystem (ULONG BootPhase,
#endif /* MP */
}
else
else if (BootPhase == 1)
{
HalpInitBusHandlers ();
}
else
{
/* Enumerate the devices on the motherboard */
HalpStartEnumerator();
}
return TRUE;
}

View file

@ -6,6 +6,7 @@ OBJECTS_HAL_COMMON = \
hal/x86/display.o \
hal/x86/dma.o \
hal/x86/drive.o \
hal/x86/enum.o \
hal/x86/fmutex.o \
hal/x86/halinit.o \
hal/x86/isa.o \

View file

@ -9,14 +9,17 @@
*/
/*
* NOTE: Define NDEBUG before including this header to disable debugging
* macros
* NOTES: Define DBG in configuration file for "checked" version
* Define NDEBUG before including this header to disable debugging
* macros
* Define NASSERT before including this header to disable assertions
*/
#ifndef __INTERNAL_DEBUG
#define __INTERNAL_DEBUG
#include <internal/ntoskrnl.h>
#include <internal/config.h>
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
@ -25,12 +28,25 @@
#define CHECKED
#endif
#ifdef DBG
/* Assert only on "checked" version */
#ifndef NASSERT
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); }
#else
#define assert(x)
#endif
/* Print if using a "checked" version */
#define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
#else /* DBG */
#define CPRINT(args...)
#define assert(x)
#endif /* DBG */
#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
#define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);

View file

@ -32,6 +32,9 @@ VOID HalpCalibrateStallExecution(VOID);
/* pci.c */
VOID HalpInitPciBus (VOID);
/* enum.c */
VOID HalpStartEnumerator (VOID);
struct _ADAPTER_OBJECT {
int Channel;
PVOID PagePort;

View file

@ -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: io.h,v 1.9 2001/04/03 17:25:49 dwelch Exp $
/* $Id: io.h,v 1.10 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -33,17 +33,85 @@
#include <ddk/ntddk.h>
#include <internal/ob.h>
extern POBJECT_TYPE IoSymbolicLinkType;
typedef struct _DEVICE_NODE
{
struct _DEVICE_NODE *Parent;
struct _DEVICE_NODE *PrevSibling;
struct _DEVICE_NODE *NextSibling;
struct _DEVICE_NODE *Child;
PDEVICE_OBJECT Pdo;
UNICODE_STRING InstancePath;
UNICODE_STRING ServiceName;
//TargetDeviceNotifyList?
DEVICE_CAPABILITIES CapabilityFlags;
ULONG Flags;
ULONG UserFlags;
ULONG DisableableDepends;
ULONG Problem;
PCM_RESOURCE_LIST CmResourceList;
PCM_RESOURCE_LIST BootResourcesList;
PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList;
} DEVICE_NODE, *PDEVICE_NODE;
/*
* FUNCTION: Called to initalize a loaded driver
* ARGUMENTS:
* entry = pointer to the driver initialization routine
* RETURNS: Success or failure
*/
NTSTATUS
IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
/* For Flags field */
#define DNF_MADEUP 0x0001
#define DNF_HAL_NODE 0x0002
#define DNF_PROCESSED 0x0004
#define DNF_ENUMERATED 0x0008
#define DNF_ADDED 0x0010
#define DNF_HAS_BOOT_CONFIG 0x0020
#define DNF_BOOT_CONFIG_RESERVED 0x0040
#define DNF_RESOURCE_ASSIGNED 0x0080
#define DNF_NO_RESOURCE_REQUIRED 0x0100
#define DNF_STARTED 0x0200
#define DNF_LEGACY_DRIVER 0x0400
#define DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED 0x0800
#define DNF_HAS_PROBLEM 0x1000
/* For UserFlags field */
#define DNUF_DONT_SHOW_IN_UI 0x0002
#define DNUF_NOT_DISABLEABLE 0x0008
/* For Problem field */
#define CM_PROB_FAILED_INSTALL 0x0001
extern PDEVICE_NODE IopRootDeviceNode;
extern POBJECT_TYPE IoSymbolicLinkType;
VOID
PnpInit(VOID);
NTSTATUS
STDCALL
PnpRootDriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath);
NTSTATUS
PnpRootCreateDevice(
PDEVICE_OBJECT *PhysicalDeviceObject);
NTSTATUS
IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject);
NTSTATUS
IopCreateDeviceNode(PDEVICE_NODE ParentNode,
PDEVICE_OBJECT PhysicalDeviceObject,
PDEVICE_NODE *DeviceNode);
NTSTATUS
IopFreeDeviceNode(PDEVICE_NODE DeviceNode);
NTSTATUS
IopInterrogateBusExtender(PDEVICE_NODE DeviceNode,
PDEVICE_OBJECT FunctionDeviceObject,
BOOLEAN BootDriversOnly);
VOID
IopLoadBootStartDrivers(VOID);
NTSTATUS
IopCreateDriverObject(PDRIVER_OBJECT *DriverObject);
NTSTATUS
IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry,
PDEVICE_NODE ParentDeviceNode,
BOOLEAN BootDriversOnly);
VOID
IoInitCancelHandling(VOID);
VOID

View file

@ -9,10 +9,13 @@
#define __INCLUDE_INTERNAL_LDR_H
#include <pe.h>
#include <internal/io.h>
NTSTATUS
LdrLoadDriver (
IN PUNICODE_STRING Filename
PUNICODE_STRING Filename,
PDEVICE_NODE DeviceNode,
BOOLEAN BootDriversOnly
);
NTSTATUS
LdrLoadInitialProcess (
@ -29,7 +32,8 @@ LdrInitModuleManagement (
NTSTATUS
LdrProcessDriver (
IN PVOID ModuleLoadBase,
IN PCHAR FileName
IN PCHAR FileName,
IN ULONG ModuleLength
);
NTSTATUS
LdrpMapSystemDll (

View file

@ -204,7 +204,9 @@ PMEMORY_AREA MmSplitMemoryArea(struct _EPROCESS* Process,
PVOID MmInitializePageList(PVOID FirstPhysKernelAddress,
PVOID LastPhysKernelAddress,
ULONG MemorySizeInPages,
ULONG LastKernelBase);
ULONG LastKernelBase,
PADDRESS_RANGE BIOSMemoryMap,
ULONG AddressRangeCount);
PVOID MmAllocPage(SWAPENTRY SavedSwapEntry);
VOID MmDereferencePage(PVOID PhysicalAddress);
@ -311,7 +313,9 @@ VOID MmFreeSwapPage(SWAPENTRY Entry);
VOID MmInit1(ULONG FirstKernelPhysAddress,
ULONG LastKernelPhysAddress,
ULONG LastKernelAddress);
ULONG LastKernelAddress,
PADDRESS_RANGE BIOSMemoryMap,
ULONG AddressRangeCount);
VOID MmInit2(VOID);
VOID MmInit3(VOID);
NTSTATUS MmInitPagerThread(VOID);

View file

@ -35,7 +35,7 @@ typedef struct _MODULE_TEXT_SECTION
#endif /* KDBG */
PVOID SymbolsBase;
ULONG SymbolsLength;
} MODULE_TEXT_SECTION;
} MODULE_TEXT_SECTION, *PMODULE_TEXT_SECTION;
typedef struct _MODULE_OBJECT
{
@ -48,6 +48,7 @@ typedef struct _MODULE_OBJECT
LIST_ENTRY ListEntry;
UNICODE_STRING FullName;
UNICODE_STRING BaseName;
PMODULE_TEXT_SECTION TextSection;
union
{
struct

View file

@ -0,0 +1,27 @@
/* $Id: po.h,v 1.1 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/po.h
* PURPOSE: Internal power manager declarations
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* UPDATE HISTORY:
* 01/05/2001 Created
*/
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_PO_H
#define __NTOSKRNL_INCLUDE_INTERNAL_PO_H
#include <ddk/ntddk.h>
#include <internal/io.h>
extern PDEVICE_NODE PopSystemPowerDeviceNode;
VOID
PoInit(VOID);
NTSTATUS
PopSetSystemPowerState(
SYSTEM_POWER_STATE PowerState);
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_PO_H */

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.39 2001/05/01 11:05:42 ekohl Exp $
/* $Id: create.c,v 1.40 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -78,12 +78,16 @@ IopCreateFile (PVOID ObjectBody,
if (NULL == DeviceObject)
{
/* This is probably an attempt to create a meta fileobject (eg. for FAT)
for the cache manager, so return STATUS_SUCCESS */
DPRINT("DeviceObject was NULL\n");
return (STATUS_SUCCESS);
}
if (IoDeviceObjectType != BODY_TO_HEADER(Parent)->ObjectType)
{
DPRINT("Parent is not a device type\n");
CPRINT("Parent is a %S which not a device type\n",
BODY_TO_HEADER(Parent)->ObjectType->TypeName.Buffer);
assert(FALSE);
return (STATUS_UNSUCCESSFUL);
}
Status = ObReferenceObjectByPointer (DeviceObject,
@ -121,7 +125,8 @@ IopCreateFile (PVOID ObjectBody,
&& (DeviceObject->DeviceType != FILE_DEVICE_NAMED_PIPE)
&& (DeviceObject->DeviceType != FILE_DEVICE_MAILSLOT))
{
DPRINT("Device was wrong type\n");
CPRINT ("Device was wrong type\n");
assert(FALSE);
return (STATUS_UNSUCCESSFUL);
}
@ -136,7 +141,7 @@ IopCreateFile (PVOID ObjectBody,
DPRINT("Status %x\n", Status);
if (!NT_SUCCESS(Status))
{
DPRINT("Failed to mount storage device (statux %x)\n",
CPRINT("Failed to mount storage device (statux %x)\n",
Status);
return (Status);
}
@ -185,18 +190,19 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject,
{
HANDLE FileHandle;
PFILE_OBJECT CreatedFileObject;
DbgPrint("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n",
DPRINT("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n",
FileObject, DeviceObject);
assert_irql (PASSIVE_LEVEL);
CreatedFileObject = ObCreateObject (&FileHandle,
STANDARD_RIGHTS_REQUIRED,
NULL,
IoFileObjectType);
if (NULL == CreatedFileObject)
{
DPRINT("Could not create FileObject\n");
return (NULL);
}
@ -205,6 +211,9 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject,
DeviceObject = FileObject->DeviceObject;
}
DeviceObject = IoGetAttachedDevice(DeviceObject);
DPRINT("DeviceObject %x\n", DeviceObject);
CreatedFileObject->DeviceObject = DeviceObject;
CreatedFileObject->Vpb = DeviceObject->Vpb;
CreatedFileObject->Type = InternalFileType;
@ -327,13 +336,10 @@ IoCreateFile(
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
{
//FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
//FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
FileObject->Flags |= (FO_ALERTABLE_IO | FO_SYNCHRONOUS_IO);
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT)
{
//FileObject->Flags |= FileObject->Flags | FO_SYNCHRONOUS_IO;
FileObject->Flags |= FO_SYNCHRONOUS_IO;
}
KeInitializeEvent(&FileObject->Lock, NotificationEvent, TRUE);

View file

@ -1,4 +1,4 @@
/* $Id: device.c,v 1.26 2001/03/07 16:48:41 dwelch Exp $
/* $Id: device.c,v 1.27 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -13,11 +13,13 @@
#include <ddk/ntddk.h>
#include <internal/io.h>
#include <internal/po.h>
#include <internal/ob.h>
#include <internal/ldr.h>
#include <internal/id.h>
#include <internal/ps.h>
#include <internal/pool.h>
#include <internal/config.h>
#define NDEBUG
#include <internal/debug.h>
@ -25,6 +27,7 @@
/* GLOBALS *******************************************************************/
#define TAG_DRIVER TAG('D', 'R', 'V', 'R')
#define TAG_DRIVER_EXTENSION TAG('D', 'R', 'V', 'E')
#define TAG_DEVICE_EXTENSION TAG('D', 'E', 'X', 'T')
/* FUNCTIONS ***************************************************************/
@ -58,8 +61,26 @@ NtLoadDriver (
PUNICODE_STRING DriverServiceName
)
{
PDEVICE_NODE DeviceNode;
NTSTATUS Status;
/* FIXME: this should lookup the filename from the registry and then call LdrLoadDriver */
return LdrLoadDriver (DriverServiceName);
/* Use IopRootDeviceNode for now */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
if (!NT_SUCCESS(Status))
{
return(Status);
}
Status = LdrLoadDriver (DriverServiceName, DeviceNode, FALSE);
if (!NT_SUCCESS(Status))
{
IopFreeDeviceNode(DeviceNode);
DPRINT("Driver load failed, status (%x)\n", Status);
}
return Status;
}
@ -210,6 +231,21 @@ IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
return(Current);
}
PDEVICE_OBJECT
STDCALL
IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT Current = DeviceObject;
while (Current->AttachedDevice!=NULL)
{
Current = Current->AttachedDevice;
}
ObReferenceObject(Current);
return(Current);
}
PDEVICE_OBJECT STDCALL
IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
PDEVICE_OBJECT TargetDevice)
@ -247,40 +283,176 @@ IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject,
}
NTSTATUS
IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry)
IopCreateDriverObject(PDRIVER_OBJECT *DriverObject)
{
PDRIVER_OBJECT Object;
ULONG i;
Object = ExAllocatePoolWithTag(NonPagedPool,
sizeof(DRIVER_OBJECT),
TAG_DRIVER);
if (Object == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(Object, sizeof(DRIVER_OBJECT));
Object->DriverExtension = (PDRIVER_EXTENSION)
ExAllocatePoolWithTag(NonPagedPool,
sizeof(DRIVER_EXTENSION),
TAG_DRIVER_EXTENSION);
if (Object->DriverExtension == NULL)
{
ExFreePool(Object);
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(Object->DriverExtension, sizeof(DRIVER_EXTENSION));
Object->Type = InternalDriverType;
for (i=0; i<=IRP_MJ_MAXIMUM_FUNCTION; i++)
{
Object->MajorFunction[i] = IopDefaultDispatchFunction;
}
*DriverObject = Object;
return STATUS_SUCCESS;
}
NTSTATUS
IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry,
PDEVICE_NODE DeviceNode,
BOOLEAN BootDriversOnly)
/*
* FUNCTION: Called to initalize a loaded driver
* ARGUMENTS:
*/
{
NTSTATUS Status;
PDRIVER_OBJECT DriverObject;
ULONG i;
DriverObject =
ExAllocatePoolWithTag(NonPagedPool, sizeof(DRIVER_OBJECT), TAG_DRIVER);
if (DriverObject == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
memset(DriverObject, 0, sizeof(DRIVER_OBJECT));
DriverObject->Type = InternalDriverType;
for (i=0; i<=IRP_MJ_MAXIMUM_FUNCTION; i++)
{
DriverObject->MajorFunction[i] = IopDefaultDispatchFunction;
}
IO_STATUS_BLOCK IoStatusBlock;
PDRIVER_OBJECT DriverObject;
PIO_STACK_LOCATION IrpSp;
PDEVICE_OBJECT Fdo;
NTSTATUS Status;
KEVENT Event;
PIRP Irp;
DPRINT("Calling driver entrypoint at %08lx\n", DriverEntry);
Status = DriverEntry(DriverObject, NULL);
if (!NT_SUCCESS(Status))
{
DPRINT("IopInitializeDriver (DriverEntry %08lx, DeviceNode %08lx, "
"BootDriversOnly %d)\n", DriverEntry, DeviceNode, BootDriversOnly);
Status = IopCreateDriverObject(&DriverObject);
if (!NT_SUCCESS(Status))
{
return(Status);
}
DPRINT("Calling driver entrypoint at %08lx\n", DriverEntry);
Status = DriverEntry(DriverObject, NULL);
if (!NT_SUCCESS(Status))
{
ExFreePool(DriverObject->DriverExtension);
ExFreePool(DriverObject);
return(Status);
}
}
return(Status);
if (DriverObject->DriverExtension->AddDevice)
{
/* This is a Plug and Play driver */
DPRINT("Plug and Play driver found\n");
assert(DeviceNode->Pdo);
DPRINT("Calling driver AddDevice entrypoint at %08lx\n",
DriverObject->DriverExtension->AddDevice);
Status = DriverObject->DriverExtension->AddDevice(
DriverObject, DeviceNode->Pdo);
if (!NT_SUCCESS(Status))
{
ExFreePool(DriverObject->DriverExtension);
ExFreePool(DriverObject);
return(Status);
}
DPRINT("Sending IRP_MN_START_DEVICE to driver\n");
Fdo = IoGetAttachedDeviceReference(DeviceNode->Pdo);
if (Fdo == DeviceNode->Pdo)
{
/* FIXME: What do we do? Unload the driver? */
DbgPrint("An FDO was not attached\n");
KeBugCheck(0);
}
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP,
Fdo,
NULL,
0,
NULL,
&Event,
&IoStatusBlock);
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MinorFunction = IRP_MN_START_DEVICE;
/* FIXME: Put some resources in the IRP for the device */
Status = IoCallDriver(Fdo, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(Fdo);
ExFreePool(DriverObject->DriverExtension);
ExFreePool(DriverObject);
return(Status);
}
if (Fdo->DeviceType == FILE_DEVICE_BUS_EXTENDER)
{
DPRINT("Bus extender found\n");
Status = IopInterrogateBusExtender(
DeviceNode, Fdo, BootDriversOnly);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(Fdo);
ExFreePool(DriverObject->DriverExtension);
ExFreePool(DriverObject);
return(Status);
}
else
{
#ifdef ACPI
static BOOLEAN SystemPowerDeviceNodeCreated = FALSE;
/* The system power device node is the first bus enumerator
device node created after the root device node */
if (!SystemPowerDeviceNodeCreated)
{
PopSystemPowerDeviceNode = DeviceNode;
SystemPowerDeviceNodeCreated = TRUE;
}
#endif /* ACPI */
}
}
ObDereferenceObject(Fdo);
}
return(Status);
}
NTSTATUS STDCALL
@ -411,7 +583,13 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
ExFreePool(CreatedDeviceObject);
return(STATUS_INSUFFICIENT_RESOURCES);
}
if (DeviceExtensionSize > 0)
{
RtlZeroMemory(CreatedDeviceObject->DeviceExtension,
DeviceExtensionSize);
}
CreatedDeviceObject->AttachedDevice = NULL;
CreatedDeviceObject->DeviceType = DeviceType;
CreatedDeviceObject->StackSize = 1;

View file

@ -1,4 +1,4 @@
/* $Id: iomgr.c,v 1.18 2001/03/07 16:48:42 dwelch Exp $
/* $Id: iomgr.c,v 1.19 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -254,6 +254,11 @@ VOID IoInit (VOID)
L"\\??");
IoCreateSymbolicLink (&UnicodeString,
&DeviceName);
/*
* Initialize PnP manager
*/
PnpInit();
}

View file

@ -1,4 +1,4 @@
/* $Id: irp.c,v 1.36 2001/04/09 02:45:04 dwelch Exp $
/* $Id: irp.c,v 1.37 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -104,17 +104,25 @@ IofCallDriver (PDEVICE_OBJECT DeviceObject, PIRP Irp)
PDRIVER_OBJECT DriverObject;
PIO_STACK_LOCATION Param;
// DPRINT("IoCallDriver(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
DPRINT("IofCallDriver(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
assert(Irp);
assert(DeviceObject);
DriverObject = DeviceObject->DriverObject;
assert(DriverObject);
Param = IoGetNextIrpStackLocation(Irp);
DPRINT("IrpSp 0x%X\n", Param);
Irp->Tail.Overlay.CurrentStackLocation--;
Irp->CurrentLocation--;
// DPRINT("MajorFunction %d\n", Param->MajorFunction);
// DPRINT("DriverObject->MajorFunction[Param->MajorFunction] %x\n",
// DriverObject->MajorFunction[Param->MajorFunction]);
DPRINT("MajorFunction %d\n", Param->MajorFunction);
DPRINT("DriverObject->MajorFunction[Param->MajorFunction] %x\n",
DriverObject->MajorFunction[Param->MajorFunction]);
Status = DriverObject->MajorFunction[Param->MajorFunction](DeviceObject,
Irp);
return Status;

View file

@ -1,4 +1,4 @@
/* $Id: pnpmgr.c,v 1.1 2001/04/16 00:51:19 chorns Exp $
/* $Id: pnpmgr.c,v 1.2 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -12,14 +12,23 @@
/* INCLUDES ******************************************************************/
#include <ddk/ntddk.h>
#include <internal/io.h>
#include <internal/po.h>
#include <internal/ldr.h>
#include <internal/module.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
PDEVICE_NODE IopRootDeviceNode;
KSPIN_LOCK IopDeviceTreeLock;
/* DATA **********************************************************************/
PDRIVER_OBJECT IopRootDriverObject;
/* FUNCTIONS *****************************************************************/
VOID
@ -238,8 +247,234 @@ IoUnregisterPlugPlayNotification(
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject)
{
KIRQL OldIrql;
assert(PopSystemPowerDeviceNode);
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
*DeviceObject = PopSystemPowerDeviceNode->Pdo;
KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql);
return STATUS_SUCCESS;
}
/**********************************************************************
* DESCRIPTION
* Creates a device node
*
* ARGUMENTS
* ParentNode = Pointer to parent device node
* PhysicalDeviceObject = Pointer to PDO for device object. Pass NULL
* to have the root device node create one
* (eg. for legacy drivers)
* DeviceNode = Pointer to storage for created device node
*
* RETURN VALUE
* Status
*/
NTSTATUS
IopCreateDeviceNode(PDEVICE_NODE ParentNode,
PDEVICE_OBJECT PhysicalDeviceObject,
PDEVICE_NODE *DeviceNode)
/* */
{
PDEVICE_NODE Node;
NTSTATUS Status;
KIRQL OldIrql;
DPRINT("ParentNode %x PhysicalDeviceObject %x\n");
Node = (PDEVICE_NODE)ExAllocatePool(PagedPool, sizeof(DEVICE_NODE));
if (!Node)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(Node, sizeof(DEVICE_NODE));
if (!PhysicalDeviceObject)
{
Status = PnpRootCreateDevice(&PhysicalDeviceObject);
if (!NT_SUCCESS(Status))
{
ExFreePool(Node);
return Status;
}
}
Node->Pdo = PhysicalDeviceObject;
if (ParentNode)
{
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
Node->Parent = ParentNode;
Node->NextSibling = ParentNode->Child;
ParentNode->Child->PrevSibling = Node;
ParentNode->Child = Node;
KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql);
}
*DeviceNode = Node;
return STATUS_SUCCESS;
}
NTSTATUS
IopFreeDeviceNode(PDEVICE_NODE DeviceNode)
{
KIRQL OldIrql;
/* All children must be deleted before a parent is deleted */
assert(!DeviceNode->Child);
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
assert(DeviceNode->Pdo);
ObDereferenceObject(DeviceNode->Pdo);
/* Unlink from parent if it exists */
if ((DeviceNode->Parent) && (DeviceNode->Parent->Child == DeviceNode))
{
DeviceNode->Parent->Child = DeviceNode->NextSibling;
}
/* Unlink from sibling list */
if (DeviceNode->PrevSibling)
{
DeviceNode->PrevSibling->NextSibling = DeviceNode->NextSibling;
}
if (DeviceNode->NextSibling)
{
DeviceNode->NextSibling->PrevSibling = DeviceNode->PrevSibling;
}
KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql);
ExFreePool(DeviceNode);
return STATUS_SUCCESS;
}
NTSTATUS
IopInterrogateBusExtender(PDEVICE_NODE DeviceNode,
PDEVICE_OBJECT FunctionDeviceObject,
BOOLEAN BootDriversOnly)
{
IO_STATUS_BLOCK IoStatusBlock;
PIO_STACK_LOCATION IrpSp;
NTSTATUS Status;
KEVENT Event;
PIRP Irp;
DPRINT("Sending IRP_MN_QUERY_DEVICE_RELATIONS to bus driver\n");
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP,
FunctionDeviceObject,
NULL,
0,
NULL,
&Event,
&IoStatusBlock);
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
IrpSp->Parameters.QueryDeviceRelations.Type = BusRelations;
Status = IoCallDriver(FunctionDeviceObject, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
if (!NT_SUCCESS(Status))
{
CPRINT("IoCallDriver() failed\n");
}
return Status;
}
VOID IopLoadBootStartDrivers(VOID)
{
UNICODE_STRING DriverName;
PDEVICE_NODE DeviceNode;
NTSTATUS Status;
DPRINT("Loading boot start drivers\n");
return;
/* FIXME: Get these from registry */
/* Use IopRootDeviceNode for now */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
if (!NT_SUCCESS(Status))
{
return;
}
/*
* ISA Plug and Play driver
*/
RtlInitUnicodeString(&DriverName,
L"\\SystemRoot\\system32\\drivers\\isapnp.sys");
Status = LdrLoadDriver(&DriverName, DeviceNode, TRUE);
if (!NT_SUCCESS(Status))
{
IopFreeDeviceNode(DeviceNode);
/* FIXME: Write an entry in the system error log */
DbgPrint("Could not load boot start driver: %wZ, status 0x%X\n",
&DriverName, Status);
return;
}
}
VOID PnpInit(VOID)
{
NTSTATUS Status;
DPRINT("Called\n");
KeInitializeSpinLock(&IopDeviceTreeLock);
Status = IopCreateDriverObject(&IopRootDriverObject);
if (!NT_SUCCESS(Status))
{
DbgPrint("IoCreateDriverObject() failed\n");
KeBugCheck(0);
}
PnpRootDriverEntry(IopRootDriverObject, NULL);
Status = IoCreateDevice(IopRootDriverObject, 0, NULL,
FILE_DEVICE_CONTROLLER, 0, FALSE, &IopRootDeviceNode->Pdo);
if (!NT_SUCCESS(Status))
{
DbgPrint("IoCreateDevice() failed\n");
KeBugCheck(0);
}
IopRootDeviceNode->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
IopRootDriverObject->DriverExtension->AddDevice(
IopRootDriverObject, IopRootDeviceNode->Pdo);
}
/* EOF */

View file

@ -0,0 +1,290 @@
/* $Id: pnproot.c,v 1.1 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/pnproot.c
* PURPOSE: PnP manager root device
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* UPDATE HISTORY:
* 16/04/2001 CSH Created
*/
/* INCLUDES ******************************************************************/
#include <ddk/ntddk.h>
#include <internal/io.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
/* DATA **********************************************************************/
typedef struct _PNPROOT_DEVICE {
LIST_ENTRY ListEntry;
PDEVICE_OBJECT Pdo;
} PNPROOT_DEVICE, *PPNPROOT_DEVICE;
PDEVICE_OBJECT PnpRootDeviceObject;
LIST_ENTRY PnpRootDeviceListHead;
ULONG PnpRootDeviceListCount;
KSPIN_LOCK PnpRootDeviceListLock;
/* FUNCTIONS *****************************************************************/
NTSTATUS
PnpRootCreateDevice(
PDEVICE_OBJECT *PhysicalDeviceObject)
{
PPNPROOT_DEVICE Device;
NTSTATUS Status;
DPRINT("Called\n");
Device = (PPNPROOT_DEVICE)ExAllocatePool(PagedPool, sizeof(PNPROOT_DEVICE));
if (!Device)
return STATUS_INSUFFICIENT_RESOURCES;
Status = IoCreateDevice(PnpRootDeviceObject->DriverObject, 0,
NULL, FILE_DEVICE_CONTROLLER, 0, FALSE, &Device->Pdo);
if (!NT_SUCCESS(Status))
{
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
ExFreePool(Device);
return Status;
}
Device->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
ObReferenceObject(Device->Pdo);
ExInterlockedInsertTailList(&PnpRootDeviceListHead,
&Device->ListEntry,
&PnpRootDeviceListLock);
*PhysicalDeviceObject = Device->Pdo;
return STATUS_SUCCESS;
}
NTSTATUS
PnpRootQueryBusRelations(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PIO_STACK_LOCATION IrpSp)
{
PDEVICE_RELATIONS Relations;
PLIST_ENTRY CurrentEntry;
PPNPROOT_DEVICE Device;
NTSTATUS Status;
ULONG Size;
ULONG i;
DPRINT("Called\n");
Size = sizeof(DEVICE_RELATIONS) + sizeof(Relations->Objects) *
(PnpRootDeviceListCount - 1);
Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size);
if (!Relations)
return STATUS_INSUFFICIENT_RESOURCES;
Relations->Count = PnpRootDeviceListCount;
i = 0;
CurrentEntry = PnpRootDeviceListHead.Flink;
while (CurrentEntry != &PnpRootDeviceListHead)
{
Device = CONTAINING_RECORD(
CurrentEntry, PNPROOT_DEVICE, ListEntry);
if (!Device->Pdo) {
/* Create a physical device object for the
device as it does not already have one */
Status = IoCreateDevice(DeviceObject->DriverObject, 0,
NULL, FILE_DEVICE_CONTROLLER, 0, FALSE, &Device->Pdo);
if (!NT_SUCCESS(Status)) {
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
ExFreePool(Relations);
return Status;
}
Device->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
}
/* Reference the physical device object. The PnP manager
will dereference it again when it is no longer needed */
ObReferenceObject(Device->Pdo);
Relations->Objects[i] = Device->Pdo;
i++;
CurrentEntry = CurrentEntry->Flink;
}
Irp->IoStatus.Information = (ULONG)Relations;
return Status;
}
NTSTATUS
PnpRootQueryDeviceRelations(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PIO_STACK_LOCATION IrpSp)
{
NTSTATUS Status;
DPRINT("Called\n");
switch (IrpSp->Parameters.QueryDeviceRelations.Type)
{
case BusRelations:
Status = PnpRootQueryBusRelations(DeviceObject, Irp, IrpSp);
break;
default:
Status = STATUS_NOT_IMPLEMENTED;
}
return Status;
}
NTSTATUS
STDCALL
PnpRootPnpControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION IrpSp;
NTSTATUS Status;
DPRINT("Called\n");
IrpSp = IoGetCurrentIrpStackLocation(Irp);
switch (IrpSp->MinorFunction)
{
case IRP_MN_QUERY_DEVICE_RELATIONS:
Status = PnpRootQueryDeviceRelations(DeviceObject, Irp, IrpSp);
break;
case IRP_MN_START_DEVICE:
PnpRootDeviceListCount = 0;
Status = STATUS_SUCCESS;
break;
case IRP_MN_STOP_DEVICE:
/* Root device cannot be stopped */
Status = STATUS_UNSUCCESSFUL;
break;
default:
DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
Status = STATUS_NOT_IMPLEMENTED;
break;
}
if (Status != STATUS_PENDING)
{
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
DPRINT("Leaving. Status 0x%X\n", Status);
return Status;
}
NTSTATUS
STDCALL
PnpRootPowerControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION IrpSp;
NTSTATUS Status;
DPRINT("Called\n");
IrpSp = IoGetCurrentIrpStackLocation(Irp);
switch (IrpSp->MinorFunction)
{
default:
DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
Status = STATUS_NOT_IMPLEMENTED;
break;
}
if (Status != STATUS_PENDING)
{
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
DPRINT("Leaving. Status 0x%X\n", Status);
return Status;
}
NTSTATUS
PnpRootAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject)
{
PDEVICE_OBJECT Ldo;
NTSTATUS Status;
DPRINT("Called\n");
Status = IoCreateDevice(DriverObject, 0, NULL, FILE_DEVICE_BUS_EXTENDER,
FILE_DEVICE_SECURE_OPEN, TRUE, &PnpRootDeviceObject);
if (!NT_SUCCESS(Status))
{
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
KeBugCheck(0);
return Status;
}
Ldo = IoAttachDeviceToDeviceStack(PnpRootDeviceObject, PhysicalDeviceObject);
if (!PnpRootDeviceObject)
{
DbgPrint("PnpRootDeviceObject 0x%X\n", PnpRootDeviceObject);
KeBugCheck(0);
}
if (!PhysicalDeviceObject)
{
DbgPrint("PhysicalDeviceObject 0x%X\n", PhysicalDeviceObject);
KeBugCheck(0);
}
InitializeListHead(&PnpRootDeviceListHead);
PnpRootDeviceListCount = 0;
KeInitializeSpinLock(&PnpRootDeviceListLock);
PnpRootDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
DPRINT("Done\n");
return STATUS_SUCCESS;
}
NTSTATUS
STDCALL
PnpRootDriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
DPRINT("Called\n");
DriverObject->MajorFunction[IRP_MJ_PNP] = PnpRootPnpControl;
DriverObject->MajorFunction[IRP_MJ_POWER] = PnpRootPowerControl;
DriverObject->DriverExtension->AddDevice = PnpRootAddDevice;
return STATUS_SUCCESS;
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: shutdown.c,v 1.4 2001/03/07 16:48:42 dwelch Exp $
/* $Id: shutdown.c,v 1.5 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -14,6 +14,7 @@
#include <ddk/ntddk.h>
#include <internal/pool.h>
#define NDEBUG
#include <internal/debug.h>
/* LOCAL DATA ***************************************************************/

View file

@ -1,4 +1,4 @@
/* $Id: dlog.c,v 1.2 2001/03/25 18:56:12 dwelch Exp $
/* $Id: dlog.c,v 1.3 2001/05/01 23:08:19 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -13,6 +13,7 @@
#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <internal/config.h>
#include <internal/kd.h>
#include <ntos/minmax.h>

View file

@ -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: main.c,v 1.94 2001/04/26 03:58:32 phreak Exp $
/* $Id: main.c,v 1.95 2001/05/01 23:08:19 chorns Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c
@ -38,6 +38,7 @@
#include <internal/ps.h>
#include <internal/ke.h>
#include <internal/io.h>
#include <internal/po.h>
#include <napi/shared_data.h>
#include <internal/v86m.h>
#include <internal/kd.h>
@ -56,6 +57,8 @@ LOADER_PARAMETER_BLOCK EXPORTED KeLoaderBlock;
static LOADER_MODULE KeLoaderModules[64];
static UCHAR KeLoaderModuleStrings[64][256];
static UCHAR KeLoaderCommandLine[256];
static ADDRESS_RANGE KeMemoryMap[64];
static ULONG KeMemoryMapRangeCount;
static ULONG FirstKrnlPhysAddr;
static ULONG LastKrnlPhysAddr;
static ULONG LastKernelAddress;
@ -134,7 +137,7 @@ CreateSystemRootLink (PCSZ ParameterLine)
{
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&DeviceName);
DbgPrint("NtOpenSymbolicLinkObject() '%wZ' failed (Status %x)\n",
DPRINT("NtOpenSymbolicLinkObject() '%wZ' failed (Status %x)\n",
&ArcName,
Status);
RtlFreeUnicodeString (&ArcName);
@ -382,11 +385,34 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
}
}
#ifndef NDEBUG
VOID DumpBIOSMemoryMap(VOID)
{
ULONG i;
DbgPrint("Dumping BIOS memory map:\n");
DbgPrint("Memory map base: %d\n", KeLoaderBlock.MmapAddr);
DbgPrint("Memory map size: %d\n", KeLoaderBlock.MmapLength);
DbgPrint("Address range count: %d\n", KeMemoryMapRangeCount);
for (i = 0; i < KeMemoryMapRangeCount; i++)
{
DbgPrint("Range: Base (%08X) Length (%08X) Type (%02X)\n",
KeMemoryMap[i].BaseAddrLow,
KeMemoryMap[i].LengthLow,
KeMemoryMap[i].Type);
}
for (;;);
}
#endif /* !NDEBUG */
VOID
ExpInitializeExecutive(VOID)
{
ULONG i;
ULONG start;
ULONG length;
PCHAR name;
CHAR str[50];
@ -416,7 +442,11 @@ ExpInitializeExecutive(VOID)
NtEarlyInitVdm();
MmInit1(FirstKrnlPhysAddr, LastKrnlPhysAddr, LastKernelAddress);
MmInit1(FirstKrnlPhysAddr,
LastKrnlPhysAddr,
LastKernelAddress,
(PADDRESS_RANGE)&KeMemoryMap,
KeMemoryMapRangeCount);
/*
* Initialize the kernel debugger
@ -480,6 +510,7 @@ ExpInitializeExecutive(VOID)
ExInit();
IoInit();
PoInit();
LdrInitModuleManagement();
CmInitializeRegistry();
NtInit();
@ -487,7 +518,7 @@ ExpInitializeExecutive(VOID)
/* Report all resources used by hal */
HalReportResourceUsage ();
/*
* Enter the kernel debugger before starting up the boot drivers
*/
@ -501,7 +532,7 @@ ExpInitializeExecutive(VOID)
DPRINT1("%d files loaded\n",KeLoaderBlock.ModsCount);
for (i=0; i < KeLoaderBlock.ModsCount; i++)
{
DPRINT1("module: %s\n", KeLoaderModules[i].String);
CPRINT("Module: %s\n", KeLoaderModules[i].String);
}
/* Pass 1: load registry chunks passed in */
@ -510,7 +541,7 @@ ExpInitializeExecutive(VOID)
start = KeLoaderModules[i].ModStart;
if (strcmp ((PCHAR) start, "REGEDIT4") == 0)
{
DPRINT1("process registry chunk at %08lx\n", start);
CPRINT("Process registry chunk at %08lx\n", start);
CmImportHive((PCHAR) start);
}
}
@ -519,16 +550,18 @@ ExpInitializeExecutive(VOID)
for (i=1; i < KeLoaderBlock.ModsCount; i++)
{
start = KeLoaderModules[i].ModStart;
length = KeLoaderModules[i].ModEnd - start;
name = (PCHAR)KeLoaderModules[i].String;
if (strcmp ((PCHAR) start, "REGEDIT4") != 0)
{
DPRINT1("process module '%s' at %08lx\n", name, start);
LdrProcessDriver((PVOID)start, name);
CPRINT("Processing module '%s' at %08lx, length 0x%08lx\n",
name, start, length);
LdrProcessDriver((PVOID)start, name, length);
}
}
/* Create the SystemRoot symbolic link */
DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine);
CPRINT("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine);
CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine);
@ -541,6 +574,16 @@ ExpInitializeExecutive(VOID)
CmInitializeRegistry2();
/*
* Start the motherboard enumerator (the HAL)
*/
HalInitSystem (2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
/*
* Load boot start drivers
*/
IopLoadBootStartDrivers();
/*
* Load Auto configured drivers
*/
@ -599,6 +642,7 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
*/
{
ULONG i;
ULONG size;
ULONG last_kernel_address;
extern ULONG _bss_end__;
@ -640,6 +684,22 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
LastKrnlPhysAddr = last_kernel_address - 0xc0000000 + 0x200000;
LastKernelAddress = last_kernel_address;
KeMemoryMapRangeCount = 0;
if (KeLoaderBlock.Flags & MB_FLAGS_MMAP_INFO)
{
/* We have a memory map from the nice BIOS */
size = *((PULONG)(KeLoaderBlock.MmapAddr - sizeof(ULONG)));
i = 0;
while (i < KeLoaderBlock.MmapLength)
{
memcpy (&KeMemoryMap[KeMemoryMapRangeCount],
(PVOID)(KeLoaderBlock.MmapAddr + i),
sizeof(ADDRESS_RANGE));
KeMemoryMapRangeCount++;
i += size;
}
}
KeInit1();
KiSystemStartup(1);

View file

@ -1,4 +1,4 @@
/* $Id: loader.c,v 1.76 2001/04/26 14:26:22 phreak Exp $
/* $Id: loader.c,v 1.77 2001/05/01 23:08:20 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -28,6 +28,7 @@
#include <internal/config.h>
#include <internal/module.h>
#include <internal/ntoskrnl.h>
#include <internal/io.h>
#include <internal/mm.h>
#include <internal/ob.h>
#include <internal/ps.h>
@ -38,9 +39,6 @@
#include <internal/debug.h>
/* FIXME: this should appear in a kernel header file */
NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
/* MACROS ********************************************************************/
#define MODULE_ROOT_NAME L"\\Modules\\"
@ -222,9 +220,9 @@ VOID LdrInitModuleManagement(VOID)
ModuleObject->Image.PE.OptionalHeader->AddressOfEntryPoint);
DPRINT("ModuleObject:%08x entrypoint at %x\n", ModuleObject, ModuleObject->EntryPoint);
ModuleObject->Length = ModuleObject->Image.PE.OptionalHeader->SizeOfImage;
ModuleObject->TextSection = &NtoskrnlTextSection;
/* FIXME: Add fake module entry for HAL */
}
/*
@ -232,48 +230,64 @@ VOID LdrInitModuleManagement(VOID)
*/
static VOID LdrLoadAutoConfigDriver (LPWSTR RelativeDriverName)
{
WCHAR TmpFileName [MAX_PATH];
NTSTATUS Status;
WCHAR TmpFileName [MAX_PATH];
UNICODE_STRING DriverName;
PDEVICE_NODE DeviceNode;
NTSTATUS Status;
DbgPrint("Loading %S\n",RelativeDriverName);
CPRINT("Loading %S\n",RelativeDriverName);
wcscpy(TmpFileName, L"\\SystemRoot\\system32\\drivers\\");
wcscat(TmpFileName, RelativeDriverName);
RtlInitUnicodeString (&DriverName, TmpFileName);
Status = LdrLoadDriver(&DriverName);
/* Use IopRootDeviceNode for now */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
if (!NT_SUCCESS(Status))
{
DbgPrint("driver load failed, status (%x)\n", Status);
// KeBugCheck(0);
return;
}
Status = LdrLoadDriver(&DriverName, DeviceNode, FALSE);
if (!NT_SUCCESS(Status))
{
IopFreeDeviceNode(DeviceNode);
DPRINT1("Driver load failed, status (%x)\n", Status);
}
}
#ifdef KDBG
BOOLEAN LdrReadLine(PCHAR Line,
PVOID *Buffer,
PULONG Size)
BOOLEAN LdrpReadLine(PCHAR Line,
ULONG LineSize,
PVOID *Buffer,
PULONG Size)
{
CHAR ch;
PCHAR Block;
ULONG Count;
if (*Size == 0)
return FALSE;
ch = ' ';
Count = 0;
Block = *Buffer;
while ((*Size > 0) && ((ch = *Block) != (CHAR)13))
while ((*Size > 0) && (Count < LineSize) && ((ch = *Block) != (CHAR)13))
{
*Line = ch;
Line++;
Block++;
Count++;
*Size -= 1;
}
*Line = (CHAR)0;
Block++;
*Size -= 1;
if (ch == (CHAR)13)
{
Block++;
*Size -= 1;
}
if ((*Size > 0) && (*Block == (CHAR)10))
{
@ -310,9 +324,10 @@ ULONG HexL(PCHAR Buffer)
return Value;
}
PSYMBOL LdrParseLine(PCHAR Line,
PULONG ImageBase,
PBOOLEAN ImageBaseValid)
PSYMBOL LdrpParseLine(PCHAR Line,
PULONG TextBase,
PBOOLEAN TextBaseValid,
PULONG FileAlignment)
/*
Line format: [ADDRESS] <TYPE> <NAME>
TYPE:
@ -334,8 +349,6 @@ PSYMBOL LdrParseLine(PCHAR Line,
PCHAR Str;
CHAR Type;
*ImageBaseValid = FALSE;
if ((Line[0] == (CHAR)0) || (Line[0] == ' '))
return NULL;
@ -359,13 +372,19 @@ PSYMBOL LdrParseLine(PCHAR Line,
else
strncpy((char*)&Buffer, Line, Str - Line);
if ((Type == 'A') && (strcmp((char*)&Buffer, "__image_base__")) == 0)
if ((Type == 'A') && (strcmp((char*)&Buffer, "__file_alignment__")) == 0)
{
*ImageBase = Address;
*ImageBaseValid = TRUE;
*FileAlignment = Address;
return NULL;
}
/* if ((Type == 'A') && (strcmp((char*)&Buffer, "__image_base__")) == 0)
{
*TextBase = Address;
*TextBaseValid = TRUE;
return NULL;
}*/
/* We only want symbols in the .text segment */
if ((Type != 't') && (Type != 'T'))
return NULL;
@ -385,29 +404,86 @@ PSYMBOL LdrParseLine(PCHAR Line,
RtlInitAnsiString(&AnsiString, (PCSZ)&Buffer);
RtlAnsiStringToUnicodeString(&Symbol->Name, &AnsiString, TRUE);
if (!(*TextBaseValid))
{
*TextBase = Address - *FileAlignment;
*TextBaseValid = TRUE;
}
return Symbol;
}
VOID LdrLoadModuleSymbols(PMODULE_OBJECT ModuleObject,
MODULE_TEXT_SECTION* ModuleTextSection)
VOID LdrpLoadModuleSymbolsFromBuffer(
PMODULE_OBJECT ModuleObject,
PVOID Buffer,
ULONG Length)
/*
Symbols must be sorted by address, e.g.
"nm --numeric-sort module.sys > module.sym"
*/
{
WCHAR TmpFileName[MAX_PATH];
LPWSTR Start, Ext;
ULONG Length, Tmp;
UNICODE_STRING Filename;
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
HANDLE FileHandle;
PVOID FileBuffer, FilePtr;
CHAR Line[256];
FILE_STANDARD_INFORMATION FileStdInfo;
BOOLEAN ImageBaseValid;
ULONG ImageBase = 0;
PSYMBOL Symbol, CurrentSymbol = NULL;
BOOLEAN TextBaseValid;
BOOLEAN Valid;
ULONG TextBase = 0;
ULONG FileAlignment = 0;
CHAR Line[256];
ULONG Tmp;
assert(ModuleObject);
if (ModuleObject->TextSection == NULL)
{
ModuleObject->TextSection = &NtoskrnlTextSection;
}
if (ModuleObject->TextSection->Symbols.SymbolCount > 0)
{
CPRINT("Symbols are already loaded for %wZ\n", &ModuleObject->BaseName);
return;
}
ModuleObject->TextSection->Symbols.SymbolCount = 0;
ModuleObject->TextSection->Symbols.Symbols = NULL;
TextBaseValid = FALSE;
Valid = FALSE;
while (LdrpReadLine((PCHAR)&Line, 256, &Buffer, &Length))
{
Symbol = LdrpParseLine((PCHAR)&Line, &Tmp, &Valid, &FileAlignment);
if ((Valid) && (!TextBaseValid))
{
TextBase = Tmp;
TextBaseValid = TRUE;
}
if (Symbol != NULL)
{
Symbol->RelativeAddress -= TextBase;
if (ModuleObject->TextSection->Symbols.Symbols == NULL)
ModuleObject->TextSection->Symbols.Symbols = Symbol;
else
CurrentSymbol->Next = Symbol;
CurrentSymbol = Symbol;
ModuleObject->TextSection->Symbols.SymbolCount++;
}
}
}
VOID LdrpLoadModuleSymbols(PMODULE_OBJECT ModuleObject)
{
FILE_STANDARD_INFORMATION FileStdInfo;
OBJECT_ATTRIBUTES ObjectAttributes;
WCHAR TmpFileName[MAX_PATH];
UNICODE_STRING Filename;
LPWSTR Start, Ext;
HANDLE FileHandle;
PVOID FileBuffer;
NTSTATUS Status;
ULONG Length;
/* Get the path to the symbol store */
wcscpy(TmpFileName, L"\\SystemRoot\\symbols\\");
@ -446,7 +522,7 @@ VOID LdrLoadModuleSymbols(PMODULE_OBJECT ModuleObject,
return;
}
DbgPrint("Loading symbols from %wZ...\n", &Filename);
CPRINT("Loading symbols from %wZ...\n", &Filename);
/* Get the size of the file */
Status = ZwQueryInformationFile(FileHandle,
@ -485,37 +561,50 @@ VOID LdrLoadModuleSymbols(PMODULE_OBJECT ModuleObject,
ZwClose(FileHandle);
ModuleTextSection->Symbols.SymbolCount = 0;
ModuleTextSection->Symbols.Symbols = NULL;
FilePtr = FileBuffer;
Length = FileStdInfo.EndOfFile.u.LowPart;
while (LdrReadLine((PCHAR)&Line, &FilePtr, &Length))
{
Symbol = LdrParseLine((PCHAR)&Line, &Tmp, &ImageBaseValid);
if (ImageBaseValid)
ImageBase = Tmp;
if (Symbol != NULL)
{
Symbol->RelativeAddress -= ImageBase;
if (ModuleTextSection->Symbols.Symbols == NULL)
ModuleTextSection->Symbols.Symbols = Symbol;
else
CurrentSymbol->Next = Symbol;
CurrentSymbol = Symbol;
ModuleTextSection->Symbols.SymbolCount++;
}
}
LdrpLoadModuleSymbolsFromBuffer(ModuleObject,
FileBuffer,
FileStdInfo.EndOfFile.u.LowPart);
ExFreePool(FileBuffer);
}
NTSTATUS LdrpFindModuleObject(
PUNICODE_STRING ModuleName,
PMODULE_OBJECT *ModuleObject)
{
NTSTATUS Status;
WCHAR NameBuffer[MAX_PATH];
UNICODE_STRING Name;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING RemainingPath;
wcscpy(NameBuffer, MODULE_ROOT_NAME);
wcscat(NameBuffer, ModuleName->Buffer);
RtlInitUnicodeString(&Name, NameBuffer);
InitializeObjectAttributes(&ObjectAttributes,
&Name,
0,
NULL,
NULL);
Status = ObFindObject(&ObjectAttributes,
(PVOID*)ModuleObject,
&RemainingPath,
NULL);
if (!NT_SUCCESS(Status))
{
return Status;
}
if ((RemainingPath.Buffer != NULL) || (*ModuleObject == NULL))
{
RtlFreeUnicodeString(&RemainingPath);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
}
#endif /* KDBG */
VOID LdrLoadAutoConfigDrivers (VOID)
@ -524,33 +613,17 @@ VOID LdrLoadAutoConfigDrivers (VOID)
#ifdef KDBG
NTSTATUS Status;
WCHAR NameBuffer[60];
UNICODE_STRING ModuleName;
PMODULE_OBJECT ModuleObject;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING RemainingPath;
/* Load symbols for ntoskrnl.exe and hal.dll because \SystemRoot
is created after their module entries */
wcscpy(NameBuffer, MODULE_ROOT_NAME);
wcscat(NameBuffer, L"ntoskrnl.exe");
RtlInitUnicodeString(&ModuleName, NameBuffer);
RtlInitUnicodeString(&ModuleName, L"ntoskrnl.exe");
InitializeObjectAttributes(&ObjectAttributes,
&ModuleName,
0,
NULL,
NULL);
Status = ObFindObject(&ObjectAttributes,
(PVOID*)&ModuleObject,
&RemainingPath,
NULL);
Status = LdrpFindModuleObject(&ModuleName, &ModuleObject);
if (NT_SUCCESS(Status)) {
RtlFreeUnicodeString(&RemainingPath);
LdrLoadModuleSymbols(ModuleObject, &NtoskrnlTextSection);
LdrpLoadModuleSymbols(ModuleObject);
}
/* FIXME: Load symbols for hal.dll */
@ -643,19 +716,27 @@ LdrCreateModule(PVOID ObjectBody,
* RETURNS: Status
*/
NTSTATUS LdrLoadDriver(PUNICODE_STRING Filename)
NTSTATUS LdrLoadDriver(PUNICODE_STRING Filename,
PDEVICE_NODE DeviceNode,
BOOLEAN BootDriversOnly)
{
PMODULE_OBJECT ModuleObject;
PMODULE_OBJECT ModuleObject;
NTSTATUS Status;
ModuleObject = LdrLoadModule(Filename);
if (ModuleObject == 0)
if (!ModuleObject)
{
return STATUS_UNSUCCESSFUL;
return STATUS_UNSUCCESSFUL;
}
/* FIXME: should we dereference the ModuleObject here? */
Status = IopInitializeDriver(ModuleObject->EntryPoint,
DeviceNode, BootDriversOnly);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(ModuleObject);
}
return IoInitializeDriver(ModuleObject->EntryPoint);
return Status;
}
NTSTATUS LdrLoadGdiDriver (PUNICODE_STRING DriverName,
@ -720,8 +801,8 @@ LdrLoadModule(PUNICODE_STRING Filename)
CHECKPOINT;
if (!NT_SUCCESS(Status))
{
DbgPrint("Could not open module file: %wZ\n", Filename);
return 0;
CPRINT("Could not open module file: %wZ\n", Filename);
return NULL;
}
CHECKPOINT;
@ -733,8 +814,8 @@ LdrLoadModule(PUNICODE_STRING Filename)
FileStandardInformation);
if (!NT_SUCCESS(Status))
{
DbgPrint("Could not get file size\n");
return 0;
CPRINT("Could not get file size\n");
return NULL;
}
CHECKPOINT;
@ -745,8 +826,8 @@ LdrLoadModule(PUNICODE_STRING Filename)
if (ModuleLoadBase == NULL)
{
DbgPrint("could not allocate memory for module");
return 0;
CPRINT("Could not allocate memory for module");
return NULL;
}
CHECKPOINT;
@ -758,10 +839,9 @@ LdrLoadModule(PUNICODE_STRING Filename)
0, 0);
if (!NT_SUCCESS(Status))
{
DbgPrint("could not read module file into memory");
CPRINT("Could not read module file into memory");
ExFreePool(ModuleLoadBase);
return 0;
return NULL;
}
CHECKPOINT;
@ -772,14 +852,88 @@ LdrLoadModule(PUNICODE_STRING Filename)
/* Cleanup */
ExFreePool(ModuleLoadBase);
#ifdef KDBG
/* Load symbols for module if available */
LdrpLoadModuleSymbols(ModuleObject);
#endif /* KDBG */
return ModuleObject;
}
NTSTATUS
LdrProcessDriver(PVOID ModuleLoadBase, PCHAR FileName)
LdrProcessDriver(PVOID ModuleLoadBase, PCHAR FileName, ULONG ModuleLength)
{
PMODULE_OBJECT ModuleObject;
UNICODE_STRING ModuleName;
PDEVICE_NODE DeviceNode;
NTSTATUS Status;
#ifdef KDBG
CHAR TmpBaseName[MAX_PATH];
CHAR TmpFileName[MAX_PATH];
ANSI_STRING AnsiString;
ULONG Length;
PCHAR Ext;
/* Split the filename into base name and extension */
Ext = strrchr(FileName, '.');
if (Ext != NULL)
Length = Ext - FileName;
else
Length = strlen(FileName);
if ((Ext != NULL) && (strcmp(Ext, ".sym") == 0))
{
DPRINT("Module %s is a symbol file\n", FileName);
strncpy(TmpBaseName, FileName, Length);
TmpBaseName[Length] = '\0';
DPRINT("base: %s (Length %d)\n", TmpBaseName, Length);
strcpy(TmpFileName, TmpBaseName);
strcat(TmpFileName, ".sys");
RtlInitAnsiString(&AnsiString, TmpFileName);
DPRINT("dasdsad: %s\n", TmpFileName);
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
Status = LdrpFindModuleObject(&ModuleName, &ModuleObject);
RtlFreeUnicodeString(&ModuleName);
if (!NT_SUCCESS(Status))
{
strcpy(TmpFileName, TmpBaseName);
strcat(TmpFileName, ".exe");
RtlInitAnsiString(&AnsiString, TmpFileName);
RtlAnsiStringToUnicodeString(&ModuleName, &AnsiString, TRUE);
Status = LdrpFindModuleObject(&ModuleName, &ModuleObject);
RtlFreeUnicodeString(&ModuleName);
}
if (NT_SUCCESS(Status))
{
LdrpLoadModuleSymbolsFromBuffer(
ModuleObject,
ModuleLoadBase,
ModuleLength);
}
return(STATUS_SUCCESS);
}
else
{
DPRINT("Module %s is executable\n", FileName);
}
#endif /* KDBG */
/* Use IopRootDeviceNode for now */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
if (!NT_SUCCESS(Status))
{
CPRINT("Driver load failed, status (%x)\n", Status);
return(Status);
}
RtlCreateUnicodeStringFromAsciiz(&ModuleName,
FileName);
@ -788,13 +942,19 @@ LdrProcessDriver(PVOID ModuleLoadBase, PCHAR FileName)
RtlFreeUnicodeString(&ModuleName);
if (ModuleObject == NULL)
{
DPRINT1("Driver load was unsuccessful\n");
return(STATUS_UNSUCCESSFUL);
IopFreeDeviceNode(DeviceNode);
CPRINT("Driver load failed, status (%x)\n", Status);
return(STATUS_UNSUCCESSFUL);
}
/* FIXME: should we dereference the ModuleObject here? */
Status = IopInitializeDriver(ModuleObject->EntryPoint, DeviceNode, FALSE);
if (!NT_SUCCESS(Status))
{
IopFreeDeviceNode(DeviceNode);
CPRINT("Driver load failed, status (%x)\n", Status);
}
return(IoInitializeDriver(ModuleObject->EntryPoint));
return(Status);
}
PMODULE_OBJECT
@ -809,7 +969,7 @@ LdrProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING ModuleName)
return LdrPEProcessModule(ModuleLoadBase, ModuleName);
}
DPRINT1("Module wasn't PE\n");
CPRINT("Module wasn't PE\n");
return 0;
}
@ -1035,23 +1195,23 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING FileName)
/* Check file magic numbers */
if (PEDosHeader->e_magic != IMAGE_DOS_MAGIC)
{
DbgPrint("Incorrect MZ magic: %04x\n", PEDosHeader->e_magic);
CPRINT("Incorrect MZ magic: %04x\n", PEDosHeader->e_magic);
return 0;
}
if (PEDosHeader->e_lfanew == 0)
{
DbgPrint("Invalid lfanew offset: %08x\n", PEDosHeader->e_lfanew);
return 0;
CPRINT("Invalid lfanew offset: %08x\n", PEDosHeader->e_lfanew);
return NULL;
}
if (*PEMagic != IMAGE_PE_MAGIC)
{
DbgPrint("Incorrect PE magic: %08x\n", *PEMagic);
return 0;
CPRINT("Incorrect PE magic: %08x\n", *PEMagic);
return NULL;
}
if (PEFileHeader->Machine != IMAGE_FILE_MACHINE_I386)
{
DbgPrint("Incorrect Architechture: %04x\n", PEFileHeader->Machine);
return 0;
CPRINT("Incorrect Architechture: %04x\n", PEFileHeader->Machine);
return NULL;
}
CHECKPOINT;
@ -1074,10 +1234,10 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING FileName)
DriverBase = MmAllocateSection(DriverSize);
if (DriverBase == 0)
{
DbgPrint("Failed to allocate a virtual section for driver\n");
CPRINT("Failed to allocate a virtual section for driver\n");
return 0;
}
DbgPrint("DriverBase: %x\n", DriverBase);
CPRINT("DriverBase: %x\n", DriverBase);
CHECKPOINT;
/* Copy headers over */
memcpy(DriverBase, ModuleLoadBase, PEOptionalHeader->SizeOfHeaders);
@ -1174,8 +1334,8 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING FileName)
}
else if (Type != 0)
{
DbgPrint("Unknown relocation type %x at %x\n",Type, &Type);
return 0;
CPRINT("Unknown relocation type %x at %x\n",Type, &Type);
return NULL;
}
}
TotalRelocs += RelocDir->SizeOfBlock;
@ -1218,7 +1378,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING FileName)
LibraryModuleObject = LdrLoadModule(&ModuleName);
if (LibraryModuleObject == 0)
{
DbgPrint("Unknown import module: %wZ\n", &ModuleName);
CPRINT("Unknown import module: %wZ\n", &ModuleName);
}
/* Get the import address list */
ImportAddressList = (PVOID *) ((DWORD)DriverBase +
@ -1262,8 +1422,8 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING FileName)
}
else
{
DbgPrint("Unresolved kernel symbol: %s\n", pName);
return(NULL);
CPRINT("Unresolved kernel symbol: %s\n", pName);
return(NULL);
}
ImportAddressList++;
FunctionNameList++;
@ -1285,7 +1445,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING FileName)
wcscat(NameBuffer, FileName->Buffer);
}
RtlInitUnicodeString (&ModuleName, NameBuffer);
DbgPrint("Module name is: %wZ\n", &ModuleName);
CPRINT("Module name is: %wZ\n", &ModuleName);
/* Initialize ObjectAttributes for ModuleObject */
InitializeObjectAttributes(&ObjectAttributes,
@ -1341,12 +1501,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING FileName)
wcscpy(ModuleTextSection->Name, NameBuffer);
InsertTailList(&ModuleTextListHead, &ModuleTextSection->ListEntry);
#ifdef KDBG
/* Load symbols for module if available */
LdrLoadModuleSymbols(ModuleObject, ModuleTextSection);
#endif /* KDBG */
ModuleObject->TextSection = ModuleTextSection;
return ModuleObject;
}
@ -1374,7 +1529,6 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
return NULL;
}
FunctionList = (PDWORD)((DWORD)ExportDir->AddressOfFunctions + ModuleObject->Base);
NameList = (PDWORD)((DWORD)ExportDir->AddressOfNames + ModuleObject->Base);
OrdinalList = (PWORD)((DWORD)ExportDir->AddressOfNameOrdinals + ModuleObject->Base);
@ -1416,10 +1570,10 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
if (ExportAddress == 0)
{
DbgPrint("Export not found for %d:%s\n",
CPRINT("Export not found for %d:%s\n",
Hint,
Name != NULL ? Name : "(Ordinal)");
KeBugCheck(0);
return NULL;
}
return ExportAddress;
@ -1454,7 +1608,7 @@ LdrPEGetModuleObject(PUNICODE_STRING ModuleName)
Entry = Entry->Flink;
}
DbgPrint("LdrPEGetModuleObject: Failed to find dll %wZ\n", ModuleName);
CPRINT("LdrPEGetModuleObject: Failed to find dll %wZ\n", ModuleName);
return NULL;
}
@ -1490,12 +1644,11 @@ LdrPEFixupForward(PCHAR ForwardName)
if (ModuleObject == NULL)
{
DbgPrint("LdrPEFixupForward: failed to find module %s\n", NameBuffer);
CPRINT("LdrPEFixupForward: failed to find module %s\n", NameBuffer);
return NULL;
}
return LdrPEGetExportAddress(ModuleObject, p+1, 0);
}
/* EOF */

View file

@ -117,10 +117,96 @@ MmGetContinuousPages(ULONG NumberOfBytes,
return((PVOID)(start * 4096));
}
VOID MiParseRangeToFreeList(
PADDRESS_RANGE Range)
{
ULONG i, first, last;
/* FIXME: Not 64-bit ready */
DPRINT("Range going to free list (Base 0x%X, Length 0x%X, Type 0x%X)\n",
Range->BaseAddrLow,
Range->LengthLow,
Range->Type);
first = (Range->BaseAddrLow + PAGESIZE - 1) / PAGESIZE;
last = first + ((Range->LengthLow + PAGESIZE - 1) / PAGESIZE) + 1;
for (i = first; i < last; i++)
{
if (MmPageArray[i].Flags == 0)
{
MmPageArray[i].Flags = MM_PHYSICAL_PAGE_FREE;
MmPageArray[i].ReferenceCount = 0;
InsertTailList(&FreePageListHead,
&MmPageArray[i].ListEntry);
}
}
}
VOID MiParseRangeToBiosList(
PADDRESS_RANGE Range)
{
ULONG i, first, last;
/* FIXME: Not 64-bit ready */
DPRINT("Range going to bios list (Base 0x%X, Length 0x%X, Type 0x%X)\n",
Range->BaseAddrLow,
Range->LengthLow,
Range->Type);
first = (Range->BaseAddrLow + PAGESIZE - 1) / PAGESIZE;
last = first + ((Range->LengthLow + PAGESIZE - 1) / PAGESIZE) + 1;
for (i = first; i < last; i++)
{
/* Remove the page from the free list if it is there */
if (MmPageArray[i].Flags == MM_PHYSICAL_PAGE_FREE)
{
RemoveEntryList(&MmPageArray[i].ListEntry);
}
if (MmPageArray[i].Flags != MM_PHYSICAL_PAGE_BIOS)
{
MmPageArray[i].Flags = MM_PHYSICAL_PAGE_BIOS;
MmPageArray[i].ReferenceCount = 1;
InsertTailList(&BiosPageListHead,
&MmPageArray[i].ListEntry);
}
}
}
VOID MiParseBIOSMemoryMap(
ULONG MemorySizeInPages,
PADDRESS_RANGE BIOSMemoryMap,
ULONG AddressRangeCount)
{
PADDRESS_RANGE p;
ULONG i;
p = BIOSMemoryMap;
for (i = 0; i < AddressRangeCount; i++)
{
if (((p->BaseAddrLow + PAGESIZE - 1) / PAGESIZE) < MemorySizeInPages)
{
if (p->Type == 1)
{
MiParseRangeToFreeList(p);
}
else
{
MiParseRangeToBiosList(p);
}
}
p += 1;
}
}
PVOID MmInitializePageList(PVOID FirstPhysKernelAddress,
PVOID LastPhysKernelAddress,
ULONG MemorySizeInPages,
ULONG LastKernelAddress)
ULONG LastKernelAddress,
PADDRESS_RANGE BIOSMemoryMap,
ULONG AddressRangeCount)
/*
* FUNCTION: Initializes the page list with all pages free
* except those known to be reserved and those used by the kernel
@ -141,7 +227,7 @@ PVOID MmInitializePageList(PVOID FirstPhysKernelAddress,
LastPhysKernelAddress,
MemorySizeInPages,
LastKernelAddress);
InitializeListHead(&UsedPageListHead);
KeInitializeSpinLock(&PageListLock);
InitializeListHead(&FreePageListHead);
@ -282,7 +368,16 @@ PVOID MmInitializePageList(PVOID FirstPhysKernelAddress,
MmPageArray[i].ReferenceCount = 0;
InsertTailList(&FreePageListHead,
&MmPageArray[i].ListEntry);
}
}
if ((BIOSMemoryMap != NULL) && (AddressRangeCount > 0))
{
MiParseBIOSMemoryMap(
MemorySizeInPages,
BIOSMemoryMap,
AddressRangeCount);
}
MmStats.NrTotalPages = MmStats.NrFreePages + MmStats.NrSystemPages +
MmStats.NrReservedPages + MmStats.NrUserPages;
return((PVOID)LastKernelAddress);
@ -423,7 +518,7 @@ MmIsUsablePage(PVOID PhysicalAddress)
{
KeBugCheck(0);
}
if (MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_USED &&
MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_BIOS)
{

View file

@ -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: iospace.c,v 1.10 2001/04/09 02:45:04 dwelch Exp $
/* $Id: iospace.c,v 1.11 2001/05/01 23:08:20 chorns Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/iospace.c
@ -93,11 +93,11 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
{
Attributes |= (PAGE_NOCACHE | PAGE_WRITETHROUGH);
}
for (i = 0; (i <= (NumberOfBytes / PAGESIZE)); i++)
for (i = 0; (i < ((NumberOfBytes + PAGESIZE - 1) / PAGESIZE)); i++)
{
Status =
MmCreateVirtualMapping (NULL,
(Result + (i * PAGESIZE)),
MmCreateVirtualMappingForKernel (
(Result + (i * PAGESIZE)),
Attributes,
PhysicalAddress.u.LowPart + (i * PAGESIZE));
if (!NT_SUCCESS(Status))
@ -106,7 +106,7 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
KeBugCheck(0);
}
}
return ((PVOID)Result);
return ((PVOID)(Result + PhysicalAddress.QuadPart % PAGESIZE));
}
@ -138,7 +138,7 @@ MmUnmapIoSpace (IN PVOID BaseAddress,
IN ULONG NumberOfBytes)
{
(VOID)MmFreeMemoryArea(&PsGetCurrentProcess()->AddressSpace,
BaseAddress,
(PVOID)(((ULONG)BaseAddress / PAGESIZE) * PAGESIZE),
NumberOfBytes,
NULL,
NULL);

View file

@ -308,6 +308,9 @@ MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
BaseAddress);
if (MemoryArea == NULL)
{
DPRINT1("AddressSpace 0x%X - KASpace 0x%X\n", AddressSpace, MmGetKernelAddressSpace());
DPRINT1("Memory area is NULL\n");
KeBugCheck(0);
return(STATUS_UNSUCCESSFUL);
}

View file

@ -1,4 +1,4 @@
/* $Id: mminit.c,v 1.20 2001/04/26 14:26:23 phreak Exp $
/* $Id: mminit.c,v 1.21 2001/05/01 23:08:20 chorns Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
@ -79,6 +79,7 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
ULONG Length;
ULONG ParamLength = KernelLength;
NTSTATUS Status;
//ULONG i;
DPRINT("MmInitVirtualMemory(%x, %x)\n",LastKernelAddress, KernelLength);
@ -163,14 +164,29 @@ VOID MmInitVirtualMemory(ULONG LastKernelAddress,
KeBugCheck(0);
}
((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->TickCountLow = 0xdeadbeef;
#if 0
for (i = 0; i < 0x100; i++)
{
Status = MmCreateVirtualMapping(NULL,
(PVOID)(i*PAGESIZE),
PAGE_READWRITE,
(ULONG)(i*PAGESIZE));
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
}
#endif
// MmDumpMemoryAreas();
DPRINT("MmInitVirtualMemory() done\n");
}
VOID MmInit1(ULONG FirstKrnlPhysAddr,
ULONG LastKrnlPhysAddr,
ULONG LastKernelAddress)
ULONG LastKernelAddress,
PADDRESS_RANGE BIOSMemoryMap,
ULONG AddressRangeCount)
/*
* FUNCTION: Initalize memory managment
*/
@ -216,7 +232,7 @@ VOID MmInit1(ULONG FirstKrnlPhysAddr,
*/
#ifndef MP
/* FIXME: This is broken in SMP mode */
MmDeletePageTable(NULL, 0);
//MmDeletePageTable(NULL, 0);
#endif
/*
* Free all pages not used for kernel memory
@ -240,13 +256,18 @@ VOID MmInit1(ULONG FirstKrnlPhysAddr,
/* add 1MB for standard memory (not extended) */
MmStats.NrTotalPages += 256;
}
#if 1
MmStats.NrTotalPages += 16;
#endif
DbgPrint("Used memory %dKb\n", (MmStats.NrTotalPages * PAGESIZE) / 1024);
LastKernelAddress = (ULONG)MmInitializePageList(
(PVOID)FirstKrnlPhysAddr,
(PVOID)LastKrnlPhysAddr,
MmStats.NrTotalPages,
PAGE_ROUND_UP(LastKernelAddress));
PAGE_ROUND_UP(LastKernelAddress),
BIOSMemoryMap,
AddressRangeCount);
kernel_len = LastKrnlPhysAddr - FirstKrnlPhysAddr;
/*

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.104 2001/04/21 12:39:33 ekohl Exp $
; $Id: ntoskrnl.def,v 1.105 2001/05/01 23:08:17 chorns Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -244,6 +244,7 @@ IoFreeController@4
IoFreeIrp@4
IoFreeMdl@4
IoGetAttachedDevice@4
IoGetAttachedDeviceReference@4
IoGetBaseFileSystemDeviceObject@4
IoGetConfigurationInformation@0
IoGetCurrentProcess@0
@ -550,7 +551,6 @@ NtWriteFile@36
;ObCheckObjectAccess@20
;ObCreateObject@36
ObCreateObject@16
ObDereferenceObject@4
;ObFindHandleForObject@20
;ObGetObjectPointerCount@4
;ObGetObjectSecurity@12
@ -560,15 +560,13 @@ ObOpenObjectByName@28
ObOpenObjectByPointer@28
;ObQueryNameString@16
;ObQueryObjectAuditingByHandle@8
ObfDereferenceObject@4
ObfReferenceObject@4
ObReferenceObjectByHandle@24
ObReferenceObjectByName@32
ObReferenceObjectByPointer@16
;ObReleaseObjectSecurity@8
;ObSetSecurityDescriptorInfo@24
;@ObfDereferenceObject@4
ObfDereferenceObject@4
;@ObfReferenceObject@4
ObfReferenceObject@4
ObAddEntryDirectory@12
;PfxFindPrefix
;PfxInitialize

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.91 2001/04/21 12:39:33 ekohl Exp $
; $Id: ntoskrnl.edf,v 1.92 2001/05/01 23:08:18 chorns Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -244,6 +244,7 @@ IoFreeController=IoFreeController@4
IoFreeIrp=IoFreeIrp@4
IoFreeMdl=IoFreeMdl@4
IoGetAttachedDevice=IoGetAttachedDevice@4
IoGetAttachedDeviceReference=IoGetAttachedDeviceReference@4
IoGetBaseFileSystemDeviceObject=IoGetBaseFileSystemDeviceObject@4
IoGetConfigurationInformation=IoGetConfigurationInformation@0
IoGetCurrentProcess=IoGetCurrentProcess@0
@ -550,7 +551,6 @@ NtWriteFile=NtWriteFile@36
;ObCheckObjectAccess=ObCheckObjectAccess@20
;ObCreateObject=ObCreateObject@36
ObCreateObject=ObCreateObject@16
ObDereferenceObject=ObDereferenceObject@4
;ObFindHandleForObject=ObFindHandleForObject@20
;ObGetObjectPointerCount=ObGetObjectPointerCount@4
;ObGetObjectSecurity=ObGetObjectSecurity@12
@ -560,15 +560,13 @@ ObOpenObjectByName=ObOpenObjectByName@28
ObOpenObjectByPointer=ObOpenObjectByPointer@28
;ObQueryNameString=ObQueryNameString@16
;ObQueryObjectAuditingByHandle=ObQueryObjectAuditingByHandle@8
ObfDereferenceObject=ObfDereferenceObject@4
ObfReferenceObject=ObfReferenceObject@4
ObReferenceObjectByHandle=ObReferenceObjectByHandle@24
ObReferenceObjectByName=ObReferenceObjectByName@32
ObReferenceObjectByPointer=ObReferenceObjectByPointer@16
;ObReleaseObjectSecurity=ObReleaseObjectSecurity@8
;ObSetSecurityDescriptorInfo=ObSetSecurityDescriptorInfo@24
;ObfDereferenceObject=@ObfDereferenceObject@4
ObfDereferenceObject=ObfDereferenceObject@4
;ObfReferenceObject=@ObfReferenceObject@4
ObfReferenceObject=ObfReferenceObject@4
ObAddEntryDirectory=ObAddEntryDirectory@12
;PfxFindPrefix
;PfxInitialize

View file

@ -1,4 +1,4 @@
/* $Id: object.c,v 1.35 2001/05/01 11:06:24 ekohl Exp $
/* $Id: object.c,v 1.36 2001/05/01 23:08:20 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -12,6 +12,7 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/config.h>
#include <internal/ob.h>
#include <internal/ps.h>
#include <internal/id.h>
@ -113,8 +114,8 @@ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
DPRINT("ObFindObject(ObjectAttributes %x, ReturnedObject %x, "
"RemainingPath %x)\n",ObjectAttributes,ReturnedObject,RemainingPath);
DPRINT("ObjectAttributes->ObjectName->Buffer %x\n",
ObjectAttributes->ObjectName->Buffer);
DPRINT("ObjectAttributes->ObjectName %wZ\n",
ObjectAttributes->ObjectName);
RtlInitUnicodeString (RemainingPath, NULL);
@ -171,6 +172,10 @@ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
{
DPRINT("current %S\n",current);
CurrentHeader = BODY_TO_HEADER(CurrentObject);
DPRINT("Current ObjectType %wZ\n",
&CurrentHeader->ObjectType->TypeName);
if (CurrentHeader->ObjectType->Parse == NULL)
{
DPRINT("Current object can't parse\n");
@ -273,7 +278,6 @@ ObCreateObject(PHANDLE Handle,
if ((Header->ObjectType != NULL) &&
(Header->ObjectType->Create != NULL))
{
DPRINT("Calling %x\n", Header->ObjectType);
DPRINT("Calling %x\n", Header->ObjectType->Create);
Status = Header->ObjectType->Create(HEADER_TO_BODY(Header),
Parent,
@ -281,7 +285,10 @@ ObCreateObject(PHANDLE Handle,
ObjectAttributes);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject( Parent );
if (Parent)
{
ObDereferenceObject( Parent );
}
RtlFreeUnicodeString( &Header->Name );
RtlFreeUnicodeString( &RemainingPath );
ExFreePool( Header );
@ -431,57 +438,58 @@ ULONG ObGetHandleCount(PVOID ObjectBody)
/**********************************************************************
* NAME EXPORTED
* @ObfReferenceObject@0
* ObfReferenceObject@4
*
* DESCRIPTION
* Increments a given object's reference count and performs
* retention checks.
*
* ARGUMENTS
* ObjectBody
* Body of the object.
* ObjectBody = Body of the object.
*
* RETURN VALUE
* The current value of the reference counter.
* None.
*/
ULONG FASTCALL ObfReferenceObject(PVOID ObjectBody)
VOID FASTCALL ObfReferenceObject(PVOID Object)
{
POBJECT_HEADER Header = BODY_TO_HEADER(ObjectBody);
ULONG ReferenceCount;
ReferenceCount = Header->RefCount++;
POBJECT_HEADER Header;
assert (Object);
Header = BODY_TO_HEADER(Object);
Header->RefCount++;
ObPerformRetentionChecks (Header);
return(ReferenceCount);
}
VOID FASTCALL ObfDereferenceObject (PVOID ObjectBody)
VOID FASTCALL ObfDereferenceObject (PVOID Object)
/*
* FUNCTION: Decrements a given object's reference count and performs
* retention checks
* ARGUMENTS:
* ObjectBody = Body of the object
* Object = Body of the object
*/
{
POBJECT_HEADER Header = BODY_TO_HEADER(ObjectBody);
POBJECT_HEADER Header;
extern POBJECT_TYPE PsProcessType;
// DPRINT("ObDeferenceObject(ObjectBody %x) RefCount %d\n",ObjectBody,
// Header->RefCount);
assert (Object);
Header = BODY_TO_HEADER(Object);
if (Header->ObjectType == PsProcessType)
{
DPRINT("Deref p 0x%x with refcount %d type %x ",
ObjectBody, Header->RefCount, PsProcessType);
DPRINT("eip %x\n", ((PULONG)&ObjectBody)[-1]);
Object, Header->RefCount, PsProcessType);
DPRINT("eip %x\n", ((PULONG)&Object)[-1]);
}
if (Header->ObjectType == PsThreadType)
{
DPRINT("Deref t 0x%x with refcount %d type %x ",
ObjectBody, Header->RefCount, PsThreadType);
DPRINT("eip %x\n", ((PULONG)&ObjectBody)[-1]);
Object, Header->RefCount, PsThreadType);
DPRINT("eip %x\n", ((PULONG)&Object)[-1]);
}
Header->RefCount--;
@ -489,21 +497,4 @@ VOID FASTCALL ObfDereferenceObject (PVOID ObjectBody)
ObPerformRetentionChecks(Header);
}
VOID STDCALL ObDereferenceObject (PVOID ObjectBody)
{
POBJECT_HEADER Header = BODY_TO_HEADER(ObjectBody);
extern POBJECT_TYPE PsProcessType;
if (Header->ObjectType == PsProcessType)
{
DPRINT("Deref p 0x%x with refcount %d type %x ",
ObjectBody, Header->RefCount, PsProcessType);
DPRINT("eip %x\n", ((PULONG)&ObjectBody)[-1]);
}
ObfDereferenceObject (ObjectBody);
}
/* EOF */

View file

@ -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: power.c,v 1.2 2001/04/16 00:48:04 chorns Exp $
/* $Id: power.c,v 1.3 2001/05/01 23:08:20 chorns Exp $
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/po/power.c
* PURPOSE: Power Manager
@ -26,6 +26,16 @@
* 16/04/2001 CSH Stubs added
*/
#include <ddk/ntddk.h>
#include <internal/config.h>
#include <internal/io.h>
#include <internal/po.h>
#define NDEBUG
#include <internal/debug.h>
PDEVICE_NODE PopSystemPowerDeviceNode = NULL;
NTSTATUS
STDCALL
@ -33,7 +43,11 @@ PoCallDriver(
IN PDEVICE_OBJECT DeviceObject,
IN OUT PIRP Irp)
{
return STATUS_NOT_IMPLEMENTED;
NTSTATUS Status;
Status = IoCallDriver(DeviceObject, Irp);
return Status;
}
PULONG
@ -112,4 +126,75 @@ PoUnregisterSystemState(
{
}
NTSTATUS
PopSetSystemPowerState(
SYSTEM_POWER_STATE PowerState)
{
#ifdef ACPI
IO_STATUS_BLOCK IoStatusBlock;
PDEVICE_OBJECT DeviceObject;
PIO_STACK_LOCATION IrpSp;
PDEVICE_OBJECT Fdo;
NTSTATUS Status;
KEVENT Event;
PIRP Irp;
Status = IopGetSystemPowerDeviceObject(&DeviceObject);
if (!NT_SUCCESS(Status)) {
CPRINT("No system power driver available\n");
return STATUS_UNSUCCESSFUL;
}
Fdo = IoGetAttachedDeviceReference(DeviceObject);
if (Fdo == DeviceObject)
{
DPRINT("An FDO was not attached\n");
return STATUS_UNSUCCESSFUL;
}
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER,
Fdo,
NULL,
0,
NULL,
&Event,
&IoStatusBlock);
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MinorFunction = IRP_MN_SET_POWER;
IrpSp->Parameters.Power.Type = SystemPowerState;
IrpSp->Parameters.Power.State.SystemState = PowerState;
Status = PoCallDriver(Fdo, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
ObDereferenceObject(Fdo);
return Status;
#endif /* ACPI */
return STATUS_NOT_IMPLEMENTED;
}
VOID
PoInit(VOID)
{
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: psmgr.c,v 1.9 2001/04/16 02:02:07 dwelch Exp $
/* $Id: psmgr.c,v 1.10 2001/05/01 23:08:20 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -14,6 +14,7 @@
#include <internal/ps.h>
#include <reactos/version.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS ***************************************************************/

View file

@ -43,7 +43,7 @@ EXE_POSTFIX := .exe
#CP = copy /B
CP = $(PATH_TO_TOP)/rcopy
DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as
NASM_CMD = nasm
NASM_CMD = nasmw
RM = del
RMDIR = rmdir
#KM_SPECS = specs
@ -115,6 +115,7 @@ OBJCOPY = $(PREFIX)objcopy
-o $@.unstripped \
$^
- $(RM) temp.exp
- $(NM) --numeric-sort $@.unstripped > $@.sym
$(STRIP) --strip-debug $<
$(CC) \
-nostartfiles -nostdlib -e _DriverEntry@8 \
@ -144,11 +145,3 @@ OBJCOPY = $(PREFIX)objcopy
- $(RM) temp.exp
RULES_MAK_INCLUDED = 1

View file

@ -1,4 +1,4 @@
/* $Id: shell.c,v 1.4 2001/02/28 23:51:58 phreak Exp $
/* $Id: shell.c,v 1.5 2001/05/01 23:08:17 chorns Exp $
*
* PROJECT : ReactOS Operating System
* DESCRIPTION: ReactOS' Native Shell
@ -99,6 +99,12 @@ void ExecuteReboot(char* cmdline)
}
void ExecuteShutdown(char* cmdline)
{
NtShutdownSystem (ShutdownNoReboot);
}
void ExecuteType(char* cmdline)
{
HANDLE FileHandle;
@ -358,6 +364,11 @@ void ExecuteCommand(char* line)
ExecuteReboot(tail);
return;
}
if (strcmp(cmd,"shutdown")==0)
{
ExecuteShutdown(tail);
return;
}
if (strcmp(cmd,"type")==0)
{
ExecuteType(tail);