2 * Copyright (C) 2010 Nathan Whitehorn
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
30 #include "bootstrap.h"
36 #define FONT dflt_font_14
39 #define BG_COLOR 0x00000000
40 #define FG_COLOR 0xffffffff
42 #define FB_SIZE (16*1024*1024)
43 uint64_t fb_paddr = 0;
46 int fb_width, fb_height;
49 static void ps3cons_probe(struct console *cp);
50 static int ps3cons_init(int arg);
51 static void ps3cons_putchar(int c);
52 static int ps3cons_getchar();
53 static int ps3cons_poll();
55 struct console ps3console = {
57 "Playstation 3 Framebuffer",
67 ps3cons_probe(struct console *cp)
69 /* XXX: Get from HV */
73 cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
79 uint64_t fbhandle, fbcontext;
83 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET,
85 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET,
87 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
88 0,L1GPU_DISPLAY_SYNC_VSYNC,0,0);
89 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
90 1,L1GPU_DISPLAY_SYNC_VSYNC,0,0);
91 lv1_gpu_memory_allocate(FB_SIZE, 0, 0, 0, 0, &fbhandle, &fb_paddr);
92 lv1_gpu_context_allocate(fbhandle, 0, &fbcontext);
94 lv1_gpu_context_attribute(fbcontext,
95 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, 0, 0, 0);
96 lv1_gpu_context_attribute(fbcontext,
97 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0);
99 fb_vaddr = ps3mmu_mapdev(fb_paddr, FB_SIZE);
104 for (i = 0; i < fb_width*fb_height; i++)
105 fb_vaddr[i] = BG_COLOR;
111 ps3cons_putchar(int c)
134 /* Wrap long lines */
135 if (x + XMARGIN + FONT_SIZE > fb_width - XMARGIN) {
140 if (y + YMARGIN + FONT_SIZE > fb_height - YMARGIN)
143 addr = fb_vaddr + (y + YMARGIN)*fb_width + (x + XMARGIN);
144 p = FONT + c*FONT_SIZE;
146 for (i = 0; i < FONT_SIZE; i++) {
147 for (j = 0, k = 7; j < 8; j++, k--) {
148 if ((p[i] & (1 << k)) == 0)