Author: arty Date: Mon Oct 2 02:57:16 2006 New Revision: 24357
URL: http://svn.reactos.org/svn/reactos?rev=24357&view=rev Log: A 'boot logo' of sorts to show we're about to switch to kernel mode. We'll pass the FB address into kernel land so we can continue writing on it.
Added: branches/powerpc/reactos/include/reactos/ppcboot.h Modified: branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mmu.c branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mmu.h
Modified: branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c URL: http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/fre... ============================================================================== --- branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c (original) +++ branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c Mon Oct 2 02:57:16 2006 @@ -201,11 +201,31 @@ } }
+/* Appropriated from linux' btext.c + * author: + * Benjamin Herrenschmidt benh@kernel.crashing.org + */ VOID PpcVideoPrepareForReactOS() { - int i, j, display_handle, display_size = 0; + int i, j, k, /* display_handle, */ display_package, display_size = 0; int node, ret, elts; - pci_reg_property display_regs[8]; + int device_address; + //pci_reg_property display_regs[8]; char type[256], path[256], name[256]; + char logo[] = { + " " + " XXXXXX " + " X X " + " X X X X " + " X X " + " X XXXX X " + " X XX X " + " X X " + " XXXXXX " + " " + }; + int logo_x = 10, logo_y = 10; + int logo_scale_x = 8, logo_scale_y = 8; +
for( node = ofw_finddevice("/"); prom_next_node(&node); ) { memset(type, 0, sizeof(type)); @@ -231,62 +251,56 @@ }
printf("Opening display package: %s\n", path); - - display_handle = ofw_open(path); - - printf("display handle %x\n", display_handle); + display_package = ofw_finddevice(path); + printf("display package %x\n", display_package);
BootInfo.dispDeviceRect[0] = BootInfo.dispDeviceRect[1] = 0;
- ofw_getprop(display_handle, "width", + ofw_getprop(display_package, "width", (void *)&BootInfo.dispDeviceRect[2], sizeof(int)); - ofw_getprop(display_handle, "height", + ofw_getprop(display_package, "height", (void *)&BootInfo.dispDeviceRect[3], sizeof(int)); - ofw_getprop(display_handle, "depth", + ofw_getprop(display_package, "depth", (void *)&BootInfo.dispDeviceDepth, sizeof(int)); - ofw_getprop(display_handle, "linebytes", + ofw_getprop(display_package, "linebytes", (void *)&BootInfo.dispDeviceRowBytes, sizeof(int));
+ BootInfo.dispDeviceRect[2] = REV(BootInfo.dispDeviceRect[2]); + BootInfo.dispDeviceRect[3] = REV(BootInfo.dispDeviceRect[3]); + BootInfo.dispDeviceDepth = REV(BootInfo.dispDeviceDepth); + BootInfo.dispDeviceRowBytes = REV(BootInfo.dispDeviceRowBytes); + if(ofw_getprop - (display_handle, + (display_package, "address", - (void *)&BootInfo.dispDeviceBase, - sizeof(BootInfo.dispDeviceBase)) > 0) { - goto finish; - } - - if((elts = ofw_getprop(display_handle, - "assigned-addresses", - (void *)display_regs, - sizeof(display_regs))) <= 0) { - printf("Could not get assigned addresses\n"); + (void *)&device_address, + sizeof(device_address)) < 1) { + printf("Could not get device base\n"); return; }
- elts /= sizeof(display_regs[0]); - for( i = 0; i < elts; i++ ) { - display_size = display_regs[i].size_lo; - if( display_size >= (1 << 20) ) { - BootInfo.dispDeviceBase = (void *)display_regs[i].addr.a_lo; - - /* Map pages for display at some location */ - BootInfo.logicalDisplayBase = (void *)0xc0000000; - - for( i = 0; i < display_size; i += (1 << 12) ) { - InsertPageEntry((ULONG_PTR)((PCHAR)BootInfo.logicalDisplayBase)+i, - (ULONG_PTR)((PCHAR)BootInfo.dispDeviceBase)+i); + BootInfo.dispDeviceBase = (PVOID)(REV(device_address)); + + display_size = BootInfo.dispDeviceRowBytes * BootInfo.dispDeviceRect[3]; + + printf("Display size is %x bytes (%x per row times %x rows)\n", + display_size, + BootInfo.dispDeviceRowBytes, + BootInfo.dispDeviceRect[3]); + + printf("display is at %x\n", BootInfo.dispDeviceBase); + + for( i = 0; i < logo_y * logo_scale_y; i++ ) { + for( j = 0; j < logo_x * logo_scale_x; j++ ) { + elts = (j/logo_scale_x) + ((i/logo_scale_y) * logo_x); + + for( k = 0; k < BootInfo.dispDeviceDepth/8; k++ ) { + SetPhysByte(((ULONG_PTR)BootInfo.dispDeviceBase)+ + k + + ((j * (BootInfo.dispDeviceDepth/8)) + + (i * (BootInfo.dispDeviceRowBytes))), + logo[elts] == ' ' ? 0 : 255); } - } - } - -finish: - /* Draw something ... */ - elts = 0; - for( i = 0; i < BootInfo.dispDeviceRect[3]; i++ ) { - for( j = 0; j < BootInfo.dispDeviceRect[2]; j++ ) { - ((PCHAR)BootInfo.logicalDisplayBase) - [(j * (BootInfo.dispDeviceDepth/8)) + - (i * (BootInfo.dispDeviceRowBytes))] = elts++; } } }
Modified: branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mmu.c URL: http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/fre... ============================================================================== --- branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mmu.c (original) +++ branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mmu.c Mon Oct 2 02:57:16 2006 @@ -4,6 +4,12 @@ inline int GetMSR() { register int res asm ("r3"); __asm__("mfmsr 3"); + return res; +} + +inline int GetDEC() { + register int res asm ("r3"); + __asm__("mfdec 3"); return res; }
@@ -15,8 +21,12 @@ "xori 3,3,4\n\t" /* Undo effects of LE without swapping */ "andi. 6,5,0xffef\n\t"/* turn off MSR[DR] */ "mtmsr 6\n\t" + "isync\n\t" + "sync\n\t" "lwz 3,0(3)\n\t" /* Get actual value at phys addr r3 */ "mtmsr 5\n\t" + "isync\n\t" + "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" @@ -31,8 +41,35 @@ "xori 3,3,4\n\t" /* Undo effects of LE without swapping */ "andi. 6,5,0xffef\n\t"/* turn off MSR[DR] */ "mtmsr 6\n\t" - "stw 4,0(3)\n\t" /* Get actual value at phys addr r3 */ + "sync\n\t" + "eieio\n\t" + "stw 4,0(3)\n\t" /* Set actual value at phys addr r3 */ + "dcbst 0,3\n\t" "mtmsr 5\n\t" + "sync\n\t" + "eieio\n\t" + "mr 3,4\n\t" + "lwz 0,0(1)\n\t" + "addi 1,1,16\n\t" + "mtlr 0\n\t" + "blr" + ); + +__asm__("\t.globl SetPhysByte\n" + "SetPhysByte:\t\n" + "mflr 0\n\t" + "stwu 0,-16(1)\n\t" + "mfmsr 5\n\t" + "xori 3,3,7\n\t" /* Undo effects of LE without swapping */ + "andi. 6,5,0xffef\n\t"/* turn off MSR[DR] */ + "mtmsr 6\n\t" + "sync\n\t" + "eieio\n\t" + "stb 4,0(3)\n\t" /* Set actual value at phys addr r3 */ + "dcbst 0,3\n\t" + "mtmsr 5\n\t" + "sync\n\t" + "eieio\n\t" "mr 3,4\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" @@ -183,6 +220,7 @@ break; } } + __asm__("isync\n\tsync"); }
inline int GetSDR1() {
Modified: branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mmu.h URL: http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/fre... ============================================================================== --- branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mmu.h (original) +++ branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mmu.h Mon Oct 2 02:57:16 2006 @@ -1,9 +1,11 @@ #ifndef FREELDR_MMU_H #define FREELDR_MMU_H
+int GetDEC(); int GetMSR(); int GetPhys( int addr ); void SetPhys( int addr, int val ); +void SetPhysByte( int addr, int val ); int GetSR(int n); void GetBat( int bat, int inst, int *batHi, int *batLo ); void SetBat( int bat, int inst, int batHi, int batLo );
Added: branches/powerpc/reactos/include/reactos/ppcboot.h URL: http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/include/reactos/... ============================================================================== --- branches/powerpc/reactos/include/reactos/ppcboot.h (added) +++ branches/powerpc/reactos/include/reactos/ppcboot.h Mon Oct 2 02:57:16 2006 @@ -1,0 +1,11 @@ +#ifndef REACTOS_PPCBOOT_H +#define REACTOS_PPCBOOT_H + +typedef struct _boot_infos_t { + int dispDeviceRect[4]; + int dispDeviceRowBytes; + int dispDeviceDepth; + void *dispDeviceBase; +} boot_infos_t; + +#endif/*REACTOS_PPCBOOT_H*/