[ros-diffs] [fireball] 26960: - Added OFW function calls lib by FirmWorks (should be changed to arty's OFW generation tool in future). - Hacked FreeLdr's multiboot entry point, so it does what's needed by the OFW loading stub. - We can call OFW functions from FreeLdr now.

fireball at svn.reactos.org fireball at svn.reactos.org
Fri Jun 8 17:33:35 CEST 2007


Author: fireball
Date: Fri Jun  1 21:39:49 2007
New Revision: 26960

URL: http://svn.reactos.org/svn/reactos?rev=26960&view=rev
Log:
- Added OFW function calls lib by FirmWorks (should be changed to arty's OFW generation tool in future).
- Hacked FreeLdr's multiboot entry point, so it does what's needed by the OFW loading stub.
- We can call OFW functions from FreeLdr now.

Added:
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/1275.h   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/debug.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/intprop.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/lib.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/main.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.h   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/mem.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/printf.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/regprop.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/stdio.h   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/strprop.c   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/types.h   (with props)
    branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/wrappers.c   (with props)
Modified:
    branches/olpc/boot/freeldr/freeldr/arch/i386/arch.S
    branches/olpc/boot/freeldr/freeldr/freeldr.c
    branches/olpc/boot/freeldr/freeldr/freeldr_arch.rbuild

Modified: branches/olpc/boot/freeldr/freeldr/arch/i386/arch.S
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/arch.S?rev=26960&r1=26959&r2=26960&view=diff
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/arch.S (original)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/arch.S Fri Jun  1 21:39:49 2007
@@ -276,6 +276,14 @@
 
 	ret
 
+EXTERN(_call_firmware)
+	movl 4(%esp),%eax
+	push %ebx
+	movl cifentry,%ebx
+	call *%ebx
+	pop %ebx
+	ret
+
 /* Multiboot support
  *
  * Allows freeldr to be loaded as a "multiboot kernel" by
@@ -295,7 +303,7 @@
  * ourself to 0x8000
  */
 #define FREELDR_BASE 0x8000
-#define INITIAL_BASE 0x200000
+#define INITIAL_BASE 0x8000
 
 	/* Align 32 bits boundary */
 	.align 4
@@ -328,26 +336,29 @@
 	/* Although the multiboot spec says we should be called with the
 	 * segment registers set to 4GB flat mode, let's be sure and set up
 	 * our own */
-	lgdt	gdtptrhigh + INITIAL_BASE - FREELDR_BASE
+	/* lgdt	gdtptrhigh + INITIAL_BASE - FREELDR_BASE */
 	/* Reload segment selectors */
-	ljmp	$PMODE_CS, $(mb1 + INITIAL_BASE - FREELDR_BASE)
+/*	ljmp	$PMODE_CS, $(mb1 + INITIAL_BASE - FREELDR_BASE)
 mb1:
 	movw	$PMODE_DS,%dx
 	movw	%dx,%ds
-	movw	%dx,%es
+	movw	%dx,%es*/
 
 	/* Check for valid multiboot signature */
 	cmpl	$MULTIBOOT_BOOTLOADER_MAGIC,%eax
 	jne	mbfail
 
+	/* Store pointer to OFW */
+	movl	%esi,cifentry
+
 	/* Store multiboot info in a safe place */
-	movl	%ebx,%esi
-	movl	$(mb_info + INITIAL_BASE - FREELDR_BASE),%edi
-	movl	$MB_INFO_SIZE,%ecx
-	rep movsb
+	//movl	%ebx,%esi
+	//movl	$(mb_info + INITIAL_BASE - FREELDR_BASE),%edi
+	//movl	$MB_INFO_SIZE,%ecx
+	//rep movsb
 
 	/* Save commandline */
-	movl	MB_INFO_FLAGS_OFFSET(%ebx),%edx
+	/*movl	MB_INFO_FLAGS_OFFSET(%ebx),%edx
 	testl	$MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx)
 	jz	mb3
 	movl	MB_INFO_COMMAND_LINE_OFFSET(%ebx),%esi
@@ -358,57 +369,56 @@
 	testb	%al,%al
 	jz	mb3
 	dec	%ecx
-	jnz	mb2
+	jnz	mb2*/
 mb3:
 
 	/* Copy to low mem */
-	movl	$INITIAL_BASE,%esi
-	movl	$FREELDR_BASE,%edi
-	movl	$(__bss_end__ - FREELDR_BASE),%ecx
-	addl	$3,%ecx
-	shrl	$2,%ecx
-	rep movsl
+	//movl	$INITIAL_BASE,%esi
+	//movl	$FREELDR_BASE,%edi
+	//movl	$(__bss_end__ - FREELDR_BASE),%ecx
+	//addl	$3,%ecx
+	//shrl	$2,%ecx
+	//rep movsl
 
 	/* Load the GDT and IDT */
-	lgdt	gdtptr
-	lidt	i386idtptr
+	//lgdt	gdtptr
+	//lidt	i386idtptr
 
 	/* Clear prefetch queue & correct CS,
 	 * jump to low mem */
-	ljmp	$PMODE_CS, $mb4
-mb4:
+	//ljmp	$PMODE_CS, $mb4
+//mb4:
 	/* Reload segment selectors */
-	movw	$PMODE_DS,%dx
-	movw	%dx,%ds
-	movw	%dx,%es
-	movw	%dx,%fs
-	movw	%dx,%gs
-	movw	%dx,%ss
-	movl	$STACK32ADDR,%esp
-
-	movl	$mb_info,%ebx
+	//movw	$PMODE_DS,%dx
+	//movw	%dx,%ds
+	//movw	%dx,%es
+	//movw	%dx,%fs
+	//movw	%dx,%gs
+	//movw	%dx,%ss
+	//movl	$STACK32ADDR,%esp
+
+	//movl	$mb_info,%ebx
 	/* See if the boot device was passed in */
-	movl	MB_INFO_FLAGS_OFFSET(%ebx),%edx
-	testl	$MB_INFO_FLAG_BOOT_DEVICE,%edx
-	jz	mb5
+	//movl	MB_INFO_FLAGS_OFFSET(%ebx),%edx
+	//testl	$MB_INFO_FLAG_BOOT_DEVICE,%edx
+	//jz	mb5
 	/* Retrieve boot device info */
-	movl	MB_INFO_BOOT_DEVICE_OFFSET(%ebx),%eax
-	shrl	$16,%eax
-	incb	%al
-	movb	%al,_i386BootPartition
-	movb	%ah,_i386BootDrive
-	jmp	mb6
+	//movl	MB_INFO_BOOT_DEVICE_OFFSET(%ebx),%eax
+	//shrl	$16,%eax
+	//incb	%al
+	//movb	%al,_i386BootPartition
+	//movb	%ah,_i386BootDrive
+	//jmp	mb6
 mb5:	/* No boot device known, assume first partition of first harddisk */
 	movb	$0x80,_i386BootDrive
 	movb	$1,_i386BootPartition
 mb6:
 	/* Check for command line */
-	mov	$cmdline,%eax
-	testl	$MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx)
-	jnz	mb7
-	xorl	%eax,%eax
+	//mov	$cmdline,%eax
+	//testl	$MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx)
+	//jnz	mb7
+	//xorl	%eax,%eax
 mb7:
-
 	/* GO! */
 	pushl	%eax	
 	call	_BootMain
@@ -484,6 +494,10 @@
 	.word	0x3ff		/* Limit */
 	.long	0			/* Base Address */
 
+/* Pointer to OFW */
+cifentry:
+	.long	0
+
 EXTERN(_i386BootDrive)
 	.long	0
 

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/1275.h
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/1275.h?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/1275.h (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/1275.h Fri Jun  1 21:39:49 2007
@@ -1,0 +1,49 @@
+// See license at end of file
+
+#include "types.h"
+
+typedef long phandle;
+typedef long ihandle;
+
+typedef struct {
+	long hi, lo;
+	long size;
+} reg;
+
+#ifdef	putchar
+# undef	putchar
+#endif
+#ifdef	puts
+# undef	puts
+#endif
+
+typedef enum {
+	NOALLOC,
+	ALLOC
+} allocflag;
+
+#define	new(t)	(t *)zalloc(sizeof(t));
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/1275.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/debug.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/debug.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/debug.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/debug.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,51 @@
+// See license at end of file
+
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+#include <stdarg.h>
+
+int level = 0;
+
+int Debug = 0;
+
+VOID
+debug(int debug_level, char *fmt, ...)
+{
+	va_list args;
+	int i;
+
+	if (!(debug_level & Debug))
+		return;
+
+	va_start(args, fmt);
+	for (i = 0; i < level; ++i)
+		putchar('\t');
+	printf(fmt, args);
+	va_end(args);
+}
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/debug.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/intprop.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/intprop.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/intprop.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/intprop.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,68 @@
+// See license at end of file
+
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+int
+decode_int(UCHAR *p)
+{
+	ULONG   i = *p++  << 8;
+	i =    (i + *p++) << 8;
+	i =    (i + *p++) << 8;
+	return (i + *p);
+}
+
+int
+get_int_prop(phandle node, char *key)
+{
+	int res;
+	char buf[sizeof(int)];
+
+	res = OFGetprop(node, key, buf, sizeof(int));
+	if (res != sizeof(int)) {
+#ifdef notdef
+		fatal("get_int_prop(node %x, key '%s') returned %x\n",
+		    node, key, res);
+#endif
+		return(-1);
+	}
+	return(decode_int((UCHAR *) buf));
+}
+
+int
+get_int_prop_def(phandle node, char *key, int defval)
+{
+	int res;
+	char buf[sizeof(int)];
+
+	res = OFGetprop(node, key, buf, sizeof(int));
+	if (res != sizeof(int)) {
+		return(defval);
+	}
+	return(decode_int((UCHAR *) buf));
+}
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/intprop.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/lib.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/lib.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/lib.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/lib.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,272 @@
+// See license at end of file
+
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+extern void *malloc();
+extern char *get_str_prop();
+extern int  get_int_prop();
+extern int  get_int_prop_def();
+
+void
+abort()
+{
+  OFExit();
+}
+
+void
+exit()
+{
+  OFExit();
+}
+
+VOID
+sleep(ULONG delay)
+{
+	delay = (delay * 1000) + OFMilliseconds();
+	while ((OFMilliseconds() - delay) < 0)
+		;
+}
+
+/* files */
+
+#include "stdio.h"
+
+FILE _stdin  = { -1, 0, 0};
+FILE _stdout = { -1, 0, 0};
+FILE *stdin  = &_stdin;
+FILE *stdout = &_stdout;
+
+char _homedir[128];
+
+char *
+gethomedir()
+{
+  return(_homedir);
+}
+
+parse_homedir(char *progname)
+{
+  char *p, *q, c;
+
+  p = progname + strlen(progname);
+  while (p > progname) {
+    c = *--p;
+    if (c == ',' || c == ':' || c == '\\') {
+      ++p;
+      break;
+    }
+  }
+  for (q = _homedir; progname < p; )
+    *q++ = *progname++;
+
+  *q = '\0';
+}
+
+FILE *
+fopen (char *name, char *mode)
+{
+  FILE *fp;
+
+  fp = (FILE *)malloc(sizeof(struct _file));
+  if (fp == (FILE *)NULL)
+      return ((FILE *)NULL);
+
+  if ((fp->id = OFOpen(name)) == 0)
+      return ((FILE *)NULL);
+  
+  fp->bufc = 0;
+  return(fp);
+}
+
+int
+ferror(FILE *fp)
+{
+  return(0);	/* Implement me */
+}
+
+void
+fputc(char c, FILE *fp)
+{
+  if (fp == stdout && c == '\n')
+    fputc('\r', fp);
+
+  fp->buf[fp->bufc++] = c;
+
+  if ((fp->bufc == 127) || (fp == stdout && c == '\n')) {
+    OFWrite(fp->id, fp->buf, fp->bufc);
+    fp->bufc = 0;
+  }
+}
+
+void
+fflush (FILE *fp)
+{
+  if (fp->bufc != 0) {
+    OFWrite(fp->id, fp->buf, fp->bufc);
+    fp->bufc = 0;
+  }
+}
+
+int
+fgetc(FILE *fp)
+{
+  int  count;
+
+  /* try to read from the buffer */
+  if (fp->bufc != 0) {
+    fp->bufc--;
+    return(*fp->inbufp++);
+  }
+
+  /* read from the file */
+  do {
+      count = OFRead(fp->id, fp->buf, 128);
+  } while (count == -2);	/* Wait until input available */
+
+  if (count > 0)
+    {
+      fp->bufc = count-1;
+      fp->inbufp = fp->buf;
+      return(*fp->inbufp++);
+    }
+
+  /* otherwise return EOF */
+  return (-1);
+}
+
+int
+fclose (FILE *fp)
+{
+  fflush(fp);
+  OFClose(fp->id);
+  free(fp);
+  return(0);
+}
+
+int
+getchar()
+{
+  return(fgetc(stdin));
+}
+
+VOID
+putchar(char c)
+{
+  fputc(c, stdout);
+}
+
+int
+puts(char *s)
+{
+  fputs(s, stdout);
+  putchar('\n');
+  return(0);
+}
+
+VOID
+gets(char *buf)
+{
+  while ((*buf = getchar()) != '\r')
+    buf++;
+  *buf = '\0';
+}
+
+int
+fputs(char *s, FILE *f)
+{
+  register char c;
+  while(c = *s++)
+    fputc(c, f);
+  return(0);
+}
+
+char *
+fgets(char *buf, int n, FILE *f)
+{
+  char *p = buf;
+
+  while ((n > 1) && ((*p = fgetc(f)) != '\n')) {
+    p++;
+    n--;
+  }
+  *p = '\0';
+  return(buf);
+}
+
+unlink(char *filename)
+{
+  return(-1);
+/* XXX Implement me */
+}
+
+system(char *str)
+{
+  OFInterpret0(str);
+}
+
+#define MAXENV 256
+char *
+getenv(char *str)
+{
+  phandle ph;
+  int res;
+
+  if ((ph = OFFinddevice("/options")) == -1)
+      return(NULL);
+
+  return (get_str_prop(ph, str, 0));
+}
+
+int
+stdout_rows()
+{
+  phandle ph;
+  int res;
+
+  if ((ph = OFFinddevice("/chosen")) == -1)
+    return(24);
+  res = get_int_prop_def(ph, "stdout-#lines", 24);
+  if (res < 0)
+    return(24);		/* XXX should look in device node too */
+  return (res);
+}
+
+int
+stdout_columns()
+{
+  phandle ph;
+  int res;
+
+  if ((ph = OFFinddevice("/chosen")) == -1)
+      return(80);
+  res = get_int_prop_def(ph, "stdout-#columns", 80);
+  if (res < 0)
+    return(80);		/* XXX should look in device node too */
+  return (res);
+}
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/lib.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/main.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/main.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/main.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/main.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,6 @@
+#ifdef __GNUC__
+void
+__main()
+{
+}
+#endif

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/main.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,307 @@
+// See license at end of file
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * A  "smarter" malloc				William L. Sebok
+ *						Sept. 24, 1984
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *	 If n = the size of an area rounded DOWN to the nearest power of two,
+ *	all free areas of memory whose length is the same index n is organized
+ *	into a chain with other free areas of index n. A request for memory
+ *	takes the first item in the chain whose index is the size of the
+ *	request rounded UP to the nearest power of two.  If this chain is
+ *	empty the next higher chain is examined.  If no larger chain has memory
+ *	then new memory is allocated.  Only the amount of new memory needed is
+ *	allocated.  Any old free memory left after an allocation is returned
+ *	to the free list.  Extra new memory returned because of rounding
+ *	to page boundaries is returned to free list.
+ *
+ *	  All memory areas (free or busy) handled by malloc are also chained
+ *	sequentially by increasing address.  When memory is freed it is
+ *	merged with adjacent free areas, if any.  If a free area of memory
+ *	ends at the end of memory (i.e. at the break),  the break is
+ *	contracted, freeing the memory back to the system.
+ *
+ *	Notes:
+ *		ov_length field includes sizeof(struct overhead)
+ *		adjacency chain includes all memory, allocated plus free.
+ */
+
+#define MALLOC
+#include "malloc.h"
+#ifndef	NULL
+#define NULL	0
+#endif
+#ifdef debug
+# define ASSERT(p,q)	if (!(p)) fatal(q)
+#else
+# define ASSERT(p,q)
+#endif
+
+#define ALIGN(n, granule)  ((n + ((granule)-1)) & ~((granule)-1))
+/*
+// PowerPC page size = 4 KB; PC page size is the same???
+*/
+
+#define PAGE_SIZE (ULONG)0x1000
+#define ULONG unsigned long
+
+char *
+malloc(nbytes)
+	unsigned nbytes;
+{
+        extern ULONG OFClaim();
+	register struct overhead *p, *q;
+	register int surplus;
+	register struct qelem *bucket;
+	nbytes = ALIGN(nbytes, NALIGN) + sizeof(struct overhead);
+	bucket = &buckets[_log2(nbytes-1) + 1];	/* log2 rounded up */
+	for (p = NULL; bucket < &buckets[NBUCKETS]; bucket++) { 
+		if (bucket->q_forw != bucket) {
+			/*  remove from bucket chain */
+			p = FROMBUK(bucket->q_forw);
+			ASSERT(p->ov_magic == MAGIC_FREE, "\nmalloc: Entry \
+not marked FREE found on Free List!\n");
+			remque(TOBUK(p));
+			surplus = p->ov_length - nbytes;
+			break;
+		}
+	}
+	if (p == NULL) {
+#ifdef USE_SBRK
+		register int i;
+		p = (struct overhead *)CURBRK;
+		if ((int)p == -1)
+			return(NULL);
+		if (i = (int)p&(NALIGN-1))
+			sbrk(NALIGN-i);
+		p = (struct overhead *)sbrk(nbytes);
+		if ((int)p == -1)
+			return(NULL);
+		q = (struct overhead *)CURBRK;
+		if ((int)q == -1)
+			return(NULL);
+		p->ov_length = (char *)q - (char *)p;
+		surplus = p->ov_length - nbytes;
+		/* add to end of adjacency chain */
+		ASSERT((FROMADJ(adjhead.q_back)) < p, "\nmalloc: Entry in \
+adjacency chain found with address lower than Chain head!\n" );
+		insque(TOADJ(p),adjhead.q_back);
+#else
+		struct qelem *pp;
+		int alloc_size = ALIGN(nbytes, PAGE_SIZE);
+
+		p = (struct overhead *)OFClaim(0, alloc_size, NALIGN);
+		if (p == (struct overhead *)-1)
+			return(NULL);
+		p->ov_length = alloc_size;
+		surplus = p->ov_length - nbytes;
+
+		/* add to adjacency chain in the correct place */
+		for (pp = adjhead.q_forw;
+		     pp != &adjhead;
+		     pp = pp->q_forw) {
+			if (p < FROMADJ(pp))
+				break;
+		}
+		ASSERT(pp == &adjhead || (p < FROMADJ(pp)),
+		       "\nmalloc: Bogus insertion in adjacency list\n");
+		insque(TOADJ(p),pp->q_back);
+#endif
+	}
+	if (surplus > sizeof(struct overhead)) {
+		/* if big enough, split it up */
+		q = (struct overhead *)( (char *)p + nbytes);
+		q->ov_length = surplus;
+		p->ov_length = nbytes;
+		q->ov_magic = MAGIC_FREE;
+		/* add surplus into adjacency chain */
+		insque(TOADJ(q),TOADJ(p));
+		/* add surplus into bucket chain */
+		insque(TOBUK(q),&buckets[_log2(surplus)]);
+	}
+	p->ov_magic = MAGIC_BUSY;
+	return((char*)p + sizeof(struct overhead));
+}
+
+void
+free(mem)
+register char *mem;
+{
+	register struct overhead *p, *q;
+	if (mem == NULL)
+		return;
+	p = (struct overhead *)(mem - sizeof(struct overhead));
+	if (p->ov_magic == MAGIC_FREE)
+		return;
+	if (p->ov_magic != MAGIC_BUSY) {
+		fatal("attempt to free memory not allocated with malloc!\n");
+	}
+	q = FROMADJ((TOADJ(p))->q_back);
+	if (q != FROMADJ(&adjhead)) {	/* q is not the first list item */
+		ASSERT(q < p, "\nfree: While trying to merge a free area with \
+a lower adjacent free area,\n addresses were found out of order!\n");
+		/* If lower segment can be merged */
+		if (   q->ov_magic == MAGIC_FREE
+		   && (char *)q + q->ov_length == (char *)p
+		) {
+			/* remove lower address area from bucket chain */
+			remque(TOBUK(q));
+			/* remove upper address area from adjacency chain */
+			remque(TOADJ(p));
+			q->ov_length += p->ov_length;
+			p->ov_magic = NULL;
+			p = q;
+		}
+	}
+	q = FROMADJ((TOADJ(p))->q_forw);
+	if (q != FROMADJ(&adjhead)) {	/* q is not the last list item */
+		/* upper segment can be merged */
+		ASSERT(q > p, "\nfree: While trying to merge a free area with \
+a higher adjacent free area,\n addresses were found out of order!\n");
+		if ( 	q->ov_magic == MAGIC_FREE
+		   &&	(char *)p + p->ov_length == (char *)q
+		) {
+			/* remove upper from bucket chain */
+			remque(TOBUK(q));
+			/* remove upper from adjacency chain */
+			remque(TOADJ(q));
+			p->ov_length += q->ov_length;
+			q->ov_magic = NULL;
+		}
+	}
+#ifdef USE_SBRK
+	if (	/* freed area is at end of memory */
+		endfree && adjhead.q_back == TOADJ(p)
+	    &&	(char*)p + p->ov_length == (char *)CURBRK
+	) {
+		/* remove from end of adjacency chain */
+		remque(adjhead.q_back);
+		/* release memory to system */
+		sbrk( -((int)(p->ov_length)));
+		return;
+	}
+#endif
+	p->ov_magic = MAGIC_FREE;
+	/* place in bucket chain */
+	insque(TOBUK(p),&buckets[_log2(p->ov_length)]);
+	return;
+}
+
+char *
+realloc(mem,nbytes)
+register char *mem; unsigned nbytes;
+{
+	register char *newmem;
+	register struct overhead *p, *q;
+	register int surplus;
+	if (mem == NULL)
+		return(malloc(nbytes));
+	if(mem > (char*)FROMADJ(adjhead.q_back) + sizeof(struct overhead))
+		return(NULL);
+	
+	p = (struct overhead *)(mem - sizeof(struct overhead));
+	nbytes = (nbytes + (NALIGN-1)) & (~(NALIGN-1));
+	if (  p->ov_magic == MAGIC_BUSY
+	   && (q = FROMADJ(adjhead.q_back)) != p
+	   && (q->ov_magic != MAGIC_FREE || (FROMADJ(q->ov_adj.q_back) != p))
+	)
+		free(mem);
+	if( (p->ov_magic == MAGIC_BUSY || p->ov_magic == MAGIC_FREE)
+	 && (surplus = p->ov_length - nbytes - sizeof(struct overhead)) >= 0
+	) {
+		if (surplus > sizeof(struct overhead)) {
+			/*  return surplus to free list */
+			nbytes += sizeof(struct overhead);
+#ifdef USE_SBRK
+			if (	/* freed area is at end of memory */
+				endfree && adjhead.q_back == TOADJ(p)
+			  &&	(char*)p + p->ov_length == (char *)CURBRK
+			) {
+				/* release memory to system */
+				sbrk(-surplus);
+			} else
+#endif
+			{
+				q = (struct overhead *)( (char *)p + nbytes);
+				q->ov_length = surplus;
+				q->ov_magic = MAGIC_FREE;
+				insque(TOADJ(q),TOADJ(p));
+				insque(TOBUK(q),&buckets[_log2(surplus)]);
+			}
+			p->ov_length = nbytes;
+		}
+		if (p->ov_magic == MAGIC_FREE) {
+			remque(TOBUK(p));
+			p->ov_magic = MAGIC_BUSY;
+		}
+		return(mem);
+	}
+	newmem = malloc(nbytes);
+	if (newmem != mem && newmem != NULL) {
+		register int n;
+		if (p->ov_magic == MAGIC_BUSY || p->ov_magic == MAGIC_FREE) {
+			n = p->ov_length - sizeof(struct overhead);
+			nbytes = (nbytes < n) ? nbytes : n ;
+		}
+		memcpy(newmem,mem,nbytes);
+	}
+	if (p->ov_magic == MAGIC_BUSY)
+		free(mem);
+	return(newmem);
+}
+
+_log2(n)
+register int n;
+{
+	register int i = 0;
+	while ((n >>= 1) > 0)
+		i++;
+	return(i);
+}
+
+void
+insque(item,queu)
+register struct qelem *item, *queu;
+{
+	register struct qelem *pueu;
+	pueu = queu->q_forw;
+	item->q_forw = pueu;
+	item->q_back = queu;
+	queu->q_forw = item;
+	pueu->q_back = item;
+}
+
+void
+remque(item)
+register struct qelem *item;
+{
+	register struct qelem *queu, *pueu;
+	pueu = item->q_forw;
+	queu = item->q_back;
+	queu->q_forw = pueu;
+	pueu->q_back = queu;
+}
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.h
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.h?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.h (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.h Fri Jun  1 21:39:49 2007
@@ -1,0 +1,96 @@
+// See license at end of file
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * A  "smarter" malloc				William L. Sebok
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#define	MAGIC_FREE	0x548a934c
+#define	MAGIC_BUSY	0xc139569a
+
+#define NBUCKETS	24
+#define NALIGN		sizeof(long)
+
+struct qelem {
+	struct qelem *q_forw;
+	struct qelem *q_back;
+};
+
+struct overhead {
+	struct qelem	ov_adj;		/* adjacency chain pointers */ 
+	struct qelem	ov_buk;		/* bucket chain pointers */
+	long		ov_magic;
+	unsigned long	ov_length;
+};
+
+#ifdef MALLOC
+char endfree = 0;
+struct qelem adjhead = { &adjhead, &adjhead };
+struct qelem buckets[NBUCKETS] = {
+	&buckets[0],  &buckets[0],
+	&buckets[1],  &buckets[1],
+	&buckets[2],  &buckets[2],
+	&buckets[3],  &buckets[3],
+	&buckets[4],  &buckets[4],
+	&buckets[5],  &buckets[5],
+	&buckets[6],  &buckets[6],
+	&buckets[7],  &buckets[7],
+	&buckets[8],  &buckets[8],
+	&buckets[9],  &buckets[9],
+	&buckets[10], &buckets[10],
+	&buckets[11], &buckets[11],
+	&buckets[12], &buckets[12],
+	&buckets[13], &buckets[13],
+	&buckets[14], &buckets[14],
+	&buckets[15], &buckets[15],
+	&buckets[16], &buckets[16],
+	&buckets[17], &buckets[17],
+	&buckets[18], &buckets[18],
+	&buckets[19], &buckets[19],
+	&buckets[20], &buckets[20],
+	&buckets[21], &buckets[21],
+	&buckets[22], &buckets[22],
+	&buckets[23], &buckets[23],
+};
+#else
+extern char endfree;
+extern struct qelem adjhead, buckets[NBUCKETS];
+#endif
+
+/*
+ * The following macros depend on the order of the elements in struct overhead
+ */
+#define TOADJ(p)	((struct qelem *)(p))
+#define FROMADJ(p)	((struct overhead *)(p))
+#define FROMBUK(p)	((struct overhead *)( (char *)p - sizeof(struct qelem)))
+#define TOBUK(p)	((struct qelem *)( (char *)p + sizeof(struct qelem)))
+
+#ifndef CURBRK
+#define CURBRK	sbrk(0)
+#endif CURBRK
+
+extern void insque(), remque();
+extern char *malloc(), *realloc();
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/malloc.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/mem.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/mem.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/mem.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/mem.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,17 @@
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+VOID
+memcpy(char *to, char *from, size_t len)
+{
+	while (len--)
+		*to++ = *from++;
+}
+
+VOID
+memset(char *cp, int c, size_t len)
+{
+	while (len--)
+		*(cp + len) = c;
+}

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/mem.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/printf.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/printf.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/printf.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/printf.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,177 @@
+// See license at end of file
+
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+#include <stdarg.h>
+
+int
+atoi(char *s)
+{
+	int temp = 0, base = 10;
+
+	if (*s == '0') {
+		++s;
+		if (*s == 'x') {
+			++s;
+			base = 16;
+		} else {
+			base = 8;
+		}
+	}
+	while (*s) {
+		switch (*s) {
+		case '0': case '1': case '2': case '3': case '4':
+		case '5': case '6': case '7': case '8': case '9':
+			temp = (temp * base) + (*s++ - '0');
+			break;
+		case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+			temp = (temp * base) + (*s++ - 'a' + 10);
+			break;
+		case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+			temp = (temp * base) + (*s++ - 'A' + 10);
+			break;
+		default:
+			return (temp);
+		}
+	}
+	return (temp);
+}
+
+STATIC int
+printbase(ULONG x, int base)
+{
+	static char itoa[] = "0123456789abcdef";
+	ULONG j;
+	char buf[16], *s = buf;
+	int n = 0;
+
+	if (x == 0) {
+		putchar('0');
+		n++;
+		return (n);
+	}
+	memset(buf, 16, 0);
+	while (x) {
+		j = x % base;
+		*s++ = itoa[j];
+		x -= j;
+		x /= base;
+	}
+
+	for (--s; s >= buf; --s) {
+		putchar(*s);
+		n++;
+	}
+	return (n);
+}
+
+int
+_printf(char *fmt, va_list args)
+{
+	ULONG x;
+	char c, *s;
+	int n = 0;
+
+	while (c = *fmt++) {
+		if (c != '%') {
+			putchar(c);
+			n++;
+			continue;
+		}
+		switch (c = *fmt++) {
+		case 'x':
+			x = va_arg(args, ULONG);
+			n += printbase(x, 16);
+			break;
+		case 'o':
+			x = va_arg(args, ULONG);
+			n += printbase(x, 8);
+			break;
+		case 'd':
+			x = va_arg(args, ULONG);
+			if ((LONG) x < 0) {
+				putchar('-');
+				n++;
+				x = -x;
+			}
+			n += printbase(x, 10);
+			break;
+		case 'c':
+			c = va_arg(args, char);
+			putchar(c);
+			n++;
+			break;
+		case 's':
+			s = va_arg(args, char *);
+			while (*s) {
+				putchar(*s++);
+				n++;
+			}
+			break;
+		default:
+			putchar(c);
+			n++;
+			break;
+		}
+	}
+	return(n);
+}
+
+int
+ofwprintf(char *fmt, ...)
+{
+	va_list args;
+	int i;
+
+	va_start(args, fmt);
+	i = _printf(fmt, args);
+	va_end(args);
+	return (i);
+}
+
+VOID
+warn(char *fmt, ...)
+{
+	va_list args;
+
+	va_start(args, fmt);
+	(void)_printf(fmt, args);
+	va_end(args);
+}
+
+VOID
+fatal(char *fmt, ...)
+{
+	va_list args;
+
+	va_start(args, fmt);
+	(void)_printf(fmt, args);
+	OFExit();
+	va_end(args);
+} 
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/printf.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/regprop.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/regprop.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/regprop.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/regprop.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,65 @@
+// See license at end of file
+
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+reg *
+decode_reg(UCHAR *buf, int buflen)
+{
+	static reg staticreg;
+	reg *sregp;
+	int i;
+
+	if (buflen)
+		staticreg.hi = decode_int(buf);
+	if (buflen > 4)
+		staticreg.lo = decode_int(buf+4);
+	if (buflen > 8)
+		staticreg.size = decode_int(buf+8);
+	return (sregp = &staticreg);
+}
+
+reg *
+get_reg_prop(phandle node, char *key)
+{
+	int res;
+	char *buf;
+	reg *regp;
+	int len = OFGetproplen(node, key);
+
+	buf = (char *)malloc(len);
+	res = OFGetprop(node, key, buf, len);
+	if (res != len) {
+		fatal("get_reg_prop(node %x, key '%s', len %x) returned %x\n",
+		    node, key, len, res);
+		return ((reg *) 0);
+	}
+	regp = decode_reg(buf, len);
+	free(buf);
+	return (regp);
+}
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/regprop.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/stdio.h
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/stdio.h?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/stdio.h (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/stdio.h Fri Jun  1 21:39:49 2007
@@ -1,0 +1,39 @@
+// See license at end of file
+
+typedef struct _file {
+  long id;
+  int  bufc;
+  char *inbufp;
+  char buf[128];
+} FILE;
+
+extern FILE *stdin;
+extern FILE *stdout;
+
+#define EOF -1
+extern FILE *fopen();
+
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/stdio.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/strprop.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/strprop.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/strprop.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/strprop.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,80 @@
+// See license at end of file
+
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+extern void *malloc();
+VOID *
+zalloc(int size)
+{
+	VOID *vp;
+
+	vp = (void *)malloc(size);
+	memset(vp, size, 0);
+	return (vp);
+}
+
+char *
+get_str_prop(phandle node, char *key, allocflag alloc)
+{
+	int len, res;
+	static char *priv_buf, priv_buf_len = 0;
+	char *cp;
+
+	len = OFGetproplen(node, key);
+	if (len == -1 || len == 0)
+		return((char *) 0);
+
+	/*
+	 * Leave room for a null terminator, on the off chance that the
+	 * property isn't null-terminated.
+	 */
+	len += 1;
+	if (alloc == ALLOC)
+		cp = (char *) zalloc(len);
+	else {
+		if (len > priv_buf_len) {
+			if (priv_buf_len)
+				free(priv_buf);
+			priv_buf = (char *) zalloc(len);
+			priv_buf_len = len;
+		} else
+			memset(priv_buf, len, 0);
+		cp = priv_buf;
+	}
+	len -= 1;
+
+	res = OFGetprop(node, key, cp, len);
+	if (res != len) {
+		fatal(
+		    "get_str_prop(node %x, key '%s', len %x) returned len %x\n",
+		    node, key, len, res);
+		return((char *) 0);
+	}
+	return(cp);
+}
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/strprop.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/types.h
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/types.h?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/types.h (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/types.h Fri Jun  1 21:39:49 2007
@@ -1,0 +1,10 @@
+#define STATIC static
+#define VOID void
+#define UCHAR unsigned char
+#define ULONG unsigned long
+#define LONG  long
+#define NULL 0
+
+typedef unsigned int size_t;
+
+VOID fatal(char *fmt, ...);

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/types.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/wrappers.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/wrappers.c?rev=26960&view=auto
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/wrappers.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/wrappers.c Fri Jun  1 21:39:49 2007
@@ -1,0 +1,545 @@
+// See license at end of file
+
+/*++
+
+Abstract:
+
+    This module implements the wrapper for the P1275 boot firmware client
+    program interface. There is a wrapper routine for each of the client
+    interface service. The wrapper routine constructs a client interface
+    argument array as illustraed in the figure below, places its address
+    in r3 and transfers control to the client interface handler. The
+    return address of the wrapper routine is placed in lr register.
+    
+    The Client interface handler performs the service specified in the
+    argument array and return to wrapper routine which in turn return
+    to the client program. The client interface handler returns an
+    overall success or failure code to the caller as a subroutine
+    return value (%o0 for SPARC, %r3 for PowerPC, %eax for x86).
+    
+
+	Layout of the argument array
+
+	+--------------------------------------+
+	| Name of the client interface service |
+	+--------------------------------------+
+	| Number of input arguments            |
+	+--------------------------------------+	
+	| Number of return values              |
+	+--------------------------------------+	
+	| Input arguments (arg1, ..., argN)    |
+	+--------------------------------------+	
+	| Returned values (ret1, ..., retN)    |
+	+--------------------------------------+
+
+--*/
+
+#include "1275.h"
+
+#ifdef SPRO
+typedef long long cell_t;
+#else
+typedef unsigned long cell_t ;
+#endif
+
+#ifdef CIF64
+#define LOW(index) ((index*2) + 1)
+#else
+#define LOW(index) (index)
+#endif
+
+extern int call_firmware(ULONG *);
+extern void warn(char *fmt, ...);
+
+#ifdef CIF64
+#define CIF_HANDLER_IN 6
+#else
+#define CIF_HANDLER_IN 3
+#endif
+
+// Device tree routines
+
+//
+// Peer() - This routines outputs the identifier(phandle) of the device node that is
+//          the next sibling of the specified device node.
+//
+//   Inputs:
+//           phandle - identifier of a device node
+//
+//   Outputs:
+//           sibling_phandle - identifier of the next sibling.
+//                             Zero if there are no more siblings.
+//
+
+phandle
+OFPeer(phandle device_id)
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"peer", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"peer",1,1,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = device_id;
+	if (call_firmware(argarray) != 0)
+	{
+		return (phandle)0;
+	}
+	return ((phandle)argarray[CIF_HANDLER_IN+LOW(1)]);
+}
+
+phandle
+OFChild(phandle device_id)
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"child", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"child",1,1,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = device_id;
+	if (call_firmware(argarray) != 0)
+	{
+		return (phandle)0;
+	}
+	return ((phandle)argarray[CIF_HANDLER_IN+LOW(1)]);
+}
+
+phandle
+OFParent(phandle device_id)
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"parent", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"parent", 1,1,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = device_id;
+	if (call_firmware(argarray) != 0)
+	{
+		return (phandle)0;
+	}
+	return ((phandle)argarray[CIF_HANDLER_IN+LOW(1)]);
+}
+
+long
+OFGetproplen(
+    phandle device_id,
+    char *name
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"getproplen", 0,2, 0,1, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"getproplen", 2,1,0,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long)device_id;
+	argarray[CIF_HANDLER_IN+LOW(1)] = (long)name;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(2)]);
+}
+
+long
+OFGetprop(
+    phandle device_id,
+    char *name,
+    char *buf,
+    ULONG buflen
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"getprop", 0,4, 0,1, 0,0, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"getprop", 4,1,0,0,0,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long)device_id;
+	argarray[CIF_HANDLER_IN+LOW(1)] = (long)name;
+	argarray[CIF_HANDLER_IN+LOW(2)] = (long)buf;
+	argarray[CIF_HANDLER_IN+LOW(3)] = buflen;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(4)]);
+}
+
+long
+OFNextprop(
+    phandle device_id,
+    char *name,
+    char *buf
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"nextprop", 0,3, 0,1, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"nextprop", 3,1,0,0,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long)device_id;
+	argarray[CIF_HANDLER_IN+LOW(1)] = (long)name;
+	argarray[CIF_HANDLER_IN+LOW(2)] = (long)buf;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(3)]);
+}
+
+long
+OFSetprop(
+    phandle device_id,
+    char *name,
+    char *buf,
+    ULONG buflen
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"setprop", 0,4, 0,1, 0,0, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"setprop", 4,1,0,0,0,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long)device_id;
+	argarray[CIF_HANDLER_IN+LOW(1)] = (long)name;
+	argarray[CIF_HANDLER_IN+LOW(2)] = (long)buf;
+	argarray[CIF_HANDLER_IN+LOW(3)] = buflen;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(4)]);
+}
+
+phandle
+OFFinddevice( char *devicename)
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"finddevice", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"finddevice", 1,1,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long)devicename;
+	if (call_firmware(argarray) != 0)
+	{
+		return (phandle)0;
+	}
+	return ((phandle) argarray[CIF_HANDLER_IN+LOW(1)]);
+}
+
+ihandle
+OFOpen( char *devicename)
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"open", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"open", 1,1,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long)devicename;
+	if (call_firmware(argarray) != 0)
+	{
+		return (ihandle)0;
+	}
+	return ((ihandle) argarray[CIF_HANDLER_IN+LOW(1)]);
+}
+
+void
+OFClose(ihandle id)
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"close", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"close", 1,1,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long)id;
+	if (call_firmware(argarray) != 0)
+	{
+#ifdef notdef
+		warn("OFClose(%x) failed\n", id);
+#endif
+	}
+	
+}
+
+long
+OFRead(
+    ihandle instance_id,
+    char *addr,
+    ULONG len
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"read", 0,3, 0,1, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"read", 3,1,0,0,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long) instance_id;
+	argarray[CIF_HANDLER_IN+LOW(1)] = (cell_t)addr;
+	argarray[CIF_HANDLER_IN+LOW(2)] = len;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(3)]);
+}
+
+long
+OFWrite(
+    ihandle instance_id,
+    char *addr,
+    ULONG len
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"write", 0,3, 0,1, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"write", 3,1,0,0,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long) instance_id;
+	argarray[CIF_HANDLER_IN+LOW(1)] = (cell_t)addr;
+	argarray[CIF_HANDLER_IN+LOW(2)] = len;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(3)]);
+}
+
+long
+OFSeek(
+    ihandle instance_id,
+    ULONG poshi,
+    ULONG poslo
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"seek", 0,3, 0,1, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"seek", 3,1,0,0,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (long) instance_id;
+	argarray[CIF_HANDLER_IN+LOW(1)] = poshi;
+	argarray[CIF_HANDLER_IN+LOW(2)] = poslo;
+	if (call_firmware(argarray) != 0) {
+		return (-1);
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(3)]);
+}
+
+ULONG
+OFClaim(
+    char *addr,
+    ULONG size,
+    ULONG align
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"claim", 0,3, 0,1, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"claim", 3,1,0,0,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (cell_t)addr;
+	argarray[CIF_HANDLER_IN+LOW(1)] = size;
+	argarray[CIF_HANDLER_IN+LOW(2)] = align;
+	if (call_firmware(argarray) != 0)
+	{
+		return (ULONG)0;
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(3)]);
+}
+
+VOID
+OFRelease(
+    char *addr,
+    ULONG size
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"release", 0,2, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"release", 2,0,0,0};
+#endif
+	argarray[CIF_HANDLER_IN+LOW(0)] = (cell_t)addr;
+	argarray[CIF_HANDLER_IN+LOW(1)] = size;
+	call_firmware(argarray); 
+}
+
+long
+OFPackageToPath(
+    phandle device_id,
+    char *addr,
+    ULONG buflen
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"package-to-path", 0,3, 0,1, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"package-to-path", 3,1,0,0,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (cell_t)device_id;
+	argarray[CIF_HANDLER_IN+LOW(1)] = (cell_t)addr;
+	argarray[CIF_HANDLER_IN+LOW(2)] = buflen;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return ((LONG)argarray[CIF_HANDLER_IN+LOW(3)]);
+}
+
+phandle
+OFInstanceToPackage(ihandle ih)
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"instance-to-package", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"instance-to-package", 1,1,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (cell_t)ih;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return ((LONG)argarray[CIF_HANDLER_IN+LOW(1)]);
+}
+
+long
+OFCallMethod(
+    char *method,
+    ihandle id,
+    ULONG arg
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"call-method", 0,3, 0,1, 0,0, 0,0, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"call-method", 3,1,0,0,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (cell_t)method;
+	argarray[CIF_HANDLER_IN+LOW(1)] = (cell_t)id;
+	argarray[CIF_HANDLER_IN+LOW(2)] = arg;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return ((LONG)argarray[CIF_HANDLER_IN+LOW(3)]);
+}
+
+long
+OFInterpret0(
+    char *cmd
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"interpret", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"interpret", 1,1,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (cell_t)cmd;
+	if (call_firmware(argarray) != 0)
+	{
+		return (-1);
+	}
+	return ((LONG)argarray[CIF_HANDLER_IN+LOW(1)]);
+}
+
+ULONG
+OFMilliseconds( VOID )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"milliseconds", 0,0, 0,1, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"milliseconds", 0,1,0};
+#endif
+	if (call_firmware(argarray) != 0)
+	{
+		return (ULONG)0;
+	}
+	return (argarray[CIF_HANDLER_IN+LOW(0)]);
+}
+
+void (*OFSetCallback(void (*func)(void)))(void)
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"set-callback", 0,1, 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"set-callback", 1,1,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (cell_t)func;
+	if (call_firmware(argarray) != 0)
+	{
+		return (NULL);
+	}
+	return ((void (*)(void))argarray[CIF_HANDLER_IN+LOW(1)]);
+}
+
+long
+OFBoot(
+    char *bootspec
+    )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"boot", 0,1, 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"boot", 1,0,0};
+#endif
+
+	argarray[CIF_HANDLER_IN+LOW(0)] = (cell_t)bootspec;
+	call_firmware(argarray);
+}
+
+VOID
+OFEnter( VOID )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"enter", 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"enter", 0,0};
+#endif
+
+	call_firmware(argarray);
+}
+
+/* volatile VOID */
+ VOID
+OFExit( VOID )
+{
+#ifdef CIF64
+	ULONG argarray[] = { 0,(ULONG)"exit", 0,0, 0,0};
+#else
+	cell_t argarray[] = { (cell_t)"exit", 0,0};
+#endif
+	call_firmware(argarray);
+}
+
+// LICENSE_BEGIN
+// Copyright (c) 2006 FirmWorks
+// 
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// LICENSE_END

Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofw/wrappers.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/olpc/boot/freeldr/freeldr/freeldr.c
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/freeldr.c?rev=26960&r1=26959&r2=26960&view=diff
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/freeldr.c (original)
+++ branches/olpc/boot/freeldr/freeldr/freeldr.c Fri Jun  1 21:39:49 2007
@@ -20,8 +20,16 @@
 #include <freeldr.h>
 #include <debug.h>
 
