make all drivers relocatable. Per default, an 1:1 mapping is assumed.
authorStefan Reinauer <stepan@coresystems.de>
Tue, 19 Aug 2008 17:49:53 +0000 (17:49 +0000)
committerStefan Reinauer <stepan@openbios.org>
Tue, 19 Aug 2008 17:49:53 +0000 (17:49 +0000)
Patch to add relocation to libpayload will follow.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Jordan Crouse <jordan.crouse@amd.com>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3524 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

payloads/libpayload/drivers/video/geode.c
payloads/libpayload/drivers/video/vga.c
payloads/libpayload/i386/Makefile.inc
payloads/libpayload/i386/coreboot.c
payloads/libpayload/i386/virtual.c [new file with mode: 0644]
payloads/libpayload/include/arch/virtual.h [new file with mode: 0644]
payloads/libpayload/include/libpayload.h

index b0631c55b36c446428aeb88de69286e771f62cc8..c3823ffe18d907f5325fc3492c6096fef1354c9c 100644 (file)
@@ -87,7 +87,10 @@ static unsigned long vgaddr;
 static unsigned long gpaddr;
 static unsigned long fbaddr;
 
-#define FB ((unsigned char *) fbaddr)
+#define DC (phys_to_virt(dcaddr))
+#define VG (phys_to_virt(vgaddr))
+#define GP (phys_to_virt(gpaddr))
+#define FB ((unsigned char *) phys_to_virt(fbaddr))
 
 static void init_video_mode(void)
 {
@@ -119,32 +122,32 @@ static void init_video_mode(void)
        lo &= ~0x38;
        wrmsr(0x48002001, lo, hi);
 
-       writel(0x4758, dcaddr + 0x00);
+       writel(0x4758, DC + 0x00);
 
-       val = readl(dcaddr + 0x00);
+       val = readl(DC + 0x00);
 
-       writel(0, dcaddr + 0x10);
-       writel(0, dcaddr + 0x14);
-       writel(0, dcaddr + 0x18);
+       writel(0, DC + 0x10);
+       writel(0, DC + 0x14);
+       writel(0, DC + 0x18);
 
        /* Set up the default scaling */
 
-       val = readl(dcaddr + 0xD4);
+       val = readl(DC + 0xD4);
 
-       writel((0x4000 << 16) | 0x4000, dcaddr + 0x90);
-       writel(0, dcaddr + 0x94);
-       writel(val & ~0xf3040000, dcaddr + 0xD4);
+       writel((0x4000 << 16) | 0x4000, DC + 0x90);
+       writel(0, DC + 0x94);
+       writel(val & ~0xf3040000, DC + 0xD4);
 
        /* Set up the compression (or lack thereof) */
-       writel(vga_mode.hactive * vga_mode.vactive | 0x01, dcaddr + 0x2C);
+       writel(vga_mode.hactive * vga_mode.vactive | 0x01, DC + 0x2C);
 
-       val = readl(dcaddr + 0x88);
-       writel(val & ~0xC00, dcaddr + 0x88);
-       writel(0, dcaddr + 0x8C);
+       val = readl(DC + 0x88);
+       writel(val & ~0xC00, DC + 0x88);
+       writel(0, DC + 0x8C);
 
        /* Set the pitch */
-       writel(vga_mode.hactive >> 3, dcaddr + 0x34);
-       writel((vga_mode.hactive + 7) >> 3, dcaddr + 0x30);
+       writel(vga_mode.hactive >> 3, DC + 0x34);
+       writel((vga_mode.hactive + 7) >> 3, DC + 0x30);
 
        /* Set up default watermarks */
 
@@ -154,50 +157,50 @@ static void init_video_mode(void)
        /* Write the timings */
 
        writel((vga_mode.hactive - 1) | ((vga_mode.htotal - 1) << 16),
-              dcaddr + 0x40);
+              DC + 0x40);
 
        writel((vga_mode.hblankstart - 1) | ((vga_mode.hblankend - 1) << 16),
-              dcaddr + 0x44);
+              DC + 0x44);
 
        writel((vga_mode.hsyncstart - 1) | ((vga_mode.hsyncend - 1) << 16),
-              dcaddr + 0x48);
+              DC + 0x48);
 
        writel((vga_mode.vactive - 1) | ((vga_mode.vtotal - 1) << 16),
-              dcaddr + 0x50);
+              DC + 0x50);
 
        writel((vga_mode.vblankstart - 1) | ((vga_mode.vblankend - 1) << 16),
-              dcaddr + 0x54);
+              DC + 0x54);
 
        writel((vga_mode.vsyncstart - 1) | ((vga_mode.vsyncend - 1) << 16),
-              dcaddr + 0x58);
+              DC + 0x58);
 
        writel(((vga_mode.hactive - 1) << 16) | (vga_mode.vactive - 1),
-              dcaddr + 0x5C);
+              DC + 0x5C);
 
 
        /* Write the VG configuration */
 
