Author: arty
Date: Tue Jun 27 17:03:35 2006
New Revision: 22666
URL:
http://svn.reactos.org/svn/reactos?rev=22666&view=rev
Log:
- LE Stubs fully correct and we can move freely between freeldr and ofwboot.
- Small tweaking.
- Added build for ppc-le2be, cause it's needed to mangle freeldr into a
correct ofwboot payload.
- Some cleaning in ofwboot.
Added:
branches/powerpc/reactos/tools/ppc-le2be.mak
Modified:
branches/powerpc/reactos/boot/freeldr/bootsect/ofw_tests/ofwtest.s
branches/powerpc/reactos/boot/freeldr/bootsect/ofw_util.s
branches/powerpc/reactos/boot/freeldr/bootsect/ofwboot.s
branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/boot.s
branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c
branches/powerpc/reactos/boot/freeldr/freeldr/include/of.h
branches/powerpc/reactos/tools/ofw_interface/calls.ofw
branches/powerpc/reactos/tools/ofw_interface/ofw_interface.cpp
branches/powerpc/reactos/tools/ppc.lost+found/link-freeldr
branches/powerpc/reactos/tools/tools.mak
Modified: branches/powerpc/reactos/boot/freeldr/bootsect/ofw_tests/ofwtest.s
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/bo…
==============================================================================
--- branches/powerpc/reactos/boot/freeldr/bootsect/ofw_tests/ofwtest.s (original)
+++ branches/powerpc/reactos/boot/freeldr/bootsect/ofw_tests/ofwtest.s Tue Jun 27 17:03:35
2006
@@ -5,12 +5,8 @@
.long 0
.long 0
- .globl ofw_functions_addr
.globl ofw_dumpregs
-ofw_functions_addr:
- .long ofw_functions
-
.globl _begin
_begin:
sync
@@ -30,158 +26,8 @@
foo:
b foo
-
- .align 4
-call_freeldr:
- /* Get the address of the functions list --
- * Note:
- * Because of little endian switch we must use an even number of
- * instructions here.. Pad with a nop if needed. */
- mfmsr %r10
- ori %r10,%r10,1
- mtmsr %r10
-
- nop
-
- /* Note that this is little-endian from here on */
- blr
- nop
-
- .align 4
-
-call_ofw:
- /* R3 has the function offset to call (n * 4)
- * Other arg registers are unchanged.
- * Note that these 4 instructions are in reverse order due to
- * little-endian convention */
- andi. %r0,%r0,65534
- mfmsr %r0
- mtmsr %r0
- /* Now normal ordering resumes */
- subi %r1,%r1,0x100
-
- stw %r8,4(%r1)
- stw %r9,8(%r1)
- stw %r10,12(%r1)
- mflr %r8
- stw %r8,16(%r1)
-
- lis %r10,0xe00000@ha
- add %r9,%r3,%r10
- lwz %r3,ofw_functions_addr - _start@l(%r9)
- lwz %r3,0(%r3)
- mtctr %r3
-
- mr %r3,%r4
- mr %r4,%r5
- mr %r5,%r6
- mr %r6,%r7
- mr %r7,%r8
-
- /* Goto the swapped function */
- bctrl
-
- lwz %r8,16(%r1)
- mtlr %r8
-
- lwz %r8,4(%r1)
- lwz %r9,8(%r1)
- lwz %r10,12(%r1)
-
- addi %r1,%r1,0x100
- /* Ok, go back to little endian */
- mfmsr %r0
- ori %r0,%r0,1
- mtmsr %r0
-
- /* Note that this is little-endian from here on */
- blr
- nop
-
-zero_registers:
- xor %r2,%r2,%r2
- mr %r0,%r2
- mr %r3,%r2
-
- mr %r4,%r2
- mr %r5,%r2
- mr %r6,%r2
- mr %r7,%r2
-
- mr %r8,%r2
- mr %r9,%r2
- mr %r10,%r2
- mr %r11,%r2
-
- mr %r12,%r2
- mr %r13,%r2
- mr %r14,%r2
- mr %r15,%r2
-
- mr %r12,%r2
- mr %r13,%r2
- mr %r14,%r2
- mr %r15,%r2
-
- mr %r16,%r2
- mr %r17,%r2
- mr %r18,%r2
- mr %r19,%r2
-
- mr %r20,%r2
- mr %r21,%r2
- mr %r22,%r2
- mr %r23,%r2
-
- mr %r24,%r2
- mr %r25,%r2
- mr %r26,%r2
- mr %r27,%r2
-
- mr %r28,%r2
- mr %r29,%r2
- mr %r30,%r2
- mr %r31,%r2
-
- blr
.org 0x1000
-freeldr_banner:
- .ascii "ReactOS OpenFirmware Boot Program\r\n\0"
-
-freeldr_halt:
- .ascii "ReactOS OpenFirmware Boot Program Halting\r\n\0"
-
-freeldr_reg_init:
- .ascii "r\0"
-freeldr_reg_lr:
- .ascii "lr \0"
-freeldr_reg_cr:
- .ascii "cr \0"
-freeldr_reg_ctr:
- .ascii "ctr\0"
-freeldr_reg_msr:
- .ascii "msr\0"
-
-ofw_memory_size:
- .long 0
- .long 0
- .long 0
- .long 0
-
-ofw_chosen_name:
- .ascii "/chosen\0"
-
-ofw_stdout_name:
- .ascii "stdout\0"
-
-ofw_memory_name:
- .ascii "/memory@0\0"
-
-ofw_reg_name:
- .ascii "reg\0"
-
- .org 0x2000
stack:
.space 0x4000
Modified: branches/powerpc/reactos/boot/freeldr/bootsect/ofw_util.s
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/bo…
==============================================================================
--- branches/powerpc/reactos/boot/freeldr/bootsect/ofw_util.s (original)
+++ branches/powerpc/reactos/boot/freeldr/bootsect/ofw_util.s Tue Jun 27 17:03:35 2006
@@ -12,24 +12,23 @@
* instructions here.. Pad with a nop if needed. */
mfmsr %r10
ori %r10,%r10,1
+ nop
mtmsr %r10
-
- nop
/* Note that this is little-endian from here on */
blr
nop
.align 4
-
call_ofw:
/* R3 has the function offset to call (n * 4)
* Other arg registers are unchanged.
* Note that these 4 instructions are in reverse order due to
* little-endian convention */
- andi. %r0,%r0,65534
- mfmsr %r0
- mtmsr %r0
+ subi %r20,%r20,1
+ mfmsr %r20
+ mtmsr %r20
+ nop
/* Now normal ordering resumes */
subi %r1,%r1,0x100
@@ -40,10 +39,11 @@
stw %r8,16(%r1)
lis %r10,0xe00000@ha
- add %r9,%r3,%r10
- lwz %r3,ofw_functions_addr - _start@l(%r9)
- lwz %r3,0(%r3)
- mtctr %r3
+ addi %r8,%r10,ofw_functions_addr@l
+ lwz %r9,0(%r8)
+ add %r8,%r3,%r9
+ lwz %r9,0(%r8)
+ mtctr %r9
mr %r3,%r4
mr %r4,%r5
@@ -63,8 +63,12 @@
addi %r1,%r1,0x100
/* Ok, go back to little endian */
+
+ .align 4
mfmsr %r0
ori %r0,%r0,1
+
+ nop
mtmsr %r0
/* Note that this is little-endian from here on */
Modified: branches/powerpc/reactos/boot/freeldr/bootsect/ofwboot.s
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/bo…
==============================================================================
--- branches/powerpc/reactos/boot/freeldr/bootsect/ofwboot.s (original)
+++ branches/powerpc/reactos/boot/freeldr/bootsect/ofwboot.s Tue Jun 27 17:03:35 2006
@@ -49,10 +49,8 @@
lis %r5,0x8000@ha
addi %r5,%r5,0x8000@l
- bl ofw_dumpregs
-
+ bl ofw_dumpregs
bl copy_bits
-
bl zero_registers
/* Zero CTR */
@@ -63,32 +61,11 @@
mtlr %r3
- lis %r3,call_freeldr@ha
- addi %r3,%r3,call_freeldr - _start
+ lis %r3,call_ofw@ha
+ addi %r3,%r3,call_ofw - _start
- blr
+ b call_freeldr
-/*
- * lifted from ppc/boot/openfirmware/misc.S
- * Copyright (C) Paul Mackerras 1997.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation ; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-/*
- * Use the BAT2 & 3 registers to map the 1st 16MB of RAM to
- * the address given as the 1st argument.
- */
-setup_bats:
- xor 3,3,3
-
- sync
- isync
- blr
-
zero_registers:
xor %r2,%r2,%r2
mr %r0,%r2
Modified: branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/boot.s
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/fr…
==============================================================================
--- branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/boot.s (original)
+++ branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/boot.s Tue Jun 27 17:03:35
2006
@@ -1,3 +1,3 @@
.extern PpcInit
_start:
- b PpcInit+4
+ b PpcInit
Modified: branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/fr…
==============================================================================
--- branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c (original)
+++ branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c Tue Jun 27 17:03:35
2006
@@ -280,10 +280,12 @@
int len;
ofproxy = the_ofproxy;
+ ofw_print_string("Made it into freeldr LE code ... bootstrap complete\n");
+
chosen_package = ofw_finddevice( "/chosen" );
ofw_getprop( chosen_package, "stdin",
- &stdin_handle, sizeof(stdin_handle) );
+ (char *)&stdin_handle, sizeof(stdin_handle) );
stdin_handle = REV(stdin_handle);
Modified: branches/powerpc/reactos/boot/freeldr/freeldr/include/of.h
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/fr…
==============================================================================
--- branches/powerpc/reactos/boot/freeldr/freeldr/include/of.h (original)
+++ branches/powerpc/reactos/boot/freeldr/freeldr/include/of.h Tue Jun 27 17:03:35 2006
@@ -10,7 +10,7 @@
#include <string.h>
typedef int (*of_proxy)
- ( int table_off, void *arg1, void *arg2, void *arg3, void *arg4 );
+ ( int table_off, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5 );
typedef long jmp_buf[100];
extern of_proxy ofproxy;
extern void le_swap( void *begin, void *end, void *dest );
Modified: branches/powerpc/reactos/tools/ofw_interface/calls.ofw
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ofw_inter…
==============================================================================
--- branches/powerpc/reactos/tools/ofw_interface/calls.ofw (original)
+++ branches/powerpc/reactos/tools/ofw_interface/calls.ofw Tue Jun 27 17:03:35 2006
@@ -9,6 +9,16 @@
child 1 1 int int
peer 1 1 int int
seek 2 1 int int int
+# MMU methods
+# claim (virt size align -- base)
+claim 3 1 int int int int
+# release (virt size --)
+release 2 0 int int
+# map (plo phi virt size mode --)
+map 5 0 int int int int int
+unmap 2 0 int int
+modify 3 0 int int int
+translate 4 1 int int int int int
# Convenience functions that interact closely with OFW (written in BE asm)
-dumpregs 0 0
-print_string 1 0 char*
Modified: branches/powerpc/reactos/tools/ofw_interface/ofw_interface.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ofw_inter…
==============================================================================
--- branches/powerpc/reactos/tools/ofw_interface/ofw_interface.cpp (original)
+++ branches/powerpc/reactos/tools/ofw_interface/ofw_interface.cpp Tue Jun 27 17:03:35
2006
@@ -134,17 +134,15 @@
for( i = 0; i < args; i++ ) {
if( need_swap(argtypes[i]) ) {
- std::string len;
+ le_stub << "\tint len" << i << " = ";
if( have_len(argtypes[i]).size() )
- len = have_len(argtypes[i]);
+ le_stub << have_len(argtypes[i]) << ";\n";
else {
- std::ostringstream oss;
- oss << "strlen(arg" << i << ")";
- len = oss.str();
+ le_stub << "strlen(arg" << i << ");\n";
}
le_stub << "\tle_swap("
<< "arg" << i << ","
- << "arg" << i << "+" << len <<
","
+ << "arg" << i << "+len" << i <<
","
<< "arg" << i << ");\n";
}
}
@@ -154,7 +152,7 @@
le_stub << "ofproxy(" << (wrapper.ctindex * 4);
- for( i = 0; i < 4; i++ ) {
+ for( i = 0; i < 5; i++ ) {
if( i < args ) le_stub << ",(void *)arg" << i;
else le_stub << ",NULL";
}
@@ -163,17 +161,9 @@
for( i = args-1; i >= 0; i-- ) {
if( need_swap(argtypes[i]) ) {
- std::string len;
- if( have_len(argtypes[i]).size() )
- len = have_len(argtypes[i]);
- else {
- std::ostringstream oss;
- oss << "strlen(arg" << i << ")";
- len = oss.str();
- }
le_stub << "\tle_swap("
<< "arg" << i << ","
- << "arg" << i << "+" << len <<
","
+ << "arg" << i << "+len" << i <<
","
<< "arg" << i << ");\n";
}
}
@@ -242,6 +232,7 @@
out << "/* AUTOMATICALLY GENERATED BY ofw_interface */\n"
<< "\t.section .text\n"
+ << "\t.align 4\n"
<< "\t.globl _start\n"
<< "\t.globl ofw_call_addr\n"
<< "ofw_call_addr:\n"
Added: branches/powerpc/reactos/tools/ppc-le2be.mak
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-le2be…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-le2be.mak (added)
+++ branches/powerpc/reactos/tools/ppc-le2be.mak Tue Jun 27 17:03:35 2006
@@ -1,0 +1,36 @@
+PPC_LE2BE_BASE = $(TOOLS_BASE)
+PPC_LE2BE_BASE_ = $(PPC_LE2BE_BASE)$(SEP)
+
+PPC_LE2BE_INT = $(INTERMEDIATE_)$(PPC_LE2BE_BASE)
+PPC_LE2BE_INT_ = $(PPC_LE2BE_INT)$(SEP)
+PPC_LE2BE_OUT = $(OUTPUT_)$(PPC_LE2BE_BASE)
+PPC_LE2BE_OUT_ = $(PPC_LE2BE_OUT)$(SEP)
+
+PPC_LE2BE_TARGET = \
+ $(EXEPREFIX)$(PPC_LE2BE_OUT_)ppc-le2be$(EXEPOSTFIX)
+
+PPC_LE2BE_SOURCES = \
+ $(PPC_LE2BE_BASE_)ppc-le2be.c
+
+PPC_LE2BE_OBJECTS = \
+ $(addprefix $(INTERMEDIATE_), $(PPC_LE2BE_SOURCES:.c=.o))
+
+PPC_LE2BE_HOST_CFLAGS = $(TOOLS_CFLAGS)
+
+PPC_LE2BE_HOST_LFLAGS = $(TOOLS_LFLAGS)
+
+.PHONY: ppc-le2be
+ppc-le2be: $(PPC_LE2BE_TARGET)
+
+$(PPC_LE2BE_TARGET): $(PPC_LE2BE_OBJECTS) | $(PPC_LE2BE_OUT)
+ $(ECHO_LD)
+ ${host_gcc} $(PPC_LE2BE_OBJECTS) $(PPC_LE2BE_HOST_LFLAGS) -o $@
+
+$(PPC_LE2BE_INT_)ppc-le2be.o: $(PPC_LE2BE_BASE_)ppc-le2be.c | $(PPC_LE2BE_INT)
+ $(ECHO_CC)
+ ${host_gcc} $(PPC_LE2BE_HOST_CFLAGS) -c $< -o $@
+
+.PHONY: ppc-le2be_clean
+ppc-le2be_clean:
+ -@$(rm) $(PPC_LE2BE_TARGET) $(PPC_LE2BE_OBJECTS) 2>$(NUL)
+clean: ppc-le2be_clean
Modified: branches/powerpc/reactos/tools/ppc.lost+found/link-freeldr
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc.lost%…
==============================================================================
--- branches/powerpc/reactos/tools/ppc.lost+found/link-freeldr (original)
+++ branches/powerpc/reactos/tools/ppc.lost+found/link-freeldr Tue Jun 27 17:03:35 2006
@@ -1,8 +1,9 @@
-#!/bin/sh
+#!/bin/sh -v
export PATH=$PATH:/usr/local/pkg/reactos-powerpc/bin
ld -EL -g -nostartfiles -nostdlib -N -Ttext=0x8000 -o freeldr.elf
obj-ppc/boot/freeldr/freeldr/arch/powerpc/boot.o
obj-ppc/boot/freeldr/freeldr/cache/blocklist.o obj-ppc/boot/freeldr/freeldr/cache/cache.o
obj-ppc/boot/freeldr/freeldr/comm/rs232.o obj-ppc/boot/freeldr/freeldr/disk/disk.o
obj-ppc/boot/freeldr/freeldr/disk/partition.o obj-ppc/boot/freeldr/freeldr/fs/ext2.o
obj-ppc/boot/freeldr/freeldr/fs/fat.o obj-ppc/boot/freeldr/freeldr/fs/fs.o
obj-ppc/boot/freeldr/freeldr/fs/fsrec.o obj-ppc/boot/freeldr/freeldr/fs/iso.o
obj-ppc/boot/freeldr/freeldr/fs/ntfs.o obj-ppc/boot/freeldr/freeldr/inifile/ini_init.o
obj-ppc/boot/freeldr/freeldr/inifile/inifile.o
obj-ppc/boot/freeldr/freeldr/inifile/parse.o obj-ppc/boot/freeldr/freeldr/math/libgcc2.o
obj-ppc/boot/freeldr/freeldr/mm/meminit.o obj-ppc/boot/freeldr/freeldr/mm/mm.o
obj-ppc/boot/freeldr/freeldr/reactos/registry.o
obj-ppc/boot/freeldr/freeldr/reactos/arcname.o
obj-ppc/boot/freeldr/freeldr/reactos/binhive.o
obj-ppc/boot/freeldr/freeldr/reactos/reactos.o obj-ppc/boot/freeldr/freeldr/rtl/list.o
obj-ppc/boot/freeldr/freeldr/ui/gui.o obj-ppc/boot/freeldr/freeldr/ui/tui.o
obj-ppc/boot/freeldr/freeldr/ui/tuimenu.o obj-ppc/boot/freeldr/freeldr/ui/ui.o
obj-ppc/boot/freeldr/freeldr/video/bank.o obj-ppc/boot/freeldr/freeldr/video/fade.o
obj-ppc/boot/freeldr/freeldr/video/palette.o obj-ppc/boot/freeldr/freeldr/video/pixel.o
obj-ppc/boot/freeldr/freeldr/video/video.o obj-ppc/boot/freeldr/freeldr/freeldr.o
obj-ppc/boot/freeldr/freeldr/debug.o obj-ppc/boot/freeldr/freeldr/version.o
obj-ppc/boot/freeldr/freeldr/cmdline.o obj-ppc/boot/freeldr/freeldr/machine.o
obj-ppc/boot/freeldr/freeldr/arch/powerpc/mach.o
obj-ppc/boot/freeldr/freeldr/arch/powerpc/ofw.o
obj-ppc/boot/freeldr/freeldr/arch/powerpc/mboot.o obj-ppc/boot/freeldr/freeldr/bootmgr.o
obj-ppc/boot/freeldr/freeldr/drivemap.o obj-ppc/boot/freeldr/freeldr/miscboot.o
obj-ppc/boot/freeldr/freeldr/options.o obj-ppc/boot/freeldr/freeldr/linuxboot.o
obj-ppc/boot/freeldr/freeldr/oslist.o obj-ppc/boot/freeldr/freeldr/custom.o
obj-ppc/lib/rossym/rossym.a obj-ppc/lib/string/string.a obj-ppc/lib/rtl/rtl.a
/usr/local/pkg/reactos-powerpc/lib/libgcc.a
-objcopy -O binary --only-section=.text --only-section=.data --only-section=.bss
freeldr.elf freeldr.tmp
+objcopy -O binary --only-section=.text --only-section=.data --only-section=.bss
freeldr.elf freeldr.tmp.le
+output-ppc/tools/ppc-le2be freeldr.tmp.le freeldr.tmp
objcopy -I binary -B powerpc:common -O elf32-powerpc freeldr.tmp ofwldr.payload
-reactos-powerpc-as -mbig -o ofwboot.o boot/freeldr/bootsect/ofwboot.s
-ld -EB -Ttext 0xe00000 -e _begin -o ofwldr ofwboot.o ofwldr.payload
+reactos-powerpc-as -mbig -o ofwboot.o boot/freeldr/bootsect/ofwboot.s
boot/freeldr/bootsect/ofw_util.s boot/freeldr/bootsect/ofw.s
+ld -EB -Ttext 0xe00000 -Tdata 0xe17000 -e _begin -o ofwldr ofwboot.o ofwldr.payload
Modified: branches/powerpc/reactos/tools/tools.mak
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/tools.mak…
==============================================================================
--- branches/powerpc/reactos/tools/tools.mak (original)
+++ branches/powerpc/reactos/tools/tools.mak Tue Jun 27 17:03:35 2006
@@ -53,6 +53,7 @@
include tools/nci/nci.mak
include tools/rbuild/rbuild.mak
include tools/ofw_interface/ofw_interface.mak
+include tools/ppc-le2be.mak
include tools/unicode/unicode.mak
include tools/widl/widl.mak
include tools/winebuild/winebuild.mak