+int
+ofwprintf(char *fmt, ...);
+VOID
+OFExit( VOID );
+
+
 VOID BootMain(LPSTR CmdLine)
 {
+	OFExit();
+	ofwprintf("Hi from the bootloader!\n");
 	CmdLineParse(CmdLine);
 
 	MachInit(CmdLine);

Modified: branches/olpc/boot/freeldr/freeldr/freeldr_arch.rbuild
URL: http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/freeldr_arch.rbuild?rev=26960&r1=26959&r2=26960&view=diff
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/freeldr_arch.rbuild (original)
+++ branches/olpc/boot/freeldr/freeldr/freeldr_arch.rbuild Fri Jun  1 21:39:49 2007
@@ -1,7 +1,7 @@
 <directory name="arch">
 	<directory name="i386">
 		<if property="ARCH" value="i386">
-			<module name="freeldr_arch" type="objectlibrary">
+			<module name="freeldr_arch" type="objectlibrary" allowwarnings="true">
 				<include base="freeldr_base">include</include>
 				<include base="freeldr_base">cache</include>
 				<include base="ntoskrnl">include</include>
@@ -38,6 +38,17 @@
 				<file>xboxmem.c</file>
 				<file>xboxrtc.c</file>
 				<file>xboxvideo.c</file>
+
+				<file>ofw/debug.c</file>
+				<file>ofw/intprop.c</file>
+				<file>ofw/lib.c</file>
+				<file>ofw/main.c</file>
+				<file>ofw/malloc.c</file>
+				<file>ofw/mem.c</file>
+				<file>ofw/printf.c</file>
+				<file>ofw/regprop.c</file>
+				<file>ofw/strprop.c</file>
+				<file>ofw/wrappers.c</file>
 			</module>
 		</if>
 	</directory>




More information about the Ros-diffs mailing list