Fixes for page list initialization

V86 mode fixes

svn path=/trunk/; revision=1736
This commit is contained in:
David Welch 2001-03-26 20:46:53 +00:00
parent 51a205bc71
commit 8c86bcfe89
10 changed files with 263 additions and 291 deletions

View file

@ -1,5 +1,6 @@
file ntoskrnl/ntoskrnl.nostrip.exe file ntoskrnl/ntoskrnl.nostrip.exe
#add-symbol-file lib/ntdll/ntdll.dll 0x77f61000 #add-symbol-file lib/ntdll/ntdll.dll 0x77f61000
add-symbol-file lib/kernel32/kernel32.dll 0x77f01000
#add-symbol-file apps/exp/exp.exe 0x401000 #add-symbol-file apps/exp/exp.exe 0x401000
#add-symbol-file subsys/csrss/csrss.exe 0x401000 #add-symbol-file subsys/csrss/csrss.exe 0x401000
#add-symbol-file subsys/smss/smss.exe 0x401000 #add-symbol-file subsys/smss/smss.exe 0x401000

View file

@ -39,12 +39,14 @@ typedef struct _KTSS
USHORT Reserved6; USHORT Reserved6;
USHORT Ss; USHORT Ss;
USHORT Reserved7; USHORT Reserved7;
USHORT Fs; USHORT Ds;
USHORT Reserved8; USHORT Reserved8;
USHORT Gs; USHORT Fs;
USHORT Reserved9; USHORT Reserved9;
USHORT Ldt; USHORT Gs;
USHORT Reserved10; USHORT Reserved10;
USHORT Ldt;
USHORT Reserved11;
USHORT Trap; USHORT Trap;
USHORT IoMapBase; USHORT IoMapBase;
UCHAR IoBitmap[1]; UCHAR IoBitmap[1];

View file

@ -1,4 +1,4 @@
/* $Id: atom.c,v 1.9 2000/07/01 17:07:00 ea Exp $ /* $Id: atom.c,v 1.10 2001/03/26 20:46:52 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -97,25 +97,20 @@ DeleteAtom(
ATOM ATOM STDCALL
STDCALL GlobalAddAtomA(LPCSTR lpString)
GlobalAddAtomA(
LPCSTR lpString
)
{ {
UINT BufLen = strlen(lpString); UINT BufLen = strlen(lpString);
WCHAR * lpBuffer = (WCHAR *) HeapAlloc( WCHAR* lpBuffer;
GetProcessHeap(),
(HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY),
(BufLen * sizeof (WCHAR))
);
ATOM atom; ATOM atom;
lpBuffer = (WCHAR *) HeapAlloc(GetProcessHeap(),
(HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY),
(BufLen * sizeof (WCHAR)));
ansi2unicode(lpBuffer, lpString, BufLen); ansi2unicode(lpBuffer, lpString, BufLen);
atom = AWGLAddAtom(&GlobalAtomTable, lpBuffer); atom = AWGLAddAtom(&GlobalAtomTable, lpBuffer);
HeapFree(GetProcessHeap(), 0, lpBuffer); HeapFree(GetProcessHeap(), 0, lpBuffer);
return atom; return(atom);
} }
@ -300,9 +295,7 @@ GLDeleteAtom(
ATOM ATOM
AWGLAddAtom( AWGLAddAtom(ATOMTABLE *at, const WCHAR *lpString)
ATOMTABLE *at, const WCHAR *lpString
)
{ {
ATOM atom; ATOM atom;
ATOMID q; ATOMID q;
@ -311,10 +304,9 @@ AWGLAddAtom(
int atomlen; int atomlen;
int newlen; int newlen;
/* if we already have it, bump refcnt */ /* if we already have it, bump refcnt */
if((atom = AWGLFindAtom(at, lpString ))) { if((atom = AWGLFindAtom(at, lpString )))
{
lp = GetAtomPointer(at,atom - ATOMBASE); lp = GetAtomPointer(at,atom - ATOMBASE);
if(lp->idsize) lp->refcnt++; if(lp->idsize) lp->refcnt++;
return atom; return atom;
@ -326,11 +318,15 @@ AWGLAddAtom(
lpfree = 0; lpfree = 0;
freeindex = 0; freeindex = 0;
for(index = 0;(lp = GetAtomPointer(at,index));index++) { for(index = 0;(lp = GetAtomPointer(at,index));index++)
if(lp->q == 0 && lp->refcnt == 0) { {
if(lp->idsize > atomlen) { if(lp->q == 0 && lp->refcnt == 0)
{
if(lp->idsize > atomlen)
{
if ((lpfree == 0) || if ((lpfree == 0) ||
(lpfree->idsize > lp->idsize)) { (lpfree->idsize > lp->idsize))
{
lpfree = lp; lpfree = lp;
freeindex = index; freeindex = index;
} }
@ -339,7 +335,8 @@ AWGLAddAtom(
} }
/* intatoms do not take space in data, but do get new entries */ /* intatoms do not take space in data, but do get new entries */
/* an INTATOM will have length of 0 */ /* an INTATOM will have length of 0 */
if(lpfree && atomlen) { if(lpfree && atomlen)
{
lpfree->q = q; lpfree->q = q;
lpfree->refcnt = 1; lpfree->refcnt = 1;
lstrcpynW(&at->AtomData[lpfree->idx],lpString,atomlen); lstrcpynW(&at->AtomData[lpfree->idx],lpString,atomlen);
@ -348,12 +345,15 @@ AWGLAddAtom(
/* no space was available, or we have an INTATOM */ /* no space was available, or we have an INTATOM */
/* so expand or create the table */ /* so expand or create the table */
if(at->AtomTable == 0) { if(at->AtomTable == 0)
{
at->AtomTable = (ATOMENTRY *) HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(ATOMENTRY)); at->AtomTable = (ATOMENTRY *) HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(ATOMENTRY));
at->TableSize = 1; at->TableSize = 1;
lp = at->AtomTable; lp = at->AtomTable;
index = 0; index = 0;
} else { }
else
{
at->TableSize++; at->TableSize++;
at->AtomTable = (ATOMENTRY *) HeapReAlloc(GetProcessHeap(),0, at->AtomTable = (ATOMENTRY *) HeapReAlloc(GetProcessHeap(),0,
(LPVOID) at->AtomTable, (LPVOID) at->AtomTable,
@ -397,9 +397,7 @@ AWGLAddAtom(
ATOM ATOM
AWGLFindAtom( AWGLFindAtom(ATOMTABLE *at, const WCHAR *lpString)
ATOMTABLE *at, const WCHAR *lpString
)
{ {
ATOMID q; ATOMID q;
@ -408,8 +406,6 @@ AWGLFindAtom(
int atomlen; int atomlen;
/* convert string to 'q', and get length */ /* convert string to 'q', and get length */
q = AtomHashString(lpString,&atomlen); q = AtomHashString(lpString,&atomlen);

View file

@ -13,12 +13,13 @@
#include <user32/dce.h> #include <user32/dce.h>
#include <user32/heapdup.h> #include <user32/heapdup.h>
CLASS *rootClass; CLASS *rootClass;
ATOM STDCALL RegisterClassA(const WNDCLASS* wc) ATOM STDCALL
RegisterClassA(const WNDCLASS* wc)
{ {
WNDCLASSEX wcex; WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX); wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = wc->style; wcex.style = wc->style;
wcex.lpfnWndProc = wc->lpfnWndProc; wcex.lpfnWndProc = wc->lpfnWndProc;
@ -34,9 +35,11 @@ ATOM STDCALL RegisterClassA(const WNDCLASS* wc)
return RegisterClassExA(&wcex); return RegisterClassExA(&wcex);
} }
ATOM STDCALL RegisterClassW(const WNDCLASS* wc) ATOM STDCALL
RegisterClassW(const WNDCLASS* wc)
{ {
WNDCLASSEX wcex; WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX); wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = wc->style; wcex.style = wc->style;
wcex.lpfnWndProc = wc->lpfnWndProc; wcex.lpfnWndProc = wc->lpfnWndProc;
@ -52,15 +55,16 @@ ATOM STDCALL RegisterClassW(const WNDCLASS* wc)
return RegisterClassExW(&wcex); return RegisterClassExW(&wcex);
} }
ATOM STDCALL RegisterClassExA(const WNDCLASSEX* wc) ATOM STDCALL
RegisterClassExA(const WNDCLASSEX* wc)
{ {
ATOM atom; ATOM atom;
CLASS *classPtr; CLASS *classPtr;
INT classExtra, winExtra; INT classExtra, winExtra;
int len; int len;
if (wc == NULL || wc->cbSize != sizeof(WNDCLASSEX))
if ( wc == NULL || wc->cbSize != sizeof(WNDCLASSEX)) { {
SetLastError(ERROR_INVALID_DATA); SetLastError(ERROR_INVALID_DATA);
return FALSE; return FALSE;
} }

View file

@ -196,6 +196,7 @@ HalInitFirstTask(PETHREAD thread)
KiTss.Esp0 = (ULONG)&init_stack_top; KiTss.Esp0 = (ULONG)&init_stack_top;
KiTss.Ss0 = KERNEL_DS; KiTss.Ss0 = KERNEL_DS;
KiTss.IoMapBase = FIELD_OFFSET(KTSS, IoBitmap); KiTss.IoMapBase = FIELD_OFFSET(KTSS, IoBitmap);
//KiTss.IoMapBase = 0xFFFF;
KiTss.IoBitmap[0] = 0xFF; KiTss.IoBitmap[0] = 0xFF;
KiTss.Ldt = LDT_SELECTOR; KiTss.Ldt = LDT_SELECTOR;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: main.c,v 1.83 2001/03/25 02:34:28 dwelch Exp $ /* $Id: main.c,v 1.84 2001/03/26 20:46:53 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c * FILE: ntoskrnl/ke/main.c
@ -377,65 +377,6 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
} }
} }
extern NTSTATUS STDCALL
Ke386CallBios(UCHAR Int, KV86M_REGISTERS* Regs);
struct __attribute__((packed)) vesa_info
{
UCHAR Signature[4];
USHORT Version;
ULONG OEMName;
ULONG Capabilities;
ULONG SupportedModes;
USHORT TotalVideoMemory;
USHORT OEMVersion;
ULONG VendorName;
ULONG ProductName;
ULONG ProductRevisionString;
UCHAR Reserved[478];
};
VOID
TestV86Mode(VOID)
{
ULONG i;
extern UCHAR OrigIVT[1024];
KV86M_REGISTERS regs;
NTSTATUS Status;
struct vesa_info* vi;
for (i = 0; i < (640 / 4); i++)
{
MmCreateVirtualMapping(NULL,
(PVOID)(i * 4096),
PAGE_EXECUTE_READWRITE,
(ULONG)MmAllocPage(0));
}
for (; i < (1024 / 4); i++)
{
MmCreateVirtualMapping(NULL,
(PVOID)(i * 4096),
PAGE_EXECUTE_READ,
i * 4096);
}
vi = (struct vesa_info*)0x20000;
vi->Signature[0] = 'V';
vi->Signature[1] = 'B';
vi->Signature[2] = 'E';
vi->Signature[3] = '2';
memset(&regs, 0, sizeof(regs));
regs.Eax = 0x4F00;
regs.Es = 0x2000;
regs.Edi = 0x0;
memcpy((PVOID)0x0, OrigIVT, 1024);
Status = Ke386CallBios(0x10, &regs);
DbgPrint("Finished (Status %x, CS:EIP %x:%x)\n", Status, regs.Cs,
regs.Eip);
DbgPrint("Eax %x\n", regs.Eax);
DbgPrint("Signature %.4s\n", vi->Signature);
DbgPrint("TotalVideoMemory %dKB\n", vi->TotalVideoMemory * 64);
}
VOID VOID
_main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock) _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
/* /*

View file

@ -45,6 +45,12 @@ static KSPIN_LOCK PageListLock;
static LIST_ENTRY FreePageListHead; static LIST_ENTRY FreePageListHead;
static LIST_ENTRY BiosPageListHead; static LIST_ENTRY BiosPageListHead;
NTSTATUS
MmCreateVirtualMappingUnsafe(struct _EPROCESS* Process,
PVOID Address,
ULONG flProtect,
ULONG PhysicalAddress);
/* FUNCTIONS *************************************************************/ /* FUNCTIONS *************************************************************/
PVOID PVOID
@ -163,7 +169,8 @@ PVOID MmInitializePageList(PVOID FirstPhysKernelAddress,
if (!MmIsPagePresent(NULL, if (!MmIsPagePresent(NULL,
(PVOID)((ULONG)MmPageArray + (i * PAGESIZE)))) (PVOID)((ULONG)MmPageArray + (i * PAGESIZE))))
{ {
Status = MmCreateVirtualMapping(NULL, Status =
MmCreateVirtualMappingUnsafe(NULL,
(PVOID)((ULONG)MmPageArray + (PVOID)((ULONG)MmPageArray +
(i * PAGESIZE)), (i * PAGESIZE)),
PAGE_READWRITE, PAGE_READWRITE,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: page.c,v 1.24 2001/03/25 02:34:29 dwelch Exp $ /* $Id: page.c,v 1.25 2001/03/26 20:46:53 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/i386/page.c * FILE: ntoskrnl/mm/i386/page.c
@ -583,8 +583,8 @@ BOOLEAN MmIsPagePresent(PEPROCESS Process, PVOID Address)
return((MmGetPageEntryForProcess1(Process, Address)) & PA_PRESENT); return((MmGetPageEntryForProcess1(Process, Address)) & PA_PRESENT);
} }
NTSTATUS
NTSTATUS MmCreateVirtualMapping(PEPROCESS Process, MmCreateVirtualMappingUnsafe(PEPROCESS Process,
PVOID Address, PVOID Address,
ULONG flProtect, ULONG flProtect,
ULONG PhysicalAddress) ULONG PhysicalAddress)
@ -594,11 +594,6 @@ NTSTATUS MmCreateVirtualMapping(PEPROCESS Process,
PULONG Pte; PULONG Pte;
NTSTATUS Status; NTSTATUS Status;
if (!MmIsUsablePage((PVOID)PhysicalAddress))
{
DPRINT1("Page not usable\n");
KeBugCheck(0);
}
if (Process == NULL && Address < (PVOID)KERNEL_BASE) if (Process == NULL && Address < (PVOID)KERNEL_BASE)
{ {
DPRINT1("No process\n"); DPRINT1("No process\n");
@ -651,6 +646,23 @@ NTSTATUS MmCreateVirtualMapping(PEPROCESS Process,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS
MmCreateVirtualMapping(PEPROCESS Process,
PVOID Address,
ULONG flProtect,
ULONG PhysicalAddress)
{
if (!MmIsUsablePage((PVOID)PhysicalAddress))
{
DPRINT1("Page not usable\n");
KeBugCheck(0);
}
return(MmCreateVirtualMappingUnsafe(Process,
Address,
flProtect,
PhysicalAddress));
}
ULONG ULONG
MmGetPageProtect(PEPROCESS Process, PVOID Address) MmGetPageProtect(PEPROCESS Process, PVOID Address)
{ {

View file

@ -1,4 +1,4 @@
/* $Id: mminit.c,v 1.15 2001/03/25 02:34:28 dwelch Exp $ /* $Id: mminit.c,v 1.16 2001/03/26 20:46:53 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top directory * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -232,7 +232,7 @@ VOID MmInit1(ULONG FirstKrnlPhysAddr,
/* add 1MB for standard memory (not extended) */ /* add 1MB for standard memory (not extended) */
MmStats.NrTotalPages += 256; MmStats.NrTotalPages += 256;
} }
DbgPrint("Used memory %d\n", MmStats.NrTotalPages * PAGESIZE); DbgPrint("Used memory %dKb\n", (MmStats.NrTotalPages * PAGESIZE) / 1024);
LastKernelAddress = (ULONG)MmInitializePageList( LastKernelAddress = (ULONG)MmInitializePageList(
(PVOID)FirstKrnlPhysAddr, (PVOID)FirstKrnlPhysAddr,

View file

@ -1,4 +1,4 @@
/* $Id: services.c,v 1.2 2001/01/20 18:39:35 ekohl Exp $ /* $Id: services.c,v 1.3 2001/03/26 20:46:52 dwelch Exp $
* *
* service control manager * service control manager
* *
@ -93,6 +93,7 @@ WinMain(HINSTANCE hInstance,
int nShowCmd) int nShowCmd)
{ {
HANDLE hScmStartEvent; HANDLE hScmStartEvent;
HANDLE hEvent;
PrintString("Service Control Manager\n"); PrintString("Service Control Manager\n");
@ -138,10 +139,17 @@ WinMain(HINSTANCE hInstance,
PrintString("SERVICES: Running.\n"); PrintString("SERVICES: Running.\n");
hEvent = CreateEvent(NULL,
TRUE,
FALSE,
NULL);
WaitForSingleObject(hEvent, INFINITE);
#if 0
for (;;) for (;;)
{ {
NtYieldExecution(); NtYieldExecution();
} }
#endif
PrintString("SERVICES: Finished.\n"); PrintString("SERVICES: Finished.\n");