Multiboot fixes

svn path=/trunk/; revision=1529
This commit is contained in:
David Welch 2001-01-17 15:38:03 +00:00
parent 695a57cff6
commit 7a3409d80c
7 changed files with 112 additions and 80 deletions

View file

@ -1,8 +1,8 @@
#!/bin/sh
echo "Installing to floppy."
mount -t vfat /bochs/1.44a /mnt/floppy -o loop,rw
./install-system.sh /mnt/floppy
umount /mnt/floppy
#echo "Installing to floppy."
#mount -t vfat /bochs/1.44a /mnt/floppy -o loop,rw
#./install-system.sh /mnt/floppy
#umount /mnt/floppy
echo "Installing to disk."
mount -t vfat /bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw
./install.sh /mnt/floppy

View file

@ -266,51 +266,57 @@ entry:
mov [_multiboot_cmdline], eax
add dword [_multiboot_cmdline], _multiboot_kernel_cmdline
;;
;; Hide the kernel's entry in the list of modules
;;
mov [_multiboot_mods_addr], eax
add dword [_multiboot_mods_addr], _multiboot_modules
mov ebx, _multiboot_modules
add ebx, multiboot_module_size
add dword [_multiboot_mods_addr], ebx
dec dword [_multiboot_mods_count]
;;
;; get extended memory size in KB
;;
push ebx
xor ebx,ebx
mov [_multiboot_mem_upper],ebx
mov [_multiboot_mem_lower],ebx
mov ax, 0xe801
int 015h
cmp ebx,ebx
jz .oldstylemem
push ebx
xor ebx,ebx
mov [_multiboot_mem_lower],ebx
mov ax, 0xe801
int 015h
cmp ebx,ebx
jz .oldstylemem
and ebx, 0xffff
shl ebx,6
mov [_multiboot_mem_lower],ebx
and eax,0xffff
add dword [_multiboot_mem_lower],eax
jmp .done_mem
and ebx, 0xffff
shl ebx,6
mov [_multiboot_mem_upper],ebx
and eax,0xffff
add dword [_multiboot_mem_upper],eax
jmp .done_mem
.oldstylemem:
;; int 15h opt e801 don't work , try int 15h, option 88h
mov ah, 088h
int 015h
cmp ax,ax
jz .cmosmem
mov [_multiboot_mem_lower],ax
jmp .done_mem
mov ah, 088h
int 015h
cmp ax,ax
jz .cmosmem
mov [_multiboot_mem_upper],ax
jmp .done_mem
.cmosmem:
;; int 15h opt 88h don't work , try read cmos
xor eax,eax
mov al, 0x31
out 0x70, al
in al, 0x71
and eax, 0xffff ; clear carry
shl eax,8
mov [_multiboot_mem_lower],eax
;; xor eax,eax
;; mov al, 0x30
;; out 0x70, al
;; in al, 0x71
;; and eax, 0xffff ; clear carry
;; add [_multiboot_mem_lower],eax
xor eax,eax
mov al, 0x31
out 0x70, al
in al, 0x71
and eax, 0xffff ; clear carry
shl eax,8
mov [_multiboot_mem_upper],eax
;; xor eax,eax
;; mov al, 0x30
;; out 0x70, al
;; in al, 0x71
;; and eax, 0xffff ; clear carry
;; add [_multiboot_mem_lower],eax
.done_mem:
pop ebx

View file

