Author: fireball
Date: Thu Jun 21 23:59:47 2007
New Revision: 27256
URL:
http://svn.reactos.org/svn/reactos?rev=27256&view=rev
Log:
- Map framebuffer before jumping to the kernel (so we can do text output in the kernel
early boot stage).
- Shut down USB controller before jumping to the kernel.
- Fix memory map (convert int property), also add a hack there to not touch anything above
0x700000.
Modified:
branches/olpc/boot/freeldr/freeldr/arch/i386/loader.c
branches/olpc/boot/freeldr/freeldr/arch/i386/macholpc.c
branches/olpc/boot/freeldr/freeldr/arch/i386/mb.S
Modified: branches/olpc/boot/freeldr/freeldr/arch/i386/loader.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/loader.c (original)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/loader.c Thu Jun 21 23:59:47 2007
@@ -44,6 +44,11 @@
extern PAGE_DIRECTORY_X86 apic_pagetable;
extern PAGE_DIRECTORY_X86 kpcr_pagetable;
extern PAGE_DIRECTORY_X86 kuser_pagetable;
+extern PAGE_DIRECTORY_X86 framebuffer_pagetable;
+
+#define FRAMEBUFFER_PHYS 0xFD000000
+#define FRAMEBUFFER_VIRT 0xFF000000
+#define FRAMEBUFFER_SIZE 2 * 1024 * 1024
PVOID
NTAPI
@@ -73,6 +78,9 @@
NTAPI
FrLdrStartup(ULONG Magic)
{
+ /* Goodbye OFW */
+ OFInterpret0("usb-quiet");
+
/* Disable Interrupts */
_disable();
@@ -189,6 +197,11 @@
PageDir->Pde[KuserPageTableIndex].Valid = 1;
PageDir->Pde[KuserPageTableIndex].Write = 1;
PageDir->Pde[KuserPageTableIndex].PageFrameNumber = PaPtrToPfn(kuser_pagetable);
+
+ /* Set up framebuffer mapping PDE */
+ PageDir->Pde[FRAMEBUFFER_VIRT >> PDE_SHIFT].Valid = 1;
+ PageDir->Pde[FRAMEBUFFER_VIRT >> PDE_SHIFT].Write = 1;
+ PageDir->Pde[FRAMEBUFFER_VIRT >> PDE_SHIFT].PageFrameNumber =
PaPtrToPfn(framebuffer_pagetable);
/* Set up Low Memory PTEs */
PageDir = (PPAGE_DIRECTORY_X86)&lowmem_pagetable;
@@ -238,6 +251,16 @@
PageDir->Pde[i].Owner = 1;
PageDir->Pde[i].PageFrameNumber = PaToPfn(KI_USER_SHARED_DATA + i *
PAGE_SIZE);
}
+
+ /* Set up Framebuffer PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&framebuffer_pagetable;
+ for (i=0; i<512; i++)
+ {
+ PageDir->Pde[i].Valid = 1;
+ PageDir->Pde[i].Write = 1;
+ PageDir->Pde[i].PageFrameNumber = PaToPfn(FRAMEBUFFER_PHYS + i * PAGE_SIZE);
+ }
+
}
PLOADER_MODULE
Modified: branches/olpc/boot/freeldr/freeldr/arch/i386/macholpc.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/macholpc.c (original)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/macholpc.c Thu Jun 21 23:59:47 2007
@@ -28,11 +28,13 @@
char BootPath[0x100] = { 0 }, BootPart[0x100] = { 0 }, CmdLine[0x100] = {
"bootprep" };
+int decode_int(UCHAR *p);
VOID OlpcVideoInit();
VOID
XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG
Minute, PULONG Second);
+ULONG_PTR MemMin, MemMax; // OFW can report whole physical memory region
VOID
OlpcMachInit(const char *CmdLine_)
@@ -151,10 +153,25 @@
memhandle = OFFinddevice("/memory");
+ /* Get Max/Min memory boundaries */
+ returned = OFGetprop(memhandle, "reg",
+ (char *)memdata, sizeof(memdata));
+
+ ofwprintf("Returned 'reg' data: %d\n", returned);
+ if( returned == -1 )
+ {
+ ofwprintf("getprop /memory[@reg] failed\n");
+ return 0;
+ }
+ MemMin = decode_int(&memdata[0]);
+ MemMax = MemMin + decode_int(&memdata[1]);
+ ofwprintf("Memory start: %x, memory end: %x\n", MemMin, MemMax);
+
+ /* Get unclaimed regions */
returned = OFGetprop(memhandle, "available",
(char *)memdata, sizeof(memdata));
- ofwprintf("Returned data: %d\n", returned);
+ ofwprintf("Returned 'available' data: %d\n", returned);
if( returned == -1 ) {
ofwprintf("getprop /memory[@reg] failed\n");
return 0;
@@ -165,36 +182,40 @@
}
ofwprintf("\n");
- for( i = 0; i < returned / 2; i++ ) {
- BiosMemoryMap[slots].Type = 1/*MEMTYPE_USABLE*/;
- BiosMemoryMap[slots].BaseAddress = memdata[i*2];
- BiosMemoryMap[slots].Length = memdata[i*2+1];
- ofwprintf("MemoryMap[%d] = (%x:%x)\n",
- i,
- (int)BiosMemoryMap[slots].BaseAddress,
- (int)BiosMemoryMap[slots].Length);
-
- /* Hack for pearpc */
- if(/* kernel_mem */FALSE) {
- /*BiosMemoryMap[slots].Length = kernel_mem * 1024;
- if( !FixedMemory ) {
- OFClaim((int)BiosMemoryMap[slots].BaseAddress,
- (int)BiosMemoryMap[slots].Length,
- 0x1000);
- FixedMemory = BiosMemoryMap[slots].BaseAddress;
- }
- total += BiosMemoryMap[slots].Length;
- slots++;*/
- break;
- /* Normal way */
- } else if( BiosMemoryMap[slots].Length &&
- OFClaim((int)BiosMemoryMap[slots].BaseAddress,
- (int)BiosMemoryMap[slots].Length,
- 0x1000) ) {
- total += BiosMemoryMap[slots].Length;
- slots++;
- }
- }
+ for( i = 0; i < returned / 2; i++ )
+ {
+ if (decode_int(&memdata[i*2]) > 0x7000000)
+ continue;
+
+ BiosMemoryMap[slots].Type = 1/*MEMTYPE_USABLE*/;
+ BiosMemoryMap[slots].BaseAddress = decode_int(&memdata[i*2]);
+ BiosMemoryMap[slots].Length = decode_int(&memdata[i*2+1]);
+ ofwprintf("MemoryMap[%d] = (%x:%x)\n",
+ i,
+ (int)BiosMemoryMap[slots].BaseAddress,
+ (int)BiosMemoryMap[slots].Length);
+
+ /* Hack for pearpc */
+ if(/* kernel_mem */FALSE) {
+ /*BiosMemoryMap[slots].Length = kernel_mem * 1024;
+ if( !FixedMemory ) {
+ OFClaim((int)BiosMemoryMap[slots].BaseAddress,
+ (int)BiosMemoryMap[slots].Length,
+ 0x1000);
+ FixedMemory = BiosMemoryMap[slots].BaseAddress;
+ }
+ total += BiosMemoryMap[slots].Length;
+ slots++;*/
+ break;
+ /* Normal way */
+ } else if( BiosMemoryMap[slots].Length &&
+ OFClaim((int)BiosMemoryMap[slots].BaseAddress,
+ (int)BiosMemoryMap[slots].Length,
+ 0x1000) ) {
+ total += BiosMemoryMap[slots].Length;
+ slots++;
+ }
+ }
ofwprintf( "Returning memory map (%dk total)\n", total / 1024 );
Modified: branches/olpc/boot/freeldr/freeldr/arch/i386/mb.S
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/mb.S (original)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/mb.S Thu Jun 21 23:59:47 2007
@@ -38,6 +38,7 @@
.globl _apic_pagetable
.globl _kpcr_pagetable
.globl _kuser_pagetable
+ .globl _framebuffer_pagetable
.globl _PageDirectoryEnd
@@ -76,4 +77,7 @@
_kuser_pagetable:
.fill 4096, 1, 0
+_framebuffer_pagetable:
+ .fill 4096, 1, 0
+
_PageDirectoryEnd: