mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
Multiboot fixes
svn path=/trunk/; revision=1529
This commit is contained in:
parent
695a57cff6
commit
7a3409d80c
7 changed files with 112 additions and 80 deletions
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo "Installing to floppy."
|
#echo "Installing to floppy."
|
||||||
mount -t vfat /bochs/1.44a /mnt/floppy -o loop,rw
|
#mount -t vfat /bochs/1.44a /mnt/floppy -o loop,rw
|
||||||
./install-system.sh /mnt/floppy
|
#./install-system.sh /mnt/floppy
|
||||||
umount /mnt/floppy
|
#umount /mnt/floppy
|
||||||
echo "Installing to disk."
|
echo "Installing to disk."
|
||||||
mount -t vfat /bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw
|
mount -t vfat /bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw
|
||||||
./install.sh /mnt/floppy
|
./install.sh /mnt/floppy
|
||||||
|
|
|
@ -266,51 +266,57 @@ entry:
|
||||||
mov [_multiboot_cmdline], eax
|
mov [_multiboot_cmdline], eax
|
||||||
add dword [_multiboot_cmdline], _multiboot_kernel_cmdline
|
add dword [_multiboot_cmdline], _multiboot_kernel_cmdline
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; Hide the kernel's entry in the list of modules
|
||||||
|
;;
|
||||||
mov [_multiboot_mods_addr], eax
|
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
|
;; 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
|
and ebx, 0xffff
|
||||||
xor ebx,ebx
|
shl ebx,6
|
||||||
mov [_multiboot_mem_lower],ebx
|
mov [_multiboot_mem_upper],ebx
|
||||||
mov ax, 0xe801
|
and eax,0xffff
|
||||||
int 015h
|
add dword [_multiboot_mem_upper],eax
|
||||||
cmp ebx,ebx
|
jmp .done_mem
|
||||||
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
|
|
||||||
|
|
||||||
.oldstylemem:
|
.oldstylemem:
|
||||||
;; int 15h opt e801 don't work , try int 15h, option 88h
|
;; int 15h opt e801 don't work , try int 15h, option 88h
|
||||||
mov ah, 088h
|
mov ah, 088h
|
||||||
int 015h
|
int 015h
|
||||||
cmp ax,ax
|
cmp ax,ax
|
||||||
jz .cmosmem
|
jz .cmosmem
|
||||||
mov [_multiboot_mem_lower],ax
|
mov [_multiboot_mem_upper],ax
|
||||||
jmp .done_mem
|
jmp .done_mem
|
||||||
.cmosmem:
|
.cmosmem:
|
||||||
;; int 15h opt 88h don't work , try read cmos
|
;; int 15h opt 88h don't work , try read cmos
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
mov al, 0x31
|
mov al, 0x31
|
||||||
out 0x70, al
|
out 0x70, al
|
||||||
in al, 0x71
|
in al, 0x71
|
||||||
and eax, 0xffff ; clear carry
|
and eax, 0xffff ; clear carry
|
||||||
shl eax,8
|
shl eax,8
|
||||||
mov [_multiboot_mem_lower],eax
|
mov [_multiboot_mem_upper],eax
|
||||||
;; xor eax,eax
|
;; xor eax,eax
|
||||||
;; mov al, 0x30
|
;; mov al, 0x30
|
||||||
;; out 0x70, al
|
;; out 0x70, al
|
||||||
;; in al, 0x71
|
;; in al, 0x71
|
||||||
;; and eax, 0xffff ; clear carry
|
;; and eax, 0xffff ; clear carry
|
||||||
;; add [_multiboot_mem_lower],eax
|
;; add [_multiboot_mem_lower],eax
|
||||||
|
|
||||||
.done_mem:
|
.done_mem:
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
|
@ -89,11 +89,28 @@ BOOLEAN KiDeliverUserApc(PKTRAP_FRAME TrapFrame)
|
||||||
PCONTEXT Context;
|
PCONTEXT Context;
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
PKTHREAD Thread;
|
PKTHREAD Thread;
|
||||||
|
PETHREAD EThread;
|
||||||
|
|
||||||
DPRINT("KiDeliverUserApc(TrapFrame %x/%x)\n", TrapFrame,
|
DPRINT("KiDeliverUserApc(TrapFrame %x/%x)\n", TrapFrame,
|
||||||
KeGetCurrentThread()->TrapFrame);
|
KeGetCurrentThread()->TrapFrame);
|
||||||
Thread = KeGetCurrentThread();
|
Thread = KeGetCurrentThread();
|
||||||
KeAcquireSpinLock(&PiApcLock, &oldlvl);
|
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;
|
current_entry = Thread->ApcState.ApcListHead[1].Flink;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -174,20 +191,6 @@ BOOLEAN KiDeliverUserApc(PKTRAP_FRAME TrapFrame)
|
||||||
(PVOID*)&Esp[3],
|
(PVOID*)&Esp[3],
|
||||||
(PVOID*)&Esp[4]);
|
(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);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,10 +234,11 @@ VOID STDCALL KiDeliverApc(ULONG Unknown1,
|
||||||
// Thread->Tcb.WaitStatus = STATUS_KERNEL_APC;
|
// Thread->Tcb.WaitStatus = STATUS_KERNEL_APC;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID STDCALL KeInsertQueueApc (PKAPC Apc,
|
VOID STDCALL
|
||||||
PVOID SystemArgument1,
|
KeInsertQueueApc (PKAPC Apc,
|
||||||
PVOID SystemArgument2,
|
PVOID SystemArgument1,
|
||||||
UCHAR Mode)
|
PVOID SystemArgument2,
|
||||||
|
UCHAR Mode)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Queues an APC for execution
|
* FUNCTION: Queues an APC for execution
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
|
|
@ -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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -84,13 +84,13 @@ CreateSystemRootLink (PCSZ ParameterLine)
|
||||||
RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
|
RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
|
||||||
}
|
}
|
||||||
DPRINT("Arc name: %s\n", ParamBuffer);
|
DPRINT("Arc name: %s\n", ParamBuffer);
|
||||||
|
|
||||||
/* Only arc name left - build full arc name */
|
/* Only arc name left - build full arc name */
|
||||||
ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
|
ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
|
||||||
swprintf (ArcNameBuffer,
|
swprintf (ArcNameBuffer,
|
||||||
L"\\ArcName\\%S", ParamBuffer);
|
L"\\ArcName\\%S", ParamBuffer);
|
||||||
RtlInitUnicodeString (&ArcName, ArcNameBuffer);
|
RtlInitUnicodeString (&ArcName, ArcNameBuffer);
|
||||||
DPRINT("Arc name: %wZ\n", &ArcName);
|
DPRINT1("Arc name: %wZ\n", &ArcName);
|
||||||
|
|
||||||
/* free ParamBuffer */
|
/* free ParamBuffer */
|
||||||
ExFreePool (ParamBuffer);
|
ExFreePool (ParamBuffer);
|
||||||
|
@ -435,25 +435,31 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
|
||||||
ULONG last_kernel_address;
|
ULONG last_kernel_address;
|
||||||
ULONG start;
|
ULONG start;
|
||||||
PCHAR name;
|
PCHAR name;
|
||||||
|
extern ULONG _bss_end__;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy the parameters to a local buffer because lowmem will go away
|
* Copy the parameters to a local buffer because lowmem will go away
|
||||||
*/
|
*/
|
||||||
memcpy (&KeLoaderBlock, _LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK));
|
memcpy (&KeLoaderBlock, _LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK));
|
||||||
memcpy (&KeLoaderModules, (PVOID)KeLoaderBlock.ModsAddr,
|
memcpy (&KeLoaderModules[1], (PVOID)KeLoaderBlock.ModsAddr,
|
||||||
sizeof(LOADER_MODULE) * KeLoaderBlock.ModsCount);
|
sizeof(LOADER_MODULE) * KeLoaderBlock.ModsCount);
|
||||||
|
KeLoaderBlock.ModsCount++;
|
||||||
KeLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules;
|
KeLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: Preliminary hack!!!! Add boot device to beginning of command line.
|
* FIXME: Preliminary hack!!!! Add boot device to beginning of command line.
|
||||||
* This should be done by the boot loader.
|
* This should be done by the boot loader.
|
||||||
*/
|
*/
|
||||||
strcpy (KeLoaderCommandLine,
|
strcpy (KeLoaderCommandLine,
|
||||||
"multi(0)disk(0)rdisk(0)partition(1)\\reactos ");
|
"multi(0)disk(0)rdisk(0)partition(1)\\reactos ");
|
||||||
strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine);
|
strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine);
|
||||||
|
|
||||||
KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine;
|
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);
|
strcpy(KeLoaderModuleStrings[i], (PUCHAR)KeLoaderModules[i].String);
|
||||||
KeLoaderModules[i].ModStart -= 0x200000;
|
KeLoaderModules[i].ModStart -= 0x200000;
|
||||||
|
@ -469,11 +475,12 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
|
||||||
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
|
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
|
||||||
KeInit1();
|
KeInit1();
|
||||||
KeLowerIrql(DISPATCH_LEVEL);
|
KeLowerIrql(DISPATCH_LEVEL);
|
||||||
|
|
||||||
{
|
{
|
||||||
char tmpbuf[80];
|
char tmpbuf[80];
|
||||||
sprintf(tmpbuf,"system with %d MB extended memory\n",
|
sprintf(tmpbuf,"system with %d/%d MB memory\n",
|
||||||
(unsigned int)(KeLoaderBlock.MemLower)/1024);
|
(unsigned int)(KeLoaderBlock.MemLower)/1024,
|
||||||
|
(unsigned int)(KeLoaderBlock.MemHigher)/1024);
|
||||||
HalDisplayString(tmpbuf);
|
HalDisplayString(tmpbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,6 +571,7 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the SystemRoot symbolic link */
|
/* Create the SystemRoot symbolic link */
|
||||||
|
DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine);
|
||||||
CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine);
|
CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine);
|
||||||
|
|
||||||
CmInitializeRegistry2();
|
CmInitializeRegistry2();
|
||||||
|
|
|
@ -103,6 +103,7 @@ l2:
|
||||||
movl $0, %eax
|
movl $0, %eax
|
||||||
movl $__bss_end__, %ecx
|
movl $__bss_end__, %ecx
|
||||||
subl $__bss_start__, %ecx
|
subl $__bss_start__, %ecx
|
||||||
|
shr $2, %ecx
|
||||||
movl $__bss_start__, %edi
|
movl $__bss_start__, %edi
|
||||||
rep
|
rep
|
||||||
stosl
|
stosl
|
||||||
|
|
|
@ -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
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -217,19 +217,23 @@ VOID MmInit1(ULONG FirstKrnlPhysAddr,
|
||||||
/*
|
/*
|
||||||
* Free physical memory not used by the kernel
|
* Free physical memory not used by the kernel
|
||||||
*/
|
*/
|
||||||
MmStats.NrTotalPages = KeLoaderBlock.MemLower/4;
|
MmStats.NrTotalPages = KeLoaderBlock.MemHigher/4;
|
||||||
if ( !MmStats.NrTotalPages )
|
if (!MmStats.NrTotalPages)
|
||||||
{
|
{
|
||||||
DbgPrint("Memory not detected, default to 8 MB\n");
|
DbgPrint("Memory not detected, default to 8 MB\n");
|
||||||
MmStats.NrTotalPages = 2048;
|
MmStats.NrTotalPages = 2048;
|
||||||
}
|
}
|
||||||
else
|
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(
|
LastKernelAddress = (ULONG)MmInitializePageList(
|
||||||
(PVOID)FirstKrnlPhysAddr,
|
(PVOID)FirstKrnlPhysAddr,
|
||||||
(PVOID)LastKrnlPhysAddr,
|
(PVOID)LastKrnlPhysAddr,
|
||||||
// 1024,
|
MmStats.NrTotalPages,
|
||||||
MmStats.NrTotalPages ,
|
|
||||||
PAGE_ROUND_UP(LastKernelAddress));
|
PAGE_ROUND_UP(LastKernelAddress));
|
||||||
kernel_len = LastKrnlPhysAddr - FirstKrnlPhysAddr;
|
kernel_len = LastKrnlPhysAddr - FirstKrnlPhysAddr;
|
||||||
|
|
||||||
|
|
|
@ -149,8 +149,15 @@ PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus)
|
||||||
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
|
||||||
Thread, ExitStatus);
|
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->DeadThread = 1;
|
||||||
Thread->ExitStatus = ExitStatus;
|
Thread->ExitStatus = ExitStatus;
|
||||||
|
Thread->Tcb.ApcState.UserApcPending++;
|
||||||
if (Thread->Tcb.State == THREAD_STATE_FROZEN &&
|
if (Thread->Tcb.State == THREAD_STATE_FROZEN &&
|
||||||
(Thread->Tcb.Alertable || Thread->Tcb.WaitMode == UserMode))
|
(Thread->Tcb.Alertable || Thread->Tcb.WaitMode == UserMode))
|
||||||
{
|
{
|
||||||
|
@ -254,7 +261,8 @@ NTSTATUS STDCALL PsTerminateSystemThread(NTSTATUS ExitStatus)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCallTerminatePorts(PETHREAD Thread)
|
NTSTATUS STDCALL
|
||||||
|
NtCallTerminatePorts(PETHREAD Thread)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -276,7 +284,8 @@ NTSTATUS STDCALL NtCallTerminatePorts(PETHREAD Thread)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtRegisterThreadTerminatePort(HANDLE TerminationPortHandle)
|
NTSTATUS STDCALL
|
||||||
|
NtRegisterThreadTerminatePort(HANDLE TerminationPortHandle)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPORT_TERMINATION_REQUEST Request;
|
PEPORT_TERMINATION_REQUEST Request;
|
||||||
|
|
Loading…
Reference in a new issue