Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Jan 2011 04:12:30 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r217044 - in head/sys: boot/powerpc boot/powerpc/ps3 conf powerpc/conf powerpc/include powerpc/ps3
Message-ID:  <201101060412.p064CUrA001671@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Thu Jan  6 04:12:29 2011
New Revision: 217044
URL: http://svn.freebsd.org/changeset/base/217044

Log:
  Import support for the Sony Playstation 3 using the OtherOS feature
  available on firmwares 3.15 and earlier.
  
  Caveats: Support for the internal SATA controller is currently missing,
  as is support for framebuffer resolutions other than 720x480. These
  deficiencies will be remedied soon.
  
  Special thanks to Peter Grehan for providing the hardware that made this
  port possible, and thanks to Geoff Levand of Sony Computer Entertainment
  for advice on the LV1 hypervisor.

Added:
  head/sys/boot/powerpc/ps3/
  head/sys/boot/powerpc/ps3/Makefile   (contents, props changed)
  head/sys/boot/powerpc/ps3/conf.c   (contents, props changed)
  head/sys/boot/powerpc/ps3/devicename.c   (contents, props changed)
  head/sys/boot/powerpc/ps3/help.ps3   (contents, props changed)
  head/sys/boot/powerpc/ps3/ldscript.powerpc   (contents, props changed)
  head/sys/boot/powerpc/ps3/lv1call.S   (contents, props changed)
  head/sys/boot/powerpc/ps3/lv1call.h   (contents, props changed)
  head/sys/boot/powerpc/ps3/main.c   (contents, props changed)
  head/sys/boot/powerpc/ps3/metadata.c   (contents, props changed)
  head/sys/boot/powerpc/ps3/ppc64_elf_freebsd.c   (contents, props changed)
  head/sys/boot/powerpc/ps3/ps3.h   (contents, props changed)
  head/sys/boot/powerpc/ps3/ps3cons.c   (contents, props changed)
  head/sys/boot/powerpc/ps3/ps3mmu.c   (contents, props changed)
  head/sys/boot/powerpc/ps3/ps3net.c   (contents, props changed)
  head/sys/boot/powerpc/ps3/start.S   (contents, props changed)
  head/sys/boot/powerpc/ps3/version   (contents, props changed)
  head/sys/powerpc/ps3/
  head/sys/powerpc/ps3/ehci_ps3.c   (contents, props changed)
  head/sys/powerpc/ps3/if_glc.c   (contents, props changed)
  head/sys/powerpc/ps3/if_glcreg.h   (contents, props changed)
  head/sys/powerpc/ps3/mmu_ps3.c   (contents, props changed)
  head/sys/powerpc/ps3/platform_ps3.c   (contents, props changed)
  head/sys/powerpc/ps3/ps3-hv-asm.awk   (contents, props changed)
  head/sys/powerpc/ps3/ps3-hv-header.awk   (contents, props changed)
  head/sys/powerpc/ps3/ps3-hvcall.S   (contents, props changed)
  head/sys/powerpc/ps3/ps3-hvcall.h   (contents, props changed)
  head/sys/powerpc/ps3/ps3-hvcall.master   (contents, props changed)
  head/sys/powerpc/ps3/ps3_syscons.c   (contents, props changed)
  head/sys/powerpc/ps3/ps3bus.c   (contents, props changed)
  head/sys/powerpc/ps3/ps3bus.h   (contents, props changed)
  head/sys/powerpc/ps3/ps3pic.c   (contents, props changed)
Modified:
  head/sys/boot/powerpc/Makefile
  head/sys/conf/files.powerpc
  head/sys/conf/options.powerpc
  head/sys/powerpc/conf/GENERIC64
  head/sys/powerpc/conf/NOTES
  head/sys/powerpc/include/pte.h

Modified: head/sys/boot/powerpc/Makefile
==============================================================================
--- head/sys/boot/powerpc/Makefile	Thu Jan  6 04:05:25 2011	(r217043)
+++ head/sys/boot/powerpc/Makefile	Thu Jan  6 04:12:29 2011	(r217044)
@@ -1,5 +1,5 @@
 # $FreeBSD$
 