@ -89,11 +89,28 @@ BOOLEAN KiDeliverUserApc(PKTRAP_FRAME TrapFrame)
PCONTEXT Context;
KIRQL oldlvl;
PKTHREAD Thread;
PETHREAD EThread;
DPRINT("KiDeliverUserApc(TrapFrame %x/%x)\n", TrapFrame,
KeGetCurrentThread()->TrapFrame);
Thread = KeGetCurrentThread();
KeAcquireSpinLock(&PiApcLock, &oldlvl);
/*
* Check for thread termination
*/
KeAcquireSpinLock(&PiThreadListLock, &oldlvl);
EThread = CONTAINING_RECORD(Thread, ETHREAD, Tcb);
if (EThread->DeadThread)
{
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
PsTerminateCurrentThread(EThread->ExitStatus);
}
else
{
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
}
current_entry = Thread->ApcState.ApcListHead[1].Flink;
/*
@ -174,20 +191,6 @@ BOOLEAN KiDeliverUserApc(PKTRAP_FRAME TrapFrame)
(PVOID*)&Esp[3],
(PVOID*)&Esp[4]);
#if 0
KeAcquireSpinLock(&PiThreadListLock, &oldlvl);
EThread = CONTAINING_RECORD(Thread, ETHREAD, Tcb);
if (EThread->DeadThread)
{
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
PsTerminateCurrentThread(EThread->ExitStatus);
}
else
{
KeReleaseSpinLock(&PiThreadListLock, oldlvl);
}
return ret;
#endif
return(TRUE);
}
@ -231,10 +234,11 @@ VOID STDCALL KiDeliverApc(ULONG Unknown1,
// Thread->Tcb.WaitStatus = STATUS_KERNEL_APC;
}
VOID STDCALL KeInsertQueueApc (PKAPC Apc,
PVOID SystemArgument1,
PVOID SystemArgument2,
UCHAR Mode)
VOID STDCALL
KeInsertQueueApc (PKAPC Apc,
PVOID SystemArgument1,
PVOID SystemArgument2,
UCHAR Mode)
/*
* FUNCTION: Queues an APC for execution
* ARGUMENTS:

View file

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.73 2001/01/14 15:30:47 ekohl Exp $
/* $Id: main.c,v 1.74 2001/01/17 15:38:02 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -84,13 +84,13 @@ CreateSystemRootLink (PCSZ ParameterLine)
RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
}
DPRINT("Arc name: %s\n", ParamBuffer);
/* Only arc name left - build full arc name */
ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
swprintf (ArcNameBuffer,
L"\\ArcName\\%S", ParamBuffer);
RtlInitUnicodeString (&ArcName, ArcNameBuffer);
DPRINT("Arc name: %wZ\n", &ArcName);
DPRINT1("Arc name: %wZ\n", &ArcName);
/* free ParamBuffer */
ExFreePool (ParamBuffer);
@ -435,25 +435,31 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
ULONG last_kernel_address;
ULONG start;
PCHAR name;
extern ULONG _bss_end__;
/*
* Copy the parameters to a local buffer because lowmem will go away
*/
memcpy (&KeLoaderBlock, _LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK));
memcpy (&KeLoaderModules, (PVOID)KeLoaderBlock.ModsAddr,
memcpy (&KeLoaderModules[1], (PVOID)KeLoaderBlock.ModsAddr,
sizeof(LOADER_MODULE) * KeLoaderBlock.ModsCount);
KeLoaderBlock.ModsCount++;
KeLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules;
/*
* FIXME: Preliminary hack!!!! Add boot device to beginning of command line.
* This should be done by the boot loader.
*/
strcpy (KeLoaderCommandLine,
"multi(0)disk(0)rdisk(0)partition(1)\\reactos ");
strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine);
strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine);
KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine;
for (i = 0; i < KeLoaderBlock.ModsCount; i++)
strcpy(KeLoaderModuleStrings[0], "ntoskrnl.exe");
KeLoaderModules[0].String = (ULONG)KeLoaderModuleStrings[0];
KeLoaderModules[0].ModStart = 0xC0000000;
KeLoaderModules[0].ModEnd = PAGE_ROUND_UP((ULONG)&_bss_end__);
for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{
strcpy(KeLoaderModuleStrings[i], (PUCHAR)KeLoaderModules[i].String);
KeLoaderModules[i].ModStart -= 0x200000;
@ -469,11 +475,12 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
KeInit1();
KeLowerIrql(DISPATCH_LEVEL);
{
char tmpbuf[80];
sprintf(tmpbuf,"system with %d MB extended memory\n",
(unsigned int)(KeLoaderBlock.MemLower)/1024);
sprintf(tmpbuf,"system with %d/%d MB memory\n",
(unsigned int)(KeLoaderBlock.MemLower)/1024,
(unsigned int)(KeLoaderBlock.MemHigher)/1024);
HalDisplayString(tmpbuf);
}
@ -564,6 +571,7 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
}
/* Create the SystemRoot symbolic link */
DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine);
CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine);
CmInitializeRegistry2();

View file

@ -103,6 +103,7 @@ l2:
movl $0, %eax
movl $__bss_end__, %ecx
subl $__bss_start__, %ecx
shr $2, %ecx
movl $__bss_start__, %edi
rep
stosl

View file

@ -1,4 +1,4 @@
/* $Id: mminit.c,v 1.12 2000/12/28 03:38:07 dwelch Exp $
/* $Id: mminit.c,v 1.13 2001/01/17 15:38:03 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
@ -217,19 +217,23 @@ VOID MmInit1(ULONG FirstKrnlPhysAddr,
/*
* Free physical memory not used by the kernel
*/
MmStats.NrTotalPages = KeLoaderBlock.MemLower/4;
if ( !MmStats.NrTotalPages )
{
DbgPrint("Memory not detected, default to 8 MB\n");
MmStats.NrTotalPages = KeLoaderBlock.MemHigher/4;
if (!MmStats.NrTotalPages)
{
DbgPrint("Memory not detected, default to 8 MB\n");
MmStats.NrTotalPages = 2048;
}
}
else
MmStats.NrTotalPages += 256;// add 1MB for standard memory (not extended)
{
/* add 1MB for standard memory (not extended) */
MmStats.NrTotalPages += 256;
}
DbgPrint("Used memory %d\n", MmStats.NrTotalPages * PAGESIZE);
LastKernelAddress = (ULONG)MmInitializePageList(
(PVOID)FirstKrnlPhysAddr,
(PVOID)LastKrnlPhysAddr,
// 1024,
MmStats.NrTotalPages ,
MmStats.NrTotalPages,
PAGE_ROUND_UP(LastKernelAddress));
kernel_len = LastKrnlPhysAddr - FirstKrnlPhysAddr;

View file

@ -149,8 +149,15 @@ PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus)
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
Thread, ExitStatus);
/*
* We must synchronize the termination of a thread with its execution
* so all this routine does is to mark the thread as terminated and
* wake it if possible. The thread will then kill itself when it
* next exits kernel mode.
*/
Thread->DeadThread = 1;
Thread->ExitStatus = ExitStatus;
Thread->Tcb.ApcState.UserApcPending++;
if (Thread->Tcb.State == THREAD_STATE_FROZEN &&
(Thread->Tcb.Alertable || Thread->Tcb.WaitMode == UserMode))
{
@ -254,7 +261,8 @@ NTSTATUS STDCALL PsTerminateSystemThread(NTSTATUS ExitStatus)
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL NtCallTerminatePorts(PETHREAD Thread)
NTSTATUS STDCALL
NtCallTerminatePorts(PETHREAD Thread)
{
KIRQL oldIrql;
PLIST_ENTRY current_entry;
@ -276,7 +284,8 @@ NTSTATUS STDCALL NtCallTerminatePorts(PETHREAD Thread)
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL NtRegisterThreadTerminatePort(HANDLE TerminationPortHandle)
NTSTATUS STDCALL
NtRegisterThreadTerminatePort(HANDLE TerminationPortHandle)
{
NTSTATUS Status;
PEPORT_TERMINATION_REQUEST Request;