Author: ros-arm-bringup
Date: Sat Jun 14 22:32:52 2008
New Revision: 33974
URL:
http://svn.reactos.org/svn/reactos?rev=33974&view=rev
Log:
- Fix a bug in MmGetPhysicalAddress.
- Don't hang in the clock interrupt anymore, for now we'll just ignore it (but it
works! :D)
- Make all unimplemented bootvid functions hang the system, so we can better stop at
progress-points.
- Implement VidInitialize:
- We allocate a 640x480@16bpp framebuffer using contiguous physical memory (our MMU code
survives!).
- We setup the LCD controller timings and framebuffer address.
- We enable the LCD
- For debugging, we're also drawing a nice little test pattern... and it works! We
have GUI Code :)
Modified:
trunk/reactos/drivers/base/bootvid/arm/bootvid.c
trunk/reactos/hal/halarm/generic/hal.c
trunk/reactos/ntoskrnl/mm/arm/stubs.c
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 22:32:52
2008
@@ -2,8 +2,97 @@
#define NDEBUG
#include "debug.h"
+#define LCDTIMING0_PPL(x) ((((x) / 16 - 1) & 0x3f) << 2)
+#define LCDTIMING1_LPP(x) (((x) & 0x3ff) - 1)
+#define LCDCONTROL_LCDPWR (1 << 11)
+#define LCDCONTROL_LCDEN (1)
+#define LCDCONTROL_LCDBPP(x) (((x) & 7) << 1)
+#define LCDCONTROL_LCDTFT (1 << 5)
+
+#define PL110_LCDTIMING0 (PVOID)0xE0020000
+#define PL110_LCDTIMING1 (PVOID)0xE0020004
+#define PL110_LCDTIMING2 (PVOID)0xE0020008
+#define PL110_LCDUPBASE (PVOID)0xE0020010
+#define PL110_LCDLPBASE (PVOID)0xE0020014
+#define PL110_LCDCONTROL (PVOID)0xE0020018
+
+#define READ_REGISTER_ULONG(r) (*(volatile ULONG * const)(r))
+#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG *)(r) = (v))
+
+#define READ_REGISTER_USHORT(r) (*(volatile USHORT * const)(r))
+#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT *)(r) = (v))
+
+PUSHORT VgaArmBase;
+
+typedef struct _VGA_COLOR
+{
+ UCHAR Red;
+ UCHAR Green;
+ UCHAR Blue;
+} VGA_COLOR;
+
+VGA_COLOR VidpVga8To16BitTransform[16] =
+{
+ {0x00, 0x00, 0x00}, // Black
+ {0x00, 0x00, 0x08}, // Blue
+ {0x00, 0x08, 0x00}, // Green
+ {0x00, 0x08, 0x08}, // Cyan
+ {0x08, 0x00, 0x00}, // Red
+ {0x08, 0x00, 0x08}, // Magenta
+ {0x08, 0x08, 0x00}, // Brown
+ {0x10, 0x10, 0x10}, // Light Gray
+ {0x08, 0x08, 0x08}, // Dark Gray
+ {0x00, 0x00, 0x1F}, // Light Blue
+ {0x00, 0x1F, 0x00}, // Light Green
+ {0x00, 0x1F, 0x1F}, // Light Cyan
+ {0x1F, 0x00, 0x00}, // Light Red
+ {0x1F, 0x00, 0x1F}, // Light Magenta
+ {0x1F, 0x1F, 0x00}, // Yellow
+ {0x1F, 0x1F, 0x1F}, // White
+};
+
/* PRIVATE FUNCTIONS *********************************************************/
+USHORT
+FORCEINLINE
+VidpBuildColor(IN UCHAR Color)
+{
+ UCHAR Red, Green, Blue;
+
+ //
+ // Extract color components
+ //
+ Red = VidpVga8To16BitTransform[Color].Red;
+ Green = VidpVga8To16BitTransform[Color].Green;
+ Blue = VidpVga8To16BitTransform[Color].Blue;
+
+ //
+ // Build the 16-bit color mask
+ //
+ return ((Blue & 0x1F) << 11) | ((Green & 0x1F) << 6) | ((Red
& 0x1F));
+}
+
+
+VOID
+FORCEINLINE
+VidpSetPixel(IN ULONG Left,
+ IN ULONG Top,
+ IN UCHAR Color)
+{
+ PUSHORT PixelPosition;
+
+ //
+ // Calculate the pixel position
+ //
+ PixelPosition = &VgaArmBase[Left + (Top * 640)];
+
+ //
+ // Set our color
+ //
+ WRITE_REGISTER_USHORT(PixelPosition, VidpBuildColor(Color));
+}
+
+
/* PUBLIC FUNCTIONS **********************************************************/
/*
@@ -12,11 +101,67 @@
BOOLEAN
NTAPI
VidInitialize(IN BOOLEAN SetMode)
-{
- DPRINT1("bv-arm\n");
- UNIMPLEMENTED;
- while (TRUE);
- return FALSE;
+{
+ 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);
+
+ //
+ // Set framebuffer address
+ //
+ WRITE_REGISTER_ULONG(PL110_LCDUPBASE, Physical.LowPart);
+ WRITE_REGISTER_ULONG(PL110_LCDLPBASE, Physical.LowPart);
+
+ //
+ // Initialize timings to 640x480
+ //
+ WRITE_REGISTER_ULONG(PL110_LCDTIMING0, LCDTIMING0_PPL(640));
+ WRITE_REGISTER_ULONG(PL110_LCDTIMING1, LCDTIMING1_LPP(480));
+
+ //
+ // Enable the LCD Display
+ //
+ WRITE_REGISTER_ULONG(PL110_LCDCONTROL,
+ LCDCONTROL_LCDEN |
+ LCDCONTROL_LCDTFT |
+ LCDCONTROL_LCDPWR |
+ LCDCONTROL_LCDBPP(4));
+
+#if DBG
+ //
+ // Draw an RGB test pattern
+ //
+ int y, x;
+ for (y = 0; y < 480; y += 40)
+ {
+ for (x = 0; x < 640; x++)
+ {
+ VidpSetPixel(x, y, 12);
+ VidpSetPixel(x, y + 10, 9);
+ VidpSetPixel(x, y + 20, 10);
+ VidpSetPixel(x, y + 30, 15);
+ }
+ }
+#endif
+
+ //
+ // We are done!
+ //
+ return TRUE;
}
/*
@@ -27,6 +172,7 @@
VidResetDisplay(IN BOOLEAN HalReset)
{
UNIMPLEMENTED;
+ while (TRUE);
}
/*
@@ -37,6 +183,7 @@
VidSetTextColor(ULONG Color)
{
UNIMPLEMENTED;
+ while (TRUE);
return 0;
}
@@ -51,6 +198,7 @@
BOOLEAN Transparent)
{
UNIMPLEMENTED;
+ while (TRUE);
}
/*
@@ -64,6 +212,7 @@
ULONG y2)
{
UNIMPLEMENTED;
+ while (TRUE);
}
/*
@@ -74,6 +223,7 @@
VidCleanUp(VOID)
{
UNIMPLEMENTED;
+ while (TRUE);
}
/*
@@ -89,6 +239,7 @@
IN ULONG Delta)
{
UNIMPLEMENTED;
+ while (TRUE);
}
/*
@@ -99,6 +250,7 @@
VidDisplayString(PUCHAR String)
{
UNIMPLEMENTED;
+ while (TRUE);
}
/*
@@ -111,6 +263,7 @@
ULONG Top)
{
UNIMPLEMENTED;
+ while (TRUE);
}
/*
@@ -126,6 +279,7 @@
ULONG Delta)
{
UNIMPLEMENTED;
+ while (TRUE);
}
/*
@@ -140,5 +294,5 @@
IN UCHAR Color)
{
UNIMPLEMENTED;
-}
-
+ while (TRUE);
+}
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 22:32:52 2008
@@ -529,9 +529,9 @@
//
// Clear the interrupt
//
- DPRINT1("CLOCK INTERRUPT!!!\n");
+ //DPRINT1("CLOCK INTERRUPT!!!\n");
WRITE_REGISTER_ULONG(TIMER_INT_CLEAR, 1);
- while (TRUE);
+ //while (TRUE);
}
VOID
Modified: trunk/reactos/ntoskrnl/mm/arm/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/arm/stubs.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/arm/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/arm/stubs.c [iso-8859-1] Sat Jun 14 22:32:52 2008
@@ -583,7 +583,7 @@
//
// Return the information
//
- ASSERT(PointerPte->u.Hard.L2.Small.Type != SmallPte);
+ ASSERT(PointerPte->u.Hard.L2.Small.Type == SmallPte);
PhysicalAddress.QuadPart = PointerPte->u.Hard.L2.Small.BaseAddress;
PhysicalAddress.QuadPart <<= PAGE_SHIFT;
PhysicalAddress.LowPart += BYTE_OFFSET(Address);