-SUBDIR=		boot1.chrp ofw uboot
+SUBDIR=		boot1.chrp ofw ps3 uboot
 
 .include <bsd.subdir.mk>

Added: head/sys/boot/powerpc/ps3/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/powerpc/ps3/Makefile	Thu Jan  6 04:12:29 2011	(r217044)
@@ -0,0 +1,122 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+MK_SSP=		no
+
+PROG=		loader.ps3
+NEWVERSWHAT=	"Playstation 3 loader" ${MACHINE_ARCH}
+BINDIR?=	/boot
+INSTALLFLAGS=	-b
+
+# Architecture-specific loader code
+SRCS=		start.S conf.c metadata.c vers.c main.c devicename.c ppc64_elf_freebsd.c
+SRCS+=		lv1call.S ps3cons.c font.h ps3mmu.c ps3net.c
+SRCS+=		ucmpdi2.c
+
+LOADER_DISK_SUPPORT?=	yes
+LOADER_UFS_SUPPORT?=	yes
+LOADER_CD9660_SUPPORT?=	yes
+LOADER_EXT2FS_SUPPORT?=	no
+LOADER_NET_SUPPORT?=	yes
+LOADER_NFS_SUPPORT?=	yes
+LOADER_TFTP_SUPPORT?=	no
+LOADER_GZIP_SUPPORT?=	yes
+LOADER_FDT_SUPPORT?=	no
+LOADER_BZIP2_SUPPORT?=	no
+
+.if ${LOADER_DISK_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_DISK_SUPPORT
+.endif
+.if ${LOADER_UFS_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_UFS_SUPPORT
+.endif
+.if ${LOADER_CD9660_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_CD9660_SUPPORT
+.endif
+.if ${LOADER_EXT2FS_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_EXT2FS_SUPPORT
+.endif
+.if ${LOADER_GZIP_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_GZIP_SUPPORT
+.endif
+.if ${LOADER_BZIP2_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_BZIP2_SUPPORT
+.endif
+.if ${LOADER_NET_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_NET_SUPPORT
+.endif
+.if ${LOADER_NFS_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_NFS_SUPPORT
+.endif
+.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
+BOOT_FORTH=	yes
+CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/powerpc
+LIBFICL=	${.OBJDIR}/../../ficl/libficl.a
+.endif
+
+# Avoid the open-close-dance for every file access as some firmwares perform
+# an auto-negotiation on every open of the network interface and thus causes
+# netbooting to take horribly long.
+CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE -mcpu=powerpc64
+
+# Always add MI sources
+.PATH:		${.CURDIR}/../../common ${.CURDIR}/../../../libkern
+.include	"${.CURDIR}/../../common/Makefile.inc"
+CFLAGS+=	-I${.CURDIR}/../../common -I${.CURDIR}/../../..
+CFLAGS+=	-I.
+
+CLEANFILES+=	vers.c loader.help
+
+CFLAGS+=	-Wall -ffreestanding -msoft-float -DAIM
+# load address. set in linker script
+RELOC?=		0x0
+CFLAGS+=	-DRELOC=${RELOC}
+
+LDFLAGS=	-nostdlib -static -T ${.CURDIR}/ldscript.powerpc
+
+# 64-bit bridge extensions
+CFLAGS+= -Wa,-mppc64bridge
+
+# Pull in common loader code
+#.PATH:		${.CURDIR}/../../ofw/common
+#.include	"${.CURDIR}/../../ofw/common/Makefile.inc"
+
+# where to get libstand from
+CFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
+
+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}
+
+loader.help: help.common help.ps3
+	cat ${.ALLSRC} | \
+	    awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
+
+.PATH: ${.CURDIR}/../../forth
+FILES=	loader.help loader.4th support.4th loader.conf
+FILESDIR_loader.conf=	/boot/defaults
+
+.if !exists(${DESTDIR}/boot/loader.rc)
+FILES+= loader.rc
+.endif
+
+.include <bsd.prog.mk>

Added: head/sys/boot/powerpc/ps3/conf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/powerpc/ps3/conf.c	Thu Jan  6 04:12:29 2011	(r217044)
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
+ * 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 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <stand.h>
+#include "bootstrap.h"
+
+#if defined(LOADER_NET_SUPPORT)
+#include "dev_net.h"
+#endif
+
+/*
+ * We could use linker sets for some or all of these, but
+ * then we would have to control what ended up linked into
+ * the bootstrap.  So it's easier to conditionalise things
+ * here.
+ *
+ * XXX rename these arrays to be consistent and less namespace-hostile
+ */
+
+/* Exported for libstand */
+struct devsw *devsw[] = {
+#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT)
+#ifdef NOTYET
+    &ps3disk,
+#endif
+#endif
+#if defined(LOADER_NET_SUPPORT)
+    &netdev,
+#endif
+    NULL
+};
+
+struct fs_ops *file_system[] = {
+#if defined(LOADER_UFS_SUPPORT)
+    &ufs_fsops,
+#endif
+#if defined(LOADER_CD9660_SUPPORT)
+    &cd9660_fsops,
+#endif
+#if defined(LOADER_EXT2FS_SUPPORT)
+    &ext2fs_fsops,
+#endif
+#if defined(LOADER_NFS_SUPPORT)
+    &nfs_fsops,
+#endif
+#if defined(LOADER_TFTP_SUPPORT)
+    &tftp_fsops,
+#endif
+#if defined(LOADER_GZIP_SUPPORT)
+    &gzipfs_fsops,
+#endif
+#if defined(LOADER_BZIP2_SUPPORT)
+    &bzipfs_fsops,
+#endif
+    NULL
+};
+
+extern struct netif_driver ps3net;
+
+struct netif_driver *netif_drivers[] = {
+#if defined(LOADER_NET_SUPPORT)
+	&ps3net,
+#endif
+	NULL,
+};
+
+/* Exported for PowerPC only */
+/* 
+ * Sort formats so that those that can detect based on arguments
+ * rather than reading the file go first.
+ */
+
+extern struct file_format ppc_elf64;
+
+struct file_format *file_formats[] = {
+    &ppc_elf64,
+    NULL
+};
+
+/* 
+ * Consoles 
+ */
+extern struct console ps3console;
+
+struct console *consoles[] = {
+    &ps3console,
+    NULL
+};
+
+/*
+ * reloc - our load address
+ */
+vm_offset_t	reloc = RELOC;

Added: head/sys/boot/powerpc/ps3/devicename.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/powerpc/ps3/devicename.c	Thu Jan  6 04:12:29 2011	(r217044)
@@ -0,0 +1,238 @@
+/*-
+ * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
+ * 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 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/disklabel.h>
+
+#include <stand.h>
+#include <string.h>
+
+#include "bootstrap.h"
+
+static int ps3_parsedev(struct devdesc **dev, const char *devspec,
+    const char **path);
+
+/*
+ * Point (dev) at an allocated device specifier for the device matching the
+ * path in (devspec). If it contains an explicit device specification,
+ * use that.  If not, use the default device.
+ */
+int
+ps3_getdev(void **vdev, const char *devspec, const char **path)
+{
+	struct devdesc **dev = (struct devdesc **)vdev;
+	int rv = 0;
+
+	/*
+	 * If it looks like this is just a path and no
+	 * device, go with the current device.
+	 */
+	if ((devspec == NULL) || (devspec[0] == '/') ||
+	    (strchr(devspec, ':') == NULL)) {
+		rv = ps3_parsedev(dev, getenv("currdev"), NULL);
+
+		if (rv == 0 && path != NULL)
+			*path = devspec;
+		return(rv);
+	}
+
+	/*
+	 * Try to parse the device name off the beginning of the devspec.
+	 */
+	return (ps3_parsedev(dev, devspec, path));
+}
+
+/*
+ * Point (dev) at an allocated device specifier matching the string version
+ * at the beginning of (devspec).  Return a pointer to the remaining
+ * text in (path).
+ *
+ * In all cases, the beginning of (devspec) is compared to the names
+ * of known devices in the device switch, and then any following text
+ * is parsed according to the rules applied to the device type.
+ *
+ * For disk-type devices, the syntax is:
+ *
+ * disk<unit>[<partition>]:
+ *
+ */
+static int
+ps3_parsedev(struct devdesc **dev, const char *devspec, const char **path)
+{
+	struct devdesc *idev;
+	struct devsw *dv;
+	char *cp;
+	const char *np;
+	int i, unit, pnum, ptype, err;
+
+	/* minimum length check */
+	if (strlen(devspec) < 2)
+		return(EINVAL);
+
+	/* look for a device that matches */
+	for (i = 0, dv = NULL; devsw[i] != NULL; i++) {
+		if (!strncmp(devspec, devsw[i]->dv_name,
+		    strlen(devsw[i]->dv_name))) {
+			dv = devsw[i];
+			break;
+		}
+	}
+	if (dv == NULL)
+		return(ENOENT);
+	idev = malloc(sizeof(struct devdesc));
+	err = 0;
+	np = (devspec + strlen(dv->dv_name));
+
+	switch(dv->dv_type) {
+	case DEVT_NONE:
+		break;
+
+#ifdef NOTYET
+	case DEVT_DISK:
+		unit = -1;
+		pnum = -1;
+		ptype = -1;
+		if (*np && (*np != ':')) {
+			/* next comes the unit number */
+			unit = strtol(np, &cp, 10);
+			if (cp == np) {
+				err = EUNIT;
+				goto fail;
+			}
+			if (*cp && (*cp != ':')) {
+				/* get partition */
+				if (*cp == 'p' && *(cp + 1) &&
+				    *(cp + 1) != ':') {
+					pnum = strtol(cp + 1, &cp, 10);
+					ptype = PTYPE_GPT;
+				} else {
+					pnum = *cp - 'a';
+					ptype = PTYPE_BSDLABEL;
+					if ((pnum < 0) ||
+					    (pnum >= MAXPARTITIONS)) {
+						err = EPART;
+						goto fail;
+					}
+					cp++;
+				}
+			}
+		}
+		if (*cp && (*cp != ':')) {
+			err = EINVAL;
+			goto fail;
+		}
+
+		idev->d_unit = unit;
+		idev->d_disk.pnum = pnum;
+		idev->d_disk.ptype = ptype;
+		idev->d_disk.data = NULL;
+		if (path != NULL)
+			*path = (*cp == 0) ? cp : cp + 1;
+		break;
+#endif
+
+	case DEVT_NET:
+		/*
+		 * PS3 only has one network interface (well, two, but
+		 * netbooting over wireless is not something I'm going
+		 * to worry about.
+		 */
+
+		idev->d_unit = 0;
+		break;
+
+	default:
+		err = EINVAL;
+		goto fail;
+	}
+	idev->d_dev = dv;
+	idev->d_type = dv->dv_type;
+	if (dev == NULL) {
+		free(idev);
+	} else {
+		*dev = idev;
+	}
+	return (0);
+
+fail:
+	free(idev);
+	return (err);
+}
+
+
+char *
+ps3_fmtdev(void *vdev)
+{
+	struct devdesc *dev = (struct devdesc *)vdev;
+	char *cp;
+	static char buf[128];
+
+	switch(dev->d_type) {
+	case DEVT_NONE:
+		strcpy(buf, "(no device)");
+		break;
+
+#ifdef NOTYET
+	case DEVT_DISK:
+		cp = buf;
+		cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit);
+		if (dev->d_kind.disk.pnum >= 0) {
+			if (dev->d_kind.disk.ptype == PTYPE_BSDLABEL)
+				cp += sprintf(cp, "%c",
+				    dev->d_kind.disk.pnum + 'a');
+			else if (dev->d_kind.disk.ptype == PTYPE_GPT)
+				cp += sprintf(cp, "p%i",
+				    dev->d_kind.disk.pnum);
+		}
+
+		strcat(cp, ":");
+		break;
+#endif
+
+	case DEVT_NET:
+		sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
+		break;
+	}
+	return(buf);
+}
+
+/*
+ * Set currdev to suit the value being supplied in (value).
+ */
+int
+ps3_setcurrdev(struct env_var *ev, int flags, const void *value)
+{
+	struct devdesc *ncurr;
+	int rv;
+
+	if ((rv = ps3_parsedev(&ncurr, value, NULL)) != 0)
+		return (rv);
+	free(ncurr);
+	env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
+	return (0);
+}

Added: head/sys/boot/powerpc/ps3/help.ps3
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/powerpc/ps3/help.ps3	Thu Jan  6 04:12:29 2011	(r217044)
@@ -0,0 +1 @@
+$FreeBSD$

Added: head/sys/boot/powerpc/ps3/ldscript.powerpc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/powerpc/ps3/ldscript.powerpc	Thu Jan  6 04:12:29 2011	(r217044)
@@ -0,0 +1,112 @@
+/* $FreeBSD$ */
+
+OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
+OUTPUT_ARCH(powerpc:common)
+ENTRY(_start)
+SEARCH_DIR(/usr/lib);
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+PROVIDE (__stack = 0);
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  . = 0x0;
+  .text      :
+  {
+    *(.text)
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+    *(.gnu.linkonce.t*)
+  } =0
+  _etext = .;
+  .interp     : { *(.interp) 	}
+  .hash          : { *(.hash)		}
+  .dynsym        : { *(.dynsym)		}
+  .dynstr        : { *(.dynstr)		}
+  .gnu.version   : { *(.gnu.version)	}
+  .gnu.version_d   : { *(.gnu.version_d)	}
+  .gnu.version_r   : { *(.gnu.version_r)	}
+  .rela.text     :
+    { *(.rela.text) *(.rela.gnu.linkonce.t*) }
+  .rela.data     :
+    { *(.rela.data) *(.rela.gnu.linkonce.d*) }
+  .rela.rodata   :
+    { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
+  .rela.got      : { *(.rela.got)		}
+  .rela.got1     : { *(.rela.got1)		}
+  .rela.got2     : { *(.rela.got2)		}
+  .rela.ctors    : { *(.rela.ctors)	}
+  .rela.dtors    : { *(.rela.dtors)	}
+  .rela.init     : { *(.rela.init)	}
+  .rela.fini     : { *(.rela.fini)	}
+  .rela.bss      : { *(.rela.bss)		}
+  .rela.plt      : { *(.rela.plt)		}
+  .rela.sbss     : { *(.rela.sbss)		}
+  .rela.sbss2    : { *(.rela.sbss2)		}
+  .text      :
+  {
+    *(.text)
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+    *(.gnu.linkonce.t*)
+  } =0
+  _etext = .;
+  PROVIDE (etext = .);
+  .init      : { *(.init)    } =0
+  .fini      : { *(.fini)    } =0
+  .rodata    : { *(.rodata) *(.gnu.linkonce.r*) }
+  .rodata1   : { *(.rodata1) }
+  .sbss2     : { *(.sbss2)   }
+  /* Adjust the address for the data segment to the next page up. */
+  . = ((. + 0x1000) & ~(0x1000 - 1));
+  .data    :
+  {
+    *(.data)
+    *(.gnu.linkonce.d*)
+    CONSTRUCTORS
+  }
+  .data1   : { *(.data1) }
+  .got1           : { *(.got1) }
+  .dynamic        : { *(.dynamic) }
+  /* Put .ctors and .dtors next to the .got2 section, so that the pointers
+     get relocated with -mrelocatable. Also put in the .fixup pointers.
+     The current compiler no longer needs this, but keep it around for 2.7.2  */
+                PROVIDE (_GOT2_START_ = .);
+  .got2           :  { *(.got2) }
+                PROVIDE (__CTOR_LIST__ = .);
+  .ctors          : { *(.ctors) }
+                PROVIDE (__CTOR_END__ = .);
+                PROVIDE (__DTOR_LIST__ = .);
+  .dtors          : { *(.dtors) }
+                PROVIDE (__DTOR_END__ = .);
+                PROVIDE (_FIXUP_START_ = .);
+  .fixup          : { *(.fixup) }
+                PROVIDE (_FIXUP_END_ = .);
+                PROVIDE (_GOT2_END_ = .);
+                PROVIDE (_GOT_START_ = .);
+  .got            : { *(.got) }
+  .got.plt        : { *(.got.plt) }
+                PROVIDE (_GOT_END_ = .);
+  _edata  =  .;
+  PROVIDE (edata = .);
+  .sbss      :
+  {
+    PROVIDE (__sbss_start = .);
+    *(.sbss)
+    *(.scommon)
+    *(.dynsbss)
+    PROVIDE (__sbss_end = .);
+  }
+  .plt   : { *(.plt) }
+  .bss       :
+  {
+   PROVIDE (__bss_start = .);
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+  }
+  . = ALIGN(4096);
+  _end = . ;
+  PROVIDE (end = .);
+}
+

Added: head/sys/boot/powerpc/ps3/lv1call.S
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/powerpc/ps3/lv1call.S	Thu Jan  6 04:12:29 2011	(r217044)
@@ -0,0 +1,256 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+/* Hypercall stubs. Note: this is all a hack and should die. */
+
+#define	hc	.long   0x44000022
+
+#define LD64_IM(r, highest, higher, high, low) \
+	lis	r,highest; \
+	addi	r,r,higher; \
+	sldi	r,r,32; \
+	addis	r,r,high; \
+	addi	r,r,low;
+
+#define SIMPLE_HVCALL(x, c) \
+.global x;			\
+x:				\
+	mflr	%r0;		\
+	stw	%r0,4(%r1);	\
+	clrldi	%r3,%r3,32;	\
+	clrldi	%r4,%r4,32;	\
+	clrldi	%r5,%r5,32;	\
+	clrldi	%r6,%r6,32;	\
+	clrldi	%r7,%r7,32;	\
+	clrldi	%r8,%r8,32;	\
+	clrldi	%r9,%r9,32;	\
+	clrldi	%r10,%r10,32;	\
+	li	%r11,c;		\
+	hc;			\
+	extsw	%r3,%r3;	\
+	lwz	%r0,4(%r1);	\
+	mtlr	%r0;		\
+	blr
+
+SIMPLE_HVCALL(lv1_open_device, 170)
+SIMPLE_HVCALL(lv1_close_device, 171)
+SIMPLE_HVCALL(lv1_gpu_open, 210)
+SIMPLE_HVCALL(lv1_gpu_context_attribute, 225)
+SIMPLE_HVCALL(lv1_panic, 255)
+SIMPLE_HVCALL(lv1_net_start_tx_dma, 187)
+SIMPLE_HVCALL(lv1_net_stop_tx_dma, 188)
+SIMPLE_HVCALL(lv1_net_start_rx_dma, 189)
+SIMPLE_HVCALL(lv1_net_stop_rx_dma, 190)
+
+.global lv1_get_physmem
+lv1_get_physmem:
+	mflr	%r0
+	stw	%r0,4(%r1)
+	stw	%r3,-8(%r1)	/* Address for maxmem */
+
+	li	%r11,69		/* Get PU ID */
+	hc
+	std	%r4,-16(%r1)
+
+	li	%r11,74		/* Get LPAR ID */
+	hc
+	std	%r4,-24(%r1)
+
+	ld	%r3,-24(%r1)
+	LD64_IM(%r4,0x0000,0x0000,0x6269,0x0000 /* "bi" */)
+	LD64_IM(%r5,0x7075,0x0000,0x0000,0x0000 /* "pu" */)
+	ld	%r6,-16(%r1)
+	LD64_IM(%r7,0x726d,0x5f73,0x697a,0x6500 /* "rm_size" */)
+	li	%r11,91
+	hc
+	extsw	%r3,%r3
+
+	lwz	%r5,-8(%r1)
+	std	%r4,0(%r5)
+
+	lwz	%r0,4(%r1)
+	mtlr	%r0
+	blr
+
+.global lv1_setup_address_space
+lv1_setup_address_space:
+	mflr	%r0
+	stw	%r0,4(%r1)
+
+	stw	%r3,-4(%r1)
+	stw	%r4,-8(%r1)
+
+	li	%r3,18		/* PT size: log2(256 KB) */
+	li	%r4,2		/* Two page sizes */
+	li	%r5,24		/* Page sizes: (24 << 56) | (16 << 48) */
+	sldi	%r5,%r5,24
+	li	%r6,16
+	sldi	%r6,%r6,16
+	or	%r5,%r5,%r6
+	sldi	%r5,%r5,32
+
+	li	%r11,2		/* lv1_construct_virtual_address_space */
+	hc
+
+	lwz	%r6,-4(%r1)
+	lwz	%r7,-8(%r1)
+	std	%r4,0(%r6)
+	std	%r5,0(%r7)
+
+	/* AS_ID in r4 */
+	mr	%r3,%r4
+	li	%r11,7		/* lv1_select_virtual_address_space */
+	hc
+	extsw	%r3,%r3
+
+	lwz	%r0,4(%r1)
+	mtlr	%r0
+	blr
+
+.global lv1_insert_pte
+lv1_insert_pte:
+	mflr	%r0
+	stw	%r0,4(%r1)
+
+	mr	%r11,%r4	/* Save R4 */
+
+	clrldi	%r3,%r3,32
+	clrldi	%r7,%r5,32
+
+	sldi	%r4,%r3,3	/* Convert ptegidx into base PTE slot */
+	li	%r3,0		/* Current address space */
+	ld	%r5,0(%r11)
+	ld	%r6,8(%r11)
+	li	%r8,0		/* No other flags */
+	
+	li	%r11,158
+	hc
+	extsw	%r3,%r3
+
+	lwz	%r0,4(%r1)
+	mtlr	%r0
+	blr
+
+.global lv1_gpu_context_allocate
+lv1_gpu_context_allocate:
+	mflr	%r0
+	stw	%r0,4(%r1)
+	stw	%r7,-4(%r1)
+
+	sldi	%r3,%r3,32
+	clrldi	%r4,%r4,32
+	ori	%r3,%r3,%r4
+	clrldi	%r4,%r5,32
+	clrldi	%r5,%r6,32
+
+	li	%r11,217
+	hc
+	extsw	%r3,%r3
+
+	lwz	%r7,-4(%r1)
+	std	%r4,0(%r7)
+
+	lwz	%r0,4(%r1)
+	mtlr	%r0
+	blr
+	
+.global lv1_gpu_memory_allocate
+lv1_gpu_memory_allocate:
+	mflr	%r0
+	stw	%r0,4(%r1)
+	stw	%r8,-4(%r1)
+	stw	%r9,-8(%r1)
+
+	li	%r11,214
+	hc
+	extsw	%r3,%r3
+
+	lwz	%r8,-4(%r1)
+	lwz	%r9,-8(%r1)
+	std	%r4,0(%r8)
+	std	%r5,0(%r9)
+
+	lwz	%r0,4(%r1)
+	mtlr	%r0
+	blr
+
+.global lv1_net_control
+lv1_net_control:
+	mflr	%r0
+	stw	%r0,4(%r1)
+	stw	%r9,-4(%r1)
+
+	li	%r11,194
+	hc
+	extsw	%r3,%r3
+
+	lwz	%r8,-4(%r1)
+	std	%r4,0(%r8)
+
+	lwz	%r0,4(%r1)
+	mtlr	%r0
+	blr
+
+.global lv1_setup_dma
+lv1_setup_dma:
+	mflr	%r0
+	stw	%r0,4(%r1)
+	stw	%r3,-4(%r1)
+	stw	%r4,-8(%r1)
+	stw	%r5,-12(%r1)
+
+	lwz	%r3,-4(%r1)
+	lwz	%r4,-8(%r1)
+	lis	%r5,0x0800	/* 128 MB */
+	li	%r6,24		/* log2(IO_PAGESIZE) */
+	li	%r7,0		/* flags */
+	li	%r11,174	/* lv1_allocate_device_dma_region */
+	hc
+	extsw	%r3,%r3
+	cmpdi	%r3,0
+	bne	1f
+	std	%r4,-24(%r1)
+
+	lwz	%r3,-4(%r1)
+	lwz	%r4,-8(%r1)
+	li	%r5,0
+	ld	%r6,-24(%r1)
+	lis	%r7,0x0800	/* 128 MB */
+	lis	%r8,0xf800	/* flags */
+	sldi	%r8,%r8,32
+	li	%r11,176	/* lv1_map_device_dma_region */
+	hc
+	extsw	%r3,%r3
+
+	lwz	%r9,-12(%r1)
+	ld	%r6,-24(%r1)
+	std	%r6,0(%r9)
+
+1:	lwz	%r0,4(%r1)
+	mtlr	%r0
+	blr
+

Added: head/sys/boot/powerpc/ps3/lv1call.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/powerpc/ps3/lv1call.h	Thu Jan  6 04:12:29 2011	(r217044)
@@ -0,0 +1,72 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _PS3_LV1CALL_H
+#define _PS3_LV1CALL_H
+
+#include <machine/pte.h>
+
+int lv1_get_physmem(uint64_t *maxmem);
+int lv1_setup_address_space(uint64_t *as_id, uint64_t *ptsize);
+int lv1_insert_pte(u_int ptegidx, struct lpte *pte, int lockflags);
+int lv1_panic(int reboot);
+
+#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET	0x0100
+#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC		0x0101
+#define  L1GPU_DISPLAY_SYNC_HSYNC			1
+#define  L1GPU_DISPLAY_SYNC_VSYNC			2
+#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP		0x0102
+
+int lv1_gpu_open(int);
+int lv1_gpu_context_attribute(int context, int op, int, int, int, int);
+int lv1_gpu_memory_allocate(int size, int, int, int, int, uint64_t *handle,
+	uint64_t *paddr);
+int lv1_gpu_context_allocate(uint64_t handle, int, uint64_t *context);
+
+int lv1_open_device(int, int, int /* 0 */);
+int lv1_close_device(int, int);
+int lv1_setup_dma(int, int, uint64_t *dmabase);
+
+#define GELIC_GET_MAC_ADDRESS	0x0001
+#define GELIC_GET_LINK_STATUS	0x0002
+#define  GELIC_LINK_UP		0x0001
+#define  GELIC_FULL_DUPLEX	0x0002
+#define  GELIC_AUTO_NEG		0x0004
+#define  GELIC_SPEED_10		0x0010
+#define  GELIC_SPEED_100	0x0020
+#define  GELIC_SPEED_1000	0x0040
+#define GELIC_GET_VLAN_ID	0x0004
+
+int lv1_net_init(int bus, int dev);
+int lv1_net_control(int bus, int dev, int, int, int, int, uint64_t *);
+int lv1_net_start_tx_dma(int bus, int dev, uint32_t addr, int);
+int lv1_net_start_rx_dma(int bus, int dev, uint32_t addr, int);
+int lv1_net_stop_tx_dma(int bus, int dev, int);
+int lv1_net_stop_rx_dma(int bus, int dev, int);
+
+#endif
+

Added: head/sys/boot/powerpc/ps3/main.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/powerpc/ps3/main.c	Thu Jan  6 04:12:29 2011	(r217044)
@@ -0,0 +1,211 @@
+/*-
+ * 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$");
+
+#include <stand.h>
+#include <sys/param.h>
+
+#define _KERNEL
+#include <machine/cpufunc.h>
+
+#include "bootstrap.h"
+#include "lv1call.h"
+#include "ps3.h"
+
+struct arch_switch	archsw;
+extern void *_end;
+
+extern char bootprog_name[];
+extern char bootprog_rev[];
+extern char bootprog_date[];
+extern char bootprog_maker[];
+
+int ps3_getdev(void **vdev, const char *devspec, const char **path);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101060412.p064CUrA001671>