Author: ros-arm-bringup
Date: Sat Jun 14 23:43:22 2008
New Revision: 33976
URL: http://svn.reactos.org/svn/reactos?rev=33976&view=rev
Log:
- Copy/pasted a bunch of code from the i386 bootvid for text output.
- Don't implement BitBlt for now.
- Add the bootdata font file to the arm bootvid as well.
- Not sure how it's possible, but we are seeing text output on the console with this hacked-up code! The ReactOS version string appears...
- We are now getting much further in the boot cycle.
Added:
trunk/reactos/drivers/base/bootvid/arm/bootdata.c
- copied unchanged from r33973, trunk/reactos/drivers/base/bootvid/i386/bootdata.c
Modified:
trunk/reactos/drivers/base/bootvid/arm/bootvid.c
trunk/reactos/drivers/base/bootvid/bootvid.rbuild
Modified: trunk/reactos/drivers/base/bootvid/arm/bootvid.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/bootvid/arm/b…
==============================================================================
--- trunk/reactos/drivers/base/bootvid/arm/bootvid.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/bootvid/arm/bootvid.c [iso-8859-1] Sat Jun 14 23:43:22 2008
@@ -23,6 +23,7 @@
#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT *)(r) = (v))
PUSHORT VgaArmBase;
+BOOLEAN NextLine = FALSE;
UCHAR VidpTextColor = 0xF;
ULONG VidpCurrentX = 0;
ULONG VidpCurrentY = 0;
@@ -102,6 +103,146 @@
WRITE_REGISTER_USHORT(PixelPosition, VidpBuildColor(Color));
}
+VOID
+NTAPI
+DisplayCharacter(CHAR Character,
+ ULONG Left,
+ ULONG Top,
+ ULONG TextColor,
+ ULONG BackTextColor)
+{
+ PUCHAR FontChar;
+ ULONG i, j, XOffset;
+
+ /* Get the font line for this character */
+ FontChar = &FontData[Character * 13 - Top];
+
+ /* Loop each pixel height */
+ i = 13;
+ do
+ {
+ /* Loop each pixel width */
+ j = 128;
+ XOffset = Left;
+ do
+ {
+ /* Check if we should draw this pixel */
+ if (FontChar[Top] & (UCHAR)j)
+ {
+ /* We do, use the given Text Color */
+ VidpSetPixel(XOffset, Top, (UCHAR)TextColor);
+ }
+ else if (BackTextColor < 16)
+ {
+ /* This is a background pixel. We're drawing it unless it's */
+ /* transparent. */
+ VidpSetPixel(XOffset, Top, (UCHAR)BackTextColor);
+ }
+
+ /* Increase X Offset */
+ XOffset++;
+ } while (j >>= 1);
+
+ /* Move to the next Y ordinate */
+ Top++;
+ } while (--i);
+}
+
+VOID
+NTAPI
+VgaScroll(ULONG Scroll)
+{
+ ULONG Top, Offset;
+ PUSHORT SourceOffset, DestOffset;
+ PUSHORT i, j;
+
+ /* Set memory positions of the scroll */
+ SourceOffset = &VgaArmBase[(VidpScrollRegion[1] * 80) + (VidpScrollRegion[0] >> 3)];
+ DestOffset = &SourceOffset[Scroll * 80];
+
+ /* Save top and check if it's above the bottom */
+ Top = VidpScrollRegion[1];
+ if (Top > VidpScrollRegion[3]) return;
+
+ /* Start loop */
+ do
+ {
+ /* Set number of bytes to loop and start offset */
+ Offset = VidpScrollRegion[0] >> 3;
+ j = SourceOffset;
+
+ /* Check if this is part of the scroll region */
+ if (Offset <= (VidpScrollRegion[2] >> 3))
+ {
+ /* Update position */
+ i = (PUSHORT)(DestOffset - SourceOffset);
+
+ /* Loop the X axis */
+ do
+ {
+ /* Write value in the new position so that we can do the scroll */
+ WRITE_REGISTER_USHORT(j, READ_REGISTER_USHORT(j + (ULONG_PTR)i));
+
+ /* Move to the next memory location to write to */
+ j++;
+
+ /* Move to the next byte in the region */
+ Offset++;
+
+ /* Make sure we don't go past the scroll region */
+ } while (Offset <= (VidpScrollRegion[2] >> 3));
+ }
+
+ /* Move to the next line */
+ SourceOffset += 80;
+ DestOffset += 80;
+
+ /* Increase top */
+ Top++;
+
+ /* Make sure we don't go past the scroll region */
+ } while (Top <= VidpScrollRegion[3]);
+}
+
+VOID
+NTAPI
+PreserveRow(IN ULONG CurrentTop,
+ IN ULONG TopDelta,
+ IN BOOLEAN Direction)
+{
+ PUSHORT Position1, Position2;
+ ULONG Count;
+
+ /* Check which way we're preserving */
+ if (Direction)
+ {
+ /* Calculate the position in memory for the row */
+ Position1 = &VgaArmBase[CurrentTop * 80];
+ Position2 = &VgaArmBase[0x9600];
+ }
+ else
+ {
+ /* Calculate the position in memory for the row */
+ Position1 = &VgaArmBase[0x9600];
+ Position2 = &VgaArmBase[CurrentTop * 80];
+ }
+
+ /* Set the count and make sure it's above 0 */
+ Count = TopDelta * 80;
+ if (Count)
+ {
+ /* Loop every pixel */
+ do
+ {
+ /* Write the data back on the other position */
+ WRITE_REGISTER_USHORT(Position1, READ_REGISTER_USHORT(Position2));
+
+ /* Increase both positions */
+ Position2++;
+ Position1++;
+ } while (--Count);
+ }
+}
/* PUBLIC FUNCTIONS **********************************************************/
@@ -279,8 +420,81 @@
NTAPI
VidDisplayString(PUCHAR String)
{
- UNIMPLEMENTED;
- while (TRUE);
+ ULONG TopDelta = 14;
+
+ /* Start looping the string */
+ while (*String)
+ {
+ /* Treat new-line separately */
+ if (*String == '\n')
+ {
+ /* Modify Y position */
+ VidpCurrentY += TopDelta;
+ if (VidpCurrentY >= VidpScrollRegion[3])
+ {
+ /* Scroll the view */
+ VgaScroll(TopDelta);
+ VidpCurrentY -= TopDelta;
+
+ /* Preserve row */
+ PreserveRow(VidpCurrentY, TopDelta, TRUE);
+ }
+
+ /* Update current X */
+ VidpCurrentX = VidpScrollRegion[0];
+
+ /* Preseve the current row */
+ PreserveRow(VidpCurrentY, TopDelta, FALSE);
+ }
+ else if (*String == '\r')
+ {
+ /* Update current X */
+ VidpCurrentX = VidpScrollRegion[0];
+
+ /* Check if we're being followed by a new line */
+ if (String[1] != '\n') NextLine = TRUE;
+ }
+ else
+ {
+ /* Check if we had a \n\r last time */
+ if (NextLine)
+ {
+ /* We did, preserve the current row */
+ PreserveRow(VidpCurrentY, TopDelta, TRUE);
+ NextLine = FALSE;
+ }
+
+ /* Display this character */
+ DisplayCharacter(*String,
+ VidpCurrentX,
+ VidpCurrentY,
+ VidpTextColor,
+ 16);
+ VidpCurrentX += 8;
+
+ /* Check if we should scroll */
+ if (VidpCurrentX > VidpScrollRegion[2])
+ {
+ /* Update Y position and check if we should scroll it */
+ VidpCurrentY += TopDelta;
+ if (VidpCurrentY > VidpScrollRegion[3])
+ {
+ /* Do the scroll */
+ VgaScroll(TopDelta);
+ VidpCurrentY -= TopDelta;
+
+ /* Save the row */
+ PreserveRow(VidpCurrentY, TopDelta, TRUE);
+ }
+
+ /* Update X */
+ VidpCurrentX = VidpScrollRegion[0];
+ }
+ }
+
+ /* Get the next character */
+ String++;
+ }
}
/*
@@ -293,7 +507,7 @@
ULONG Top)
{
UNIMPLEMENTED;
- while (TRUE);
+ //while (TRUE);
}
/*
Modified: trunk/reactos/drivers/base/bootvid/bootvid.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/bootvid/bootv…
==============================================================================
--- trunk/reactos/drivers/base/bootvid/bootvid.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/bootvid/bootvid.rbuild [iso-8859-1] Sat Jun 14 23:43:22 2008
@@ -16,6 +16,7 @@
<if property="ARCH" value="arm">
<directory name="arm">
<file>bootvid.c</file>
+ <file>bootdata.c</file>
</directory>
</if>
<file>bootvid.rc</file>
Author: ros-arm-bringup
Date: Sat Jun 14 17:28:40 2008
New Revision: 33969
URL: http://svn.reactos.org/svn/reactos?rev=33969&view=rev
Log:
- Implement the basic stall interrupt to be used to calculate the factors for KeStallExecution (using NT MIPS algorithm, hope this will work)
- Also written KeStallExecution.
- Now, we are back to where we hang before Phase 1 (so Phase 1 doesn't occur anymore).
- This hang is because we used to do a DPC here, which isn't good, since IRQL is already at dispatch.
- Instead, the correct course of action is to enter the idle loop, which will schedule the phase 1 thread.
- But, we don't have an idle loop yet ;-)
Modified:
trunk/reactos/hal/halarm/generic/hal.c
Modified: trunk/reactos/hal/halarm/generic/hal.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halarm/generic/hal.c?r…
==============================================================================
--- trunk/reactos/hal/halarm/generic/hal.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halarm/generic/hal.c [iso-8859-1] Sat Jun 14 17:28:40 2008
@@ -504,6 +504,8 @@
asm ("clz\t%0, %1": "=r" (__value): "r" (__arg)); \
__value; })
+ULONG HalpStallStart, HalpStallEnd, HalpStallScaleFactor;
+
ULONG
HalGetInterruptSource(VOID)
{
@@ -517,15 +519,53 @@
}
VOID
-HalpStallInterrupt(VOID)
-{
- DPRINT1("STALL INTERRUPT!!!\n");
-
+HalpClockInterrupt(VOID)
+{
//
// Clear the interrupt
//
+ DPRINT1("CLOCK INTERRUPT!!!\n");
WRITE_REGISTER_ULONG(TIMER_INT_CLEAR, 1);
while (TRUE);
+}
+
+VOID
+HalpStallInterrupt(VOID)
+{
+ //
+ // Clear the interrupt
+ //
+ DPRINT1("STALL INTERRUPT!!!: %lx %lx\n", HalpStallStart, HalpStallEnd);
+ WRITE_REGISTER_ULONG(TIMER_INT_CLEAR, 1);
+
+ //
+ // Check if this is our first time here
+ //
+ if (!(HalpStallStart + HalpStallEnd))
+ {
+ //
+ // Remember that we've been hit once
+ //
+ HalpStallEnd = 1;
+ }
+ else if (!(HalpStallStart) && (HalpStallEnd))
+ {
+ //
+ // Okay, this is our second time here!
+ // Load the stall execution count that was setup for us...
+ // And get ready to hit the case below
+ //
+ HalpStallStart = PCR->StallExecutionCount;
+ HalpStallEnd = 0;
+ }
+ else if ((HalpStallStart) && !(HalpStallEnd))
+ {
+ //
+ // This our third time here!
+ // Now we can just save the stall execution count at end time
+ //
+ HalpStallEnd = PCR->StallExecutionCount;
+ }
}
VOID
@@ -553,7 +593,7 @@
// (TIMCLKENXdiv (1) * PRESCALEdiv (1))
//
ClockInterval = 0x2710;
-
+
//
// Enable the timer
//
@@ -766,66 +806,22 @@
FASTCALL
HalRequestSoftwareInterrupt(IN KIRQL Request)
{
- ULONG Interrupt = 0;
-
- //
- // Get the interrupt that maches this IRQL level
- //
- switch (Request)
- {
- case APC_LEVEL:
-
- Interrupt = 1 << 1;
- break;
-
- case DISPATCH_LEVEL:
-
- Interrupt = 1 << 2;
- break;
-
- default:
-
- ASSERT(FALSE);
- }
-
//
// Force a software interrupt
//
- DPRINT1("About to force interrupt mask: %d\n", Interrupt);
- WRITE_REGISTER_ULONG(VICSOFTINT, Interrupt);
+ DPRINT1("[SOFTINT]: %d\n", Request);
+ WRITE_REGISTER_ULONG(VICSOFTINT, 1 << Request);
}
VOID
FASTCALL
HalClearSoftwareInterrupt(IN KIRQL Request)
-{
- ULONG Interrupt = 0;
-
- //
- // Get the interrupt that maches this IRQL level
- //
- switch (Request)
- {
- case APC_LEVEL:
-
- Interrupt = 1 << 1;
- break;
-
- case DISPATCH_LEVEL:
-
- Interrupt = 1 << 2;
- break;
-
- default:
-
- ASSERT(FALSE);
- }
-
+{
//
// Force a software interrupt
//
- DPRINT1("About to kill interrupt mask: %d\n", Interrupt);
- WRITE_REGISTER_ULONG(VICSOFTINTCLEAR, Interrupt);
+ DPRINT1("[SOFTINTC] %d\n", Request);
+ WRITE_REGISTER_ULONG(VICSOFTINTCLEAR, 1 << Request);
}
VOID
@@ -1091,7 +1087,20 @@
KeStallExecutionProcessor(
ULONG Microseconds)
{
- UNIMPLEMENTED;
+ ULONG Index;
+
+ //
+ // Calculate how many times we should loop
+ //
+ Index = Microseconds * PCR->StallScaleFactor;
+ while (Index)
+ {
+ //
+ // Do one stall cycle
+ //
+ PCR->StallExecutionCount++;
+ Index--;
+ };
}
VOID