Author: ros-arm-bringup
Date: Thu Jun 26 23:19:50 2008
New Revision: 34121
URL:
http://svn.reactos.org/svn/reactos?rev=34121&view=rev
Log:
- Implement KiApcInterrupt -- ACPs now work!
- Change some infinite loops to ASSERTs since bugchecks now work and we can better
differentiate stubs versus loops versus unimplemented code.
- Add back the system call debug prints -- total hack to make the stack work.
- Add support for the ARC Disk Information/Signature in FreeLDR.
- We've reached a major, major milestone here folks -- the kernel bugchecks because no
boot device was found (since we don't have any working drivers yet).
- We have a lot of stuff to fix before continuing, and code review will take some time.
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c
trunk/reactos/ntoskrnl/ke/arm/kiinit.c
trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s
trunk/reactos/ntoskrnl/ke/arm/trapc.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c [iso-8859-1] Thu Jun 26 23:19:50
2008
@@ -1056,7 +1056,12 @@
ULONG Dummy, i;
PLDR_DATA_TABLE_ENTRY LdrEntry;
PLIST_ENTRY NextEntry, OldEntry;
-
+ PARC_DISK_INFORMATION ArcDiskInformation;
+ PARC_DISK_SIGNATURE ArcDiskSignature;
+ ULONG ArcDiskCount = 0, Checksum = 0;
+ PMASTER_BOOT_RECORD Mbr;
+ PULONG Buffer;
+
//
// Allocate the ARM Shared Heap
//
@@ -1241,10 +1246,6 @@
InsertTailList(&ArmLoaderBlock->LoadOrderListHead,
&LdrEntry->InLoadOrderLinks);
//
- // TODO: Setup boot-driver data
- //
-
- //
// Build descriptors for the drivers loaded
//
for (i = 0; i < Drivers; i++)
@@ -1260,7 +1261,6 @@
&Dummy);
if (Status != STATUS_SUCCESS) return;
}
-
//
// Loop driver list
@@ -1488,6 +1488,75 @@
//
NextEntry->Flink = (PVOID)((ULONG_PTR)NextEntry->Flink | KSEG0_BASE);
NextEntry->Blink = (PVOID)((ULONG_PTR)NextEntry->Blink | KSEG0_BASE);
+
+ //
+ // Allocate ARC disk structure
+ //
+ ArcDiskInformation = ArmAllocateFromSharedHeap(sizeof(ARC_DISK_INFORMATION));
+ InitializeListHead(&ArcDiskInformation->DiskSignatureListHead);
+ ArmLoaderBlock->ArcDiskInformation = (PVOID)((ULONG_PTR)ArcDiskInformation |
KSEG0_BASE);
+
+ //
+ // Read the MBR
+ //
+ MachDiskReadLogicalSectors(0x49, 0ULL, 1, (PVOID)DISKREADBUFFER);
+ Buffer = (ULONG*)DISKREADBUFFER;
+ Mbr = (PMASTER_BOOT_RECORD)DISKREADBUFFER;
+
+ //
+ // Calculate the MBR checksum
+ //
+ for (i = 0; i < 128; i++) Checksum += Buffer[i];
+ Checksum = ~Checksum + 1;
+
+ //
+ // Allocate a disk signature and fill it out
+ //
+ ArcDiskSignature = ArmAllocateFromSharedHeap(sizeof(ARC_DISK_SIGNATURE));
+ ArcDiskSignature->Signature = Mbr->Signature;
+ ArcDiskSignature->CheckSum = Checksum;
+
+ //
+ // Allocare a string for the name and fill it out
+ //
+ ArcDiskSignature->ArcName = ArmAllocateFromSharedHeap(256);
+ sprintf(ArcDiskSignature->ArcName, "multi(0)disk(0)rdisk(%lu)",
ArcDiskCount++);
+ ArcDiskSignature->ArcName = (PVOID)((ULONG_PTR)ArcDiskSignature->ArcName |
KSEG0_BASE);
+
+ //
+ // Insert the descriptor into the list
+ //
+ InsertTailList(&ArcDiskInformation->DiskSignatureListHead,
+ &ArcDiskSignature->ListEntry);
+
+ //
+ // Loop ARC disk list
+ //
+ NextEntry = ArcDiskInformation->DiskSignatureListHead.Flink;
+ while (NextEntry != &ArcDiskInformation->DiskSignatureListHead)
+ {
+ //
+ // Remember the physical entry
+ //
+ OldEntry = NextEntry->Flink;
+
+ //
+ // Edit the data
+ //
+ NextEntry->Flink = (PVOID)((ULONG_PTR)NextEntry->Flink | KSEG0_BASE);
+ NextEntry->Blink = (PVOID)((ULONG_PTR)NextEntry->Blink | KSEG0_BASE);
+
+ //
+ // Keep looping
+ //
+ NextEntry = OldEntry;
+ }
+
+ //
+ // Now edit the root itself
+ //
+ NextEntry->Flink = (PVOID)((ULONG_PTR)NextEntry->Flink | KSEG0_BASE);
+ NextEntry->Blink = (PVOID)((ULONG_PTR)NextEntry->Blink | KSEG0_BASE);
}
VOID
Modified: trunk/reactos/ntoskrnl/ke/arm/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/kiinit.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/kiinit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/kiinit.c [iso-8859-1] Thu Jun 26 23:19:50 2008
@@ -23,8 +23,13 @@
/* FUNCTIONS ******************************************************************/
+//
+// FIXME: Header cleanup
+//
VOID
-KiIdleLoop(VOID);
+KiIdleLoop(
+ VOID
+);
VOID
DebugService(IN ULONG ServiceType,
@@ -34,7 +39,7 @@
IN ULONG Level)
{
//
- // ARM Bring-up Hack
+ // FIXME: ARM Bring-up Hack
//
void arm_kprintf(const char *fmt, ...);
arm_kprintf("%s", Buffer);
@@ -230,7 +235,7 @@
else
{
//
- // FIXME
+ // FIXME: No MP Support
//
DPRINT1("ARM MPCore not supported\n");
}
Modified: trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/stubs_asm.…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s [iso-8859-1] Thu Jun 26 23:19:50 2008
@@ -46,7 +46,6 @@
//
// Traps, Debugging and Execeptions
//
-GENERATE_ARM_STUB KiApcInterrupt
GENERATE_ARM_STUB KiPassiveRelease
GENERATE_ARM_STUB KiInterruptTemplate
GENERATE_ARM_STUB KiUnexpectedInterrupt
Modified: trunk/reactos/ntoskrnl/ke/arm/trapc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/trapc.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] Thu Jun 26 23:19:50 2008
@@ -102,7 +102,7 @@
DPRINT1("Swapping context!\n");
KiSwapContext(OldThread, NewThread);
DPRINT1("Back\n");
- while (TRUE);
+ ASSERT(FALSE);
}
else
{
@@ -160,7 +160,7 @@
// FIXME: TODO
//
DPRINT1("WMI Tracing not supported\n");
- while (TRUE);
+ ASSERT(FALSE);
}
//
@@ -180,7 +180,7 @@
// FIXME: TODO
//
DPRINT1("Address space switch not implemented\n");
- while (TRUE);
+ ASSERT(FALSE);
}
}
@@ -210,7 +210,7 @@
// FIXME: FAIL
//
DPRINT1("DPCS ACTIVE!!!\n");
- while (TRUE);
+ ASSERT(FALSE);
}
//
@@ -222,13 +222,52 @@
// FIXME: TODO
//
DPRINT1("APCs pending!\n");
- while (TRUE);
+ ASSERT(FALSE);
}
//
// Return
//
return FALSE;
+}
+
+VOID
+KiApcInterrupt(VOID)
+{
+ KPROCESSOR_MODE PreviousMode;
+ KEXCEPTION_FRAME ExceptionFrame;
+ PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
+ DPRINT1("[APC]\n");
+
+ //
+ // Isolate previous mode
+ //
+ PreviousMode = KiGetPreviousMode(TrapFrame);
+
+ //
+ // FIXME No use-mode support
+ //
+ if (PreviousMode == UserMode) ASSERT(FALSE);
+
+ //
+ // Disable interrupts
+ //
+ _disable();
+
+ //
+ // Clear APC interrupt
+ //
+ HalClearSoftwareInterrupt(APC_LEVEL);
+
+ //
+ // Re-enable interrupts
+ //
+ _enable();
+
+ //
+ // Deliver APCs
+ //
+ KiDeliverApc(PreviousMode, &ExceptionFrame, TrapFrame);
}
VOID
@@ -309,7 +348,7 @@
DPRINT1("Swapping context!\n");
KiSwapContext(OldThread, NewThread);
DPRINT1("Back\n");
- while (TRUE);
+ ASSERT(FALSE);
}
}
@@ -402,21 +441,17 @@
//
// Check if this is a page fault
//
- if ((KeArmFaultStatusRegisterGet() == 21) ||
- (KeArmFaultStatusRegisterGet() == 23))
- {
- //
- // Handle the fault
- //
- Status = MmAccessFault(FALSE, Address, KernelMode, TrapFrame);
+ if (KeArmFaultStatusRegisterGet() == 21 || KeArmFaultStatusRegisterGet() == 23)
+ {
+ Status = MmAccessFault(FALSE,
+ Address,
+ KernelMode,
+ TrapFrame);
if (Status == STATUS_SUCCESS) return Status;
}
- //
- // We don't handle this yet
- //
UNIMPLEMENTED;
- while (TRUE);
+ ASSERT(FALSE);
return STATUS_SUCCESS;
}
@@ -443,7 +478,7 @@
// Get the system call ID
//
Id = Instruction & 0xFFFFF;
- //DPRINT1("[SWI] (%x) %p (%d) \n", Id, Thread, Thread->PreviousMode);
+ DPRINT1("[SWI] (%x) %p (%d) \n", Id, Thread, Thread->PreviousMode);
//
// Get the descriptor table
@@ -463,7 +498,7 @@
// Check if this is a GUI call
//
UNIMPLEMENTED;
- while (TRUE);
+ ASSERT(FALSE);
}
//
@@ -480,7 +515,7 @@
// TODO
//
UNIMPLEMENTED;
- while (TRUE);
+ ASSERT(FALSE);
}
//
@@ -499,6 +534,7 @@
//
// Copy them into the kernel stack
//
+ DPRINT1("Argument: %p\n", *Argument);
Arguments[i] = *Argument;
Argument++;
}
@@ -539,6 +575,7 @@
//
// Copy into kernel stack
//
+ DPRINT1("Argument: %p\n", *Argument);
Arguments[i] = *Argument;
Argument++;
}
@@ -548,7 +585,7 @@
// Do the system call and save result in EAX
//
TrapFrame->R0 = KiSystemCall(SystemCall, Arguments, ArgumentCount);
- //DPRINT1("Returned: %lx\n", TrapFrame->R0);
+ DPRINT1("Returned: %lx\n", TrapFrame->R0);
}
VOID
@@ -569,7 +606,7 @@
PreviousMode = KiGetPreviousMode(TrapFrame);
//
- // Save old previous mode
+ // FIXME: Save old previous mode
//
//TrapFrame->PreviousMode = PreviousMode;