-/* $Id: ide.c,v 1.32 2000/08/22 21:09:25 ekohl Exp $
+/* $Id: ide.c,v 1.33 2000/08/24 19:15:20 ekohl Exp $
*
* IDE.C - IDE Disk driver
* written by Rex Jolliff
* FIXME: add support for ATAPI tape drives
*/
-#include <ddk/ntddk.h>
-
// -------------------------------------------------------------------------
-#include "../../../ntoskrnl/include/internal/i386/io.h"
-#include <string.h>
+#include <ddk/ntddk.h>
#define NDEBUG
#include <debug.h>
IN PIDE_DRIVE_IDENTIFY DrvParms,
PARTITION *PartitionTable);
static NTSTATUS IDECreateDevice(IN PDRIVER_OBJECT DriverObject,
- IN PCHAR DeviceName,
+// IN PCHAR DeviceName,
OUT PDEVICE_OBJECT *DeviceObject,
IN PCONTROLLER_OBJECT ControllerObject,
IN int UnitNumber,
+ IN ULONG DiskNumber,
+ IN ULONG PartitionNumber,
IN PIDE_DRIVE_IDENTIFY DrvParms,
IN DWORD Offset,
IN DWORD Size);
IN PVOID DpcContext);
static VOID IDEFinishOperation(PIDE_CONTROLLER_EXTENSION ControllerExtension);
static VOID IDEIoTimer(PDEVICE_OBJECT DeviceObject, PVOID Context);
-
+
// ---------------------------------------------------------------- Inlines
extern inline void
IN int HarddiskIdx)
{
BOOLEAN CreatedDevices;
- char RawDeviceName[IDE_MAX_NAME_LENGTH];
- char PrimaryDeviceName[IDE_MAX_NAME_LENGTH];
+ WCHAR NameBuffer[IDE_MAX_NAME_LENGTH];
int CommandPort, PartitionIdx, PartitionNum;
NTSTATUS RC;
IDE_DRIVE_IDENTIFY DrvParms;
PDEVICE_OBJECT PrimaryDeviceObject;
PIDE_DEVICE_EXTENSION RawDeviceExtension;
PARTITION PartitionTable[4], *p;
- char DeviceDirName[IDE_MAX_NAME_LENGTH + 1];
- ANSI_STRING AnsiDeviceDirName;
UNICODE_STRING UnicodeDeviceDirName;
OBJECT_ATTRIBUTES DeviceDirAttributes;
HANDLE Handle;
CreatedDevices = FALSE;
// Create the harddisk device directory
- strcpy(DeviceDirName, IDE_NT_ROOTDIR_NAME);
- strcat(DeviceDirName, IDE_NT_DEVICE_NAME);
- DeviceDirName[strlen(DeviceDirName) + 1] = '\0';
- DeviceDirName[strlen(DeviceDirName)] = '0' + HarddiskIdx;
- RtlInitAnsiString(&AnsiDeviceDirName, DeviceDirName);
- RC = RtlAnsiStringToUnicodeString(&UnicodeDeviceDirName,
- &AnsiDeviceDirName,
- TRUE);
- if (!NT_SUCCESS(RC))
- {
- DPRINT("Could not convert ansi to unicode for device dir\n", 0);
- return FALSE;
- }
- InitializeObjectAttributes(&DeviceDirAttributes,
- &UnicodeDeviceDirName,
- 0,
- NULL,
+ swprintf (NameBuffer,
+ L"\\Device\\Harddisk%d",
+ HarddiskIdx);
+ RtlInitUnicodeString(&UnicodeDeviceDirName,
+ NameBuffer);
+ InitializeObjectAttributes(&DeviceDirAttributes,
+ &UnicodeDeviceDirName,
+ 0,
+ NULL,
NULL);
RC = ZwCreateDirectoryObject(&Handle, 0, &DeviceDirAttributes);
if (!NT_SUCCESS(RC))
DPRINT("Could not create device dir object\n", 0);
return FALSE;
}
- RtlFreeUnicodeString(&UnicodeDeviceDirName);
// Create the raw device
- strcpy(RawDeviceName, IDE_NT_ROOTDIR_NAME);
- strcat(RawDeviceName, IDE_NT_DEVICE_NAME);
- RawDeviceName[strlen(RawDeviceName) + 1] = '\0';
- RawDeviceName[strlen(RawDeviceName)] = '0' + HarddiskIdx;
- strcat(RawDeviceName, IDE_NT_PARTITION_NAME);
- RawDeviceName[strlen(RawDeviceName) + 1] = '\0';
- RawDeviceName[strlen(RawDeviceName)] = '0';
-
if (DrvParms.Capabilities & IDE_DRID_LBA_SUPPORTED)
{
SectorCount =
}
RC = IDECreateDevice(DriverObject,
- RawDeviceName,
&RawDeviceObject,
ControllerObject,
DriveIdx,
+ HarddiskIdx,
+ 0,
&DrvParms,
0,
SectorCount);
p->SectorCount);
// Create Device for partition
- strcpy(PrimaryDeviceName, IDE_NT_ROOTDIR_NAME);
- strcat(PrimaryDeviceName, IDE_NT_DEVICE_NAME);
- PrimaryDeviceName[strlen(PrimaryDeviceName) + 1] = '\0';
- PrimaryDeviceName[strlen(PrimaryDeviceName)] = '0' + HarddiskIdx;
- strcat(PrimaryDeviceName, IDE_NT_PARTITION_NAME);
- PrimaryDeviceName[strlen(PrimaryDeviceName) + 1] = '\0';
- PrimaryDeviceName[strlen(PrimaryDeviceName)] = '0' + PartitionNum++;
TotalPartitions++;
RC = IDECreateDevice(DriverObject,
- PrimaryDeviceName,
&PrimaryDeviceObject,
ControllerObject,
DriveIdx,
+ HarddiskIdx,
+ PartitionNum,
&DrvParms,
p->StartingBlock + PartitionOffset,
p->SectorCount);
break;
}
PartitionOffset += (p->StartingBlock + p->SectorCount);
+ PartitionNum++;
}
else if (IsExtendedPartition(p->PartitionType))
{
//
// ARGUMENTS:
// IN PDRIVER_OBJECT DriverObject The system supplied driver object
-// IN PCHAR DeviceName The name of the device
// OUT PDEVICE_OBJECT *DeviceObject The created device object
// IN PCONTROLLER_OBJECT ControllerObject The Controller for the device
// IN BOOLEAN LBASupported Does the drive support LBA addressing?
// NTSTATUS
//
-NTSTATUS
-IDECreateDevice(IN PDRIVER_OBJECT DriverObject,
- IN PCHAR DeviceName,
- OUT PDEVICE_OBJECT *DeviceObject,
- IN PCONTROLLER_OBJECT ControllerObject,
+NTSTATUS
+IDECreateDevice(IN PDRIVER_OBJECT DriverObject,
+ OUT PDEVICE_OBJECT *DeviceObject,
+ IN PCONTROLLER_OBJECT ControllerObject,
IN int UnitNumber,
+ IN ULONG DiskNumber,
+ IN ULONG PartitionNumber,
IN PIDE_DRIVE_IDENTIFY DrvParms,
- IN DWORD Offset,
- IN DWORD Size)
+ IN DWORD Offset,
+ IN DWORD Size)
{
- WCHAR UnicodeBuffer[IDE_MAX_NAME_LENGTH];
+ WCHAR NameBuffer[IDE_MAX_NAME_LENGTH];
+ WCHAR ArcNameBuffer[IDE_MAX_NAME_LENGTH + 15];
+ UNICODE_STRING DeviceName;
+ UNICODE_STRING ArcName;
NTSTATUS RC;
- ANSI_STRING AnsiName;
- UNICODE_STRING UnicodeName;
PIDE_DEVICE_EXTENSION DeviceExtension;
// Create a unicode device name
- RtlInitAnsiString(&AnsiName, DeviceName);
- UnicodeName.MaximumLength = IDE_MAX_NAME_LENGTH * sizeof(WCHAR);
- UnicodeName.Buffer = UnicodeBuffer;
- RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, FALSE);
+ swprintf(NameBuffer,
+ L"\\Device\\Harddisk%d\\Partition%d",
+ DiskNumber,
+ PartitionNumber);
+ RtlInitUnicodeString(&DeviceName,
+ NameBuffer);
// Create the device
- RC = IoCreateDevice(DriverObject, sizeof(IDE_DEVICE_EXTENSION),
- &UnicodeName, FILE_DEVICE_DISK, 0, TRUE, DeviceObject);
- if (!NT_SUCCESS(RC))
+ RC = IoCreateDevice(DriverObject, sizeof(IDE_DEVICE_EXTENSION),
+ &DeviceName, FILE_DEVICE_DISK, 0, TRUE, DeviceObject);
+ if (!NT_SUCCESS(RC))
{
DPRINT("IoCreateDevice call failed\n",0);
return RC;
(DrvParms->Capabilities & IDE_DRID_DMA_SUPPORTED) ? 1 : 0;
// FIXME: deal with bizarre sector sizes
DeviceExtension->BytesPerSector = 512 /* DrvParms->BytesPerSector */;
- DeviceExtension->SectorsPerLogCyl = DrvParms->LogicalHeads *
+ DeviceExtension->SectorsPerLogCyl = DrvParms->LogicalHeads *
DrvParms->SectorsPerTrack;
DeviceExtension->SectorsPerLogTrk = DrvParms->SectorsPerTrack;
DeviceExtension->LogicalHeads = DrvParms->LogicalHeads;
DeviceExtension->Offset = Offset;
DeviceExtension->Size = Size;
- DPRINT("%s: offset %d size %d \n",
- DeviceName,
+ DPRINT("%wZ: offset %d size %d \n",
+ &DeviceName,
DeviceExtension->Offset,
DeviceExtension->Size);
// Initialize the DPC object here
IoInitializeDpcRequest(*DeviceObject, IDEDpcForIsr);
- DbgPrint("%s %dMB\n", DeviceName, Size / 2048);
+ if (PartitionNumber != 0)
+ {
+ DbgPrint("%wZ %dMB\n", &DeviceName, Size / 2048);
+ }
+
+ /* assign arc name */
+ if (PartitionNumber == 0)
+ {
+ swprintf(ArcNameBuffer,
+ L"\\ArcName\\multi(0)disk(0)rdisk(%d)",
+ DiskNumber);
+ }
+ else
+ {
+ swprintf(ArcNameBuffer,
+ L"\\ArcName\\multi(0)disk(0)rdisk(%d)partition(%d)",
+ DiskNumber,
+ PartitionNumber);
+ }
+ RtlInitUnicodeString (&ArcName,
+ ArcNameBuffer);
+ DPRINT1("%wZ ==> %wZ\n", &ArcName, &DeviceName);
+ RC = IoAssignArcName (&ArcName,
+ &DeviceName);
+ if (!NT_SUCCESS(RC))
+ {
+ DPRINT1("IoAssignArcName (%wZ) failed (Status %x)\n",
+ &ArcName, RC);
+ }
+
return RC;
}
#define IDE_MAXIMUM_DEVICES 8
#define IDE_MAX_NAME_LENGTH 50
-#define IDE_NT_ROOTDIR_NAME "\\Device"
-#define IDE_NT_DEVICE_NAME "\\Harddisk"
-#define IDE_NT_PARTITION_NAME "\\Partition"
-#define IDE_WIN32_DEVICE_NAME "\\DosDevices\\IDE"
-#define IDE_DRIVER_NAME "IDEDRIVER"
#define IDE_SECTOR_BUF_SZ 512
#define IDE_MAX_SECTORS_PER_XFER 256
// Access macros for command registers
// Each macro takes an address of the command port block, and data
//
-#define IDEReadError(Address) (inb_p((Address) + IDE_REG_ERROR))
-#define IDEWritePrecomp(Address, Data) (outb_p((Address) + IDE_REG_PRECOMP, (Data)))
-#define IDEReadSectorCount(Address) (inb_p((Address) + IDE_REG_SECTOR_CNT))
-#define IDEWriteSectorCount(Address, Data) (outb_p((Address) + IDE_REG_SECTOR_CNT, (Data)))
-#define IDEReadSectorNum(Address) (inb_p((Address) + IDE_REG_SECTOR_NUM))
-#define IDEWriteSectorNum(Address, Data) (outb_p((Address) + IDE_REG_SECTOR_NUM, (Data)))
-#define IDEReadCylinderLow(Address) (inb_p((Address) + IDE_REG_CYL_LOW))
-#define IDEWriteCylinderLow(Address, Data) (outb_p((Address) + IDE_REG_CYL_LOW, (Data)))
-#define IDEReadCylinderHigh(Address) (inb_p((Address) + IDE_REG_CYL_HIGH))
-#define IDEWriteCylinderHigh(Address, Data) (outb_p((Address) + IDE_REG_CYL_HIGH, (Data)))
-#define IDEReadDriveHead(Address) (inb_p((Address) + IDE_REG_DRV_HEAD))
-#define IDEWriteDriveHead(Address, Data) (outb_p((Address) + IDE_REG_DRV_HEAD, (Data)))
-#define IDEReadStatus(Address) (inb_p((Address) + IDE_REG_STATUS))
-#define IDEWriteCommand(Address, Data) (outb_p((Address) + IDE_REG_COMMAND, (Data)))
+#define IDEReadError(Address) \
+ (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_ERROR)))
+#define IDEWritePrecomp(Address, Data) \
+ (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_PRECOMP), (Data)))
+#define IDEReadSectorCount(Address) \
+ (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_CNT)))
+#define IDEWriteSectorCount(Address, Data) \
+ (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_CNT), (Data)))
+#define IDEReadSectorNum(Address) \
+ (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_NUM)))
+#define IDEWriteSectorNum(Address, Data) \
+ (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_NUM), (Data)))
+#define IDEReadCylinderLow(Address) \
+ (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_LOW)))
+#define IDEWriteCylinderLow(Address, Data) \
+ (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_LOW), (Data)))
+#define IDEReadCylinderHigh(Address) \
+ (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_HIGH)))
+#define IDEWriteCylinderHigh(Address, Data) \
+ (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_HIGH), (Data)))
+#define IDEReadDriveHead(Address) \
+ (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DRV_HEAD)))
+#define IDEWriteDriveHead(Address, Data) \
+ (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DRV_HEAD), (Data)))
+#define IDEReadStatus(Address) \
+ (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_STATUS)))
+#define IDEWriteCommand(Address, Data) \
+ (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_COMMAND), (Data)))
+
//
// Data block read and write commands
//
#define IDEReadBlock(Address, Buffer, Count) \
- (insw((Address) + IDE_REG_DATA_PORT, (Buffer), (Count) / 2))
+ (READ_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
#define IDEWriteBlock(Address, Buffer, Count) \
- (outsw((Address) + IDE_REG_DATA_PORT, (Buffer), (Count) / 2))
+ (WRITE_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
//
// Access macros for control registers
// Each macro takes an address of the control port blank and data
//
-#define IDEWriteDriveControl(Address, Data) (outb_p((Address) + IDE_REG_DEV_CNTRL, (Data)))
+#define IDEWriteDriveControl(Address, Data) \
+ (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DEV_CNTRL), (Data)))
// IDE_DEVICE_EXTENSION
//
#ifndef _INCLUDE_DDK_IOFUNCS_H
#define _INCLUDE_DDK_IOFUNCS_H
-/* $Id: iofuncs.h,v 1.19 2000/07/30 18:22:32 dwelch Exp $ */
+/* $Id: iofuncs.h,v 1.20 2000/08/24 19:06:29 ekohl Exp $ */
/* --- EXPORTED BY NTOSKRNL --- */
* PUNICODE_STRING DeviceName
* );
*/
-#define IoAssignArcName (ArcName, DeviceName) \
- (IoCreateSymbolicLink ((ArcName), (DeviceName)))
+#define IoAssignArcName(ArcName,DeviceName) \
+ (IoCreateSymbolicLink((ArcName),(DeviceName)))
/**********************************************************************
* NAME EXPORTED
VOID
);
-#define IoInitializeDpcRequest(DeviceObject, DpcRoutine) \
+#define IoInitializeDpcRequest(DeviceObject,DpcRoutine) \
(KeInitializeDpc(&(DeviceObject)->Dpc, \
(PKDEFERRED_ROUTINE)(DpcRoutine), \
(DeviceObject)))
PBOOLEAN ConflictDetected
);
-#define IoRequestDpc(DeviceObject, Irp, Context) \
+#define IoRequestDpc(DeviceObject,Irp,Context) \
(KeInsertQueueDpc(&(DeviceObject)->Dpc,(Irp),(Context)))
-#define IoSetCancelRoutine(Irp, NewCancelRoutine) \
+#define IoSetCancelRoutine(Irp,NewCancelRoutine) \
((PDRIVER_CANCEL)InterlockedExchange((PULONG)&(Irp)->CancelRoutine, \
(ULONG)(NewCancelRoutine)));
#ifndef _INCLUDE_DDK_OBTYPES_H
#define _INCLUDE_DDK_OBTYPES_H
-/* $Id: obtypes.h,v 1.8 2000/06/15 18:37:33 ekohl Exp $ */
+/* $Id: obtypes.h,v 1.9 2000/08/24 19:06:29 ekohl Exp $ */
struct _DIRECTORY_OBJECT;
struct _OBJECT_ATTRIBUTES;
NTSTATUS (*Parse)(PVOID ParsedObject,
PVOID *NextObject,
PUNICODE_STRING FullPath,
- PWSTR *Path);
+ PWSTR *Path,
+ struct _OBJECT_TYPE* ObjectType);
/*
*/
-/* $Id: io.h,v 1.3 2000/07/07 10:30:55 dwelch Exp $
+/* $Id: io.h,v 1.4 2000/08/24 19:07:49 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <ddk/ntddk.h>
#include <internal/ob.h>
-extern POBJECT_TYPE IoSymbolicLinkObjectType;
+extern POBJECT_TYPE IoSymbolicLinkType;
/*
* FUNCTION: Called to initalize a loaded driver
struct _EPROCESS* Process);
NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* ReturnedObject,
- PUNICODE_STRING RemainingPath);
-// PWSTR* RemainingPath);
-
+ PUNICODE_STRING RemainingPath,
+ POBJECT_TYPE ObjectType);
ULONG ObGetReferenceCount(PVOID Object);
ULONG ObGetHandleCount(PVOID Object);
VOID ObCloseAllHandles(struct _EPROCESS* Process);
-/* $Id: iomgr.c,v 1.13 2000/07/07 02:10:18 ekohl Exp $
+/* $Id: iomgr.c,v 1.14 2000/08/24 19:09:12 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
OBJECT_ATTRIBUTES attr;
HANDLE handle;
UNICODE_STRING UnicodeString;
- ANSI_STRING AnsiString;
UNICODE_STRING DeviceName;
/*
IoDeviceObjectType->OkayToClose = NULL;
IoDeviceObjectType->Create = IopCreateDevice;
- RtlInitAnsiString (
- & AnsiString,
- "Device"
- );
- RtlAnsiStringToUnicodeString (
+ RtlInitUnicodeString (
& IoDeviceObjectType->TypeName,
- & AnsiString,
- TRUE
+ L"Device"
);
+
/*
* Register iomgr types: FileObjectType
* (alias DriverObjectType)
IoFileObjectType->OkayToClose = NULL;
IoFileObjectType->Create = IopCreateFile;
- RtlInitAnsiString (
- & AnsiString,
- "File"
- );
- RtlAnsiStringToUnicodeString (
+ RtlInitUnicodeString (
& IoFileObjectType->TypeName,
- & AnsiString,
- TRUE
+ L"File"
);
/*
- * Create the device directory
+ * Create the '\Device' directory
*/
- RtlInitAnsiString (
- & AnsiString,
- "\\Device"
- );
- RtlAnsiStringToUnicodeString (
+ RtlInitUnicodeString (
& UnicodeString,
- & AnsiString,
- TRUE
+ L"\\Device"
);
InitializeObjectAttributes (
& attr,
);
/*
- * Create the \?? directory
+ * Create the '\??' directory
*/
- RtlInitAnsiString (
- & AnsiString,
- "\\??"
+ RtlInitUnicodeString (
+ & UnicodeString,
+ L"\\??"
);
- RtlAnsiStringToUnicodeString (
+ InitializeObjectAttributes (
+ & attr,
& UnicodeString,
- & AnsiString,
- TRUE
+ 0,
+ NULL,
+ NULL
);
+ ZwCreateDirectoryObject (
+ & handle,
+ 0,
+ & attr
+ );
+
+ /*
+ * Create the '\ArcName' directory
+ */
+ RtlInitUnicodeString (
+ & UnicodeString,
+ L"\\ArcName");
InitializeObjectAttributes (
& attr,
& UnicodeString,
0,
& attr
);
+
/*
* Initialize remaining subsubsystem
*/
IoInitVpbImplementation ();
/*
- * Create link from \DosDevices to \?? directory
+ * Create link from '\DosDevices' to '\??' directory
*/
RtlInitUnicodeString (&UnicodeString,
L"\\DosDevices");
-/* $Id: symlink.c,v 1.15 2000/06/29 23:35:38 dwelch Exp $
+/* $Id: symlink.c,v 1.16 2000/08/24 19:09:12 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PVOID Object,
PVOID * NextObject,
PUNICODE_STRING FullPath,
- PWSTR * RemainingPath
+ PWSTR * RemainingPath,
+ POBJECT_TYPE ObjectType
)
{
NTSTATUS Status;
PVOID ReturnedObject;
UNICODE_STRING TargetPath;
+ DPRINT("IopParseSymbolicLink (RemainingPath %S)\n", *RemainingPath);
+ /*
+ * Stop parsing if the entire path has been parsed and
+ * the desired object is a symbolic link object.
+ */
+ if (((*RemainingPath == NULL) || (**RemainingPath == 0)) &&
+ (ObjectType == IoSymbolicLinkType))
+ {
+ DPRINT("Parsing stopped!\n");
+ *NextObject = NULL;
+ return STATUS_SUCCESS;
+ }
+
Status = ObReferenceObjectByName(
SymlinkObject->Target.ObjectName,
0,
NTSTATUS Status;
PVOID Object;
+ DPRINT("NtOpenSymbolicLinkObject (Name %wZ)\n",
+ ObjectAttributes->ObjectName);
+
Status = ObReferenceObjectByName(
ObjectAttributes->ObjectName,
ObjectAttributes->Attributes,
NULL,
DesiredAccess,
- NULL,
+ IoSymbolicLinkType,
UserMode,
NULL,
& Object
{
return STATUS_UNSUCCESSFUL;
}
-
SymbolicLink->TargetName.Length = 0;
SymbolicLink->TargetName.MaximumLength =
((wcslen(DeviceName->Buffer) + 1) * sizeof(WCHAR));
-/* $Id: xhaldrv.c,v 1.5 2000/08/22 21:10:28 ekohl Exp $
+/* $Id: xhaldrv.c,v 1.6 2000/08/24 19:09:12 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#define PARTITION_OFFSET 0x01be
#define PARTITION_TBL_SIZE 4
-/*
-#define PTCHSToLBA(c, h, s, scnt, hcnt) ((s) & 0x3f) + \
- (scnt) * ( (h) + (hcnt) * ((c) | (((s) & 0xc0) << 2)))
-#define PTLBAToCHS(lba, c, h, s, scnt, hcnt) ( \
- (s) = (lba) % (scnt) + 1, \
- (lba) /= (scnt), \
- (h) = (lba) % (hcnt), \
- (lba) /= (heads), \
- (c) = (lba) & 0xff, \
- (s) |= ((lba) >> 2) & 0xc0)
-*/
-
#define IsUsablePartition(P) \
((P) != PTEmpty && \
(P) != PTDosExtended && \
RtlInitUnicodeString (&DriveName,
DriveNameBuffer);
- DPRINT1(" %wZ ==> %wZ\n",
- &DriveName,
- PartitionName);
+ DPRINT(" %wZ ==> %wZ\n",
+ &DriveName,
+ PartitionName);
/* create symbolic link */
IoCreateSymbolicLink (&DriveName,
RtlInitUnicodeString (&UnicodeString2,
Buffer2);
- DPRINT1("Creating link: %S ==> %S\n",
- Buffer2,
- Buffer1);
+ DPRINT("Creating link: %S ==> %S\n",
+ Buffer2,
+ Buffer1);
IoCreateSymbolicLink (&UnicodeString2,
&UnicodeString1);
&LayoutInfo);
if (!NT_SUCCESS(Status))
{
- DPRINT1("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n",
- Status);
+ DbgPrint("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n",
+ Status);
continue;
}
&LayoutInfo);
if (!NT_SUCCESS(Status))
{
- DPRINT1("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n",
- Status);
+ DbgPrint("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n",
+ Status);
continue;
}
&LayoutInfo);
if (!NT_SUCCESS(Status))
{
- DPRINT1("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n",
- Status);
+ DbgPrint("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n",
+ Status);
continue;
}
-/* $Id: main.c,v 1.57 2000/08/15 12:44:47 ekohl Exp $
+/* $Id: main.c,v 1.58 2000/08/24 19:10:27 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <internal/ps.h>
#include <internal/hal.h>
#include <internal/ke.h>
+#include <internal/io.h>
#include <internal/mmhal.h>
#include <internal/i386/segment.h>
/* FUNCTIONS ****************************************************************/
-static VOID CreateSystemRootLink (LPWSTR Device)
+static VOID
+CreateSystemRootLink (PCSZ ParameterLine)
{
UNICODE_STRING LinkName;
UNICODE_STRING DeviceName;
+ UNICODE_STRING ArcName;
+ UNICODE_STRING BootPath;
+ PCHAR ParamBuffer;
+ PWCHAR ArcNameBuffer;
+ PCHAR p;
+ NTSTATUS Status;
+ ULONG Length;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ HANDLE Handle;
+ /* create local parameter line copy */
+ ParamBuffer = ExAllocatePool (PagedPool, 256);
+ strcpy (ParamBuffer, (char *)ParameterLine);
+
+ DPRINT("%s\n", ParamBuffer);
+ /* Format: <arc_name>\<path> [options...] */
+
+ /* cut options off */
+ p = strchr (ParamBuffer, ' ');
+ if (p)
+ *p = 0;
+ DPRINT("%s\n", ParamBuffer);
+
+ /* extract path */
+ p = strchr (ParamBuffer, '\\');
+ if (p)
+ {
+ DPRINT("Boot path: %s\n", p);
+ RtlCreateUnicodeStringFromAsciiz (&BootPath, p);
+ *p = 0;
+ }
+ else
+ {
+ DPRINT("Boot path: %s\n", "\\");
+ RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
+ }
+ DPRINT("Arc name: %s\n", ParamBuffer);
+
+ /* Only arc name left - build full arc name */
+ ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
+ swprintf (ArcNameBuffer,
+ L"\\ArcName\\%S", ParamBuffer);
+ RtlInitUnicodeString (&ArcName, ArcNameBuffer);
+ DPRINT("Arc name: %wZ\n", &ArcName);
+
+ /* free ParamBuffer */
+ ExFreePool (ParamBuffer);
+
+ /* allocate device name string */
+ DeviceName.Length = 0;
+ DeviceName.MaximumLength = 256 * sizeof(WCHAR);
+ DeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
+
+ InitializeObjectAttributes (&ObjectAttributes,
+ &ArcName,
+ 0,
+ NULL,
+ NULL);
+
+ Status = NtOpenSymbolicLinkObject (&Handle,
+ SYMBOLIC_LINK_ALL_ACCESS,
+ &ObjectAttributes);
+ RtlFreeUnicodeString (&ArcName);
+ if (!NT_SUCCESS(Status))
+ {
+ RtlFreeUnicodeString (&BootPath);
+ RtlFreeUnicodeString (&DeviceName);
+ DbgPrint("NtOpenSymbolicLinkObject() failed (Status %x)\n",
+ Status);
+
+ KeBugCheck (0x0);
+ }
+
+ Status = NtQuerySymbolicLinkObject (Handle,
+ &DeviceName,
+ &Length);
+ NtClose (Handle);
+ if (!NT_SUCCESS(Status))
+ {
+ RtlFreeUnicodeString (&BootPath);
+ RtlFreeUnicodeString (&DeviceName);
+ DbgPrint("NtQuerySymbolicObject() failed (Status %x)\n",
+ Status);
+
+ KeBugCheck (0x0);
+ }
+ DPRINT("Length: %lu DeviceName: %wZ\n", Length, &DeviceName);
+
+ RtlAppendUnicodeStringToString (&DeviceName,
+ &BootPath);
+
+ RtlFreeUnicodeString (&BootPath);
+ DPRINT("DeviceName: %wZ\n", &DeviceName);
+
+ /* create the '\SystemRoot' link */
RtlInitUnicodeString (&LinkName,
L"\\SystemRoot");
- RtlInitUnicodeString (&DeviceName,
- Device);
+ Status = IoCreateSymbolicLink (&LinkName,
+ &DeviceName);
+ RtlFreeUnicodeString (&DeviceName);
+ if (!NT_SUCCESS(Status))
+ {
+ DbgPrint("IoCreateSymbolicLink() failed (Status %x)\n",
+ Status);
- IoCreateSymbolicLink (&LinkName,
- &DeviceName);
+ KeBugCheck (0x0);
+ }
+
+ /*
+ * FIXME: test if '\SystemRoot' (LinkName)can be opened,
+ * otherwise crash it!
+ */
}
+static VOID
+InitSystemSharedUserPage (VOID)
+{
+ PKUSER_SHARED_DATA SharedPage;
+
+ SharedPage = (PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE;
+
+ /* set system root in shared user page */
+ wcscpy (SharedPage->NtSystemRoot, L"C:\\reactos");
+
+ SharedPage->NtProductType = NtProductWinNt;
+}
+
+
void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
/*
* FUNCTION: Called by the boot loader to start the kernel
* Initializes the kernel parameter line.
* This should be done by the boot loader.
*/
- strcpy (KeLoaderBlock.kernel_parameters, "/DEBUGPORT=SCREEN");
+ strcpy (KeLoaderBlock.kernel_parameters,
+ "multi(0)disk(0)rdisk(0)partition(1)\\reactos /DEBUGPORT=SCREEN");
/*
* Initialization phase 0
*/
DPRINT1("%d files loaded\n",KeLoaderBlock.nr_files);
- /* Pass 1: load registry chunks passed in */
- start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
- for (i = 1; i < KeLoaderBlock.nr_files; i++)
- {
- if (!strcmp ((PCHAR) start, "REGEDIT4"))
- {
- DPRINT1("process registry chunk at %08lx\n", start);
- CmImportHive((PCHAR) start);
- }
- start = start + KeLoaderBlock.module_length[i];
- }
-
- /* Pass 2: process boot loaded drivers */
- start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
- start1 = start + KeLoaderBlock.module_length[1];
- for (i=1;i<KeLoaderBlock.nr_files;i++)
- {
- if (strcmp ((PCHAR) start, "REGEDIT4"))
- {
- DPRINT1("process module at %08lx\n", start);
- LdrProcessDriver((PVOID)start);
- }
- start = start + KeLoaderBlock.module_length[i];
- }
+ /* Pass 1: load registry chunks passed in */
+ start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
+ for (i = 1; i < KeLoaderBlock.nr_files; i++)
+ {
+ if (!strcmp ((PCHAR) start, "REGEDIT4"))
+ {
+ DPRINT1("process registry chunk at %08lx\n", start);
+ CmImportHive((PCHAR) start);
+ }
+ start = start + KeLoaderBlock.module_length[i];
+ }
+
+ /* Pass 2: process boot loaded drivers */
+ start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]);
+ start1 = start + KeLoaderBlock.module_length[1];
+ for (i=1;i<KeLoaderBlock.nr_files;i++)
+ {
+ if (strcmp ((PCHAR) start, "REGEDIT4"))
+ {
+ DPRINT1("process module at %08lx\n", start);
+ LdrProcessDriver((PVOID)start);
+ }
+ start = start + KeLoaderBlock.module_length[i];
+ }
/* Create the SystemRoot symbolic link */
- /* Hardcoded to 'C:\reactos' but this will change. */
- CreateSystemRootLink (L"\\Device\\Harddisk0\\Partition1\\reactos");
+ CreateSystemRootLink (KeLoaderBlock.kernel_parameters);
/*
* Load Auto configured drivers
NULL,
NULL);
- /* set system root in shared user page */
- wcscpy (((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtSystemRoot,
- L"C:\\reactos");
-
- ((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtProductType = NtProductWinNt;
-
+ /* initialize shared user page */
+ InitSystemSharedUserPage ();
/*
* Launch initial process
-/* $Id: loader.c,v 1.60 2000/08/12 19:33:21 dwelch Exp $
+/* $Id: loader.c,v 1.61 2000/08/24 19:11:06 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Status = ObFindObject(&ObjectAttributes,
(PVOID *) &ModuleObject,
- &RemainingPath);
+ &RemainingPath,
+ NULL);
CHECKPOINT;
if (NT_SUCCESS(Status) && (RemainingPath.Buffer == NULL || *(RemainingPath.Buffer) == 0))
{
PVOID ParseContext,
PVOID* ObjectPtr)
{
- PVOID Object;
+ PVOID Object = NULL;
UNICODE_STRING RemainingPath;
-// PWSTR RemainingPath;
OBJECT_ATTRIBUTES ObjectAttributes;
-
+ NTSTATUS Status;
+
InitializeObjectAttributes(&ObjectAttributes,
ObjectPath,
0,
NULL,
NULL);
- ObFindObject(&ObjectAttributes,
- &Object,
- &RemainingPath);
-
+ Status = ObFindObject(&ObjectAttributes,
+ &Object,
+ &RemainingPath,
+ ObjectType);
+ if (!NT_SUCCESS(Status))
+ {
+ return(STATUS_UNSUCCESSFUL);
+ }
+
if (RemainingPath.Buffer != NULL ||
Object == NULL)
{
PVOID Object,
PVOID * NextObject,
PUNICODE_STRING FullPath,
- PWSTR * Path
+ PWSTR * Path,
+ POBJECT_TYPE ObjectType
)
{
PWSTR end;
-/* $Id: object.c,v 1.25 2000/07/30 18:22:35 dwelch Exp $
+/* $Id: object.c,v 1.26 2000/08/24 19:12:16 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/**********************************************************************
* NAME PRIVATE
- * ObFindObject@12
+ * ObFindObject@16
*
* DESCRIPTION
*
* The caller must free the buffer after use by calling
* RtlFreeUnicodeString ().
*
+ * ObjectType
+ * Optional pointer to an object type. This is used to
+ * descide if a symbolic link object will be parsed or not.
+ *
* RETURN VALUE
*/
NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* ReturnedObject,
- PUNICODE_STRING RemainingPath)
+ PUNICODE_STRING RemainingPath,
+ POBJECT_TYPE ObjectType)
{
PVOID NextObject;
PVOID CurrentObject;
Status = CurrentHeader->ObjectType->Parse(CurrentObject,
&NextObject,
&PathString,
- ¤t);
+ ¤t,
+ ObjectType);
if (Status == STATUS_REPARSE)
{
/* reparse the object path */
{
ObFindObject(ObjectAttributes,
&Parent,
- &RemainingPath);
+ &RemainingPath,
+ NULL);
}
else
{