svn commit: r205943 - projects/ppc64/sys/boot/powerpc/ps3
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Tue Mar 30 23:15:07 UTC 2010
Author: nwhitehorn
Date: Tue Mar 30 23:15:06 2010
New Revision: 205943
URL: http://svn.freebsd.org/changeset/base/205943
Log:
Add a framebuffer console, and print the standard things that loader prints
when it begins. printf() will make development much, much easier.
Added:
projects/ppc64/sys/boot/powerpc/ps3/ps3.h
projects/ppc64/sys/boot/powerpc/ps3/ps3cons.c
Deleted:
projects/ppc64/sys/boot/powerpc/ps3/lv1call_fake.c
Modified:
projects/ppc64/sys/boot/powerpc/ps3/Makefile
projects/ppc64/sys/boot/powerpc/ps3/conf.c
projects/ppc64/sys/boot/powerpc/ps3/main.c
projects/ppc64/sys/boot/powerpc/ps3/ps3mmu.c
Modified: projects/ppc64/sys/boot/powerpc/ps3/Makefile
==============================================================================
--- projects/ppc64/sys/boot/powerpc/ps3/Makefile Tue Mar 30 23:14:35 2010 (r205942)
+++ projects/ppc64/sys/boot/powerpc/ps3/Makefile Tue Mar 30 23:15:06 2010 (r205943)
@@ -9,8 +9,8 @@ BINDIR?= /boot
INSTALLFLAGS= -b
# Architecture-specific loader code
-SRCS= start.S conf.c metadata.c vers.c main.c lv1call.S ps3mmu.c
-#SRCS= start.S conf.c metadata.c vers.c main.c lv1call_fake.c ps3mmu.c
+SRCS= start.S conf.c metadata.c vers.c main.c lv1call.S
+SRCS+= ps3cons.c font.h ps3mmu.c
SRCS+= ucmpdi2.c
LOADER_DISK_SUPPORT?= no
@@ -71,7 +71,7 @@ CFLAGS+= -I.
CLEANFILES+= vers.c loader.help
-CFLAGS+= -ffreestanding -msoft-float -DAIM
+CFLAGS+= -Wall -ffreestanding -msoft-float -DAIM
# load address. set in linker script
RELOC?= 0x0
CFLAGS+= -DRELOC=${RELOC}
@@ -91,6 +91,11 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/li
DPADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND}
LDADD= ${LIBFICL} ${LIBOFW} -lstand
+SC_DFLT_FONT=cp437
+
+font.h:
+ uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h
+
vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
Modified: projects/ppc64/sys/boot/powerpc/ps3/conf.c
==============================================================================
--- projects/ppc64/sys/boot/powerpc/ps3/conf.c Tue Mar 30 23:14:35 2010 (r205942)
+++ projects/ppc64/sys/boot/powerpc/ps3/conf.c Tue Mar 30 23:15:06 2010 (r205943)
@@ -101,16 +101,11 @@ struct file_format *file_formats[] = {
/*
* Consoles
- *
- * We don't prototype these in libofw.h because they require
- * data structures from bootstrap.h as well.
*/
-extern struct console ofwconsole;
+extern struct console ps3console;
struct console *consoles[] = {
-#if 0
- &mamboconsole,
-#endif
+ &ps3console,
NULL
};
Modified: projects/ppc64/sys/boot/powerpc/ps3/main.c
==============================================================================
--- projects/ppc64/sys/boot/powerpc/ps3/main.c Tue Mar 30 23:14:35 2010 (r205942)
+++ projects/ppc64/sys/boot/powerpc/ps3/main.c Tue Mar 30 23:15:06 2010 (r205943)
@@ -27,55 +27,55 @@
__FBSDID("$FreeBSD: head/sys/boot/powerpc/ofw/start.c 174722 2007-12-17 22:18:07Z marcel $");
#include <stand.h>
+#include <sys/param.h>
+
#include "bootstrap.h"
#include "lv1call.h"
+#include "ps3.h"
struct arch_switch archsw;
+extern void *_end;
-int ps3mmu_init(int maxmem);
-
-uint64_t fb_paddr = 0;
-uint32_t *fb_vaddr;
-
-int
-fb_init(void)
-{
- uint64_t fbhandle, fbcontext;
-
- lv1_gpu_open(0);
- lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET,
- 0,0,0,0);
- lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET,
- 0,0,1,0);
- lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
- 0,L1GPU_DISPLAY_SYNC_VSYNC,0,0);
- lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
- 1,L1GPU_DISPLAY_SYNC_VSYNC,0,0);
- lv1_gpu_memory_allocate(16*1024*1024, 0, 0, 0, 0, &fbhandle, &fb_paddr);
- lv1_gpu_context_allocate(fbhandle, 0, &fbcontext);
-
- lv1_gpu_context_attribute(fbcontext,
- L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, 0, 0, 0);
- lv1_gpu_context_attribute(fbcontext,
- L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0);
-}
+extern char bootprog_name[];
+extern char bootprog_rev[];
+extern char bootprog_date[];
+extern char bootprog_maker[];
int
main(void)
{
- int i = 0;
uint64_t maxmem = 0;
+ void *heapbase;
+ int i;
lv1_get_physmem(&maxmem);
- fb_init();
ps3mmu_init(maxmem);
- /* Turn the top of the screen red */
- for (i = 0; i < 81920; i++)
- fb_vaddr[i] = 0x00ff0000;
+ /*
+ * Set up console.
+ */
+ cons_probe();
+
+ /*
+ * Set the heap to one page after the end of the loader.
+ */
+ heapbase = (void *)((((u_long)&_end) + PAGE_SIZE) & ~PAGE_MASK);
+ setheap(heapbase, heapbase + 0x80000);
+
+ /*
+ * March through the device switch probing for things.
+ */
+ for (i = 0; devsw[i] != NULL; i++)
+ if (devsw[i]->dv_init != NULL)
+ (devsw[i]->dv_init)();
+
+ printf("\n");
+ printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
+ printf("(%s, %s)\n", bootprog_maker, bootprog_date);
+ printf("Memory: %lldKB\n", maxmem / 1024);
- while (1) {}
+ interact(); /* doesn't return */
return (0);
}
Added: projects/ppc64/sys/boot/powerpc/ps3/ps3.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/ppc64/sys/boot/powerpc/ps3/ps3.h Tue Mar 30 23:15:06 2010 (r205943)
@@ -0,0 +1,33 @@
+/*-
+ * Copyright (C) 2010 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 TOOLS GMBH 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 _PS3_H
+#define _PS3_H
+
+int ps3mmu_init(int maxmem);
+int ps3mmu_map(uint64_t va, uint64_t pa);
+void *ps3mmu_mapdev(uint64_t pa, size_t length);
+
+#endif
Added: projects/ppc64/sys/boot/powerpc/ps3/ps3cons.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/ppc64/sys/boot/powerpc/ps3/ps3cons.c Tue Mar 30 23:15:06 2010 (r205943)
@@ -0,0 +1,166 @@
+/*-
+ * Copyright (C) 2010 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 TOOLS GMBH 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD: head/sys/boot/powerpc/ofw/start.c 174722 2007-12-17 22:18:07Z marcel $");
+
+#include <stand.h>
+#include "bootstrap.h"
+#include "font.h"
+#include "lv1call.h"
+#include "ps3.h"
+
+#define FONT_SIZE 14
+#define FONT dflt_font_14
+#define XMARGIN 40
+#define YMARGIN 30
+#define BG_COLOR 0x00000000
+#define FG_COLOR 0xffffffff
+
+#define FB_SIZE (16*1024*1024)
+uint64_t fb_paddr = 0;
+uint32_t *fb_vaddr;
+
+int fb_width, fb_height;
+int x, y;
+
+static void ps3cons_probe(struct console *cp);
+static int ps3cons_init(int arg);
+static void ps3cons_putchar(int c);
+static int ps3cons_getchar();
+static int ps3cons_poll();
+
+struct console ps3console = {
+ "ps3",
+ "Playstation 3 Framebuffer",
+ 0,
+ ps3cons_probe,
+ ps3cons_init,
+ ps3cons_putchar,
+ ps3cons_getchar,
+ ps3cons_poll,
+};
+
+static void
+ps3cons_probe(struct console *cp)
+{
+ /* XXX: Get from HV */
+ fb_width = 720;
+ fb_height = 480;
+
+ cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
+}
+
+static int
+ps3cons_init(int arg)
+{
+ uint64_t fbhandle, fbcontext;
+ int i;
+
+ lv1_gpu_open(0);
+ lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET,
+ 0,0,0,0);
+ lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET,
+ 0,0,1,0);
+ lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
+ 0,L1GPU_DISPLAY_SYNC_VSYNC,0,0);
+ lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
+ 1,L1GPU_DISPLAY_SYNC_VSYNC,0,0);
+ lv1_gpu_memory_allocate(FB_SIZE, 0, 0, 0, 0, &fbhandle, &fb_paddr);
+ lv1_gpu_context_allocate(fbhandle, 0, &fbcontext);
+
+ lv1_gpu_context_attribute(fbcontext,
+ L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, 0, 0, 0);
+ lv1_gpu_context_attribute(fbcontext,
+ L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0);
+
+ fb_vaddr = ps3mmu_mapdev(fb_paddr, FB_SIZE);
+
+ x = y = 0;
+
+ /* Blank console */
+ for (i = 0; i < fb_width*fb_height; i++)
+ fb_vaddr[i] = BG_COLOR;
+
+ return (0);
+}
+
+static void
+ps3cons_putchar(int c)
+{
+ uint32_t fg, bg;
+ uint32_t *addr;
+ int i, j, k;
+ u_char *p;
+
+ if (c == 0 || c == '\r')
+ return;
+
+ /* Move down on newlines */
+ if (c == '\n') {
+ y += FONT_SIZE;
+ x = 0;
+ return;
+ }
+
+ /* Wrap long lines */
+ if (x + XMARGIN + FONT_SIZE > fb_width - XMARGIN) {
+ y += FONT_SIZE;
+ x = 0;
+ }
+
+
+ fg = FG_COLOR;
+ bg = BG_COLOR;
+
+ addr = fb_vaddr + (y + YMARGIN)*fb_width + (x + XMARGIN);
+ p = FONT + c*FONT_SIZE;
+
+ for (i = 0; i < FONT_SIZE; i++) {
+ for (j = 0, k = 7; j < 8; j++, k--) {
+ if ((p[i] & (1 << k)) == 0)
+ *(addr + j) = bg;
+ else
+ *(addr + j) = fg;
+ }
+
+ addr += fb_width;
+ }
+
+ x += 8;
+}
+
+static int
+ps3cons_getchar()
+{
+ return (-1);
+}
+
+static int
+ps3cons_poll()
+{
+ return (0);
+}
+
Modified: projects/ppc64/sys/boot/powerpc/ps3/ps3mmu.c
==============================================================================
--- projects/ppc64/sys/boot/powerpc/ps3/ps3mmu.c Tue Mar 30 23:14:35 2010 (r205942)
+++ projects/ppc64/sys/boot/powerpc/ps3/ps3mmu.c Tue Mar 30 23:15:06 2010 (r205943)
@@ -34,17 +34,15 @@ __FBSDID("$FreeBSD: head/sys/boot/powerp
#include <machine/psl.h>
#include <machine/pte.h>
#include <machine/slb.h>
+#include <machine/param.h>
#include "bootstrap.h"
#include "lv1call.h"
-
-#define PS3_LPAR_VAS_ID_CURRENT 0
+#include "ps3.h"
register_t pteg_count, pteg_mask;
uint64_t as_id;
-
-extern uint64_t fb_paddr;
-extern uint32_t *fb_vaddr;
+uint64_t virtual_avail;
int
ps3mmu_map(uint64_t va, uint64_t pa)
@@ -76,6 +74,25 @@ ps3mmu_map(uint64_t va, uint64_t pa)
return (lv1_insert_pte(ptegidx, &pt, LPTE_LOCKED));
}
+void *
+ps3mmu_mapdev(uint64_t pa, size_t length)
+{
+ uint64_t spa;
+ void *mapstart;
+ int err;
+
+ mapstart = (void *)(uintptr_t)virtual_avail;
+
+ for (spa = pa; spa < pa + length; spa += PAGE_SIZE) {
+ err = ps3mmu_map(virtual_avail, spa);
+ virtual_avail += PAGE_SIZE;
+ if (err != 0)
+ return (NULL);
+ }
+
+ return (mapstart);
+}
+
int
ps3mmu_init(int maxmem)
{
@@ -89,9 +106,7 @@ ps3mmu_init(int maxmem)
for (i = 0; i < maxmem; i += 16*1024*1024)
ps3mmu_map(i,i);
- for (i = 0; i < 16*1024*1024; i += 4096)
- ps3mmu_map(0x10000000 + i, fb_paddr + i);
- fb_vaddr = (uint32_t *)0x10000000;
+ virtual_avail = 0x10000000;
__asm __volatile ("slbia; slbmte %0, %1; slbmte %2,%3" ::
"r"((0 << SLBV_VSID_SHIFT) | SLBV_L), "r"(0 | SLBE_VALID),
@@ -99,5 +114,7 @@ ps3mmu_init(int maxmem)
"r"((1 << SLBE_ESID_SHIFT) | SLBE_VALID | 1));
mtmsr(mfmsr() | PSL_IR | PSL_DR | PSL_RI | PSL_ME);
+
+ return (0);
}
More information about the svn-src-projects
mailing list