On 19/08/08 19:27 +0200, Stefan Reinauer wrote:
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
make all drivers relocatable. Per default, an 1:1 mapping is assumed. Patch to add relocation to libpayload will follow.
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Jordan Crouse jordan.crouse@amd.com
Index: include/libpayload.h
--- include/libpayload.h (revision 3519) +++ include/libpayload.h (working copy) @@ -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> Index: include/arch/virtual.h =================================================================== --- include/arch/virtual.h (revision 0) +++ include/arch/virtual.h (revision 0) @@ -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:
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 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.
- 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: i386/Makefile.inc =================================================================== --- i386/Makefile.inc (revision 3519) +++ i386/Makefile.inc (working copy) @@ -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: i386/virtual.c
--- i386/virtual.c (revision 0) +++ i386/virtual.c (revision 0) @@ -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:
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 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.
- 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: i386/coreboot.c
--- i386/coreboot.c (revision 3519) +++ i386/coreboot.c (working copy) @@ -152,10 +151,10 @@
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;
} Index: drivers/video/geode.c =================================================================== --- drivers/video/geode.c (revision 3519) +++ drivers/video/geode.c (working copy) @@ -87,7 +87,10 @@ 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 @@ 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 @@ /* 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: drivers/video/vga.c =================================================================== --- drivers/video/vga.c (revision 3519) +++ drivers/video/vga.c (working copy) @@ -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) {
-- coreboot mailing list coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot