#
# Select the device drivers and filesystems you want
#
-DEVICE_DRIVERS = blue ide keyboard null parallel serial vidport
+DEVICE_DRIVERS = blue ide keyboard null parallel serial vidport floppy
# DEVICE_DRIVERS = beep event floppy ide_test mouse sound test test1
FS_DRIVERS = vfat minix
# FS_DRIVERS = minix ext2 template
.PHONY: clean
-floppy: make_floppy_dirs autoexec_floppy $(COMPONENTS:%=%_floppy) \
+install_floppy: make_floppy_dirs autoexec_floppy $(COMPONENTS:%=%_floppy) \
$(DLLS:%=%_floppy) $(LOADERS:%=%_floppy) \
$(KERNEL_SERVICES:%=%_floppy) $(SUBSYS:%=%_floppy) \
$(APPS:%=%_floppy)
-//
-// FLOPPY.C - NEC-765/8272A floppy device driver
-// written by Rex Jolliff
-// with help from various other sources, including but not limited to:
-// Art Baker's NT Device Driver Book, Linux Source, and the internet.
-//
-// Modification History:
-// 08/19/98 RJJ Created.
-//
-// To do:
-// FIXME: get it working
-// FIXME: add support for DMA hardware
-// FIXME: should add support for floppy tape/zip devices
+/*
+ * FLOPPY.C - NEC-765/8272A floppy device driver
+ * written by Rex Jolliff
+ * with help from various other sources, including but not limited to:
+ * Art Baker's NT Device Driver Book, Linux Source, and the internet.
+ *
+ * Modification History:
+ * 08/19/98 RJJ Created.
+ *
+ * To do:
+ * FIXME: get it working
+ * FIXME: add support for DMA hardware
+ * FIXME: should add support for floppy tape/zip devices
+ */
#include <ddk/ntddk.h>
+#include "../../../ntoskrnl/include/internal/i386/io.h"
#include "floppy.h"
+#include <debug.h>
+
#define VERSION "V0.0.1"
-// --------------------------------------------------- File Statics
+/* --------------------------------------------------- File Statics */
+
+/* from linux drivers/block/floppy.c */
+#define FLOPPY_MAX_REPLIES (16)
+
+typedef struct _FLOPPY_DEVICE_EXTENSION
+{
+} FLOPPY_DEVICE_EXTENSION, *PFLOPPY_DEVICE_EXTENSION;
-typedef struct _FLOPPY_CONTROLLER_PARAMETERS
+typedef struct _FLOPPY_CONTROLLER_EXTENSION
{
- int PortBase;
- int Vector;
- int IrqL;
- int SynchronizeIrqL;
+ PKINTERRUPT Interrupt;
+ KSPIN_LOCK SpinLock;
+ FLOPPY_CONTROLLER_TYPE FDCType;
+ ULONG Number;
+ ULONG PortBase;
+ ULONG Vector;
+} FLOPPY_CONTROLLER_EXTENSION, *PFLOPPY_CONTROLLER_EXTENSION;
+
+typedef struct _FLOPPY_CONTROLLER_PARAMETERS
+{
+ ULONG PortBase;
+ ULONG Vector;
+ ULONG IrqL;
+ ULONG SynchronizeIrqL;
KINTERRUPT_MODE InterruptMode;
KAFFINITY Affinity;
} FLOPPY_CONTROLLER_PARAMETERS, *PFLOPPY_CONTROLLER_PARAMETERS;
static BOOLEAN FloppyInitialized = FALSE;
-// ------------------------------------------------------ Functions
-
-// ModuleEntry
-//
-// DESCRIPTION:
-// This function initializes the driver, locates and claims
-// hardware resources, and creates various NT objects needed
-// to process I/O requests.
-//
-// RUN LEVEL:
-// PASSIVE_LEVEL
-//
-// ARGUMENTS:
-// IN PDRIVER_OBJECT DriverObject System allocated Driver Object
-// for this driver
-// IN PUNICODE_STRING RegistryPath Name of registry driver service
-// key
-//
-// RETURNS:
-// NTSTATUS
-
-NTSTATUS
-DriverEntry(IN PDRIVER_OBJECT DriverObject,
- IN PUNICODE_STRING RegistryPath)
+/* Bits of main status register */
+#define STATUS_BUSYMASK (0x0f)
+#define STATUS_BUSY (0x10)
+#define STATUS_DMA (0x20)
+#define STATUS_DIR (0x40)
+#define STATUS_READY (0x80)
+
+#define FLOPPY_STATUS (4)
+#define FLOPPY_DATA (5)
+
+#define FLOPPY_CMD_UNLK_FIFO 0x14
+#define FLOPPY_CMD_LOCK_FIFO 0x94
+
+/* ------------------------------------------------------ Functions */
+
+static int
+FloppyReadSTAT(ULONG PortBase)
+{
+ return(inb_p(PortBase + FLOPPY_STATUS));
+}
+
+/* waits until the fdc becomes ready */
+static int
+FloppyWaitUntilReady(WORD PortBase)
{
- NTSTATUS RC;
- PFLOPPY_DEVICE_EXTENSION DeviceExtension;
-
- // Export other driver entry points...
- DriverObject->DriverStartIo = FloppyStartIo;
- DriverObject->MajorFunction[IRP_MJ_CREATE] = FloppyDispatchOpenClose;
- DriverObject->MajorFunction[IRP_MJ_CLOSE] = FloppyDispatchOpenClose;
- DriverObject->MajorFunction[IRP_MJ_READ] = FloppyDispatchReadWrite;
- DriverObject->MajorFunction[IRP_MJ_WRITE] = FloppyDispatchReadWrite;
- DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FloppyDispatchDeviceControl;
-
- // Try to detect controller and abort if it fails
- if (!FloppyCreateController(DriverObject,
- &ControllerParameters[0],
- 0))
+ int Retries;
+ int Status;
+
+ for (Retries = 0; Retries < FLOPPY_MAX_STAT_RETRIES; Retries++)
+ {
+ Status = FloppyReadSTAT(PortBase);
+ if (Status & STATUS_READY)
+ {
+ return Status;
+ }
+ }
+
+ if (FloppyInitialized)
{
- DPRINT("Could not find floppy controller");
- return STATUS_NO_SUCH_DEVICE;
+ DPRINT("Getstatus times out (%x) on fdc %d\n",
+ Status,
+ PortBase);
}
- return STATUS_SUCCESS;
+ return -1;
}
-static BOOLEAN
-FloppyCreateController(PDRIVER_OBJECT DriverObject,
- PFLOPPY_CONTROLLER_PARAMETERS ControllerParameters,
- int Index)
+static VOID
+FloppyWriteData(WORD PortBase, BYTE Byte)
+{
+ outb_p(PortBase + FLOPPY_DATA, Byte);
+}
+
+/* sends a command byte to the fdc */
+static BOOLEAN
+FloppyWriteCommandByte(WORD PortBase, BYTE Byte)
{
- PFLOPPY_CONTROLLER_TYPE ControllerType;
- PCONTROLLER_OBJECT ControllerObject;
- PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
+ int Status;
- /* Detect controller and determine type */
- if (!FloppyGetControllerVersion(ControllerParameters, &ControllerType))
+ if ((Status = FloppyWaitUntilReady(PortBase)) < 0)
{
return FALSE;
}
- // FIXME: Register port ranges and interrupts with HAL
+ if ((Status & (STATUS_READY|STATUS_DIR|STATUS_DMA)) == STATUS_READY)
+ {
+ FloppyWriteData(PortBase, Byte);
+ return 0;
+ }
- /* Create controller object for FDC */
- ControllerObject = IoCreateController(sizeof(FLOPPY_CONTROLLER_EXTENSION));
- if (ControllerObject == NULL)
+ if (FloppyInitialized)
{
- DPRINT("Could not create controller object for controller %d\n",
- Index);
- return FALSE;
+ DPRINT("Unable to send byte %x to FDC. Fdc=%x Status=%x\n",
+ Byte,
+ PortBase,
+ Status);
+ }
+
+ return FALSE;
+}
+
+/* gets the response from the fdc */
+static int
+FloppyReadResultCode(WORD PortBase, PUCHAR Result)
+{
+ int Replies;
+ int Status;
+
+ for (Replies = 0; Replies < FLOPPY_MAX_REPLIES; Replies++)
+ {
+ if ((Status = FloppyWaitUntilReady(PortBase)) < 0)
+ {
+ break;
+ }
+ Status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA;
+ if ((Status & ~STATUS_BUSY) == STATUS_READY)
+ {
+ return Replies;
+ }
+ if (Status == (STATUS_DIR | STATUS_READY | STATUS_BUSY))
+ {
+ Result[Replies] = inb_p(FLOPPY_DATA);
+ }
+ else
+ {
+ break;
+ }
}
- // FIXME: fill out controller data
- ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)
- ControllerObject->ControllerExtension;
- ControllerExtension->Number = Index;
- ControllerExtension->PortBase = ControllerParameters->PortBase;
- ControllerExtension->Vector = ControllerParameters->Vector;
- ControllerExtension->FDCType = ControllerType;
-
- /* Initialize the spin lock in the controller extension */
- KeInitializeSpinLock(&ControllerExtension->SpinLock);
-
- /* Register an interrupt handler for this controller */
- RC = IoConnectInterrupt(&ControllerExtension->Interrupt,
- FloppyIsr,
- ControllerExtension,
- &ControllerExtension->SpinLock,
- ControllerExtension->Vector,
- ControllerParameters->IrqL,
- ControllerParameters->SynchronizeIrqL,
- ControllerParameters->InterruptMode,
- FALSE,
- ControllerParameters->Affinity,
- FALSE);
- if (!NT_SUCCESS(RC))
+ if (FloppyInitialized)
{
- DPRINT("Could not Connect Interrupt %d\n", ControllerExtension->Vector);
- IoDeleteController(ControllerObject);
- return FALSE;
+ DPRINT("get result error. Fdc=%d Last status=%x Read bytes=%d\n",
+ PortBase,
+ Status,
+ Replies);
}
- // FIXME: setup DMA stuff for controller
+ return -1;
+}
- // Check for each possible drive and create devices for them
- for (DriveIdx = 0; DriveIdx < FLOPPY_MAX_DRIVES; DriveIdx++)
+#define MORE_OUTPUT -2
+/* does the fdc need more output? */
+static int
+FloppyNeedsMoreOutput(WORD PortBase, PUCHAR Result)
+{
+ int Status;
+
+ if ((Status = FloppyWaitUntilReady(PortBase)) < 0)
+ return -1;
+ if ((Status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY)
{
- // FIXME: try to identify the drive
- // FIXME: create a device if it's there
+ return FLOPPY_NEEDS_OUTPUT;
}
-
- return STATUS_SUCCESS;
+
+ return FloppyReadResultCode(PortBase, Result);
}
-// FloppyGetControllerVersion
-//
-// DESCRIPTION
-// Get the type/version of the floppy controller
-//
-// RUN LEVEL:
-// PASSIVE_LEVEL
-//
-// ARGUMENTS:
-// IN OUT PFLOPPY_DEVICE_EXTENSION DeviceExtension
-//
-// RETURNS:
-// BOOL success or failure
-//
-// COMMENTS:
-// This routine (get_fdc_version) was originally written by David C. Niemi
-//
+static BOOLEAN
+FloppyConfigure(WORD PortBase, BOOLEAN DisableFIFO, BYTE FIFODepth)
+{
+ BYTE Result[FLOPPY_MAX_REPLIES];
+
+ /* Turn on FIFO */
+ FloppyWriteCommandByte(PortBase, FLOPPY_CMD_CFG_FIFO);
+ if (FloppyNeedsMoreOutput(PortBase, Result) != FLOPPY_NEEDS_OUTPUT)
+ {
+ return FALSE;
+ }
+ FloppyWriteCommandByte(PortBase, 0);
+ FloppyWriteCommandByte(PortBase,
+ 0x10 |
+ (DisableFIFO ? 0x20 : 0x00) |
+ (FIFODepth & 0x0f));
+ /* pre-compensation from track 0 upwards */
+ FloppyWriteCommandByte(PortBase, 0);
+
+ return TRUE;
+}
+
+/* FloppyGetControllerVersion
+ *
+ * DESCRIPTION
+ * Get the type/version of the floppy controller
+ *
+ * RUN LEVEL:
+ * PASSIVE_LEVEL
+ *
+ * ARGUMENTS:
+ * IN OUT PFLOPPY_DEVICE_EXTENSION DeviceExtension
+ *
+ * RETURNS:
+ * BOOL success or failure
+ *
+ * COMMENTS:
+ * This routine (get_fdc_version) was originally written by David C. Niemi
+ */
static BOOLEAN
FloppyGetControllerVersion(IN PFLOPPY_CONTROLLER_PARAMETERS ControllerParameters,
OUT PFLOPPY_CONTROLLER_TYPE ControllerType)
{
- BYTE ResultReturned
- BYTE Result[FLOPPY_MAX_REPLIES];
- int ResultLength;
+ ULONG ResultLength;
+ UCHAR Result[FLOPPY_MAX_REPLIES];
/* 82072 and better know DUMPREGS */
if (!FloppyWriteCommandByte(ControllerParameters->PortBase,
FLOPPY_CMD_DUMP_FDC))
{
- return FALSE;
+ DPRINT("Failed to write command byte\n");
+ return FALSE;
}
- ResultLength = FloppyReadResultCode(PortBase, &Result));
+ ResultLength = FloppyReadResultCode(ControllerParameters->PortBase,
+ Result);
if (ResultLength < 0)
{
return FALSE;
/* 8272a/765 don't know DUMPREGS */
if ((ResultLength == 1) && (Result[0] == 0x80))
{
- DPRINT("FDC %d is an 8272A\n", PortBase);
+ DPRINT("FDC %d is an 8272A\n", ControllerParameters->PortBase);
*ControllerType = FDC_8272A;
return TRUE;
}
- if (r != 10)
+ if (ResultLength != 10)
{
DPRINT("FDC %d init: DUMP_FDC: unexpected return of %d bytes.\n",
- PortBase,
+ ControllerParameters->PortBase,
ResultLength);
return FALSE;
}
- if (!FloppyConfigure(PortBase, FALSE, 0x0a))
+ if (!FloppyConfigure(ControllerParameters->PortBase, FALSE, 0x0a))
{
- DPRINT("FDC %d is an 82072\n", PortBase);
+ DPRINT("FDC %d is an 82072\n", ControllerParameters->PortBase);
*ControllerType = FDC_82072;
return TRUE;
}
- FloppyWriteCommandByte(PortBase, FLOPPY_CMD_PPND_RW);
- if (FloppyNeedsMoreOutput(PortBase, Result) == FLOPPY_NEEDS_OUTPUT)
+ FloppyWriteCommandByte(ControllerParameters->PortBase, FLOPPY_CMD_PPND_RW);
+ if (FloppyNeedsMoreOutput(ControllerParameters->PortBase, Result) ==
+ FLOPPY_NEEDS_OUTPUT)
{
- FloppyWriteCommandByte(PortBase, 0);
+ FloppyWriteCommandByte(ControllerParameters->PortBase, 0);
}
else
{
- DPRINT("FDC %d is an 82072A\n", PortBase);
+ DPRINT("FDC %d is an 82072A\n", ControllerParameters->PortBase);
*ControllerType = FDC_82072A;
return TRUE;
}
/* Pre-1991 82077, doesn't know LOCK/UNLOCK */
- FloppyWriteCommandByte(PortBase, FLOPPY_CMD_UNLK_FIFO);
- ResultLength = FloppyReadResultCode(PortBase, &Result));
+ FloppyWriteCommandByte(ControllerParameters->PortBase, FLOPPY_CMD_UNLK_FIFO);
+ ResultLength = FloppyReadResultCode(ControllerParameters->PortBase,
+ Result);
if ((ResultLength == 1) && (Result[0] == 0x80))
{
- DPRINT("FDC %d is a pre-1991 82077\n", PortBase);
+ DPRINT("FDC %d is a pre-1991 82077\n", ControllerParameters->PortBase);
*ControllerType = FDC_82077_ORIG;
return TRUE;
}
if ((ResultLength != 1) || (Result[0] != 0x00))
{
DPRINT("FDC %d init: UNLOCK: unexpected return of %d bytes.\n",
- PortBase,
+ ControllerParameters->PortBase,
ResultLength);
return FALSE;
}
/* Revised 82077AA passes all the tests */
- FloppyWriteCommandByte(PortBase, FLOPPY_CMD_PARTID);
- ResultLength = FloppyReadResultCode(PortBase, &Result));
+ FloppyWriteCommandByte(ControllerParameters->PortBase, FLOPPY_CMD_PARTID);
+ ResultLength = FloppyReadResultCode(ControllerParameters->PortBase,
+ Result);
if (ResultLength != 1)
{
DPRINT("FDC %d init: PARTID: unexpected return of %d bytes.\n",
- PortBase,
+ ControllerParameters->PortBase,
ResultLength);
return FALSE;
}
if (Result[0] == 0x80)
{
- DPRINT("FDC %d is a post-1991 82077\n", PortBase);
+ DPRINT("FDC %d is a post-1991 82077\n", ControllerParameters->PortBase);
*ControllerType = FDC_82077;
return TRUE;
}
{
case 0x0:
/* Either a 82078-1 or a 82078SL running at 5Volt */
- DPRINT("FDC %d is an 82078.\n", PortBase);
+ DPRINT("FDC %d is an 82078.\n", ControllerParameters->PortBase);
*ControllerType = FDC_82078;
return TRUE;
case 0x1:
- DPRINT("FDC %d is a 44pin 82078\n", PortBase);
+ DPRINT("FDC %d is a 44pin 82078\n", ControllerParameters->PortBase);
*ControllerType = FDC_82078;
return TRUE;
case 0x2:
- DPRINT("FDC %d is a S82078B\n", PortBase);
+ DPRINT("FDC %d is a S82078B\n", ControllerParameters->PortBase);
*ControllerType = FDC_S82078B;
return TRUE;
case 0x3:
- DPRINT("FDC %d is a National Semiconductor PC87306\n", PortBase);
+ DPRINT("FDC %d is a National Semiconductor PC87306\n",
+ ControllerParameters->PortBase);
*ControllerType = FDC_87306;
return TRUE;
default:
DPRINT("FDC %d init: 82078 variant with unknown PARTID=%d.\n",
- PortBase,
+ ControllerParameters->PortBase,
Result[0] >> 5);
*ControllerType = FDC_82078_UNKN;
return TRUE;
}
}
-/* sends a command byte to the fdc */
static BOOLEAN
-FloppyWriteCommandByte(WORD PortBase, BYTE Byte)
+FloppyIsr(PKINTERRUPT Interrupt, PVOID ServiceContext)
{
- int Status;
-
- if ((Status = FloppyWaitUntilReady()) < 0)
- {
- return FALSE;
- }
-
- if ((Status & (STATUS_READY|STATUS_DIR|STATUS_DMA)) == STATUS_READY)
- {
- FloppyWriteData(PortBase, Byte);
- return 0;
- }
-
- if (FloppyInitialized)
- {
- DPRINT("Unable to send byte %x to FDC. Fdc=%x Status=%x\n",
- Byte,
- PortBase,
- Status);
- }
-
- return FALSE;
+ return(TRUE);
}
-/* gets the response from the fdc */
-static int
-FloppyReadResultCode(WORD PortBase, PBYTE Result)
+static BOOLEAN
+FloppyCreateController(PDRIVER_OBJECT DriverObject,
+ PFLOPPY_CONTROLLER_PARAMETERS ControllerParameters,
+ int Index)
{
- int Replies;
- int Status;
-
- for (Replies = 0; Replies < FLOPPY_MAX_REPLIES; Replies++)
- {
- if ((Status = FloppyWaitUntilReady(PortBase)) < 0)
- {
- break;
- }
- Status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA;
- if ((Status & ~STATUS_BUSY) == STATUS_READY)
- {
- return Replies;
- }
- if (Status == (STATUS_DIR | STATUS_READY | STATUS_BUSY))
- {
- Result[Replies] = fd_inb(FD_DATA);
- }
- else
- {
- break;
- }
- }
-
- if (FloppyInitialized)
- {
- DPRINT("get result error. Fdc=%d Last status=%x Read bytes=%d\n",
- PortBase,
- Status,
- Replies);
- }
-
- return -1;
+ FLOPPY_CONTROLLER_TYPE ControllerType;
+ PCONTROLLER_OBJECT ControllerObject;
+ PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
+ UNICODE_STRING DeviceName;
+ UNICODE_STRING SymlinkName;
+ NTSTATUS Status;
+ PDEVICE_OBJECT DeviceObject;
+
+ /* Detect controller and determine type */
+ if (!FloppyGetControllerVersion(ControllerParameters, &ControllerType))
+ {
+ DPRINT("Failed to get controller version\n");
+ return FALSE;
+ }
+
+ /* FIXME: Register port ranges and interrupts with HAL */
+
+ /* Create controller object for FDC */
+ ControllerObject = IoCreateController(sizeof(FLOPPY_CONTROLLER_EXTENSION));
+ if (ControllerObject == NULL)
+ {
+ DPRINT("Could not create controller object for controller %d\n",
+ Index);
+ return FALSE;
+ }
+
+ /* FIXME: fill out controller data */
+ ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)
+ ControllerObject->ControllerExtension;
+ ControllerExtension->Number = Index;
+ ControllerExtension->PortBase = ControllerParameters->PortBase;
+ ControllerExtension->Vector = ControllerParameters->Vector;
+ ControllerExtension->FDCType = ControllerType;
+
+ /* Initialize the spin lock in the controller extension */
+ KeInitializeSpinLock(&ControllerExtension->SpinLock);
+
+ /* Register an interrupt handler for this controller */
+ Status = IoConnectInterrupt(&ControllerExtension->Interrupt,
+ FloppyIsr,
+ ControllerExtension,
+ &ControllerExtension->SpinLock,
+ ControllerExtension->Vector,
+ ControllerParameters->IrqL,
+ ControllerParameters->SynchronizeIrqL,
+ ControllerParameters->InterruptMode,
+ FALSE,
+ ControllerParameters->Affinity,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("Could not Connect Interrupt %d\n",
+ ControllerExtension->Vector);
+ IoDeleteController(ControllerObject);
+ return FALSE;
+ }
+
+ /* FIXME: setup DMA stuff for controller */
+
+#if 0
+ /* Check for each possible drive and create devices for them */
+ for (DriveIdx = 0; DriveIdx < FLOPPY_MAX_DRIVES; DriveIdx++)
+ {
+ /* FIXME: try to identify the drive */
+ /* FIXME: create a device if it's there */
+ }
+#endif
+
+ /* FIXME: Let's assume one drive and one controller for the moment */
+ RtlInitUnicodeString(&DeviceName, L"\\Device\\Floppy0");
+ Status = IoCreateDevice(DriverObject,
+ sizeof(FLOPPY_DEVICE_EXTENSION),
+ &DeviceName,
+ FILE_DEVICE_DISK,
+ FILE_REMOVABLE_MEDIA | FILE_FLOPPY_DISKETTE,
+ FALSE,
+ &DeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ IoDisconnectInterrupt(ControllerExtension->Interrupt);
+ IoDeleteController(ControllerObject);
+ }
+
+ /* Initialize the device */
+ DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
+ DeviceObject->AlignmentRequirement = FILE_WORD_ALIGNMENT;
+
+ /* Create a symlink */
+ RtlInitUnicodeString(&SymlinkName, L"\\??\\A:");
+ IoCreateSymbolicLink(&SymlinkName, &DeviceName);
+
+ return STATUS_SUCCESS;
}
-
-/* waits until the fdc becomes ready */
-static int
-FloppyWaitUntilReady(WORD PortBase)
+
+VOID FloppyStartIo(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
{
- int Retries;
- int Status;
-
- for (Retries = 0; Retries < FLOPPY_MAX_STAT_RETRIES; Retries++)
- {
- status = FloppyReadSTAT(PortBase);
- if (Status & STATUS_READY)
- {
- return Status;
- }
- }
-
- if (FloppyInitialized)
- {
- DPRINT("Getstatus times out (%x) on fdc %d\n",
- Status,
- PortBase);
- }
-
- return -1;
}
-
-#define MORE_OUTPUT -2
-/* does the fdc need more output? */
-static int
-FloppyNeedsMoreOutput(WORD PortBase, PBYTE Result)
+NTSTATUS FloppyDispatchOpenClose(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
{
- int Status;
-
- if ((Status = FloppyWaitUntilReady(PortBase)) < 0)
- return -1;
- if ((Status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY)
- {
- return FLOPPY_NEEDS_OUTPUT;
- }
-
- return FloppyReadResultCode(PortBase, Result);
+ return(STATUS_UNSUCCESSFUL);
}
-static BOOLEAN
-FloppyConfigure(WORD PortBase, BOOLEAN DisableFIFO, BYTE FIFODepth)
+NTSTATUS FloppyDispatchReadWrite(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
{
- BYTE Result[FLOPPY_MAX_REPLIES];
-
- /* Turn on FIFO */
- FloppyWriteCommandByte(FLOPPY_CMD_CFG_FIFO);
- if (FloppyNeedsOutput(PortBase, Result) != FLOPPY_NEEDS_OUTPUT)
- {
- return FALSE;
- }
- FloppyWriteCommandByte(PortBase, 0);
- FloppyWriteCommandByte(PortBase,
- 0x10 |
- (DisableFIFO ? 0x20 : 0x00) |
- (FIFODepth & 0x0f));
- /* pre-compensation from track 0 upwards */
- FloppyWriteCommandByte(PortBase, 0);
-
- return TRUE;
-}
+ return(STATUS_UNSUCCESSFUL);
+}
+NTSTATUS FloppyDispatchDeviceControl(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ return(STATUS_UNSUCCESSFUL);
+}
+/* ModuleEntry
+ *
+ * DESCRIPTION:
+ * This function initializes the driver, locates and claims
+ * hardware resources, and creates various NT objects needed
+ * to process I/O requests.
+ *
+ * RUN LEVEL:
+ * PASSIVE_LEVEL
+ *
+ * ARGUMENTS:
+ * IN PDRIVER_OBJECT DriverObject System allocated Driver Object
+ * for this driver
+ * IN PUNICODE_STRING RegistryPath Name of registry driver service
+ * key
+ *
+ * RETURNS:
+ * NTSTATUS
+ */
+NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
+ IN PUNICODE_STRING RegistryPath)
+{
+ DbgPrint("Floppy driver\n");
+
+ /* Export other driver entry points... */
+ DriverObject->DriverStartIo = FloppyStartIo;
+ DriverObject->MajorFunction[IRP_MJ_CREATE] = FloppyDispatchOpenClose;
+ DriverObject->MajorFunction[IRP_MJ_CLOSE] = FloppyDispatchOpenClose;
+ DriverObject->MajorFunction[IRP_MJ_READ] = FloppyDispatchReadWrite;
+ DriverObject->MajorFunction[IRP_MJ_WRITE] = FloppyDispatchReadWrite;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
+ FloppyDispatchDeviceControl;
+
+ /* Try to detect controller and abort if it fails */
+ if (!FloppyCreateController(DriverObject,
+ &ControllerParameters[0],
+ 0))
+ {
+ DPRINT("Could not find floppy controller\n");
+ return STATUS_NO_SUCH_DEVICE;
+ }
+
+ return STATUS_SUCCESS;
+}
-# $Id: makefile,v 1.11 2000/06/29 23:35:48 dwelch Exp $
+# $Id: makefile,v 1.12 2000/07/19 14:18:20 dwelch Exp $
#
#
TARGET=ide
BASE_CFLAGS = -I. -I../../../include
-all: $(TARGET).sys
+all: $(TARGET).nostrip.sys $(TARGET).sys
.phony: all
endif
$(TARGET).sys: $(OBJECTS)
+ $(STRIP) --strip-debug $(OBJECTS)
$(CC) \
-specs=../../svc_specs \
-mdll \
$(OBJECTS)
- $(RM) temp.exp
+$(TARGET).nostrip.sys: $(OBJECTS)
+ $(CC) \
+ -specs=../../svc_specs \
+ -mdll \
+ -o junk.tmp \
+ -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ \
+ -Wl,--defsym,_etext=etext \
+ -Wl,--base-file,base.tmp $(OBJECTS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) \
+ --dllname $(TARGET).sys \
+ --base-file base.tmp \
+ --output-exp temp.exp \
+ --kill-at
+ - $(RM) base.tmp
+ $(CC) \
+ --verbose \
+ -Wl,--image-base,0x10000 \
+ -Wl,-e,_DriverEntry@8 \
+ -Wl,temp.exp \
+ -specs=../../svc_specs \
+ -mdll \
+ -o $(TARGET).nostrip.sys \
+ $(OBJECTS)
+ - $(RM) temp.exp
+
+
+WITH_DEBUGGING=yes
include ../../../rules.mak
-# $Id: makefile_rex,v 1.10 2000/05/14 13:10:00 dwelch Exp $
+# $Id: makefile_rex,v 1.11 2000/07/19 14:18:20 dwelch Exp $
#
# Minix IFS Driver makefile
#
minix.o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o minix.o
+minixfs.nostrip.sys: $(OBJECTS)
+ $(CC) \
+ -specs=../../svc_specs \
+ -mdll \
+ -o junk.tmp \
+ -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ \
+ -Wl,--defsym,_etext=etext \
+ -Wl,--base-file,base.tmp \
+ $(OBJECTS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) \
+ --dllname $(TARGETNAME).sys \
+ --base-file base.tmp \
+ --output-exp temp.exp
+ - $(RM) base.tmp
+ $(CC) \
+ --verbose \
+ -Wl,--image-base,0x10000 \
+ -Wl,-e,_DriverEntry@8 \
+ -specs=../../svc_specs \
+ -mdll \
+ -o $(TARGETNAME).nostrip.sys \
+ $(OBJECTS) \
+ -Wl,temp.exp
+ - $(RM) temp.exp
+
minixfs.sys: $(OBJECTS)
+ $(STRIP) --strip-debug $(OBJECTS)
$(CC) \
-specs=../../svc_specs \
-mdll \
WIN32_LEAN_AND_MEAN = yes
WARNINGS_ARE_ERRORS = yes
+WITH_DEBUGGING = yes
include ../../../rules.mak
# EOF
-# $Id: makefile,v 1.17 2000/07/07 02:14:14 ekohl Exp $
+# $Id: makefile,v 1.18 2000/07/19 14:18:20 dwelch Exp $
#
#
TARGET=vfatfs
BASE_CFLAGS = -I. -I../../../include
-all: $(TARGET).sys
+all: $(TARGET).nostrip.sys $(TARGET).sys
.phony: all
$(CP) $(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys
endif
+$(TARGET).nostrip.sys: $(OBJECTS) $(LIBS)
+ $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext -Wl,--base-file,base.tmp -Wl,"-h vfatfs.sys" $(OBJECTS) $(LIBS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) \
+ --dllname $(TARGET).sys \
+ --base-file base.tmp \
+ --output-exp temp.exp \
+ --def vfatfs.def
+ - $(RM) base.tmp
+ $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 -Wl,temp.exp -Wl,"-h vfatfs.sys" -specs=../../svc_specs -mdll -o $(TARGET).nostrip.sys $(OBJECTS) $(LIBS)
+ - $(RM) temp.exp
+
+
$(TARGET).sys: $(OBJECTS) $(LIBS)
+ $(STRIP) --strip-debug $(OBJECTS)
$(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext -Wl,--base-file,base.tmp -Wl,"-h vfatfs.sys" $(OBJECTS) $(LIBS)
- $(RM) junk.tmp
$(DLLTOOL) \
$(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 -Wl,temp.exp -Wl,"-h vfatfs.sys" -specs=../../svc_specs -mdll -o $(TARGET).sys $(OBJECTS) $(LIBS)
- $(RM) temp.exp
-
+WITH_DEBUGGING=yes
WARNINGS_ARE_ERRORS = yes
include ../../../rules.mak
cp ntoskrnl/ntoskrnl.exe $1
cp services/fs/vfat/vfatfs.sys $1
cp services/dd/ide/ide.sys $1
+#cp services/dd/floppy/floppy.sys $1
cp ntoskrnl/ntoskrnl.exe $1/reactos/system32/
cp services/fs/vfat/vfatfs.sys $1/reactos/system32/drivers/
cp services/dd/ide/ide.sys $1/reactos/system32/drivers/
+#cp services/dd/floppy/floppy.sys $1/reactos/system32/drivers/
cp services/dd/keyboard/keyboard.sys $1/reactos/system32/drivers
cp services/dd/blue/blue.sys $1/reactos/system32/drivers
#cp services/dd/vga/miniport/vgamp.sys $1/reactos/system32/drivers
./install-system.sh /mnt/floppy
umount /mnt/floppy
echo "Installing to disk."
-mount -t vfat /bochs/10M.vga /mnt/floppy -o loop,offset=8704,rw
+mount -t vfat /bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw
+#mount -t minix /bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw
./install.sh /mnt/floppy
umount /mnt/floppy
cp apps/file/file.exe $1/reactos/bin
cp apps/pteb/pteb.exe $1/reactos/bin
cp apps/consume/consume.exe $1/reactos/bin
+cp apps/float/float.exe $1/reactos/bin
-# $Id: makefile,v 1.48 2000/05/14 13:10:00 dwelch Exp $
+# $Id: makefile,v 1.49 2000/07/19 14:18:17 dwelch Exp $
#
# ReactOS Operating System
#
$(CP) $(TARGET).dll ../../$(DIST_DIR)/dlls/$(TARGET).dll
endif
+WITH_DEBUGGING=yes
#WARNINGS_ARE_ERRORS = yes
include ../../rules.mak
* Pointer to allocated memory block
* NULL: Failure
*/
-PVOID STDCALL RtlAllocateHeap(
- HANDLE heap, /* [in] Handle of private heap block */
- ULONG flags, /* [in] Heap allocation control flags */
- ULONG size /* [in] Number of bytes to allocate */
-) {
- ARENA_FREE *pArena;
- ARENA_INUSE *pInUse;
- SUBHEAP *subheap;
- HEAP *heapPtr = HEAP_GetPtr( heap );
-
- /* Validate the parameters */
-
- if (!heapPtr) return NULL;
- flags &= HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY;
- flags |= heapPtr->flags;
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLockHeap( heap );
- size = (size + 3) & ~3;
- if (size < HEAP_MIN_BLOCK_SIZE) size = HEAP_MIN_BLOCK_SIZE;
+PVOID STDCALL
+RtlAllocateHeap(HANDLE heap, /* [in] Handle of private heap block */
+ ULONG flags, /* [in] Heap allocation control flags */
+ ULONG size /* [in] Number of bytes to allocate */)
+{
+ ARENA_FREE* pArena;
+ ARENA_INUSE* pInUse;
+ SUBHEAP* subheap;
+ HEAP* heapPtr = NULL;
+
+ DPRINT("RtlAllocateHeap(heap 0x%x, flags 0x%x, size %d)\n",
+ heap, flags, size);
+
+ /* Validate the parameters */
+
+ heapPtr = HEAP_GetPtr(heap);
+ if (!heapPtr)
+ {
+ return NULL;
+ }
+ flags &= HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY;
+ flags |= heapPtr->flags;
+ if (!(flags & HEAP_NO_SERIALIZE))
+ {
+ RtlLockHeap(heap);
+ }
+ size = (size + 3) & ~3;
+ if (size < HEAP_MIN_BLOCK_SIZE)
+ {
+ size = HEAP_MIN_BLOCK_SIZE;
+ }
/* Locate a suitable free block */
{
DPRINT("(%08x,%08lx,%08lx): returning NULL\n",
heap, flags, size );
- if (!(flags & HEAP_NO_SERIALIZE)) RtlUnlockHeap( heap );
-// SetLastError( ERROR_COMMITMENT_LIMIT );
- return NULL;
+ if (!(flags & HEAP_NO_SERIALIZE)) RtlUnlockHeap( heap );
+ /* SetLastError( ERROR_COMMITMENT_LIMIT ); */
+ return NULL;
}
/* Remove the arena from the free list */
pInUse->size = (pInUse->size & ~ARENA_FLAG_FREE)
+ sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
pInUse->callerEIP = *((DWORD *)&heap - 1); /* hack hack */
-// pInUse->threadId = GetCurrentTask();
+/* pInUse->threadId = GetCurrentTask(); */
pInUse->magic = ARENA_INUSE_MAGIC;
/* Shrink the block */
;
BITS 16
-%define NDEBUG 1
+;%define NDEBUG 1
%macro DPRINT 1+
%ifndef NDEBUG
;
; Begin the pmode initalization
;
- jmp _to_pmode
+ ;jmp _to_pmode
exit:
mov ax,04c00h
-/* $Id: adapter.c,v 1.1 2000/03/26 19:38:18 ea Exp $
+/* $Id: adapter.c,v 1.2 2000/07/19 14:18:18 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* NOTE: IoAllocateAdapterChannel in NTOSKRNL.EXE */
-BOOLEAN
-STDCALL
-IoFlushAdapterBuffers (
- PADAPTER_OBJECT AdapterObject,
- PMDL Mdl,
- PVOID MapRegisterBase,
- PVOID CurrentVa,
- ULONG Length,
- BOOLEAN WriteToDevice
- )
+BOOLEAN STDCALL
+IoFlushAdapterBuffers (PADAPTER_OBJECT AdapterObject,
+ PMDL Mdl,
+ PVOID MapRegisterBase,
+ PVOID CurrentVa,
+ ULONG Length,
+ BOOLEAN WriteToDevice)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
-VOID
-STDCALL
-IoFreeAdapterChannel (
- PADAPTER_OBJECT AdapterObject
- )
+VOID STDCALL
+IoFreeAdapterChannel (PADAPTER_OBJECT AdapterObject)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
-VOID
-STDCALL
-IoFreeMapRegisters (
- PADAPTER_OBJECT AdapterObject,
- PVOID MapRegisterBase,
- ULONG NumberOfMapRegisters
- )
+VOID STDCALL
+IoFreeMapRegisters (PADAPTER_OBJECT AdapterObject,
+ PVOID MapRegisterBase,
+ ULONG NumberOfMapRegisters)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
-PHYSICAL_ADDRESS
-STDCALL
-IoMapTransfer (
- PADAPTER_OBJECT AdapterObject,
- PMDL Mdl,
- PVOID MapRegisterBase,
- PVOID CurrentVa,
- PULONG Length,
- BOOLEAN WriteToDevice
- )
+PHYSICAL_ADDRESS STDCALL
+IoMapTransfer (PADAPTER_OBJECT AdapterObject,
+ PMDL Mdl,
+ PVOID MapRegisterBase,
+ PVOID CurrentVa,
+ PULONG Length,
+ BOOLEAN WriteToDevice)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
-/* $Id: dma.c,v 1.7 2000/07/01 18:23:06 ekohl Exp $
+/* $Id: dma.c,v 1.8 2000/07/19 14:18:18 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <internal/debug.h>
-/* TYPES *********************************************************************/
-
-#define MAP_REGISTER_SIZE (PAGESIZE)
-#define NR_MAP_REGISTERS (32)
-
-typedef struct
-{
- PVOID VirtualAddress;
- PVOID PhysicalAddress;
-} MAP_REGISTER, *PMAP_REGISTER;
-/*
-typedef struct _ADAPTER_OBJECT
-{
- DEVICE_DESCRIPTION desc;
- KDEVICE_QUEUE wait_queue;
-} ADAPTER_OBJECT, *PADAPTER_OBJECT
-*/
-/* GLOBALS *******************************************************************/
-
-static PMAP_REGISTER map_registers[];
-
/* FUNCTIONS *****************************************************************/
-VOID HalInitializeAdapterSupport(VOID)
-{
- /* ?? */
-}
-
-ULONG HalGetDmaAlignmentRequirement()
-/*
- * FUNCTION: Returns the size of the cache boundary
- */
-{
- return(1);
-}
-
-
-PVOID
-STDCALL
-HalAllocateCommonBuffer (
- PADAPTER_OBJECT AdapterObject,
- ULONG Length,
- PPHYSICAL_ADDRESS LogicalAddress,
- BOOLEAN CacheEnabled
- )
+PVOID STDCALL
+HalAllocateCommonBuffer (PADAPTER_OBJECT AdapterObject,
+ ULONG Length,
+ PPHYSICAL_ADDRESS LogicalAddress,
+ BOOLEAN CacheEnabled)
/*
* FUNCTION: Allocates memory that is visible to both the processor(s) and
* a dma device
* NULL on failure
*/
{
-/*
- PVOID Buffer;
- PHYSICAL_ADDRESS highest_address;
-
- highest_address.HighPart = 0;
- if (AdapterObject->Desc.Dma32BitAddresses )
- {
- highest_address.LowPart = 0xffffffff;
- }
- else
- {
- highest_address.LowPart = 0xfffff;
- }
- Buffer = MmAllocateContiguousMemory(Length,&highest_address);
- LogicalAddress->HighPart = 0;
- LogicalAddress->LowPart = MmGetPhysicalAddress(Buffer);
- return(Buffer);*/
- return NULL;
+ UNIMPLEMENTED;
}
-BOOLEAN
-STDCALL
-HalFlushCommonBuffer (
- ULONG Unknown1,
- ULONG Unknown2,
- ULONG Unknown3,
- ULONG Unknown4,
- ULONG Unknown5,
- ULONG Unknown6,
- ULONG Unknown7,
- ULONG Unknown8
- )
+BOOLEAN STDCALL
+HalFlushCommonBuffer (ULONG Unknown1,
+ ULONG Unknown2,
+ ULONG Unknown3,
+ ULONG Unknown4,
+ ULONG Unknown5,
+ ULONG Unknown6,
+ ULONG Unknown7,
+ ULONG Unknown8)
{
return TRUE;
}
-VOID
-STDCALL
-HalFreeCommonBuffer (
- PADAPTER_OBJECT AdapterObject,
- ULONG Length,
- PHYSICAL_ADDRESS LogicalAddress,
- PVOID VirtualAddress,
- BOOLEAN CacheEnabled
- )
+VOID STDCALL
+HalFreeCommonBuffer (PADAPTER_OBJECT AdapterObject,
+ ULONG Length,
+ PHYSICAL_ADDRESS LogicalAddress,
+ PVOID VirtualAddress,
+ BOOLEAN CacheEnabled)
{
- MmFreeContiguousMemory (VirtualAddress);
+ UNIMPLEMENTED;
}
-PADAPTER_OBJECT
-STDCALL
-HalGetAdapter (
- PDEVICE_DESCRIPTION DeviceDescription,
- PULONG NumberOfMapRegisters
- )
+PADAPTER_OBJECT STDCALL
+HalGetAdapter (PDEVICE_DESCRIPTION DeviceDescription,
+ PULONG NumberOfMapRegisters)
/*
* FUNCTION: Returns a pointer to an adapter object for the DMA device
* defined the device description structure
* NULL on failure
*/
{
-/* PADAPTER_OBJECT adapter;
-
- adapter = ExAllocatePool(NonPagedPool,sizeof(ADAPTER_OBJECT));
- RtlCopyMemory(&adapter->desc,DeviceDescription,sizeof(DEVICE_DESCRIPTION));
- */
- return NULL;
+ UNIMPLEMENTED;
}
-ULONG
-STDCALL
-HalReadDmaCounter (
- PADAPTER_OBJECT AdapterObject
- )
+ULONG STDCALL
+HalReadDmaCounter (PADAPTER_OBJECT AdapterObject)
{
UNIMPLEMENTED;
}
-/* $Id: adapter.c,v 1.3 2000/05/09 16:13:49 ekohl Exp $
+/* $Id: adapter.c,v 1.4 2000/07/19 14:18:18 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* FUNCTIONS *****************************************************************/
-NTSTATUS
-STDCALL
-IoAllocateAdapterChannel (
- PADAPTER_OBJECT AdapterObject,
- PDEVICE_OBJECT DeviceObject,
- ULONG NumberOfMapRegisters,
- PDRIVER_CONTROL ExecutionRoutine,
- PVOID Context
- )
+NTSTATUS STDCALL
+IoAllocateAdapterChannel (PADAPTER_OBJECT AdapterObject,
+ PDEVICE_OBJECT DeviceObject,
+ ULONG NumberOfMapRegisters,
+ PDRIVER_CONTROL ExecutionRoutine,
+ PVOID Context)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
: /* No outputs */
: "i" (TEB_SELECTOR)
: "ax");
+ __asm__("clts\n\t");
#if 0
Thread = PsGetCurrentThread();
#define NDEBUG
#include <internal/debug.h>
+/* GLOBALS *******************************************************************/
+
+static ULONG HardwareMathSupport;
+static ULONG x;
+
/* FUNCTIONS *****************************************************************/
+VOID KiCheckFPU(VOID)
+{
+ unsigned short int status;
+ int cr0;
+
+ HardwareMathSupport = 0;
+
+ __asm__("clts\n\t");
+ __asm__("fninit\n\t");
+ __asm__("fstsw %0\n\t" : "=a" (status));
+ if (status != 0)
+ {
+ __asm__("movl %%cr0, %0\n\t" : "=g" (cr0));
+ cr0 = cr0 | 0x4;
+ __asm__("movl %0, %%cr0\n\t" :
+ : "g" (cr0));
+ DbgPrint("No FPU detected\n");
+ return;
+ }
+ /* FIXME: Do fsetpm */
+ DbgPrint("Detected FPU\n");
+ HardwareMathSupport = 1;
+
+ DbgPrint("Testing FPU\n");
+ x = x * 6.789456;
+}
+
VOID KeInit1(VOID)
{
+ KiCheckFPU();
+
KeInitExceptions ();
KeInitInterrupts ();
}
-/* $Id: loader.c,v 1.58 2000/07/04 08:52:41 dwelch Exp $
+/* $Id: loader.c,v 1.59 2000/07/19 14:18:18 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
VOID LdrLoadAutoConfigDrivers (VOID)
{
- /*
- * Keyboard driver
- */
- LdrLoadAutoConfigDriver( L"keyboard.sys" );
- /*
- * Raw console driver
- */
- LdrLoadAutoConfigDriver( L"blue.sys" );
-
-// LdrLoadAutoConfigDriver(L"minixfs.sys");
+ /*
+ * Keyboard driver
+ */
+ LdrLoadAutoConfigDriver( L"keyboard.sys" );
+
+ /*
+ * Raw console driver
+ */
+ LdrLoadAutoConfigDriver( L"blue.sys" );
+
+ /*
+ * Floppy disk driver
+ */
+// LdrLoadAutoConfigDriver(L"floppy.sys");
+
+ /*
+ * Minix filesystem driver
+ */
+ LdrLoadAutoConfigDriver(L"minixfs.sys");
}
/* TYPES *******************************************************************/
-#define PHYSICAL_PAGE_FREE (0x1)
-#define PHYSICAL_PAGE_INUSE (0x2)
-#define PHYSICAL_PAGE_BIOS (0x3)
+#define MM_PHYSICAL_PAGE_FREE (0x1)
+#define MM_PHYSICAL_PAGE_USED (0x2)
+#define MM_PHYSICAL_PAGE_BIOS (0x3)
+
+#define MM_PTYPE(x) ((x) & 0x3)
typedef struct _PHYSICAL_PAGE
{
static LIST_ENTRY FreePageListHead;
static LIST_ENTRY BiosPageListHead;
-ULONG MiNrFreePages;
-ULONG MiNrUsedPages;
-
/* FUNCTIONS *************************************************************/
PVOID MmInitializePageList(PVOID FirstPhysKernelAddress,
LastPhysKernelAddress = (PVOID)PAGE_ROUND_UP(LastPhysKernelAddress);
LastPhysKernelAddress = LastPhysKernelAddress + (Reserved * PAGESIZE);
- MiNrFreePages = 0;
- MiNrUsedPages = 0;
+ MmStats.NrTotalPages = 0;
+ MmStats.NrSystemPages = 0;
+ MmStats.NrUserPages = 0;
+ MmStats.NrReservedPages = 0;
+ MmStats.NrFreePages = 0;
+ MmStats.NrLockedPages = 0;
for (i = 0; i < Reserved; i++)
{
i = 1;
if ((ULONG)FirstPhysKernelAddress < 0xa0000)
{
- MiNrFreePages = MiNrFreePages +
- ((ULONG)FirstPhysKernelAddress/PAGESIZE);
+ MmStats.NrFreePages += ((ULONG)FirstPhysKernelAddress/PAGESIZE);
for (; i<((ULONG)FirstPhysKernelAddress/PAGESIZE); i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_FREE;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_FREE;
MmPageArray[i].ReferenceCount = 0;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
InsertTailList(&FreePageListHead,
&MmPageArray[i].ListEntry);
}
- MiNrUsedPages = MiNrUsedPages +
+ MmStats.NrSystemPages +=
((((ULONG)LastPhysKernelAddress) / PAGESIZE) - i);
for (; i<((ULONG)LastPhysKernelAddress / PAGESIZE); i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_INUSE;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_USED;
MmPageArray[i].ReferenceCount = 1;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
InsertTailList(&UsedPageListHead,
&MmPageArray[i].ListEntry);
}
- MiNrFreePages = MiNrFreePages +
- ((0xa0000/PAGESIZE) - i);
+ MmStats.NrFreePages += ((0xa0000/PAGESIZE) - i);
for (; i<(0xa0000/PAGESIZE); i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_FREE;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_FREE;
MmPageArray[i].ReferenceCount = 0;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
InsertTailList(&FreePageListHead,
&MmPageArray[i].ListEntry);
}
+ MmStats.NrReservedPages += ((0x100000/PAGESIZE) - i);
for (; i<(0x100000 / PAGESIZE); i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_BIOS;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_BIOS;
MmPageArray[i].ReferenceCount = 1;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
}
else
{
- MiNrFreePages = MiNrFreePages + (0xa0000 / PAGESIZE);
+ MmStats.NrFreePages += (0xa0000 / PAGESIZE);
for (; i<(0xa0000 / PAGESIZE); i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_FREE;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_FREE;
MmPageArray[i].ReferenceCount = 0;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
InsertTailList(&FreePageListHead,
&MmPageArray[i].ListEntry);
}
+ MmStats.NrReservedPages += (0x60000 / PAGESIZE);
for (; i<(0x100000 / PAGESIZE); i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_BIOS;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_BIOS;
MmPageArray[i].ReferenceCount = 1;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
InsertTailList(&BiosPageListHead,
&MmPageArray[i].ListEntry);
}
- MiNrFreePages = MiNrFreePages +
- (((ULONG)FirstPhysKernelAddress/PAGESIZE) - i);
+ MmStats.NrFreePages += (((ULONG)FirstPhysKernelAddress/PAGESIZE) - i);
for (; i<((ULONG)FirstPhysKernelAddress/PAGESIZE); i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_FREE;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_FREE;
MmPageArray[i].ReferenceCount = 0;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
InsertTailList(&FreePageListHead,
&MmPageArray[i].ListEntry);
}
- MiNrUsedPages = MiNrUsedPages +
+ MmStats.NrSystemPages +=
(((ULONG)LastPhysKernelAddress/PAGESIZE) - i);
for (; i<((ULONG)LastPhysKernelAddress/PAGESIZE); i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_INUSE;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_USED;
MmPageArray[i].ReferenceCount = 1;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
}
}
- MiNrFreePages = MiNrFreePages + (MemorySizeInPages - i);
+ MmStats.NrFreePages += (MemorySizeInPages - i);
for (; i<MemorySizeInPages; i++)
{
- MmPageArray[i].Flags = PHYSICAL_PAGE_FREE;
+ MmPageArray[i].Flags = MM_PHYSICAL_PAGE_FREE;
MmPageArray[i].ReferenceCount = 0;
KeInitializeEvent(&MmPageArray[i].Event,
NotificationEvent,
}
KeAcquireSpinLock(&PageListLock, &oldIrql);
+
+ if (MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_USED)
+ {
+ DbgPrint("Referencing non-used page\n");
+ KeBugCheck(0);
+ }
+
MmPageArray[Start].ReferenceCount++;
KeReleaseSpinLock(&PageListLock, oldIrql);
}
KeBugCheck(0);
}
- if (((ULONG)PhysicalAddress) > 0x400000)
+ KeAcquireSpinLock(&PageListLock, &oldIrql);
+
+ if (MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_USED)
{
- DbgPrint("MmFreePage() failed with %x\n", PhysicalAddress);
+ DbgPrint("Dereferencing free page\n");
KeBugCheck(0);
}
- KeAcquireSpinLock(&PageListLock, &oldIrql);
-
- MiNrFreePages = MiNrFreePages + 1;
- MiNrUsedPages = MiNrUsedPages - 1;
+ MmStats.NrFreePages++;
+ MmStats.NrSystemPages--;
MmPageArray[Start].ReferenceCount--;
if (MmPageArray[Start].ReferenceCount == 0)
{
RemoveEntryList(&MmPageArray[Start].ListEntry);
- MmPageArray[Start].Flags = PHYSICAL_PAGE_FREE;
+ if (MmPageArray[Start].LockCount > 0)
+ {
+ DbgPrint("Freeing locked page\n");
+ KeBugCheck(0);
+ }
+ if (MmPageArray[Start].Flags != MM_PHYSICAL_PAGE_USED)
+ {
+ DbgPrint("Freeing page with flags %x\n",
+ MmPageArray[Start].Flags);
+ KeBugCheck(0);
+ }
+ MmPageArray[Start].Flags = MM_PHYSICAL_PAGE_FREE;
InsertTailList(&FreePageListHead, &MmPageArray[Start].ListEntry);
}
KeReleaseSpinLock(&PageListLock, oldIrql);
}
+ULONG MmGetLockCountPage(PVOID PhysicalAddress)
+{
+ ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
+ KIRQL oldIrql;
+ ULONG LockCount;
+
+ DPRINT("MmGetLockCountPage(PhysicalAddress %x)\n", PhysicalAddress);
+
+ if (((ULONG)PhysicalAddress) == 0)
+ {
+ KeBugCheck(0);
+ }
+
+ KeAcquireSpinLock(&PageListLock, &oldIrql);
+
+ if (MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_USED)
+ {
+ DbgPrint("Getting lock count for free page\n");
+ KeBugCheck(0);
+ }
+
+ LockCount = MmPageArray[Start].LockCount;
+ KeReleaseSpinLock(&PageListLock, oldIrql);
+
+ return(LockCount);
+}
+
VOID MmLockPage(PVOID PhysicalAddress)
{
ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
KIRQL oldIrql;
- DPRINT("MmReferencePage(PhysicalAddress %x)\n", PhysicalAddress);
+ DPRINT("MmLockPage(PhysicalAddress %x)\n", PhysicalAddress);
if (((ULONG)PhysicalAddress) == 0)
{
}
KeAcquireSpinLock(&PageListLock, &oldIrql);
+
+ if (MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_USED)
+ {
+ DbgPrint("Locking free page\n");
+ KeBugCheck(0);
+ }
+
MmPageArray[Start].LockCount++;
KeReleaseSpinLock(&PageListLock, oldIrql);
}
ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
KIRQL oldIrql;
- DPRINT("MmReferencePage(PhysicalAddress %x)\n", PhysicalAddress);
+ DPRINT("MmUnlockPage(PhysicalAddress %x)\n", PhysicalAddress);
if (((ULONG)PhysicalAddress) == 0)
{
}
KeAcquireSpinLock(&PageListLock, &oldIrql);
+
+ if (MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_USED)
+ {
+ DbgPrint("Unlocking free page\n");
+ KeBugCheck(0);
+ }
+
MmPageArray[Start].LockCount--;
KeReleaseSpinLock(&PageListLock, oldIrql);
}
}
PageDescriptor = CONTAINING_RECORD(ListEntry, PHYSICAL_PAGE, ListEntry);
DPRINT("PageDescriptor %x\n",PageDescriptor);
- PageDescriptor->Flags = PHYSICAL_PAGE_INUSE;
+ if (PageDescriptor->Flags != MM_PHYSICAL_PAGE_FREE)
+ {
+ DbgPrint("Got non-free page from freelist\n");
+ KeBugCheck(0);
+ }
+ PageDescriptor->Flags = MM_PHYSICAL_PAGE_USED;
PageDescriptor->ReferenceCount = 1;
+ PageDescriptor->LockCount = 0;
PageDescriptor->SavedSwapEntry = SavedSwapEntry;
ExInterlockedInsertTailList(&UsedPageListHead, ListEntry,
&PageListLock);
offset = offset / sizeof(PHYSICAL_PAGE) * PAGESIZE;
DPRINT("offset %x\n",offset);
- MiNrUsedPages = MiNrUsedPages + 1;
- MiNrFreePages = MiNrFreePages - 1;
-
- if (offset > 0x400000)
- {
- DbgPrint("Failed in MmAllocPage() with offset %x\n", offset);
- KeBugCheck(0);
- }
+ MmStats.NrSystemPages++;
+ MmStats.NrFreePages--;
DPRINT("MmAllocPage() = %x\n",offset);
return((PVOID)offset);
-/* $Id: page.c,v 1.12 2000/07/07 10:30:57 dwelch Exp $
+/* $Id: page.c,v 1.13 2000/07/19 14:18:19 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
/* GLOBALS *****************************************************************/
-extern ULONG MiNrFreePages;
-
#define PA_BIT_PRESENT (0)
#define PA_BIT_READWRITE (1)
#define PA_BIT_USER (2)
{
if (PAGE_MASK(*page_tlb) >= 0x400000)
{
- DbgPrint("MmDeletePageEntry(Address %x) Physical %x Free %d, "
+ DbgPrint("MmDeletePageEntry(Address %x) Physical %x "
"Entry %x\n",
- Address, PAGE_MASK(*page_tlb), MiNrFreePages,
+ Address, PAGE_MASK(*page_tlb),
*page_tlb);
KeBugCheck(0);
}
{
PHYSICAL_ADDRESS p;
- p.QuadPart = 0;
-
DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr);
- p.u.LowPart = PAGE_MASK(*MmGetPageEntry(vaddr));
- p.u.HighPart = 0;
+ p.QuadPart = PAGE_MASK(*MmGetPageEntry(vaddr));
return p;
}
-/* $Id: mminit.c,v 1.3 2000/07/07 10:30:56 dwelch Exp $
+/* $Id: mminit.c,v 1.4 2000/07/19 14:18:19 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
MmUserProbeAddress = (PVOID)0x7fff0000;
MmHighestUserAddress = (PVOID)0x7ffeffff;
+ /*
+ * Initialize memory managment statistics
+ */
+ MmStats.NrTotalPages = 0;
+ MmStats.NrSystemPages = 0;
+ MmStats.NrUserPages = 0;
+ MmStats.NrReservedPages = 0;
+ MmStats.NrUserPages = 0;
+ MmStats.NrFreePages = 0;
+ MmStats.NrLockedPages = 0;
+ MmStats.PagingRequestsInLastMinute = 0;
+ MmStats.PagingRequestsInLastFiveMinutes = 0;
+ MmStats.PagingRequestsInLastFifteenMinutes = 0;
+
+ /*
+ * Initialize the kernel address space
+ */
MmInitializeKernelAddressSpace();
/*
-/* $Id: pager.c,v 1.3 2000/07/06 14:34:51 dwelch Exp $
+/* $Id: pager.c,v 1.4 2000/07/19 14:18:19 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
LastProcess = PsGetNextProcess(LastProcess);
}
}
+ DbgPrint("Out of memory\n");
KeSetEvent(&FreedMemEvent, IO_NO_INCREMENT, FALSE);
}
}