Author: fireball
Date: Thu Aug 23 18:16:28 2007
New Revision: 28471
URL:
http://svn.reactos.org/svn/reactos?rev=28471&view=rev
Log:
- Commiting freeldr OFW stub source code. In order to compile them, you need to have a
cygwin install (or be under *nix system which is able to produce a real elf result).
Source code is not cleaned up, but I decided to commit right away so they don't get
lost.
Added:
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/1275.h (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/callofw.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/debug.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/intprop.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/lib.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/main.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/malloc.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/malloc.h (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/mem.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/printf.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/property.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/regprop.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/stdio.h (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/strings.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/strprop.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/types.h (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/wrappers.c (with props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/wrappers64.c (with
props)
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/x86/
branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/x86/makefile (with
props)
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/1275.h
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/1275.h (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/1275.h Thu Aug 23 18:16:28
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/ofwstub/source/1275.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/callofw.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/callofw.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/callofw.c Thu Aug 23
18:16:28 2007
@@ -1,0 +1,93 @@
+/*
+ * callofw.c - Open Firmware client interface for 32-bit systems.
+ * This code is intended to be portable to any 32-bit Open Firmware
+ * implementation with a standard client interface that can be
+ * called when Linux is running.
+ */
+
+#include <stdarg.h>
+#include <asm/callofw.h>
+#include <linux/types.h>
+#include <linux/spinlock.h>
+
+u32 (*call_firmware)(u32 *);
+
+static DEFINE_SPINLOCK(prom_lock);
+
+#define MAXARGS 20
+int callofw(char *name, int numargs, int numres, ...)
+{
+ va_list ap;
+ u32 argarray[MAXARGS+3];
+ int argnum = 3;
+ int retval;
+ int *intp;
+ unsigned long flags;
+
+ if (call_firmware == NULL)
+ return -1;
+
+ argarray[0] = (u32)name;
+ argarray[1] = numargs;
+ argarray[2] = numres;
+
+ if ((numargs + numres) > MAXARGS)
+ return -1;
+
+ va_start(ap, numres);
+ while (numargs--)
+ argarray[argnum++] = va_arg(ap, int);
+
+ spin_lock_irqsave(&prom_lock, flags);
+ retval = call_firmware(argarray);
+ spin_unlock_irqrestore(&prom_lock, flags);
+
+ if (retval == 0) {
+ while (numres--) {
+ intp = va_arg(ap, int *);
+ *intp = argarray[argnum++];
+ }
+ }
+ va_end(ap);
+ return retval;
+}
+
+/*
+The return value from callofw in all cases is 0 if the attempt to call the
+function succeeded, nonzero otherwise. That return value is from the
+gateway function only. Any results from the called function are returned
+via output argument pointers.
+
+Here are call templates for all the standard OFW client services.
+
+callofw("test", 1, 1, namestr, &missing);
+callofw("peer", 1, 1, phandle, &sibling_phandle);
+callofw("child", 1, 1, phandle, &child_phandle);
+callofw("parent", 1, 1, phandle, &parent_phandle);
+callofw("instance-to-package", 1, 1, ihandle, &phandle);
+callofw("getproplen", 2, 1, phandle, namestr, &proplen);
+callofw("getprop", 4, 1, phandle, namestr, bufaddr, buflen, &size);
+callofw("nextprop", 3, 1, phandle, previousstr, bufaddr, &flag);
+callofw("setprop", 4, 1, phandle, namestr, bufaddr, len, &size);
+callofw("canon", 3, 1, devspecstr, bufaddr, buflen, &length);
+callofw("finddevice", 1, 1, devspecstr, &phandle);
+callofw("instance-to-path", 3, 1, ihandle, bufaddr, buflen, &length);
+callofw("instance-to-interposed-path", 3, 1, ihandle, bufaddr, buflen,
&length);
+callofw("package-to-path", 3, 1, phandle, bufaddr, buflen, &length);
+callofw("call-method", numin, numout, in0, in1, ..., &out0, &out1,
...);
+callofw("open", 1, 1, devspecstr, &ihandle);
+callofw("close", 1, 0, ihandle);
+callofw("read", 3, 1, ihandle, addr, len, &actual);
+callofw("write", 3, 1, ihandle, addr, len, &actual);
+callofw("seek", 3, 1, ihandle, pos_hi, pos_lo, &status);
+callofw("claim", 3, 1, virtaddr, size, align, &baseaddr);
+callofw("release", 2, 0, virtaddr, size);
+callofw("boot", 1, 0, bootspecstr);
+callofw("enter", 0, 0);
+callofw("exit", 0, 0);
+callofw("chain", 5, 0, virtaddr, size, entryaddr, argsaddr, len);
+callofw("interpret", numin+1, numout+1, cmdstr, in0, ..., &catchres,
&out0, ...);
+callofw("set-callback", 1, 1, newfuncaddr, &oldfuncaddr);
+callofw("set-symbol-lookup", 2, 0, symtovaladdr, valtosymaddr);
+callofw("milliseconds", 0, 1, &ms);
+*/
Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/callofw.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/debug.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/debug.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/debug.c Thu Aug 23
18:16:28 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/ofwstub/source/debug.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/intprop.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/intprop.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/intprop.c Thu Aug 23
18:16:28 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/ofwstub/source/intprop.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/lib.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/lib.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/lib.c Thu Aug 23 18:16:28
2007
@@ -1,0 +1,302 @@
+// 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';
+}
+
+int
+ofw_setup()
+{
+ static char *argv[8];
+ phandle ph;
+ char *argstr;
+ int i;
+
+ if ((ph = OFFinddevice("/chosen")) == -1)
+ abort() ;
+ stdin->id = get_int_prop(ph, "stdin");
+ stdout->id = get_int_prop(ph, "stdout");
+
+ argv[0] = get_str_prop(ph, "bootpath", ALLOC);
+ argstr = get_str_prop(ph, "bootargs", ALLOC);
+
+ for (i = 1; i < 8;) {
+ if (*argstr == '\0')
+ break;
+ argv[i++] = argstr;
+ while (*argstr != ' ' && *argstr != '\0')
+ ++argstr;
+ if (*argstr == '\0')
+ break;
+ *argstr++ = '\0';
+ }
+ parse_homedir(argv[0]);
+ main(i, argv);
+}
+
+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/ofwstub/source/lib.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/main.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/main.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/main.c Thu Aug 23 18:16:28
2007
@@ -1,0 +1,6 @@
+#ifdef __GNUC__
+void
+__main()
+{
+}
+#endif
Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/main.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/malloc.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/malloc.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/malloc.c Thu Aug 23
18:16:28 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/ofwstub/source/malloc.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/malloc.h
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/malloc.h (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/malloc.h Thu Aug 23
18:16:28 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/ofwstub/source/malloc.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/mem.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/mem.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/mem.c Thu Aug 23 18:16:28
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/ofwstub/source/mem.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/printf.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/printf.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/printf.c Thu Aug 23
18:16:28 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
+printf(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/ofwstub/source/printf.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/property.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/property.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/property.c Thu Aug 23
18:16:28 2007
@@ -1,0 +1,66 @@
+// See license at end of file
+
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+STATIC 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)) {
+ fatal("get_int_prop(node %x, key '%s') returned %x\n",
+ node, key, res);
+ 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/ofwstub/source/property.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/regprop.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/regprop.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/regprop.c Thu Aug 23
18:16:28 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/ofwstub/source/regprop.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/stdio.h
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/stdio.h (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/stdio.h Thu Aug 23
18:16:28 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/ofwstub/source/stdio.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/strings.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/strings.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/strings.c Thu Aug 23
18:16:28 2007
@@ -1,0 +1,128 @@
+// See license at end of file
+
+/* For gcc, compile with -fno-builtin to suppress warnings */
+
+#include "1275.h"
+
+int
+strcmp(const char *s, const char *t)
+{
+ int i;
+
+ for (i = 0; s[i] == t[i]; ++i)
+ if (s[i] == '\0')
+ return (0);
+ return((int) (s[i] - t[i]));
+}
+
+int
+strncmp(const char *s, const char *t, size_t len)
+{
+ int i;
+
+ for (i = 0; (s[i] == t[i]) && (i != len); ++i)
+ if (s[i] == '\0')
+ return (0);
+ if (i == len)
+ return(0);
+ return((int) (s[i] - t[i]));
+}
+
+size_t
+strlen(const char *s)
+{
+ int i;
+
+ for (i = 0; s[i] != '\0'; ++i)
+ ;
+ return((size_t) i);
+}
+
+char *
+strcpy(char *to, const char *from)
+{
+ int i = 0;
+
+ while (to[i] = from[i])
+ i += 1;
+ return(to);
+}
+
+char *
+strncpy(char *to, const char *from, int maxlen)
+{
+ int i = 0;
+
+ while ((maxlen != 0) && (to[i] = from[i]))
+ {
+ i += 1;
+ maxlen--;
+ }
+ return(to);
+}
+
+char *
+strcat(char *to, const char *from)
+{
+ char *ret = to;
+
+ while (*to)
+ to += 1;
+ strcpy(to, from);
+ return (ret);
+}
+char *
+index(char *s, int c)
+{
+ while (*s) {
+ if (*s == c)
+ return (s);
+ ++s;
+ }
+ return ((char *) 0);
+}
+
+char *
+strctok(char *s, const char sep)
+{
+ static char *saved_str = NULL;
+ char *temp;
+
+ if (s != NULL)
+ saved_str = s;
+ if (saved_str == NULL)
+ return(NULL);
+ s = index(saved_str, sep);
+ if (s != NULL) {
+ *s++ = '\0';
+ while (*s && (*s == sep))
+ ++s;
+ }
+ temp = saved_str;
+ saved_str = s;
+ return(temp);
+}
+
+// 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/ofwstub/source/strings.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/strprop.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/strprop.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/strprop.c Thu Aug 23
18:16:28 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/ofwstub/source/strprop.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/types.h
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/types.h (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/types.h Thu Aug 23
18:16:28 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/ofwstub/source/types.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/wrappers.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/wrappers.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/wrappers.c Thu Aug 23
18:16:28 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/ofwstub/source/wrappers.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/wrappers64.c
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/wrappers64.c (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/wrappers64.c Thu Aug 23
18:16:28 2007
@@ -1,0 +1,434 @@
+// 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"
+extern int call_firmware(ULONG *);
+extern void warn(char *fmt, ...);
+
+#define CIF_HANDLER_IN 3
+
+// 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)
+{
+ ULONG argarray[] = { (ULONG)"peer",1,1,0,0};
+ argarray[CIF_HANDLER_IN+0] = device_id;
+ if (call_firmware(argarray) != 0)
+ {
+ return (phandle)0;
+ }
+ return ((phandle)argarray[CIF_HANDLER_IN+1]);
+}
+
+phandle
+OFChild(phandle device_id)
+{
+ ULONG argarray[] = { (ULONG)"child",1,1,0,0};
+ argarray[CIF_HANDLER_IN+0] = device_id;
+ if (call_firmware(argarray) != 0)
+ {
+ return (phandle)0;
+ }
+ return ((phandle)argarray[CIF_HANDLER_IN+1]);
+}
+
+phandle
+OFParent(phandle device_id)
+{
+ ULONG argarray[] = { (ULONG)"parent",1,1,0,0};
+ argarray[CIF_HANDLER_IN+0] = device_id;
+ if (call_firmware(argarray) != 0)
+ {
+ return (phandle)0;
+ }
+ return ((phandle)argarray[CIF_HANDLER_IN+1]);
+}
+
+long
+OFGetproplen(
+ phandle device_id,
+ char *name
+ )
+{
+ ULONG argarray[] = { (ULONG)"getproplen",2,1,0,0,0};
+ argarray[CIF_HANDLER_IN+0] = (long)device_id;
+ argarray[CIF_HANDLER_IN+1] = (long)name;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return (argarray[CIF_HANDLER_IN+2]);
+}
+
+long
+OFGetprop(
+ phandle device_id,
+ char *name,
+ char *buf,
+ ULONG buflen
+ )
+{
+ ULONG argarray[] = { (ULONG)"getprop",4,1,0,0,0,0,0};
+ argarray[CIF_HANDLER_IN+0] = (long)device_id;
+ argarray[CIF_HANDLER_IN+1] = (long)name;
+ argarray[CIF_HANDLER_IN+2] = (long)buf;
+ argarray[CIF_HANDLER_IN+3] = buflen;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return (argarray[CIF_HANDLER_IN+4]);
+}
+
+long
+OFNextprop(
+ phandle device_id,
+ char *name,
+ char *buf
+ )
+{
+ ULONG argarray[] = { (ULONG)"nextprop",3,1,0,0,0,0};
+ argarray[CIF_HANDLER_IN+0] = (long)device_id;
+ argarray[CIF_HANDLER_IN+1] = (long)name;
+ argarray[CIF_HANDLER_IN+2] = (long)buf;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return (argarray[CIF_HANDLER_IN+3]);
+}
+
+long
+OFSetprop(
+ phandle device_id,
+ char *name,
+ char *buf,
+ ULONG buflen
+ )
+{
+ ULONG argarray[] = { (ULONG)"setprop",4,1,0,0,0,0,0};
+ argarray[CIF_HANDLER_IN+0] = (long)device_id;
+ argarray[CIF_HANDLER_IN+1] = (long)name;
+ argarray[CIF_HANDLER_IN+2] = (long)buf;
+ argarray[CIF_HANDLER_IN+3] = buflen;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return (argarray[CIF_HANDLER_IN+4]);
+}
+
+phandle
+OFFinddevice( char *devicename)
+{
+ ULONG argarray[] = { (ULONG)"finddevice",1,1,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (long)devicename;
+ if (call_firmware(argarray) != 0)
+ {
+ return (phandle)0;
+ }
+ return ((phandle) argarray[CIF_HANDLER_IN+1]);
+}
+
+ihandle
+OFOpen( char *devicename)
+{
+ ULONG argarray[] = { (ULONG)"open",1,1,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (long)devicename;
+ if (call_firmware(argarray) != 0)
+ {
+ return (ihandle)0;
+ }
+ return ((ihandle) argarray[CIF_HANDLER_IN+1]);
+}
+
+void
+OFClose(ihandle id)
+{
+ ULONG argarray[] = { (ULONG)"close",1,1,0,0};
+ argarray[CIF_HANDLER_IN+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
+ )
+{
+ ULONG argarray[] = { (ULONG)"read",3,1,0,0,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (long) instance_id;
+ argarray[CIF_HANDLER_IN+1] = (ULONG)addr;
+ argarray[CIF_HANDLER_IN+2] = len;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return (argarray[CIF_HANDLER_IN+3]);
+}
+
+long
+OFWrite(
+ ihandle instance_id,
+ char *addr,
+ ULONG len
+ )
+{
+ ULONG argarray[] = { (ULONG)"write",3,1,0,0,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (long) instance_id;
+ argarray[CIF_HANDLER_IN+1] = (ULONG)addr;
+ argarray[CIF_HANDLER_IN+2] = len;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return (argarray[CIF_HANDLER_IN+3]);
+}
+
+long
+OFSeek(
+ ihandle instance_id,
+ ULONG poshi,
+ ULONG poslo
+ )
+{
+ ULONG argarray[] = { (ULONG)"seek",3,1,0,0,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (long) instance_id;
+ argarray[CIF_HANDLER_IN+1] = poshi;
+ argarray[CIF_HANDLER_IN+2] = poslo;
+ if (call_firmware(argarray) != 0) {
+ return (-1);
+ }
+ return (argarray[CIF_HANDLER_IN+3]);
+}
+
+ULONG
+OFClaim(
+ char *addr,
+ ULONG size,
+ ULONG align
+ )
+{
+ ULONG argarray[] = { (ULONG)"claim",3,1,0,0,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (ULONG)addr;
+ argarray[CIF_HANDLER_IN+1] = size;
+ argarray[CIF_HANDLER_IN+2] = align;
+ if (call_firmware(argarray) != 0)
+ {
+ return (ULONG)0;
+ }
+ return (argarray[CIF_HANDLER_IN+3]);
+}
+
+VOID
+OFRelease(
+ char *addr,
+ ULONG size
+ )
+{
+ ULONG argarray[] = { (ULONG)"release",2,0,0,0};
+ argarray[CIF_HANDLER_IN+0] = (ULONG)addr;
+ argarray[CIF_HANDLER_IN+1] = size;
+ call_firmware(argarray);
+}
+
+long
+OFPackageToPath(
+ phandle device_id,
+ char *addr,
+ ULONG buflen
+ )
+{
+ ULONG argarray[] = { (ULONG)"package-to-path",3,1,0,0,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (ULONG)device_id;
+ argarray[CIF_HANDLER_IN+1] = (ULONG)addr;
+ argarray[CIF_HANDLER_IN+2] = buflen;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return ((LONG)argarray[CIF_HANDLER_IN+3]);
+}
+
+phandle
+OFInstanceToPackage(ihandle ih)
+{
+ ULONG argarray[] = { (ULONG)"instance-to-package",1,1,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (ULONG)ih;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return ((LONG)argarray[CIF_HANDLER_IN+1]);
+}
+
+long
+OFCallMethod(
+ char *method,
+ ihandle id,
+ ULONG arg
+ )
+{
+ ULONG argarray[] = { (ULONG)"call-method",3,1,0,0,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (ULONG)method;
+ argarray[CIF_HANDLER_IN+1] = (ULONG)id;
+ argarray[CIF_HANDLER_IN+2] = arg;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return ((LONG)argarray[CIF_HANDLER_IN+3]);
+}
+
+long
+OFInterpret0(
+ char *cmd
+ )
+{
+ ULONG argarray[] = { (ULONG)"interpret",1,1,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (ULONG)cmd;
+ if (call_firmware(argarray) != 0)
+ {
+ return (-1);
+ }
+ return ((LONG)argarray[CIF_HANDLER_IN+1]);
+}
+
+ULONG
+OFMilliseconds( VOID )
+{
+ ULONG argarray[] = { (ULONG)"milliseconds",0,1,0};
+ if (call_firmware(argarray) != 0)
+ {
+ return (ULONG)0;
+ }
+ return (argarray[CIF_HANDLER_IN+0]);
+}
+
+void (*OFSetCallback(void (*func)(void)))(void)
+{
+ ULONG argarray[] = { (ULONG)"set-callback",1,1,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (ULONG)func;
+ if (call_firmware(argarray) != 0)
+ {
+ return (NULL);
+ }
+ return ((void (*)(void))argarray[CIF_HANDLER_IN+1]);
+}
+
+long
+OFBoot(
+ char *bootspec
+ )
+{
+ ULONG argarray[] = { (ULONG)"boot",1,0,0};
+
+ argarray[CIF_HANDLER_IN+0] = (ULONG)bootspec;
+ call_firmware(argarray);
+}
+
+VOID
+OFEnter( VOID )
+{
+ ULONG argarray[] = { (ULONG)"enter",0,0};
+
+ call_firmware(argarray);
+}
+
+/* volatile VOID */
+ VOID
+OFExit( VOID )
+{
+#ifdef DEBUG
+ ULONG argarray[] = { (ULONG)"enter",0,0};
+#else
+ ULONG argarray[] = { (ULONG)"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/ofwstub/source/wrappers64.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/x86/makefile
URL:
http://svn.reactos.org/svn/reactos/branches/olpc/boot/freeldr/freeldr/arch/…
==============================================================================
--- branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/x86/makefile (added)
+++ branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/x86/makefile Thu Aug 23
18:16:28 2007
@@ -1,0 +1,70 @@
+# This makefile has been tested on a FreeBSD 2.2.5 system with GCC
+
+# -fno-builtin has the effect of suppressing some warnings about
+# functions that conflict with gcc builtins
+CC=gcc
+CFLAGS=-g -fno-builtin
+
+all: libobp.a hello.elf start.o
+
+# Create a library file containing all the library routines
+
+libobp.a: lib.o printf.o wrappers.o malloc.o strings.o printf.o debug.o main.o intprop.o
regprop.o strprop.o mem.o
+ ar rcv libobp.a lib.o malloc.o wrappers.o strings.o printf.o debug.o main.o intprop.o
regprop.o strprop.o mem.o
+ ranlib libobp.a
+
+# Build machine-independent library routines
+
+main.o: ../main.c
+ ${CC} ${CFLAGS} -c ../main.c
+
+lib.o: ../lib.c
+ ${CC} ${CFLAGS} -c ../lib.c
+
+printf.o: ../printf.c
+ ${CC} ${CFLAGS} -c ../printf.c
+
+debug.o: ../debug.c
+ ${CC} ${CFLAGS} -c ../debug.c
+
+strings.o: ../strings.c
+ ${CC} ${CFLAGS} -c ../strings.c
+
+mem.o: ../mem.c
+ ${CC} ${CFLAGS} -c ../mem.c
+
+intprop.o: ../intprop.c
+ ${CC} ${CFLAGS} -c ../intprop.c
+
+regprop.o: ../regprop.c
+ ${CC} ${CFLAGS} -c ../regprop.c
+
+strprop.o: ../strprop.c
+ ${CC} ${CFLAGS} -c ../strprop.c
+
+wrappers.o: ../wrappers.c
+ ${CC} ${CFLAGS} -c ../wrappers.c
+
+malloc.o: ../malloc.c
+ ${CC} ${CFLAGS} -c ../malloc.c
+
+# Build processor-specific startup code and call gateway
+
+start.o: start.s
+ ${CC} ${CFLAGS} -c start.s
+
+# Hello is a demo program that uses the stdio library
+
+hello.elf: libobp.a start.o ofwboot.o freeldr_ofw.o
+ ld -nostdlib -Bstatic -N -Ttext 0x100000 -o $@ start.o ofwboot.o freeldr_ofw.o libobp.a
freeldr.elf
+
+ofwboot.o: ../../ofwboot.c
+ ${CC} ${CFLAGS} -c ../../ofwboot.c
+
+freeldr_ofw.o: ../../freeldr_ofw.o
+ ${CC} ${CFLAGS} -c ../../freeldr_ofw.c
+
+
+
+clean:
+ rm *.o hello* *.a
Propchange: branches/olpc/boot/freeldr/freeldr/arch/i386/ofwstub/source/x86/makefile
------------------------------------------------------------------------------
svn:eol-style = native