mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 12:45:16 +00:00
[FORMATTING]
- Reformat to the kernel coding style. svn path=/trunk/; revision=36426
This commit is contained in:
parent
7a0cd51dea
commit
55ea8c5583
|
@ -1,115 +1,117 @@
|
|||
/* $Id$
|
||||
*
|
||||
* ReactOS Project
|
||||
/*
|
||||
* PROJECT: ReactOS Client/Server Runtime subsystem
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: subsystems/win32/csrss/video.c
|
||||
* PURPOSE: Video memory initialization.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <csrss.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
ULONG
|
||||
InitializeVideoAddressSpace(VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING PhysMemName = RTL_CONSTANT_STRING(L"\\Device\\PhysicalMemory");
|
||||
NTSTATUS Status;
|
||||
HANDLE PhysMemHandle;
|
||||
PVOID BaseAddress;
|
||||
PVOID NullAddress;
|
||||
LARGE_INTEGER Offset;
|
||||
ULONG ViewSize;
|
||||
CHAR IVTAndBda[1024+256];
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING PhysMemName = RTL_CONSTANT_STRING(L"\\Device\\PhysicalMemory");
|
||||
NTSTATUS Status;
|
||||
HANDLE PhysMemHandle;
|
||||
PVOID BaseAddress;
|
||||
PVOID NullAddress;
|
||||
LARGE_INTEGER Offset;
|
||||
ULONG ViewSize;
|
||||
CHAR IVTAndBda[1024+256];
|
||||
|
||||
/*
|
||||
* Open the physical memory section
|
||||
*/
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&PhysMemName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = ZwOpenSection(&PhysMemHandle, SECTION_ALL_ACCESS,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("Couldn't open \\Device\\PhysicalMemory\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Map the BIOS and device registers into the address space
|
||||
*/
|
||||
Offset.QuadPart = 0xa0000;
|
||||
ViewSize = 0x100000 - 0xa0000;
|
||||
BaseAddress = (PVOID)0xa0000;
|
||||
Status = NtMapViewOfSection(PhysMemHandle,
|
||||
NtCurrentProcess(),
|
||||
&BaseAddress,
|
||||
0,
|
||||
8192,
|
||||
&Offset,
|
||||
&ViewSize,
|
||||
ViewUnmap,
|
||||
0,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("Couldn't map physical memory (%x)\n", Status);
|
||||
NtClose(PhysMemHandle);
|
||||
return(0);
|
||||
}
|
||||
NtClose(PhysMemHandle);
|
||||
if (BaseAddress != (PVOID)0xa0000)
|
||||
{
|
||||
DbgPrint("Couldn't map physical memory at the right address "
|
||||
"(was %x)\n", BaseAddress);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Map some memory to use for the non-BIOS parts of the v86 mode address
|
||||
* space
|
||||
*/
|
||||
BaseAddress = (PVOID)0x1;
|
||||
ViewSize = 0xa0000 - 0x1000;
|
||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||
&BaseAddress,
|
||||
0,
|
||||
&ViewSize,
|
||||
MEM_COMMIT,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("Failed to allocate virtual memory (Status %x)\n", Status);
|
||||
return(0);
|
||||
}
|
||||
if (BaseAddress != (PVOID)0x0)
|
||||
{
|
||||
DbgPrint("Failed to allocate virtual memory at right address "
|
||||
"(was %x)\n", BaseAddress);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the real mode IVT and BDA from the kernel
|
||||
*/
|
||||
Status = NtVdmControl(VdmInitialize, IVTAndBda);
|
||||
/* Open the physical memory section */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&PhysMemName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = ZwOpenSection(&PhysMemHandle,
|
||||
SECTION_ALL_ACCESS,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("NtVdmControl failed (status %x)\n", Status);
|
||||
return(0);
|
||||
}
|
||||
{
|
||||
DPRINT1("Couldn't open \\Device\\PhysicalMemory\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the IVT and BDA into the right place
|
||||
*/
|
||||
NullAddress = (PVOID)0x0; /* Workaround for GCC 3.4 */
|
||||
memcpy(NullAddress, IVTAndBda, 1024);
|
||||
memcpy((PVOID)0x400, &IVTAndBda[1024], 256);
|
||||
/* Map the BIOS and device registers into the address space */
|
||||
Offset.QuadPart = 0xa0000;
|
||||
ViewSize = 0x100000 - 0xa0000;
|
||||
BaseAddress = (PVOID)0xa0000;
|
||||
Status = NtMapViewOfSection(PhysMemHandle,
|
||||
NtCurrentProcess(),
|
||||
&BaseAddress,
|
||||
0,
|
||||
8192,
|
||||
&Offset,
|
||||
&ViewSize,
|
||||
ViewUnmap,
|
||||
0,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Couldn't map physical memory (%x)\n", Status);
|
||||
NtClose(PhysMemHandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return(1);
|
||||
/* Close physical memory section handle */
|
||||
NtClose(PhysMemHandle);
|
||||
|
||||
if (BaseAddress != (PVOID)0xa0000)
|
||||
{
|
||||
DPRINT1("Couldn't map physical memory at the right address "
|
||||
"(was %x)\n", BaseAddress);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Map some memory to use for the non-BIOS parts of
|
||||
* the v86 mode address space
|
||||
*/
|
||||
BaseAddress = (PVOID)0x1;
|
||||
ViewSize = 0xa0000 - 0x1000;
|
||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||
&BaseAddress,
|
||||
0,
|
||||
&ViewSize,
|
||||
MEM_COMMIT,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Failed to allocate virtual memory (Status %x)\n", Status);
|
||||
return 0;
|
||||
}
|
||||
if (BaseAddress != (PVOID)0x0)
|
||||
{
|
||||
DPRINT1("Failed to allocate virtual memory at right address "
|
||||
"(was %x)\n", BaseAddress);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get the real mode IVT and BDA from the kernel */
|
||||
Status = NtVdmControl(VdmInitialize, IVTAndBda);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("NtVdmControl failed (status %x)\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the IVT and BDA into the right place */
|
||||
NullAddress = (PVOID)0x0; /* Workaround for GCC 3.4 */
|
||||
memcpy(NullAddress, IVTAndBda, 1024);
|
||||
memcpy((PVOID)0x400, &IVTAndBda[1024], 256);
|
||||
|
||||
/* Return success */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue