5 modified files
reactos/drivers/video/videoprt
diff -u -r1.1.2.4 -r1.1.2.5
--- dispatch.c 14 Mar 2004 20:13:46 -0000 1.1.2.4
+++ dispatch.c 15 Mar 2004 17:02:14 -0000 1.1.2.5
@@ -18,11 +18,15 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: dispatch.c,v 1.1.2.4 2004/03/14 20:13:46 navaraf Exp $
+ * $Id: dispatch.c,v 1.1.2.5 2004/03/15 17:02:14 navaraf Exp $
*/
#include "videoprt.h"
+typedef PVOID PHAL_RESET_DISPLAY_PARAMETERS;
+VOID STDCALL HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
+VOID STDCALL HalReleaseDisplayOwnership();
+
/* GLOBAL VARIABLES ***********************************************************/
PVIDEO_PORT_DEVICE_EXTENSION ResetDisplayParametersDeviceExtension = NULL;
@@ -378,10 +382,30 @@
DPRINT("VidDispatchOpen\n");
+ if (CsrssInitialized == FALSE)
+ {
+ /*
+ * We know the first open call will be from the CSRSS process
+ * to let us know its handle.
+ */
+
+ DPRINT("Referencing CSRSS\n");
+ Csrss = PsGetCurrentProcess();
+ DPRINT("Csrss %p\n", Csrss);
+
+ CsrssInitialized = TRUE;
+
+ Irp->IoStatus.Information = FILE_OPENED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return STATUS_SUCCESS;
+ }
+
DriverExtension = IoGetDriverObjectExtension(
DeviceObject->DriverObject,
DeviceObject->DriverObject);
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
if (DriverExtension->InitializationData.HwInitialize(DeviceExtension->MiniPortDeviceExtension))
{
Irp->IoStatus.Status = STATUS_SUCCESS;
@@ -425,7 +449,8 @@
{
DPRINT("VidDispatchClose\n");
- HalReleaseDisplayOwnership();
+ if (ResetDisplayParametersDeviceExtension != NULL)
+ HalReleaseDisplayOwnership();
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -539,5 +564,4 @@
VOID STDCALL
VideoPortUnload(PDRIVER_OBJECT DriverObject)
{
- UnmapVideoAddressSpace();
}
reactos/drivers/video/videoprt
diff -u -r1.4.2.1 -r1.4.2.2
--- int10.c 14 Mar 2004 17:16:28 -0000 1.4.2.1
+++ int10.c 15 Mar 2004 17:02:14 -0000 1.4.2.2
@@ -18,7 +18,7 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: int10.c,v 1.4.2.1 2004/03/14 17:16:28 navaraf Exp $
+ * $Id: int10.c,v 1.4.2.2 2004/03/15 17:02:14 navaraf Exp $
*/
#include "videoprt.h"
@@ -35,22 +35,30 @@
{
PVOID MemoryAddress;
NTSTATUS Status;
+ PEPROCESS CallingProcess;
+ PEPROCESS PrevAttachedProcess;
DPRINT("IntInt10AllocateBuffer\n");
+ IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+
MemoryAddress = (PVOID)0x20000;
Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
Length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+
if (!NT_SUCCESS(Status))
{
DPRINT("- ZwAllocateVirtualMemory failed\n");
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return ERROR_NOT_ENOUGH_MEMORY;
}
+
if (MemoryAddress > (PVOID)(0x100000 - *Length))
{
ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, Length,
MEM_RELEASE);
DPRINT("- Unacceptable memory allocated\n");
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return ERROR_NOT_ENOUGH_MEMORY;
}
@@ -61,6 +69,8 @@
DPRINT("- Offset: %x\n", (ULONG)MemoryAddress & 0xFF);
DPRINT("- Length: %x\n", *Length);
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+
return NO_ERROR;
}
@@ -72,13 +82,17 @@
{
PVOID MemoryAddress = (PVOID)((Seg << 4) + Off);
NTSTATUS Status;
+ PEPROCESS CallingProcess;
+ PEPROCESS PrevAttachedProcess;
DPRINT("IntInt10FreeBuffer\n");
DPRINT("- Segment: %x\n", Seg);
DPRINT("- Offset: %x\n", Off);
+ IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
Status = ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
MEM_RELEASE);
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return Status;
}
@@ -91,13 +105,18 @@
OUT PVOID Buffer,
IN ULONG Length)
{
+ PEPROCESS CallingProcess;
+ PEPROCESS PrevAttachedProcess;
+
DPRINT("IntInt10ReadMemory\n");
DPRINT("- Segment: %x\n", Seg);
DPRINT("- Offset: %x\n", Off);
DPRINT("- Buffer: %x\n", Buffer);
DPRINT("- Length: %x\n", Length);
+ IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
RtlCopyMemory(Buffer, (PVOID)((Seg << 4) + Off), Length);
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return NO_ERROR;
}
@@ -110,13 +129,18 @@
IN PVOID Buffer,
IN ULONG Length)
{
+ PEPROCESS CallingProcess;
+ PEPROCESS PrevAttachedProcess;
+
DPRINT("IntInt10WriteMemory\n");
DPRINT("- Segment: %x\n", Seg);
DPRINT("- Offset: %x\n", Off);
DPRINT("- Buffer: %x\n", Buffer);
DPRINT("- Length: %x\n", Length);
+ IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
RtlCopyMemory((PVOID)((Seg << 4) + Off), Buffer, Length);
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return NO_ERROR;
}
@@ -128,9 +152,13 @@
{
KV86M_REGISTERS Regs;
NTSTATUS Status;
+ PEPROCESS CallingProcess;
+ PEPROCESS PrevAttachedProcess;
DPRINT("IntInt10CallBios\n");
+ IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+
memset(&Regs, 0, sizeof(Regs));
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
Regs.Eax = BiosArguments->Eax;
@@ -161,6 +189,8 @@
BiosArguments->SegDs = Regs.Ds;
BiosArguments->SegEs = Regs.Es;
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+
return Status;
}
@@ -177,9 +207,13 @@
{
KV86M_REGISTERS Regs;
NTSTATUS Status;
+ PEPROCESS CallingProcess;
+ PEPROCESS PrevAttachedProcess;
DPRINT("VideoPortInt10\n");
+ IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+
memset(&Regs, 0, sizeof(Regs));
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
Regs.Eax = BiosArguments->Eax;
@@ -197,5 +231,7 @@
Regs.Ebp = BiosArguments->Ebp;
Status = Ke386CallBios(0x10, &Regs);
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+
return Status;
}
reactos/drivers/video/videoprt
diff -u -r1.1.2.1 -r1.1.2.2
--- resource.c 14 Mar 2004 17:16:28 -0000 1.1.2.1
+++ resource.c 15 Mar 2004 17:02:14 -0000 1.1.2.2
@@ -18,153 +18,13 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: resource.c,v 1.1.2.1 2004/03/14 17:16:28 navaraf Exp $
+ * $Id: resource.c,v 1.1.2.2 2004/03/15 17:02:14 navaraf Exp $
*/
#include "videoprt.h"
/* PRIVATE FUNCTIONS **********************************************************/
-/*
- * MapVideoAddressSpace
- *
- * This function maps the BIOS memory into our virtual address space and
- * setups real-mode interrupt table.
- */
-
-BOOL FASTCALL
-MapVideoAddressSpace(VOID)
-{
- NTSTATUS Status;
- PVOID BaseAddress;
- PVOID NullAddress;
- ULONG ViewSize;
- CHAR IVT[1024];
- CHAR BDA[256];
- LARGE_INTEGER Offset;
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING PhysMemName;
- HANDLE PhysMemHandle;
-
- /*
- * Open the physical memory section
- */
-
- RtlInitUnicodeString(&PhysMemName, L"\\Device\\PhysicalMemory");
- InitializeObjectAttributes(&ObjectAttributes, &PhysMemName, 0, NULL, NULL);
- Status = ZwOpenSection(&PhysMemHandle, SECTION_ALL_ACCESS, &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- DPRINT(("VBEMP: Couldn't open \\Device\\PhysicalMemory\n"));
- return FALSE;
- }
-
- /*
- * Map the BIOS and device registers into the address space
- */
-
- Offset.QuadPart = 0xa0000;
- ViewSize = 0x30000;
- BaseAddress = (PVOID)0xa0000;
- Status = ZwMapViewOfSection(PhysMemHandle, NtCurrentProcess(), &BaseAddress,
- 0, 8192, &Offset, &ViewSize, ViewUnmap, 0, PAGE_EXECUTE_READWRITE);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT("Couldn't map physical memory (%x)\n", Status);
- NtClose(PhysMemHandle);
- return FALSE;
- }
-
- NtClose(PhysMemHandle);
-
- if (BaseAddress != (PVOID)0xa0000)
- {
- DPRINT("Couldn't map physical memory at the right address "
- "(was %x)\n", BaseAddress);
- return FALSE;
- }
-
- /*
- * Map some memory to use for the non-BIOS parts of the v86 mode address
- * space
- */
-
- BaseAddress = (PVOID)0x1;
- ViewSize = 0x20000;
- Status = ZwAllocateVirtualMemory(
- NtCurrentProcess(),
- &BaseAddress,
- 0,
- &ViewSize,
- MEM_COMMIT,
- PAGE_EXECUTE_READWRITE);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT("Failed to allocate virtual memory (Status %x)\n", Status);
- return FALSE;
- }
-
- if (BaseAddress != (PVOID)0x0)
- {
- DPRINT("Failed to allocate virtual memory at right address "
- "(was %x)\n", BaseAddress);
- return FALSE;
- }
-
- /*
- * Get the real mode IVT from the kernel
- */
-
- Status = NtVdmControl(0, IVT);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("NtVdmControl failed (status %x)\n", Status);
- return 0;
- }
-
- /*
- * Copy the real mode IVT into the right place
- */
-
- NullAddress = (PVOID)0x0; /* Workaround for GCC 3.4 */
- RtlCopyMemory(NullAddress, IVT, 1024);
-
- /*
- * Get the BDA from the kernel
- */
-
- Status = NtVdmControl(1, BDA);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("NtVdmControl failed (status %x)\n", Status);
- return FALSE;
- }
-
- /*
- * Copy the BDA into the right place
- */
-
- RtlCopyMemory((PVOID)0x400, BDA, 256);
-
- return TRUE;
-}
-
-/*
- * UnmapVideoAddressSpace
- *
- * This function unmaps the BIOS memory from our virtual address space that
- * was mapped by MapVideoAddressSpace.
- */
-
-VOID FASTCALL
-UnmapVideoAddressSpace(VOID)
-{
- /* FIXME */
- DPRINT1("UnmapVideoAddressSpace: Unimplemented.\n");
-}
-
PVOID STDCALL
InternalMapMemory(
IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
reactos/drivers/video/videoprt
diff -u -r1.21.2.1 -r1.21.2.2
--- videoprt.c 14 Mar 2004 17:16:28 -0000 1.21.2.1
+++ videoprt.c 15 Mar 2004 17:02:14 -0000 1.21.2.2
@@ -18,10 +18,16 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: videoprt.c,v 1.21.2.1 2004/03/14 17:16:28 navaraf Exp $
+ * $Id: videoprt.c,v 1.21.2.2 2004/03/15 17:02:14 navaraf Exp $
*/
#include "videoprt.h"
+#include "internal/ps.h"
+
+/* GLOBAL VARIABLES ***********************************************************/
+
+ULONG CsrssInitialized = FALSE;
+PEPROCESS Csrss = NULL;
/* PRIVATE FUNCTIONS **********************************************************/
@@ -111,6 +117,38 @@
return NULL;
}
+VOID FASTCALL
+IntAttachToCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess)
+{
+ *CallingProcess = PsGetCurrentProcess();
+ if (*CallingProcess != Csrss)
+ {
+ if (PsGetCurrentThread()->OldProcess != NULL)
+ {
+ *PrevAttachedProcess = *CallingProcess;
+ KeDetachProcess();
+ }
+ else
+ {
+ *PrevAttachedProcess = NULL;
+ }
+ KeAttachProcess(Csrss);
+ }
+}
+
+VOID FASTCALL
+IntDetachFromCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess)
+{
+ if (*CallingProcess != Csrss)
+ {
+ KeDetachProcess();
+ if (NULL != *PrevAttachedProcess)
+ {
+ KeAttachProcess(*PrevAttachedProcess);
+ }
+ }
+}
+
/* PUBLIC FUNCTIONS ***********************************************************/
/*
@@ -143,11 +181,6 @@
return STATUS_UNSUCCESSFUL;
}
- if (!MapVideoAddressSpace())
- {
- return STATUS_UNSUCCESSFUL;
- }
-
Status = IoAllocateDriverObjectExtension(
DriverObject,
DriverObject,
@@ -427,6 +460,8 @@
IN ULONG Length)
{
static PVOID RomImageBuffer = NULL;
+ PEPROCESS CallingProcess;
+ PEPROCESS PrevAttachedProcess;
DPRINT("VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
HwDeviceExtension, Length);
@@ -463,7 +498,9 @@
return NULL;
}
+ IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
+ IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return RomImageBuffer;
}
reactos/drivers/video/videoprt
diff -u -r1.6.2.1 -r1.6.2.2
--- videoprt.h 14 Mar 2004 17:16:28 -0000 1.6.2.1
+++ videoprt.h 15 Mar 2004 17:02:14 -0000 1.6.2.2
@@ -18,7 +18,7 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: videoprt.h,v 1.6.2.1 2004/03/14 17:16:28 navaraf Exp $
+ * $Id: videoprt.h,v 1.6.2.2 2004/03/15 17:02:14 navaraf Exp $
*/
#ifndef VIDEOPRT_H
@@ -31,11 +31,8 @@
/* #define NDEBUG */
#include <debug.h>
-typedef PVOID PHAL_RESET_DISPLAY_PARAMETERS;
int swprintf(wchar_t *buf, const wchar_t *fmt, ...);
int vsprintf(char *buf, const char *fmt, va_list args);
-VOID STDCALL HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
-VOID STDCALL HalReleaseDisplayOwnership();
BOOLEAN STDCALL HalDisableSystemInterrupt(ULONG Vector, ULONG Unknown2);
BOOLEAN STDCALL HalEnableSystemInterrupt(ULONG Vector, ULONG Unknown2, ULONG Unknown3);
PIMAGE_NT_HEADERS STDCALL RtlImageNtHeader(IN PVOID BaseAddress);
@@ -132,21 +129,22 @@
IN struct _KINTERRUPT *Interrupt,
IN PVOID ServiceContext);
-/* resource.c */
-
-BOOL FASTCALL
-MapVideoAddressSpace(VOID);
-
-VOID FASTCALL
-UnmapVideoAddressSpace(VOID);
-
/* videoprt.c */
+extern ULONG CsrssInitialized;
+extern PEPROCESS Csrss;
+
PVOID STDCALL
VideoPortGetProcAddress(
IN PVOID HwDeviceExtension,
IN PUCHAR FunctionName);
+VOID FASTCALL
+IntAttachToCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess);
+
+VOID FASTCALL
+IntDetachFromCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess);
+
/* int10.c */
VP_STATUS STDCALL
CVSspam 0.2.8