-       writel(0x290000F | vga_mode.synccfg, vgaddr + 0x08);
+       writel(0x290000F | vga_mode.synccfg, VG + 0x08);
 
        /* Turn on the dacs */
 
-       val = readl(vgaddr + 0x50);
-       writel((val & ~0xC00) | 0x01, vgaddr + 0x50);
+       val = readl(VG + 0x50);
+       writel((val & ~0xC00) | 0x01, VG + 0x50);
 
        /* Set the framebuffer base */
-       writel(fbaddr, dcaddr + 0x84);
+       writel(fbaddr, DC + 0x84);
 
        /* Write the final configuration */
 
-       writel(0xB000059, dcaddr + 0x08);
-       writel(0, dcaddr + 0x0C);
-       writel(0x2B601, dcaddr + 0x04);
+       writel(0xB000059, DC + 0x08);
+       writel(0, DC + 0x0C);
+       writel(0x2B601, DC + 0x04);
 }
 
 static void geode_set_palette(int entry, unsigned int color)
 {
-       writel(entry, dcaddr + 0x70);
-       writel(color, dcaddr + 0x74);
+       writel(entry, DC + 0x70);
+       writel(color, DC + 0x74);
 }
 
 static void geode_scroll_up(void)
index 540e6733891e75a372244c34ed26e4c621cb955c..37acde7637ddd7dd46442dec67ee849f0c8220ec 100644 (file)
@@ -36,7 +36,7 @@
 #define CRTC_DATA       0x3d5
 
 #define VIDEO(_r, _c)\
-  ((u16 *) (0xB8000 + ((_r) * (VIDEO_COLS * 2)) + ((_c) * 2)))
+  ((u16 *) (phys_to_virt(0xB8000) + ((_r) * (VIDEO_COLS * 2)) + ((_c) * 2)))
 
 static u8 crtc_read(u8 index)
 {
index f12511f3e1726435eb673a36bd3d045ae0d9ef92..bb6bcb5a11f59a7a7180f4f800abdf5472aa8ba2 100644 (file)
@@ -29,4 +29,5 @@
 
 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
+TARGETS-y += i386/exec.S.o i386/virtual.o
+
index af76f182fc6bbd27d7712f50d30b33ed4cc00058..d27e0f3abbe18055c876c0e9afcee0503e5f8d13 100644 (file)
@@ -152,10 +152,10 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 
 int get_coreboot_info(struct sysinfo_t *info)
 {
-       int ret = cb_parse_header((void *)0x0, 0x1000, info);
+       int ret = cb_parse_header(phys_to_virt(0x00000000), 0x1000, info);
 
        if (ret != 1)
-               ret = cb_parse_header((void *)0xf0000, 0x1000, info);
+               ret = cb_parse_header(phys_to_virt(0x000f0000), 0x1000, info);
 
        return (ret == 1) ? 0 : -1;
 }
diff --git a/payloads/libpayload/i386/virtual.c b/payloads/libpayload/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/include/arch/virtual.h b/payloads/libpayload/include/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 b7f7fe0276d99be7e273153063f8d87507e2952b..8fb6d504e46fd93e606062bcdc5aaf8144a06184 100644 (file)
@@ -33,6 +33,7 @@
 #include <stddef.h>
 #include <arch/types.h>
 #include <arch/io.h>
+#include <arch/virtual.h>
 #include <sysinfo.h>
 #include <stdarg.h>
 #include <lar.h>