This change adds PPC support to libpayload, and hooks it up in the build
authorPatrick Georgi <patrick.georgi@coresystems.de>
Thu, 21 May 2009 10:02:52 +0000 (10:02 +0000)
committerPatrick Georgi <patrick.georgi@coresystems.de>
Thu, 21 May 2009 10:02:52 +0000 (10:02 +0000)
process.
The PPC support is still stubbed, with commented out x86 code as guide
line for an implementor.

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4293 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

50 files changed:
payloads/libpayload/Config.in
payloads/libpayload/Makefile
payloads/libpayload/arch/i386/Makefile.inc [new file with mode: 0644]
payloads/libpayload/arch/i386/coreboot.c [new file with mode: 0644]
payloads/libpayload/arch/i386/exec.S [new file with mode: 0644]
payloads/libpayload/arch/i386/head.S [new file with mode: 0644]
payloads/libpayload/arch/i386/main.c [new file with mode: 0644]
payloads/libpayload/arch/i386/multiboot.c [new file with mode: 0644]
payloads/libpayload/arch/i386/sysinfo.c [new file with mode: 0644]
payloads/libpayload/arch/i386/timer.c [new file with mode: 0644]
payloads/libpayload/arch/i386/util.S [new file with mode: 0644]
payloads/libpayload/arch/i386/virtual.c [new file with mode: 0644]
payloads/libpayload/arch/powerpc/Makefile.inc [new file with mode: 0644]
payloads/libpayload/arch/powerpc/coreboot.c [new file with mode: 0644]
payloads/libpayload/arch/powerpc/exec.S [new file with mode: 0644]
payloads/libpayload/arch/powerpc/head.S [new file with mode: 0644]
payloads/libpayload/arch/powerpc/main.c [new file with mode: 0644]
payloads/libpayload/arch/powerpc/sysinfo.c [new file with mode: 0644]
payloads/libpayload/arch/powerpc/timer.c [new file with mode: 0644]
payloads/libpayload/arch/powerpc/util.S [new file with mode: 0644]
payloads/libpayload/arch/powerpc/virtual.c [new file with mode: 0644]
payloads/libpayload/configs/defconfig
payloads/libpayload/i386/Makefile.inc [deleted file]
payloads/libpayload/i386/coreboot.c [deleted file]
payloads/libpayload/i386/exec.S [deleted file]
payloads/libpayload/i386/head.S [deleted file]
payloads/libpayload/i386/main.c [deleted file]
payloads/libpayload/i386/multiboot.c [deleted file]
payloads/libpayload/i386/sysinfo.c [deleted file]
payloads/libpayload/i386/timer.c [deleted file]
payloads/libpayload/i386/util.S [deleted file]
payloads/libpayload/i386/virtual.c [deleted file]
payloads/libpayload/include/arch/endian.h [deleted file]
payloads/libpayload/include/arch/io.h [deleted file]
payloads/libpayload/include/arch/msr.h [deleted file]
payloads/libpayload/include/arch/rdtsc.h [deleted file]
payloads/libpayload/include/arch/types.h [deleted file]
payloads/libpayload/include/arch/virtual.h [deleted file]
payloads/libpayload/include/i386/arch/endian.h [new file with mode: 0644]
payloads/libpayload/include/i386/arch/io.h [new file with mode: 0644]
payloads/libpayload/include/i386/arch/msr.h [new file with mode: 0644]
payloads/libpayload/include/i386/arch/rdtsc.h [new file with mode: 0644]
payloads/libpayload/include/i386/arch/types.h [new file with mode: 0644]
payloads/libpayload/include/i386/arch/virtual.h [new file with mode: 0644]
payloads/libpayload/include/powerpc/arch/endian.h [new file with mode: 0644]
payloads/libpayload/include/powerpc/arch/io.h [new file with mode: 0644]
payloads/libpayload/include/powerpc/arch/types.h [new file with mode: 0644]
payloads/libpayload/include/powerpc/arch/virtual.h [new file with mode: 0644]
payloads/libpayload/libc/malloc.c
payloads/libpayload/libc/time.c

index 55f09f7b2d6c9e830b917ad2b98c093f0bb564ec..e0add21f4d76dbffc0346686c42aa46b57abf45e 100644 (file)
 
 mainmenu "Libpayload Configuration"
 
-# When (if) we support multiple architectures, this will become an option.
+menu "Architecture Options"
+
+choice
+        prompt "Target Architecture"
+        default TARGET_I386
+
 config TARGET_I386
-       bool
-       default y
+        bool "x86"
+        help
+          Support the x86 architecture
 
-menu "Architecture Options"
+config TARGET_POWERPC
+        bool "PowerPC"
+        help
+         Support the PowerPC architecture
+
+endchoice
 
 config MULTIBOOT
        bool "Multiboot header support"
+       depends on TARGET_I386
        default y
 
 endmenu
index 32c39575e7b2c9432791220a03e9372885991be2..8086b2949c4dfdfafe2ce55f6f798081eae80785 100644 (file)
@@ -34,7 +34,7 @@ export srck := $(src)/util/kconfig
 export obj := $(src)/build
 export objk := $(src)/build/util/kconfig
 
-export KERNELVERSION      := 0.1.0
+export KERNELVERSION      := 0.2.0
 export KCONFIG_AUTOHEADER := $(src)/include/libpayload-config.h
 export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
 
@@ -68,9 +68,10 @@ else
 
 include $(src)/.config
 
-ARCHDIR-$(CONFIG_TARGET_I386) := i386
+ARCHDIR-$(CONFIG_TARGET_I386)    := i386
+ARCHDIR-$(CONFIG_TARGET_POWERPC) := powerpc
 
-PLATFORM-y += $(ARCHDIR-y)/Makefile.inc
+PLATFORM-y += arch/$(ARCHDIR-y)/Makefile.inc
 TARGETS-y :=
 
 BUILD-y := crypto/Makefile.inc libc/Makefile.inc drivers/Makefile.inc
@@ -84,7 +85,7 @@ all: lib
 include $(PLATFORM-y) $(BUILD-y)
 
 OBJS     := $(patsubst %,$(obj)/%,$(TARGETS-y))
