summaryrefslogtreecommitdiffstats
path: root/private/ntos/boot/inc
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/ntos/boot/inc
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/ntos/boot/inc')
-rw-r--r--private/ntos/boot/inc/bldr.h747
-rw-r--r--private/ntos/boot/inc/bldrx86.h234
-rw-r--r--private/ntos/boot/inc/cdfsboot.h175
-rw-r--r--private/ntos/boot/inc/fatboot.h293
-rw-r--r--private/ntos/boot/inc/hpfsboot.h895
-rw-r--r--private/ntos/boot/inc/ntfsboot.h204
-rw-r--r--private/ntos/boot/inc/scsiboot.h500
7 files changed, 3048 insertions, 0 deletions
diff --git a/private/ntos/boot/inc/bldr.h b/private/ntos/boot/inc/bldr.h
new file mode 100644
index 000000000..ce6bc4dc5
--- /dev/null
+++ b/private/ntos/boot/inc/bldr.h
@@ -0,0 +1,747 @@
+/*++
+
+Copyright (c) 1991 Microsoft Corporation
+
+Module Name:
+
+ bldr.h
+
+Abstract:
+
+ This module is the header file for the NT boot loader.
+
+Author:
+
+ David N. Cutler (davec) 10-May-1991
+
+Revision History:
+
+--*/
+
+#ifndef _BLDR_
+#define _BLDR_
+
+#include "ntos.h"
+#include "arccodes.h"
+
+
+//
+// Define boot file id.
+//
+
+#define BOOT_FILEID 2 // boot partition file id
+
+//
+// Define image types.
+//
+
+#define MIPS_IMAGE 0x162
+#define I386_IMAGE 0x14C
+#define ALPHA_IMAGE 0x184
+#define PPC_IMAGE 0x1f0
+
+#if defined(_MIPS_)
+
+#define TARGET_IMAGE MIPS_IMAGE
+
+#endif
+
+#if defined(_X86_)
+
+#define TARGET_IMAGE I386_IMAGE
+#define KSEG0_BASE 0x80000000
+
+#endif
+
+#if defined(_ALPHA_)
+
+#define TARGET_IMAGE ALPHA_IMAGE
+
+#endif
+
+#if defined(_PPC_)
+
+#define TARGET_IMAGE PPC_IMAGE
+
+#endif
+
+//
+// Define size of sector.
+//
+
+#define SECTOR_SIZE 512 // size of disk sector
+#define SECTOR_SHIFT 9 // sector shift value
+
+//
+// Define heap allocation block granularity.
+//
+
+#define BL_GRANULARITY 8
+
+//
+// Define number of entries in file table.
+//
+
+#define BL_FILE_TABLE_SIZE 32
+
+//
+// Define size of memory allocation table.
+//
+
+#define BL_MEMORY_TABLE_SIZE 16
+
+//
+// Define number of loader heap and stack pages.
+//
+
+#define BL_HEAP_PAGES 16
+#define BL_STACK_PAGES 8
+
+//
+// Define buffer alignment macro.
+//
+
+#define ALIGN_BUFFER(Buffer) (PVOID) \
+ ((((ULONG)(Buffer) + BlDcacheFillSize - 1)) & (~(BlDcacheFillSize - 1)))
+
+
+typedef
+ARC_STATUS
+(*PRENAME_ROUTINE)(
+ IN ULONG FileId,
+ IN PCHAR NewName
+ );
+
+typedef struct _BOOTFS_INFO {
+ PWSTR DriverName;
+} BOOTFS_INFO, *PBOOTFS_INFO;
+
+
+//
+// Device entry table structure.
+//
+
+typedef struct _BL_DEVICE_ENTRY_TABLE {
+ PARC_CLOSE_ROUTINE Close;
+ PARC_MOUNT_ROUTINE Mount;
+ PARC_OPEN_ROUTINE Open;
+ PARC_READ_ROUTINE Read;
+ PARC_READ_STATUS_ROUTINE GetReadStatus;
+ PARC_SEEK_ROUTINE Seek;
+ PARC_WRITE_ROUTINE Write;
+ PARC_GET_FILE_INFO_ROUTINE GetFileInformation;
+ PARC_SET_FILE_INFO_ROUTINE SetFileInformation;
+ PRENAME_ROUTINE Rename;
+ PARC_GET_DIRECTORY_ENTRY_ROUTINE GetDirectoryEntry;
+ PBOOTFS_INFO BootFsInfo;
+} BL_DEVICE_ENTRY_TABLE, *PBL_DEVICE_ENTRY_TABLE;
+
+
+//
+// Define main entrypoint.
+//
+ARC_STATUS
+BlOsLoader (
+ IN ULONG Argc,
+ IN PCHAR Argv[],
+ IN PCHAR Envp[]
+ );
+
+
+//
+// Define file I/O prototypes.
+//
+
+ARC_STATUS
+BlIoInitialize (
+ VOID
+ );
+
+ARC_STATUS
+BlClose (
+ IN ULONG FileId
+ );
+
+PBOOTFS_INFO
+BlGetFsInfo(
+ IN ULONG DeviceId
+ );
+
+ARC_STATUS
+BlMount (
+ IN PCHAR MountPath,
+ IN MOUNT_OPERATION Operation
+ );
+
+ARC_STATUS
+BlOpen (
+ IN ULONG DeviceId,
+ IN PCHAR OpenPath,
+ IN OPEN_MODE OpenMode,
+ OUT PULONG FileId
+ );
+
+ARC_STATUS
+BlRead (
+ IN ULONG FileId,
+ OUT PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+BlRename (
+ IN ULONG FileId,
+ IN PCHAR NewName
+ );
+
+ARC_STATUS
+BlGetReadStatus (
+ IN ULONG FileId
+ );
+
+ARC_STATUS
+BlSeek (
+ IN ULONG FileId,
+ IN PLARGE_INTEGER Offset,
+ IN SEEK_MODE SeekMode
+ );
+
+ARC_STATUS
+BlWrite (
+ IN ULONG FileId,
+ IN PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+BlGetFileInformation (
+ IN ULONG FileId,
+ IN PFILE_INFORMATION FileInformation
+ );
+
+ARC_STATUS
+BlSetFileInformation (
+ IN ULONG FileId,
+ IN ULONG AttributeFlags,
+ IN ULONG AttributeMask
+ );
+
+#ifdef DBLSPACE_LEGAL
+VOID
+BlSetAutoDoubleSpace (
+ IN BOOLEAN Enable
+ );
+#endif
+
+//
+// Define image manipulation routine prototyupes.
+//
+
+ARC_STATUS
+BlLoadImage(
+ IN ULONG DeviceId,
+ IN TYPE_OF_MEMORY MemoryType,
+ IN PCHAR LoadFile,
+ IN USHORT ImageType,
+ OUT PVOID *ImageBase);
+
+ARC_STATUS
+BlLoadDeviceDriver (
+ IN ULONG DeviceId,
+ IN PCHAR LoadDevice,
+ IN PCHAR DirectoryPath,
+ IN PCHAR DriverName,
+ IN ULONG DriverFlags,
+ IN PLDR_DATA_TABLE_ENTRY *DriverDataTableEntry
+ );
+
+ARC_STATUS
+BlLoadNLSData(
+ IN ULONG DeviceId,
+ IN PCHAR DeviceName,
+ IN PCHAR DirectoryPath,
+ IN PUNICODE_STRING AnsiCodepage,
+ IN PUNICODE_STRING OemCodepage,
+ IN PUNICODE_STRING LanguageTable,
+ OUT PCHAR BadFileName
+ );
+
+ARC_STATUS
+BlLoadOemHalFont(
+ IN ULONG DeviceId,
+ IN PCHAR DeviceName,
+ IN PCHAR DirectoryPath,
+ IN PUNICODE_STRING OemHalFont,
+ OUT PCHAR BadFileName
+ );
+
+
+
+PVOID
+BlImageNtHeader (
+ IN PVOID Base
+ );
+
+ARC_STATUS
+BlSetupForNt(
+ IN PLOADER_PARAMETER_BLOCK BlLoaderBlock
+ );
+
+ARC_STATUS
+BlScanImportDescriptorTable (
+ IN ULONG DeviceId,
+ IN PCHAR DeviceName,
+ IN PCHAR DirectoryPath,
+ IN PLDR_DATA_TABLE_ENTRY DataTableEntry
+ );
+
+ARC_STATUS
+BlScanOsloaderBoundImportTable (
+ IN PLDR_DATA_TABLE_ENTRY ScanEntry
+ );
+
+#if defined(_ALPHA_)
+
+ARC_STATUS
+BlGeneratePalName(
+ IN PCHAR PalFIleName
+ );
+
+ARC_STATUS
+BlLoadPal(
+ IN ULONG DeviceId,
+ IN TYPE_OF_MEMORY MemoryType,
+ IN PCHAR LoadPath,
+ IN USHORT ImageType,
+ OUT PVOID *ImageBase,
+ IN PCHAR LoadDevice
+ );
+
+#endif
+
+#if defined(_PPC_)
+
+ARC_STATUS
+BlPpcInitialize (
+ VOID
+ );
+
+#endif // defined(_PPC)
+
+//
+// Define configuration allocation prototypes.
+//
+
+
+ARC_STATUS
+BlConfigurationInitialize (
+ IN PCONFIGURATION_COMPONENT Parent,
+ IN PCONFIGURATION_COMPONENT_DATA ParentEntry
+ );
+
+//
+// define routines for searching the ARC firmware tree
+//
+typedef
+BOOLEAN
+(*PNODE_CALLBACK)(
+ IN PCONFIGURATION_COMPONENT_DATA FoundComponent
+ );
+
+BOOLEAN
+BlSearchConfigTree(
+ IN PCONFIGURATION_COMPONENT_DATA Node,
+ IN CONFIGURATION_CLASS Class,
+ IN CONFIGURATION_TYPE Type,
+ IN ULONG Key,
+ IN PNODE_CALLBACK CallbackRoutine
+ );
+
+VOID
+BlGetPathnameFromComponent(
+ IN PCONFIGURATION_COMPONENT_DATA Component,
+ OUT PCHAR ArcName
+ );
+
+BOOLEAN
+BlGetPathMnemonicKey(
+ IN PCHAR OpenPath,
+ IN PCHAR Mnemonic,
+ IN PULONG Key
+ );
+
+ARC_STATUS
+BlGetArcDiskInformation(
+ VOID
+ );
+
+BOOLEAN
+BlReadSignature(
+ IN PCHAR DiskName,
+ IN BOOLEAN IsCdRom
+ );
+
+//
+// Define memory allocation prototypes.
+//
+
+typedef enum _ALLOCATION_POLICY {
+ BlAllocateLowestFit,
+ BlAllocateBestFit,
+ BlAllocateHighestFit
+} ALLOCATION_POLICY, *PALLOCATION_POLICY;
+
+VOID
+BlSetAllocationPolicy (
+ IN ALLOCATION_POLICY MemoryAllocationPolicy,
+ IN ALLOCATION_POLICY HeapAllocationPolicy
+ );
+
+ARC_STATUS
+BlMemoryInitialize (
+ VOID
+ );
+
+ARC_STATUS
+BlAllocateDataTableEntry (
+ IN PCHAR BaseDllName,
+ IN PCHAR FullDllName,
+ IN PVOID ImageHeader,
+ OUT PLDR_DATA_TABLE_ENTRY *Entry
+ );
+
+#define BlAllocateDescriptor(_MemoryType, _BasePage, _PageCount, _ActualBase) \
+ BlAllocateAlignedDescriptor((_MemoryType), \
+ (_BasePage), \
+ (_PageCount), \
+ 1, \
+ (_ActualBase))
+
+ARC_STATUS
+BlAllocateAlignedDescriptor (
+ IN TYPE_OF_MEMORY MemoryType,
+ IN ULONG BasePage,
+ IN ULONG PageCount,
+ IN ULONG Alignment,
+ OUT PULONG ActualBase
+ );
+
+PVOID
+BlAllocateHeapAligned (
+ IN ULONG Size
+ );
+
+PVOID
+BlAllocateHeap (
+ IN ULONG Size
+ );
+
+VOID
+BlStartConfigPrompt(
+ VOID
+ );
+
+BOOLEAN
+BlEndConfigPrompt(
+ VOID
+ );
+
+BOOLEAN
+BlCheckForLoadedDll (
+ IN PCHAR DllName,
+ OUT PLDR_DATA_TABLE_ENTRY *FoundEntry
+ );
+
+PMEMORY_ALLOCATION_DESCRIPTOR
+BlFindMemoryDescriptor(
+ IN ULONG BasePage
+ );
+
+ARC_STATUS
+BlInitResources(
+ IN PCHAR StartCommand
+ );
+
+PCHAR
+BlFindMessage(
+ IN ULONG Id
+ );
+
+ARC_STATUS
+BlGenerateDescriptor (
+ IN PMEMORY_ALLOCATION_DESCRIPTOR MemoryDescriptor,
+ IN MEMORY_TYPE MemoryType,
+ IN ULONG BasePage,
+ IN ULONG PageCount
+ );
+
+VOID
+BlInsertDescriptor (
+ IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor
+ );
+
+#define BlRemoveDescriptor(_md_) RemoveEntryList(&(_md_)->ListEntry)
+
+ARC_STATUS
+BlGenerateDeviceNames (
+ IN PCHAR ArcDeviceName,
+ OUT PCHAR ArcCanonicalName,
+ OUT OPTIONAL PCHAR NtDevicePrefix
+ );
+
+BOOLEAN
+BlLastKnownGoodPrompt(
+ IN OUT PBOOLEAN UseLastKnownGood
+ );
+
+PCHAR
+BlGetArgumentValue (
+ IN ULONG Argc,
+ IN PCHAR Argv[],
+ IN PCHAR ArgumentName
+ );
+
+//
+// Define message output prototype.
+//
+
+VOID
+BlOutputLoadMessage (
+ IN PCHAR DeviceName,
+ IN PCHAR FileName
+ );
+
+//
+// Define file structure recognition prototypes.
+//
+
+PBL_DEVICE_ENTRY_TABLE
+IsCdfsFileStructure (
+ IN ULONG DeviceId,
+ IN PVOID StructureContext
+ );
+
+#ifdef DBLSPACE_LEGAL
+PBL_DEVICE_ENTRY_TABLE
+IsDblsFileStructure (
+ IN ULONG DeviceId,
+ IN PVOID StructureContext
+ );
+#endif
+
+PBL_DEVICE_ENTRY_TABLE
+IsFatFileStructure (
+ IN ULONG DeviceId,
+ IN PVOID StructureContext
+ );
+
+PBL_DEVICE_ENTRY_TABLE
+IsHpfsFileStructure (
+ IN ULONG DeviceId,
+ IN PVOID StructureContext
+ );
+
+PBL_DEVICE_ENTRY_TABLE
+IsNtfsFileStructure (
+ IN ULONG DeviceId,
+ IN PVOID StructureContext
+ );
+
+#if defined(ELTORITO)
+PBL_DEVICE_ENTRY_TABLE
+IsEtfsFileStructure (
+ IN ULONG DeviceId,
+ IN PVOID StructureContext
+ );
+#endif
+
+//
+// Define registry prototypes
+//
+
+ARC_STATUS
+BlLoadSystemHive(
+ IN ULONG DeviceId,
+ IN PCHAR DeviceName,
+ IN PCHAR DirectoryPath,
+ IN PCHAR HiveName
+ );
+
+ARC_STATUS
+BlLoadAndScanSystemHive(
+ IN ULONG DeviceId,
+ IN PCHAR DeviceName,
+ IN PCHAR DirectoryPath,
+ IN PWSTR BootFileSystem,
+ OUT PCHAR BadFileName
+ );
+
+ARC_STATUS
+BlLoadAndInitSystemHive(
+ IN ULONG DeviceId,
+ IN PCHAR DeviceName,
+ IN PCHAR DirectoryPath,
+ IN PCHAR HiveName,
+ IN BOOLEAN IsAlternate,
+ OUT PBOOLEAN RestartSetup
+ );
+
+ARC_STATUS
+BlLoadBootDrivers(
+ IN ULONG DeviceId,
+ IN PCHAR LoadDevice,
+ IN PCHAR SystemPath,
+ IN PLIST_ENTRY BootDriverListHead,
+ OUT PCHAR BadFileName
+ );
+
+PCHAR
+BlScanRegistry(
+ IN PWSTR BootFileSystemPath,
+ OUT PLIST_ENTRY BootDriverListHead,
+ OUT PUNICODE_STRING AnsiCodepage,
+ OUT PUNICODE_STRING OemCodepage,
+ OUT PUNICODE_STRING LanguageTable,
+ OUT PUNICODE_STRING OemHalFont
+ );
+
+
+//
+// Define external references.
+//
+
+extern ULONG BlConsoleOutDeviceId;
+extern ULONG BlConsoleInDeviceId;
+
+extern ULONG BlDcacheFillSize;
+
+extern ULONG BlHeapFree;
+extern ULONG BlHeapLimit;
+extern PLOADER_PARAMETER_BLOCK BlLoaderBlock;
+
+extern ULONG DbcsLangId;
+extern BOOLEAN BlRebootSystem;
+//
+// Routine to get graphics characters
+//
+typedef enum {
+ GraphicsCharDoubleRightDoubleDown = 0,
+ GraphicsCharDoubleLeftDoubleDown,
+ GraphicsCharDoubleRightDoubleUp,
+ GraphicsCharDoubleLeftDoubleUp,
+ GraphicsCharDoubleVertical,
+ GraphicsCharDoubleHorizontal,
+ GraphicsCharMax
+} GraphicsChar;
+
+UCHAR
+GetGraphicsChar(
+ IN GraphicsChar WhichOne
+ );
+
+//
+// Control sequence introducer.
+// On x86 machines the loaders support dbcs and so using
+// 0x9b for output is no good (that value is a dbcs lead byte
+// in several codepages). Escape-leftbracket is a synonym for CSI
+// in the emulated ARC console on x86 (and on many ARC machines too
+// but since we can't be sure all the machines out there support
+// this we use the old-style csi on non-x86).
+//
+// We ignore this issue for characters read from the ARC console
+// since we don't ask for any text to be typed in, just arrow keys,
+// escape, F#, enter, etc.
+//
+#define ASCI_CSI_IN 0x9b
+#ifdef _X86_
+#define ASCI_CSI_OUT "\033[" // escape-leftbracket
+#else
+#define ASCI_CSI_OUT "\233" // 0x9b
+#endif
+
+//
+// Define OS/2 executable resource information structure.
+//
+
+#define FONT_DIRECTORY 0x8007
+#define FONT_RESOURCE 0x8008
+
+typedef struct _RESOURCE_TYPE_INFORMATION {
+ USHORT Ident;
+ USHORT Number;
+ LONG Proc;
+} RESOURCE_TYPE_INFORMATION, *PRESOURCE_TYPE_INFORMATION;
+
+//
+// Define OS/2 executable resource name information structure.
+//
+
+typedef struct _RESOURCE_NAME_INFORMATION {
+ USHORT Offset;
+ USHORT Length;
+ USHORT Flags;
+ USHORT Ident;
+ USHORT Handle;
+ USHORT Usage;
+} RESOURCE_NAME_INFORMATION, *PRESOURCE_NAME_INFORMATION;
+
+//
+// Define debug logging macros and functions.
+//
+
+#if !DBG
+
+#define BlLogInitialize(_x_)
+#define BlLogTerminate()
+#define BlLog(_x_)
+#define BlLogArcDescriptors(_x_)
+#define BlLogMemoryDescriptors(_x_)
+#define BlLogWaitForKeystroke()
+
+#else
+
+VOID
+BlLogInitialize (
+ IN ULONG LogfileDeviceId
+ );
+
+VOID
+BlLogTerminate (
+ VOID
+ );
+
+#define BlLog(_x_) BlLogPrint _x_
+
+#define LOG_DISPLAY 0x0001
+#define LOG_LOGFILE 0x0002
+#define LOG_WAIT 0x8000
+#define LOG_ALL (LOG_DISPLAY | LOG_LOGFILE)
+#define LOG_ALL_W (LOG_ALL | LOG_WAIT)
+
+VOID
+BlLogPrint (
+ ULONG Targets,
+ PCHAR Format,
+ ...
+ );
+
+VOID
+BlLogArcDescriptors (
+ ULONG Targets
+ );
+
+VOID
+BlLogMemoryDescriptors (
+ ULONG Targets
+ );
+
+VOID
+BlLogWaitForKeystroke (
+ VOID
+ );
+
+#endif // DBG
+
+#endif // _BLDR_
diff --git a/private/ntos/boot/inc/bldrx86.h b/private/ntos/boot/inc/bldrx86.h
new file mode 100644
index 000000000..216b7fb7b
--- /dev/null
+++ b/private/ntos/boot/inc/bldrx86.h
@@ -0,0 +1,234 @@
+/*++
+
+Copyright (c) 1992 Microsoft Corporation
+
+Module Name:
+
+ bldrx86.h
+
+Abstract:
+
+ Contains definitions and prototypes specific to the x86 NTLDR.
+
+Author:
+
+ John Vert (jvert) 20-Dec-1993
+
+Revision History:
+
+--*/
+#include "bldr.h"
+
+
+
+ARC_STATUS
+AEInitializeIo(
+ IN ULONG DriveId
+ );
+
+PVOID
+FwAllocateHeap(
+ IN ULONG Size
+ );
+
+VOID
+AbiosInitDataStructures(
+ VOID
+ );
+
+VOID
+MdShutoffFloppy(
+ VOID
+ );
+
+PCHAR
+BlSelectKernel(
+ IN ULONG DriveId,
+ IN PCHAR BootFile,
+ OUT PCHAR *LoadOptions,
+ IN BOOLEAN UseTimeOut
+ );
+
+BOOLEAN
+BlDetectHardware(
+ IN ULONG DriveId,
+ IN PCHAR LoadOptions
+ );
+
+VOID
+BlStartup(
+ IN PCHAR PartitionName
+ );
+
+typedef struct {
+ ULONG ErrorFlag;
+ ULONG Key;
+ ULONG Size;
+ struct {
+ ULONG BaseAddrLow;
+ ULONG BaseAddrHigh;
+ ULONG SizeLow;
+ ULONG SizeHigh;
+ ULONG MemoryType;
+ } Descriptor;
+} E820FRAME, *PE820FRAME;
+
+
+// E X T E R N A L S E R V I C E S T A B L E
+//
+// External Services Table - machine dependent services
+// like reading a sector from the disk and finding out how
+// much memory is installed are provided by a lower level
+// module or a ROM BIOS. The EST provides entry points
+// for the OS loader.
+//
+
+typedef struct _EXTERNAL_SERVICES_TABLE {
+ VOID (__cdecl * RebootProcessor)(VOID);
+ NTSTATUS (__cdecl * DiskIOSystem)(USHORT,USHORT,USHORT,USHORT,USHORT,USHORT,PUCHAR);
+ ULONG (__cdecl * GetKey)(VOID);
+ ULONG (__cdecl * GetCounter)(VOID);
+ VOID (__cdecl * Reboot)(ULONG);
+ ULONG (__cdecl * AbiosServices)(USHORT,PUCHAR,PUCHAR,PUCHAR,PUCHAR,USHORT,USHORT);
+ VOID (__cdecl * DetectHardware)(ULONG, ULONG, PVOID, PULONG, PCHAR, ULONG);
+ VOID (__cdecl * HardwareCursor)(ULONG,ULONG);
+ VOID (__cdecl * GetDateTime)(PULONG,PULONG);
+ VOID (__cdecl * ComPort)(LONG,ULONG,UCHAR);
+ BOOLEAN (__cdecl * IsMcaMachine)(VOID);
+ ULONG (__cdecl * GetStallCount)(VOID);
+ VOID (__cdecl * InitializeDisplayForNt)(VOID);
+ VOID (__cdecl * GetMemoryDescriptor)(P820FRAME);
+#if defined(ELTORITO)
+ NTSTATUS (__cdecl * GetEddsSector)(ULONG,ULONG,ULONG,ULONG,PUCHAR);
+ NTSTATUS (__cdecl * GetElToritoStatus)(PUCHAR,ULONG);
+#endif
+} EXTERNAL_SERVICES_TABLE, *PEXTERNAL_SERVICES_TABLE;
+extern PEXTERNAL_SERVICES_TABLE ExternalServicesTable;
+
+//
+// External Services Macros
+//
+
+#define REBOOT_PROCESSOR (*ExternalServicesTable->RebootProcessor)
+#define GET_SECTOR (*ExternalServicesTable->DiskIOSystem)
+#define RESET_DISK (*ExternalServicesTable->DiskIOSystem)
+#define BIOS_IO (*ExternalServicesTable->DiskIOSystem)
+#define GET_KEY (*ExternalServicesTable->GetKey)
+#define GET_COUNTER (*ExternalServicesTable->GetCounter)
+#define REBOOT (*ExternalServicesTable->Reboot)
+#define ABIOS_SERVICES (*ExternalServicesTable->AbiosServices)
+#define DETECT_HARDWARE (*ExternalServicesTable->DetectHardware)
+#define HW_CURSOR (*ExternalServicesTable->HardwareCursor)
+#define GET_DATETIME (*ExternalServicesTable->GetDateTime)
+#define COMPORT (*ExternalServicesTable->ComPort)
+#define ISMCA (*ExternalServicesTable->IsMcaMachine)
+#define GET_STALL_COUNT (*ExternalServicesTable->GetStallCount)
+#define SETUP_DISPLAY_FOR_NT (*ExternalServicesTable->InitializeDisplayForNt)
+#define GET_MEMORY_DESCRIPTOR (*ExternalServicesTable->GetMemoryDescriptor)
+#if defined(ELTORITO)
+#define GET_EDDS_SECTOR (*ExternalServicesTable->GetEddsSector)
+#define GET_ELTORITO_STATUS (*ExternalServicesTable->GetElToritoStatus)
+#endif
+
+//
+// Define special key input values
+//
+#define DOWN_ARROW 0x5000
+#define UP_ARROW 0x4800
+#define HOME_KEY 0x4700
+#define END_KEY 0x4F00
+#define F1_KEY 0x3B00
+#define F3_KEY 0x3D00
+#define F5_KEY 0x3F00
+#define F6_KEY 0x4000
+
+
+//
+// x86-specific video support
+//
+VOID
+TextGetCursorPosition(
+ OUT PULONG X,
+ OUT PULONG Y
+ );
+
+VOID
+TextSetCursorPosition(
+ IN ULONG X,
+ IN ULONG Y
+ );
+
+VOID
+TextSetCurrentAttribute(
+ IN UCHAR Attribute
+ );
+
+UCHAR
+TextGetCurrentAttribute(
+ VOID
+ );
+
+VOID
+TextClearDisplay(
+ VOID
+ );
+
+VOID
+TextClearToEndOfDisplay(
+ VOID
+ );
+
+VOID
+TextClearFromStartOfLine(
+ VOID
+ );
+
+VOID
+TextClearToEndOfLine(
+ VOID
+ );
+
+VOID
+TextStringOut(
+ IN PUCHAR String
+ );
+
+PUCHAR
+TextCharOut(
+ IN PUCHAR pc
+ );
+
+VOID
+TextFillAttribute(
+ IN UCHAR Attribute,
+ IN ULONG Length
+ );
+
+UCHAR
+TextGetGraphicsCharacter(
+ IN GraphicsChar WhichOne
+ );
+
+VOID
+TextGrInitialize(
+ IN ULONG DiskId
+ );
+
+VOID
+TextGrTerminate(
+ VOID
+ );
+
+//
+// Printf-style routine for x86 use only. This routine can be called
+// only in the x86-specific part of the library, for example in places
+// where arc emulation for video hasn't been initialized yet. All other
+// display should take place with ArcWrite.
+//
+VOID
+BlPrint(
+ PCHAR cp,
+ ...
+ );
+
+#define BlPuts(str) TextStringOut(str)
diff --git a/private/ntos/boot/inc/cdfsboot.h b/private/ntos/boot/inc/cdfsboot.h
new file mode 100644
index 000000000..7f9e35b99
--- /dev/null
+++ b/private/ntos/boot/inc/cdfsboot.h
@@ -0,0 +1,175 @@
+/*++
+
+Copyright (c) 1991 Microsoft Corporation
+
+Module Name:
+
+ CdfsBoot.h
+
+Abstract:
+
+ This module defines globally used procedure and data structures used
+ by Cdfs boot.
+
+Author:
+
+ Brian Andrew [BrianAn] 05-Aug-1991
+
+Revision History:
+
+--*/
+
+#ifndef _CDFSBOOT_
+#define _CDFSBOOT_
+
+#define MAX_CDROM_READ (16 * CD_SECTOR_SIZE)
+
+typedef struct _CDFS_STRUCTURE_CONTEXT {
+
+ //
+ // The following field is the sector offset of the start of
+ // directory data.
+ //
+
+ ULONG RootDirSectorOffset;
+
+ //
+ // The following field is the start of the sector containing the
+ // this directory.
+ //
+
+ ULONG RootDirDiskOffset;
+
+ //
+ // The following field is the size of the directory.
+ //
+
+ ULONG RootDirSize;
+
+ //
+ // The following field is the sector offset of the start of
+ // directory data.
+ //
+
+ ULONG DirSectorOffset;
+
+ //
+ // The following field is the start of the sector containing the
+ // this directory.
+ //
+
+ ULONG DirDiskOffset;
+
+ //
+ // The following field is the size of the directory.
+ //
+
+ ULONG DirSize;
+
+ //
+ // The following field indicates the size of the disk Logical Blocks.
+ //
+
+ ULONG LbnBlockSize;
+
+ //
+ // The following field indicates the number of logical blocks on the
+ // disk.
+ //
+
+ ULONG LogicalBlockCount;
+
+ //
+ // The following indicates whether this is an Iso or Hsg disk.
+ //
+
+ BOOLEAN IsIsoVol;
+
+} CDFS_STRUCTURE_CONTEXT, *PCDFS_STRUCTURE_CONTEXT;
+
+//
+// Define Cdfs file context structure.
+//
+
+typedef struct _CDFS_FILE_CONTEXT {
+
+ //
+ // The following is the disk offset of the read position for the
+ // start of the file. This may include the above number of non-file
+ // bytes.
+ //
+
+ ULONG DiskOffset;
+
+ //
+ // The following field contains the size of the file, in bytes.
+ //
+
+ ULONG FileSize;
+
+ //
+ // The following field indicates whether this is a directory.
+ //
+
+ BOOLEAN IsDirectory;
+
+} CDFS_FILE_CONTEXT, *PCDFS_FILE_CONTEXT;
+
+//
+// Define file I/O prototypes.
+//
+
+ARC_STATUS
+CdfsClose (
+ IN ULONG FileId
+ );
+
+ARC_STATUS
+CdfsOpen (
+ IN PCHAR OpenPath,
+ IN OPEN_MODE OpenMode,
+ OUT PULONG FileId
+ );
+
+ARC_STATUS
+CdfsRead (
+ IN ULONG FileId,
+ OUT PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+CdfsSeek (
+ IN ULONG FileId,
+ IN PLARGE_INTEGER Offset,
+ IN SEEK_MODE SeekMode
+ );
+
+ARC_STATUS
+CdfsWrite (
+ IN ULONG FileId,
+ IN PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+CdfsGetFileInformation (
+ IN ULONG FileId,
+ OUT PFILE_INFORMATION Buffer
+ );
+
+ARC_STATUS
+CdfsSetFileInformation (
+ IN ULONG FileId,
+ IN ULONG AttributeFlags,
+ IN ULONG AttributeMask
+ );
+
+ARC_STATUS
+CdfsInitialize(
+ VOID
+ );
+
+#endif // _CDFSBOOT_
diff --git a/private/ntos/boot/inc/fatboot.h b/private/ntos/boot/inc/fatboot.h
new file mode 100644
index 000000000..71b63cc66
--- /dev/null
+++ b/private/ntos/boot/inc/fatboot.h
@@ -0,0 +1,293 @@
+/*++
+
+Copyright (c) 1991 Microsoft Corporation
+
+Module Name:
+
+ fatboot.h
+
+Abstract:
+
+ This module defines globally used procedure and data structures used
+ by fat boot.
+
+Author:
+
+ Gary Kimura (garyki) 29-Aug-1989
+
+Revision History:
+
+--*/
+
+#ifndef _FATBOOT_
+#define _FATBOOT_
+#include "fat.h"
+#include "cvf.h"
+
+
+//
+// The following structure is used to define the local mcb structure used within
+// the fat boot loader to maintain a small cache of the retrieval information
+// for a single file/directory
+//
+
+#define FAT_MAXIMUM_MCB (41)
+
+typedef struct _FAT_MCB {
+
+ //
+ // The following fields indicate the number of entries in use by
+ // the boot mcb. and the boot mcb itself. The boot mcb is
+ // just a collection of [vbo, lbo] pairs. The last InUse entry
+ // Lbo's value is ignored, because it is only used to give the
+ // length of the previous run.
+ //
+
+ ULONG InUse;
+
+ VBO Vbo[ FAT_MAXIMUM_MCB ];
+ LBO Lbo[ FAT_MAXIMUM_MCB ];
+
+} FAT_MCB, *PFAT_MCB;
+
+//
+// The following structure is used to define the geometry of the fat volume
+// There is one for every mounted volume. It describes the size/configuration
+// of the volume, contains a small cached mcb for the last file being accessed
+// on the volume, and contains a small cache of the fat. Given a FileId we
+// can access the structure context through the structure context field in the
+// global BlFileTable (e.g., BlFileTable[FileId].StructureContext).
+//
+
+//
+// The following constant is used to determine how much of the fat we keep
+// cached in memory at any one time. It must be a multiple of 6 bytes in order to
+// hold complete 12 and 16 bit fat entries in the cache at any one time.
+//
+
+#define FAT_CACHE_SIZE (512*3)
+
+typedef struct _FAT_STRUCTURE_CONTEXT {
+
+ //
+ // The following field contains an unpacked copy of the bios parameter block
+ // for the mounted volume
+ //
+
+ BIOS_PARAMETER_BLOCK Bpb;
+
+ //
+ // The following two fields contain current file id of the file/directory
+ // whose mcb we are keeping around, and the second field is the mcb itself
+ //
+
+ ULONG FileId;
+ FAT_MCB Mcb;
+
+ //
+ // The following fields describe/contain the current cached fat. The vbo
+ // is the smallest vbo of the fat currently in the cache, and cached fat
+ // is a pointer to the cached data. The extra buffer/indirectiion is needed
+ // to keep everything aligned properly. The dirty flag is used to indicate
+ // if the current cached fat has been modified and needs to be flushed to disk.
+ // Vbo is used because this allows us to do a lot of our computations having
+ // already biased lbo offset to the first fat table.
+ //
+
+ BOOLEAN CachedFatDirty;
+ VBO CachedFatVbo;
+ PUCHAR CachedFat;
+ UCHAR CachedFatBuffer[ FAT_CACHE_SIZE + 256 ];
+
+} FAT_STRUCTURE_CONTEXT, *PFAT_STRUCTURE_CONTEXT;
+
+//
+// The following structure is used to define the location and size of each
+// opened file. There is one of these of every opened file. It is part of
+// the union of a BL_FILE_TABLE structuure. Given a FileId we can access the
+// file context via the BlFileTable (e.g., BlFileTable[FileId].u.FatFileContext)
+//
+
+typedef struct _FAT_FILE_CONTEXT {
+
+ //
+ // The following two fields describe where on the disk the dirent for the
+ // file is located and also contains a copy of the dirent
+ //
+
+ LBO DirentLbo;
+ DIRENT Dirent;
+
+} FAT_FILE_CONTEXT, *PFAT_FILE_CONTEXT;
+
+
+//
+// Define file I/O prototypes.
+//
+
+ARC_STATUS
+FatClose (
+ IN ULONG FileId
+ );
+
+ARC_STATUS
+FatOpen (
+ IN PCHAR OpenPath,
+ IN OPEN_MODE OpenMode,
+ OUT PULONG FileId
+ );
+
+ARC_STATUS
+FatRead (
+ IN ULONG FileId,
+ OUT PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+FatSeek (
+ IN ULONG FileId,
+ IN PLARGE_INTEGER Offset,
+ IN SEEK_MODE SeekMode
+ );
+
+ARC_STATUS
+FatWrite (
+ IN ULONG FileId,
+ IN PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+FatGetFileInformation (
+ IN ULONG FileId,
+ OUT PFILE_INFORMATION Buffer
+ );
+
+ARC_STATUS
+FatSetFileInformation (
+ IN ULONG FileId,
+ IN ULONG AttributeFlags,
+ IN ULONG AttributeMask
+ );
+
+ARC_STATUS
+FatRename(
+ IN ULONG FileId,
+ IN PCHAR NewFileName
+ );
+
+ARC_STATUS
+FatGetDirectoryEntry (
+ IN ULONG FileId,
+ IN DIRECTORY_ENTRY *DirEntry,
+ IN ULONG NumberDir,
+ OUT PULONG CountDir
+ );
+
+ARC_STATUS
+FatInitialize(
+ VOID
+ );
+
+#ifdef DBLSPACE_LEGAL
+
+//
+// The remainder of this file contains the double space additions
+//
+
+typedef struct _DBLS_STRUCTURE_CONTEXT {
+
+ //
+ // The following field contains the regular fat structure context
+ // It is important that it be the first field in the struture
+ // because double space boot piggybacks on a lot of the existing
+ // fat boot code, and the context structure is expected to be at
+ // the same offset.
+ //
+
+ FAT_STRUCTURE_CONTEXT FatStructureContext;
+
+ //
+ // For a double space partition we keep track of the cvf, and
+ // vfp (Virtual Fat Partition) layout.
+ //
+
+ CVF_HEADER CvfHeader;
+ CVF_LAYOUT CvfLayout;
+
+ struct {
+
+ COMPONENT_LOCATION Fat;
+ COMPONENT_LOCATION RootDirectory;
+ COMPONENT_LOCATION FileArea;
+
+ ULONG BytesPerCluster;
+
+ } VfpLayout;
+
+ //
+ // The following fields are used to point to the decompression
+ // algorithm's work space.
+ //
+
+ PVOID DecompressWorkSpace;
+ PUCHAR CompressedBuffer;
+ PUCHAR UncompressedBuffer;
+
+ //
+ // The following fields are used to keep a cache of fat extensions
+ //
+
+ LBO CachedFatExtensionsLbo;
+ PCVF_FAT_EXTENSIONS CachedFatExtensions;
+
+} DBLS_STRUCTURE_CONTEXT, *PDBLS_STRUCTURE_CONTEXT;
+
+//
+// Define file I/O prototypes.
+//
+
+ARC_STATUS
+DblsClose (
+ IN ULONG FileId
+ );
+
+ARC_STATUS
+DblsOpen (
+ IN PCHAR OpenPath,
+ IN OPEN_MODE OpenMode,
+ OUT PULONG FileId
+ );
+
+ARC_STATUS
+DblsRead (
+ IN ULONG FileId,
+ OUT PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+DblsSeek (
+ IN ULONG FileId,
+ IN PLARGE_INTEGER Offset,
+ IN SEEK_MODE SeekMode
+ );
+
+ARC_STATUS
+DblsGetFileInformation (
+ IN ULONG FileId,
+ OUT PFILE_INFORMATION Buffer
+ );
+
+ARC_STATUS
+DblsInitialize(
+ VOID
+ );
+
+#endif // def DBLSPACE_LEGAL
+
+#endif // _FATBOOT_
diff --git a/private/ntos/boot/inc/hpfsboot.h b/private/ntos/boot/inc/hpfsboot.h
new file mode 100644
index 000000000..9fa25704a
--- /dev/null
+++ b/private/ntos/boot/inc/hpfsboot.h
@@ -0,0 +1,895 @@
+/*++
+
+Copyright (c) 1991 Microsoft Corporation
+
+Module Name:
+
+ HpfsBoot.h
+
+Abstract:
+
+ This module defines globally used procedure and data structures used
+ by Hpfs boot.
+
+Author:
+
+ Gary Kimura [GaryKi] 19-Jul-1991
+
+Revision History:
+
+--*/
+
+#ifndef _HPFSBOOT_
+#define _HPFSBOOT_
+
+typedef ULONG LBN;
+typedef LBN *PLBN;
+
+typedef ULONG VBN;
+typedef VBN *PVBN;
+
+
+//
+// The following structure is a context block used by the exported
+// procedures in the Hpfs boot package. The context contains our cached
+// part of the boot mcb structure. The max number must not be smaller than
+// the maximum number of leafs possible in a pinball allocation sector plus
+// one.
+//
+
+#define MAXIMUM_NUMBER_OF_BOOT_MCB (41)
+
+typedef struct _HPFS_BOOT_MCB {
+
+ //
+ // The following fields indicate the number of entries in use by
+ // the boot mcb. and the boot mcb itself. The boot mcb is
+ // just a collection of vbn - lbn pairs. The last InUse entry
+ // Lbn's value is ignored, because it is only used to give the
+ // length of the previous run.
+ //
+
+ ULONG InUse;
+
+ VBN Vbn[ MAXIMUM_NUMBER_OF_BOOT_MCB ];
+ LBN Lbn[ MAXIMUM_NUMBER_OF_BOOT_MCB ];
+
+} HPFS_BOOT_MCB, *PHPFS_BOOT_MCB;
+
+typedef struct _HPFS_STRUCTURE_CONTEXT {
+
+ //
+ // The following field contains the fnode lbn of the file
+ //
+
+ LBN Fnode;
+
+ //
+ // The following field contains the cached mcb
+ //
+
+ HPFS_BOOT_MCB BootMcb;
+
+} HPFS_STRUCTURE_CONTEXT, *PHPFS_STRUCTURE_CONTEXT;
+
+//
+// Define Hpfs file context structure.
+//
+
+typedef struct _HPFS_FILE_CONTEXT {
+
+ //
+ // The following field contains the size of the file, in bytes.
+ //
+
+ ULONG FileSize;
+
+} HPFS_FILE_CONTEXT, *PHPFS_FILE_CONTEXT;
+
+//
+// HPFS file system structures
+//
+typedef ULONG SIGNATURE;
+typedef SIGNATURE *PSIGNATURE;
+
+typedef ULONG PINBALL_TIME;
+typedef PINBALL_TIME *PPINBALL_TIME;
+//
+// There are only three sectors on the disk that have fixed locations. They
+// are the boot sector, the super sector, and the spare sector.
+//
+
+#define BOOT_SECTOR_LBN (0)
+#define SUPER_SECTOR_LBN (16)
+#define SPARE_SECTOR_LBN (17)
+
+typedef struct _SUPER_SECTOR {
+
+ //
+ // The Super Sector starts with a double signature.
+ //
+
+ SIGNATURE Signature1; // offset = 0x000 0
+ SIGNATURE Signature2; // offset = 0x004 4
+
+ //
+ // The version and functional version describe the version of
+ // the on-disk file system structures and the oldest version of the
+ // file system that can understand this disk.
+ //
+
+ UCHAR Version; // offset = 0x008 8
+ UCHAR FunctionalVersion; // offset = 0x009 9
+ USHORT Unused1; // offset = 0x00A 10
+
+ //
+ // This field denotes the sector containing the FNODE for the root
+ // directory for the volume.
+ //
+
+ LBN RootDirectoryFnode; // offset = 0x00C 12
+
+ //
+ // The follow two fields indicate the number of total sectors on the
+ // volume (good and bad), and the number of bad sectors on the volume.
+ //
+
+ ULONG NumberOfSectors; // offset = 0x010 16
+ ULONG NumberOfBadSectors; // offset = 0x014 20
+
+ //
+ // This field denotes the sector containing the first level of the
+ // volumes bitmap table.
+ //
+
+ LBN BitMapIndirect; // offset = 0x018 24
+ ULONG Unused2; // offset = 0x01C 28
+
+ //
+ // This field denotes the sector containing the first bad sector disk
+ // buffer for the volume.
+ //
+
+ LBN BadSectorList; // offset = 0x020 32
+ ULONG Unused3; // offset = 0x024 36
+
+ //
+ // The following two dates are the time of the last execution of
+ // chkdsk and disk optimize on the volume.
+ //
+
+ PINBALL_TIME ChkdskDate; // offset = 0x028 40
+ PINBALL_TIME DiskOptimizeDate; // offset = 0x02C 44
+
+ //
+ // The following four fields describe the directory disk buffer pool.
+ // It is a contiguous run on of sectors on the disk set aside for
+ // holding directory disk buffers. PoolSize is the total number of
+ // sectors in the pool. First and Last Sector denote the boundaries
+ // of the pool, and BitMap denotes the start of a small bitmap used to
+ // describe the directory disk buffer pool's current allocation. The
+ // bitmap is 4 contiguous sectors in size, and each bit in the map
+ // corresponds to 1 Directory Disk Buffer (i.e., 4 Sectors worth)
+ //
+
+ ULONG DirDiskBufferPoolSize; // offset = 0x030 48
+ LBN DirDiskBufferPoolFirstSector; // offset = 0x034 52
+ LBN DirDiskBufferPoolLastSector; // offset = 0x038 56
+ LBN DirDiskBufferPoolBitMap; // offset = 0x03C 60
+
+ //
+ // The following field contains the name of the volume
+ //
+
+ UCHAR VolumeName[32]; // offset = 0x040 64
+
+ //
+ // The following field denotes the start of the Small ID (SID) table
+ // which is used to store the Small ID to GUID mappings used on the
+ // volume. The SID table is 8 contiguous sectors in size.
+ //
+
+ LBN SidTable; // offset = 0x060 96
+ UCHAR Unused4[512-100]; // offset = 0x064 100
+
+} SUPER_SECTOR; // sizeof = 0x200 512
+typedef SUPER_SECTOR *PSUPER_SECTOR;
+
+//
+// Super Sector signatures
+//
+
+#define SUPER_SECTOR_SIGNATURE1 (0xf995e849)
+#define SUPER_SECTOR_SIGNATURE2 (0xfa53e9c5)
+
+//
+// Super Sector versions
+//
+
+#define SUPER_SECTOR_VERSION (0x02)
+#define SUPER_SECTOR_FUNC_VERSION (0x02)
+
+typedef struct _SPARE_SECTOR {
+
+ //
+ // The Spare Sector starts with a double signature.
+ //
+
+ SIGNATURE Signature1; // offset = 0x000 0
+ SIGNATURE Signature2; // offset = 0x004 4
+
+ //
+ // The flags field describe how "clean" the volume is.
+ //
+
+ UCHAR Flags; // offset = 0x008 8
+ UCHAR Unused1[3]; // offset = 0x009 9
+
+ //
+ // The following three fields describe the hotfix structure for the
+ // volume. The List field is denotes the disk buffer used to store
+ // the hotfix table. The InUse describes how many hotfixes are
+ // currently being used, and MaxSize is the total number of hotfixes
+ // that can be in use at any one time.
+ //
+
+ LBN HotFixList; // offset = 0x00C 12
+ ULONG HotFixInUse; // offset = 0x010 16
+ ULONG HotFixMaxSize; // offset = 0x014 20
+
+ //
+ // The following two fields describe the "emergency" pool of spare
+ // directory disk buffers. Free describes how many spare directory
+ // disk buffers are currently available for use. MaxSize is the total
+ // number of spare directory disk buffers available. The actual location
+ // of the spare directory disk buffers is denoted in the table at the
+ // end of the spare sector (i.e., field SpareDirDiskBuffer).
+ //
+
+ ULONG SpareDirDiskBufferAvailable; // offset = 0x018 24
+ ULONG SpareDirDiskBufferMaxSize; // offset = 0x01C 28
+
+ //
+ // The following two fields describe the code page information used
+ // on the volume. The InfoSector field is the sector of the beginning
+ // Code Page Information Sector, and the InUse field is the total number
+ // of code pages currently in use on the volume.
+ //
+
+ LBN CodePageInfoSector; // offset = 0x020 32
+ ULONG CodePageInUse; // offset = 0x024 36
+ ULONG Unused2[17]; // offset = 0x028 40
+
+ //
+ // The following field is an array of LBN's for the spare directory
+ // disk buffers that are for "emergency" use.
+ //
+
+ LBN SpareDirDiskBuffer[101]; // offset = 0x06C 108
+
+} SPARE_SECTOR; // sizeof = 0x200 512
+typedef SPARE_SECTOR *PSPARE_SECTOR;
+
+//
+// Spare Sector signatures
+//
+
+#define SPARE_SECTOR_SIGNATURE1 (0xf9911849)
+#define SPARE_SECTOR_SIGNATURE2 (0xfa5229c5)
+
+
+//
+// The on-disk allocation structure is defined using B-Trees. For every
+// B-Tree block there is an Allocation Header, followed by a list of
+// either Allocation Leafs or Allocation Nodes. This structure will either
+// appear in an FNODE or in an AllocationSector.
+//
+// The allocation header (called Allocation Block in earlier implementations)
+// describes a B-tree block.
+//
+
+typedef struct _ALLOCATION_HEADER {
+
+ //
+ // The following flag describes the state of the B-tree block (e.g.,
+ // indicates if the block is a leaf or an internal node.
+ //
+
+ UCHAR Flags; // offset = 0x000 0
+ UCHAR Unused[3]; // offset = 0x001 1
+
+ //
+ // The following two fields denote the number of free records in the
+ // B-Tree block, and the number of records that are currently in use
+ //
+
+ UCHAR FreeCount; // offset = 0x004 4
+ UCHAR OccupiedCount; // offset = 0x005 5
+
+ //
+ // The next field contains the offset (in bytes) from the beginning
+ // of the allocation header to the first free byte in the B-Tree block
+ //
+
+ USHORT FirstFreeByte; // offset = 0x006 6
+
+} ALLOCATION_HEADER; // sizeof = 0x008 8
+typedef ALLOCATION_HEADER *PALLOCATION_HEADER;
+
+//
+// Allocation header flags
+//
+// NODE - if set this indicates that the B-Tree block contains internal
+// nodes and not leaf entries.
+//
+// BINARY_SEARCH - if set this suggest that a binary search should be used
+// to search the B-Tree block.
+//
+// FNODE_PARENT - if set this indicates that the sector which is the
+// parent of the sector with this header (not this sector), is an
+// FNODE.
+//
+
+#define ALLOCATION_BLOCK_NODE (0x80)
+#define ALLOCATION_BLOCK_BINARY (0x40)
+#define ALLOCATION_BLOCK_FNODE_PARENT (0x20)
+
+//
+// Immediately following an allocation header are one or more allocation nodes
+// of allocation leafs.
+//
+
+typedef struct _ALLOCATION_NODE {
+
+ //
+ // All children of this allocation node will have values less than
+ // the following VBN field.
+ //
+
+ VBN Vbn; // offset = 0x000 0
+
+ //
+ // This is the LBN of the allocation sector refered to by this node
+ //
+
+ LBN Lbn; // offset = 0x004 4
+
+} ALLOCATION_NODE; // sizeof = 0x008 8
+typedef ALLOCATION_NODE *PALLOCATION_NODE;
+
+typedef struct _ALLOCATION_LEAF {
+
+ //
+ // The following field has the starting VBN for this run
+ //
+
+ VBN Vbn; // offset = 0x000 0
+
+ //
+ // This is the length of the run in sectors
+ //
+
+ ULONG Length; // offset = 0x004 4
+
+ //
+ // This is the starting LBN of the run
+ //
+
+ LBN Lbn; // offset = 0x008 8
+
+} ALLOCATION_LEAF; // sizeof = 0x00C 12
+typedef ALLOCATION_LEAF *PALLOCATION_LEAF;
+
+//
+// An allocation sector is an on-disk structure that contains allocation
+// information. It contains some bookkeeping information, an allocation
+// header and then an array of either allocation leafs or allocation nodes.
+//
+// AllocationSector
+// +-------------------+
+// | bookkeeping |
+// +- - - - - - - - - -+
+// | Allocation Header |
+// +- - - - - - - - - -+
+// | Allocation Leafs |
+// | or |
+// | Allocation Nodes |
+// +-------------------+
+//
+// where the number of allocation leafs that can be stored in a sector is
+// 40 and the number of nodes is 60.
+//
+
+#define ALLOCATION_NODES_PER_SECTOR (60)
+#define ALLOCATION_LEAFS_PER_SECTOR (40)
+
+typedef struct _ALLOCATION_SECTOR {
+
+ //
+ // The allocation sector starts off with a signature field
+ //
+
+ SIGNATURE Signature; // offset = 0x000 0
+
+ //
+ // This following two fields contains the LBN of this allocation
+ // sector itself, and the LBN of the parent of this sector (the
+ // parent is either an FNODE or another allocation sector)
+ //
+
+ LBN Lbn; // offset = 0x004 4
+ LBN ParentLbn; // offset = 0x008 8
+
+ //
+ // The allocation header for the sector
+ //
+
+ ALLOCATION_HEADER AllocationHeader; // offset = 0x00C 12
+
+ //
+ // The remainder of the sector is either an array of allocation leafs
+ // of allocation nodes
+ //
+
+ union { // offset = 0x014 20
+ ALLOCATION_NODE Node[ ALLOCATION_NODES_PER_SECTOR ];
+ ALLOCATION_LEAF Leaf[ ALLOCATION_LEAFS_PER_SECTOR ];
+ } Allocation;
+
+ UCHAR Unused[12]; // offset = 0x1F4 500
+
+} ALLOCATION_SECTOR; // sizeof = 0x200 512
+typedef ALLOCATION_SECTOR *PALLOCATION_SECTOR;
+
+//
+// The allocation sector signature
+//
+
+#define ALLOCATION_SECTOR_SIGNATURE (0x37e40aae)
+
+//
+// The on-disk FNODE structure is used to describe both files and directories
+// It contains some fixed data information, the EA and ACL lookup information,
+// allocation information and then a free space for storing some EAs and
+// ACLs that fit in the sector
+//
+
+#define ALLOCATION_NODES_PER_FNODE (12)
+#define ALLOCATION_LEAFS_PER_FNODE (8)
+
+typedef struct _FNODE_SECTOR {
+
+ //
+ // The sector starts with a signature field
+ //
+
+ SIGNATURE Signature; // offset = 0x000 0
+
+ //
+ // The following fields was for history tracking, but in NT Pinball
+ // doesn't need this information.
+ //
+
+ ULONG Unused1[2]; // offset = 0x004 4
+
+ //
+ // The following two fields contain the file name length, and the first
+ // 15 bytes of the filename, as stored in the dirent that references
+ // this fnode. For the root directory theses values are all zeros.
+ //
+
+ UCHAR FileNameLength; // offset = 0x00C 12
+ UCHAR FileName[15]; // offset = 0x00D 13
+
+ //
+ // The following field denotes the parent directory's FNODE
+ //
+
+ LBN ParentFnode; // offset = 0x01C 28
+
+ //
+ // The following four fields describe the ACL for the file/directory.
+ //
+ // AclDiskAllocationLength holds the number of bytes in the ACL that
+ // are stored outside of this FNODE. If this value is not zero
+ // then AclFnodeLength must be equal to zero.
+ //
+ // AclLbn points to the first sector of the data run or the allocation
+ // sector containing describing the ACL. AclFlags indicates if
+ // it is a data run or an allocation sector. AclLbn is only used
+ // if AclDiskAllocationLength is not zero.
+ //
+ // AclFnodeLength holds the number of bytes in the ACL that are
+ // stored within this FNODE. If value is not zero then
+ // AclDiskAllocationLength must be equal to zero. The ACL, if stored
+ // in the FNODE, is located at AclEaFnodeBuffer in this FNODE sector.
+ //
+ // AclFlags if the data is outside the FNODE this flag indicates whether
+ // ACL is stored in a single data run (AclFlags == 0) or via an
+ // allocation sector (AclFlags != 0). AclFlags is only used if
+ // AclDiskAllocationLength is not zero.
+ //
+
+ ULONG AclDiskAllocationLength; // offset = 0x020 32
+ LBN AclLbn; // offset = 0x024 36
+ USHORT AclFnodeLength; // offset = 0x028 40
+ UCHAR AclFlags; // offset = 0x02A 42
+
+ //
+ // The following field was used for the number of valid history
+ // bits but we don't need this field of NT Pinball
+ //
+
+ UCHAR Unused2; // offset = 0x02B 43
+
+ //
+ // The following four fields describe the EA for the file/directory.
+ //
+ // EaDiskAllocationLength holds the number of bytes in the EA that
+ // are stored outside of this FNODE. If this value is not zero
+ // then EaFnodeLength must be equal to zero.
+ //
+ // EaLbn points to the first sector of the data run or the allocation
+ // sector containing describing the EA. EaFlags indicates if
+ // it is a data run or an allocation sector. EaLbn is only used
+ // if EaDiskAllocationLength is not zero.
+ //
+ // EaFnodeLength holds the number of bytes in the EA that are
+ // stored within this FNODE. If value is not zero then
+ // EaDiskAllocationLength must be equal to zero. The EA, if stored
+ // in the FNODE, is located immediately after the ACL stored in the
+ // AclEaFnodeBuffer.
+ //
+ // EaFlags if the data is outside the FNODE this flag indicates whether
+ // EA is stored in a single data run (EaFlags == 0) or via an
+ // allocation sector (EaFlags != 0). EaFlags is only used if
+ // EaDiskAllocationLength is not zero.
+ //
+
+ ULONG EaDiskAllocationLength; // offset = 0x02C 44
+ LBN EaLbn; // offset = 0x030 48
+ USHORT EaFnodeLength; // offset = 0x034 52
+ UCHAR EaFlags; // offset = 0x036 54
+
+ //
+ // The following byte contains the FNODE flags
+ //
+
+ UCHAR Flags; // offset = 0x037 55
+
+ //
+ // The following two fields describe the top level allocation for
+ // this file/directory
+ //
+
+ ALLOCATION_HEADER AllocationHeader; // offset = 0x038 56
+
+ union { // offset = 0x040 64
+ ALLOCATION_NODE Node[ ALLOCATION_NODES_PER_FNODE ];
+ ALLOCATION_LEAF Leaf[ ALLOCATION_LEAFS_PER_FNODE ];
+ } Allocation;
+
+ //
+ // The following field contains the valid length of the file. The size
+ // of the file is stored in the dirent. The difference between these two
+ // values is that the file size is the actual size allocated and visible
+ // to the user. The Valid length is the number of bytes that have
+ // had their data zeroed out or modified. (i.e., if a read request
+ // is greater than valid length but less than file size then the file
+ // system must first zero out the data in the file up to and including
+ // data being read.
+ //
+
+ ULONG ValidDataLength; // offset = 0x0A0 160
+
+ //
+ // The following field contains the number of EAs in this file that have
+ // the need ea attribute set.
+ //
+
+ ULONG NeedEaCount; // offset = 0x0A4 164
+ UCHAR Unused3[16]; // offset = 0x0A8 168
+
+ //
+ // The following field contains the offset, in bytes, from the start of
+ // FNODE to the first ACE stored in the FNODE
+ //
+
+ USHORT AclBase; // offset = 0x0B8 184
+ UCHAR Unused4[10]; // offset = 0x0BA 186
+
+ //
+ // The following buffer is used to store acl/ea in the FNODE
+ //
+
+ UCHAR AclEaFnodeBuffer[316]; // offset = 0x0C4 196
+
+} FNODE_SECTOR; // sizeof = 0x200 512
+typedef FNODE_SECTOR *PFNODE_SECTOR;
+
+//
+// The FNODE Sector signature
+//
+
+#define FNODE_SECTOR_SIGNATURE (0xf7e40aae)
+
+//
+// The on-disk directory disk buffer is used to contain directory entries.
+// It contains a fixed header followed by a collection of one or more
+// dirents. Dirents are variable so size we cannot use a simply C struct
+// declartion for the entire disk buffer.
+//
+
+typedef struct _DIRECTORY_DISK_BUFFER {
+
+ //
+ // The disk buffer starts with a signature field
+ //
+
+ SIGNATURE Signature; // offset = 0x000 0
+
+ //
+ // The following field is the offset to the first free byte in this
+ // disk buffer
+ //
+
+ ULONG FirstFree; // offset = 0x004 4
+
+ //
+ // The following field is a change count that is kept around for
+ // bookkeeping purposes. It is incremented whenever we move any
+ // of the entries in this disk buffer. This means for any file if we
+ // remember its offset and its change count we will be able to quickly
+ // locate the dirent again without needing to search from the top
+ // of the directory again. (i.e., only if the remembered change count
+ // and the current change count match). For this to work the file system
+ // in memory will need to keep track of whenever it removes a Directory
+ // Disk Buffer from a directory, and have each saved dirent location
+ // keep this Directory change count, the Directory Disk Buffer Change
+ // Count, LBN and Offset.
+ //
+ // In addition we overload the bit in this value to indicate if this
+ // is the topmost directory disk buffer for the directory (low order bit
+ // = 1) or if it is a lower lever buffer (low order bit = 0).
+ //
+
+ ULONG ChangeCount; // offset = 0x008 8
+
+ //
+ // The following field contains the LBN of either the parent
+ // directory disk buffer containing this disk buffer or the FNODE.
+ // It is the FNODE if this is a topmost disk buffer and a parent
+ // directory disk buffer otherwise.
+ //
+
+ LBN Parent; // offset = 0x00C 12
+
+ //
+ // The following field is the LBN of the sector containing the
+ // start of this disk buffer
+ //
+
+ LBN Sector; // offset = 0x010 16
+
+ //
+ // This following buffer contains the dirents stored in this disk buffer
+ //
+
+ UCHAR Dirents[2028]; // offset = 0x014 20
+
+} DIRECTORY_DISK_BUFFER; // sizeof = 0x800 2048
+typedef DIRECTORY_DISK_BUFFER *PDIRECTORY_DISK_BUFFER;
+
+//
+// Size of Directory Disk Buffer in sectors.
+//
+
+#define DIRECTORY_DISK_BUFFER_SECTORS (4)
+
+//
+// Directory Disk Buffer Signature
+//
+
+#define DIRECTORY_DISK_BUFFER_SIGNATURE (0x77e40aae)
+
+typedef struct _PBDIRENT {
+
+ USHORT DirentSize; // offset = 0x000 0
+ UCHAR Flags; // offset = 0x002 2
+ UCHAR FatFlags; // offset = 0x003 3
+
+ LBN Fnode; // offset = 0x004 4
+
+ PINBALL_TIME LastModificationTime; // offset = 0x008 8
+
+ ULONG FileSize; // offset = 0x00C 12
+
+ PINBALL_TIME LastAccessTime; // offset = 0x010 16
+
+ PINBALL_TIME FnodeCreationTime; // offset = 0x014 20
+
+ ULONG EaLength; // offset = 0x018 24
+
+ UCHAR ResidentAceCount; // offset = 0x01C 28
+ UCHAR CodePageIndex; // offset = 0x01D 29
+ UCHAR FileNameLength; // offset = 0x01E 30
+ UCHAR FileName[1]; // offset = 0x01F 31
+
+} PBDIRENT; // sizeof = 0x020 32
+typedef PBDIRENT *PPBDIRENT;
+
+//
+// Define sizes of .. and End PBDIRENT.
+//
+
+#define SIZEOF_DIR_DOTDOT (sizeof(PBDIRENT) + sizeof(LONG))
+#define SIZEOF_DIR_END (sizeof(PBDIRENT))
+#define SIZEOF_DIR_MAXPBDIRENT (sizeof(PBDIRENT) + 256 + \
+ (3*sizeof(PINBALL_ACE)) + sizeof(LBN))
+
+#define DIRENT_FIRST_ENTRY (0x0001)
+#define DIRENT_ACL (0x0002)
+#define DIRENT_BTREE_POINTER (0x0004)
+#define DIRENT_END (0x0008)
+#define DIRENT_EXPLICIT_ACL (0x0040)
+#define DIRENT_NEED_EA (0x0080)
+#define DIRENT_NEW_NAMING_RULES (0x4000)
+//
+// The following macros are used to help locate dirents within a Directory
+// Disk Buffer. GetFirstDirent returns a pointer to the first dirent entry
+// in the directory disk buffer. GetNextDirent returns a pointer to the
+// next dirent entry in a directory disk buffer, without checking for the
+// end of the Directory Disk Buffer.
+//
+// PDIRENT
+// GetFirstDirent (
+// IN PDIRECTORY_DISK_BUFFER DirectoryDiskBuffer
+// );
+//
+// PDIRENT
+// GetNextDirent (
+// IN PDIRENT Dirent
+// );
+//
+
+#define GetFirstDirent(DIR) ( \
+ (PDIRENT)&(DIR)->Dirents[0] \
+)
+
+//
+// This macro blindly returns a pointer to the next Dirent, without checking
+// for the end of the Directory Disk Buffer, i.e., callers must always check
+// for the End record in the Directory Disk Buffer. If GetNextDirent is
+// called with the End record as input, it will return the next free byte
+// in the buffer.
+//
+
+#define GetNextDirent(ENT) ( \
+ (PDIRENT)((PUCHAR)(ENT)+(ENT)->DirentSize) \
+)
+//
+// The following macros are used to help retrieve the variable fields
+// within a dirent. GetAceInDirent returns a pointer to the ACE within
+// the dirent corresponding to the supplied index, or NULL if there isn't
+// a corresponding ACE. GetBtreePointerInDirent returns the LBN field of
+// the down B-tree pointer stored in the dirent, or it returns a value of
+// zero if there isn't a down pointer. SetBtreePointerInDirent sets the
+// LBN downpointer field.
+//
+// PPINBALL_ACE
+// GetAceInDirent (
+// IN PDIRENT Dirent,
+// IN ULONG Index // (0, 1, or 2)
+// );
+//
+// LBN
+// GetBtreePointerInDirent (
+// IN PDIRENT Dirent
+// );
+//
+// VOID
+// SetBtreePointerInDirent (
+// IN OUT PDIRENT Dirent,
+// IN LBN Blbn
+// );
+//
+//
+//
+// To return a pointer to an ACE in a dirent we need to check to see if the
+// index is within the resident ace count. The first ace is the address of
+// the first longword after the filename, the second ace is the second long
+// word.
+//
+
+#define GetAceInDirent(ENT,I) ( \
+ ((I) >= 0 && (I) < (ENT)->ResidentAceCount ? \
+ (PPINBALL_ACE)( \
+ (LONG)LongAlign((ENT)->FileName[(ENT)->FileNameLength]) + \
+ (I)*sizeof(PINBALL_ACE) \
+ ) \
+ : \
+ NULL \
+ ) \
+)
+
+//
+// To return the Btree pointer we need to first check to see if there
+// is Btree pointer field, otherwise we return NULL. The field, if present,
+// is located 4 bytes back from the end of the dirent.
+//
+
+#define GetBtreePointerInDirent(ENT) ( \
+ (FlagOn((ENT)->Flags,DIRENT_BTREE_POINTER) ? \
+ *(PLBN)(((PUCHAR)(ENT)) + (ENT)->DirentSize - sizeof(LBN)) \
+ : \
+ 0 \
+ ) \
+)
+
+//
+// To set the Btree pointer we assume there is a Btree pointer field.
+// The field is located 4 bytes back from the end of the dirent.
+//
+
+#define SetBtreePointerInDirent(ENT,BLBN) ( \
+ *(PLBN)(((PUCHAR)(ENT)) + (ENT)->DirentSize - sizeof(LBN)) = (BLBN) \
+)
+
+//
+// Define file I/O prototypes.
+//
+
+ARC_STATUS
+HpfsClose (
+ IN ULONG FileId
+ );
+
+ARC_STATUS
+HpfsOpen (
+ IN PCHAR OpenPath,
+ IN OPEN_MODE OpenMode,
+ OUT PULONG FileId
+ );
+
+ARC_STATUS
+HpfsRead (
+ IN ULONG FileId,
+ OUT PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+HpfsSeek (
+ IN ULONG FileId,
+ IN PLARGE_INTEGER Offset,
+ IN SEEK_MODE SeekMode
+ );
+
+ARC_STATUS
+HpfsWrite (
+ IN ULONG FileId,
+ IN PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+HpfsGetFileInformation (
+ IN ULONG FileId,
+ OUT PFILE_INFORMATION Buffer
+ );
+
+ARC_STATUS
+HpfsSetFileInformation (
+ IN ULONG FileId,
+ IN ULONG AttributeFlags,
+ IN ULONG AttributeMask
+ );
+
+ARC_STATUS
+HpfsInitialize(
+ VOID
+ );
+
+#endif // _HPFSBOOT_
diff --git a/private/ntos/boot/inc/ntfsboot.h b/private/ntos/boot/inc/ntfsboot.h
new file mode 100644
index 000000000..a79f09548
--- /dev/null
+++ b/private/ntos/boot/inc/ntfsboot.h
@@ -0,0 +1,204 @@
+/*++
+
+Copyright (c) 1991 Microsoft Corporation
+
+Module Name:
+
+ NtfsBoot.h
+
+Abstract:
+
+ This module defines globally used procedure and data structures used by Ntfs boot.
+
+Author:
+
+ Gary Kimura [GaryKi] 10-Apr-1992
+
+Revision History:
+
+--*/
+
+#ifndef _NTFSBOOT_
+#define _NTFSBOOT_
+
+
+//
+// Some important manifest constants. These are the maximum byte size we'll ever
+// see for a file record or an index allocation buffer.
+//
+
+#define MAXIMUM_FILE_RECORD_SIZE (4096)
+
+#define MAXIMUM_INDEX_ALLOCATION_SIZE (4096)
+
+#define MAXIMUM_COMPRESSION_UNIT_SIZE (65536)
+
+//
+// The following structure is an mcb structure for storing cached retrieval pointer
+// information.
+//
+
+#define MAXIMUM_NUMBER_OF_MCB_ENTRIES (16)
+
+typedef struct _NTFS_MCB {
+
+ //
+ // The following fields indicate the number of entries in use by the mcb. and
+ // the mcb itself. The mcb is just a collection of vbo - lbo pairs. The last
+ // InUse entry Lbo's value is ignored, because it is only used to give the
+ // length of the previous run.
+ //
+
+ ULONG InUse;
+
+ LONGLONG Vbo[ MAXIMUM_NUMBER_OF_MCB_ENTRIES ];
+ LONGLONG Lbo[ MAXIMUM_NUMBER_OF_MCB_ENTRIES ];
+
+} NTFS_MCB, *PNTFS_MCB;
+
+//
+// Define the Ntfs file context structure and the attribute context structure.
+//
+
+typedef struct _NTFS_FILE_CONTEXT {
+
+ //
+ // The following field indicates the type of attribute opened
+ //
+
+ ULONG TypeCode;
+
+ //
+ // The following field indicates the size of the data portion of the attribute
+ //
+
+ LONGLONG DataSize;
+
+ //
+ // The following two fields identify and locate the attribute on the volume.
+ // The first number is the file record where the attribute header is located and
+ // the second number is the offset in the file record of the attribute header
+ //
+
+ LONGLONG FileRecord;
+ USHORT FileRecordOffset;
+
+ //
+ // The following field indicates if the attribute is resident
+ //
+
+ BOOLEAN IsAttributeResident;
+
+ //
+ // The following fields are only used if the data stream is compressed.
+ // If it is compressed then the CompressionFormat field is not zero, and
+ // contains the value to pass to the decompression engine. CompressionUnit
+ // is the number of bytes in each unit of compression.
+ //
+
+ USHORT CompressionFormat;
+ ULONG CompressionUnit;
+
+} NTFS_FILE_CONTEXT, *PNTFS_FILE_CONTEXT;
+typedef NTFS_FILE_CONTEXT NTFS_ATTRIBUTE_CONTEXT, *PNTFS_ATTRIBUTE_CONTEXT;
+
+//
+// Define the Ntfs volume structure context
+//
+
+typedef struct _NTFS_STRUCTURE_CONTEXT {
+
+ //
+ // This is the device that we talk to
+ //
+
+ ULONG DeviceId;
+
+ //
+ // Some volume specific constants that describe the size of various records
+ //
+
+ ULONG BytesPerCluster;
+ ULONG BytesPerFileRecord;
+
+ //
+ // The following three fields describe the $DATA stream for the the MFT. We
+ // need two Mcbs one holds the base of the mft and the other to hold any excess
+ // retrival information. I.e., we must not loose the base mcb otherwise we
+ // can't find anything.
+ //
+
+ NTFS_ATTRIBUTE_CONTEXT MftAttributeContext;
+ NTFS_MCB MftBaseMcb;
+
+ //
+ // The following three fields hold a cached mcb that we use for non-resident
+ // attributes other than the mft data stream. The first two fields identify the
+ // attribute and the third field contains the cached mcb.
+ //
+
+ LONGLONG CachedMcbFileRecord[16];
+ USHORT CachedMcbFileRecordOffset[16];
+ NTFS_MCB CachedMcb[16];
+
+} NTFS_STRUCTURE_CONTEXT, *PNTFS_STRUCTURE_CONTEXT;
+
+
+//
+// Define file I/O prototypes.
+//
+
+ARC_STATUS
+NtfsClose (
+ IN ULONG FileId
+ );
+
+ARC_STATUS
+NtfsOpen (
+ IN PCHAR OpenPath,
+ IN OPEN_MODE OpenMode,
+ OUT PULONG FileId
+ );
+
+ARC_STATUS
+NtfsRead (
+ IN ULONG FileId,
+ OUT PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+NtfsSeek (
+ IN ULONG FileId,
+ IN PLARGE_INTEGER Offset,
+ IN SEEK_MODE SeekMode
+ );
+
+ARC_STATUS
+NtfsWrite (
+ IN ULONG FileId,
+ IN PVOID Buffer,
+ IN ULONG Length,
+ OUT PULONG Count
+ );
+
+ARC_STATUS
+NtfsGetFileInformation (
+ IN ULONG FileId,
+ OUT PFILE_INFORMATION Buffer
+ );
+
+ARC_STATUS
+NtfsSetFileInformation (
+ IN ULONG FileId,
+ IN ULONG AttributeFlags,
+ IN ULONG AttributeMask
+ );
+
+ARC_STATUS
+NtfsInitialize(
+ VOID
+ );
+
+#endif // _NTFSBOOT_
diff --git a/private/ntos/boot/inc/scsiboot.h b/private/ntos/boot/inc/scsiboot.h
new file mode 100644
index 000000000..9fdc9b412
--- /dev/null
+++ b/private/ntos/boot/inc/scsiboot.h
@@ -0,0 +1,500 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ scsiboot.h
+
+Abstract:
+
+ This file defines the necessary structures, defines, and functions for
+ the common SCSI boot port driver.
+
+Author:
+
+ Jeff Havens (jhavens) 28-Feb-1991
+ Mike Glass
+
+Revision History:
+
+--*/
+
+#include "ntddscsi.h"
+
+//
+// SCSI Get Configuration Information
+//
+// LUN Information
+//
+
+typedef struct _LUNINFO {
+ UCHAR PathId;
+ UCHAR TargetId;
+ UCHAR Lun;
+ BOOLEAN DeviceClaimed;
+ PVOID DeviceObject;
+ struct _LUNINFO *NextLunInfo;
+ UCHAR InquiryData[INQUIRYDATABUFFERSIZE];
+} LUNINFO, *PLUNINFO;
+
+typedef struct _SCSI_BUS_SCAN_DATA {
+ USHORT Length;
+ UCHAR InitiatorBusId;
+ UCHAR NumberOfLogicalUnits;
+ PLUNINFO LunInfoList;
+} SCSI_BUS_SCAN_DATA, *PSCSI_BUS_SCAN_DATA;
+
+typedef struct _SCSI_CONFIGURATION_INFO {
+ UCHAR NumberOfBuses;
+ PSCSI_BUS_SCAN_DATA BusScanData[1];
+} SCSI_CONFIGURATION_INFO, *PSCSI_CONFIGURATION_INFO;
+
+#define MAXIMUM_RETRIES 4
+
+//
+// SCSI device timeout values in seconds
+//
+
+#define SCSI_DISK_TIMEOUT 10
+#define SCSI_CDROM_TIMEOUT 10
+#define SCSI_TAPE_TIMEOUT 120
+
+//
+// Adapter object transfer information.
+//
+
+typedef struct _ADAPTER_TRANSFER {
+ PSCSI_REQUEST_BLOCK Srb;
+ PVOID LogicalAddress;
+ ULONG Length;
+}ADAPTER_TRANSFER, *PADAPTER_TRANSFER;
+
+typedef struct _SRB_SCATTER_GATHER {
+ ULONG PhysicalAddress;
+ ULONG Length;
+}SRB_SCATTER_GATHER, *PSRB_SCATTER_GATHER;
+
+//
+// Srb Structure plus extra storage for the port driver.
+//
+
+#define IRP_STACK_SIZE 2
+
+typedef struct _FULL_SCSI_REQUEST_BLOCK {
+ SCSI_REQUEST_BLOCK Srb;
+ PVOID PreviousIrp;
+ IRP Irp;
+ IO_STACK_LOCATION IrpStack[IRP_STACK_SIZE];
+ ULONG SrbExtensionSize;
+ MDL Mdl;
+ ULONG PageFrame[20];
+}FULL_SCSI_REQUEST_BLOCK, *PFULL_SCSI_REQUEST_BLOCK;
+
+//
+// Logical unit extension
+//
+
+typedef struct _LOGICAL_UNIT_EXTENSION {
+ UCHAR PathId;
+ UCHAR TargetId;
+ UCHAR Lun;
+ ULONG Flags;
+ PIRP CurrentRequest;
+ KSPIN_LOCK CurrentRequestSpinLock;
+ PVOID SpecificLuExtension;
+ struct _LOGICAL_UNIT_EXTENSION *NextLogicalUnit;
+ KDEVICE_QUEUE RequestQueue;
+ KSPIN_LOCK RequestQueueSpinLock;
+ LONG RequestTimeoutCounter;
+ ULONG RetryCount;
+ UCHAR NumberOfLogicalUnits;
+ PVOID MapRegisterBase;
+ ULONG NumberOfMapRegisters;
+ SRB_SCATTER_GATHER ScatterGather[17];
+} LOGICAL_UNIT_EXTENSION, *PLOGICAL_UNIT_EXTENSION;
+
+//
+// Device extension
+//
+
+typedef struct _DEVICE_EXTENSION {
+
+ PDEVICE_OBJECT DeviceObject;
+
+ //
+ // Dma Adapter information.
+ //
+
+ PVOID MapRegisterBase;
+ PADAPTER_OBJECT DmaAdapterObject;
+ ADAPTER_TRANSFER FlushAdapterParameters;
+
+ //
+ // Number of SCSI buses
+ //
+
+ UCHAR NumberOfBuses;
+
+ //
+ // Maximum targets per bus
+ //
+
+ UCHAR MaximumTargetIds;
+
+ //
+ // SCSI Capabilities structure
+ //
+
+ IO_SCSI_CAPABILITIES Capabilities;
+
+ //
+ // SCSI port driver flags
+ //
+
+ ULONG Flags;
+
+ //
+ // SCSI port interrupt flags
+ //
+
+ ULONG InterruptFlags;
+
+ //
+ // List head for singlely linked list of complete IRPs.
+ //
+
+ PIRP CompletedRequests;
+
+ //
+ // Adapter object transfer parameters.
+ //
+
+ ADAPTER_TRANSFER MapTransferParameters;
+
+ KSPIN_LOCK SpinLock;
+
+ //
+ // Miniport Initialization Routine
+ //
+
+ PHW_INITIALIZE HwInitialize;
+
+ //
+ // Miniport Start IO Routine
+ //
+
+ PHW_STARTIO HwStartIo;
+
+ //
+ // Miniport Interrupt Service Routine
+ //
+
+ PHW_INTERRUPT HwInterrupt;
+
+ //
+ // Miniport Reset Routine
+ //
+
+ PHW_RESET_BUS HwReset;
+
+ //
+ // Miniport DMA started Routine
+ //
+
+ PHW_DMA_STARTED HwDmaStarted;
+
+ //
+ // Buffers must be mapped into system space.
+ //
+
+ BOOLEAN MapBuffers;
+
+ //
+ // Is this device a bus master and does it require map registers.
+ //
+
+ BOOLEAN MasterWithAdapter;
+ //
+ // Device extension for miniport routines.
+ //
+
+ PVOID HwDeviceExtension;
+
+ //
+ // Miniport request interrupt enabled/disable routine.
+ //
+
+ PHW_INTERRUPT HwRequestInterrupt;
+
+ //
+ // Miniport timer request routine.
+ //
+
+ PHW_INTERRUPT HwTimerRequest;
+
+ //
+ // SCSI configuration information from inquiries.
+ //
+
+ PSCSI_CONFIGURATION_INFO ScsiInfo;
+
+ //
+ // Miniport noncached device extension
+ //
+
+ PVOID NonCachedExtension;
+
+ //
+ // SrbExtension Zone Pool
+ //
+
+ PVOID SrbExtensionZonePool;
+ PCHAR SrbExtensionPointer;
+
+ //
+ // Physical address of zone pool
+ //
+
+ ULONG PhysicalZoneBase;
+
+ //
+ // Size of Srb extension.
+ //
+
+ ULONG SrbExtensionSize;
+
+ //
+ // Spinlock for zoned hash table entries
+ //
+
+ KSPIN_LOCK ZoneSpinLock;
+
+ //
+ // Logical Unit Extension
+ //
+
+ ULONG HwLogicalUnitExtensionSize;
+
+ PLOGICAL_UNIT_EXTENSION LogicalUnitList;
+
+
+ ULONG TimerValue;
+
+ //
+ // Port timing count.
+ //
+
+ LONG PortTimeoutCounter;
+
+} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
+
+#define DEVICE_EXTENSION_SIZE sizeof(DEVICE_EXTENSION)
+
+//
+// Port driver extension flags.
+//
+
+#define PD_CURRENT_IRP_VALID 0X0001
+#define PD_RESET_DETECTED 0X0002
+#define PD_NOTIFICATION_IN_PROGRESS 0X0004
+#define PD_READY_FOR_NEXT_REQUEST 0X0008
+#define PD_FLUSH_ADAPTER_BUFFERS 0X0010
+#define PD_MAP_TRANSFER 0X0020
+#define PD_CALL_DMA_STARTED 0X01000
+#define PD_DISABLE_CALL_REQUEST 0X02000
+#define PD_DISABLE_INTERRUPTS 0X04000
+#define PD_ENABLE_CALL_REQUEST 0X08000
+#define PD_TIMER_CALL_REQUEST 0X10000
+
+//
+// Logical unit extension flags.
+//
+
+#define PD_QUEUE_FROZEN 0X0001
+#define PD_LOGICAL_UNIT_IS_ACTIVE 0X0002
+#define PD_CURRENT_REQUEST_COMPLETE 0X0004
+#define PD_LOGICAL_UNIT_IS_BUSY 0X0008
+
+//
+// The timer interval for the miniport timer routine specified in
+// units of 100 nanoseconds.
+//
+#define PD_TIMER_INTERVAL (250 * 1000 * 10) // 250 ms
+
+#define PD_TIMER_RESET_HOLD_TIME 4
+
+//
+// The define the interloop stall.
+//
+
+#define PD_INTERLOOP_STALL 5
+
+#define MINIMUM_SRB_EXTENSIONS 8
+#define COMPLETION_DELAY 10
+
+//
+// Port driver error logging
+//
+
+#define ERROR_LOG_ENTRY_LENGTH 8
+
+typedef struct _ERROR_LOG_ENTRY {
+ UCHAR PathId;
+ UCHAR TargetId;
+ UCHAR Lun;
+ ULONG ErrorCode;
+ ULONG UniqueId;
+} ERROR_LOG_ENTRY, *PERROR_LOG_ENTRY;
+
+
+//
+// Define global data structures
+//
+
+extern ULONG ScsiPortCount;
+extern FULL_SCSI_REQUEST_BLOCK PrimarySrb;
+extern FULL_SCSI_REQUEST_BLOCK AbortSrb;
+
+#define MAXIMUM_NUMBER_OF_SCSIPORT_OBJECTS 16
+extern PDEVICE_OBJECT ScsiPortDeviceObject[MAXIMUM_NUMBER_OF_SCSIPORT_OBJECTS];
+
+extern PREAD_CAPACITY_DATA ReadCapacityBuffer;
+extern PUCHAR SenseInfoBuffer;
+
+//
+// Support routine.
+//
+
+PIRP
+InitializeIrp(
+ PFULL_SCSI_REQUEST_BLOCK FullSrb,
+ CCHAR MajorFunction,
+ PVOID DeviceObject,
+ PVOID BufferPointer,
+ ULONG BufferSize
+ );
+
+
+ARC_STATUS
+GetAdapterCapabilities(
+ IN PDEVICE_OBJECT PortDeviceObject,
+ OUT PIO_SCSI_CAPABILITIES *PortCapabilities
+ );
+
+ARC_STATUS
+GetInquiryData(
+ IN PDEVICE_OBJECT PortDeviceObject,
+ IN PSCSI_CONFIGURATION_INFO *ConfigInfo
+ );
+
+ARC_STATUS
+ReadDriveCapacity(
+ IN PPARTITION_CONTEXT PartitionContext
+ );
+
+ARC_STATUS
+ScsiClassIoComplete(
+ IN PPARTITION_CONTEXT PartitionContext,
+ IN PIRP Irp,
+ IN PVOID Context
+ );
+
+ARC_STATUS
+SendSrbSynchronous(
+ PPARTITION_CONTEXT PartitionContext,
+ PSCSI_REQUEST_BLOCK Srb,
+ PVOID BufferAddress,
+ ULONG BufferLength,
+ BOOLEAN WriteToDevice
+ );
+
+BOOLEAN
+InterpretSenseInfo(
+ IN PSCSI_REQUEST_BLOCK Srb,
+ OUT ARC_STATUS *Status,
+ PPARTITION_CONTEXT PartitionContext
+ );
+
+VOID
+RetryRequest(
+ PPARTITION_CONTEXT PartitionContext,
+ PIRP Irp
+ );
+
+PIRP
+BuildRequest(
+ IN PPARTITION_CONTEXT PartitionContext,
+ IN PMDL Mdl,
+ IN ULONG LogicalBlockAddress,
+ IN BOOLEAN Operation
+ );
+
+
+//
+// Define the necessary functions to simulate the I/O environment.
+//
+
+#define ExAllocatePool(Type, Size) FwAllocatePool(Size)
+
+#if defined(_MIPS_) || defined(_ALPHA_) || defined(_PPC_)
+#define DbgPrint FwPrint
+#else
+#define DbgPrint BlPrint
+#define PAUSE while (!GET_KEY());
+
+typedef struct _DRIVER_LOOKUP_ENTRY {
+ PCHAR DevicePath;
+ PBL_DEVICE_ENTRY_TABLE DispatchTable;
+} DRIVER_LOOKUP_ENTRY, *PDRIVER_LOOKUP_ENTRY;
+#undef ASSERT
+#define ASSERT( exp ) { \
+ if (!(#exp)) { \
+ BlPrint("ASSERT File: %s line: %lx\n", __FILE__, __LINE__); \
+ PAUSE; \
+ } \
+}
+
+VOID
+ScsiPortExecute(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp
+ );
+
+#endif
+#define ExFreePool(Size)
+#ifdef IoCallDriver
+#undef IoCallDriver
+#endif
+#define IoCallDriver(DeviceObject, Irp) ( \
+ DeviceObject->CurrentIrp = Irp, \
+ Irp->Tail.Overlay.CurrentStackLocation--, \
+ ScsiPortExecute(DeviceObject, Irp), \
+ Irp->Tail.Overlay.CurrentStackLocation++ )
+#ifdef IoCompleteRequest
+#undef IoCompleteRequest
+#endif
+#define IoCompleteRequest(Irp, Boost) Irp->PendingReturned = FALSE
+#define IoAllocateErrorLogEntry(DeviceObject, Length) NULL
+#define IoWriteErrorLogEntry(Entry)
+#ifdef KeAcquireSpinLock
+#undef KeAcquireSpinLock
+#endif
+#define KeAcquireSpinLock(Lock, Irql)
+#ifdef KeReleaseSpinLock
+#undef KeReleaseSpinLock
+#endif
+#define KeReleaseSpinLock(Lock, Irql)
+#define KiAcquireSpinLock(Lock)
+#define KiReleaseSpinLock(Lock)
+#define KeSynchronizeExecution(InterruptObject, ExecutionRoutine, Context) \
+ (ExecutionRoutine)(Context)
+
+#ifdef KeRaiseIrql
+#undef KeRaiseIrql
+#endif
+#define KeRaiseIrql(NewLevel, OldLevel)
+#ifdef KeLowerIrql
+#undef KeLowerIrql
+#endif
+#define KeLowerIrql(Level)