Date: Sun, 4 Jul 2010 02:44:32 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r209681 - in user/nwhitehorn/ps3: boot/fdt/dts boot/powerpc/ps3 conf powerpc/aim powerpc/ps3 Message-ID: <201007040244.o642iWJM099391@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Sun Jul 4 02:44:32 2010 New Revision: 209681 URL: http://svn.freebsd.org/changeset/base/209681 Log: Provide syscons and platform modules for the PS3. This gets a console up, message from KDB, and the whole init sequence up until it tries to init the MMU, which does not work because of the hypervisor. That is pending. Simple hypervisor calls (e.g. determining the amount of non-hotplug memory) work at this point as well. Because of my abject and total failure to get FDT behaving, FDT-related platform detection code is under an #if 0 for now, and everything is keyed off of setting the loader tunable hw.platform=ps3. Added: user/nwhitehorn/ps3/boot/fdt/dts/ps3.dts user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c user/nwhitehorn/ps3/powerpc/ps3/ps3_syscons.c - copied, changed from r209627, user/nwhitehorn/ps3/powerpc/ofw/ofw_syscons.c Modified: user/nwhitehorn/ps3/boot/powerpc/ps3/Makefile user/nwhitehorn/ps3/conf/files user/nwhitehorn/ps3/conf/files.powerpc64 user/nwhitehorn/ps3/conf/options.powerpc64 user/nwhitehorn/ps3/powerpc/aim/ofw_machdep.c Added: user/nwhitehorn/ps3/boot/fdt/dts/ps3.dts ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/ps3/boot/fdt/dts/ps3.dts Sun Jul 4 02:44:32 2010 (r209681) @@ -0,0 +1,16 @@ +/* + * Sony PS3 flattened device tree + * + * $FreeBSD$ + */ + +/dts-v1/; + +/ { + model = "SonyPS3"; + compatible = "sony,ps3"; + #size-cells = <2>; + #address-cells = <2>; + + chosen {}; +}; Modified: user/nwhitehorn/ps3/boot/powerpc/ps3/Makefile ============================================================================== --- user/nwhitehorn/ps3/boot/powerpc/ps3/Makefile Sun Jul 4 02:42:01 2010 (r209680) +++ user/nwhitehorn/ps3/boot/powerpc/ps3/Makefile Sun Jul 4 02:44:32 2010 (r209681) @@ -21,6 +21,7 @@ LOADER_NET_SUPPORT?= yes LOADER_NFS_SUPPORT?= yes LOADER_TFTP_SUPPORT?= no LOADER_GZIP_SUPPORT?= yes +LOADER_FDT_SUPPORT?= yes LOADER_BZIP2_SUPPORT?= no .if ${LOADER_DISK_SUPPORT} == "yes" @@ -50,6 +51,13 @@ CFLAGS+= -DLOADER_NFS_SUPPORT .if ${LOADER_TFTP_SUPPORT} == "yes" CFLAGS+= -DLOADER_TFTP_SUPPORT .endif +.if ${LOADER_FDT_SUPPORT} == "yes" +CFLAGS+= -I${.CURDIR}/../../fdt +CFLAGS+= -I${.OBJDIR}/../../fdt +CFLAGS+= -DLOADER_FDT_SUPPORT +LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a +.endif + .if ${MK_FORTH} != "no" # Enable BootForth Modified: user/nwhitehorn/ps3/conf/files ============================================================================== --- user/nwhitehorn/ps3/conf/files Sun Jul 4 02:42:01 2010 (r209680) +++ user/nwhitehorn/ps3/conf/files Sun Jul 4 02:44:32 2010 (r209681) @@ -980,11 +980,7 @@ dev/ex/if_ex_pccard.c optional ex pccar dev/exca/exca.c optional cbb dev/fatm/if_fatm.c optional fatm pci dev/fb/splash.c optional splash -dev/fdt/fdt_common.c optional fdt -dev/fdt/fdt_pci.c optional fdt pci dev/fdt/fdt_static_dtb.S optional fdt fdt_dtb_static -dev/fdt/fdtbus.c optional fdt -dev/fdt/simplebus.c optional fdt dev/fe/if_fe.c optional fe dev/fe/if_fe_pccard.c optional fe pccard dev/firewire/firewire.c optional firewire Modified: user/nwhitehorn/ps3/conf/files.powerpc64 ============================================================================== --- user/nwhitehorn/ps3/conf/files.powerpc64 Sun Jul 4 02:42:01 2010 (r209680) +++ user/nwhitehorn/ps3/conf/files.powerpc64 Sun Jul 4 02:44:32 2010 (r209681) @@ -34,6 +34,7 @@ dev/ofw/ofw_bus_subr.c optional aim dev/ofw/ofw_console.c optional aim dev/ofw/ofw_disk.c optional ofwd aim dev/ofw/ofw_iicbus.c optional iicbus aim +dev/ofw/ofw_fdt.c optional fdt dev/powermac_nvram/powermac_nvram.c optional powermac_nvram powermac dev/scc/scc_bfe_macio.c optional scc powermac dev/sound/macio/aoa.c optional snd_davbus | snd_ai2s powermac @@ -50,6 +51,7 @@ libkern/ffs.c standard libkern/ffsl.c standard libkern/fls.c standard libkern/flsl.c standard +libkern/memchr.c standard libkern/memmove.c standard libkern/memset.c standard powerpc/aim/clock.c optional aim @@ -135,6 +137,9 @@ powerpc/powerpc/suswintr.c standard powerpc/powerpc/syncicache.c standard powerpc/powerpc/sys_machdep.c standard powerpc/powerpc/uio_machdep.c standard +powerpc/ps3/platform_ps3.c optional ps3 +powerpc/ps3/ps3_syscons.c optional ps3 +powerpc/ps3/ps3-hvcall.S optional ps3 compat/freebsd32/freebsd32_ioctl.c optional compat_freebsd32 compat/freebsd32/freebsd32_misc.c optional compat_freebsd32 Modified: user/nwhitehorn/ps3/conf/options.powerpc64 ============================================================================== --- user/nwhitehorn/ps3/conf/options.powerpc64 Sun Jul 4 02:42:01 2010 (r209680) +++ user/nwhitehorn/ps3/conf/options.powerpc64 Sun Jul 4 02:44:32 2010 (r209681) @@ -4,7 +4,6 @@ AIM opt_global.h E500 opt_global.h CELL -MAMBO COMPAT_FREEBSD32 opt_compat.h @@ -12,7 +11,9 @@ GFB_DEBUG opt_gfb.h GFB_NO_FONT_LOADING opt_gfb.h GFB_NO_MODE_CHANGE opt_gfb.h +MAMBO opt_platform.h POWERMAC opt_platform.h +PS3 opt_platform.h SC_OFWFB opt_ofwfb.h Modified: user/nwhitehorn/ps3/powerpc/aim/ofw_machdep.c ============================================================================== --- user/nwhitehorn/ps3/powerpc/aim/ofw_machdep.c Sun Jul 4 02:42:01 2010 (r209680) +++ user/nwhitehorn/ps3/powerpc/aim/ofw_machdep.c Sun Jul 4 02:44:32 2010 (r209681) @@ -368,6 +368,7 @@ OF_bootstrap() */ ofw_quiesce(); } else { + ofw_real_mode = TRUE; status = OF_install(OFW_FDT, 0); if (status != TRUE) Added: user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c Sun Jul 4 02:44:32 2010 (r209681) @@ -0,0 +1,185 @@ +/*- + * 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 THE AUTHOR 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: user/nwhitehorn/ps3/powerpc/booke/platform_ps3.c 193492 2009-06-05 09:46:00Z raj $"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/bus.h> +#include <sys/pcpu.h> +#include <sys/proc.h> +#include <sys/reboot.h> +#include <sys/smp.h> + +#include <machine/bootinfo.h> +#include <machine/bus.h> +#include <machine/cpu.h> +#include <machine/hid.h> +#include <machine/platform.h> +#include <machine/platformvar.h> +#include <machine/smp.h> +#include <machine/spr.h> +#include <machine/vmparam.h> + +#include <dev/ofw/openfirm.h> + +#include "platform_if.h" +#include "ps3-hvcall.h" + +static int ps3_probe(platform_t); +static int ps3_attach(platform_t); +static void ps3_mem_regions(platform_t, struct mem_region **phys, int *physsz, + struct mem_region **avail, int *availsz); +static u_long ps3_timebase_freq(platform_t, struct cpuref *cpuref); +static int ps3_smp_first_cpu(platform_t, struct cpuref *cpuref); +static int ps3_smp_next_cpu(platform_t, struct cpuref *cpuref); +static int ps3_smp_get_bsp(platform_t, struct cpuref *cpuref); +static int ps3_smp_start_cpu(platform_t, struct pcpu *cpu); + +static platform_method_t ps3_methods[] = { + PLATFORMMETHOD(platform_probe, ps3_probe), + PLATFORMMETHOD(platform_attach, ps3_attach), + PLATFORMMETHOD(platform_mem_regions, ps3_mem_regions), + PLATFORMMETHOD(platform_timebase_freq, ps3_timebase_freq), + + PLATFORMMETHOD(platform_smp_first_cpu, ps3_smp_first_cpu), + PLATFORMMETHOD(platform_smp_next_cpu, ps3_smp_next_cpu), + PLATFORMMETHOD(platform_smp_get_bsp, ps3_smp_get_bsp), + PLATFORMMETHOD(platform_smp_start_cpu, ps3_smp_start_cpu), + + { 0, 0 } +}; + +static platform_def_t ps3_platform = { + "ps3", + ps3_methods, + 0 +}; + +PLATFORM_DEF(ps3_platform); + +static int +ps3_probe(platform_t plat) +{ +#if 0 + phandle_t root; + char compatible[64]; + + root = OF_finddevice("/"); + + if (OF_getprop(root, "compatible", compatible, sizeof(compatible)) <= 0) + return (ENXIO); + + if (strncmp(compatible, "sony,ps3", sizeof(compatible)) == 0) + return (BUS_PROBE_SPECIFIC); + + return (ENXIO); +#else + return (BUS_PROBE_NOWILDCARD); +#endif +} + +static int +ps3_attach(platform_t plat) +{ + boothowto |= RB_VERBOSE; + + return (0); +} + +#define MEM_REGIONS 8 +static struct mem_region avail_regions[MEM_REGIONS]; + +void +ps3_mem_regions(platform_t plat, struct mem_region **phys, int *physsz, + struct mem_region **avail, int *availsz) +{ + uint64_t lpar_id, junk, ppe_id; + + avail_regions[0].mr_start = 0; + lv1_get_logical_partition_id(&lpar_id); + lv1_get_logical_ppe_id(&ppe_id); + lv1_get_repository_node_value(lpar_id, + lv1_repository_string("bi") >> 32, lv1_repository_string("pu"), + ppe_id, lv1_repository_string("rm_size"), + &avail_regions[0].mr_size, &junk); + + *phys = *avail = avail_regions; + *physsz = *availsz = 1; +} + +static u_long +ps3_timebase_freq(platform_t plat, struct cpuref *cpuref) +{ + uint64_t ticks, node_id, junk; + uint64_t lpar_id; + + lv1_get_logical_partition_id(&lpar_id); + lv1_get_repository_node_value(lpar_id, PS3_LPAR_ID_PME, + lv1_repository_string("be") >> 32, 0, 0, &node_id, &junk); + lv1_get_repository_node_value(lpar_id, PS3_LPAR_ID_PME, + lv1_repository_string("be") >> 32, node_id, + lv1_repository_string("clock"), &ticks, &junk); + + return (ticks); +} + +static int +ps3_smp_first_cpu(platform_t plat, struct cpuref *cpuref) +{ + + cpuref->cr_cpuid = 0; + cpuref->cr_hwref = cpuref->cr_cpuid; + + return (0); +} + +static int +ps3_smp_next_cpu(platform_t plat, struct cpuref *cpuref) +{ + + return (ENOENT); +} + +static int +ps3_smp_get_bsp(platform_t plat, struct cpuref *cpuref) +{ + + cpuref->cr_cpuid = 0; + cpuref->cr_hwref = cpuref->cr_cpuid; + + return (0); +} + +static int +ps3_smp_start_cpu(platform_t plat, struct pcpu *pc) +{ + + /* No SMP support */ + return (ENXIO); +} Copied and modified: user/nwhitehorn/ps3/powerpc/ps3/ps3_syscons.c (from r209627, user/nwhitehorn/ps3/powerpc/ofw/ofw_syscons.c) ============================================================================== --- user/nwhitehorn/ps3/powerpc/ofw/ofw_syscons.c Thu Jul 1 14:55:54 2010 (r209627, copy source) +++ user/nwhitehorn/ps3/powerpc/ps3/ps3_syscons.c Sun Jul 4 02:44:32 2010 (r209681) @@ -44,113 +44,110 @@ __FBSDID("$FreeBSD$"); #include <machine/bus.h> #include <machine/sc_machdep.h> +#include <machine/platform.h> #include <sys/rman.h> #include <dev/fb/fbreg.h> #include <dev/syscons/syscons.h> -#include <dev/ofw/openfirm.h> -#include <dev/ofw/ofw_bus.h> -#include <dev/ofw/ofw_pci.h> -#include <powerpc/ofw/ofw_syscons.h> - -static int ofwfb_ignore_mmap_checks = 1; -SYSCTL_NODE(_hw, OID_AUTO, ofwfb, CTLFLAG_RD, 0, "ofwfb"); -SYSCTL_INT(_hw_ofwfb, OID_AUTO, relax_mmap, CTLFLAG_RW, - &ofwfb_ignore_mmap_checks, 0, "relaxed mmap bounds checking"); - extern u_char dflt_font_16[]; extern u_char dflt_font_14[]; extern u_char dflt_font_8[]; -static int ofwfb_configure(int flags); +static int ps3fb_configure(int flags); + +static vi_probe_t ps3fb_probe; +static vi_init_t ps3fb_init; +static vi_get_info_t ps3fb_get_info; +static vi_query_mode_t ps3fb_query_mode; +static vi_set_mode_t ps3fb_set_mode; +static vi_save_font_t ps3fb_save_font; +static vi_load_font_t ps3fb_load_font; +static vi_show_font_t ps3fb_show_font; +static vi_save_palette_t ps3fb_save_palette; +static vi_load_palette_t ps3fb_load_palette; +static vi_set_border_t ps3fb_set_border; +static vi_save_state_t ps3fb_save_state; +static vi_load_state_t ps3fb_load_state; +static vi_set_win_org_t ps3fb_set_win_org; +static vi_read_hw_cursor_t ps3fb_read_hw_cursor; +static vi_set_hw_cursor_t ps3fb_set_hw_cursor; +static vi_set_hw_cursor_shape_t ps3fb_set_hw_cursor_shape; +static vi_blank_display_t ps3fb_blank_display; +static vi_mmap_t ps3fb_mmap; +static vi_ioctl_t ps3fb_ioctl; +static vi_clear_t ps3fb_clear; +static vi_fill_rect_t ps3fb_fill_rect; +static vi_bitblt_t ps3fb_bitblt; +static vi_diag_t ps3fb_diag; +static vi_save_cursor_palette_t ps3fb_save_cursor_palette; +static vi_load_cursor_palette_t ps3fb_load_cursor_palette; +static vi_copy_t ps3fb_copy; +static vi_putp_t ps3fb_putp; +static vi_putc_t ps3fb_putc; +static vi_puts_t ps3fb_puts; +static vi_putm_t ps3fb_putm; + +struct ps3fb_softc { + video_adapter_t sc_va; + struct cdev *sc_si; + int sc_console; + + intptr_t sc_addr; + int sc_height; + int sc_width; + int sc_stride; + int sc_ncol; + int sc_nrow; + + int sc_xmargin; + int sc_ymargin; -static vi_probe_t ofwfb_probe; -static vi_init_t ofwfb_init; -static vi_get_info_t ofwfb_get_info; -static vi_query_mode_t ofwfb_query_mode; -static vi_set_mode_t ofwfb_set_mode; -static vi_save_font_t ofwfb_save_font; -static vi_load_font_t ofwfb_load_font; -static vi_show_font_t ofwfb_show_font; -static vi_save_palette_t ofwfb_save_palette; -static vi_load_palette_t ofwfb_load_palette; -static vi_set_border_t ofwfb_set_border; -static vi_save_state_t ofwfb_save_state; -static vi_load_state_t ofwfb_load_state; -static vi_set_win_org_t ofwfb_set_win_org; -static vi_read_hw_cursor_t ofwfb_read_hw_cursor; -static vi_set_hw_cursor_t ofwfb_set_hw_cursor; -static vi_set_hw_cursor_shape_t ofwfb_set_hw_cursor_shape; -static vi_blank_display_t ofwfb_blank_display; -static vi_mmap_t ofwfb_mmap; -static vi_ioctl_t ofwfb_ioctl; -static vi_clear_t ofwfb_clear; -static vi_fill_rect_t ofwfb_fill_rect; -static vi_bitblt_t ofwfb_bitblt; -static vi_diag_t ofwfb_diag; -static vi_save_cursor_palette_t ofwfb_save_cursor_palette; -static vi_load_cursor_palette_t ofwfb_load_cursor_palette; -static vi_copy_t ofwfb_copy; -static vi_putp_t ofwfb_putp; -static vi_putc_t ofwfb_putc; -static vi_puts_t ofwfb_puts; -static vi_putm_t ofwfb_putm; - -static video_switch_t ofwfbvidsw = { - .probe = ofwfb_probe, - .init = ofwfb_init, - .get_info = ofwfb_get_info, - .query_mode = ofwfb_query_mode, - .set_mode = ofwfb_set_mode, - .save_font = ofwfb_save_font, - .load_font = ofwfb_load_font, - .show_font = ofwfb_show_font, - .save_palette = ofwfb_save_palette, - .load_palette = ofwfb_load_palette, - .set_border = ofwfb_set_border, - .save_state = ofwfb_save_state, - .load_state = ofwfb_load_state, - .set_win_org = ofwfb_set_win_org, - .read_hw_cursor = ofwfb_read_hw_cursor, - .set_hw_cursor = ofwfb_set_hw_cursor, - .set_hw_cursor_shape = ofwfb_set_hw_cursor_shape, - .blank_display = ofwfb_blank_display, - .mmap = ofwfb_mmap, - .ioctl = ofwfb_ioctl, - .clear = ofwfb_clear, - .fill_rect = ofwfb_fill_rect, - .bitblt = ofwfb_bitblt, - .diag = ofwfb_diag, - .save_cursor_palette = ofwfb_save_cursor_palette, - .load_cursor_palette = ofwfb_load_cursor_palette, - .copy = ofwfb_copy, - .putp = ofwfb_putp, - .putc = ofwfb_putc, - .puts = ofwfb_puts, - .putm = ofwfb_putm, + u_char *sc_font; + int sc_font_height; }; -/* - * bitmap depth-specific routines - */ -static vi_blank_display_t ofwfb_blank_display8; -static vi_putc_t ofwfb_putc8; -static vi_putm_t ofwfb_putm8; -static vi_set_border_t ofwfb_set_border8; - -static vi_blank_display_t ofwfb_blank_display32; -static vi_putc_t ofwfb_putc32; -static vi_putm_t ofwfb_putm32; -static vi_set_border_t ofwfb_set_border32; +static video_switch_t ps3fbvidsw = { + .probe = ps3fb_probe, + .init = ps3fb_init, + .get_info = ps3fb_get_info, + .query_mode = ps3fb_query_mode, + .set_mode = ps3fb_set_mode, + .save_font = ps3fb_save_font, + .load_font = ps3fb_load_font, + .show_font = ps3fb_show_font, + .save_palette = ps3fb_save_palette, + .load_palette = ps3fb_load_palette, + .set_border = ps3fb_set_border, + .save_state = ps3fb_save_state, + .load_state = ps3fb_load_state, + .set_win_org = ps3fb_set_win_org, + .read_hw_cursor = ps3fb_read_hw_cursor, + .set_hw_cursor = ps3fb_set_hw_cursor, + .set_hw_cursor_shape = ps3fb_set_hw_cursor_shape, + .blank_display = ps3fb_blank_display, + .mmap = ps3fb_mmap, + .ioctl = ps3fb_ioctl, + .clear = ps3fb_clear, + .fill_rect = ps3fb_fill_rect, + .bitblt = ps3fb_bitblt, + .diag = ps3fb_diag, + .save_cursor_palette = ps3fb_save_cursor_palette, + .load_cursor_palette = ps3fb_load_cursor_palette, + .copy = ps3fb_copy, + .putp = ps3fb_putp, + .putc = ps3fb_putc, + .puts = ps3fb_puts, + .putm = ps3fb_putm, +}; -VIDEO_DRIVER(ofwfb, ofwfbvidsw, ofwfb_configure); +VIDEO_DRIVER(ps3fb, ps3fbvidsw, ps3fb_configure); extern sc_rndr_sw_t txtrndrsw; -RENDERER(ofwfb, 0, txtrndrsw, gfb_set); +RENDERER(ps3fb, 0, txtrndrsw, gfb_set); -RENDERER_MODULE(ofwfb, gfb_set); +RENDERER_MODULE(ps3fb, gfb_set); /* * Define the iso6429-1983 colormap @@ -159,7 +156,7 @@ static struct { uint8_t red; uint8_t green; uint8_t blue; -} ofwfb_cmap[16] = { /* # R G B Color */ +} ps3fb_cmap[16] = { /* # R G B Color */ /* - - - - ----- */ { 0x00, 0x00, 0x00 }, /* 0 0 0 0 Black */ { 0x00, 0x00, 0xaa }, /* 1 0 0 2/3 Blue */ @@ -181,46 +178,44 @@ static struct { #define TODO printf("%s: unimplemented\n", __func__) -static u_int16_t ofwfb_static_window[ROW*COL]; +static u_int16_t ps3fb_static_window[ROW*COL]; -static struct ofwfb_softc ofwfb_softc; +static struct ps3fb_softc ps3fb_softc; static __inline int -ofwfb_background(uint8_t attr) +ps3fb_background(uint8_t attr) { return (attr >> 4); } static __inline int -ofwfb_foreground(uint8_t attr) +ps3fb_foreground(uint8_t attr) { return (attr & 0x0f); } static u_int -ofwfb_pix32(int attr) +ps3fb_pix32(int attr) { u_int retval; - retval = (ofwfb_cmap[attr].blue << 16) | - (ofwfb_cmap[attr].green << 8) | - ofwfb_cmap[attr].red; + retval = (ps3fb_cmap[attr].blue << 16) | + (ps3fb_cmap[attr].green << 8) | + ps3fb_cmap[attr].red; return (retval); } static int -ofwfb_configure(int flags) +ps3fb_configure(int flags) { - struct ofwfb_softc *sc; - phandle_t chosen; - ihandle_t stdout; - phandle_t node; - uint32_t fb_phys; - int depth; + struct ps3fb_softc *sc; + vm_offset_t fb_phys; int disable; - int len; - char type[16]; + char compatible[64]; +#if 0 + phandle_t root; +#endif static int done = 0; disable = 0; @@ -232,43 +227,27 @@ ofwfb_configure(int flags) return (0); done = 1; - sc = &ofwfb_softc; + sc = &ps3fb_softc; - chosen = OF_finddevice("/chosen"); - OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); - node = OF_instance_to_package(stdout); - if (node == -1) { - /* - * The "/chosen/stdout" does not exist try - * using "screen" directly. - */ - node = OF_finddevice("screen"); - } - OF_getprop(node, "device_type", type, sizeof(type)); - if (strcmp(type, "display") != 0) +#if 0 + root = OF_finddevice("/"); + if (OF_getprop(root, "compatible", compatible, sizeof(compatible)) <= 0) + return (0); + + if (strncmp(compatible, "sony,ps3", sizeof(compatible)) != 0) return (0); - - /* Only support 8 and 32-bit framebuffers */ - OF_getprop(node, "depth", &depth, sizeof(depth)); - if (depth == 8) { - sc->sc_blank = ofwfb_blank_display8; - sc->sc_putc = ofwfb_putc8; - sc->sc_putm = ofwfb_putm8; - sc->sc_set_border = ofwfb_set_border8; - } else if (depth == 32) { - sc->sc_blank = ofwfb_blank_display32; - sc->sc_putc = ofwfb_putc32; - sc->sc_putm = ofwfb_putm32; - sc->sc_set_border = ofwfb_set_border32; - } else +#else + TUNABLE_STR_FETCH("hw.platform", compatible, sizeof(compatible)); + if (strcmp(compatible, "ps3") != 0) return (0); +#endif - sc->sc_depth = depth; - sc->sc_node = node; sc->sc_console = 1; - OF_getprop(node, "height", &sc->sc_height, sizeof(sc->sc_height)); - OF_getprop(node, "width", &sc->sc_width, sizeof(sc->sc_width)); - OF_getprop(node, "linebytes", &sc->sc_stride, sizeof(sc->sc_stride)); + + /* XXX: get from HV repository */ + sc->sc_height = 480; + sc->sc_width = 720; + sc->sc_stride = sc->sc_width*4; /* * Grab the physical address of the framebuffer, and then map it @@ -277,51 +256,35 @@ ofwfb_configure(int flags) * * XXX We assume #address-cells is 1 at this point. */ - OF_getprop(node, "address", &fb_phys, sizeof(fb_phys)); + fb_phys = 0x10000000; bus_space_map(&bs_be_tag, fb_phys, sc->sc_height * sc->sc_stride, 0, &sc->sc_addr); - /* - * Get the PCI addresses of the adapter. The node may be the - * child of the PCI device: in that case, try the parent for - * the assigned-addresses property. - */ - len = OF_getprop(node, "assigned-addresses", sc->sc_pciaddrs, - sizeof(sc->sc_pciaddrs)); - if (len == -1) { - len = OF_getprop(OF_parent(node), "assigned-addresses", - sc->sc_pciaddrs, sizeof(sc->sc_pciaddrs)); - } - - if (len != -1) { - sc->sc_num_pciaddrs = len / sizeof(struct ofw_pci_register); - } - - ofwfb_init(0, &sc->sc_va, 0); + ps3fb_init(0, &sc->sc_va, 0); return (0); } static int -ofwfb_probe(int unit, video_adapter_t **adp, void *arg, int flags) +ps3fb_probe(int unit, video_adapter_t **adp, void *arg, int flags) { TODO; return (0); } static int -ofwfb_init(int unit, video_adapter_t *adp, int flags) +ps3fb_init(int unit, video_adapter_t *adp, int flags) { - struct ofwfb_softc *sc; + struct ps3fb_softc *sc; video_info_t *vi; - int cborder; + int cxborder, cyborder; int font_height; - sc = (struct ofwfb_softc *)adp; + sc = (struct ps3fb_softc *)adp; vi = &adp->va_info; - vid_init_struct(adp, "ofwfb", -1, unit); + vid_init_struct(adp, "ps3fb", -1, unit); /* The default font size can be overridden by loader */ font_height = 16; @@ -339,12 +302,14 @@ ofwfb_init(int unit, video_adapter_t *ad } /* The user can set a border in chars - default is 1 char width */ - cborder = 1; - TUNABLE_INT_FETCH("hw.syscons.border", &cborder); + cxborder = 8; + cyborder = 2; + TUNABLE_INT_FETCH("hw.syscons.xborder", &cxborder); + TUNABLE_INT_FETCH("hw.syscons.yborder", &cyborder); vi->vi_cheight = sc->sc_font_height; - vi->vi_width = sc->sc_width/8 - 2*cborder; - vi->vi_height = sc->sc_height/sc->sc_font_height - 2*cborder; + vi->vi_width = sc->sc_width/8 - 2*cxborder; + vi->vi_height = sc->sc_height/sc->sc_font_height - 2*cyborder; vi->vi_cwidth = 8; /* @@ -362,77 +327,52 @@ ofwfb_init(int unit, video_adapter_t *ad * Avoid huge amounts of conditional code in syscons by * defining a dummy h/w text display buffer. */ - adp->va_window = (vm_offset_t) ofwfb_static_window; + adp->va_window = (vm_offset_t) ps3fb_static_window; /* * Enable future font-loading and flag color support, as well as - * adding V_ADP_MODECHANGE so that we ofwfb_set_mode() gets called + * adding V_ADP_MODECHANGE so that we ps3fb_set_mode() gets called * when the X server shuts down. This enables us to get the console * back when X disappears. */ adp->va_flags |= V_ADP_FONT | V_ADP_COLOR | V_ADP_MODECHANGE; - ofwfb_set_mode(&sc->sc_va, 0); - + ps3fb_set_mode(&sc->sc_va, 0); vid_register(&sc->sc_va); return (0); } static int -ofwfb_get_info(video_adapter_t *adp, int mode, video_info_t *info) +ps3fb_get_info(video_adapter_t *adp, int mode, video_info_t *info) { bcopy(&adp->va_info, info, sizeof(*info)); return (0); } static int -ofwfb_query_mode(video_adapter_t *adp, video_info_t *info) +ps3fb_query_mode(video_adapter_t *adp, video_info_t *info) { TODO; return (0); } static int -ofwfb_set_mode(video_adapter_t *adp, int mode) +ps3fb_set_mode(video_adapter_t *adp, int mode) { - struct ofwfb_softc *sc; - char name[64]; - ihandle_t ih; - int i, retval; + struct ps3fb_softc *sc; - sc = (struct ofwfb_softc *)adp; + sc = (struct ps3fb_softc *)adp; - /* - * Open the display device, which will initialize it. - */ + /* XXX: no real mode setting at the moment */ - memset(name, 0, sizeof(name)); - OF_package_to_path(sc->sc_node, name, sizeof(name)); - ih = OF_open(name); - - if (sc->sc_depth == 8) { - /* - * Install the ISO6429 colormap - older OFW systems - * don't do this by default - */ - for (i = 0; i < 16; i++) { - OF_call_method("color!", ih, 4, 1, - ofwfb_cmap[i].red, - ofwfb_cmap[i].green, - ofwfb_cmap[i].blue, - i, - &retval); - } - } - - ofwfb_blank_display(&sc->sc_va, V_DISPLAY_ON); + ps3fb_blank_display(&sc->sc_va, V_DISPLAY_ON); return (0); } static int -ofwfb_save_font(video_adapter_t *adp, int page, int size, int width, +ps3fb_save_font(video_adapter_t *adp, int page, int size, int width, u_char *data, int c, int count) { TODO; @@ -440,12 +380,12 @@ ofwfb_save_font(video_adapter_t *adp, in } static int -ofwfb_load_font(video_adapter_t *adp, int page, int size, int width, +ps3fb_load_font(video_adapter_t *adp, int page, int size, int width, u_char *data, int c, int count) { - struct ofwfb_softc *sc; + struct ps3fb_softc *sc; - sc = (struct ofwfb_softc *)adp; + sc = (struct ps3fb_softc *)adp; /* * syscons code has already determined that current width/height @@ -456,109 +396,56 @@ ofwfb_load_font(video_adapter_t *adp, in } static int -ofwfb_show_font(video_adapter_t *adp, int page) +ps3fb_show_font(video_adapter_t *adp, int page) { return (0); } static int -ofwfb_save_palette(video_adapter_t *adp, u_char *palette) +ps3fb_save_palette(video_adapter_t *adp, u_char *palette) { /* TODO; */ return (0); } static int -ofwfb_load_palette(video_adapter_t *adp, u_char *palette) +ps3fb_load_palette(video_adapter_t *adp, u_char *palette) { /* TODO; */ return (0); } static int -ofwfb_set_border8(video_adapter_t *adp, int border) -{ - struct ofwfb_softc *sc; - int i, j; - uint8_t *addr; - uint8_t bground; - - sc = (struct ofwfb_softc *)adp; - - bground = ofwfb_background(border); - - /* Set top margin */ - addr = (uint8_t *) sc->sc_addr; - for (i = 0; i < sc->sc_ymargin; i++) { - for (j = 0; j < sc->sc_width; j++) { - *(addr + j) = bground; - } - addr += sc->sc_stride; - } - - /* bottom margin */ - addr = (uint8_t *) sc->sc_addr + (sc->sc_height - sc->sc_ymargin)*sc->sc_stride; - for (i = 0; i < sc->sc_ymargin; i++) { - for (j = 0; j < sc->sc_width; j++) { - *(addr + j) = bground; - } - addr += sc->sc_stride; - } - - /* remaining left and right borders */ - addr = (uint8_t *) sc->sc_addr + sc->sc_ymargin*sc->sc_stride; - for (i = 0; i < sc->sc_height - 2*sc->sc_xmargin; i++) { - for (j = 0; j < sc->sc_xmargin; j++) { - *(addr + j) = bground; - *(addr + j + sc->sc_width - sc->sc_xmargin) = bground; - } - addr += sc->sc_stride; - } - - return (0); -} - -static int -ofwfb_set_border32(video_adapter_t *adp, int border) +ps3fb_set_border(video_adapter_t *adp, int border) { /* XXX Be lazy for now and blank entire screen */ - return (ofwfb_blank_display32(adp, border)); + return (ps3fb_blank_display(adp, border)); } static int -ofwfb_set_border(video_adapter_t *adp, int border) -{ - struct ofwfb_softc *sc; - - sc = (struct ofwfb_softc *)adp; - - return ((*sc->sc_set_border)(adp, border)); -} - -static int -ofwfb_save_state(video_adapter_t *adp, void *p, size_t size) +ps3fb_save_state(video_adapter_t *adp, void *p, size_t size) { TODO; return (0); } static int -ofwfb_load_state(video_adapter_t *adp, void *p) +ps3fb_load_state(video_adapter_t *adp, void *p) { TODO; return (0); } static int -ofwfb_set_win_org(video_adapter_t *adp, off_t offset) +ps3fb_set_win_org(video_adapter_t *adp, off_t offset) { TODO; return (0); } static int -ofwfb_read_hw_cursor(video_adapter_t *adp, int *col, int *row) +ps3fb_read_hw_cursor(video_adapter_t *adp, int *col, int *row) { *col = 0; *row = 0; @@ -567,91 +454,42 @@ ofwfb_read_hw_cursor(video_adapter_t *ad } static int -ofwfb_set_hw_cursor(video_adapter_t *adp, int col, int row) +ps3fb_set_hw_cursor(video_adapter_t *adp, int col, int row) { return (0); } static int -ofwfb_set_hw_cursor_shape(video_adapter_t *adp, int base, int height, +ps3fb_set_hw_cursor_shape(video_adapter_t *adp, int base, int height, int celsize, int blink) { return (0); } static int -ofwfb_blank_display8(video_adapter_t *adp, int mode) +ps3fb_blank_display(video_adapter_t *adp, int mode) { - struct ofwfb_softc *sc; - int i; - uint8_t *addr; - - sc = (struct ofwfb_softc *)adp; - addr = (uint8_t *) sc->sc_addr; - - /* Could be done a lot faster e.g. 32-bits, or Altivec'd */ - for (i = 0; i < sc->sc_stride*sc->sc_height; i++) - *(addr + i) = ofwfb_background(SC_NORM_ATTR); - - return (0); -} - -static int -ofwfb_blank_display32(video_adapter_t *adp, int mode) -{ - struct ofwfb_softc *sc; + struct ps3fb_softc *sc; int i; uint32_t *addr; - sc = (struct ofwfb_softc *)adp; + sc = (struct ps3fb_softc *)adp; addr = (uint32_t *) sc->sc_addr; for (i = 0; i < (sc->sc_stride/4)*sc->sc_height; i++) - *(addr + i) = ofwfb_pix32(ofwfb_background(SC_NORM_ATTR)); + *(addr + i) = ps3fb_pix32(ps3fb_background(SC_NORM_ATTR)); return (0); } static int -ofwfb_blank_display(video_adapter_t *adp, int mode) -{ - struct ofwfb_softc *sc; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007040244.o642iWJM099391>