-INCLUDES := -Iinclude -Ibuild
+INCLUDES := -Iinclude -Ibuild -Iinclude/$(ARCHDIR-y)
 INCLUDES += -I$(shell $(CC) -print-search-dirs | head -n 1 | cut -d' ' -f2)include
 
 try-run= $(shell set -e; \
@@ -107,8 +108,8 @@ all: lib
 lib: $(obj)/lib/libpayload.a copystuff
 
 # Copy libpayload.a and head.o into $(src)/lib where lpgcc et al expect them.
-copystuff: $(obj)/$(ARCHDIR-y)/head.S.o $(obj)/lib/libpayload.a
-       $(Q)cp $(obj)/$(ARCHDIR-y)/head.S.o $(src)/lib/$(ARCHDIR-y)/head.o
+copystuff: $(obj)/arch/$(ARCHDIR-y)/head.S.o $(obj)/lib/libpayload.a
+       $(Q)cp $(obj)/arch/$(ARCHDIR-y)/head.S.o $(src)/lib/$(ARCHDIR-y)/head.o
        $(Q)cp $(obj)/lib/libpayload.a $(src)/lib
 
 $(obj)/lib/libpayload.a: prepare $(OBJS)
@@ -138,7 +139,7 @@ prepare:
        $(Q)mkdir -p $(obj)/util/kconfig/lxdialog
        $(Q)mkdir -p $(obj)/crypto $(obj)/curses $(obj)/drivers/video
        $(Q)mkdir -p $(obj)/drivers/usb
-       $(Q)mkdir -p $(obj)/i386 $(obj)/lib/$(ARCHDIR-y) $(obj)/libc 
+       $(Q)mkdir -p $(obj)/arch/$(ARCHDIR-y) $(obj)/lib/$(ARCHDIR-y) $(obj)/libc 
        $(Q)mkdir -p $(src)/lib/$(ARCHDIR-y)
 
 doxy: doxygen
@@ -151,8 +152,8 @@ doxygen-clean:
 
 clean: doxygen-clean
        $(Q)rm -rf $(obj)/crypto $(obj)/curses $(obj)/drivers
-       $(Q)rm -rf $(obj)/i386 $(obj)/lib $(obj)/libc 
-       $(Q)rm -rf $(src)/lib/i386 $(src)/lib/libpayload.a
+       $(Q)rm -rf $(obj)/i386 $(obj)/powerpc $(obj)/lib $(obj)/libc 
+       $(Q)rm -rf $(src)/lib/i386 $(src)/lib/powerpc $(src)/lib/libpayload.a
 
 distclean: clean
        $(Q)rm -rf build
diff --git a/payloads/libpayload/arch/i386/Makefile.inc b/payloads/libpayload/arch/i386/Makefile.inc
new file mode 100644 (file)
index 0000000..6461b72
--- /dev/null
@@ -0,0 +1,35 @@
+##
+## This file is part of the libpayload project.
+##
+## Copyright (C) 2008 Advanced Micro Devices, Inc.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions
+## are met:
+## 1. Redistributions of source code must retain the above copyright
+##    notice, this list of conditions and the following disclaimer.
+## 2. Redistributions in binary form must reproduce the above copyright
+##    notice, this list of conditions and the following disclaimer in the
+##    documentation and/or other materials provided with the distribution.
+## 3. The name of the author may not be used to endorse or promote products
+##    derived from this software without specific prior written permission.
+##
+## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+## ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+## SUCH DAMAGE.
+##
+
+TARGETS-y += arch/i386/head.S.o arch/i386/main.o arch/i386/sysinfo.o
+TARGETS-y += arch/i386/timer.o arch/i386/coreboot.o arch/i386/util.S.o
+TARGETS-y += arch/i386/exec.S.o arch/i386/virtual.o
+
+# Multiboot support is configurable
+TARGETS-$(CONFIG_MULTIBOOT) += arch/i386/multiboot.o
diff --git a/payloads/libpayload/arch/i386/coreboot.c b/payloads/libpayload/arch/i386/coreboot.c
new file mode 100644 (file)
index 0000000..95d8f16
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2009 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload-config.h>
+#include <libpayload.h>
+#include <coreboot_tables.h>
+
+/*
+ * Some of this is x86 specific, and the rest of it is generic. Right now,
+ * since we only support x86, we'll avoid trying to make lots of infrastructure
+ * we don't need. If in the future, we want to use coreboot on some other
+ * architecture, then take out the generic parsing code and move it elsewhere.
+ */
+
+/* === Parsing code === */
+/* This is the generic parsing code. */
+
+static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info)
+{
+       struct cb_memory *mem = (struct cb_memory *)ptr;
+       int count = MEM_RANGE_COUNT(mem);
+       int i;
+
+       if (count > SYSINFO_MAX_MEM_RANGES)
+               count = SYSINFO_MAX_MEM_RANGES;
+
+       info->n_memranges = 0;
+
+       for (i = 0; i < count; i++) {
+               struct cb_memory_range *range =
+                   (struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
+
+#if MEMMAP_RAM_ONLY
+               if (range->type != CB_MEM_RAM)
+                       continue;
+#endif
+
+               info->memrange[info->n_memranges].base =
+                   UNPACK_CB64(range->start);
+
+               info->memrange[info->n_memranges].size =
+                   UNPACK_CB64(range->size);
+
+               info->memrange[info->n_memranges].type = range->type;
+
+               info->n_memranges++;
+       }
+}
+
+static void cb_parse_serial(unsigned char *ptr, struct sysinfo_t *info)
+{
+       struct cb_serial *ser = (struct cb_serial *)ptr;
+       info->ser_ioport = ser->ioport;
+}
+
+#ifdef CONFIG_NVRAM
+static void cb_parse_optiontable(unsigned char *ptr, struct sysinfo_t *info)
+{
+       info->option_table = (struct cb_cmos_option_table *)ptr;
+}
+
+static void cb_parse_checksum(unsigned char *ptr, struct sysinfo_t *info)
+{
+       struct cb_cmos_checksum *cmos_cksum = (struct cb_cmos_checksum *)ptr;
+       info->cmos_range_start = cmos_cksum->range_start;
+       info->cmos_range_end = cmos_cksum->range_end;
+       info->cmos_checksum_location = cmos_cksum->location;
+}
+#endif
+
+static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
+{
+       struct cb_header *header;
+       unsigned char *ptr = (unsigned char *)addr;
+       int i;
+
+       for (i = 0; i < len; i += 16, ptr += 16) {
+               header = (struct cb_header *)ptr;
+               if (!strncmp((const char *)header->signature, "LBIO", 4))
+                       break;
+       }
+
+       /* We walked the entire space and didn't find anything. */
+       if (i >= len)
+               return -1;
+
+       if (!header->table_bytes)
+               return 0;
+
+       /* Make sure the checksums match. */
+       if (ipchksum((u16 *) header, sizeof(*header)) != 0)
+               return -1;
+
+       if (ipchksum((u16 *) (ptr + sizeof(*header)),
+                    header->table_bytes) != header->table_checksum)
+               return -1;
+
+       /* Now, walk the tables. */
+       ptr += header->header_bytes;
+
+       for (i = 0; i < header->table_entries; i++) {
+               struct cb_record *rec = (struct cb_record *)ptr;
+
+               /* We only care about a few tags here (maybe more later). */
+               switch (rec->tag) {
+               case CB_TAG_FORWARD:
+                       return cb_parse_header((void *)(unsigned long)((struct cb_forward *)rec)->forward, len, info);
+                       continue;
+               case CB_TAG_MEMORY:
+                       cb_parse_memory(ptr, info);
+                       break;
+               case CB_TAG_SERIAL:
+                       cb_parse_serial(ptr, info);
+                       break;
+#ifdef CONFIG_NVRAM
+               case CB_TAG_CMOS_OPTION_TABLE:
+                       cb_parse_optiontable(ptr, info);
+                       break;
+               case CB_TAG_OPTION_CHECKSUM:
+                       cb_parse_checksum(ptr, info);
+                       break;
+#endif
+               }
+
+               ptr += rec->size;
+       }
+
+       return 1;
+}
+
+/* == Architecture specific == */
+/* This is the x86 specific stuff. */
+
+int get_coreboot_info(struct sysinfo_t *info)
+{
+       int ret = cb_parse_header(phys_to_virt(0x00000000), 0x1000, info);
+
+       if (ret != 1)
+               ret = cb_parse_header(phys_to_virt(0x000f0000), 0x1000, info);
+
+       return (ret == 1) ? 0 : -1;
+}
diff --git a/payloads/libpayload/arch/i386/exec.S b/payloads/libpayload/arch/i386/exec.S
new file mode 100644 (file)
index 0000000..9a44196
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* calling syntax:  i386_do_exec(long addr, int argc, char **argv, int *ret) */
+
+/* This implements the payload API detailed here:
+ * http://www.coreboot.org/Payload_API
+ */
+
+.align 4
+.text
+
+.global i386_do_exec
+        .type i386_do_exec,@function
+
+i386_do_exec:
+       pushl %ebp
+       movl %esp, %ebp
+       pushl %eax
+
+       /* Put the run address in %eax */
+       movl 8(%ebp), %eax
+
+       /* Save off the rest of the registers */
+
+       pushl %esi
+       pushl %ecx
+       pushl %ebp
+
+       /* Push the argc and argv pointers on to the stack */
+
+       movl 12(%ebp), %esi
+       movl 16(%ebp), %ecx
+
+       pushl %esi
+       pushl %ecx
+
+       /* Move a "magic" number on the stack - the other
+        * payload will use this as a clue that the argc
+        * and argv are sane
+        */
+
+       movl  $12345678, %ecx
+       pushl %ecx
+
+       /* Jump to the code */
+       call *%eax
+
+       /* %eax has the return value */
+
+       /* Skip over the argc/argv stuff still on the stack */
+       addl $12, %esp
+
+       /* Get back %ebp */
+       popl %ebp
+
+       /* Get the pointer to the return value
+        * and save the return value in it
+         */
+
+       movl 20(%ebp), %ecx
+       movl %eax, (%eax)
+
+       /* Get the rest of the saved registers */
+       popl %ecx
+       popl %esi
+       popl %eax
+
+       /* Restore the stack pointer */
+       movl %ebp,%esp
+       popl %ebp
+       ret
+
diff --git a/payloads/libpayload/arch/i386/head.S b/payloads/libpayload/arch/i386/head.S
new file mode 100644 (file)
index 0000000..db18a51
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+       .code32
+       .global _entry, _leave
+       .text
+       .align 4
+
+/*
+ * Our entry point - assume that the CPU is in 32 bit protected mode and
+ * all segments are in a flat model. That's our operating mode, so we won't
+ * change anything.
+ */
+_entry:
+       call _init
+
+       /* We're back - go back to the bootloader. */
+       ret
+
+       .align 4
+
+#define MB_MAGIC 0x1BADB002
+#define MB_FLAGS 0x00010003
+
+mb_header:
+       .long MB_MAGIC
+       .long MB_FLAGS
+       .long -(MB_MAGIC + MB_FLAGS)
+       .long mb_header
+       .long _start
+       .long _edata
+       .long _end
+       .long _init
+
+/*
+ * This function saves off the previous stack and switches us to our
+ * own execution environment.
+ */
+_init:
+       /* No interrupts, please. */
+       cli
+
+       /* Store current stack pointer. */
+       movl %esp, %esi
+
+       /* Store EAX and EBX */
+
+       movl %eax,loader_eax
+       movl %ebx,loader_ebx
+
+       /* Setup new stack. */
+       movl $_stack, %ebx
+
+       movl %ebx, %esp
+
+       /* Save old stack pointer. */
+       pushl %esi
+
+       /* Let's rock. */
+       call start_main
+
+       /* %eax has the return value - pass it on unmolested */
+_leave:
+       /* Get old stack pointer. */
+       popl %ebx
+
+       /* Restore old stack. */
+       movl %ebx, %esp
+
+       /* Return to the original context. */
+       ret
diff --git a/payloads/libpayload/arch/i386/main.c b/payloads/libpayload/arch/i386/main.c
new file mode 100644 (file)
index 0000000..48d6ef5
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload.h>
+
+unsigned long loader_eax;  /**< The value of EAX passed from the loader */
+unsigned long loader_ebx;  /**< The value of EBX passed from the loader */
+
+unsigned int main_argc;    /**< The argc value to pass to main() */
+
+/** The argv value to pass to main() */
+char *main_argv[MAX_ARGC_COUNT];
+
+/**
+ * This is our C entry function - set up the system
+ * and jump into the payload entry point.
+ */
+void start_main(void)
+{
+       extern int main(int argc, char **argv);
+
+       /* Set up the consoles. */
+       console_init();
+
+       /* Gather system information. */
+       lib_get_sysinfo();
+
+       /*
+        * Any other system init that has to happen before the
+        * user gets control goes here.
+        */
+
+       /*
+        * Go to the entry point.
+        * In the future we may care about the return value.
+        */
+
+       (void) main(main_argc, (main_argc != 0) ? main_argv : NULL);
+
+       /*
+        * Returning here will go to the _leave function to return
+        * us to the original context.
+        */
+}
diff --git a/payloads/libpayload/arch/i386/multiboot.c b/payloads/libpayload/arch/i386/multiboot.c
new file mode 100644 (file)
index 0000000..82736b1
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload-config.h>
+#include <libpayload.h>
+#include <multiboot_tables.h>
+
+extern unsigned long loader_eax;
+extern unsigned long loader_ebx;
+
+static void mb_parse_mmap(struct multiboot_header *table,
+                       struct sysinfo_t *info)
+{
+       u8 *start = (u8 *) phys_to_virt(table->mmap_addr);
+       u8 *ptr = start;
+
+       info->n_memranges = 0;
+
+       while(ptr < (start + table->mmap_length)) {
+               struct multiboot_mmap *mmap = (struct multiboot_mmap *) ptr;
+
+#if MEMMAP_RAM_ONLY
+               /* 1 == normal RAM.  Ignore everything else for now */
+
+               if (mmap->type == 1) {
+#endif
+                       info->memrange[info->n_memranges].base = mmap->addr;
+                       info->memrange[info->n_memranges].size = mmap->length;
+                       info->memrange[info->n_memranges].type = mmap->type;
+
+                       if (++info->n_memranges == SYSINFO_MAX_MEM_RANGES)
+                               return;
+#if MEMMAP_RAM_ONLY
+               }
+#endif
+
+               ptr += (mmap->size + sizeof(mmap->size));
+       }
+}
+
+static void mb_parse_cmdline(struct multiboot_header *table)
+{
+       extern int main_argc;
+       extern char *main_argv[];
+       char *c = phys_to_virt(table->cmdline);
+
+       while(*c != '\0' && main_argc < MAX_ARGC_COUNT) {
+               main_argv[main_argc++] = c;
+
+               for( ; *c != '\0' && !isspace(*c); c++);
+
+               if (*c) {
+                       *c = 0;
+                       c++;
+               }
+       }
+}
+
+int get_multiboot_info(struct sysinfo_t *info)
+{
+       struct multiboot_header *table;
+
+       if (loader_eax != MULTIBOOT_MAGIC)
+               return -1;
+
+       table = (struct multiboot_header *) phys_to_virt(loader_ebx);
+
+       info->mbtable = phys_to_virt(loader_ebx);
+
+       if (table->flags & MULTIBOOT_FLAGS_MMAP)
+               mb_parse_mmap(table, info);
+
+       if (table->flags & MULTIBOOT_FLAGS_CMDLINE)
+               mb_parse_cmdline(table);
+
+       return 0;
+}
diff --git a/payloads/libpayload/arch/i386/sysinfo.c b/payloads/libpayload/arch/i386/sysinfo.c
new file mode 100644 (file)
index 0000000..599a811
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload-config.h>
+#include <libpayload.h>
+#include <coreboot_tables.h>
+#include <multiboot_tables.h>
+
+/**
+ * This is a global structure that is used through the library - we set it
+ * up initially with some dummy values - hopefully they will be overridden.
+ */
+struct sysinfo_t lib_sysinfo = {
+       .cpu_khz = 200,
+#ifdef CONFIG_SERIAL_CONSOLE
+       .ser_ioport = CONFIG_SERIAL_IOBASE,
+#else
+       .ser_ioport = 0x3f8,
+#endif
+};
+
+void lib_get_sysinfo(void)
+{
+       /* Get the CPU speed (for delays). */
+       lib_sysinfo.cpu_khz = get_cpu_speed();
+
+#ifdef CONFIG_MULTIBOOT
+       /* Get the information from the multiboot tables,
+        * if they exist */
+       get_multiboot_info(&lib_sysinfo);
+#endif
+
+       /* Get information from the coreboot tables,
+        * if they exist */
+
+       get_coreboot_info(&lib_sysinfo);
+
+       if (!lib_sysinfo.n_memranges) {
+               /* If we can't get a good memory range, use the default. */
+               lib_sysinfo.n_memranges = 2;
+
+               lib_sysinfo.memrange[0].base = 0;
+               lib_sysinfo.memrange[0].size = 640 * 1024;
+               lib_sysinfo.memrange[0].type = CB_MEM_RAM;
+
+               lib_sysinfo.memrange[1].base = 1024 * 1024;
+               lib_sysinfo.memrange[1].size = 31 * 1024 * 1024;
+               lib_sysinfo.memrange[1].type = CB_MEM_RAM;
+       }
+}
diff --git a/payloads/libpayload/arch/i386/timer.c b/payloads/libpayload/arch/i386/timer.c
new file mode 100644 (file)
index 0000000..3d8607b
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/**
+ * @file i386/timer.c
+ * i386 specific timer routines
+ */
+
+#include <libpayload.h>
+#include <arch/rdtsc.h>
+
+/**
+ * @ingroup arch
+ * Global variable containing the speed of the processor in KHz.
+ */
+u32 cpu_khz;
+
+/**
+ * Calculate the speed of the processor for use in delays.
+ *
+ * @return The CPU speed in kHz.
+ */
+unsigned int get_cpu_speed(void)
+{
+       unsigned long long start, end;
+
+       /* Set up the PPC port - disable the speaker, enable the T2 gate. */
+       outb((inb(0x61) & ~0x02) | 0x01, 0x61);
+
+       /* Set the PIT to Mode 0, counter 2, word access. */
+       outb(0xB0, 0x43);
+
+       /* Load the counter with 0xffff. */
+       outb(0xff, 0x42);
+       outb(0xff, 0x42);
+
+       /* Read the number of ticks during the period. */
+       start = rdtsc();
+       while (!(inb(0x61) & 0x20)) ;
+       end = rdtsc();
+
+       /*
+        * The clock rate is 1193180 Hz, the number of milliseconds for a
+        * period of 0xffff is 1193180 / (0xFFFF * 1000) or .0182.
+        * Multiply that by the number of measured clocks to get the kHz value.
+        */
+       cpu_khz = (unsigned int)((end - start) * 1193180U / (1000 * 0xffff));
+
+       return cpu_khz;
+}
+
+static inline void _delay(unsigned long long delta)
+{
+       unsigned long long timeout = rdtsc() + delta;
+       while (rdtsc() < timeout) ;
+}
+
+/**
+ * Delay for a specified number of nanoseconds.
+ *
+ * @param n Number of nanoseconds to delay for.
+ */
+void ndelay(unsigned int n)
+{
+       _delay(n * cpu_khz / 1000000);
+}
+
+/**
+ * Delay for a specified number of microseconds.
+ *
+ * @param n Number of microseconds to delay for.
+ */
+void udelay(unsigned int n)
+{
+       _delay(n * cpu_khz / 1000);
+}
+
+/**
+ * Delay for a specified number of milliseconds.
+ *
+ * @param m Number of milliseconds to delay for.
+ */
+void mdelay(unsigned int m)
+{
+       _delay(m * cpu_khz);
+}
+
+/**
+ * Delay for a specified number of seconds.
+ *
+ * @param s Number of seconds to delay for.
+ */
+void delay(unsigned int s)
+{
+       _delay(s * cpu_khz * 1000);
+}
diff --git a/payloads/libpayload/arch/i386/util.S b/payloads/libpayload/arch/i386/util.S
new file mode 100644 (file)
index 0000000..9858d29
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+       .global halt
+       .text
+       .align 4
+
+/* This function puts the system into a halt. */
+halt:
+       cli
+       hlt
+       jmp halt
diff --git a/payloads/libpayload/arch/i386/virtual.c b/payloads/libpayload/arch/i386/virtual.c
new file mode 100644 (file)
index 0000000..cff2611
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+unsigned long virtual_offset = 0;
+
diff --git a/payloads/libpayload/arch/powerpc/Makefile.inc b/payloads/libpayload/arch/powerpc/Makefile.inc
new file mode 100644 (file)
index 0000000..ddfb9fb
--- /dev/null
@@ -0,0 +1,33 @@
+##
+## This file is part of the libpayload project.
+##
+## Copyright (C) 2008 Advanced Micro Devices, Inc.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions
+## are met:
+## 1. Redistributions of source code must retain the above copyright
+##    notice, this list of conditions and the following disclaimer.
+## 2. Redistributions in binary form must reproduce the above copyright
+##    notice, this list of conditions and the following disclaimer in the
+##    documentation and/or other materials provided with the distribution.
+## 3. The name of the author may not be used to endorse or promote products
+##    derived from this software without specific prior written permission.
+##
+## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+## ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+## SUCH DAMAGE.
+##
+
+TARGETS-y += arch/powerpc/head.S.o arch/powerpc/main.o arch/powerpc/sysinfo.o
+TARGETS-y += arch/powerpc/timer.o arch/powerpc/coreboot.o arch/powerpc/util.S.o
+TARGETS-y += arch/powerpc/exec.S.o arch/powerpc/virtual.o
+
diff --git a/payloads/libpayload/arch/powerpc/coreboot.c b/payloads/libpayload/arch/powerpc/coreboot.c
new file mode 100644 (file)
index 0000000..95d8f16
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2009 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload-config.h>
+#include <libpayload.h>
+#include <coreboot_tables.h>
+
+/*
+ * Some of this is x86 specific, and the rest of it is generic. Right now,
+ * since we only support x86, we'll avoid trying to make lots of infrastructure
+ * we don't need. If in the future, we want to use coreboot on some other
+ * architecture, then take out the generic parsing code and move it elsewhere.
+ */
+
+/* === Parsing code === */
+/* This is the generic parsing code. */
+
+static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info)
+{
+       struct cb_memory *mem = (struct cb_memory *)ptr;
+       int count = MEM_RANGE_COUNT(mem);
+       int i;
+
+       if (count > SYSINFO_MAX_MEM_RANGES)
+               count = SYSINFO_MAX_MEM_RANGES;
+
+       info->n_memranges = 0;
+
+       for (i = 0; i < count; i++) {
+               struct cb_memory_range *range =
+                   (struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
+
+#if MEMMAP_RAM_ONLY
+               if (range->type != CB_MEM_RAM)
+                       continue;
+#endif
+
+               info->memrange[info->n_memranges].base =
+                   UNPACK_CB64(range->start);
+
+               info->memrange[info->n_memranges].size =
+                   UNPACK_CB64(range->size);
+
+               info->memrange[info->n_memranges].type = range->type;
+
+               info->n_memranges++;
+       }
+}
+
+static void cb_parse_serial(unsigned char *ptr, struct sysinfo_t *info)
+{
+       struct cb_serial *ser = (struct cb_serial *)ptr;
+       info->ser_ioport = ser->ioport;
+}
+
+#ifdef CONFIG_NVRAM
+static void cb_parse_optiontable(unsigned char *ptr, struct sysinfo_t *info)
+{
+       info->option_table = (struct cb_cmos_option_table *)ptr;
+}
+
+static void cb_parse_checksum(unsigned char *ptr, struct sysinfo_t *info)
+{
+       struct cb_cmos_checksum *cmos_cksum = (struct cb_cmos_checksum *)ptr;
+       info->cmos_range_start = cmos_cksum->range_start;
+       info->cmos_range_end = cmos_cksum->range_end;
+       info->cmos_checksum_location = cmos_cksum->location;
+}
+#endif
+
+static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
+{
+       struct cb_header *header;
+       unsigned char *ptr = (unsigned char *)addr;
+       int i;
+
+       for (i = 0; i < len; i += 16, ptr += 16) {
+               header = (struct cb_header *)ptr;
+               if (!strncmp((const char *)header->signature, "LBIO", 4))
+                       break;
+       }
+
+       /* We walked the entire space and didn't find anything. */
+       if (i >= len)
+               return -1;
+
+       if (!header->table_bytes)
+               return 0;
+
+       /* Make sure the checksums match. */
+       if (ipchksum((u16 *) header, sizeof(*header)) != 0)
+               return -1;
+
+       if (ipchksum((u16 *) (ptr + sizeof(*header)),
+                    header->table_bytes) != header->table_checksum)
+               return -1;
+
+       /* Now, walk the tables. */
+       ptr += header->header_bytes;
+
+       for (i = 0; i < header->table_entries; i++) {
+               struct cb_record *rec = (struct cb_record *)ptr;
+
+               /* We only care about a few tags here (maybe more later). */
+               switch (rec->tag) {
+               case CB_TAG_FORWARD:
+                       return cb_parse_header((void *)(unsigned long)((struct cb_forward *)rec)->forward, len, info);
+                       continue;
+               case CB_TAG_MEMORY:
+                       cb_parse_memory(ptr, info);
+                       break;
+               case CB_TAG_SERIAL:
+                       cb_parse_serial(ptr, info);
+                       break;
+#ifdef CONFIG_NVRAM
+               case CB_TAG_CMOS_OPTION_TABLE:
+                       cb_parse_optiontable(ptr, info);
+                       break;
+               case CB_TAG_OPTION_CHECKSUM:
+                       cb_parse_checksum(ptr, info);
+                       break;
+#endif
+               }
+
+               ptr += rec->size;
+       }
+
+       return 1;
+}
+
+/* == Architecture specific == */
+/* This is the x86 specific stuff. */
+
+int get_coreboot_info(struct sysinfo_t *info)
+{
+       int ret = cb_parse_header(phys_to_virt(0x00000000), 0x1000, info);
+
+       if (ret != 1)
+               ret = cb_parse_header(phys_to_virt(0x000f0000), 0x1000, info);
+
+       return (ret == 1) ? 0 : -1;
+}
diff --git a/payloads/libpayload/arch/powerpc/exec.S b/payloads/libpayload/arch/powerpc/exec.S
new file mode 100644 (file)
index 0000000..45672cb
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* calling syntax:  i386_do_exec(long addr, int argc, char **argv, int *ret) */
+
+/* This implements the payload API detailed here:
+ * http://www.coreboot.org/Payload_API
+ */
+
+.align 4
+.text
+
+.globl powerpc_do_exec
+        .type powerpc_do_exec,@function
+
+powerpc_do_exec:
+#if 0
+       pushl %ebp
+       movl %esp, %ebp
+       pushl %eax
+
+       /* Put the run address in %eax */
+       movl 8(%ebp), %eax
+
+       /* Save off the rest of the registers */
+
+       pushl %esi
+       pushl %ecx
+       pushl %ebp
+
+       /* Push the argc and argv pointers on to the stack */
+
+       movl 12(%ebp), %esi
+       movl 16(%ebp), %ecx
+
+       pushl %esi
+       pushl %ecx
+
+       /* Move a "magic" number on the stack - the other
+        * payload will use this as a clue that the argc
+        * and argv are sane
+        */
+
+       movl  $12345678, %ecx
+       pushl %ecx
+
+       /* Jump to the code */
+       call *%eax
+
+       /* %eax has the return value */
+
+       /* Skip over the argc/argv stuff still on the stack */
+       addl $12, %esp
+
+       /* Get back %ebp */
+       popl %ebp
+
+       /* Get the pointer to the return value
+        * and save the return value in it
+         */
+
+       movl 20(%ebp), %ecx
+       movl %eax, (%eax)
+
+       /* Get the rest of the saved registers */
+       popl %ecx
+       popl %esi
+       popl %eax
+
+       /* Restore the stack pointer */
+       movl %ebp,%esp
+       popl %ebp
+       ret
+#endif
diff --git a/payloads/libpayload/arch/powerpc/head.S b/payloads/libpayload/arch/powerpc/head.S
new file mode 100644 (file)
index 0000000..de6edad
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+       .globl _entry, _leave
+       .text
+       .align 4
+
+/*
+ * Our entry point - assume that the CPU is in 32 bit protected mode and
+ * all segments are in a flat model. That's our operating mode, so we won't
+ * change anything.
+ */
+_entry:
+#if 0
+       call _init
+
+       /* We're back - go back to the bootloader. */
+       ret
+       .align 4
+
+
+/*
+ * This function saves off the previous stack and switches us to our
+ * own execution environment.
+ */
+_init:
+       /* No interrupts, please. */
+       cli
+
+       /* Store current stack pointer. */
+       movl %esp, %esi
+
+       /* Store EAX and EBX */
+
+       movl %eax,loader_eax
+       movl %ebx,loader_ebx
+
+       /* Setup new stack. */
+       movl $_stack, %ebx
+
+       movl %ebx, %esp
+
+       /* Save old stack pointer. */
+       pushl %esi
+
+       /* Let's rock. */
+       call start_main
+
+#endif
+       /* %eax has the return value - pass it on unmolested */
+_leave:
+#if 0
+       /* Get old stack pointer. */
+       popl %ebx
+
+       /* Restore old stack. */
+       movl %ebx, %esp
+
+       /* Return to the original context. */
+       ret
+#endif
diff --git a/payloads/libpayload/arch/powerpc/main.c b/payloads/libpayload/arch/powerpc/main.c
new file mode 100644 (file)
index 0000000..48d6ef5
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload.h>
+
+unsigned long loader_eax;  /**< The value of EAX passed from the loader */
+unsigned long loader_ebx;  /**< The value of EBX passed from the loader */
+
+unsigned int main_argc;    /**< The argc value to pass to main() */
+
+/** The argv value to pass to main() */
+char *main_argv[MAX_ARGC_COUNT];
+
+/**
+ * This is our C entry function - set up the system
+ * and jump into the payload entry point.
+ */
+void start_main(void)
+{
+       extern int main(int argc, char **argv);
+
+       /* Set up the consoles. */
+       console_init();
+
+       /* Gather system information. */
+       lib_get_sysinfo();
+
+       /*
+        * Any other system init that has to happen before the
+        * user gets control goes here.
+        */
+
+       /*
+        * Go to the entry point.
+        * In the future we may care about the return value.
+        */
+
+       (void) main(main_argc, (main_argc != 0) ? main_argv : NULL);
+
+       /*
+        * Returning here will go to the _leave function to return
+        * us to the original context.
+        */
+}
diff --git a/payloads/libpayload/arch/powerpc/sysinfo.c b/payloads/libpayload/arch/powerpc/sysinfo.c
new file mode 100644 (file)
index 0000000..599a811
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload-config.h>
+#include <libpayload.h>
+#include <coreboot_tables.h>
+#include <multiboot_tables.h>
+
+/**
+ * This is a global structure that is used through the library - we set it
+ * up initially with some dummy values - hopefully they will be overridden.
+ */
+struct sysinfo_t lib_sysinfo = {
+       .cpu_khz = 200,
+#ifdef CONFIG_SERIAL_CONSOLE
+       .ser_ioport = CONFIG_SERIAL_IOBASE,
+#else
+       .ser_ioport = 0x3f8,
+#endif
+};
+
+void lib_get_sysinfo(void)
+{
+       /* Get the CPU speed (for delays). */
+       lib_sysinfo.cpu_khz = get_cpu_speed();
+
+#ifdef CONFIG_MULTIBOOT
+       /* Get the information from the multiboot tables,
+        * if they exist */
+       get_multiboot_info(&lib_sysinfo);
+#endif
+
+       /* Get information from the coreboot tables,
+        * if they exist */
+
+       get_coreboot_info(&lib_sysinfo);
+
+       if (!lib_sysinfo.n_memranges) {
+               /* If we can't get a good memory range, use the default. */
+               lib_sysinfo.n_memranges = 2;
+
+               lib_sysinfo.memrange[0].base = 0;
+               lib_sysinfo.memrange[0].size = 640 * 1024;
+               lib_sysinfo.memrange[0].type = CB_MEM_RAM;
+
+               lib_sysinfo.memrange[1].base = 1024 * 1024;
+               lib_sysinfo.memrange[1].size = 31 * 1024 * 1024;
+               lib_sysinfo.memrange[1].type = CB_MEM_RAM;
+       }
+}
diff --git a/payloads/libpayload/arch/powerpc/timer.c b/payloads/libpayload/arch/powerpc/timer.c
new file mode 100644 (file)
index 0000000..ba824b0
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/**
+ * @file i386/timer.c
+ * i386 specific timer routines
+ */
+
+#include <libpayload.h>
+// #include <arch/rdtsc.h>
+
+/**
+ * @ingroup arch
+ * Global variable containing the speed of the processor in KHz.
+ */
+u32 cpu_khz;
+
+/**
+ * Calculate the speed of the processor for use in delays.
+ *
+ * @return The CPU speed in kHz.
+ */
+unsigned int get_cpu_speed(void)
+{
+#if 0
+       unsigned long long start, end;
+
+       /* Set up the PPC port - disable the speaker, enable the T2 gate. */
+       outb((inb(0x61) & ~0x02) | 0x01, 0x61);
+
+       /* Set the PIT to Mode 0, counter 2, word access. */
+       outb(0xB0, 0x43);
+
+       /* Load the counter with 0xffff. */
+       outb(0xff, 0x42);
+       outb(0xff, 0x42);
+
+       /* Read the number of ticks during the period. */
+       start = rdtsc();
+       while (!(inb(0x61) & 0x20)) ;
+       end = rdtsc();
+
+       /*
+        * The clock rate is 1193180 Hz, the number of milliseconds for a
+        * period of 0xffff is 1193180 / (0xFFFF * 1000) or .0182.
+        * Multiply that by the number of measured clocks to get the kHz value.
+        */
+       cpu_khz = (unsigned int)((end - start) * 1193180U / (1000 * 0xffff));
+#else
+       cpu_khz = 200 * 1024;
+#endif
+       return cpu_khz;
+}
+
+static inline void _delay(unsigned long long delta)
+{
+#if 0
+       unsigned long long timeout = rdtsc() + delta;
+       while (rdtsc() < timeout) ;
+#endif
+}
+
+/**
+ * Delay for a specified number of nanoseconds.
+ *
+ * @param n Number of nanoseconds to delay for.
+ */
+void ndelay(unsigned int n)
+{
+       _delay(n * cpu_khz / 1000000);
+}
+
+/**
+ * Delay for a specified number of microseconds.
+ *
+ * @param n Number of microseconds to delay for.
+ */
+void udelay(unsigned int n)
+{
+       _delay(n * cpu_khz / 1000);
+}
+
+/**
+ * Delay for a specified number of milliseconds.
+ *
+ * @param m Number of milliseconds to delay for.
+ */
+void mdelay(unsigned int m)
+{
+       _delay(m * cpu_khz);
+}
+
+/**
+ * Delay for a specified number of seconds.
+ *
+ * @param s Number of seconds to delay for.
+ */
+void delay(unsigned int s)
+{
+       _delay(s * cpu_khz * 1000);
+}
diff --git a/payloads/libpayload/arch/powerpc/util.S b/payloads/libpayload/arch/powerpc/util.S
new file mode 100644 (file)
index 0000000..2905be7
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+       .globl halt
+       .text
+       .align 4
+
+/* This function puts the system into a halt. */
+halt:
+#if 0
+       cli
+       hlt
+       jmp halt
+#endif
diff --git a/payloads/libpayload/arch/powerpc/virtual.c b/payloads/libpayload/arch/powerpc/virtual.c
new file mode 100644 (file)
index 0000000..cff2611
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+unsigned long virtual_offset = 0;
+
index 738d6c80bc99d17b3f75138c32ff7d5a92665650..03c15fc9d171e837ff8218dba9355528e4e7909d 100644 (file)
@@ -1,13 +1,14 @@
 #
 # Automatically generated make config: don't edit
-# libpayload version: 0.1.0
-# Thu Sep 25 16:03:40 2008
+# libpayload version: 0.2.0
+# Thu May 21 12:01:39 2009
 #
-CONFIG_TARGET_I386=y
 
 #
 # Architecture Options
 #
+CONFIG_TARGET_I386=y
+# CONFIG_TARGET_POWERPC is not set
 # CONFIG_MULTIBOOT is not set
 
 #
diff --git a/payloads/libpayload/i386/Makefile.inc b/payloads/libpayload/i386/Makefile.inc
deleted file mode 100644 (file)
index 40d2699..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-##
-## This file is part of the libpayload project.
-##
-## Copyright (C) 2008 Advanced Micro Devices, Inc.
-##
-## Redistribution and use in source and binary forms, with or without
-## modification, are permitted provided that the following conditions
-## are met:
-## 1. Redistributions of source code must retain the above copyright
-##    notice, this list of conditions and the following disclaimer.
-## 2. Redistributions in binary form must reproduce the above copyright
-##    notice, this list of conditions and the following disclaimer in the
-##    documentation and/or other materials provided with the distribution.
-## 3. The name of the author may not be used to endorse or promote products
-##    derived from this software without specific prior written permission.
-##
-## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-## ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-## SUCH DAMAGE.
-##
-
-TARGETS-y += i386/head.S.o i386/main.o i386/sysinfo.o
-TARGETS-y += i386/timer.o i386/coreboot.o i386/util.S.o
-TARGETS-y += i386/exec.S.o i386/virtual.o
-
-# Multiboot support is configurable
-TARGETS-$(CONFIG_MULTIBOOT) += i386/multiboot.o
diff --git a/payloads/libpayload/i386/coreboot.c b/payloads/libpayload/i386/coreboot.c
deleted file mode 100644 (file)
index 95d8f16..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- * Copyright (C) 2009 coresystems GmbH
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <libpayload-config.h>
-#include <libpayload.h>
-#include <coreboot_tables.h>
-
-/*
- * Some of this is x86 specific, and the rest of it is generic. Right now,
- * since we only support x86, we'll avoid trying to make lots of infrastructure
- * we don't need. If in the future, we want to use coreboot on some other
- * architecture, then take out the generic parsing code and move it elsewhere.
- */
-
-/* === Parsing code === */
-/* This is the generic parsing code. */
-
-static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info)
-{
-       struct cb_memory *mem = (struct cb_memory *)ptr;
-       int count = MEM_RANGE_COUNT(mem);
-       int i;
-
-       if (count > SYSINFO_MAX_MEM_RANGES)
-               count = SYSINFO_MAX_MEM_RANGES;
-
-       info->n_memranges = 0;
-
-       for (i = 0; i < count; i++) {
-               struct cb_memory_range *range =
-                   (struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
-
-#if MEMMAP_RAM_ONLY
-               if (range->type != CB_MEM_RAM)
-                       continue;
-#endif
-
-               info->memrange[info->n_memranges].base =
-                   UNPACK_CB64(range->start);
-
-               info->memrange[info->n_memranges].size =
-                   UNPACK_CB64(range->size);
-
-               info->memrange[info->n_memranges].type = range->type;
-
-               info->n_memranges++;
-       }
-}
-
-static void cb_parse_serial(unsigned char *ptr, struct sysinfo_t *info)
-{
-       struct cb_serial *ser = (struct cb_serial *)ptr;
-       info->ser_ioport = ser->ioport;
-}
-
-#ifdef CONFIG_NVRAM
-static void cb_parse_optiontable(unsigned char *ptr, struct sysinfo_t *info)
-{
-       info->option_table = (struct cb_cmos_option_table *)ptr;
-}
-
-static void cb_parse_checksum(unsigned char *ptr, struct sysinfo_t *info)
-{
-       struct cb_cmos_checksum *cmos_cksum = (struct cb_cmos_checksum *)ptr;
-       info->cmos_range_start = cmos_cksum->range_start;
-       info->cmos_range_end = cmos_cksum->range_end;
-       info->cmos_checksum_location = cmos_cksum->location;
-}
-#endif
-
-static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
-{
-       struct cb_header *header;
-       unsigned char *ptr = (unsigned char *)addr;
-       int i;
-
-       for (i = 0; i < len; i += 16, ptr += 16) {
-               header = (struct cb_header *)ptr;
-               if (!strncmp((const char *)header->signature, "LBIO", 4))
-                       break;
-       }
-
-       /* We walked the entire space and didn't find anything. */
-       if (i >= len)
-               return -1;
-
-       if (!header->table_bytes)
-               return 0;
-
-       /* Make sure the checksums match. */
-       if (ipchksum((u16 *) header, sizeof(*header)) != 0)
-               return -1;
-
-       if (ipchksum((u16 *) (ptr + sizeof(*header)),
-                    header->table_bytes) != header->table_checksum)
-               return -1;
-
-       /* Now, walk the tables. */
-       ptr += header->header_bytes;
-
-       for (i = 0; i < header->table_entries; i++) {
-               struct cb_record *rec = (struct cb_record *)ptr;
-
-               /* We only care about a few tags here (maybe more later). */
-               switch (rec->tag) {
-               case CB_TAG_FORWARD:
-                       return cb_parse_header((void *)(unsigned long)((struct cb_forward *)rec)->forward, len, info);
-                       continue;
-               case CB_TAG_MEMORY:
-                       cb_parse_memory(ptr, info);
-                       break;
-               case CB_TAG_SERIAL:
-                       cb_parse_serial(ptr, info);
-                       break;
-#ifdef CONFIG_NVRAM
-               case CB_TAG_CMOS_OPTION_TABLE:
-                       cb_parse_optiontable(ptr, info);
-                       break;
-               case CB_TAG_OPTION_CHECKSUM:
-                       cb_parse_checksum(ptr, info);
-                       break;
-#endif
-               }
-
-               ptr += rec->size;
-       }
-
-       return 1;
-}
-
-/* == Architecture specific == */
-/* This is the x86 specific stuff. */
-
-int get_coreboot_info(struct sysinfo_t *info)
-{
-       int ret = cb_parse_header(phys_to_virt(0x00000000), 0x1000, info);
-
-       if (ret != 1)
-               ret = cb_parse_header(phys_to_virt(0x000f0000), 0x1000, info);
-
-       return (ret == 1) ? 0 : -1;
-}
diff --git a/payloads/libpayload/i386/exec.S b/payloads/libpayload/i386/exec.S
deleted file mode 100644 (file)
index 9a44196..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* calling syntax:  i386_do_exec(long addr, int argc, char **argv, int *ret) */
-
-/* This implements the payload API detailed here:
- * http://www.coreboot.org/Payload_API
- */
-
-.align 4
-.text
-
-.global i386_do_exec
-        .type i386_do_exec,@function
-
-i386_do_exec:
-       pushl %ebp
-       movl %esp, %ebp
-       pushl %eax
-
-       /* Put the run address in %eax */
-       movl 8(%ebp), %eax
-
-       /* Save off the rest of the registers */
-
-       pushl %esi
-       pushl %ecx
-       pushl %ebp
-
-       /* Push the argc and argv pointers on to the stack */
-
-       movl 12(%ebp), %esi
-       movl 16(%ebp), %ecx
-
-       pushl %esi
-       pushl %ecx
-
-       /* Move a "magic" number on the stack - the other
-        * payload will use this as a clue that the argc
-        * and argv are sane
-        */
-
-       movl  $12345678, %ecx
-       pushl %ecx
-
-       /* Jump to the code */
-       call *%eax
-
-       /* %eax has the return value */
-
-       /* Skip over the argc/argv stuff still on the stack */
-       addl $12, %esp
-
-       /* Get back %ebp */
-       popl %ebp
-
-       /* Get the pointer to the return value
-        * and save the return value in it
-         */
-
-       movl 20(%ebp), %ecx
-       movl %eax, (%eax)
-
-       /* Get the rest of the saved registers */
-       popl %ecx
-       popl %esi
-       popl %eax
-
-       /* Restore the stack pointer */
-       movl %ebp,%esp
-       popl %ebp
-       ret
-
diff --git a/payloads/libpayload/i386/head.S b/payloads/libpayload/i386/head.S
deleted file mode 100644 (file)
index db18a51..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-       .code32
-       .global _entry, _leave
-       .text
-       .align 4
-
-/*
- * Our entry point - assume that the CPU is in 32 bit protected mode and
- * all segments are in a flat model. That's our operating mode, so we won't
- * change anything.
- */
-_entry:
-       call _init
-
-       /* We're back - go back to the bootloader. */
-       ret
-
-       .align 4
-
-#define MB_MAGIC 0x1BADB002
-#define MB_FLAGS 0x00010003
-
-mb_header:
-       .long MB_MAGIC
-       .long MB_FLAGS
-       .long -(MB_MAGIC + MB_FLAGS)
-       .long mb_header
-       .long _start
-       .long _edata
-       .long _end
-       .long _init
-
-/*
- * This function saves off the previous stack and switches us to our
- * own execution environment.
- */
-_init:
-       /* No interrupts, please. */
-       cli
-
-       /* Store current stack pointer. */
-       movl %esp, %esi
-
-       /* Store EAX and EBX */
-
-       movl %eax,loader_eax
-       movl %ebx,loader_ebx
-
-       /* Setup new stack. */
-       movl $_stack, %ebx
-
-       movl %ebx, %esp
-
-       /* Save old stack pointer. */
-       pushl %esi
-
-       /* Let's rock. */
-       call start_main
-
-       /* %eax has the return value - pass it on unmolested */
-_leave:
-       /* Get old stack pointer. */
-       popl %ebx
-
-       /* Restore old stack. */
-       movl %ebx, %esp
-
-       /* Return to the original context. */
-       ret
diff --git a/payloads/libpayload/i386/main.c b/payloads/libpayload/i386/main.c
deleted file mode 100644 (file)
index 48d6ef5..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <libpayload.h>
-
-unsigned long loader_eax;  /**< The value of EAX passed from the loader */
-unsigned long loader_ebx;  /**< The value of EBX passed from the loader */
-
-unsigned int main_argc;    /**< The argc value to pass to main() */
-
-/** The argv value to pass to main() */
-char *main_argv[MAX_ARGC_COUNT];
-
-/**
- * This is our C entry function - set up the system
- * and jump into the payload entry point.
- */
-void start_main(void)
-{
-       extern int main(int argc, char **argv);
-
-       /* Set up the consoles. */
-       console_init();
-
-       /* Gather system information. */
-       lib_get_sysinfo();
-
-       /*
-        * Any other system init that has to happen before the
-        * user gets control goes here.
-        */
-
-       /*
-        * Go to the entry point.
-        * In the future we may care about the return value.
-        */
-
-       (void) main(main_argc, (main_argc != 0) ? main_argv : NULL);
-
-       /*
-        * Returning here will go to the _leave function to return
-        * us to the original context.
-        */
-}
diff --git a/payloads/libpayload/i386/multiboot.c b/payloads/libpayload/i386/multiboot.c
deleted file mode 100644 (file)
index 82736b1..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <libpayload-config.h>
-#include <libpayload.h>
-#include <multiboot_tables.h>
-
-extern unsigned long loader_eax;
-extern unsigned long loader_ebx;
-
-static void mb_parse_mmap(struct multiboot_header *table,
-                       struct sysinfo_t *info)
-{
-       u8 *start = (u8 *) phys_to_virt(table->mmap_addr);
-       u8 *ptr = start;
-
-       info->n_memranges = 0;
-
-       while(ptr < (start + table->mmap_length)) {
-               struct multiboot_mmap *mmap = (struct multiboot_mmap *) ptr;
-
-#if MEMMAP_RAM_ONLY
-               /* 1 == normal RAM.  Ignore everything else for now */
-
-               if (mmap->type == 1) {
-#endif
-                       info->memrange[info->n_memranges].base = mmap->addr;
-                       info->memrange[info->n_memranges].size = mmap->length;
-                       info->memrange[info->n_memranges].type = mmap->type;
-
-                       if (++info->n_memranges == SYSINFO_MAX_MEM_RANGES)
-                               return;
-#if MEMMAP_RAM_ONLY
-               }
-#endif
-
-               ptr += (mmap->size + sizeof(mmap->size));
-       }
-}
-
-static void mb_parse_cmdline(struct multiboot_header *table)
-{
-       extern int main_argc;
-       extern char *main_argv[];
-       char *c = phys_to_virt(table->cmdline);
-
-       while(*c != '\0' && main_argc < MAX_ARGC_COUNT) {
-               main_argv[main_argc++] = c;
-
-               for( ; *c != '\0' && !isspace(*c); c++);
-
-               if (*c) {
-                       *c = 0;
-                       c++;
-               }
-       }
-}
-
-int get_multiboot_info(struct sysinfo_t *info)
-{
-       struct multiboot_header *table;
-
-       if (loader_eax != MULTIBOOT_MAGIC)
-               return -1;
-
-       table = (struct multiboot_header *) phys_to_virt(loader_ebx);
-
-       info->mbtable = phys_to_virt(loader_ebx);
-
-       if (table->flags & MULTIBOOT_FLAGS_MMAP)
-               mb_parse_mmap(table, info);
-
-       if (table->flags & MULTIBOOT_FLAGS_CMDLINE)
-               mb_parse_cmdline(table);
-
-       return 0;
-}
diff --git a/payloads/libpayload/i386/sysinfo.c b/payloads/libpayload/i386/sysinfo.c
deleted file mode 100644 (file)
index 599a811..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <libpayload-config.h>
-#include <libpayload.h>
-#include <coreboot_tables.h>
-#include <multiboot_tables.h>
-
-/**
- * This is a global structure that is used through the library - we set it
- * up initially with some dummy values - hopefully they will be overridden.
- */
-struct sysinfo_t lib_sysinfo = {
-       .cpu_khz = 200,
-#ifdef CONFIG_SERIAL_CONSOLE
-       .ser_ioport = CONFIG_SERIAL_IOBASE,
-#else
-       .ser_ioport = 0x3f8,
-#endif
-};
-
-void lib_get_sysinfo(void)
-{
-       /* Get the CPU speed (for delays). */
-       lib_sysinfo.cpu_khz = get_cpu_speed();
-
-#ifdef CONFIG_MULTIBOOT
-       /* Get the information from the multiboot tables,
-        * if they exist */
-       get_multiboot_info(&lib_sysinfo);
-#endif
-
-       /* Get information from the coreboot tables,
-        * if they exist */
-
-       get_coreboot_info(&lib_sysinfo);
-
-       if (!lib_sysinfo.n_memranges) {
-               /* If we can't get a good memory range, use the default. */
-               lib_sysinfo.n_memranges = 2;
-
-               lib_sysinfo.memrange[0].base = 0;
-               lib_sysinfo.memrange[0].size = 640 * 1024;
-               lib_sysinfo.memrange[0].type = CB_MEM_RAM;
-
-               lib_sysinfo.memrange[1].base = 1024 * 1024;
-               lib_sysinfo.memrange[1].size = 31 * 1024 * 1024;
-               lib_sysinfo.memrange[1].type = CB_MEM_RAM;
-       }
-}
diff --git a/payloads/libpayload/i386/timer.c b/payloads/libpayload/i386/timer.c
deleted file mode 100644 (file)
index 3d8607b..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/**
- * @file i386/timer.c
- * i386 specific timer routines
- */
-
-#include <libpayload.h>
-#include <arch/rdtsc.h>
-
-/**
- * @ingroup arch
- * Global variable containing the speed of the processor in KHz.
- */
-u32 cpu_khz;
-
-/**
- * Calculate the speed of the processor for use in delays.
- *
- * @return The CPU speed in kHz.
- */
-unsigned int get_cpu_speed(void)
-{
-       unsigned long long start, end;
-
-       /* Set up the PPC port - disable the speaker, enable the T2 gate. */
-       outb((inb(0x61) & ~0x02) | 0x01, 0x61);
-
-       /* Set the PIT to Mode 0, counter 2, word access. */
-       outb(0xB0, 0x43);
-
-       /* Load the counter with 0xffff. */
-       outb(0xff, 0x42);
-       outb(0xff, 0x42);
-
-       /* Read the number of ticks during the period. */
-       start = rdtsc();
-       while (!(inb(0x61) & 0x20)) ;
-       end = rdtsc();
-
-       /*
-        * The clock rate is 1193180 Hz, the number of milliseconds for a
-        * period of 0xffff is 1193180 / (0xFFFF * 1000) or .0182.
-        * Multiply that by the number of measured clocks to get the kHz value.
-        */
-       cpu_khz = (unsigned int)((end - start) * 1193180U / (1000 * 0xffff));
-
-       return cpu_khz;
-}
-
-static inline void _delay(unsigned long long delta)
-{
-       unsigned long long timeout = rdtsc() + delta;
-       while (rdtsc() < timeout) ;
-}
-
-/**
- * Delay for a specified number of nanoseconds.
- *
- * @param n Number of nanoseconds to delay for.
- */
-void ndelay(unsigned int n)
-{
-       _delay(n * cpu_khz / 1000000);
-}
-
-/**
- * Delay for a specified number of microseconds.
- *
- * @param n Number of microseconds to delay for.
- */
-void udelay(unsigned int n)
-{
-       _delay(n * cpu_khz / 1000);
-}
-
-/**
- * Delay for a specified number of milliseconds.
- *
- * @param m Number of milliseconds to delay for.
- */
-void mdelay(unsigned int m)
-{
-       _delay(m * cpu_khz);
-}
-
-/**
- * Delay for a specified number of seconds.
- *
- * @param s Number of seconds to delay for.
- */
-void delay(unsigned int s)
-{
-       _delay(s * cpu_khz * 1000);
-}
diff --git a/payloads/libpayload/i386/util.S b/payloads/libpayload/i386/util.S
deleted file mode 100644 (file)
index 9858d29..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-       .global halt
-       .text
-       .align 4
-
-/* This function puts the system into a halt. */
-halt:
-       cli
-       hlt
-       jmp halt
diff --git a/payloads/libpayload/i386/virtual.c b/payloads/libpayload/i386/virtual.c
deleted file mode 100644 (file)
index cff2611..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 coresystems GmbH
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-unsigned long virtual_offset = 0;
-
diff --git a/payloads/libpayload/include/arch/endian.h b/payloads/libpayload/include/arch/endian.h
deleted file mode 100644 (file)
index a50ac1f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ARCH_ENDIAN_H
-#define _ARCH_ENDIAN_H
-
-#include <arch/types.h>
-
-#define ntohw(in) ((( (in) & 0xFF) << 8) | (( (in) & 0xFF00) >> 8))
-
-#define ntohl(in) ((( (in) & 0xFF) << 24) | (( (in) & 0xFF00) << 8) | \
-               (( (in) & 0xFF0000) >> 8) | (( (in) & 0xFF000000) >> 24))
-
-#define ntohll(in) (((u64) ntohl( (in) & 0xFFFFFFFF) << 32) | ((u64) ntohl( (in) >> 32))) 
-#endif
diff --git a/payloads/libpayload/include/arch/io.h b/payloads/libpayload/include/arch/io.h
deleted file mode 100644 (file)
index 31a8f88..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- * Copyright (C) 2008 coresystems GmbH
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ARCH_IO_H
-#define _ARCH_IO_H
-
-#define readb(_a) (*(volatile unsigned char *) (_a))
-#define readw(_a) (*(volatile unsigned short *) (_a))
-#define readl(_a) (*(volatile unsigned long *) (_a))
-
-#define writeb(_v, _a) (*(volatile unsigned char *) (_a) = (_v))
-#define writew(_v, _a) (*(volatile unsigned short *) (_a) = (_v))
-#define writel(_v, _a) (*(volatile unsigned long *) (_a) = (_v))
-
-static inline unsigned long inl(int port)
-{
-       unsigned long val;
-       __asm__ __volatile__("inl %w1, %0" : "=a"(val) : "Nd"(port));
-       return val;
-}
-
-static inline unsigned short inw(int port)
-{
-       unsigned short val;
-       __asm__ __volatile__("inw %w1, %w0" : "=a"(val) : "Nd"(port));
-       return val;
-}
-
-static inline unsigned char inb(int port)
-{
-       unsigned char val;
-       __asm__ __volatile__("inb %w1, %b0" : "=a"(val) : "Nd"(port));
-       return val;
-}
-
-static inline void outl(unsigned long val, int port)
-{
-       __asm__ __volatile__("outl %0, %w1" : : "a"(val), "Nd"(port));
-}
-
-static inline void outw(unsigned short val, int port)
-{
-       __asm__ __volatile__("outw %w0, %w1" : : "a"(val), "Nd"(port));
-}
-
-static inline void outb(unsigned char val, int port)
-{
-       __asm__ __volatile__("outb %b0, %w1" : : "a"(val), "Nd"(port));
-}
-
-static inline void outsl(int port, const void *addr, unsigned long count)
-{
-       __asm__ __volatile__("rep; outsl" : "+S"(addr), "+c"(count) : "d"(port));
-}
-
-static inline void outsw(int port, const void *addr, unsigned long count)
-{
-       __asm__ __volatile__("rep; outsw" : "+S"(addr), "+c"(count) : "d"(port));
-}
-
-static inline void outsb(int port, const void *addr, unsigned long count)
-{
-       __asm__ __volatile__("rep; outsb" : "+S"(addr), "+c"(count) : "d"(port));
-}
-
-static inline void insl(int port, void *addr, unsigned long count)
-{
-       __asm__ __volatile__("rep; insl" : "+D"(addr), "+c"(count) : "d"(port));
-}
-
-static inline void insw(int port, void *addr, unsigned long count)
-{
-       __asm__ __volatile__("rep; insw" : "+D"(addr), "+c"(count) : "d"(port));
-}
-
-static inline void insb(int port, void *addr, unsigned long count)
-{
-       __asm__ __volatile__("rep; insb" : "+D"(addr), "+c"(count) : "d"(port));
-}
-
-#endif
diff --git a/payloads/libpayload/include/arch/msr.h b/payloads/libpayload/include/arch/msr.h
deleted file mode 100644 (file)
index c28b56c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ARCH_MSR_H
-#define _ARCH_MSR_H
-
-static inline unsigned long long _rdmsr(unsigned int msr)
-{
-       unsigned long long val;
-       asm volatile("rdmsr" : "=A" (val) : "c" (msr));
-       return val;
-}
-
-static inline void _wrmsr(unsigned int msr, unsigned long long val)
-{
-       asm volatile("wrmsr" : : "c" (msr), "A"(val));
-}
-
-#define rdmsr(_m, _l, _h) \
-       do { \
-               unsigned long long _v = _rdmsr((_m)); \
-               (_l) = (unsigned int) _v; \
-               (_h) = (unsigned int) ((_v >> 32) & 0xFFFFFFFF); \
-       } while(0)
-
-static inline void wrmsr(unsigned int msr, unsigned int lo, unsigned int hi)
-{
-       unsigned long long val = (((unsigned long long) hi) << 32) | lo;
-       _wrmsr(msr, val);
-}
-
-#endif
diff --git a/payloads/libpayload/include/arch/rdtsc.h b/payloads/libpayload/include/arch/rdtsc.h
deleted file mode 100644 (file)
index 52f8c9c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ARCH_RDTSC_H
-#define _ARCH_RDTSC_H
-
-static u64 rdtsc(void)
-{
-       u64 val;
-       __asm__ __volatile__ ("rdtsc" : "=A" (val));
-       return val;
-}
-
-#endif
diff --git a/payloads/libpayload/include/arch/types.h b/payloads/libpayload/include/arch/types.h
deleted file mode 100644 (file)
index 1bd815b..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ARCH_TYPES_H
-#define _ARCH_TYPES_H
-
-typedef unsigned char uint8_t;
-typedef unsigned char u8;
-typedef signed char int8_t;
-typedef signed char s8;
-
-typedef unsigned short uint16_t;
-typedef unsigned short u16;
-typedef signed short int16_t;
-typedef signed short s16;
-
-typedef unsigned int uint32_t;
-typedef unsigned int u32;
-typedef signed int int32_t;
-typedef signed int s32;
-
-typedef unsigned long long uint64_t;
-typedef unsigned long long u64;
-typedef signed long long int64_t;
-typedef signed long long s64;
-
-typedef long time_t;
-typedef long suseconds_t;
-
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
-#endif
diff --git a/payloads/libpayload/include/arch/virtual.h b/payloads/libpayload/include/arch/virtual.h
deleted file mode 100644 (file)
index 328c3aa..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 coresystems GmbH
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ARCH_VIRTUAL_H
-#define _ARCH_VIRTUAL_H
-
-extern unsigned long virtual_offset;
-
-#define virt_to_phys(virt) ((unsigned long) (virt) + virtual_offset)
-#define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virtual_offset))
-
-#define virt_to_bus(addr) virt_to_phys(addr)
-#define bus_to_virt(addr) phys_to_virt(addr)
-
-#endif
diff --git a/payloads/libpayload/include/i386/arch/endian.h b/payloads/libpayload/include/i386/arch/endian.h
new file mode 100644 (file)
index 0000000..a50ac1f
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_ENDIAN_H
+#define _ARCH_ENDIAN_H
+
+#include <arch/types.h>
+
+#define ntohw(in) ((( (in) & 0xFF) << 8) | (( (in) & 0xFF00) >> 8))
+
+#define ntohl(in) ((( (in) & 0xFF) << 24) | (( (in) & 0xFF00) << 8) | \
+               (( (in) & 0xFF0000) >> 8) | (( (in) & 0xFF000000) >> 24))
+
+#define ntohll(in) (((u64) ntohl( (in) & 0xFFFFFFFF) << 32) | ((u64) ntohl( (in) >> 32))) 
+#endif
diff --git a/payloads/libpayload/include/i386/arch/io.h b/payloads/libpayload/include/i386/arch/io.h
new file mode 100644 (file)
index 0000000..31a8f88
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2008 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_IO_H
+#define _ARCH_IO_H
+
+#define readb(_a) (*(volatile unsigned char *) (_a))
+#define readw(_a) (*(volatile unsigned short *) (_a))
+#define readl(_a) (*(volatile unsigned long *) (_a))
+
+#define writeb(_v, _a) (*(volatile unsigned char *) (_a) = (_v))
+#define writew(_v, _a) (*(volatile unsigned short *) (_a) = (_v))
+#define writel(_v, _a) (*(volatile unsigned long *) (_a) = (_v))
+
+static inline unsigned long inl(int port)
+{
+       unsigned long val;
+       __asm__ __volatile__("inl %w1, %0" : "=a"(val) : "Nd"(port));
+       return val;
+}
+
+static inline unsigned short inw(int port)
+{
+       unsigned short val;
+       __asm__ __volatile__("inw %w1, %w0" : "=a"(val) : "Nd"(port));
+       return val;
+}
+
+static inline unsigned char inb(int port)
+{
+       unsigned char val;
+       __asm__ __volatile__("inb %w1, %b0" : "=a"(val) : "Nd"(port));
+       return val;
+}
+
+static inline void outl(unsigned long val, int port)
+{
+       __asm__ __volatile__("outl %0, %w1" : : "a"(val), "Nd"(port));
+}
+
+static inline void outw(unsigned short val, int port)
+{
+       __asm__ __volatile__("outw %w0, %w1" : : "a"(val), "Nd"(port));
+}
+
+static inline void outb(unsigned char val, int port)
+{
+       __asm__ __volatile__("outb %b0, %w1" : : "a"(val), "Nd"(port));
+}
+
+static inline void outsl(int port, const void *addr, unsigned long count)
+{
+       __asm__ __volatile__("rep; outsl" : "+S"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void outsw(int port, const void *addr, unsigned long count)
+{
+       __asm__ __volatile__("rep; outsw" : "+S"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void outsb(int port, const void *addr, unsigned long count)
+{
+       __asm__ __volatile__("rep; outsb" : "+S"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void insl(int port, void *addr, unsigned long count)
+{
+       __asm__ __volatile__("rep; insl" : "+D"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void insw(int port, void *addr, unsigned long count)
+{
+       __asm__ __volatile__("rep; insw" : "+D"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void insb(int port, void *addr, unsigned long count)
+{
+       __asm__ __volatile__("rep; insb" : "+D"(addr), "+c"(count) : "d"(port));
+}
+
+#endif
diff --git a/payloads/libpayload/include/i386/arch/msr.h b/payloads/libpayload/include/i386/arch/msr.h
new file mode 100644 (file)
index 0000000..c28b56c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_MSR_H
+#define _ARCH_MSR_H
+
+static inline unsigned long long _rdmsr(unsigned int msr)
+{
+       unsigned long long val;
+       asm volatile("rdmsr" : "=A" (val) : "c" (msr));
+       return val;
+}
+
+static inline void _wrmsr(unsigned int msr, unsigned long long val)
+{
+       asm volatile("wrmsr" : : "c" (msr), "A"(val));
+}
+
+#define rdmsr(_m, _l, _h) \
+       do { \
+               unsigned long long _v = _rdmsr((_m)); \
+               (_l) = (unsigned int) _v; \
+               (_h) = (unsigned int) ((_v >> 32) & 0xFFFFFFFF); \
+       } while(0)
+
+static inline void wrmsr(unsigned int msr, unsigned int lo, unsigned int hi)
+{
+       unsigned long long val = (((unsigned long long) hi) << 32) | lo;
+       _wrmsr(msr, val);
+}
+
+#endif
diff --git a/payloads/libpayload/include/i386/arch/rdtsc.h b/payloads/libpayload/include/i386/arch/rdtsc.h
new file mode 100644 (file)
index 0000000..52f8c9c
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_RDTSC_H
+#define _ARCH_RDTSC_H
+
+static u64 rdtsc(void)
+{
+       u64 val;
+       __asm__ __volatile__ ("rdtsc" : "=A" (val));
+       return val;
+}
+
+#endif
diff --git a/payloads/libpayload/include/i386/arch/types.h b/payloads/libpayload/include/i386/arch/types.h
new file mode 100644 (file)
index 0000000..1bd815b
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_TYPES_H
+#define _ARCH_TYPES_H
+
+typedef unsigned char uint8_t;
+typedef unsigned char u8;
+typedef signed char int8_t;
+typedef signed char s8;
+
+typedef unsigned short uint16_t;
+typedef unsigned short u16;
+typedef signed short int16_t;
+typedef signed short s16;
+
+typedef unsigned int uint32_t;
+typedef unsigned int u32;
+typedef signed int int32_t;
+typedef signed int s32;
+
+typedef unsigned long long uint64_t;
+typedef unsigned long long u64;
+typedef signed long long int64_t;
+typedef signed long long s64;
+
+typedef long time_t;
+typedef long suseconds_t;
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#endif
diff --git a/payloads/libpayload/include/i386/arch/virtual.h b/payloads/libpayload/include/i386/arch/virtual.h
new file mode 100644 (file)
index 0000000..328c3aa
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_VIRTUAL_H
+#define _ARCH_VIRTUAL_H
+
+extern unsigned long virtual_offset;
+
+#define virt_to_phys(virt) ((unsigned long) (virt) + virtual_offset)
+#define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virtual_offset))
+
+#define virt_to_bus(addr) virt_to_phys(addr)
+#define bus_to_virt(addr) phys_to_virt(addr)
+
+#endif
diff --git a/payloads/libpayload/include/powerpc/arch/endian.h b/payloads/libpayload/include/powerpc/arch/endian.h
new file mode 100644 (file)
index 0000000..8ffad70
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_ENDIAN_H
+#define _ARCH_ENDIAN_H
+
+#include <arch/types.h>
+
+#define ntohw(in) (in)
+
+#define ntohl(in) (in)
+
+#define ntohll(in) (in)
+
+#endif
diff --git a/payloads/libpayload/include/powerpc/arch/io.h b/payloads/libpayload/include/powerpc/arch/io.h
new file mode 100644 (file)
index 0000000..1676a8a
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2008-2009 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_IO_H
+#define _ARCH_IO_H
+
+extern uint32_t isa_io_base;
+
+#define readb(_a) (*(volatile unsigned char *) (_a))
+#define readw(_a) (*(volatile unsigned short *) (_a))
+#define readl(_a) (*(volatile unsigned long *) (_a))
+
+#define writeb(_v, _a) (*(volatile unsigned char *) (_a) = (_v))
+#define writew(_v, _a) (*(volatile unsigned short *) (_a) = (_v))
+#define writel(_v, _a) (*(volatile unsigned long *) (_a) = (_v))
+
+static inline unsigned long inl(int port)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       unsigned long val;
+       __asm__ __volatile__("lhbrx %0,0,%1; eieio":"=r"(val):
+                       "r"(addr), "m"(*addr));
+       return val;
+}
+
+static inline unsigned short inw(int port)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       unsigned short val;
+       __asm__ __volatile__("lwbrx %0,0,%1; eieio":"=r"(val):"r"(addr), "m"(*addr));
+       return val;
+}
+
+static inline unsigned char inb(int port)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       unsigned char val;
+       __asm__ __volatile__("lbz%U1%X1 %0,%1; eieio":"=r"(val):"m"(*addr));
+       return val;
+}
+
+static inline void outl(unsigned long val, int port)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       __asm__ __volatile__("stb%U0%X0 %1,%0; eieio":"=m"(*addr):"r"(val));
+}
+
+static inline void outw(unsigned short val, int port)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       __asm__ __volatile__("sthbrx %1,0,%2; eieio":"=m"(*addr):"r"(val),"r"(addr));
+}
+
+static inline void outb(unsigned char val, int port)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       __asm__ __volatile__("stwbrx %1,0,%2; eieio":"=m"(*addr):"r"(val), "r"(addr));
+}
+
+static inline void outsl(int port, const void *addr, unsigned long count)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       //__asm__ __volatile__("rep; outsl" : "+S"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void outsw(int port, const void *addr, unsigned long count)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       //__asm__ __volatile__("rep; outsw" : "+S"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void outsb(int port, const void *addr, unsigned long count)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       //__asm__ __volatile__("rep; outsb" : "+S"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void insl(int port, void *addr, unsigned long count)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       //__asm__ __volatile__("rep; insl" : "+D"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void insw(int port, void *addr, unsigned long count)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       //__asm__ __volatile__("rep; insw" : "+D"(addr), "+c"(count) : "d"(port));
+}
+
+static inline void insb(int port, void *addr, unsigned long count)
+{
+       volatile unsigned char *addr = (volatile unsigned char *)(isa_io_base + port);
+       //__asm__ __volatile__("rep; insb" : "+D"(addr), "+c"(count) : "d"(port));
+}
+
+#endif
diff --git a/payloads/libpayload/include/powerpc/arch/types.h b/payloads/libpayload/include/powerpc/arch/types.h
new file mode 100644 (file)
index 0000000..1bd815b
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_TYPES_H
+#define _ARCH_TYPES_H
+
+typedef unsigned char uint8_t;
+typedef unsigned char u8;
+typedef signed char int8_t;
+typedef signed char s8;
+
+typedef unsigned short uint16_t;
+typedef unsigned short u16;
+typedef signed short int16_t;
+typedef signed short s16;
+
+typedef unsigned int uint32_t;
+typedef unsigned int u32;
+typedef signed int int32_t;
+typedef signed int s32;
+
+typedef unsigned long long uint64_t;
+typedef unsigned long long u64;
+typedef signed long long int64_t;
+typedef signed long long s64;
+
+typedef long time_t;
+typedef long suseconds_t;
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#endif
diff --git a/payloads/libpayload/include/powerpc/arch/virtual.h b/payloads/libpayload/include/powerpc/arch/virtual.h
new file mode 100644 (file)
index 0000000..328c3aa
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARCH_VIRTUAL_H
+#define _ARCH_VIRTUAL_H
+
+extern unsigned long virtual_offset;
+
+#define virt_to_phys(virt) ((unsigned long) (virt) + virtual_offset)
+#define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virtual_offset))
+
+#define virt_to_bus(addr) virt_to_phys(addr)
+#define bus_to_virt(addr) phys_to_virt(addr)
+
+#endif
index 24daf0e680470259372c3e567ac379faf1676e69..d18b289adf9ea1a416a4211b456dee632e92b8cf 100644 (file)
@@ -103,16 +103,22 @@ static void *alloc(int len)
                                void *nptr = ptr + (HDRSIZE + len);
                                int nsize = size - (HDRSIZE + len);
 
-                               /* Mark the block as used. */
-                               *((hdrtype_t *) ptr) = USED_BLOCK(len);
-
                                /* If there is still room in this block,
-                                * then mark it as such.
+                                * then mark it as such otherwise account
+                                * the whole space for that block.
                                 */
 
-                               if (nsize > 0)
+                               if (nsize > 0) {
+                                       /* Mark the block as used. */
+                                       *((hdrtype_t *) ptr) = USED_BLOCK(len);
+
+                                       /* Create a new free block. */
                                        *((hdrtype_t *) nptr) =
                                            FREE_BLOCK(nsize);
+                               } else {
+                                       /* Mark the block as used. */
+                                       *((hdrtype_t *) ptr) = USED_BLOCK(size);
+                               }
 
                                return (void *)(ptr + HDRSIZE);
                        }
index 2d19bd173f7a866a988d5fbd92e43f76eb78e5fc..67675623a467e8397b450d3f2b4f8bc5b9f92d84 100644 (file)
@@ -34,7 +34,9 @@
 
 #include <libpayload-config.h>
 #include <libpayload.h>
+#ifdef CONFIG_TARGET_I386
 #include <arch/rdtsc.h>
+#endif
 
 extern u32 cpu_khz;
 
@@ -47,6 +49,7 @@ static struct {
 #define TICKS_PER_SEC (cpu_khz * 1000)
 #define TICKS_PER_USEC (cpu_khz / 1000)
 
+#ifdef CONFIG_TARGET_I386
 static void update_clock(void)
 {
        u64 delta = rdtsc() - clock.ticks;
@@ -114,7 +117,16 @@ static void gettimeofday_init(void)
        clock.ticks = rdtsc();
 }
 #endif
+#endif
+#ifdef CONFIG_TARGET_POWERPC
+static void update_clock(void)
+{
+}
 
+static void gettimeofday_init(void)
+{
+}
+#endif
 /**
  * Return the current time broken into a timeval structure.
  *