Author: ros-arm-bringup Date: Thu Jun 26 22:06:11 2008 New Revision: 34120
URL: http://svn.reactos.org/svn/reactos?rev=34120&view=rev Log: - Implement VidResetDisplay in BootVid-arm. - Implement KiSaveProcessorControlState and make the appropriate changes to KPROCESSOR_STATE and KSPECIAL_REGISTERS on ARM to support this, as well as moving the ARM Register definitions from ntos to NDK. - Implement RtlCaptureContext. - With these changes, BSODs now work, but because of missing palette code, they are actually R(Red)SODs, which is awesome. - Remove debug prints from system call code -- this ends up somehow corrupting the return values *sigh*. More work to be done there, defintely. We have now regressed but we have an RSOD.
Modified: trunk/reactos/drivers/base/bootvid/arm/bootvid.c trunk/reactos/include/ndk/arm/ketypes.h trunk/reactos/lib/rtl/arm/debug_asm.S trunk/reactos/ntoskrnl/include/internal/arm/ke.h trunk/reactos/ntoskrnl/include/internal/arm/ksarm.h trunk/reactos/ntoskrnl/ke/arm/cpu.c trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s trunk/reactos/ntoskrnl/ke/arm/trapc.c
Modified: trunk/reactos/drivers/base/bootvid/arm/bootvid.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/bootvid/arm/bo... ============================================================================== --- trunk/reactos/drivers/base/bootvid/arm/bootvid.c [iso-8859-1] (original) +++ trunk/reactos/drivers/base/bootvid/arm/bootvid.c [iso-8859-1] Thu Jun 26 22:06:11 2008 @@ -23,6 +23,7 @@ #define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT *)(r) = (v))
PUSHORT VgaArmBase; +PHYSICAL_ADDRESS VgaPhysical; BOOLEAN NextLine = FALSE; UCHAR VidpTextColor = 0xF; ULONG VidpCurrentX = 0; @@ -244,38 +245,15 @@ } }
-/* PUBLIC FUNCTIONS **********************************************************/ - -/* - * @implemented - */ -BOOLEAN -NTAPI -VidInitialize(IN BOOLEAN SetMode) -{ - PHYSICAL_ADDRESS Physical; - DPRINT1("bv-arm v0.1\n"); - - // - // Allocate framebuffer - // 600kb works out to 640x480@16bpp - // - Physical.QuadPart = -1; - VgaArmBase = MmAllocateContiguousMemory(600 * 1024, Physical); - if (!VgaArmBase) return FALSE; - - // - // Get physical address - // - Physical = MmGetPhysicalAddress(VgaArmBase); - if (!Physical.QuadPart) return FALSE; - DPRINT1("[BV-ARM] Frame Buffer @ 0x%p 0p%p\n", VgaArmBase, Physical.LowPart); - +VOID +NTAPI +VidpInitializeDisplay(VOID) +{ // // Set framebuffer address // - WRITE_REGISTER_ULONG(PL110_LCDUPBASE, Physical.LowPart); - WRITE_REGISTER_ULONG(PL110_LCDLPBASE, Physical.LowPart); + WRITE_REGISTER_ULONG(PL110_LCDUPBASE, VgaPhysical.LowPart); + WRITE_REGISTER_ULONG(PL110_LCDLPBASE, VgaPhysical.LowPart);
// // Initialize timings to 640x480 @@ -291,7 +269,7 @@ LCDCONTROL_LCDTFT | LCDCONTROL_LCDPWR | LCDCONTROL_LCDBPP(4)); - + #if DBG // // Draw an RGB test pattern @@ -308,7 +286,39 @@ } } #endif - +} + +/* PUBLIC FUNCTIONS **********************************************************/ + +/* + * @implemented + */ +BOOLEAN +NTAPI +VidInitialize(IN BOOLEAN SetMode) +{ + DPRINT1("bv-arm v0.1\n"); + + // + // Allocate framebuffer + // 600kb works out to 640x480@16bpp + // + VgaPhysical.QuadPart = -1; + VgaArmBase = MmAllocateContiguousMemory(600 * 1024, VgaPhysical); + if (!VgaArmBase) return FALSE; + + // + // Get physical address + // + VgaPhysical = MmGetPhysicalAddress(VgaArmBase); + if (!VgaPhysical.QuadPart) return FALSE; + DPRINT1("[BV-ARM] Frame Buffer @ 0x%p 0p%p\n", VgaArmBase, VgaPhysical.LowPart); + + // + // Setup the display + // + VidpInitializeDisplay(); + // // We are done! // @@ -322,8 +332,22 @@ NTAPI VidResetDisplay(IN BOOLEAN HalReset) { - UNIMPLEMENTED; - while (TRUE); + // + // Clear the current position + // + VidpCurrentX = 0; + VidpCurrentY = 0; + + // + // Re-initialize the VGA Display + // + VidpInitializeDisplay(); + + // + // Re-initialize the palette and fill the screen black + // + //InitializePalette(); + VidSolidColorFill(0, 0, 639, 479, 0); }
/*
Modified: trunk/reactos/include/ndk/arm/ketypes.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/arm/ketypes.h?r... ============================================================================== --- trunk/reactos/include/ndk/arm/ketypes.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/arm/ketypes.h [iso-8859-1] Thu Jun 26 22:06:11 2008 @@ -109,11 +109,178 @@ } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
// +// ARM Internal Registers +// +typedef union _ARM_TTB_REGISTER +{ + struct + { + ULONG Reserved:14; + ULONG BaseAddress:18; + }; + ULONG AsUlong; +} ARM_TTB_REGISTER; + +typedef union _ARM_STATUS_REGISTER +{ + + struct + { + ULONG Mode:5; + ULONG State:1; + ULONG FiqDisable:1; + ULONG IrqDisable:1; + ULONG ImpreciseAbort:1; + ULONG Endianness:1; + ULONG Sbz:6; + ULONG GreaterEqual:4; + ULONG Sbz1:4; + ULONG Java:1; + ULONG Sbz2:2; + ULONG StickyOverflow:1; + ULONG Overflow:1; + ULONG CarryBorrowExtend:1; + ULONG Zero:1; + ULONG NegativeLessThan:1; + }; + ULONG AsUlong; +} ARM_STATUS_REGISTER; + +typedef union _ARM_DOMAIN_REGISTER +{ + struct + { + ULONG Domain0:2; + ULONG Domain1:2; + ULONG Domain2:2; + ULONG Domain3:2; + ULONG Domain4:2; + ULONG Domain5:2; + ULONG Domain6:2; + ULONG Domain7:2; + ULONG Domain8:2; + ULONG Domain9:2; + ULONG Domain10:2; + ULONG Domain11:2; + ULONG Domain12:2; + ULONG Domain13:2; + ULONG Domain14:2; + ULONG Domain15:2; + }; + ULONG AsUlong; +} ARM_DOMAIN_REGISTER; + +typedef union _ARM_CONTROL_REGISTER +{ + struct + { + ULONG MmuEnabled:1; + ULONG AlignmentFaultsEnabled:1; + ULONG DCacheEnabled:1; + ULONG Sbo:4; + ULONG BigEndianEnabled:1; + ULONG System:1; + ULONG Rom:1; + ULONG Sbz:2; + ULONG ICacheEnabled:1; + ULONG HighVectors:1; + ULONG RoundRobinReplacementEnabled:1; + ULONG Armv4Compat:1; + ULONG Sbo1:1; + ULONG Sbz1:1; + ULONG Sbo2:1; + ULONG Reserved:14; + }; + ULONG AsUlong; +} ARM_CONTROL_REGISTER, *PARM_CONTROL_REGISTER; + +typedef union _ARM_ID_CODE_REGISTER +{ + struct + { + ULONG Revision:4; + ULONG PartNumber:12; + ULONG Architecture:4; + ULONG Variant:4; + ULONG Identifier:8; + }; + ULONG AsUlong; +} ARM_ID_CODE_REGISTER, *PARM_ID_CODE_REGISTER; + +typedef union _ARM_CACHE_REGISTER +{ + struct + { + ULONG ILength:2; + ULONG IMultipler:1; + ULONG IAssociativty:3; + ULONG ISize:4; + ULONG IReserved:2; + ULONG DLength:2; + ULONG DMultipler:1; + ULONG DAssociativty:3; + ULONG DSize:4; + ULONG DReserved:2; + ULONG Separate:1; + ULONG CType:4; + ULONG Reserved:3; + }; + ULONG AsUlong; +} ARM_CACHE_REGISTER, *PARM_CACHE_REGISTER; + +typedef union _ARM_LOCKDOWN_REGISTER +{ + struct + { + ULONG Preserve:1; + ULONG Ignored:25; + ULONG Victim:3; + ULONG Reserved:3; + }; + ULONG AsUlong; +} ARM_LOCKDOWN_REGISTER, *PARM_LOCKDOWN_REGISTER; + +// +// ARM Domains +// +typedef enum _ARM_DOMAINS +{ + Domain0, + Domain1, + Domain2, + Domain3, + Domain4, + Domain5, + Domain6, + Domain7, + Domain8, + Domain9, + Domain10, + Domain11, + Domain12, + Domain13, + Domain14, + Domain15 +} ARM_DOMAINS; + +// +// Special Registers Structure (outside of CONTEXT) +// +typedef struct _KSPECIAL_REGISTERS +{ + ARM_CONTROL_REGISTER ControlRegister; + ARM_LOCKDOWN_REGISTER LockdownRegister; + ARM_CACHE_REGISTER CacheRegister; + ARM_STATUS_REGISTER StatusRegister; +} KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS; + +// // Processor State // typedef struct _KPROCESSOR_STATE { struct _CONTEXT ContextFrame; + struct _KSPECIAL_REGISTERS SpecialRegisters; } KPROCESSOR_STATE, *PKPROCESSOR_STATE;
//
Modified: trunk/reactos/lib/rtl/arm/debug_asm.S URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/arm/debug_asm.S?rev... ============================================================================== --- trunk/reactos/lib/rtl/arm/debug_asm.S [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/arm/debug_asm.S [iso-8859-1] Thu Jun 26 22:06:11 2008 @@ -1,18 +1,59 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Run-Time Library - * PURPOSE: Debug Routines - * FILE: lib/rtl/arm/debug_asm.S + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: rtl/arm/debug_asm.S + * PURPOSE: Cross-privilege Debugging and Exception Support for ARM + * PROGRAMMERS: ReactOS Portable Systems Group */
-/* GLOBALS ********************************************************************/ + .title "ARM Kernel/User NT Debugging and Exception" + .include "ntoskrnl/include/internal/arm/kxarm.h" + .include "ntoskrnl/include/internal/arm/ksarm.h"
-.globl DbgBreakPoint - -/* FUNCTIONS ******************************************************************/ - -.func DbgBreakPoint -DbgBreakPoint: + TEXTAREA + NESTED_ENTRY DbgBreakPoint + PROLOG_END DbgBreakPoint + + // + // Do a breakpoint and return + // bkpt 3 bx lr -.endfunc + ENTRY_END DbgBreakPoint + + NESTED_ENTRY RtlCaptureContext + PROLOG_END RtlCaptureContext + + // + // FIXME: Change to stmdb later + // + str r0, [a1, #CsR0] + str r1, [a1, #CsR1] + str r2, [a1, #CsR2] + str r3, [a1, #CsR3] + str r4, [a1, #CsR4] + str r5, [a1, #CsR5] + str r6, [a1, #CsR6] + str r7, [a1, #CsR7] + str r8, [a1, #CsR8] + str r9, [a1, #CsR9] + str r10, [a1, #CsR10] + str r11, [a1, #CsR11] + str r12, [a1, #CsR12] + str sp, [a1, #CsSp] + str lr, [a1, #CsLr] + str pc, [a1, #CsPc] + mrs ip, spsr + str ip, [a1, #CsPsr] + + // + // Set flags + // + mov ip, #CONTEXT_FULL + str ip, [a1, #CsContextFlags] + + // + // Return + // + bx lr + ENTRY_END RtlCaptureContext
Modified: trunk/reactos/ntoskrnl/include/internal/arm/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/a... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/arm/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/arm/ke.h [iso-8859-1] Thu Jun 26 22:06:11 2008 @@ -13,155 +13,6 @@ #define PDR_ENTRY 2
#define KeArchHaltProcessor() KeArmHaltProcessor() - -typedef union _ARM_TTB_REGISTER -{ - struct - { - ULONG Reserved:14; - ULONG BaseAddress:18; - }; - ULONG AsUlong; -} ARM_TTB_REGISTER; - -typedef union _ARM_STATUS_REGISTER -{ - - struct - { - ULONG Mode:5; - ULONG State:1; - ULONG FiqDisable:1; - ULONG IrqDisable:1; - ULONG ImpreciseAbort:1; - ULONG Endianness:1; - ULONG Sbz:6; - ULONG GreaterEqual:4; - ULONG Sbz1:4; - ULONG Java:1; - ULONG Sbz2:2; - ULONG StickyOverflow:1; - ULONG Overflow:1; - ULONG CarryBorrowExtend:1; - ULONG Zero:1; - ULONG NegativeLessThan:1; - }; - ULONG AsUlong; -} ARM_STATUS_REGISTER; - -typedef union _ARM_DOMAIN_REGISTER -{ - struct - { - ULONG Domain0:2; - ULONG Domain1:2; - ULONG Domain2:2; - ULONG Domain3:2; - ULONG Domain4:2; - ULONG Domain5:2; - ULONG Domain6:2; - ULONG Domain7:2; - ULONG Domain8:2; - ULONG Domain9:2; - ULONG Domain10:2; - ULONG Domain11:2; - ULONG Domain12:2; - ULONG Domain13:2; - ULONG Domain14:2; - ULONG Domain15:2; - }; - ULONG AsUlong; -} ARM_DOMAIN_REGISTER; - -typedef union _ARM_CONTROL_REGISTER -{ - struct - { - ULONG MmuEnabled:1; - ULONG AlignmentFaultsEnabled:1; - ULONG DCacheEnabled:1; - ULONG Sbo:4; - ULONG BigEndianEnabled:1; - ULONG System:1; - ULONG Rom:1; - ULONG Sbz:2; - ULONG ICacheEnabled:1; - ULONG HighVectors:1; - ULONG RoundRobinReplacementEnabled:1; - ULONG Armv4Compat:1; - ULONG Sbo1:1; - ULONG Sbz1:1; - ULONG Sbo2:1; - ULONG Reserved:14; - }; - ULONG AsUlong; -} ARM_CONTROL_REGISTER, *PARM_CONTROL_REGISTER; - -typedef union _ARM_ID_CODE_REGISTER -{ - struct - { - ULONG Revision:4; - ULONG PartNumber:12; - ULONG Architecture:4; - ULONG Variant:4; - ULONG Identifier:8; - }; - ULONG AsUlong; -} ARM_ID_CODE_REGISTER, *PARM_ID_CODE_REGISTER; - -typedef union _ARM_CACHE_REGISTER -{ - struct - { - ULONG ILength:2; - ULONG IMultipler:1; - ULONG IAssociativty:3; - ULONG ISize:4; - ULONG IReserved:2; - ULONG DLength:2; - ULONG DMultipler:1; - ULONG DAssociativty:3; - ULONG DSize:4; - ULONG DReserved:2; - ULONG Separate:1; - ULONG CType:4; - ULONG Reserved:3; - }; - ULONG AsUlong; -} ARM_CACHE_REGISTER, *PARM_CACHE_REGISTER; - -typedef union _ARM_LOCKDOWN_REGISTER -{ - struct - { - ULONG Preserve:1; - ULONG Ignored:25; - ULONG Victim:3; - ULONG Reserved:3; - }; - ULONG AsUlong; -} ARM_LOCKDOWN_REGISTER, *PARM_LOCKDOWN_REGISTER; - -typedef enum _ARM_DOMAINS -{ - Domain0, - Domain1, - Domain2, - Domain3, - Domain4, - Domain5, - Domain6, - Domain7, - Domain8, - Domain9, - Domain10, - Domain11, - Domain12, - Domain13, - Domain14, - Domain15 -} ARM_DOMAINS;
VOID NTAPI
Modified: trunk/reactos/ntoskrnl/include/internal/arm/ksarm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/a... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/arm/ksarm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/arm/ksarm.h [iso-8859-1] Thu Jun 26 22:06:11 2008 @@ -60,6 +60,29 @@ */ .equ ThKernelStack, 0x20
+/* + * CONTEXT Offsets + */ +.equ CONTEXT_FULL, 0x43 +.equ CsContextFlags, 0x00 +.equ CsR0, 0x04 +.equ CsR1, 0x08 +.equ CsR2, 0x0C +.equ CsR3, 0x10 +.equ CsR4, 0x14 +.equ CsR5, 0x18 +.equ CsR6, 0x1C +.equ CsR7, 0x20 +.equ CsR8, 0x24 +.equ CsR9, 0x28 +.equ CsR10, 0x2C +.equ CsR11, 0x30 +.equ CsR12, 0x34 +.equ CsSp, 0x38 +.equ CsLr, 0x3C +.equ CsPc, 0x40 +.equ CsPsr, 0x44 + #else
/*
Modified: trunk/reactos/ntoskrnl/ke/arm/cpu.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/cpu.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/ke/arm/cpu.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/arm/cpu.c [iso-8859-1] Thu Jun 26 22:06:11 2008 @@ -115,3 +115,16 @@ // KeArmFlushTlb(); } + +VOID +NTAPI +KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState) +{ + // + // Save some critical stuff we use + // + ProcessorState->SpecialRegisters.ControlRegister = KeArmControlRegisterGet(); + ProcessorState->SpecialRegisters.LockdownRegister = KeArmLockdownRegisterGet(); + ProcessorState->SpecialRegisters.CacheRegister = KeArmCacheRegisterGet(); + ProcessorState->SpecialRegisters.StatusRegister = KeArmStatusRegisterGet(); +}
Modified: trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s... ============================================================================== --- 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 22:06:11 2008 @@ -37,7 +37,6 @@ // // Internal Ke Arch-Specific Helpers // -GENERATE_ARM_STUB KiSaveProcessorControlState GENERATE_ARM_STUB KiInitializeUserApc GENERATE_ARM_STUB KeDisableInterrupts GENERATE_ARM_STUB KiDispatchException @@ -51,7 +50,6 @@ GENERATE_ARM_STUB KiPassiveRelease GENERATE_ARM_STUB KiInterruptTemplate GENERATE_ARM_STUB KiUnexpectedInterrupt -GENERATE_ARM_STUB RtlCaptureContext GENERATE_ARM_STUB RtlGetCallersAddress GENERATE_ARM_STUB RtlUnwind GENERATE_ARM_STUB RtlpGetExceptionAddress
Modified: trunk/reactos/ntoskrnl/ke/arm/trapc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/trapc.c?rev... ============================================================================== --- trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] Thu Jun 26 22:06:11 2008 @@ -402,15 +402,19 @@ // // Check if this is a page fault // - if (KeArmFaultStatusRegisterGet() == 21 || KeArmFaultStatusRegisterGet() == 23) - { - Status = MmAccessFault(FALSE, - Address, - KernelMode, - TrapFrame); + if ((KeArmFaultStatusRegisterGet() == 21) || + (KeArmFaultStatusRegisterGet() == 23)) + { + // + // Handle the fault + // + Status = MmAccessFault(FALSE, Address, KernelMode, TrapFrame); if (Status == STATUS_SUCCESS) return Status; }
+ // + // We don't handle this yet + // UNIMPLEMENTED; while (TRUE); return STATUS_SUCCESS; @@ -439,7 +443,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 @@ -495,7 +499,6 @@ // // Copy them into the kernel stack // - DPRINT1("Argument: %p\n", *Argument); Arguments[i] = *Argument; Argument++; } @@ -536,7 +539,6 @@ // // Copy into kernel stack // - DPRINT1("Argument: %p\n", *Argument); Arguments[i] = *Argument; Argument++; } @@ -546,7 +548,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