ia64/xen-unstable

changeset 17617:b0d7780794eb

Remove defunct powerpc port.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 08 13:40:40 2008 +0100 (2008-05-08)
parents 0ac957f9d42e
children 8bd776540ab3
files Config.mk config/powerpc64.mk tools/libxc/Makefile tools/libxc/powerpc64/Makefile tools/libxc/powerpc64/flatdevtree.c tools/libxc/powerpc64/flatdevtree.h tools/libxc/powerpc64/flatdevtree_env.h tools/libxc/powerpc64/mk_flatdevtree.c tools/libxc/powerpc64/mk_flatdevtree.h tools/libxc/powerpc64/xc_memory.c tools/libxc/xc_core.h tools/libxc/xc_core_powerpc.c tools/libxc/xc_core_powerpc.h tools/libxc/xc_dom_elfloader.c tools/libxc/xc_dom_powerpc.c tools/libxc/xenctrl.h tools/libxc/xenguest.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/arch.py tools/python/xen/xend/image.py tools/xm-test/lib/XmTestLib/arch.py tools/xm-test/lib/XmTestReport/arch.py tools/xm-test/ramdisk/Makefile.am tools/xm-test/ramdisk/configs/buildroot-powerpc tools/xm-test/ramdisk/make-release.sh tools/xm-test/runtest.sh xen/Rules.mk xen/arch/powerpc/0opt.c xen/arch/powerpc/Makefile xen/arch/powerpc/Rules.mk xen/arch/powerpc/audit.c xen/arch/powerpc/backtrace.c xen/arch/powerpc/bitops.c xen/arch/powerpc/boot_of.c xen/arch/powerpc/cmdline.c xen/arch/powerpc/crash.c xen/arch/powerpc/dart.c xen/arch/powerpc/dart.h xen/arch/powerpc/dart_u3.c xen/arch/powerpc/dart_u4.c xen/arch/powerpc/domain.c xen/arch/powerpc/domain_build.c xen/arch/powerpc/domctl.c xen/arch/powerpc/exceptions.c xen/arch/powerpc/exceptions.h xen/arch/powerpc/external.c xen/arch/powerpc/float.S xen/arch/powerpc/gdbstub.c xen/arch/powerpc/hcalls.c xen/arch/powerpc/iommu.c xen/arch/powerpc/iommu.h xen/arch/powerpc/irq.c xen/arch/powerpc/machine_kexec.c xen/arch/powerpc/memory.c xen/arch/powerpc/mm.c xen/arch/powerpc/mpic.c xen/arch/powerpc/mpic_init.c xen/arch/powerpc/mpic_init.h xen/arch/powerpc/multiboot2.c xen/arch/powerpc/numa.c xen/arch/powerpc/of-devtree.c xen/arch/powerpc/of-devtree.h xen/arch/powerpc/of-devwalk.c xen/arch/powerpc/of_handler/Makefile xen/arch/powerpc/of_handler/console.c xen/arch/powerpc/of_handler/control.c xen/arch/powerpc/of_handler/cpu.c xen/arch/powerpc/of_handler/devtree.c xen/arch/powerpc/of_handler/head.S xen/arch/powerpc/of_handler/io.c xen/arch/powerpc/of_handler/leap.S xen/arch/powerpc/of_handler/memcmp.c xen/arch/powerpc/of_handler/memory.c xen/arch/powerpc/of_handler/memset.c xen/arch/powerpc/of_handler/ofh.c xen/arch/powerpc/of_handler/ofh.h xen/arch/powerpc/of_handler/papr.S xen/arch/powerpc/of_handler/papr.h xen/arch/powerpc/of_handler/rtas.c xen/arch/powerpc/of_handler/services.c xen/arch/powerpc/of_handler/snprintf.c xen/arch/powerpc/of_handler/strcmp.c xen/arch/powerpc/of_handler/strlcpy.c xen/arch/powerpc/of_handler/strlen.c xen/arch/powerpc/of_handler/strncmp.c xen/arch/powerpc/of_handler/strnlen.c xen/arch/powerpc/of_handler/vdevice.c xen/arch/powerpc/of_handler/xen_hvcall.S xen/arch/powerpc/of_handler/xencomm.c xen/arch/powerpc/ofd_fixup.c xen/arch/powerpc/ofd_fixup_memory.c xen/arch/powerpc/oftree.h xen/arch/powerpc/papr/Makefile xen/arch/powerpc/papr/debug.c xen/arch/powerpc/papr/h_perfmon.c xen/arch/powerpc/papr/tce.c xen/arch/powerpc/papr/vtce.c xen/arch/powerpc/papr/vterm.c xen/arch/powerpc/papr/xlate.c xen/arch/powerpc/physdev.c xen/arch/powerpc/platform.c xen/arch/powerpc/powerpc64/Makefile xen/arch/powerpc/powerpc64/asm-offsets.c xen/arch/powerpc/powerpc64/domain.c xen/arch/powerpc/powerpc64/exceptions.S xen/arch/powerpc/powerpc64/hypercall_table.S xen/arch/powerpc/powerpc64/io.S xen/arch/powerpc/powerpc64/memcpy.S xen/arch/powerpc/powerpc64/ppc970.c xen/arch/powerpc/powerpc64/ppc970_machinecheck.c xen/arch/powerpc/powerpc64/ppc970_scom.c xen/arch/powerpc/powerpc64/prom_call.S xen/arch/powerpc/powerpc64/scom.h xen/arch/powerpc/powerpc64/string.S xen/arch/powerpc/powerpc64/traps.c xen/arch/powerpc/ppc32/prom_call.c xen/arch/powerpc/rtas.c xen/arch/powerpc/rtas.h xen/arch/powerpc/rtas_flash.c xen/arch/powerpc/rtas_nvram.c xen/arch/powerpc/setup.c xen/arch/powerpc/shadow.c xen/arch/powerpc/smp-tbsync.c xen/arch/powerpc/smp.c xen/arch/powerpc/smpboot.c xen/arch/powerpc/start.S xen/arch/powerpc/sysctl.c xen/arch/powerpc/systemsim.S xen/arch/powerpc/tce.h xen/arch/powerpc/time.c xen/arch/powerpc/usercopy.c xen/arch/powerpc/xen.lds.S xen/include/asm-powerpc/acpi.h xen/include/asm-powerpc/asm_defns.h xen/include/asm-powerpc/atomic.h xen/include/asm-powerpc/bitops.h xen/include/asm-powerpc/boot.h xen/include/asm-powerpc/bug.h xen/include/asm-powerpc/byteorder.h xen/include/asm-powerpc/cache.h xen/include/asm-powerpc/config.h xen/include/asm-powerpc/current.h xen/include/asm-powerpc/debugger.h xen/include/asm-powerpc/delay.h xen/include/asm-powerpc/desc.h xen/include/asm-powerpc/div64.h xen/include/asm-powerpc/domain.h xen/include/asm-powerpc/elf.h xen/include/asm-powerpc/event.h xen/include/asm-powerpc/flushtlb.h xen/include/asm-powerpc/grant_table.h xen/include/asm-powerpc/guest_access.h xen/include/asm-powerpc/hardirq.h xen/include/asm-powerpc/hcalls.h xen/include/asm-powerpc/htab.h xen/include/asm-powerpc/hypercall.h xen/include/asm-powerpc/init.h xen/include/asm-powerpc/io.h xen/include/asm-powerpc/iocap.h xen/include/asm-powerpc/irq.h xen/include/asm-powerpc/mach-default/irq_vectors.h xen/include/asm-powerpc/memory.h xen/include/asm-powerpc/mm.h xen/include/asm-powerpc/mpic.h xen/include/asm-powerpc/msr.h xen/include/asm-powerpc/multicall.h xen/include/asm-powerpc/nmi.h xen/include/asm-powerpc/numa.h xen/include/asm-powerpc/page.h xen/include/asm-powerpc/papr.h xen/include/asm-powerpc/pci.h xen/include/asm-powerpc/percpu.h xen/include/asm-powerpc/perfc.h xen/include/asm-powerpc/platform.h xen/include/asm-powerpc/powerpc64/config.h xen/include/asm-powerpc/powerpc64/ppc970-hid.h xen/include/asm-powerpc/powerpc64/ppc970.h xen/include/asm-powerpc/powerpc64/procarea.h xen/include/asm-powerpc/powerpc64/processor.h xen/include/asm-powerpc/powerpc64/string.h xen/include/asm-powerpc/processor.h xen/include/asm-powerpc/reg_defs.h xen/include/asm-powerpc/regs.h xen/include/asm-powerpc/shadow.h xen/include/asm-powerpc/shared.h xen/include/asm-powerpc/smp.h xen/include/asm-powerpc/softirq.h xen/include/asm-powerpc/spinlock.h xen/include/asm-powerpc/string.h xen/include/asm-powerpc/system.h xen/include/asm-powerpc/time.h xen/include/asm-powerpc/trace.h xen/include/asm-powerpc/types.h xen/include/asm-powerpc/xenoprof.h xen/include/asm-x86/desc.h xen/include/public/arch-powerpc.h xen/include/public/io/protocols.h xen/include/public/libelf.h xen/include/public/xen.h
line diff
     1.1 --- a/Config.mk	Thu May 08 13:15:45 2008 +0100
     1.2 +++ b/Config.mk	Thu May 08 13:40:40 2008 +0100
     1.3 @@ -4,8 +4,7 @@
     1.4  debug ?= n
     1.5  
     1.6  XEN_COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/ \
     1.7 -                         -e s/ppc/powerpc/ -e s/i86pc/x86_32/   \
     1.8 -                         -e s/amd64/x86_64/)
     1.9 +                         -e s/i86pc/x86_32/ -e s/amd64/x86_64/)
    1.10  XEN_TARGET_ARCH     ?= $(XEN_COMPILE_ARCH)
    1.11  XEN_OS              ?= $(shell uname -s)
    1.12  
     2.1 --- a/config/powerpc64.mk	Thu May 08 13:15:45 2008 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,6 +0,0 @@
     2.4 -CONFIG_POWERPC := y
     2.5 -CONFIG_POWERPC_$(XEN_OS) := y
     2.6 -
     2.7 -CONFIG_XENCOMM := y
     2.8 -
     2.9 -CFLAGS += -DELFSIZE=64
     3.1 --- a/tools/libxc/Makefile	Thu May 08 13:15:45 2008 +0100
     3.2 +++ b/tools/libxc/Makefile	Thu May 08 13:40:40 2008 +0100
     3.3 @@ -9,7 +9,6 @@ ifneq ($(stubdom),y)
     3.4  CTRL_SRCS-y       += xc_core.c
     3.5  CTRL_SRCS-$(CONFIG_X86) += xc_core_x86.c
     3.6  CTRL_SRCS-$(CONFIG_IA64) += xc_core_ia64.c
     3.7 -CTRL_SRCS-$(CONFIG_POWERPC) += xc_core_powerpc.c
     3.8  endif
     3.9  CTRL_SRCS-y       += xc_domain.c
    3.10  CTRL_SRCS-y       += xc_evtchn.c
    3.11 @@ -55,7 +54,6 @@ GUEST_SRCS-y                 += xc_dom_c
    3.12  GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c
    3.13  GUEST_SRCS-$(CONFIG_X86)     += xc_cpuid_x86.c
    3.14  GUEST_SRCS-$(CONFIG_IA64)    += xc_dom_ia64.c
    3.15 -GUEST_SRCS-$(CONFIG_POWERPC) += xc_dom_powerpc.c
    3.16  endif
    3.17  
    3.18  -include $(XEN_TARGET_ARCH)/Makefile
     4.1 --- a/tools/libxc/powerpc64/Makefile	Thu May 08 13:15:45 2008 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,4 +0,0 @@
     4.4 -GUEST_SRCS-y += powerpc64/flatdevtree.c
     4.5 -GUEST_SRCS-y += powerpc64/mk_flatdevtree.c
     4.6 -
     4.7 -CTRL_SRCS-y += powerpc64/xc_memory.c
     5.1 --- a/tools/libxc/powerpc64/flatdevtree.c	Thu May 08 13:15:45 2008 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,662 +0,0 @@
     5.4 -/*
     5.5 - * This program is free software; you can redistribute it and/or modify
     5.6 - * it under the terms of the GNU General Public License as published by
     5.7 - * the Free Software Foundation; either version 2 of the License, or
     5.8 - * (at your option) any later version.
     5.9 - *
    5.10 - * This program is distributed in the hope that it will be useful,
    5.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.13 - * GNU General Public License for more details.
    5.14 - *
    5.15 - * You should have received a copy of the GNU General Public License
    5.16 - * along with this program; if not, write to the Free Software
    5.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    5.18 - *
    5.19 - * Copyright Pantelis Antoniou 2006
    5.20 - * Copyright IBM Corporation 2006, 2007
    5.21 - * 2006 (c) MontaVista, Software, Inc.
    5.22 - *
    5.23 - * Authors: Pantelis Antoniou <pantelis@embeddedalley.com>
    5.24 - *          Hollis Blanchard <hollisb@us.ibm.com>
    5.25 - *          Mark A. Greer <mgreer@mvista.com>
    5.26 - */
    5.27 -
    5.28 -#include "flatdevtree.h"
    5.29 -
    5.30 -/* Set ptrs to current one's info; return addr of next one */
    5.31 -static u32 *ft_next(u32 *p, const u32 *p_strings, const u32 version,
    5.32 -		u32 **tagpp, char **namepp, char **datapp, u32 **sizepp)
    5.33 -{
    5.34 -	u32 sz;
    5.35 -
    5.36 -	*namepp = NULL;
    5.37 -	*datapp = NULL;
    5.38 -	*sizepp = NULL;
    5.39 -	*tagpp = p;
    5.40 -
    5.41 -	switch (be32_to_cpu(*p++)) { /* Tag */
    5.42 -	case OF_DT_BEGIN_NODE:
    5.43 -		*namepp = (char *)p;
    5.44 -		p = (u32 *)_ALIGN((unsigned long)p + strlen((char *)p) + 1, 4);
    5.45 -		break;
    5.46 -	case OF_DT_PROP:
    5.47 -		sz = be32_to_cpu(*p);
    5.48 -		*sizepp = p++;
    5.49 -		*namepp = (char *)p_strings + be32_to_cpu(*p++);
    5.50 -		if ((version < 0x10) && (sz >= 8))
    5.51 -			p = (u32 *)_ALIGN((unsigned long)p, 8);
    5.52 -		*datapp = (char *)p;
    5.53 -		p = (u32 *)_ALIGN((unsigned long)p + sz, 4);
    5.54 -		break;
    5.55 -	case OF_DT_END_NODE:
    5.56 -	case OF_DT_NOP:
    5.57 -		break;
    5.58 -	case OF_DT_END:
    5.59 -	default:
    5.60 -		p = NULL;
    5.61 -		break;
    5.62 -	}
    5.63 -
    5.64 -	return p;
    5.65 -}
    5.66 -
    5.67 -static void ft_put_word(struct ft_cxt *cxt, u32 v)
    5.68 -{
    5.69 -	if (cxt->overflow)	/* do nothing */
    5.70 -		return;
    5.71 -
    5.72 -	/* check for overflow */
    5.73 -	if (cxt->p + 4 > cxt->pstr) {
    5.74 -		cxt->overflow = 1;
    5.75 -		return;
    5.76 -	}
    5.77 -
    5.78 -	*(u32 *) cxt->p = cpu_to_be32(v);
    5.79 -	cxt->p += 4;
    5.80 -}
    5.81 -
    5.82 -static inline void ft_put_bin(struct ft_cxt *cxt, const void *data, int sz)
    5.83 -{
    5.84 -	char *p;
    5.85 -
    5.86 -	if (cxt->overflow)	/* do nothing */
    5.87 -		return;
    5.88 -
    5.89 -	/* next pointer pos */
    5.90 -	p = (char *) _ALIGN((unsigned long)cxt->p + sz, 4);
    5.91 -
    5.92 -	/* check for overflow */
    5.93 -	if (p > cxt->pstr) {
    5.94 -		cxt->overflow = 1;
    5.95 -		return;
    5.96 -	}
    5.97 -
    5.98 -	memcpy(cxt->p, data, sz);
    5.99 -	if ((sz & 3) != 0)
   5.100 -		memset(cxt->p + sz, 0, 4 - (sz & 3));
   5.101 -	cxt->p = p;
   5.102 -}
   5.103 -
   5.104 -void ft_begin_node(struct ft_cxt *cxt, const char *name)
   5.105 -{
   5.106 -	ft_put_word(cxt, OF_DT_BEGIN_NODE);
   5.107 -	ft_put_bin(cxt, name, strlen(name) + 1);
   5.108 -}
   5.109 -
   5.110 -void ft_end_node(struct ft_cxt *cxt)
   5.111 -{
   5.112 -	ft_put_word(cxt, OF_DT_END_NODE);
   5.113 -}
   5.114 -
   5.115 -void ft_nop(struct ft_cxt *cxt)
   5.116 -{
   5.117 -	ft_put_word(cxt, OF_DT_NOP);
   5.118 -}
   5.119 -
   5.120 -static int lookup_string(struct ft_cxt *cxt, const char *name)
   5.121 -{
   5.122 -	char *p;
   5.123 -
   5.124 -	p = cxt->pstr;
   5.125 -	while (p < cxt->pstr_begin) {
   5.126 -		if (strcmp(p, (char *)name) == 0)
   5.127 -			return p - cxt->p_begin;
   5.128 -		p += strlen(p) + 1;
   5.129 -	}
   5.130 -
   5.131 -	return -1;
   5.132 -}
   5.133 -
   5.134 -void ft_prop(struct ft_cxt *cxt, const char *name,
   5.135 -		const void *data, unsigned int sz)
   5.136 -{
   5.137 -	int len, off;
   5.138 -
   5.139 -	if (cxt->overflow)
   5.140 -		return;
   5.141 -
   5.142 -	len = strlen(name) + 1;
   5.143 -
   5.144 -	off = lookup_string(cxt, name);
   5.145 -	if (off == -1) {
   5.146 -		/* check if we have space */
   5.147 -		if (cxt->p + 12 + sz + len > cxt->pstr) {
   5.148 -			cxt->overflow = 1;
   5.149 -			return;
   5.150 -		}
   5.151 -
   5.152 -		cxt->pstr -= len;
   5.153 -		memcpy(cxt->pstr, name, len);
   5.154 -		off = cxt->pstr - cxt->p_begin;
   5.155 -	}
   5.156 -
   5.157 -	/* now put offset from beginning of *STRUCTURE* */
   5.158 -	/* will be fixed up at the end */
   5.159 -	ft_put_word(cxt, OF_DT_PROP);
   5.160 -	ft_put_word(cxt, sz);
   5.161 -	ft_put_word(cxt, off);
   5.162 -	ft_put_bin(cxt, data, sz);
   5.163 -}
   5.164 -
   5.165 -void ft_prop_str(struct ft_cxt *cxt, const char *name, const char *str)
   5.166 -{
   5.167 -	ft_prop(cxt, name, str, strlen(str) + 1);
   5.168 -}
   5.169 -
   5.170 -void ft_prop_int(struct ft_cxt *cxt, const char *name, unsigned int val)
   5.171 -{
   5.172 -	u32 v = cpu_to_be32((u32) val);
   5.173 -
   5.174 -	ft_prop(cxt, name, &v, 4);
   5.175 -}
   5.176 -
   5.177 -/* start construction of the flat OF tree */
   5.178 -void ft_begin(struct ft_cxt *cxt, void *blob, unsigned int max_size)
   5.179 -{
   5.180 -	struct boot_param_header *bph = blob;
   5.181 -	u32 off;
   5.182 -
   5.183 -	/* clear the cxt */
   5.184 -	memset(cxt, 0, sizeof(*cxt));
   5.185 -
   5.186 -	cxt->bph = bph;
   5.187 -	cxt->max_size = max_size;
   5.188 -
   5.189 -	/* zero everything in the header area */
   5.190 -	memset(bph, 0, sizeof(*bph));
   5.191 -
   5.192 -	bph->magic = cpu_to_be32(OF_DT_HEADER);
   5.193 -	bph->version = cpu_to_be32(0x10);
   5.194 -	bph->last_comp_version = cpu_to_be32(0x10);
   5.195 -
   5.196 -	/* start pointers */
   5.197 -	cxt->pres_begin = (char *) _ALIGN((unsigned long)(bph + 1), 8);
   5.198 -	cxt->pres = cxt->pres_begin;
   5.199 -
   5.200 -	off = (unsigned long)cxt->pres_begin - (unsigned long)bph;
   5.201 -	bph->off_mem_rsvmap = cpu_to_be32(off);
   5.202 -
   5.203 -	((u64 *) cxt->pres)[0] = 0;	/* phys = 0, size = 0, terminate */
   5.204 -	((u64 *) cxt->pres)[1] = 0;
   5.205 -
   5.206 -	cxt->p_anchor = cxt->pres + 16;	/* over the terminator */
   5.207 -}
   5.208 -
   5.209 -/* add a reserver physical area to the rsvmap */
   5.210 -void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size)
   5.211 -{
   5.212 -	((u64 *) cxt->pres)[0] = cpu_to_be64(physaddr);	/* phys = 0, size = 0, terminate */
   5.213 -	((u64 *) cxt->pres)[1] = cpu_to_be64(size);
   5.214 -
   5.215 -	cxt->pres += 16;	/* advance two u64s worth */
   5.216 -
   5.217 -	((u64 *) cxt->pres)[0] = 0;	/* phys = 0, size = 0, terminate */
   5.218 -	((u64 *) cxt->pres)[1] = 0;
   5.219 -
   5.220 -	/* keep track of size */
   5.221 -	cxt->res_size = cxt->pres + 16 - cxt->pres_begin;
   5.222 -
   5.223 -	cxt->p_anchor = cxt->pres + 16;	/* over the terminator */
   5.224 -}
   5.225 -
   5.226 -int ft_set_rsvmap(void *bphp, int m, u64 physaddr, u64 size)
   5.227 -{
   5.228 -	const struct boot_param_header *bph = bphp;
   5.229 -	u64 *p_rsvmap = (u64 *)
   5.230 -		((char *)bph + be32_to_cpu(bph->off_mem_rsvmap));
   5.231 -	u32 i;
   5.232 -
   5.233 -	for (i = 0;; i++) {
   5.234 -		u64 addr, sz;
   5.235 -
   5.236 -		addr = be64_to_cpu(p_rsvmap[i * 2]);
   5.237 -		sz = be64_to_cpu(p_rsvmap[i * 2 + 1]);
   5.238 -		if (addr == 0 && size == 0)
   5.239 -			break;
   5.240 -		if (m == i) {
   5.241 -			p_rsvmap[i * 2] = cpu_to_be64(physaddr);
   5.242 -			p_rsvmap[i * 2 + 1] = cpu_to_be64(size);
   5.243 -			return 0;
   5.244 -		}
   5.245 -	}
   5.246 -	return -1;
   5.247 -}
   5.248 -
   5.249 -void ft_begin_tree(struct ft_cxt *cxt)
   5.250 -{
   5.251 -	cxt->p_begin = cxt->p_anchor;
   5.252 -	cxt->pstr_begin = (char *)cxt->bph + cxt->max_size;	/* point at the end */
   5.253 -
   5.254 -	cxt->p = cxt->p_begin;
   5.255 -	cxt->pstr = cxt->pstr_begin;
   5.256 -}
   5.257 -
   5.258 -int ft_end_tree(struct ft_cxt *cxt)
   5.259 -{
   5.260 -	struct boot_param_header *bph = cxt->bph;
   5.261 -	int off, sz, sz1;
   5.262 -	u32 tag, v;
   5.263 -	char *p;
   5.264 -
   5.265 -	ft_put_word(cxt, OF_DT_END);
   5.266 -
   5.267 -	if (cxt->overflow)
   5.268 -		return -ENOMEM;
   5.269 -
   5.270 -	/* size of the areas */
   5.271 -	cxt->struct_size = cxt->p - cxt->p_begin;
   5.272 -	cxt->strings_size = cxt->pstr_begin - cxt->pstr;
   5.273 -
   5.274 -	/* the offset we must move */
   5.275 -	off = (cxt->pstr_begin - cxt->p_begin) - cxt->strings_size;
   5.276 -
   5.277 -	/* the new strings start */
   5.278 -	cxt->pstr_begin = cxt->p_begin + cxt->struct_size;
   5.279 -
   5.280 -	/* move the whole string area */
   5.281 -	memmove(cxt->pstr_begin, cxt->pstr, cxt->strings_size);
   5.282 -
   5.283 -	/* now perform the fixup of the strings */
   5.284 -	p = cxt->p_begin;
   5.285 -	while ((tag = be32_to_cpu(*(u32 *) p)) != OF_DT_END) {
   5.286 -		p += 4;
   5.287 -
   5.288 -		if (tag == OF_DT_BEGIN_NODE) {
   5.289 -			p = (char *) _ALIGN((unsigned long)p + strlen(p) + 1, 4);
   5.290 -			continue;
   5.291 -		}
   5.292 -
   5.293 -		if (tag == OF_DT_END_NODE || tag == OF_DT_NOP)
   5.294 -			continue;
   5.295 -
   5.296 -		if (tag != OF_DT_PROP)
   5.297 -			return -EINVAL;
   5.298 -
   5.299 -		sz = be32_to_cpu(*(u32 *) p);
   5.300 -		p += 4;
   5.301 -
   5.302 -		v = be32_to_cpu(*(u32 *) p);
   5.303 -		v -= off;
   5.304 -		*(u32 *) p = cpu_to_be32(v);	/* move down */
   5.305 -		p += 4;
   5.306 -
   5.307 -		p = (char *) _ALIGN((unsigned long)p + sz, 4);
   5.308 -	}
   5.309 -
   5.310 -	/* fix sizes */
   5.311 -	p = (char *)cxt->bph;
   5.312 -	sz = (cxt->pstr_begin + cxt->strings_size) - p;
   5.313 -	sz1 = _ALIGN(sz, 16);	/* align at 16 bytes */
   5.314 -	if (sz != sz1)
   5.315 -		memset(p + sz, 0, sz1 - sz);
   5.316 -	bph->totalsize = cpu_to_be32(sz1);
   5.317 -	bph->off_dt_struct = cpu_to_be32(cxt->p_begin - p);
   5.318 -	bph->off_dt_strings = cpu_to_be32(cxt->pstr_begin - p);
   5.319 -
   5.320 -	/* the new strings start */
   5.321 -	cxt->pstr_begin = cxt->p_begin + cxt->struct_size;
   5.322 -	cxt->pstr = cxt->pstr_begin + cxt->strings_size;
   5.323 -
   5.324 -	/* mark the size of string structure in bph */
   5.325 -	bph->size_dt_strings = cxt->strings_size;
   5.326 -
   5.327 -	return 0;
   5.328 -}
   5.329 -
   5.330 -/**********************************************************************/
   5.331 -
   5.332 -static inline int isprint(int c)
   5.333 -{
   5.334 -	return c >= 0x20 && c <= 0x7e;
   5.335 -}
   5.336 -
   5.337 -static int is_printable_string(const void *data, int len)
   5.338 -{
   5.339 -	const char *s = data;
   5.340 -	const char *ss;
   5.341 -
   5.342 -	/* zero length is not */
   5.343 -	if (len == 0)
   5.344 -		return 0;
   5.345 -
   5.346 -	/* must terminate with zero */
   5.347 -	if (s[len - 1] != '\0')
   5.348 -		return 0;
   5.349 -
   5.350 -	ss = s;
   5.351 -	while (*s && isprint(*s))
   5.352 -		s++;
   5.353 -
   5.354 -	/* not zero, or not done yet */
   5.355 -	if (*s != '\0' || (s + 1 - ss) < len)
   5.356 -		return 0;
   5.357 -
   5.358 -	return 1;
   5.359 -}
   5.360 -
   5.361 -static void print_data(const void *data, int len)
   5.362 -{
   5.363 -	int i;
   5.364 -	const char *s;
   5.365 -
   5.366 -	/* no data, don't print */
   5.367 -	if (len == 0)
   5.368 -		return;
   5.369 -
   5.370 -	if (is_printable_string(data, len)) {
   5.371 -		printf(" = \"%s\"", (char *)data);
   5.372 -		return;
   5.373 -	}
   5.374 -
   5.375 -	switch (len) {
   5.376 -	case 1:		/* byte */
   5.377 -		printf(" = <0x%02x>", (*(char *) data) & 0xff);
   5.378 -		break;
   5.379 -	case 2:		/* half-word */
   5.380 -		printf(" = <0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff);
   5.381 -		break;
   5.382 -	case 4:		/* word */
   5.383 -		printf(" = <0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
   5.384 -		break;
   5.385 -	case 8:		/* double-word */
   5.386 -		printf(" = <0x%16llx>", be64_to_cpu(*(u64 *) data));
   5.387 -		break;
   5.388 -	default:		/* anything else... hexdump */
   5.389 -		printf(" = [");
   5.390 -		for (i = 0, s = data; i < len; i++)
   5.391 -			printf("%02x%s", s[i], i < len - 1 ? " " : "");
   5.392 -		printf("]");
   5.393 -
   5.394 -		break;
   5.395 -	}
   5.396 -}
   5.397 -
   5.398 -void ft_dump_blob(const void *bphp)
   5.399 -{
   5.400 -	const struct boot_param_header *bph = bphp;
   5.401 -	const u64 *p_rsvmap = (const u64 *)
   5.402 -		((const char *)bph + be32_to_cpu(bph->off_mem_rsvmap));
   5.403 -	const u32 *p_struct = (const u32 *)
   5.404 -		((const char *)bph + be32_to_cpu(bph->off_dt_struct));
   5.405 -	const u32 *p_strings = (const u32 *)
   5.406 -		((const char *)bph + be32_to_cpu(bph->off_dt_strings));
   5.407 -	const u32 version = be32_to_cpu(bph->version);
   5.408 -	u32 i, *p, *tagp, *sizep;
   5.409 -	char *namep, *datap;
   5.410 -	int depth, shift;
   5.411 -	u64 addr, size;
   5.412 -
   5.413 -
   5.414 -	if (be32_to_cpu(bph->magic) != OF_DT_HEADER) {
   5.415 -		/* not valid tree */
   5.416 -		return;
   5.417 -	}
   5.418 -
   5.419 -	depth = 0;
   5.420 -	shift = 4;
   5.421 -
   5.422 -	for (i = 0;; i++) {
   5.423 -		addr = be64_to_cpu(p_rsvmap[i * 2]);
   5.424 -		size = be64_to_cpu(p_rsvmap[i * 2 + 1]);
   5.425 -		if (addr == 0 && size == 0)
   5.426 -			break;
   5.427 -
   5.428 -		printf("/memreserve/ 0x%llx 0x%llx;\n", addr, size);
   5.429 -	}
   5.430 -
   5.431 -	p = (u32 *)p_struct;
   5.432 -	while ((p = ft_next(p, p_strings, version, &tagp, &namep, &datap,
   5.433 -					&sizep)) != NULL)
   5.434 -		switch (be32_to_cpu(*tagp)) {
   5.435 -		case OF_DT_BEGIN_NODE:
   5.436 -			printf("%*s%s {\n", depth * shift, "", namep);
   5.437 -			depth++;
   5.438 -			break;
   5.439 -		case OF_DT_END_NODE:
   5.440 -			depth--;
   5.441 -			printf("%*s};\n", depth * shift, "");
   5.442 -			break;
   5.443 -		case OF_DT_NOP:
   5.444 -			printf("%*s[NOP]\n", depth * shift, "");
   5.445 -			break;
   5.446 -		case OF_DT_END:
   5.447 -			break;
   5.448 -		case OF_DT_PROP:
   5.449 -			printf("%*s%s", depth * shift, "", namep);
   5.450 -			print_data(datap, *sizep);
   5.451 -			printf(";\n");
   5.452 -			break;
   5.453 -		default:
   5.454 -			fprintf(stderr, "%*s ** Unknown tag 0x%08x\n",
   5.455 -				depth * shift, "", *tagp);
   5.456 -			return;
   5.457 -		}
   5.458 -}
   5.459 -
   5.460 -void ft_backtrack_node(struct ft_cxt *cxt)
   5.461 -{
   5.462 -	if (be32_to_cpu(*(u32 *) (cxt->p - 4)) != OF_DT_END_NODE)
   5.463 -		return;		/* XXX only for node */
   5.464 -
   5.465 -	cxt->p -= 4;
   5.466 -}
   5.467 -
   5.468 -/* note that the root node of the blob is "peeled" off */
   5.469 -void ft_merge_blob(struct ft_cxt *cxt, void *blob)
   5.470 -{
   5.471 -	struct boot_param_header *bph = (struct boot_param_header *)blob;
   5.472 -	u32 *p_struct = (u32 *) ((char *)bph + be32_to_cpu(bph->off_dt_struct));
   5.473 -	u32 *p_strings =
   5.474 -		(u32 *) ((char *)bph + be32_to_cpu(bph->off_dt_strings));
   5.475 -	const u32 version = be32_to_cpu(bph->version);
   5.476 -	u32 *p, *tagp, *sizep;
   5.477 -	char *namep, *datap;
   5.478 -	int depth;
   5.479 -
   5.480 -	if (be32_to_cpu(*(u32 *) (cxt->p - 4)) != OF_DT_END_NODE)
   5.481 -		return;		/* XXX only for node */
   5.482 -
   5.483 -	cxt->p -= 4;
   5.484 -
   5.485 -	depth = 0;
   5.486 -	p = p_struct;
   5.487 -	while ((p = ft_next(p, p_strings, version, &tagp, &namep, &datap,
   5.488 -					&sizep)) != NULL)
   5.489 -		switch (be32_to_cpu(*tagp)) {
   5.490 -		case OF_DT_BEGIN_NODE:
   5.491 -			if (depth++ > 0)
   5.492 -				ft_begin_node(cxt, namep);
   5.493 -			break;
   5.494 -		case OF_DT_END_NODE:
   5.495 -			ft_end_node(cxt);
   5.496 -			if (--depth == 0)
   5.497 -				return;
   5.498 -			break;
   5.499 -		case OF_DT_PROP:
   5.500 -			ft_prop(cxt, namep, datap, *sizep);
   5.501 -			break;
   5.502 -		}
   5.503 -}
   5.504 -
   5.505 -/**********************************************************************/
   5.506 -
   5.507 -void *ft_find_node(const void *bphp, const char *srch_path)
   5.508 -{
   5.509 -	const struct boot_param_header *bph = bphp;
   5.510 -	u32 *p_struct = (u32 *)((char *)bph + be32_to_cpu(bph->off_dt_struct));
   5.511 -	u32 *p_strings= (u32 *)((char *)bph + be32_to_cpu(bph->off_dt_strings));
   5.512 -	u32 version = be32_to_cpu(bph->version);
   5.513 -	u32 *p, *tagp, *sizep;
   5.514 -	char *namep, *datap;
   5.515 -	static char path[MAX_PATH_LEN];
   5.516 -
   5.517 -	path[0] = '\0';
   5.518 -	p = p_struct;
   5.519 -
   5.520 -	while ((p = ft_next(p, p_strings, version, &tagp, &namep, &datap,
   5.521 -					&sizep)) != NULL)
   5.522 -		switch (be32_to_cpu(*tagp)) {
   5.523 -		case OF_DT_BEGIN_NODE:
   5.524 -			strcat(path, namep);
   5.525 -			if (!strcmp(path, srch_path))
   5.526 -				return tagp;
   5.527 -			strcat(path, "/");
   5.528 -			break;
   5.529 -		case OF_DT_END_NODE:
   5.530 -			ft_parentize(path, 1);
   5.531 -			break;
   5.532 -		}
   5.533 -	return NULL;
   5.534 -}
   5.535 -
   5.536 -int ft_get_prop(const void *bphp, const void *node, const char *propname,
   5.537 -		void *buf, const unsigned int buflen)
   5.538 -{
   5.539 -	const struct boot_param_header *bph = bphp;
   5.540 -	u32 *p_strings= (u32 *)((char *)bph + be32_to_cpu(bph->off_dt_strings));
   5.541 -	u32 version = be32_to_cpu(bph->version);
   5.542 -	u32 *p, *tagp, *sizep, size;
   5.543 -	char *namep, *datap;
   5.544 -	int depth;
   5.545 -
   5.546 -	depth = 0;
   5.547 -	p = (u32 *)node;
   5.548 -
   5.549 -	while ((p = ft_next(p, p_strings, version, &tagp, &namep, &datap,
   5.550 -					&sizep)) != NULL)
   5.551 -		switch (be32_to_cpu(*tagp)) {
   5.552 -		case OF_DT_BEGIN_NODE:
   5.553 -			depth++;
   5.554 -			break;
   5.555 -		case OF_DT_PROP:
   5.556 -			if ((depth == 1) && !strcmp(namep, propname)) {
   5.557 -				size = min(be32_to_cpu(*sizep), (u32)buflen);
   5.558 -				memcpy(buf, datap, size);
   5.559 -				return size;
   5.560 -			}
   5.561 -			break;
   5.562 -		case OF_DT_END_NODE:
   5.563 -			if (--depth <= 0)
   5.564 -				return -1;
   5.565 -			break;
   5.566 -		}
   5.567 -	return -1;
   5.568 -}
   5.569 -
   5.570 -static void ft_modify_prop(void **bphpp, char *datap, u32 *old_prop_sizep,
   5.571 -		const char *buf, const unsigned int buflen)
   5.572 -{
   5.573 -	u32 old_prop_data_len, new_prop_data_len;
   5.574 -
   5.575 -	old_prop_data_len = _ALIGN(be32_to_cpu(*old_prop_sizep), 4);
   5.576 -	new_prop_data_len = _ALIGN(buflen, 4);
   5.577 -
   5.578 -	/* Check if new prop data fits in old prop data area */
   5.579 -	if (new_prop_data_len == old_prop_data_len) {
   5.580 -		memcpy(datap, buf, buflen);
   5.581 -		*old_prop_sizep = cpu_to_be32(buflen);
   5.582 -	} else {
   5.583 -		/* Need to alloc new area to put larger or smaller ft */
   5.584 -		struct boot_param_header *old_bph = *bphpp, *new_bph;
   5.585 -		u32 *old_tailp, *new_tailp, *new_datap;
   5.586 -		u32 old_total_size, new_total_size, head_len, tail_len, diff, v;
   5.587 -
   5.588 -		old_total_size = be32_to_cpu(old_bph->totalsize);
   5.589 -		head_len = (u32)(datap - (char *)old_bph);
   5.590 -		tail_len = old_total_size - (head_len + old_prop_data_len);
   5.591 -		old_tailp = (u32 *)(datap + old_prop_data_len);
   5.592 -		new_total_size = head_len + new_prop_data_len + tail_len;
   5.593 -
   5.594 -		if (!(new_bph = malloc(new_total_size))) {
   5.595 -			printf("Can't alloc space for new ft\n");
   5.596 -			ft_exit(-ENOSPC);
   5.597 -		}
   5.598 -
   5.599 -		new_datap = (u32 *)((char *)new_bph + head_len);
   5.600 -		new_tailp = (u32 *)((char *)new_datap + new_prop_data_len);
   5.601 -
   5.602 -		memcpy(new_bph, *bphpp, head_len);
   5.603 -		memcpy(new_datap, buf, buflen);
   5.604 -		memcpy(new_tailp, old_tailp, tail_len);
   5.605 -
   5.606 -		*(new_datap - 2) = cpu_to_be32(buflen); /* Set prop size */
   5.607 -
   5.608 -		new_bph->totalsize = cpu_to_be32(new_total_size);
   5.609 -		diff = new_prop_data_len - old_prop_data_len;
   5.610 -
   5.611 -		if (be32_to_cpu(old_bph->off_dt_strings)
   5.612 -				> be32_to_cpu(old_bph->off_dt_struct)) {
   5.613 -			v = be32_to_cpu(new_bph->off_dt_strings);
   5.614 -			new_bph->off_dt_strings = cpu_to_be32(v + diff);
   5.615 -		}
   5.616 -
   5.617 -		if (be32_to_cpu(old_bph->off_mem_rsvmap)
   5.618 -				> be32_to_cpu(old_bph->off_dt_struct)) {
   5.619 -			v = be32_to_cpu(new_bph->off_mem_rsvmap);
   5.620 -			new_bph->off_mem_rsvmap = cpu_to_be32(v + diff);
   5.621 -		}
   5.622 -
   5.623 -		ft_free(*bphpp, old_total_size);
   5.624 -		*bphpp = new_bph;
   5.625 -	}
   5.626 -}
   5.627 -
   5.628 -/*
   5.629 - * - Only modifies existing properties.
   5.630 - * - The dev tree passed in may be freed and a new one allocated
   5.631 - *   (and *bphpp set to location of new dev tree).
   5.632 - */
   5.633 -int ft_set_prop(void **bphpp, const void *node, const char *propname,
   5.634 -		const void *buf, const unsigned int buflen)
   5.635 -{
   5.636 -	struct boot_param_header *bph = *bphpp;
   5.637 -	u32 *p_strings= (u32 *)((char *)bph + be32_to_cpu(bph->off_dt_strings));
   5.638 -	u32 version = be32_to_cpu(bph->version);
   5.639 -	u32 *p, *tagp, *sizep;
   5.640 -	char *namep, *datap;
   5.641 -	int depth;
   5.642 -
   5.643 -	depth = 0;
   5.644 -	p = (u32 *)node;
   5.645 -
   5.646 -	while ((p = ft_next(p, p_strings, version, &tagp, &namep, &datap,
   5.647 -					&sizep)) != NULL)
   5.648 -		switch (be32_to_cpu(*tagp)) {
   5.649 -		case OF_DT_BEGIN_NODE:
   5.650 -			depth++;
   5.651 -			break;
   5.652 -		case OF_DT_PROP:
   5.653 -			if ((depth == 1) && !strcmp(namep, propname)) {
   5.654 -				ft_modify_prop(bphpp, datap, sizep, buf,
   5.655 -						buflen);
   5.656 -				return be32_to_cpu(*sizep);
   5.657 -			}
   5.658 -			break;
   5.659 -		case OF_DT_END_NODE:
   5.660 -			if (--depth <= 0)
   5.661 -				return -1;
   5.662 -			break;
   5.663 -		}
   5.664 -	return -1;
   5.665 -}
     6.1 --- a/tools/libxc/powerpc64/flatdevtree.h	Thu May 08 13:15:45 2008 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,108 +0,0 @@
     6.4 -/*
     6.5 - * This program is free software; you can redistribute it and/or modify
     6.6 - * it under the terms of the GNU General Public License as published by
     6.7 - * the Free Software Foundation; either version 2 of the License, or
     6.8 - * (at your option) any later version.
     6.9 - *
    6.10 - * This program is distributed in the hope that it will be useful,
    6.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.13 - * GNU General Public License for more details.
    6.14 - *
    6.15 - * You should have received a copy of the GNU General Public License
    6.16 - * along with this program; if not, write to the Free Software
    6.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    6.18 - */
    6.19 -
    6.20 -#ifndef _FLATDEVTREE_H_
    6.21 -#define _FLATDEVTREE_H_
    6.22 -
    6.23 -#include "flatdevtree_env.h"
    6.24 -
    6.25 -/* Definitions used by the flattened device tree */
    6.26 -#define OF_DT_HEADER            0xd00dfeed      /* marker */
    6.27 -#define OF_DT_BEGIN_NODE        0x1     /* Start of node, full name */
    6.28 -#define OF_DT_END_NODE          0x2     /* End node */
    6.29 -#define OF_DT_PROP              0x3     /* Property: name off, size, content */
    6.30 -#define OF_DT_NOP               0x4     /* nop */
    6.31 -#define OF_DT_END               0x9
    6.32 -
    6.33 -#define OF_DT_VERSION           0x10
    6.34 -
    6.35 -struct boot_param_header {
    6.36 -	u32 magic;              /* magic word OF_DT_HEADER */
    6.37 -	u32 totalsize;          /* total size of DT block */
    6.38 -	u32 off_dt_struct;      /* offset to structure */
    6.39 -	u32 off_dt_strings;     /* offset to strings */
    6.40 -	u32 off_mem_rsvmap;     /* offset to memory reserve map */
    6.41 -	u32 version;            /* format version */
    6.42 -	u32 last_comp_version;  /* last compatible version */
    6.43 -	/* version 2 fields below */
    6.44 -	u32 boot_cpuid_phys;    /* Physical CPU id we're booting on */
    6.45 -	/* version 3 fields below */
    6.46 -	u32 size_dt_strings;    /* size of the DT strings block */
    6.47 -};
    6.48 -
    6.49 -struct ft_cxt {
    6.50 -	struct boot_param_header *bph;
    6.51 -	int max_size;           /* maximum size of tree */
    6.52 -	int overflow;           /* set when this happens */
    6.53 -	char *p, *pstr, *pres;  /* running pointers */
    6.54 -	char *p_begin, *pstr_begin, *pres_begin;        /* starting pointers */
    6.55 -	char *p_anchor;         /* start of constructed area */
    6.56 -	int struct_size, strings_size, res_size;
    6.57 -};
    6.58 -
    6.59 -void ft_begin_node(struct ft_cxt *cxt, const char *name);
    6.60 -void ft_end_node(struct ft_cxt *cxt);
    6.61 -
    6.62 -void ft_begin_tree(struct ft_cxt *cxt);
    6.63 -int ft_end_tree(struct ft_cxt *cxt);
    6.64 -
    6.65 -void ft_nop(struct ft_cxt *cxt);
    6.66 -void ft_prop(struct ft_cxt *cxt, const char *name,
    6.67 -             const void *data, unsigned int sz);
    6.68 -void ft_prop_str(struct ft_cxt *cxt, const char *name, const char *str);
    6.69 -void ft_prop_int(struct ft_cxt *cxt, const char *name, unsigned int val);
    6.70 -void ft_begin(struct ft_cxt *cxt, void *blob, unsigned int max_size);
    6.71 -void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
    6.72 -int ft_set_rsvmap(void *bphp, int m, u64 physaddr, u64 size);
    6.73 -
    6.74 -void ft_dump_blob(const void *bphp);
    6.75 -void ft_backtrack_node(struct ft_cxt *cxt);
    6.76 -void ft_merge_blob(struct ft_cxt *cxt, void *blob);
    6.77 -
    6.78 -void *ft_find_node(const void *bphp, const char *srch_path);
    6.79 -int ft_get_prop(const void *bphp, const void *node, const char *propname,
    6.80 -		void *buf, const unsigned int buflen);
    6.81 -int ft_set_prop(void **bphp, const void *node, const char *propname,
    6.82 -		const void *buf, const unsigned int buflen);
    6.83 -
    6.84 -static inline char *ft_strrchr(const char *s, int c)
    6.85 -{
    6.86 -	const char *p = s + strlen(s);
    6.87 -
    6.88 -	do {
    6.89 -		if (*p == (char)c)
    6.90 -			return (char *)p;
    6.91 -	} while (--p >= s);
    6.92 -	return NULL;
    6.93 -}
    6.94 -
    6.95 -/* 'path' is modified */
    6.96 -static inline void ft_parentize(char *path, int leave_slash)
    6.97 -{
    6.98 -	char *s = &path[strlen(path) - 1];
    6.99 -
   6.100 -	if (*s == '/')
   6.101 -		*s = '\0';
   6.102 -	s = ft_strrchr(path, '/');
   6.103 -	if (s != NULL) {
   6.104 -		if (leave_slash)
   6.105 -			s[1] = '\0';
   6.106 -		else if (s[0] == '/')
   6.107 -			s[0] = '\0';
   6.108 -	}
   6.109 -}
   6.110 -
   6.111 -#endif /* FLATDEVTREE_H */
     7.1 --- a/tools/libxc/powerpc64/flatdevtree_env.h	Thu May 08 13:15:45 2008 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,94 +0,0 @@
     7.4 -/*
     7.5 - * This program is free software; you can redistribute it and/or modify
     7.6 - * it under the terms of the GNU General Public License as published by
     7.7 - * the Free Software Foundation; either version 2 of the License, or
     7.8 - * (at your option) any later version.
     7.9 - *
    7.10 - * This program is distributed in the hope that it will be useful,
    7.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.13 - * GNU General Public License for more details.
    7.14 - *
    7.15 - * You should have received a copy of the GNU General Public License
    7.16 - * along with this program; if not, write to the Free Software
    7.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    7.18 - */
    7.19 -
    7.20 -#ifndef _FLATDEVTREE_ENV_H_
    7.21 -#define _FLATDEVTREE_ENV_H_
    7.22 -
    7.23 -#include <stdarg.h>
    7.24 -#include <stdio.h>
    7.25 -#include <stdlib.h>
    7.26 -#include <string.h>
    7.27 -#include <endian.h>
    7.28 -#include <errno.h>
    7.29 -
    7.30 -#define MAX_PATH_LEN 1024
    7.31 -
    7.32 -#define _ALIGN(addr,size)       (((addr)+(size)-1)&(~((size)-1)))
    7.33 -
    7.34 -typedef unsigned short u16;
    7.35 -typedef unsigned int u32;
    7.36 -typedef unsigned long long u64;
    7.37 -
    7.38 -static inline u16 swab16(u16 x)
    7.39 -{
    7.40 -	return  (((u16)(x) & (u16)0x00ffU) << 8) |
    7.41 -			(((u16)(x) & (u16)0xff00U) >> 8);
    7.42 -}
    7.43 -
    7.44 -static inline u32 swab32(u32 x)
    7.45 -{
    7.46 -	return  (((u32)(x) & (u32)0x000000ffUL) << 24) |
    7.47 -			(((u32)(x) & (u32)0x0000ff00UL) <<  8) |
    7.48 -			(((u32)(x) & (u32)0x00ff0000UL) >>  8) |
    7.49 -			(((u32)(x) & (u32)0xff000000UL) >> 24);
    7.50 -}
    7.51 -
    7.52 -static inline u64 swab64(u64 x)
    7.53 -{
    7.54 -	return  (u64)(((u64)(x) & (u64)0x00000000000000ffULL) << 56) |
    7.55 -			(u64)(((u64)(x) & (u64)0x000000000000ff00ULL) << 40) |
    7.56 -			(u64)(((u64)(x) & (u64)0x0000000000ff0000ULL) << 24) |
    7.57 -			(u64)(((u64)(x) & (u64)0x00000000ff000000ULL) <<  8) |
    7.58 -			(u64)(((u64)(x) & (u64)0x000000ff00000000ULL) >>  8) |
    7.59 -			(u64)(((u64)(x) & (u64)0x0000ff0000000000ULL) >> 24) |
    7.60 -			(u64)(((u64)(x) & (u64)0x00ff000000000000ULL) >> 40) |
    7.61 -			(u64)(((u64)(x) & (u64)0xff00000000000000ULL) >> 56);
    7.62 -}
    7.63 -
    7.64 -#if __BYTE_ORDER == __LITTLE_ENDIAN
    7.65 -#define cpu_to_be16(x) swab16(x)
    7.66 -#define be16_to_cpu(x) swab16(x)
    7.67 -#define cpu_to_be32(x) swab32(x)
    7.68 -#define be32_to_cpu(x) swab32(x)
    7.69 -#define cpu_to_be64(x) swab64(x)
    7.70 -#define be64_to_cpu(x) swab64(x)
    7.71 -#else
    7.72 -#define cpu_to_be16(x) (x)
    7.73 -#define be16_to_cpu(x) (x)
    7.74 -#define cpu_to_be32(x) (x)
    7.75 -#define be32_to_cpu(x) (x)
    7.76 -#define cpu_to_be64(x) (x)
    7.77 -#define be64_to_cpu(x) (x)
    7.78 -#endif
    7.79 -
    7.80 -static inline void ft_exit(int code)
    7.81 -{
    7.82 -	exit(code);
    7.83 -}
    7.84 -
    7.85 -static inline void ft_free(void *ptr, int len)
    7.86 -{
    7.87 -	free(ptr);
    7.88 -}
    7.89 -
    7.90 -static inline u32 min(u32 a, u32 b)
    7.91 -{
    7.92 -	if (a < b)
    7.93 -		return a;
    7.94 -	return b;
    7.95 -}
    7.96 -
    7.97 -#endif /* _FLATDEVTREE_ENV_H_ */
     8.1 --- a/tools/libxc/powerpc64/mk_flatdevtree.c	Thu May 08 13:15:45 2008 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,648 +0,0 @@
     8.4 -/*
     8.5 - * This program is free software; you can redistribute it and/or modify
     8.6 - * it under the terms of the GNU General Public License as published by
     8.7 - * the Free Software Foundation; either version 2 of the License, or
     8.8 - * (at your option) any later version.
     8.9 - *
    8.10 - * This program is distributed in the hope that it will be useful,
    8.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.13 - * GNU General Public License for more details.
    8.14 - *
    8.15 - * You should have received a copy of the GNU General Public License
    8.16 - * along with this program; if not, write to the Free Software
    8.17 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    8.18 - *
    8.19 - * Copyright IBM Corporation 2007
    8.20 - *
    8.21 - * Authors: Ryan Harper <ryanh@us.ibm.com>
    8.22 - */
    8.23 -
    8.24 -#include <stdio.h>
    8.25 -#include <stdlib.h>
    8.26 -#include <string.h>
    8.27 -#include <fcntl.h>
    8.28 -#include <dirent.h>
    8.29 -#include <unistd.h>
    8.30 -#include <libgen.h>    
    8.31 -#include <inttypes.h>
    8.32 -#include <math.h>
    8.33 -#include <errno.h>
    8.34 -#include <sys/types.h>
    8.35 -#include <sys/dir.h>
    8.36 -#include <sys/stat.h>
    8.37 -#include <sys/param.h>
    8.38 -
    8.39 -#include <xc_private.h> /* for PERROR() */
    8.40 -#include <xc_dom.h>
    8.41 -
    8.42 -#include "mk_flatdevtree.h"
    8.43 -
    8.44 -static uint32_t current_phandle = 0;
    8.45 -
    8.46 -static uint32_t get_phandle(void)
    8.47 -{
    8.48 -   return current_phandle++;
    8.49 -}
    8.50 -
    8.51 -static int readfile(const char *fullpath, void *data, int len)
    8.52 -{
    8.53 -    struct stat st;
    8.54 -    int saved_errno;
    8.55 -    int rc = -1;
    8.56 -    int fd;
    8.57 -   
    8.58 -    if ((fd = open(fullpath, O_RDONLY)) == -1) {
    8.59 -        PERROR("%s: failed to open file %s", __func__, fullpath);
    8.60 -        return -1;
    8.61 -    }
    8.62 -
    8.63 -    if ((rc = fstat(fd, &st)) == -1) {
    8.64 -        PERROR("%s: failed to stat fd %d", __func__, fd);
    8.65 -        goto error;
    8.66 -    }
    8.67 -
    8.68 -    if (S_ISREG(st.st_mode))
    8.69 -        rc = read(fd, data, len); 
    8.70 -
    8.71 -    close(fd);
    8.72 -    return rc;
    8.73 -
    8.74 -error:
    8.75 -    saved_errno = errno;
    8.76 -    close(fd);
    8.77 -    errno = saved_errno;
    8.78 -    return -1;
    8.79 -}
    8.80 -
    8.81 -/* 
    8.82 - * @property - string to check against the filter list
    8.83 - * @filter   - NULL terminated list of strings 
    8.84 - *
    8.85 - * compare @property string to each string in @filter
    8.86 - *
    8.87 - * return 1 if @property matches any filter, otherwise 0
    8.88 - *
    8.89 - */
    8.90 -static int match(const char *property, const char **filter)
    8.91 -{
    8.92 -    int i;
    8.93 -    
    8.94 -    for (i=0; filter[i] != NULL; i++) {
    8.95 -        /* compare the filter to property */
    8.96 -        if (strncmp(property, filter[i], strlen(filter[i])) == 0)
    8.97 -            return 1;
    8.98 -    }
    8.99 -
   8.100 -    return 0;
   8.101 -}
   8.102 -
   8.103 -/*
   8.104 - * copy the node at @dirpath filtering out any properties that match in @propfilter
   8.105 - */
   8.106 -static int copynode(struct ft_cxt *cxt, const char *dirpath, const char **propfilter)
   8.107 -{   
   8.108 -    struct dirent *tree;
   8.109 -    struct stat st;
   8.110 -    DIR *dir;
   8.111 -    char fullpath[MAX_PATH];
   8.112 -    char *bname = NULL;
   8.113 -    char *basec = NULL;
   8.114 -    int saved_errno;
   8.115 -
   8.116 -    if ((dir = opendir(dirpath)) == NULL) {
   8.117 -        PERROR("%s: failed to open dir %s", __func__, dirpath);
   8.118 -        return -1;
   8.119 -    }
   8.120 -
   8.121 -    while (1) {
   8.122 -        if ((tree = readdir(dir)) == NULL)
   8.123 -            break;  /* reached end of directory entries */
   8.124 -
   8.125 -        /* ignore . and .. */
   8.126 -        if (strcmp(tree->d_name,"." ) == 0 || strcmp(tree->d_name,"..") == 0)
   8.127 -            continue;
   8.128 -
   8.129 -        /* build full path name of the file, for stat() */
   8.130 -        if (snprintf(fullpath, sizeof(fullpath), "%s/%s", dirpath,
   8.131 -                     tree->d_name) >= sizeof(fullpath)) {
   8.132 -            PERROR("%s: failed to build full path", __func__);
   8.133 -            goto error;
   8.134 -        }
   8.135 -
   8.136 -        /* stat the entry */
   8.137 -        if (stat(fullpath, &st) < 0) {
   8.138 -            PERROR("%s: failed to stat file %s", __func__, fullpath);
   8.139 -            goto error;
   8.140 -        }
   8.141 -
   8.142 -        if (S_ISDIR(st.st_mode)) {
   8.143 -            /* start a new node for a dir */
   8.144 -            ft_begin_node(cxt, tree->d_name);
   8.145 -
   8.146 -            /* copy everything in this dir */
   8.147 -            if (copynode(cxt, fullpath, propfilter) < 0) {
   8.148 -                PERROR("%s: failed to copy node @ %s", __func__, fullpath);
   8.149 -                goto error;
   8.150 -            }
   8.151 -
   8.152 -            /* end the node */
   8.153 -            ft_end_node(cxt);
   8.154 -        }
   8.155 -        /* add files in dir as properties */
   8.156 -        else if (S_ISREG(st.st_mode)) {
   8.157 -
   8.158 -            if ((basec = strdup(fullpath)) == NULL) {
   8.159 -                PERROR("%s: failed to dupe string", __func__);
   8.160 -                goto error;
   8.161 -            }
   8.162 -
   8.163 -            if ((bname = basename(basec)) == NULL) {
   8.164 -                PERROR("%s: basename() failed", __func__);
   8.165 -                goto error;
   8.166 -            }
   8.167 -
   8.168 -            /* only add files that don't match the property filter string */
   8.169 -            if (!match(bname, propfilter)) {
   8.170 -                char data[BUFSIZE];
   8.171 -                int len;
   8.172 -
   8.173 -                /* snarf the data and push into the property */
   8.174 -                if ((len = readfile(fullpath, data, sizeof(data))) < 0) {
   8.175 -                    PERROR("%s: failed to read data from file %s", __func__,
   8.176 -                                                                   fullpath);
   8.177 -                    goto error;
   8.178 -                }
   8.179 -                ft_prop(cxt, tree->d_name, data, len);
   8.180 -
   8.181 -            }
   8.182 -
   8.183 -            /* strdup mallocs memory */
   8.184 -            if (basec != NULL ) {
   8.185 -                free(basec);
   8.186 -                basec = NULL;
   8.187 -            }
   8.188 -
   8.189 -        }
   8.190 -    }
   8.191 -
   8.192 -    closedir(dir);
   8.193 -    return 0;
   8.194 -
   8.195 -error:
   8.196 -    saved_errno = errno;
   8.197 -
   8.198 -    /* strdup mallocs memory */
   8.199 -    if (basec != NULL ) {
   8.200 -        free(basec);
   8.201 -        basec = NULL;
   8.202 -    }
   8.203 -
   8.204 -    closedir(dir);
   8.205 -
   8.206 -    errno = saved_errno;
   8.207 -    return -1;
   8.208 -}
   8.209 -
   8.210 -static int find_cpu0(char *cpupath, int len)
   8.211 -{   
   8.212 -    const char path[] = "/proc/device-tree/cpus";
   8.213 -    const char device[] = "device_type";
   8.214 -    const char dev_cpu[] = "cpu";
   8.215 -    const char reg[] = "reg";
   8.216 -    char data[sizeof(dev_cpu)];
   8.217 -    char prop[MAX_PATH];
   8.218 -    char node[MAX_PATH];
   8.219 -    struct dirent *tree;
   8.220 -    struct stat st;
   8.221 -    DIR* dir;
   8.222 -    int saved_errno;
   8.223 -    int found = 0;
   8.224 -
   8.225 -    if ((dir = opendir(path)) == NULL) {
   8.226 -        PERROR("%s: failed to open directory %s", __func__, path);
   8.227 -        return -1;
   8.228 -    }    
   8.229 -
   8.230 -    while (!found) {
   8.231 -
   8.232 -        if ((tree = readdir(dir)) == NULL)
   8.233 -            break;  /* reached end of directory entries */
   8.234 -
   8.235 -        /* ignore ., .. */
   8.236 -        if (strcmp(tree->d_name,"." ) == 0 || strcmp(tree->d_name,"..") == 0)
   8.237 -            continue;
   8.238 -
   8.239 -        /* build full path name of the file, for stat() */
   8.240 -        if (snprintf(node, sizeof(node), "%s/%s", path,
   8.241 -                     tree->d_name) >= sizeof(node)) {
   8.242 -            PERROR("%s: failed to concat strings", __func__);
   8.243 -            goto error;
   8.244 -        }
   8.245 -
   8.246 -        /* stat the entry */
   8.247 -        if (stat(node, &st) < 0) {
   8.248 -            PERROR("%s: failed to stat file %s", __func__, node);
   8.249 -            /* something funny happen in /proc/device-tree, but march onward */
   8.250 -            continue;
   8.251 -        }
   8.252 -
   8.253 -        /* for each dir, check the device_type property until we find 'cpu'*/
   8.254 -        if (S_ISDIR(st.st_mode)) {
   8.255 -
   8.256 -            /* construct path to device_type */
   8.257 -            if (snprintf(prop, sizeof(prop), "%s/%s", node,
   8.258 -                         device) >= sizeof(prop)) {
   8.259 -                PERROR("%s: failed to concat strings", __func__);
   8.260 -                goto error;
   8.261 -            }
   8.262 -
   8.263 -            /* read device_type into buffer */
   8.264 -            if ((readfile(prop, data, sizeof(data))) < 0) {
   8.265 -                PERROR("%s: failed to read data from file %s", __func__, prop);
   8.266 -                goto error;
   8.267 -            }
   8.268 -
   8.269 -            /* if the device_type is 'cpu',  and reg is 0 
   8.270 -             * return the path where we found it */
   8.271 -            if (strcmp(data, "cpu") == 0) {
   8.272 -
   8.273 -                /* construct path to reg */
   8.274 -                if (snprintf(prop, sizeof(prop), "%s/%s", node,
   8.275 -                             reg) >= sizeof(prop)) {
   8.276 -                    PERROR("%s: failed to concat strings", __func__);
   8.277 -                    goto error;
   8.278 -                }
   8.279 -
   8.280 -                /* using data buffer since reg and device_type values have same size */
   8.281 -                if ((readfile(prop, data, sizeof(data))) < 0) {
   8.282 -                    PERROR("%s: failed to read data from file %s", __func__, prop);
   8.283 -                    goto error;
   8.284 -                }
   8.285 -
   8.286 -                /* now check property "reg" for value 0 */
   8.287 -                if ((u32)*data == 0) {
   8.288 -                    if (snprintf(cpupath, len, "%s", node) >= len) {
   8.289 -                        PERROR("%s: failed to copy cpupath", __func__);
   8.290 -                        goto error;
   8.291 -                    }
   8.292 -                    found = 1;
   8.293 -                }
   8.294 -            }
   8.295 -        }
   8.296 -    }
   8.297 -
   8.298 -    closedir(dir);
   8.299 -    return found;
   8.300 -
   8.301 -error:
   8.302 -    saved_errno = errno;
   8.303 -    closedir(dir);
   8.304 -    errno = saved_errno;
   8.305 -    return -1;
   8.306 -}
   8.307 -
   8.308 -void free_devtree(struct ft_cxt *root)
   8.309 -{
   8.310 -    if ((root != NULL) && root->bph != NULL) {
   8.311 -        free(root->bph);
   8.312 -        root->bph = NULL;
   8.313 -    }
   8.314 -}
   8.315 -
   8.316 -int make_devtree(struct ft_cxt *root,
   8.317 -                 struct xc_dom_image *dom,
   8.318 -                 unsigned long shadow_mb)
   8.319 -{
   8.320 -    struct boot_param_header *bph = NULL;
   8.321 -    uint64_t val[2];
   8.322 -    uint32_t val32[2];
   8.323 -    uint64_t shared_info_paddr = dom->shared_info_pfn << PAGE_SHIFT;
   8.324 -    uint64_t xenstore_paddr = dom->xenstore_pfn << PAGE_SHIFT;
   8.325 -    uint64_t console_paddr = dom->console_pfn << PAGE_SHIFT;
   8.326 -    long remaining;
   8.327 -    unsigned long ramdisk_start;
   8.328 -    unsigned long ramdisk_size;
   8.329 -    unsigned long rma_bytes = 1 << dom->realmodearea_log;
   8.330 -    int64_t shadow_mb_log;
   8.331 -    uint64_t pft_size;
   8.332 -    char cpupath[MAX_PATH];
   8.333 -    const char *propfilter[] = { "ibm", "linux,", NULL };
   8.334 -    char *cpupath_copy = NULL;
   8.335 -    char *cpuname = NULL;
   8.336 -    int saved_errno;
   8.337 -    int dtb_fd = -1;
   8.338 -    uint32_t cpu0_phandle = get_phandle();
   8.339 -    uint32_t xen_phandle = get_phandle();
   8.340 -    uint32_t rma_phandle = get_phandle();
   8.341 -
   8.342 -    /* initialize bph to prevent double free on error path */
   8.343 -    root->bph = NULL;
   8.344 -
   8.345 -    /* carve out space for bph */
   8.346 -    if ((bph = (struct boot_param_header *)malloc(BPH_SIZE)) == NULL) {
   8.347 -        PERROR("%s: Failed to malloc bph buffer size", __func__);
   8.348 -        goto error;
   8.349 -    }
   8.350 -
   8.351 -    /* NB: struct ft_cxt root defined at top of file */
   8.352 -    /* root = Tree() */
   8.353 -    ft_begin(root, bph, BPH_SIZE);
   8.354 -
   8.355 -    /* you MUST set reservations BEFORE _starting_the_tree_ */
   8.356 -
   8.357 -    /* reserve shared_info_t page */
   8.358 -    if (shared_info_paddr) {
   8.359 -        val[0] = cpu_to_be64((u64) shared_info_paddr);
   8.360 -        val[1] = cpu_to_be64((u64) PAGE_SIZE);
   8.361 -        ft_add_rsvmap(root, val[0], val[1]);
   8.362 -    }
   8.363 -
   8.364 -    /* reserve console page for domU */
   8.365 -    if (console_paddr) {
   8.366 -        val[0] = cpu_to_be64((u64) console_paddr);
   8.367 -        val[1] = cpu_to_be64((u64) PAGE_SIZE);
   8.368 -        ft_add_rsvmap(root, val[0], val[1]);
   8.369 -    }
   8.370 -
   8.371 -    /* reserve xen store page for domU */
   8.372 -    if (xenstore_paddr) {
   8.373 -        val[0] = cpu_to_be64((u64) xenstore_paddr);
   8.374 -        val[1] = cpu_to_be64((u64) PAGE_SIZE);
   8.375 -        ft_add_rsvmap(root, val[0], val[1]);
   8.376 -    }
   8.377 -
   8.378 -    /* reserve space for initrd if needed */
   8.379 -    ramdisk_start = dom->ramdisk_seg.pfn << PAGE_SHIFT;
   8.380 -    ramdisk_size = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
   8.381 -    if (ramdisk_size > 0) {
   8.382 -        val[0] = cpu_to_be64((u64) ramdisk_start);
   8.383 -        val[1] = cpu_to_be64((u64) ramdisk_size);
   8.384 -        ft_add_rsvmap(root, val[0], val[1]);
   8.385 -    }
   8.386 -
   8.387 -    /* NB: ft_add_rsvmap() already terminates with a NULL reservation for us */
   8.388 -
   8.389 -    /* done with reservations, _starting_the_tree_ */
   8.390 -    ft_begin_tree(root);
   8.391 -
   8.392 -    /* make root node */
   8.393 -    ft_begin_node(root, "");
   8.394 -
   8.395 -    /* root.addprop('device_type', 'chrp-but-not-really\0') */
   8.396 -    ft_prop_str(root, "device_type", "chrp-but-not-really");
   8.397 -
   8.398 -    /* root.addprop('#size-cells', 2) */
   8.399 -    ft_prop_int(root, "#size-cells", 2);
   8.400 -
   8.401 -    /* root.addprop('#address-cells', 2) */
   8.402 -    ft_prop_int(root, "#address-cells", 2);
   8.403 -
   8.404 -    /* root.addprop('model', 'Momentum,Maple-D\0') */
   8.405 -    ft_prop_str(root, "model", "Momentum,Maple-D");
   8.406 -
   8.407 -    /* root.addprop('compatible', 'Momentum,Maple\0') */
   8.408 -    ft_prop_str(root, "compatible", "Momentum,Maple");
   8.409 -
   8.410 -    /* start chosen node */
   8.411 -    ft_begin_node(root, "chosen");
   8.412 -
   8.413 -    /* chosen.addprop('cpu', cpu0.get_phandle()) */
   8.414 -    ft_prop_int(root, "cpu", cpu0_phandle);
   8.415 -
   8.416 -    /* chosen.addprop('rma', rma.get_phandle()) */
   8.417 -    ft_prop_int(root, "memory", rma_phandle);
   8.418 -
   8.419 -    /* chosen.addprop('linux,stdout-path', '/xen/console\0') */
   8.420 -    ft_prop_str(root, "linux,stdout-path", "/xen/console");
   8.421 -
   8.422 -    /* chosen.addprop('interrupt-controller, xen.get_phandle()) */
   8.423 -    ft_prop_int(root, "interrupt-controller", xen_phandle);
   8.424 -
   8.425 -    /* chosen.addprop('bootargs', imghandler.cmdline + '\0') */
   8.426 -    if (dom->cmdline != NULL)
   8.427 -        ft_prop_str(root, "bootargs", dom->cmdline);
   8.428 -
   8.429 -    /* mark where the initrd is, if present */
   8.430 -    if (ramdisk_size > 0) {
   8.431 -        val[0] = cpu_to_be64((u64) ramdisk_start);
   8.432 -        val[1] = cpu_to_be64((u64) ramdisk_start + ramdisk_size);
   8.433 -        ft_prop(root, "linux,initrd-start", &(val[0]), sizeof(val[0]));
   8.434 -        ft_prop(root, "linux,initrd-end", &(val[1]), sizeof(val[1]));
   8.435 -    }
   8.436 -
   8.437 -    /* end chosen node */
   8.438 -    ft_end_node(root);
   8.439 -
   8.440 -    /* xen = root.addnode('xen') */
   8.441 -    ft_begin_node(root, "xen");
   8.442 -
   8.443 -    /*  xen.addprop('version', 'Xen-3.0-unstable\0') */
   8.444 -    ft_prop_str(root, "compatible", "Xen-3.0-unstable");
   8.445 -
   8.446 -    /* xen.addprop('reg', long(imghandler.vm.domid), long(0)) */
   8.447 -    val[0] = cpu_to_be64((u64) dom->guest_domid);
   8.448 -    val[1] = cpu_to_be64((u64) 0);
   8.449 -    ft_prop(root, "reg", val, sizeof(val));
   8.450 -
   8.451 -    /* point to shared_info_t page base addr */
   8.452 -    val[0] = cpu_to_be64((u64) shared_info_paddr);
   8.453 -    val[1] = cpu_to_be64((u64) PAGE_SIZE);
   8.454 -    ft_prop(root, "shared-info", val, sizeof(val));
   8.455 -
   8.456 -    /* xen.addprop('domain-name', imghandler.vm.getName() + '\0') */
   8.457 -    /* libxc doesn't know the domain name, that is purely a xend thing */
   8.458 -    /* ft_prop_str(root, "domain-name", domain_name); */
   8.459 -
   8.460 -    /* add xen/linux,phandle for chosen/interrupt-controller */
   8.461 -    ft_prop_int(root, "linux,phandle", xen_phandle);
   8.462 -
   8.463 -    if (console_paddr != 0) {
   8.464 -        /* xencons = xen.addnode('console') */
   8.465 -        ft_begin_node(root, "console");
   8.466 -
   8.467 -        /* console_paddr */
   8.468 -        val[0] = cpu_to_be64((u64) console_paddr);
   8.469 -        val[1] = cpu_to_be64((u64) PAGE_SIZE);
   8.470 -        ft_prop(root, "reg", val, sizeof(val));
   8.471 -
   8.472 -        /* xencons.addprop('interrupts', console_evtchn, 0) */
   8.473 -        val32[0] = cpu_to_be32((u32) dom->console_evtchn);
   8.474 -        val32[1] = cpu_to_be32((u32) 0);
   8.475 -        ft_prop(root, "interrupts", val32, sizeof(val32));
   8.476 -
   8.477 -        /* end of console */
   8.478 -        ft_end_node(root);
   8.479 -    }
   8.480 -
   8.481 -    if (xenstore_paddr != 0) {
   8.482 -        /* start store node */
   8.483 -        ft_begin_node(root, "store");
   8.484 -
   8.485 -        /* store paddr */
   8.486 -        val[0] = cpu_to_be64((u64) xenstore_paddr);
   8.487 -        val[1] = cpu_to_be64((u64) PAGE_SIZE);
   8.488 -        ft_prop(root, "reg", val, sizeof(val));
   8.489 -
   8.490 -        /* store event channel */
   8.491 -        val32[0] = cpu_to_be32((u32) dom->xenstore_evtchn);
   8.492 -        val32[1] = cpu_to_be32((u32) 0);
   8.493 -        ft_prop(root, "interrupts", val32, sizeof(val32));
   8.494 -
   8.495 -        /* end of store */
   8.496 -        ft_end_node(root);
   8.497 -    }
   8.498 -
   8.499 -    /* end of xen node */
   8.500 -    ft_end_node(root);
   8.501 -
   8.502 -    /* rma = root.addnode('memory@0') */
   8.503 -    ft_begin_node(root, "memory@0");
   8.504 -
   8.505 -    /* rma.addprop('reg', long(0), long(rma_bytes)) */
   8.506 -    val[0] = cpu_to_be64((u64) 0);
   8.507 -    val[1] = cpu_to_be64((u64) rma_bytes);
   8.508 -    ft_prop(root, "reg", val, sizeof(val));
   8.509 -
   8.510 -    /* rma.addprop('device_type', 'memory\0') */
   8.511 -    ft_prop_str(root, "device_type", "memory");
   8.512 -
   8.513 -    /* add linux,phandle for chosen/rma node */
   8.514 -    ft_prop_int(root, "linux,phandle", rma_phandle);
   8.515 -
   8.516 -    /* end of memory@0 */
   8.517 -    ft_end_node(root);
   8.518 -
   8.519 -    /* calculate remaining bytes from total - rma size */
   8.520 -    remaining = (dom->total_pages << PAGE_SHIFT) - rma_bytes;
   8.521 -
   8.522 -    /* memory@<rma_bytes> is all remaining memory after RMA */
   8.523 -    if (remaining > 0)
   8.524 -    {
   8.525 -        char mem[MAX_PATH];
   8.526 -        
   8.527 -        if (snprintf(mem, sizeof(mem), "memory@%lx",
   8.528 -                     rma_bytes) >= sizeof(mem)) {
   8.529 -            PERROR("%s: failed to build memory string", __func__);
   8.530 -            goto error;
   8.531 -        }
   8.532 -
   8.533 -        /* memory@<rma_bytes> is all remaining memory after RMA */
   8.534 -        ft_begin_node(root, mem);
   8.535 -
   8.536 -        /* mem.addprop('reg', long(rma_bytes), long(remaining)) */
   8.537 -        val[0] = cpu_to_be64((u64) rma_bytes);
   8.538 -        val[1] = cpu_to_be64((u64) remaining);
   8.539 -        ft_prop(root, "reg", val, sizeof(val));
   8.540 -
   8.541 -        /* mem.addprop('device_type', 'memory\0') */
   8.542 -        ft_prop_str(root, "device_type", "memory");
   8.543 -
   8.544 -        /* end memory@<rma_bytes> node */
   8.545 -        ft_end_node(root);
   8.546 -    }
   8.547 -
   8.548 -    /* add CPU nodes */
   8.549 -    /* cpus = root.addnode('cpus') */
   8.550 -    ft_begin_node(root, "cpus");
   8.551 -
   8.552 -    /* cpus.addprop('smp-enabled') */
   8.553 -    ft_prop(root, "smp-enabled", NULL, 0);
   8.554 -
   8.555 -    /* cpus.addprop('#size-cells', 0) */
   8.556 -    ft_prop_int(root, "#size-cells", 0);
   8.557 -
   8.558 -    /* cpus.addprop('#address-cells', 1) */
   8.559 -    ft_prop_int(root, "#address-cells", 1);
   8.560 -
   8.561 -    /*
   8.562 -     * Copy all properties the system firmware gave us from a 
   8.563 -     * CPU node in the device tree.
   8.564 -     */
   8.565 -    if (find_cpu0(cpupath, sizeof(cpupath)) <= 0) {
   8.566 -        PERROR("%s: failed find cpu0 node in host devtree", __func__);
   8.567 -        goto error;
   8.568 -    }
   8.569 -
   8.570 -    /* get the basename from path to cpu device */
   8.571 -    if ((cpupath_copy = strdup(cpupath)) == NULL) {
   8.572 -        PERROR("%s: failed to dupe string", __func__);
   8.573 -        goto error;
   8.574 -    }
   8.575 -    if ((cpuname = basename(cpupath_copy)) == NULL) {
   8.576 -        PERROR("%s: basename() failed", __func__);
   8.577 -        goto error;
   8.578 -    }
   8.579 -     
   8.580 -    /* start node for the cpu */
   8.581 -    ft_begin_node(root, cpuname);
   8.582 -
   8.583 -    /* strdup() mallocs memory */
   8.584 -    if ( cpupath_copy != NULL ) {
   8.585 -        free(cpupath_copy);
   8.586 -        cpupath_copy = NULL;
   8.587 -    }
   8.588 -
   8.589 -    /* copy over most properties from host tree for cpu */
   8.590 -    if (copynode(root, cpupath, propfilter) < 0) {
   8.591 -        PERROR("%s: failed to copy node", __func__);
   8.592 -            goto error;
   8.593 -    }
   8.594 -
   8.595 -    /* calculate the pft-size */
   8.596 -    shadow_mb_log = (int)log2((double)shadow_mb);
   8.597 -    pft_size = shadow_mb_log + 20;
   8.598 -
   8.599 -    val32[0] = cpu_to_be32((u32) 0);
   8.600 -    val32[1] = cpu_to_be32((u32) pft_size);
   8.601 -    ft_prop(root, "ibm,pft-size", val32, sizeof(val32));
   8.602 -
   8.603 -    /* make phandle for cpu0 */
   8.604 -    ft_prop_int(root, "linux,phandle", cpu0_phandle);
   8.605 -
   8.606 -    /* end <cpuname> node */
   8.607 -    ft_end_node(root);
   8.608 -
   8.609 -    /* end cpus node */
   8.610 -    ft_end_node(root);
   8.611 -
   8.612 -    /* end root node */
   8.613 -    ft_end_node(root);
   8.614 -
   8.615 -    /* end of the tree */
   8.616 -    if (ft_end_tree(root) != 0) {
   8.617 -        PERROR("%s: failed to end tree", __func__);
   8.618 -        goto error;
   8.619 -    }
   8.620 -
   8.621 -    /* write a copy of the tree to a file */
   8.622 -    if ((dtb_fd = creat(DTB_FILE, S_IRUSR | S_IWUSR)) == -1) {
   8.623 -        PERROR("%s: failed to open file %s", __func__, DTB_FILE);
   8.624 -        goto error;
   8.625 -    }
   8.626 -
   8.627 -    if (write(dtb_fd, (const void *)bph, bph->totalsize) != bph->totalsize) {
   8.628 -        PERROR("%s: failed to write blob to file", __func__);
   8.629 -        goto error; 
   8.630 -    }
   8.631 -
   8.632 -    return 0;
   8.633 - 
   8.634 -error:
   8.635 -    saved_errno = errno;
   8.636 -
   8.637 -    /* strdup() mallocs memory */
   8.638 -    if ( cpupath_copy != NULL ) {
   8.639 -        free(cpupath_copy);
   8.640 -        cpupath_copy = NULL;
   8.641 -    }
   8.642 -
   8.643 -    /* free bph buffer */
   8.644 -    free_devtree(root);
   8.645 -
   8.646 -    if (dtb_fd)
   8.647 -        close(dtb_fd);
   8.648 -
   8.649 -    errno = saved_errno;
   8.650 -    return -1;
   8.651 -}
     9.1 --- a/tools/libxc/powerpc64/mk_flatdevtree.h	Thu May 08 13:15:45 2008 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,37 +0,0 @@
     9.4 -/*
     9.5 - * This program is free software; you can redistribute it and/or modify
     9.6 - * it under the terms of the GNU General Public License as published by
     9.7 - * the Free Software Foundation; either version 2 of the License, or
     9.8 - * (at your option) any later version.
     9.9 - *
    9.10 - * This program is distributed in the hope that it will be useful,
    9.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.13 - * GNU General Public License for more details.
    9.14 - *
    9.15 - * You should have received a copy of the GNU General Public License
    9.16 - * along with this program; if not, write to the Free Software
    9.17 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    9.18 - *
    9.19 - * Copyright IBM Corporation 2007
    9.20 - *
    9.21 - * Authors: Ryan Harper <ryanh@us.ibm.com>
    9.22 - */
    9.23 -
    9.24 -#ifndef MK_FLATDEVTREE_H
    9.25 -#define MK_FLATDEVTREE_H
    9.26 -
    9.27 -#include "flatdevtree_env.h"
    9.28 -#include "flatdevtree.h"
    9.29 -
    9.30 -extern void free_devtree(struct ft_cxt *root);
    9.31 -extern int make_devtree(struct ft_cxt *root,
    9.32 -                        struct xc_dom_image *dom,
    9.33 -                        unsigned long shadow_mb);
    9.34 -
    9.35 -#define MAX_PATH 200
    9.36 -#define BUFSIZE 1024
    9.37 -#define BPH_SIZE 16*1024
    9.38 -#define DTB_FILE "/tmp/domU.dtb"
    9.39 -
    9.40 -#endif /* MK_FLATDEVTREE_H */
    10.1 --- a/tools/libxc/powerpc64/xc_memory.c	Thu May 08 13:15:45 2008 +0100
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,42 +0,0 @@
    10.4 -/*
    10.5 - * This program is free software; you can redistribute it and/or modify
    10.6 - * it under the terms of the GNU General Public License as published by
    10.7 - * the Free Software Foundation; either version 2 of the License, or
    10.8 - * (at your option) any later version.
    10.9 - *
   10.10 - * This program is distributed in the hope that it will be useful,
   10.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.13 - * GNU General Public License for more details.
   10.14 - *
   10.15 - * You should have received a copy of the GNU General Public License
   10.16 - * along with this program; if not, write to the Free Software
   10.17 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   10.18 - *
   10.19 - * Copyright (C) IBM Corporation 2006
   10.20 - *
   10.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   10.22 - */
   10.23 -
   10.24 -#include "xc_private.h"
   10.25 -#include <xen/domctl.h>
   10.26 -
   10.27 -int xc_alloc_real_mode_area(int xc_handle,
   10.28 -                            uint32_t domain,
   10.29 -                            unsigned int log)
   10.30 -{
   10.31 -    DECLARE_DOMCTL;
   10.32 -    int err;
   10.33 -
   10.34 -    domctl.cmd = XEN_DOMCTL_real_mode_area;
   10.35 -    domctl.domain = (domid_t)domain;
   10.36 -    domctl.u.real_mode_area.log = log;
   10.37 -
   10.38 -    err = do_domctl(xc_handle, &domctl);
   10.39 -
   10.40 -    if (err)
   10.41 -        DPRINTF("Failed real mode area allocation for dom %u (log %u)\n",
   10.42 -                domain, log);
   10.43 -
   10.44 -    return err;
   10.45 -}
    11.1 --- a/tools/libxc/xc_core.h	Thu May 08 13:15:45 2008 +0100
    11.2 +++ b/tools/libxc/xc_core.h	Thu May 08 13:40:40 2008 +0100
    11.3 @@ -148,8 +148,6 @@ int xc_core_arch_map_p2m(int xc_handle, 
    11.4  # include "xc_core_x86.h"
    11.5  #elif defined (__ia64__)
    11.6  # include "xc_core_ia64.h"
    11.7 -#elif defined (__powerpc__)
    11.8 -# include "xc_core_powerpc.h"
    11.9  #else
   11.10  # error "unsupported architecture"
   11.11  #endif
    12.1 --- a/tools/libxc/xc_core_powerpc.c	Thu May 08 13:15:45 2008 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,79 +0,0 @@
    12.4 -/*
    12.5 - * This program is free software; you can redistribute it and/or modify
    12.6 - * it under the terms of the GNU General Public License as published by
    12.7 - * the Free Software Foundation; either version 2 of the License, or
    12.8 - * (at your option) any later version.
    12.9 - *
   12.10 - * This program is distributed in the hope that it will be useful,
   12.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.13 - * GNU General Public License for more details.
   12.14 - *
   12.15 - * You should have received a copy of the GNU General Public License
   12.16 - * along with this program; if not, write to the Free Software
   12.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   12.18 - *
   12.19 - * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp>
   12.20 - *                    VA Linux Systems Japan K.K.
   12.21 - * Copyright IBM Corp. 2007
   12.22 - *
   12.23 - * Authors: Isaku Yamahata <yamahata at valinux co jp>
   12.24 - *          Hollis Blanchard <hollisb@us.ibm.com>
   12.25 - *
   12.26 - */
   12.27 -
   12.28 -#include "xg_private.h"
   12.29 -#include "xc_core.h"
   12.30 -
   12.31 -int
   12.32 -xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info)
   12.33 -{
   12.34 -	/* All PowerPC domU are autotranslated. */
   12.35 -	return 1;
   12.36 -}
   12.37 -
   12.38 -int
   12.39 -xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info,
   12.40 -                     shared_info_t *live_shinfo, xen_pfn_t **live_p2m,
   12.41 -                     unsigned long *pfnp)
   12.42 -{
   12.43 -	/* All PowerPC domU are autotranslated. */
   12.44 -    errno = ENOSYS;
   12.45 -    return -1;
   12.46 -}
   12.47 -
   12.48 -int
   12.49 -xc_core_arch_memory_map_get(int xc_handle, struct xc_core_arch_context *unused,
   12.50 -                            xc_dominfo_t *info, shared_info_t *live_shinfo,
   12.51 -                            xc_core_memory_map_t **mapp,
   12.52 -                            unsigned int *nr_entries)
   12.53 -{
   12.54 -    xc_core_memory_map_t *map = NULL;
   12.55 -
   12.56 -    map = malloc(sizeof(*map));
   12.57 -    if (!map) {
   12.58 -        PERROR("Could not allocate memory");
   12.59 -        goto out;
   12.60 -    }
   12.61 -
   12.62 -    map->addr = 0;
   12.63 -    map->size = info->max_memkb * 1024;
   12.64 -
   12.65 -    *mapp = map;
   12.66 -    *nr_entries = 1;
   12.67 -    return 0;
   12.68 -
   12.69 -out:
   12.70 -    free(map);
   12.71 -    return -1;
   12.72 -}
   12.73 -
   12.74 -/*
   12.75 - * Local variables:
   12.76 - * mode: C
   12.77 - * c-set-style: "BSD"
   12.78 - * c-basic-offset: 4
   12.79 - * tab-width: 4
   12.80 - * indent-tabs-mode: nil
   12.81 - * End:
   12.82 - */
    13.1 --- a/tools/libxc/xc_core_powerpc.h	Thu May 08 13:15:45 2008 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,58 +0,0 @@
    13.4 -/*
    13.5 - * This program is free software; you can redistribute it and/or modify
    13.6 - * it under the terms of the GNU General Public License as published by
    13.7 - * the Free Software Foundation; either version 2 of the License, or
    13.8 - * (at your option) any later version.
    13.9 - *
   13.10 - * This program is distributed in the hope that it will be useful,
   13.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.13 - * GNU General Public License for more details.
   13.14 - *
   13.15 - * You should have received a copy of the GNU General Public License
   13.16 - * along with this program; if not, write to the Free Software
   13.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   13.18 - *
   13.19 - * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp>
   13.20 - *                    VA Linux Systems Japan K.K.
   13.21 - *
   13.22 - */
   13.23 -
   13.24 -#ifndef XC_CORE_POWERPC_H
   13.25 -#define XC_CORE_POWERPC_H
   13.26 -
   13.27 -#define ELF_ARCH_DATA           ELFDATA2MSB
   13.28 -#define ELF_ARCH_MACHINE        EM_PPC64
   13.29 -
   13.30 -struct xc_core_arch_context {
   13.31 -    /* nothing */
   13.32 -};
   13.33 -
   13.34 -#define xc_core_arch_context_init(arch_ctxt)            do {} while (0)
   13.35 -#define xc_core_arch_context_free(arch_ctxt)            do {} while (0)
   13.36 -#define xc_core_arch_context_get(arch_ctxt, ctxt, xc_handle, domid) \
   13.37 -                                                                (0)
   13.38 -#define xc_core_arch_context_dump(arch_ctxt, args, dump_rtn)    (0)
   13.39 -#define xc_core_arch_gpfn_may_present(arch_ctxt, i)             (1)
   13.40 -
   13.41 -static inline int
   13.42 -xc_core_arch_context_get_shdr(struct xc_core_arch_context *arch_ctxt, 
   13.43 -                              struct xc_core_section_headers *sheaders,
   13.44 -                              struct xc_core_strtab *strtab,
   13.45 -                              uint64_t *filesz, uint64_t offset)
   13.46 -{
   13.47 -    *filesz = 0;
   13.48 -    return 0;
   13.49 -}
   13.50 -
   13.51 -#endif /* XC_CORE_POWERPC_H */
   13.52 -
   13.53 -/*
   13.54 - * Local variables:
   13.55 - * mode: C
   13.56 - * c-set-style: "BSD"
   13.57 - * c-basic-offset: 4
   13.58 - * tab-width: 4
   13.59 - * indent-tabs-mode: nil
   13.60 - * End:
   13.61 - */
    14.1 --- a/tools/libxc/xc_dom_elfloader.c	Thu May 08 13:15:45 2008 +0100
    14.2 +++ b/tools/libxc/xc_dom_elfloader.c	Thu May 08 13:40:40 2008 +0100
    14.3 @@ -43,8 +43,6 @@ static char *xc_dom_guest_type(struct xc
    14.4          return "xen-3.0-x86_64";
    14.5      case EM_IA_64:
    14.6          return elf_msb(elf) ? "xen-3.0-ia64be" : "xen-3.0-ia64";
    14.7 -    case EM_PPC64:
    14.8 -        return "xen-3.0-powerpc64";
    14.9      default:
   14.10          return "xen-3.0-unknown";
   14.11      }
    15.1 --- a/tools/libxc/xc_dom_powerpc.c	Thu May 08 13:15:45 2008 +0100
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,236 +0,0 @@
    15.4 -/*
    15.5 - * Xen domain builder -- powerpc bits.
    15.6 - *
    15.7 - * Most architecture-specific code for powerpc goes here.
    15.8 - *
    15.9 - * This code is licenced under the GPL.
   15.10 - * written 2006 by Gerd Hoffmann <kraxel@suse.de>.
   15.11 - *
   15.12 - * Copyright IBM Corp. 2007
   15.13 - *
   15.14 - * Authors: Gerd Hoffmann <kraxel@suse.de>
   15.15 - *          Hollis Blanchard <hollisb@us.ibm.com>
   15.16 - *
   15.17 - */
   15.18 -#include <stdio.h>
   15.19 -#include <stdlib.h>
   15.20 -#include <string.h>
   15.21 -#include <inttypes.h>
   15.22 -
   15.23 -#include <xen/xen.h>
   15.24 -
   15.25 -#include "xg_private.h"
   15.26 -#include "xc_dom.h"
   15.27 -#include "powerpc64/flatdevtree.h"
   15.28 -#include "powerpc64/mk_flatdevtree.h"
   15.29 -
   15.30 -#define RMA_LOG 26 /* 64 MB */
   15.31 -#define EXTENT_LOG 24 /* 16 MB */
   15.32 -#define EXTENT_ORDER (EXTENT_LOG - PAGE_SHIFT)
   15.33 -
   15.34 -/* ------------------------------------------------------------------------ */
   15.35 -
   15.36 -static int alloc_magic_pages(struct xc_dom_image *dom)
   15.37 -{
   15.38 -    struct ft_cxt devtree;
   15.39 -    void *guest_devtree;
   15.40 -    unsigned long shadow_mb;
   15.41 -    int rma_pages;
   15.42 -    int rc;
   15.43 -
   15.44 -    /* Allocate special pages from the end of the RMA. */
   15.45 -    rma_pages = 1 << (dom->realmodearea_log - PAGE_SHIFT);
   15.46 -    dom->shared_info_pfn = --rma_pages;
   15.47 -    dom->console_pfn = --rma_pages;
   15.48 -    dom->xenstore_pfn = --rma_pages;
   15.49 -
   15.50 -    /* Gather shadow allocation info for the device tree. */
   15.51 -    rc = xc_shadow_control(dom->guest_xc, dom->guest_domid,
   15.52 -                           XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION, NULL, 0, 
   15.53 -                           &shadow_mb, 0, NULL);
   15.54 -    if (rc < 0 || shadow_mb == 0) {
   15.55 -        xc_dom_printf("Couldn't get shadow allocation size or it was 0.\n");
   15.56 -        return rc;
   15.57 -    }
   15.58 -
   15.59 -    /* Build device tree. */
   15.60 -    rc = make_devtree(&devtree, dom, shadow_mb);
   15.61 -    if (rc < 0) {
   15.62 -        xc_dom_printf("Failed to create flattened device tree.\n");
   15.63 -        return rc;
   15.64 -    }
   15.65 -
   15.66 -    /* Find a spot for it. */
   15.67 -    rc = xc_dom_alloc_segment(dom, &dom->devicetree_seg, "devtree", 0,
   15.68 -                              devtree.bph->totalsize);
   15.69 -    if (rc)
   15.70 -        goto out;
   15.71 -
   15.72 -    /* Copy the device tree into place. */
   15.73 -    guest_devtree = xc_dom_seg_to_ptr(dom, &dom->devicetree_seg);
   15.74 -    if (!guest_devtree) {
   15.75 -        xc_dom_printf("Couldn't map guest memory for device tree.\n");
   15.76 -        rc = -1;
   15.77 -        goto out;
   15.78 -    }
   15.79 -    memcpy(guest_devtree, devtree.bph, devtree.bph->totalsize);
   15.80 -
   15.81 -out:
   15.82 -    free_devtree(&devtree);
   15.83 -    return rc;
   15.84 -}
   15.85 -
   15.86 -static int shared_info(struct xc_dom_image *dom, void *ptr)
   15.87 -{
   15.88 -    shared_info_t *shared_info = ptr;
   15.89 -
   15.90 -    xc_dom_printf("%s: called\n", __FUNCTION__);
   15.91 -
   15.92 -    memset(shared_info, 0, sizeof(*shared_info));
   15.93 -    return 0;
   15.94 -}
   15.95 -
   15.96 -static int vcpu(struct xc_dom_image *dom, void *ptr)
   15.97 -{
   15.98 -    vcpu_guest_context_t *ctxt = ptr;
   15.99 -
  15.100 -    memset(ctxt, 0x55, sizeof(*ctxt));
  15.101 -    ctxt->user_regs.pc = dom->parms.virt_entry;
  15.102 -    ctxt->user_regs.msr = 0;
  15.103 -    ctxt->user_regs.gprs[1] = 0; /* Linux uses its own stack */
  15.104 -    ctxt->user_regs.gprs[3] = dom->devicetree_seg.pfn << PAGE_SHIFT;
  15.105 -    ctxt->user_regs.gprs[4] = dom->kernel_seg.pfn << PAGE_SHIFT;
  15.106 -    ctxt->user_regs.gprs[5] = 0;
  15.107 -
  15.108 -    /* There is a buggy kernel that does not zero the "local_paca", so
  15.109 -     * we must make sure this register is 0 */
  15.110 -    ctxt->user_regs.gprs[13] = 0;
  15.111 -
  15.112 -    xc_dom_printf("%s: initial vcpu:\n", __FUNCTION__);
  15.113 -    xc_dom_printf("  pc 0x%016"PRIx64", msr 0x%016"PRIx64"\n"
  15.114 -                  "  r1-5 %016"PRIx64" %016"PRIx64" %016"PRIx64" %016"PRIx64
  15.115 -                  " %016"PRIx64"\n",
  15.116 -                  ctxt->user_regs.pc, ctxt->user_regs.msr,
  15.117 -                  ctxt->user_regs.gprs[1],
  15.118 -                  ctxt->user_regs.gprs[2],
  15.119 -                  ctxt->user_regs.gprs[3],
  15.120 -                  ctxt->user_regs.gprs[4],
  15.121 -                  ctxt->user_regs.gprs[5]);
  15.122 -
  15.123 -    return 0;
  15.124 -}
  15.125 -
  15.126 -/* ------------------------------------------------------------------------ */
  15.127 -
  15.128 -static struct xc_dom_arch xc_dom_arch = {
  15.129 -    .guest_type = "xen-3.0-powerpc64",
  15.130 -    .page_shift = PAGE_SHIFT,
  15.131 -    .alloc_magic_pages = alloc_magic_pages,
  15.132 -    .shared_info = shared_info,
  15.133 -    .vcpu = vcpu,
  15.134 -};
  15.135 -
  15.136 -static void __init register_arch_hooks(void)
  15.137 -{
  15.138 -    xc_dom_register_arch_hooks(&xc_dom_arch);
  15.139 -}
  15.140 -
  15.141 -int arch_setup_meminit(struct xc_dom_image *dom)
  15.142 -{
  15.143 -    xen_pfn_t *extent_list;
  15.144 -    unsigned long total_mem = dom->total_pages << PAGE_SHIFT;
  15.145 -    unsigned long rma_bytes;
  15.146 -    unsigned long rma_nr_pages;
  15.147 -    unsigned long nr_extents;
  15.148 -    int rc = 0;
  15.149 -    int i;
  15.150 -
  15.151 -    /* XXX RMA size is processor-dependent. */
  15.152 -    dom->realmodearea_log = RMA_LOG;
  15.153 -    rma_bytes = 1 << dom->realmodearea_log;
  15.154 -    rma_nr_pages = rma_bytes >> PAGE_SHIFT;
  15.155 -
  15.156 -    xc_dom_printf("dom%u memory: %lu MB RMA, %lu MB additional.\n",
  15.157 -            dom->guest_domid, rma_bytes >> 20, (total_mem - rma_bytes) >> 20);
  15.158 -
  15.159 -    if (total_mem < rma_bytes) {
  15.160 -        xc_dom_printf("Domain must have at least %lu MB\n", rma_bytes >> 20);
  15.161 -        return -EINVAL;
  15.162 -    }
  15.163 -
  15.164 -    /* Allocate the first chunk of memory. */
  15.165 -    rc = xc_alloc_real_mode_area(dom->guest_xc, dom->guest_domid,
  15.166 -                                 dom->realmodearea_log);
  15.167 -    if (rc) {
  15.168 -        xc_dom_printf("Failed to allocate real mode area.\n");
  15.169 -        return rc;
  15.170 -    }
  15.171 -
  15.172 -    /* Allocate p2m map. */
  15.173 -    dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * dom->total_pages);
  15.174 -    if (dom->p2m_host == NULL) {
  15.175 -        xc_dom_printf("Couldn't allocate p2m map.\n");
  15.176 -        return -ENOMEM;
  15.177 -    }
  15.178 -
  15.179 -    nr_extents = (dom->total_pages - rma_nr_pages) >> EXTENT_ORDER;
  15.180 -    if (nr_extents) {
  15.181 -        /* Allocate extent list for populate_physmap() call. */
  15.182 -        extent_list = xc_dom_malloc(dom, sizeof(xen_pfn_t) * nr_extents);
  15.183 -        if (extent_list == NULL) {
  15.184 -            xc_dom_printf("Couldn't allocate extent list.\n");
  15.185 -            return -ENOMEM;
  15.186 -        }
  15.187 -
  15.188 -        /* Allocate the remaining (non-RMA) memory. */
  15.189 -        for (i = 0; i < nr_extents; i++) {
  15.190 -            /* Use PFNs above the RMA memory we already allocated. */
  15.191 -            extent_list[i] = rma_nr_pages + i * (1<<EXTENT_ORDER);
  15.192 -        }
  15.193 -        rc = xc_domain_memory_populate_physmap(dom->guest_xc, dom->guest_domid,
  15.194 -                                               nr_extents, EXTENT_ORDER, 0,
  15.195 -                                               extent_list);
  15.196 -        if (rc < 0) {
  15.197 -            xc_dom_printf("populate_physmap(0x%lx extents order %u) -> 0x%x\n",
  15.198 -                          nr_extents, EXTENT_ORDER, rc);
  15.199 -            return rc;
  15.200 -        }
  15.201 -    }
  15.202 -
  15.203 -    /* Populate the p2m map. */
  15.204 -    rc = xc_get_pfn_list(dom->guest_xc, dom->guest_domid, dom->p2m_host,
  15.205 -                         dom->total_pages);
  15.206 -    if (rc < 0) {
  15.207 -        xc_dom_printf("Couldn't get p2m translation.\n");
  15.208 -        return rc;
  15.209 -    }
  15.210 -
  15.211 -    xc_dom_printf("%s: success\n", __func__);
  15.212 -
  15.213 -    return 0;
  15.214 -}
  15.215 -
  15.216 -int arch_setup_bootearly(struct xc_dom_image *dom)
  15.217 -{
  15.218 -    xc_dom_printf("%s: doing nothing\n", __FUNCTION__);
  15.219 -    return 0;
  15.220 -}
  15.221 -
  15.222 -int arch_setup_bootlate(struct xc_dom_image *dom)
  15.223 -{
  15.224 -    unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
  15.225 -    shared_info_t *shared_info;
  15.226 -
  15.227 -    /* setup shared_info page */
  15.228 -    xc_dom_printf("%s: shared_info: mfn 0x%" PRIpfn "\n",
  15.229 -                  __FUNCTION__, dom->shared_info_mfn);
  15.230 -    shared_info = xc_map_foreign_range(dom->guest_xc, dom->guest_domid,
  15.231 -                                       page_size,
  15.232 -                                       PROT_READ | PROT_WRITE,
  15.233 -                                       dom->shared_info_mfn);
  15.234 -    if ( shared_info == NULL )
  15.235 -        return -1;
  15.236 -    dom->arch_hooks->shared_info(dom, shared_info);
  15.237 -    munmap(shared_info, page_size);
  15.238 -    return 0;
  15.239 -}
    16.1 --- a/tools/libxc/xenctrl.h	Thu May 08 13:15:45 2008 +0100
    16.2 +++ b/tools/libxc/xenctrl.h	Thu May 08 13:40:40 2008 +0100
    16.3 @@ -55,10 +55,6 @@
    16.4  #define xen_mb()   asm volatile ("mf" ::: "memory")
    16.5  #define xen_rmb()  asm volatile ("mf" ::: "memory")
    16.6  #define xen_wmb()  asm volatile ("mf" ::: "memory")
    16.7 -#elif defined(__powerpc__)
    16.8 -#define xen_mb()   asm volatile ("sync" : : : "memory")
    16.9 -#define xen_rmb()  asm volatile ("sync" : : : "memory") /* lwsync? */
   16.10 -#define xen_wmb()  asm volatile ("sync" : : : "memory") /* eieio? */
   16.11  #else
   16.12  #error "Define barriers"
   16.13  #endif
   16.14 @@ -944,11 +940,6 @@ xc_error_handler xc_set_error_handler(xc
   16.15  int xc_set_hvm_param(int handle, domid_t dom, int param, unsigned long value);
   16.16  int xc_get_hvm_param(int handle, domid_t dom, int param, unsigned long *value);
   16.17  
   16.18 -/* PowerPC specific. */
   16.19 -int xc_alloc_real_mode_area(int xc_handle,
   16.20 -                            uint32_t domid,
   16.21 -                            unsigned int log);
   16.22 -
   16.23  /* IA64 specific, nvram save */
   16.24  int xc_ia64_save_to_nvram(int xc_handle, uint32_t dom);
   16.25  
    17.1 --- a/tools/libxc/xenguest.h	Thu May 08 13:15:45 2008 +0100
    17.2 +++ b/tools/libxc/xenguest.h	Thu May 08 13:40:40 2008 +0100
    17.3 @@ -136,18 +136,4 @@ int xc_hvm_build_mem(int xc_handle,
    17.4                       const char *image_buffer,
    17.5                       unsigned long image_size);
    17.6  
    17.7 -/* PowerPC specific. */
    17.8 -int xc_prose_build(int xc_handle,
    17.9 -                   uint32_t domid,
   17.10 -                   unsigned int mem_mb,
   17.11 -                   const char *image_name,
   17.12 -                   const char *ramdisk_name,
   17.13 -                   const char *cmdline,
   17.14 -                   const char *features,
   17.15 -                   unsigned long flags,
   17.16 -                   unsigned int store_evtchn,
   17.17 -                   unsigned long *store_mfn,
   17.18 -                   unsigned int console_evtchn,
   17.19 -                   unsigned long *console_mfn);
   17.20 -
   17.21  #endif /* XENGUEST_H */
    18.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Thu May 08 13:15:45 2008 +0100
    18.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Thu May 08 13:40:40 2008 +0100
    18.3 @@ -1350,28 +1350,6 @@ static PyObject *dom_op(XcObject *self, 
    18.4      return zero;
    18.5  }
    18.6  
    18.7 -#ifdef __powerpc__
    18.8 -static PyObject *pyxc_alloc_real_mode_area(XcObject *self,
    18.9 -                                           PyObject *args,
   18.10 -                                           PyObject *kwds)
   18.11 -{
   18.12 -    uint32_t dom;
   18.13 -    unsigned int log;
   18.14 -
   18.15 -    static char *kwd_list[] = { "dom", "log", NULL };
   18.16 -
   18.17 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
   18.18 -                                      &dom, &log) )
   18.19 -        return NULL;
   18.20 -
   18.21 -    if ( xc_alloc_real_mode_area(self->xc_handle, dom, log) )
   18.22 -        return pyxc_error_to_exception();
   18.23 -
   18.24 -    Py_INCREF(zero);
   18.25 -    return zero;
   18.26 -}
   18.27 -#endif /* powerpc */
   18.28 -
   18.29  static PyMethodDef pyxc_methods[] = {
   18.30      { "handle",
   18.31        (PyCFunction)pyxc_handle,
   18.32 @@ -1759,16 +1737,6 @@ static PyMethodDef pyxc_methods[] = {
   18.33        "Inject debug keys into Xen.\n"
   18.34        " keys    [str]: String of keys to inject.\n" },
   18.35  
   18.36 -#ifdef __powerpc__
   18.37 -    { "arch_alloc_real_mode_area", 
   18.38 -      (PyCFunction)pyxc_alloc_real_mode_area, 
   18.39 -      METH_VARARGS | METH_KEYWORDS, "\n"
   18.40 -      "Allocate a domain's real mode area.\n"
   18.41 -      " dom [int]: Identifier of domain.\n"
   18.42 -      " log [int]: Specifies the area's size.\n"
   18.43 -      "Returns: [int] 0 on success; -1 on error.\n" },
   18.44 -#endif /* __powerpc */
   18.45 -  
   18.46  #if defined(__i386__) || defined(__x86_64__)
   18.47      { "domain_check_cpuid", 
   18.48        (PyCFunction)pyxc_dom_check_cpuid, 
    19.1 --- a/tools/python/xen/xend/arch.py	Thu May 08 13:15:45 2008 +0100
    19.2 +++ b/tools/python/xen/xend/arch.py	Thu May 08 13:40:40 2008 +0100
    19.3 @@ -28,7 +28,5 @@ import os
    19.4      "amd64": "x86",
    19.5      "i86pc": "x86",
    19.6      "ia64": "ia64",
    19.7 -    "ppc": "powerpc",
    19.8 -    "ppc64": "powerpc",
    19.9  }
   19.10  type = _types.get(os.uname()[4], "unknown")
    20.1 --- a/tools/python/xen/xend/image.py	Thu May 08 13:15:45 2008 +0100
    20.2 +++ b/tools/python/xen/xend/image.py	Thu May 08 13:40:40 2008 +0100
    20.3 @@ -506,20 +506,6 @@ class LinuxImageHandler(ImageHandler):
    20.4          return args
    20.5  
    20.6  
    20.7 -class PPC_LinuxImageHandler(LinuxImageHandler):
    20.8 -
    20.9 -    ostype = "linux"
   20.10 -    
   20.11 -    def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
   20.12 -        """@param shadow_mem_kb The configured shadow memory, in KiB.
   20.13 -        @param maxmem_kb The configured maxmem, in KiB.
   20.14 -        @return The corresponding required amount of shadow memory, also in
   20.15 -        KiB.
   20.16 -        PowerPC currently uses "shadow memory" to refer to the hash table."""
   20.17 -        return max(maxmem_kb / 64, shadow_mem_kb)
   20.18 -
   20.19 -
   20.20 -
   20.21  class HVMImageHandler(ImageHandler):
   20.22  
   20.23      ostype = "hvm"
   20.24 @@ -783,9 +769,6 @@ class X86_Linux_ImageHandler(LinuxImageH
   20.25          return LinuxImageHandler.buildDomain(self)
   20.26  
   20.27  _handlers = {
   20.28 -    "powerpc": {
   20.29 -        "linux": PPC_LinuxImageHandler,
   20.30 -    },
   20.31      "ia64": {
   20.32          "linux": IA64_Linux_ImageHandler,
   20.33          "hvm": IA64_HVM_ImageHandler,
    21.1 --- a/tools/xm-test/lib/XmTestLib/arch.py	Thu May 08 13:15:45 2008 +0100
    21.2 +++ b/tools/xm-test/lib/XmTestLib/arch.py	Thu May 08 13:40:40 2008 +0100
    21.3 @@ -88,39 +88,6 @@ ia_HVMDefaults =      {"memory"       : 
    21.4  }
    21.5  # End  : Intel ia32 and ia64 as well as AMD 32-bit and 64-bit processors
    21.6  
    21.7 -# Begin: PowerPC
    21.8 -def ppc_checkBuffer(buffer):
    21.9 -    checks = [
   21.10 -        {"pattern" : re.compile("^\d+:mon>\s*$", re.MULTILINE),
   21.11 -         "message" : "domain trapped into XMON"},
   21.12 -    ]
   21.13 -
   21.14 -    for i in range(0, len(checks)):
   21.15 -        check=checks[i]
   21.16 -        if check.get('pattern').search(buffer):
   21.17 -            FAIL(check.get('message'))
   21.18 -
   21.19 -    return
   21.20 -
   21.21 -def ppc_minSafeMem():
   21.22 -    return 64
   21.23 -
   21.24 -def ppc_getDefaultKernel():
   21.25 -    """Get the path to the default DomU kernel"""
   21.26 -    dom0Ver = commands.getoutput("uname -r");
   21.27 -    domUVer = dom0Ver.replace("xen0", "xenU");
   21.28 -
   21.29 -    return "/boot/vmlinux-" + domUVer;
   21.30 -
   21.31 -ppc_ParavirtDefaults = {"memory"  : 64,
   21.32 -                        "vcpus"   : 1,
   21.33 -                        "kernel"  : ppc_getDefaultKernel(),
   21.34 -                        "root"    : "/dev/ram0",
   21.35 -                        "ramdisk" : getRdPath() + "/initrd.img",
   21.36 -                        "extra"   : "xencons=tty128 console=tty128",
   21.37 -}
   21.38 -# End  : PowerPC
   21.39 -
   21.40  """Convert from uname specification to a more general platform."""
   21.41  _uname_to_arch_map = {
   21.42      "i386"  : "x86",
   21.43 @@ -129,8 +96,6 @@ ppc_ParavirtDefaults = {"memory"  : 64,
   21.44      "i686"  : "x86",
   21.45      "x86_64": "x86_64",
   21.46      "ia64"  : "ia64",
   21.47 -    "ppc"   : "powerpc",
   21.48 -    "ppc64" : "powerpc",
   21.49  }
   21.50  
   21.51  # Lookup current platform.
   21.52 @@ -158,10 +123,5 @@ if _arch == "x86" or _arch == "x86_64" o
   21.53          minSafeMem = ia64_minSafeMem
   21.54          configDefaults['memory'] = ia64_minSafeMem()
   21.55  
   21.56 -elif _arch == "powerpc":
   21.57 -    minSafeMem = ppc_minSafeMem
   21.58 -    getDefaultKernel = ppc_getDefaultKernel
   21.59 -    checkBuffer = ppc_checkBuffer
   21.60 -    configDefaults = ppc_ParavirtDefaults
   21.61  else:
   21.62      raise ValueError, "Unknown architecture!"
    22.1 --- a/tools/xm-test/lib/XmTestReport/arch.py	Thu May 08 13:15:45 2008 +0100
    22.2 +++ b/tools/xm-test/lib/XmTestReport/arch.py	Thu May 08 13:40:40 2008 +0100
    22.3 @@ -30,8 +30,6 @@ import os
    22.4      "i686"  : "x86",
    22.5      "x86_64": "x86_64",
    22.6      "ia64"  : "ia64",
    22.7 -    "ppc"   : "powerpc",
    22.8 -    "ppc64" : "powerpc",
    22.9  }
   22.10  
   22.11  _arch = _uname_to_arch_map.get(os.uname()[4], "Unknown")
   22.12 @@ -44,9 +42,5 @@ elif _arch == "x86_64":
   22.13  elif _arch == "ia64":
   22.14      cpuValues = {"arch"     : "Unknown",
   22.15                   "features" : "Unknown"}
   22.16 -elif _arch == "powerpc":
   22.17 -    cpuValues = {"cpu"      : "Unknown",
   22.18 -                 "platform" : "Unknown",
   22.19 -                 "revision" : "Unknown"}
   22.20  else:
   22.21      raise ValueError, "Unknown architecture!"
    23.1 --- a/tools/xm-test/ramdisk/Makefile.am	Thu May 08 13:15:45 2008 +0100
    23.2 +++ b/tools/xm-test/ramdisk/Makefile.am	Thu May 08 13:40:40 2008 +0100
    23.3 @@ -14,7 +14,7 @@
    23.4  
    23.5  INITRD ?= http://xm-test.xensource.com/ramdisks
    23.6  
    23.7 -BR_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/ppc\(64\)*/powerpc/' -e 's/x86_64/i386/')
    23.8 +BR_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/x86_64/i386/')
    23.9  
   23.10  @MK@ifdef BR_SNAPSHOT
   23.11  @MK@  BR_URL = http://buildroot.uclibc.org/downloads/snapshots/buildroot-snapshot.tar.bz2
    24.1 --- a/tools/xm-test/ramdisk/configs/buildroot-powerpc	Thu May 08 13:15:45 2008 +0100
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,338 +0,0 @@
    24.4 -#
    24.5 -# Automatically generated make config: don't edit
    24.6 -#
    24.7 -BR2_HAVE_DOT_CONFIG=y
    24.8 -# BR2_alpha is not set
    24.9 -# BR2_arm is not set
   24.10 -# BR2_armeb is not set
   24.11 -# BR2_cris is not set
   24.12 -# BR2_i386 is not set
   24.13 -# BR2_m68k is not set
   24.14 -# BR2_mips is not set
   24.15 -# BR2_mipsel is not set
   24.16 -# BR2_nios2 is not set
   24.17 -BR2_powerpc=y
   24.18 -# BR2_sh is not set
   24.19 -# BR2_sh64 is not set
   24.20 -# BR2_sparc is not set
   24.21 -# BR2_x86_64 is not set
   24.22 -BR2_ARCH="powerpc"
   24.23 -BR2_ENDIAN="BIG"
   24.24 -
   24.25 -#
   24.26 -# Build options
   24.27 -#
   24.28 -BR2_WGET="wget --passive-ftp"
   24.29 -BR2_SVN="svn co"
   24.30 -BR2_ZCAT="zcat"
   24.31 -BR2_TAR_OPTIONS=""
   24.32 -BR2_DL_DIR="$(BASE_DIR)/dl"
   24.33 -BR2_SOURCEFORGE_MIRROR="easynews"
   24.34 -BR2_STAGING_DIR="$(BUILD_DIR)/staging_dir"
   24.35 -BR2_TOPDIR_PREFIX=""
   24.36 -BR2_TOPDIR_SUFFIX=""
   24.37 -BR2_GNU_BUILD_SUFFIX="pc-linux-gnu"
   24.38 -BR2_GNU_TARGET_SUFFIX="linux-uclibc"
   24.39 -BR2_JLEVEL=1
   24.40 -
   24.41 -#
   24.42 -# Toolchain Options
   24.43 -#
   24.44 -
   24.45 -#
   24.46 -# Kernel Header Options
   24.47 -#
   24.48 -# BR2_KERNEL_HEADERS_2_4_25 is not set
   24.49 -# BR2_KERNEL_HEADERS_2_4_27 is not set
   24.50 -# BR2_KERNEL_HEADERS_2_4_29 is not set
   24.51 -# BR2_KERNEL_HEADERS_2_4_31 is not set
   24.52 -# BR2_KERNEL_HEADERS_2_6_9 is not set
   24.53 -# BR2_KERNEL_HEADERS_2_6_11 is not set
   24.54 -BR2_KERNEL_HEADERS_2_6_12=y
   24.55 -# BR2_KERNEL_HEADERS_2_6_18 is not set
   24.56 -BR2_DEFAULT_KERNEL_HEADERS="2.6.12"
   24.57 -
   24.58 -#
   24.59 -# uClibc Options
   24.60 -#
   24.61 -# BR2_UCLIBC_VERSION_SNAPSHOT is not set
   24.62 -# BR2_ENABLE_LOCALE is not set
   24.63 -# BR2_PTHREADS_NONE is not set
   24.64 -# BR2_PTHREADS is not set
   24.65 -BR2_PTHREADS_OLD=y
   24.66 -# BR2_PTHREADS_NATIVE is not set
   24.67 -
   24.68 -#
   24.69 -# Binutils Options
   24.70 -#
   24.71 -# BR2_BINUTILS_VERSION_2_14_90_0_8 is not set
   24.72 -# BR2_BINUTILS_VERSION_2_15 is not set
   24.73 -# BR2_BINUTILS_VERSION_2_15_94_0_2_2 is not set
   24.74 -# BR2_BINUTILS_VERSION_2_16_1 is not set
   24.75 -# BR2_BINUTILS_VERSION_2_16_90_0_3 is not set
   24.76 -# BR2_BINUTILS_VERSION_2_16_91_0_5 is not set
   24.77 -# BR2_BINUTILS_VERSION_2_16_91_0_6 is not set
   24.78 -# BR2_BINUTILS_VERSION_2_16_91_0_7 is not set
   24.79 -BR2_BINUTILS_VERSION_2_17=y
   24.80 -# BR2_BINUTILS_VERSION_2_17_50_0_2 is not set
   24.81 -# BR2_BINUTILS_VERSION_2_17_50_0_3 is not set
   24.82 -# BR2_BINUTILS_VERSION_2_17_50_0_4 is not set
   24.83 -# BR2_BINUTILS_VERSION_2_17_50_0_5 is not set
   24.84 -# BR2_BINUTILS_VERSION_2_17_50_0_6 is not set
   24.85 -BR2_BINUTILS_VERSION="2.17"
   24.86 -BR2_EXTRA_BINUTILS_CONFIG_OPTIONS=""
   24.87 -
   24.88 -#
   24.89 -# Gcc Options
   24.90 -#
   24.91 -# BR2_GCC_VERSION_3_3_5 is not set
   24.92 -# BR2_GCC_VERSION_3_3_6 is not set
   24.93 -BR2_GCC_VERSION_3_4_2=y
   24.94 -# BR2_GCC_VERSION_3_4_3 is not set
   24.95 -# BR2_GCC_VERSION_3_4_4 is not set
   24.96 -# BR2_GCC_VERSION_3_4_5 is not set
   24.97 -# BR2_GCC_VERSION_3_4_6 is not set
   24.98 -# BR2_GCC_VERSION_4_0_0 is not set
   24.99 -# BR2_GCC_VERSION_4_0_1 is not set
  24.100 -# BR2_GCC_VERSION_4_0_2 is not set
  24.101 -# BR2_GCC_VERSION_4_0_3 is not set
  24.102 -# BR2_GCC_VERSION_4_1_0 is not set
  24.103 -# BR2_GCC_VERSION_4_1_1 is not set
  24.104 -# BR2_GCC_VERSION_4_2 is not set
  24.105 -# BR2_GCC_IS_SNAP is not set
  24.106 -BR2_GCC_VERSION="3.4.2"
  24.107 -# BR2_GCC_USE_SJLJ_EXCEPTIONS is not set
  24.108 -BR2_EXTRA_GCC_CONFIG_OPTIONS=""
  24.109 -# BR2_INSTALL_LIBSTDCPP is not set
  24.110 -# BR2_INSTALL_OBJC is not set
  24.111 -# BR2_GCC_SHARED_LIBGCC is not set
  24.112 -
  24.113 -#
  24.114 -# Ccache Options
  24.115 -#
  24.116 -BR2_CCACHE=y
  24.117 -
  24.118 -#
  24.119 -# Gdb Options
  24.120 -#
  24.121 -# BR2_PACKAGE_GDB is not set
  24.122 -# BR2_PACKAGE_GDB_SERVER is not set
  24.123 -# BR2_PACKAGE_GDB_HOST is not set
  24.124 -
  24.125 -#
  24.126 -# elf2flt
  24.127 -#
  24.128 -# BR2_ELF2FLT is not set
  24.129 -# BR2_MKLIBS is not set
  24.130 -
  24.131 -#
  24.132 -# Common Toolchain Options
  24.133 -#
  24.134 -# BR2_PACKAGE_SSTRIP_TARGET is not set
  24.135 -# BR2_PACKAGE_SSTRIP_HOST is not set
  24.136 -BR2_ENABLE_MULTILIB=y
  24.137 -BR2_LARGEFILE=y
  24.138 -# BR2_SOFT_FLOAT is not set
  24.139 -BR2_TARGET_OPTIMIZATION="-Os -pipe"
  24.140 -BR2_CROSS_TOOLCHAIN_TARGET_UTILS=y
  24.141 -
  24.142 -#
  24.143 -# Package Selection for the target
  24.144 -#
  24.145 -
  24.146 -#
  24.147 -# The default minimal system
  24.148 -#
  24.149 -BR2_PACKAGE_BUSYBOX=y
  24.150 -# BR2_PACKAGE_BUSYBOX_SNAPSHOT is not set
  24.151 -BR2_PACKAGE_BUSYBOX_INSTALL_SYMLINKS=y
  24.152 -BR2_PACKAGE_BUSYBOX_CONFIG="package/busybox/busybox.config"
  24.153 -
  24.154 -#
  24.155 -# The minimum needed to build a uClibc development system
  24.156 -#
  24.157 -# BR2_PACKAGE_BASH is not set
  24.158 -# BR2_PACKAGE_BZIP2 is not set
  24.159 -# BR2_PACKAGE_COREUTILS is not set
  24.160 -# BR2_PACKAGE_DIFFUTILS is not set
  24.161 -# BR2_PACKAGE_ED is not set
  24.162 -# BR2_PACKAGE_FINDUTILS is not set
  24.163 -# BR2_PACKAGE_FLEX is not set
  24.164 -# BR2_PACKAGE_GAWK is not set
  24.165 -# BR2_PACKAGE_GCC_TARGET is not set
  24.166 -# BR2_PACKAGE_CCACHE_TARGET is not set
  24.167 -# BR2_PACKAGE_GREP is not set
  24.168 -# BR2_PACKAGE_MAKE is not set
  24.169 -# BR2_PACKAGE_PATCH is not set
  24.170 -# BR2_PACKAGE_SED is not set
  24.171 -# BR2_PACKAGE_TAR is not set
  24.172 -
  24.173 -#
  24.174 -# Other stuff
  24.175 -#
  24.176 -# BR2_PACKAGE_ACPID is not set
  24.177 -# BR2_PACKAGE_ASTERISK is not set
  24.178 -# BR2_PACKAGE_AT is not set
  24.179 -# BR2_PACKAGE_AUTOCONF is not set
  24.180 -# BR2_PACKAGE_AUTOMAKE is not set
  24.181 -# BR2_PACKAGE_BERKELEYDB is not set
  24.182 -# BR2_PACKAGE_BIND is not set
  24.183 -# BR2_PACKAGE_BISON is not set
  24.184 -# BR2_PACKAGE_BOA is not set
  24.185 -# BR2_PACKAGE_BRIDGE is not set
  24.186 -# BR2_PACKAGE_CUSTOMIZE is not set
  24.187 -# BR2_PACKAGE_ISC_DHCP is not set
  24.188 -# BR2_PACKAGE_DIALOG is not set
  24.189 -# BR2_PACKAGE_DIRECTFB is not set
  24.190 -# BR2_PACKAGE_DISTCC is not set
  24.191 -# BR2_PACKAGE_DM is not set
  24.192 -# BR2_PACKAGE_DMRAID is not set
  24.193 -# BR2_PACKAGE_DNSMASQ is not set
  24.194 -# BR2_PACKAGE_DROPBEAR is not set
  24.195 -# BR2_PACKAGE_ETHTOOL is not set
  24.196 -# BR2_PACKAGE_EXPAT is not set
  24.197 -# BR2_PACKAGE_E2FSPROGS is not set
  24.198 -# BR2_PACKAGE_FAKEROOT is not set
  24.199 -# BR2_PACKAGE_FILE is not set
  24.200 -# BR2_PACKAGE_FREETYPE is not set
  24.201 -# BR2_PACKAGE_GETTEXT is not set
  24.202 -# BR2_PACKAGE_LIBINTL is not set
  24.203 -# BR2_PACKAGE_GZIP is not set
  24.204 -# BR2_PACKAGE_HASERL is not set
  24.205 -# BR2_PACKAGE_HDPARM is not set
  24.206 -# BR2_PACKAGE_HOSTAP is not set
  24.207 -# BR2_PACKAGE_HOTPLUG is not set
  24.208 -# BR2_PACKAGE_IOSTAT is not set
  24.209 -# BR2_PACKAGE_IPROUTE2 is not set
  24.210 -# BR2_PACKAGE_IPSEC_TOOLS is not set
  24.211 -# BR2_PACKAGE_IPTABLES is not set
  24.212 -# BR2_PACKAGE_JPEG is not set
  24.213 -# BR2_PACKAGE_LESS is not set
  24.214 -# BR2_PACKAGE_LIBCGI is not set
  24.215 -# BR2_PACKAGE_LIBCGICC is not set
  24.216 -# BR2_PACKAGE_LIBELF is not set
  24.217 -# BR2_PACKAGE_LIBFLOAT is not set
  24.218 -# BR2_PACKAGE_LIBGLIB12 is not set
  24.219 -# BR2_PACKAGE_LIBMAD is not set
  24.220 -# BR2_PACKAGE_LIBPCAP is not set
  24.221 -# BR2_PACKAGE_LIBPNG is not set
  24.222 -# BR2_PACKAGE_LIBSYSFS is not set
  24.223 -# BR2_PACKAGE_LIBTOOL is not set
  24.224 -# BR2_PACKAGE_LIBUSB is not set
  24.225 -# BR2_PACKAGE_LIGHTTPD is not set
  24.226 -# BR2_PACKAGE_LINKS is not set
  24.227 -# BR2_PACKAGE_LRZSZ is not set
  24.228 -# BR2_PACKAGE_LSOF is not set
  24.229 -# BR2_PACKAGE_LTP-TESTSUITE is not set
  24.230 -# BR2_PACKAGE_LTT is not set
  24.231 -# BR2_PACKAGE_LVM2 is not set
  24.232 -# BR2_PACKAGE_LZO is not set
  24.233 -# BR2_PACKAGE_LZMA is not set
  24.234 -# BR2_PACKAGE_M4 is not set
  24.235 -# BR2_PACKAGE_MDADM is not set
  24.236 -# BR2_PACKAGE_MEMTESTER is not set
  24.237 -# BR2_PACKAGE_MICROCOM is not set
  24.238 -# BR2_PACKAGE_MICROPERL is not set
  24.239 -# BR2_PACKAGE_MICROWIN is not set
  24.240 -# BR2_PACKAGE_MKDOSFS is not set
  24.241 -# BR2_PACKAGE_MODULE_INIT_TOOLS is not set
  24.242 -# BR2_PACKAGE_MODUTILS is not set
  24.243 -# BR2_PACKAGE_MPG123 is not set
  24.244 -# BR2_PACKAGE_MROUTED is not set
  24.245 -# BR2_PACKAGE_MTD is not set
  24.246 -# BR2_PACKAGE_NANO is not set
  24.247 -# BR2_PACKAGE_NBD is not set
  24.248 -# BR2_PACKAGE_NCURSES is not set
  24.249 -# BR2_PACKAGE_NETKITBASE is not set
  24.250 -# BR2_PACKAGE_NETKITTELNET is not set
  24.251 -# BR2_PACKAGE_NETSNMP is not set
  24.252 -# BR2_PACKAGE_NEWT is not set
  24.253 -# BR2_PACKAGE_NTP is not set
  24.254 -# BR2_PACKAGE_OPENNTPD is not set
  24.255 -# BR2_PACKAGE_OPENSSH is not set
  24.256 -# BR2_PACKAGE_OPENSSL is not set
  24.257 -# BR2_PACKAGE_OPENVPN is not set
  24.258 -# BR2_PACKAGE_PCIUTILS is not set
  24.259 -# BR2_PACKAGE_PKGCONFIG is not set
  24.260 -# BR2_PACKAGE_PORTAGE is not set
  24.261 -# BR2_PACKAGE_PORTMAP is not set
  24.262 -# BR2_PACKAGE_PPPD is not set
  24.263 -# BR2_PACKAGE_PROCPS is not set
  24.264 -# BR2_PACKAGE_PSMISC is not set
  24.265 -# BR2_PACKAGE_PYTHON is not set
  24.266 -# BR2_PACKAGE_QTE is not set
  24.267 -BR2_QTE_TMAKE_VERSION="1.13"
  24.268 -# BR2_PACKAGE_RAIDTOOLS is not set
  24.269 -# BR2_READLINE is not set
  24.270 -# BR2_PACKAGE_RSYNC is not set
  24.271 -# BR2_PACKAGE_RUBY is not set
  24.272 -# BR2_PACKAGE_RXVT is not set
  24.273 -# BR2_PACKAGE_SDL is not set
  24.274 -# BR2_PACKAGE_SFDISK is not set
  24.275 -# BR2_PACKAGE_SLANG is not set
  24.276 -# BR2_PACKAGE_SMARTMONTOOLS is not set
  24.277 -# BR2_PACKAGE_SOCAT is not set
  24.278 -# BR2_PACKAGE_SQLITE is not set
  24.279 -# BR2_PACKAGE_STRACE is not set
  24.280 -# BR2_PACKAGE_SUDO is not set
  24.281 -# BR2_PACKAGE_SYSKLOGD is not set
  24.282 -# BR2_PACKAGE_SYSVINIT is not set
  24.283 -# BR2_PACKAGE_TCL is not set
  24.284 -# BR2_PACKAGE_TCPDUMP is not set
  24.285 -# BR2_PACKAGE_TFTPD is not set
  24.286 -# BR2_PACKAGE_THTTPD is not set
  24.287 -# BR2_PACKAGE_TINYLOGIN is not set
  24.288 -# BR2_PACKAGE_TINYX is not set
  24.289 -# BR2_PACKAGE_TN5250 is not set
  24.290 -# BR2_PACKAGE_TTCP is not set
  24.291 -# BR2_PACKAGE_UDEV is not set
  24.292 -# BR2_PACKAGE_UDHCP is not set
  24.293 -# BR2_PACKAGE_UEMACS is not set
  24.294 -# BR2_PACKAGE_USBUTILS is not set
  24.295 -# BR2_PACKAGE_UTIL-LINUX is not set
  24.296 -# BR2_PACKAGE_VALGRIND is not set
  24.297 -# BR2_PACKAGE_VTUN is not set
  24.298 -# BR2_PACKAGE_WGET is not set
  24.299 -# BR2_PACKAGE_WHICH is not set
  24.300 -# BR2_PACKAGE_WIPE is not set
  24.301 -# BR2_PACKAGE_WIRELESS_TOOLS is not set
  24.302 -# BR2_PACKAGE_XFSPROGS is not set
  24.303 -# BR2_PACKAGE_ZLIB is not set
  24.304 -BR2_PACKAGE_HPING=y
  24.305 -
  24.306 -#
  24.307 -# Target Options
  24.308 -#
  24.309 -
  24.310 -#
  24.311 -# filesystem for target device
  24.312 -#
  24.313 -# BR2_TARGET_ROOTFS_CRAMFS is not set
  24.314 -# BR2_TARGET_ROOTFS_CLOOP is not set
  24.315 -BR2_TARGET_ROOTFS_EXT2=y
  24.316 -BR2_TARGET_ROOTFS_EXT2_BLOCKS=0
  24.317 -BR2_TARGET_ROOTFS_EXT2_INODES=0
  24.318 -BR2_TARGET_ROOTFS_EXT2_RESBLKS=0
  24.319 -BR2_TARGET_ROOTFS_EXT2_SQUASH=y
  24.320 -BR2_TARGET_ROOTFS_EXT2_OUTPUT="$(IMAGE).ext2"
  24.321 -# BR2_TARGET_ROOTFS_EXT2_GZ is not set
  24.322 -BR2_TARGET_ROOTFS_EXT2_COPYTO=""
  24.323 -# BR2_TARGET_ROOTFS_JFFS2 is not set
  24.324 -# BR2_TARGET_ROOTFS_SQUASHFS is not set
  24.325 -# BR2_TARGET_ROOTFS_TAR is not set
  24.326 -
  24.327 -#
  24.328 -# bootloader for target device
  24.329 -#
  24.330 -# BR2_TARGET_YABOOT is not set
  24.331 -
  24.332 -#
  24.333 -# Board Support Options
  24.334 -#
  24.335 -
  24.336 -#
  24.337 -# Generic System Support
  24.338 -#
  24.339 -# BR2_TARGET_GENERIC_ACCESS_POINT is not set
  24.340 -# BR2_TARGET_GENERIC_FIREWALL is not set
  24.341 -# BR2_TARGET_GENERIC_DEV_SYSTEM is not set
    25.1 --- a/tools/xm-test/ramdisk/make-release.sh	Thu May 08 13:15:45 2008 +0100
    25.2 +++ b/tools/xm-test/ramdisk/make-release.sh	Thu May 08 13:40:40 2008 +0100
    25.3 @@ -3,9 +3,6 @@
    25.4  if [ "$1" == "" ]
    25.5  then
    25.6    arch=""
    25.7 -elif [ "$1" == "powerpc" ]
    25.8 -then
    25.9 -  arch="BR_ARCH=powerpc"
   25.10  else
   25.11    echo "Invalid architecture specified." >&2
   25.12    exit 1
    26.1 --- a/tools/xm-test/runtest.sh	Thu May 08 13:15:45 2008 +0100
    26.2 +++ b/tools/xm-test/runtest.sh	Thu May 08 13:40:40 2008 +0100
    26.3 @@ -77,7 +77,7 @@ runnable_tests() {
    26.4      # using the right version
    26.5      realrd=$(readlink ramdisk/initrd.img)
    26.6      eval $(./lib/XmTestReport/xmtest.py)
    26.7 -    ARCH=$(uname -m | sed -e s/i.86/i386/ -e 's/ppc\(64\)*/powerpc/')
    26.8 +    ARCH=$(uname -m | sed -e s/i.86/i386/)
    26.9      rrdver="initrd-${XM_TEST_MAJ}.${XM_TEST_MIN}-${ARCH}.img"
   26.10      exp_flag=0
   26.11      realarch=`echo $realrd | awk -F- '{print $3}' | awk -F. '{print $1}'`
    27.1 --- a/xen/Rules.mk	Thu May 08 13:15:45 2008 +0100
    27.2 +++ b/xen/Rules.mk	Thu May 08 13:40:40 2008 +0100
    27.3 @@ -30,8 +30,7 @@ endif
    27.4  # Set ARCH/SUBARCH appropriately.
    27.5  override TARGET_SUBARCH  := $(XEN_TARGET_ARCH)
    27.6  override TARGET_ARCH     := $(shell echo $(XEN_TARGET_ARCH) | \
    27.7 -                              sed -e 's/x86.*/x86/' \
    27.8 -                                  -e 's/powerpc.*/powerpc/')
    27.9 +                              sed -e 's/x86.*/x86/')
   27.10  
   27.11  TARGET := $(BASEDIR)/xen
   27.12  
    28.1 --- a/xen/arch/powerpc/0opt.c	Thu May 08 13:15:45 2008 +0100
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,34 +0,0 @@
    28.4 -/*
    28.5 - * This program is free software; you can redistribute it and/or modify
    28.6 - * it under the terms of the GNU General Public License as published by
    28.7 - * the Free Software Foundation; either version 2 of the License, or
    28.8 - * (at your option) any later version.
    28.9 - *
   28.10 - * This program is distributed in the hope that it will be useful,
   28.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   28.13 - * GNU General Public License for more details.
   28.14 - *
   28.15 - * You should have received a copy of the GNU General Public License
   28.16 - * along with this program; if not, write to the Free Software
   28.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   28.18 - *
   28.19 - * Copyright (C) IBM Corp. 2005
   28.20 - *
   28.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   28.22 - */
   28.23 -
   28.24 -#include <xen/config.h>
   28.25 -#include <xen/lib.h>
   28.26 -
   28.27 -extern void __xchg_called_with_bad_pointer(void);
   28.28 -void __xchg_called_with_bad_pointer(void)
   28.29 -{
   28.30 -    BUG();
   28.31 -}
   28.32 -
   28.33 -extern void __cmpxchg_called_with_bad_pointer(void);
   28.34 -void __cmpxchg_called_with_bad_pointer(void)
   28.35 -{
   28.36 -    BUG();
   28.37 -}
    29.1 --- a/xen/arch/powerpc/Makefile	Thu May 08 13:15:45 2008 +0100
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,152 +0,0 @@
    29.4 -ifneq ($(DOM0_IMAGE),)
    29.5 -builtin_dom0 := y
    29.6 -endif
    29.7 -
    29.8 -subdir-$(HAS_PPC64) += powerpc64
    29.9 -subdir-y += papr
   29.10 -
   29.11 -obj-y += audit.o
   29.12 -obj-y += backtrace.o
   29.13 -obj-y += bitops.o
   29.14 -obj-y += boot_of.o
   29.15 -obj-y += cmdline.o
   29.16 -obj-y += dart.o
   29.17 -obj-y += dart_u3.o
   29.18 -obj-y += dart_u4.o
   29.19 -obj-y += domctl.o
   29.20 -obj-y += domain_build.o
   29.21 -obj-y += domain.o
   29.22 -obj-y += exceptions.o
   29.23 -obj-y += external.o
   29.24 -obj-y += float.o
   29.25 -obj-y += hcalls.o
   29.26 -obj-y += iommu.o
   29.27 -obj-y += irq.o
   29.28 -obj-y += systemsim.o
   29.29 -obj-y += memory.o
   29.30 -obj-y += mm.o
   29.31 -obj-y += mpic.o
   29.32 -obj-y += mpic_init.o
   29.33 -obj-y += multiboot2.o
   29.34 -obj-y += numa.o
   29.35 -obj-y += of-devtree.o
   29.36 -obj-y += of-devwalk.o
   29.37 -obj-y += ofd_fixup.o
   29.38 -obj-y += ofd_fixup_memory.o
   29.39 -obj-y += physdev.o
   29.40 -obj-y += platform.o
   29.41 -obj-y += rtas.o
   29.42 -obj-y += rtas_nvram.o
   29.43 -obj-y += rtas_flash.o
   29.44 -obj-y += setup.o
   29.45 -obj-y += shadow.o
   29.46 -obj-y += smp.o
   29.47 -obj-y += smpboot.o
   29.48 -obj-y += smp-tbsync.o
   29.49 -obj-y += sysctl.o
   29.50 -obj-y += time.o
   29.51 -obj-y += usercopy.o
   29.52 -obj-y += machine_kexec.o
   29.53 -obj-y += crash.o
   29.54 -
   29.55 -obj-$(debug) += 0opt.o
   29.56 -obj-$(crash_debug) += gdbstub.o
   29.57 -obj-$(builtin_dom0) += dom0.o
   29.58 -
   29.59 -obj-y += firmware_image.o
   29.60 -
   29.61 -# These are extra warnings like for the arch/ppc directory but may not
   29.62 -# allow the rest of the tree to build.
   29.63 -PPC_C_WARNINGS += -Wundef -Wmissing-prototypes -Wmissing-declarations
   29.64 -PPC_C_WARNINGS += -Wshadow
   29.65 -CFLAGS += $(PPC_C_WARNINGS)
   29.66 -
   29.67 -#
   29.68 -# The following flags are fed to gcc in order to link several
   29.69 -# objects into a single ELF segment and to not link in any additional
   29.70 -# objects that gcc would normally like to
   29.71 -#
   29.72 -OMAGIC = -nodefaultlibs -nostartfiles -Wl,--omagic
   29.73 -
   29.74 -firmware: of_handler/built_in.o $(TARGET_SUBARCH)/memcpy.o of-devtree.o
   29.75 -	$(CC) $(CFLAGS) $(OMAGIC) -e __ofh_start -Wl,-Ttext,0x0 $^ -o $@
   29.76 -
   29.77 -#
   29.78 -# Link firmware again but this time at the place we expect to load it.
   29.79 -# This makes debugging _way_ easier.
   29.80 -#
   29.81 -firmware.dbg: of_handler/built_in.o $(TARGET_SUBARCH)/memcpy.o of-devtree.o
   29.82 -	$(CC) $(CFLAGS) $(OMAGIC) -e __ofh_start -Wl,-Ttext,0x2000000 $^ -o $@
   29.83 -
   29.84 -firmware_image.bin: firmware firmware.dbg
   29.85 -	$(CROSS_COMPILE)objcopy --output-target=binary $< $@
   29.86 -
   29.87 -#
   29.88 -# Hacks for included C files
   29.89 -#
   29.90 -irq.o: ../x86/irq.c
   29.91 -physdev.o: ../x86/physdev.c
   29.92 -numa.o: ../x86/numa.c
   29.93 -
   29.94 -ifneq ($(CMDLINE),)
   29.95 -# The first token in the arguments will be silently dropped.
   29.96 -FULL_CMDLINE := xen $(CMDLINE)
   29.97 -endif
   29.98 -
   29.99 -ifeq ($(wildcard cmdline.dep),)
  29.100 -cmdline.dep:
  29.101 -	echo $(FULL_CMDLINE) > cmdline.dep
  29.102 -else
  29.103 -ifneq ($(FULL_CMDLINE),$(shell cat cmdline.dep))
  29.104 -cmdline.dep::
  29.105 -	echo $(FULL_CMDLINE) > cmdline.dep
  29.106 -else
  29.107 -cmdline.dep:
  29.108 -endif
  29.109 -endif
  29.110 -
  29.111 -cmdline.o: cmdline.dep
  29.112 -cmdline.o: CFLAGS += -DCMDLINE="\"$(FULL_CMDLINE)\""
  29.113 -
  29.114 -TARGET_OPTS = $(OMAGIC) -Wl,-T,xen.lds
  29.115 -TARGET_OPTS += start.o $(ALL_OBJS)
  29.116 -
  29.117 -.xen-syms: start.o $(ALL_OBJS) xen.lds
  29.118 -	$(MAKE) -f $(BASEDIR)/Rules.mk $(BASEDIR)/common/symbols-dummy.o
  29.119 -	$(CC) $(CFLAGS) $(TARGET_OPTS) $(BASEDIR)/common/symbols-dummy.o -o $@
  29.120 -
  29.121 -NM=$(CROSS_COMPILE)nm
  29.122 -new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
  29.123 -
  29.124 -ifeq ($(new_nm),y)
  29.125 -NM		:= $(NM) --synthetic
  29.126 -endif
  29.127 -
  29.128 -xen-syms.S: .xen-syms
  29.129 -	$(NM) -n $^ | $(BASEDIR)/tools/symbols > $@
  29.130 -
  29.131 -xen-syms.o: xen-syms.S
  29.132 -	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
  29.133 -
  29.134 -$(TARGET)-syms: start.o $(ALL_OBJS) xen-syms.o xen.lds
  29.135 -	$(CC) $(CFLAGS) $(TARGET_OPTS) xen-syms.o -o $@
  29.136 -
  29.137 -# our firmware only loads 32-bit ELF files
  29.138 -OCPYFLAGS := --input-target=elf64-powerpc --output-target=elf32-powerpc
  29.139 -$(TARGET): $(TARGET)-syms
  29.140 -	$(CROSS_COMPILE)objcopy $(OCPYFLAGS) $^ $@
  29.141 -
  29.142 -asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(HDRS)
  29.143 -	$(CC) $(CFLAGS) -S -o $@ $<
  29.144 -
  29.145 -xen.lds: xen.lds.S $(HDRS)
  29.146 -	$(CC) -P -E $(AFLAGS) -o $@ $<
  29.147 -
  29.148 -dom0.bin: $(DOM0_IMAGE)
  29.149 -	cp $< $@
  29.150 -
  29.151 -clean::
  29.152 -	$(MAKE) -f $(BASEDIR)/Rules.mk -C of_handler clean
  29.153 -	rm -f firmware firmware.dbg firmware_image.bin \
  29.154 -		dom0.bin .xen-syms xen-syms.S \
  29.155 -		xen.lds asm-offsets.s cmdline.dep
    30.1 --- a/xen/arch/powerpc/Rules.mk	Thu May 08 13:15:45 2008 +0100
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,52 +0,0 @@
    30.4 -HAS_PPC64 := y
    30.5 -
    30.6 -CC := $(CROSS_COMPILE)gcc
    30.7 -LD := $(CROSS_COMPILE)ld
    30.8 -
    30.9 -# These are goodess that applies to all source.
   30.10 -C_WARNINGS := -Wredundant-decls
   30.11 -
   30.12 -# _no_ common code can have packed data structures or we are in touble.
   30.13 -C_WARNINGS += -Wpacked
   30.14 -
   30.15 -CFLAGS += -m64 -ffreestanding -fno-builtin -fno-common
   30.16 -CFLAGS += -iwithprefix include -Werror -pipe
   30.17 -CFLAGS += -I$(BASEDIR)/include
   30.18 -CFLAGS += -I$(BASEDIR)/include/asm-powerpc/mach-default
   30.19 -CFLAGS += $(C_WARNINGS)
   30.20 -CFLAGS += -msoft-float -O2
   30.21 -CFLAGS-$(debug) += -O0 # last one wins
   30.22 -CFLAGS-$(papr_vterm) += -DPAPR_VDEVICE -DPAPR_VTERM
   30.23 -
   30.24 -LDFLAGS += -m elf64ppc
   30.25 -
   30.26 -#
   30.27 -# command to embed a binary inside a .o
   30.28 -#
   30.29 -%.o: %.bin
   30.30 -	$(CROSS_COMPILE)objcopy --input-target=binary \
   30.31 -		--output-target=elf64-powerpc \
   30.32 -		--binary-architecture=powerpc \
   30.33 -		--redefine-sym _binary_$*_bin_start=$*_start \
   30.34 -		--redefine-sym _binary_$*_bin_end=$*_end \
   30.35 -		--redefine-sym _binary_$*_bin_size=$*_size \
   30.36 -		$< $@
   30.37 -
   30.38 -HDRS += $(wildcard $(BASEDIR)/include/asm-powerpc/mach-*/*.h)
   30.39 -
   30.40 -# Test for at least GCC v3.2.x.
   30.41 -gcc-ver = $(shell $(CC) -dumpversion | sed -e 's/^\(.\)\.\(.\)\.\(.\)/\$(1)/')
   30.42 -ifeq ($(call gcc-ver,1),1)
   30.43 -$(error gcc-1.x.x unsupported - upgrade to at least gcc-3.2.x)
   30.44 -endif
   30.45 -ifeq ($(call gcc-ver,1),2)
   30.46 -$(error gcc-2.x.x unsupported - upgrade to at least gcc-3.2.x)
   30.47 -endif
   30.48 -ifeq ($(call gcc-ver,1),3)
   30.49 -ifeq ($(call gcc-ver,2),0)
   30.50 -$(error gcc-3.0.x unsupported - upgrade to at least gcc-3.2.x)
   30.51 -endif
   30.52 -ifeq ($(call gcc-ver,2),1)
   30.53 -$(error gcc-3.1.x unsupported - upgrade to at least gcc-3.2.x)
   30.54 -endif
   30.55 -endif
    31.1 --- a/xen/arch/powerpc/audit.c	Thu May 08 13:15:45 2008 +0100
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,47 +0,0 @@
    31.4 -/*
    31.5 - * This program is free software; you can redistribute it and/or modify
    31.6 - * it under the terms of the GNU General Public License as published by
    31.7 - * the Free Software Foundation; either version 2 of the License, or
    31.8 - * (at your option) any later version.
    31.9 - *
   31.10 - * This program is distributed in the hope that it will be useful,
   31.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   31.13 - * GNU General Public License for more details.
   31.14 - *
   31.15 - * You should have received a copy of the GNU General Public License
   31.16 - * along with this program; if not, write to the Free Software
   31.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   31.18 - *
   31.19 - * Copyright (C) IBM Corp. 2005
   31.20 - *
   31.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   31.22 - */
   31.23 -
   31.24 -#ifndef NDEBUG
   31.25 -#include <xen/lib.h>
   31.26 -#include <xen/sched.h>
   31.27 -
   31.28 -extern void audit_domain(struct domain *d);
   31.29 -extern void audit_domains(void);
   31.30 -extern void audit_domains_key(unsigned char key);
   31.31 -
   31.32 -void audit_domain(struct domain *d)
   31.33 -{
   31.34 -    panic("%s unimplemented\n", __func__);
   31.35 -}
   31.36 -
   31.37 -void audit_domains(void)
   31.38 -{
   31.39 -    struct domain *d;
   31.40 -    rcu_read_lock(&domlist_read_lock);
   31.41 -    for_each_domain ( d )
   31.42 -        audit_domain(d);
   31.43 -    rcu_read_unlock(&domlist_read_lock);
   31.44 -}
   31.45 -
   31.46 -void audit_domains_key(unsigned char key)
   31.47 -{
   31.48 -    audit_domains();
   31.49 -}
   31.50 -#endif
    32.1 --- a/xen/arch/powerpc/backtrace.c	Thu May 08 13:15:45 2008 +0100
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,217 +0,0 @@
    32.4 -/*
    32.5 - * Routines providing a simple monitor for use on the PowerMac.
    32.6 - *
    32.7 - * Copyright (C) 1996-2005 Paul Mackerras.
    32.8 - *
    32.9 - *      This program is free software; you can redistribute it and/or
   32.10 - *      modify it under the terms of the GNU General Public License
   32.11 - *      as published by the Free Software Foundation; either version
   32.12 - *      2 of the License, or (at your option) any later version.
   32.13 - */
   32.14 -
   32.15 -#include <xen/config.h>
   32.16 -#include <xen/lib.h>
   32.17 -#include <xen/console.h>
   32.18 -#include <xen/sched.h>
   32.19 -#include <xen/symbols.h>
   32.20 -#include <asm/debugger.h>
   32.21 -
   32.22 -static char namebuf[KSYM_NAME_LEN+1];
   32.23 -
   32.24 -/* Shamelessly lifted from Linux Xmon try to keep pristene */
   32.25 -#ifdef __powerpc64__
   32.26 -#define LRSAVE_OFFSET		0x10
   32.27 -#define REG_FRAME_MARKER	0x7265677368657265ul	/* "regshere" */
   32.28 -#define MARKER_OFFSET		0x60
   32.29 -#define REGS_OFFSET		0x70
   32.30 -#define REG "%016lX"
   32.31 -#else
   32.32 -#define LRSAVE_OFFSET		4
   32.33 -#define REG_FRAME_MARKER	0x72656773
   32.34 -#define MARKER_OFFSET		8
   32.35 -#define REGS_OFFSET		16
   32.36 -#define REG "%08lX"
   32.37 -#endif
   32.38 -
   32.39 -#define TRAP(regs) ((regs)->entry_vector & ~0xF)
   32.40 -static int xmon_depth_to_print = 64;
   32.41 -
   32.42 -/* Very cheap human name for vector lookup. */
   32.43 -static
   32.44 -const char *getvecname(unsigned long vec)
   32.45 -{
   32.46 -	char *ret;
   32.47 -
   32.48 -	switch (vec) {
   32.49 -	case 0x100:	ret = "(System Reset)"; break;
   32.50 -	case 0x200:	ret = "(Machine Check)"; break;
   32.51 -	case 0x300:	ret = "(Data Access)"; break;
   32.52 -	case 0x380:	ret = "(Data SLB Access)"; break;
   32.53 -	case 0x400:	ret = "(Instruction Access)"; break;
   32.54 -	case 0x480:	ret = "(Instruction SLB Access)"; break;
   32.55 -	case 0x500:	ret = "(Hardware Interrupt)"; break;
   32.56 -	case 0x600:	ret = "(Alignment)"; break;
   32.57 -	case 0x700:	ret = "(Program Check)"; break;
   32.58 -	case 0x800:	ret = "(FPU Unavailable)"; break;
   32.59 -	case 0x900:	ret = "(Decrementer)"; break;
   32.60 -	case 0xc00:	ret = "(System Call)"; break;
   32.61 -	case 0xd00:	ret = "(Single Step)"; break;
   32.62 -	case 0xf00:	ret = "(Performance Monitor)"; break;
   32.63 -	case 0xf20:	ret = "(Altivec Unavailable)"; break;
   32.64 -	case 0x1300:	ret = "(Instruction Breakpoint)"; break;
   32.65 -	default: ret = "";
   32.66 -	}
   32.67 -	return ret;
   32.68 -}
   32.69 -
   32.70 -static int mread(unsigned long adrs, void *buf, int size)
   32.71 -{
   32.72 -    memcpy(buf, (void *)adrs, size);
   32.73 -    return size;
   32.74 -}
   32.75 -
   32.76 -static void get_function_bounds(unsigned long pc, unsigned long *startp,
   32.77 -				unsigned long *endp)
   32.78 -{
   32.79 -    unsigned long size, offset;
   32.80 -	const char *name;
   32.81 -
   32.82 -    *startp = *endp = 0;
   32.83 -	if (pc == 0)
   32.84 -		return;
   32.85 -
   32.86 -    name = symbols_lookup(pc, &size, &offset, namebuf);
   32.87 -    if (name != NULL) {
   32.88 -			*startp = pc - offset;
   32.89 -			*endp = pc - offset + size;
   32.90 -    }
   32.91 -}
   32.92 -    
   32.93 -/* Print an address in numeric and symbolic form (if possible) */
   32.94 -static void xmon_print_symbol(unsigned long address, const char *mid,
   32.95 -                              const char *after)
   32.96 -{
   32.97 -	const char *name = NULL;
   32.98 -	unsigned long offset, size;
   32.99 -
  32.100 -	printk(REG, address);
  32.101 -
  32.102 -    name = symbols_lookup(address, &size, &offset, namebuf);
  32.103 -	if (name) {
  32.104 -		printk("%s%s+%#lx/%#lx", mid, name, offset, size);
  32.105 -	}
  32.106 -	printk("%s", after);
  32.107 -}
  32.108 -
  32.109 -static void backtrace(
  32.110 -    unsigned long sp, unsigned long lr, unsigned long pc)
  32.111 -{
  32.112 -	unsigned long ip;
  32.113 -	unsigned long newsp;
  32.114 -	unsigned long marker;
  32.115 -	int count = 0;
  32.116 -	struct cpu_user_regs regs;
  32.117 -
  32.118 -	do {
  32.119 -		if (sp > xenheap_phys_end) {
  32.120 -			if (sp != 0)
  32.121 -				printk("SP (%lx) is not in xen space\n", sp);
  32.122 -			break;
  32.123 -		}
  32.124 -
  32.125 -		if (!mread(sp + LRSAVE_OFFSET, &ip, sizeof(unsigned long))
  32.126 -		    || !mread(sp, &newsp, sizeof(unsigned long))) {
  32.127 -			printk("Couldn't read stack frame at %lx\n", sp);
  32.128 -			break;
  32.129 -		}
  32.130 -
  32.131 -		/*
  32.132 -		 * For the first stack frame, try to work out if
  32.133 -		 * LR and/or the saved LR value in the bottommost
  32.134 -		 * stack frame are valid.
  32.135 -		 */
  32.136 -		if ((pc | lr) != 0) {
  32.137 -			unsigned long fnstart, fnend;
  32.138 -			unsigned long nextip;
  32.139 -			int printip = 1;
  32.140 -
  32.141 -			get_function_bounds(pc, &fnstart, &fnend);
  32.142 -			nextip = 0;
  32.143 -			if (newsp > sp)
  32.144 -				mread(newsp + LRSAVE_OFFSET, &nextip,
  32.145 -				      sizeof(unsigned long));
  32.146 -			if (lr == ip) {
  32.147 -				if (lr >= xenheap_phys_end
  32.148 -				    || (fnstart <= lr && lr < fnend))
  32.149 -					printip = 0;
  32.150 -			} else if (lr == nextip) {
  32.151 -				printip = 0;
  32.152 -			} else if (lr < xenheap_phys_end
  32.153 -                       && !(fnstart <= lr && lr < fnend)) {
  32.154 -				printk("[link register   ] ");
  32.155 -				xmon_print_symbol(lr, " ", "\n");
  32.156 -			}
  32.157 -			if (printip) {
  32.158 -				printk("["REG"] ", sp);
  32.159 -				xmon_print_symbol(ip, " ", " (unreliable)\n");
  32.160 -			}
  32.161 -			pc = lr = 0;
  32.162 -
  32.163 -		} else {
  32.164 -			printk("["REG"] ", sp);
  32.165 -			xmon_print_symbol(ip, " ", "\n");
  32.166 -		}
  32.167 -
  32.168 -		/* Look for "regshere" marker to see if this is
  32.169 -		   an exception frame. */
  32.170 -		if (mread(sp + MARKER_OFFSET, &marker, sizeof(unsigned long))
  32.171 -		    && marker == REG_FRAME_MARKER) {
  32.172 -			if (mread(sp + REGS_OFFSET, &regs, sizeof(regs))
  32.173 -			    != sizeof(regs)) {
  32.174 -				printk("Couldn't read registers at %lx\n",
  32.175 -				       sp + REGS_OFFSET);
  32.176 -				break;
  32.177 -			}
  32.178 -            printk("--- Exception: %x %s at ", regs.entry_vector,
  32.179 -			       getvecname(TRAP(&regs)));
  32.180 -			pc = regs.pc;
  32.181 -			lr = regs.lr;
  32.182 -			xmon_print_symbol(pc, " ", "\n");
  32.183 -		}
  32.184 -
  32.185 -		if (newsp == 0)
  32.186 -			break;
  32.187 -        
  32.188 -		sp = newsp;
  32.189 -	} while (count++ < xmon_depth_to_print);
  32.190 -}
  32.191 -
  32.192 -void show_backtrace(ulong sp, ulong lr, ulong pc)
  32.193 -{
  32.194 -    console_start_sync();
  32.195 -    backtrace(sp, lr, pc);
  32.196 -    console_end_sync();
  32.197 -}
  32.198 -
  32.199 -void show_backtrace_regs(struct cpu_user_regs *regs)
  32.200 -{
  32.201 -    console_start_sync();
  32.202 -    
  32.203 -    show_registers(regs);
  32.204 -    printk("hid4 0x%016lx\n", regs->hid4);
  32.205 -    printk("---[ backtrace ]---\n");
  32.206 -    show_backtrace(regs->gprs[1], regs->lr, regs->pc);
  32.207 -
  32.208 -    console_end_sync();
  32.209 -}
  32.210 -
  32.211 -void dump_execution_state(void)
  32.212 -{
  32.213 -    struct cpu_user_regs *regs = guest_cpu_user_regs();
  32.214 -
  32.215 -    show_registers(regs);
  32.216 -    if (regs->msr & MSR_HV) {
  32.217 -        printk("In Xen:\n");
  32.218 -        show_backtrace(regs->gprs[1], regs->pc, regs->lr);
  32.219 -    }
  32.220 -}
    33.1 --- a/xen/arch/powerpc/bitops.c	Thu May 08 13:15:45 2008 +0100
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,94 +0,0 @@
    33.4 -/* from linux/arch/powerpc/lib/bitops.c */
    33.5 -
    33.6 -#include <asm/types.h>
    33.7 -#include <asm/bitops.h>
    33.8 -
    33.9 -#define BITOP_WORD(nr)      ((nr) / BITS_PER_LONG)
   33.10 -
   33.11 -/**
   33.12 - * find_next_bit - find the next set bit in a memory region
   33.13 - * @addr: The address to base the search on
   33.14 - * @offset: The bitnumber to start searching at
   33.15 - * @size: The maximum size to search
   33.16 - */
   33.17 -unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
   33.18 -                            unsigned long offset)
   33.19 -{
   33.20 -    const unsigned long *p = addr + BITOP_WORD(offset);
   33.21 -    unsigned long result = offset & ~(BITS_PER_LONG-1);
   33.22 -    unsigned long tmp;
   33.23 -
   33.24 -    if (offset >= size)
   33.25 -        return size;
   33.26 -    size -= result;
   33.27 -    offset %= BITS_PER_LONG;
   33.28 -    if (offset) {
   33.29 -        tmp = *(p++);
   33.30 -        tmp &= (~0UL << offset);
   33.31 -        if (size < BITS_PER_LONG)
   33.32 -            goto found_first;
   33.33 -        if (tmp)
   33.34 -            goto found_middle;
   33.35 -        size -= BITS_PER_LONG;
   33.36 -        result += BITS_PER_LONG;
   33.37 -    }
   33.38 -    while (size & ~(BITS_PER_LONG-1)) {
   33.39 -        if ((tmp = *(p++)))
   33.40 -            goto found_middle;
   33.41 -        result += BITS_PER_LONG;
   33.42 -        size -= BITS_PER_LONG;
   33.43 -    }
   33.44 -    if (!size)
   33.45 -        return result;
   33.46 -    tmp = *p;
   33.47 -
   33.48 -found_first:
   33.49 -    tmp &= (~0UL >> (BITS_PER_LONG - size));
   33.50 -    if (tmp == 0UL)        /* Are any bits set? */
   33.51 -        return result + size;    /* Nope. */
   33.52 -found_middle:
   33.53 -    return result + __ffs(tmp);
   33.54 -}
   33.55 -
   33.56 -/*
   33.57 - * This implementation of find_{first,next}_zero_bit was stolen from
   33.58 - * Linus' asm-alpha/bitops.h.
   33.59 - */
   33.60 -unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
   33.61 -                                 unsigned long offset)
   33.62 -{
   33.63 -    const unsigned long *p = addr + BITOP_WORD(offset);
   33.64 -    unsigned long result = offset & ~(BITS_PER_LONG-1);
   33.65 -    unsigned long tmp;
   33.66 -
   33.67 -    if (offset >= size)
   33.68 -        return size;
   33.69 -    size -= result;
   33.70 -    offset %= BITS_PER_LONG;
   33.71 -    if (offset) {
   33.72 -        tmp = *(p++);
   33.73 -        tmp |= ~0UL >> (BITS_PER_LONG - offset);
   33.74 -        if (size < BITS_PER_LONG)
   33.75 -            goto found_first;
   33.76 -        if (~tmp)
   33.77 -            goto found_middle;
   33.78 -        size -= BITS_PER_LONG;
   33.79 -        result += BITS_PER_LONG;
   33.80 -    }
   33.81 -    while (size & ~(BITS_PER_LONG-1)) {
   33.82 -        if (~(tmp = *(p++)))
   33.83 -            goto found_middle;
   33.84 -        result += BITS_PER_LONG;
   33.85 -        size -= BITS_PER_LONG;
   33.86 -    }
   33.87 -    if (!size)
   33.88 -        return result;
   33.89 -    tmp = *p;
   33.90 -
   33.91 -found_first:
   33.92 -    tmp |= ~0UL << size;
   33.93 -    if (tmp == ~0UL)    /* Are any bits zero? */
   33.94 -        return result + size;    /* Nope. */
   33.95 -found_middle:
   33.96 -    return result + ffz(tmp);
   33.97 -}
    34.1 --- a/xen/arch/powerpc/boot_of.c	Thu May 08 13:15:45 2008 +0100
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,1257 +0,0 @@
    34.4 -/*
    34.5 - * This program is free software; you can redistribute it and/or modify
    34.6 - * it under the terms of the GNU General Public License as published by
    34.7 - * the Free Software Foundation; either version 2 of the License, or
    34.8 - * (at your option) any later version.
    34.9 - *
   34.10 - * This program is distributed in the hope that it will be useful,
   34.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   34.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   34.13 - * GNU General Public License for more details.
   34.14 - *
   34.15 - * You should have received a copy of the GNU General Public License
   34.16 - * along with this program; if not, write to the Free Software
   34.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   34.18 - *
   34.19 - * Copyright IBM Corp. 2005, 2006, 2007
   34.20 - *
   34.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   34.22 - *          Hollis Blanchard <hollisb@us.ibm.com>
   34.23 - */
   34.24 -
   34.25 -#include <xen/config.h>
   34.26 -#include <xen/init.h>
   34.27 -#include <xen/lib.h>
   34.28 -#include <xen/version.h>
   34.29 -#include <xen/spinlock.h>
   34.30 -#include <xen/serial.h>
   34.31 -#include <xen/time.h>
   34.32 -#include <xen/sched.h>
   34.33 -#include <asm/page.h>
   34.34 -#include <asm/io.h>
   34.35 -#include <asm/boot.h>
   34.36 -#include "exceptions.h"
   34.37 -#include "of-devtree.h"
   34.38 -#include "oftree.h"
   34.39 -#include "rtas.h"
   34.40 -
   34.41 -/* Secondary processors use this for handshaking with main processor.  */
   34.42 -volatile unsigned int __spin_ack;
   34.43 -
   34.44 -static ulong of_vec;
   34.45 -static ulong of_msr;
   34.46 -static int of_out;
   34.47 -static ulong eomem;
   34.48 -
   34.49 -/* Track memory during early boot with a limited per-page bitmap. We need an
   34.50 - * allocator to tell us where we can place RTAS, our copy of the device tree.
   34.51 - * We could examine the "available" properties in memory nodes, but we
   34.52 - * apparently can't depend on firmware to update those when we call "claim". So
   34.53 - * we need to track it ourselves.
   34.54 - * We can't dynamically allocate the bitmap, because we would need something
   34.55 - * to tell us where it's safe to allocate...
   34.56 - */
   34.57 -#define MEM_AVAILABLE_PAGES ((32 << 20) >> PAGE_SHIFT)
   34.58 -static DECLARE_BITMAP(mem_available_pages, MEM_AVAILABLE_PAGES);
   34.59 -
   34.60 -extern struct ns16550_defaults ns16550;
   34.61 -
   34.62 -#undef OF_DEBUG
   34.63 -#undef OF_DEBUG_LOW
   34.64 -
   34.65 -#ifdef OF_DEBUG
   34.66 -#define DBG(args...) of_printf(args)
   34.67 -#else
   34.68 -#define DBG(args...)
   34.69 -#endif
   34.70 -
   34.71 -#ifdef OF_DEBUG_LOW
   34.72 -#define DBG_LOW(args...) of_printf(args)
   34.73 -#else
   34.74 -#define DBG_LOW(args...)
   34.75 -#endif
   34.76 -
   34.77 -#define of_panic(MSG...) \
   34.78 -    do { of_printf(MSG); of_printf("\nHANG\n"); for (;;); } while (0)
   34.79 -
   34.80 -struct of_service {
   34.81 -    u32 ofs_service;
   34.82 -    u32 ofs_nargs;
   34.83 -    u32 ofs_nrets;
   34.84 -    u32 ofs_args[10];
   34.85 -};
   34.86 -
   34.87 -static int bof_chosen;
   34.88 -
   34.89 -static struct of_service s;
   34.90 -
   34.91 -static int __init of_call(
   34.92 -    const char *service, u32 nargs, u32 nrets, s32 rets[], ...)
   34.93 -{
   34.94 -    int rc;
   34.95 -
   34.96 -    if (of_vec != 0) {
   34.97 -        va_list args;
   34.98 -        int i;
   34.99 -        memset(&s, 0, sizeof (s));
  34.100 -        s.ofs_service = (ulong)service;
  34.101 -        s.ofs_nargs = nargs;
  34.102 -        s.ofs_nrets = nrets;
  34.103 -        s.ofs_nargs = nargs;
  34.104 -
  34.105 -        /* copy all the params into the args array */
  34.106 -        va_start(args, rets);
  34.107 -
  34.108 -        for (i = 0; i < nargs; i++) {
  34.109 -            s.ofs_args[i] = va_arg(args, u32);
  34.110 -        }
  34.111 -
  34.112 -        va_end(args);
  34.113 -
  34.114 -        rc = prom_call(&s, 0, of_vec, of_msr);
  34.115 -
  34.116 -        /* yes always to the copy, just in case */
  34.117 -        for (i = 0; i < nrets; i++) {
  34.118 -            rets[i] = s.ofs_args[i + nargs];
  34.119 -        }
  34.120 -    } else {
  34.121 -        rc = OF_FAILURE;
  34.122 -    }
  34.123 -    return rc;
  34.124 -}
  34.125 -
  34.126 -/* popular OF methods */
  34.127 -static int __init _of_write(int ih, const char *addr, u32 len)
  34.128 -{
  34.129 -    int rets[1] = { OF_FAILURE };
  34.130 -    if (of_call("write", 3, 1, rets, ih, addr, len) == OF_FAILURE) {
  34.131 -        return OF_FAILURE;
  34.132 -    }
  34.133 -    return rets[0];
  34.134 -}
  34.135 -
  34.136 -/* popular OF methods */
  34.137 -static int __init of_write(int ih, const char *addr, u32 len)
  34.138 -{
  34.139 -    int rc;
  34.140 -    int i = 0;
  34.141 -    int sum = 0;
  34.142 -
  34.143 -    while (i < len) {
  34.144 -        if (addr[i] == '\n') {
  34.145 -            if (i > 0) {
  34.146 -                rc = _of_write(ih, addr, i);
  34.147 -                if (rc == OF_FAILURE)
  34.148 -                    return rc;
  34.149 -                sum += rc;
  34.150 -            }
  34.151 -            rc = _of_write(ih, "\r\n", 2);
  34.152 -            if (rc == OF_FAILURE)
  34.153 -                return rc;
  34.154 -            sum += rc;
  34.155 -            i++;
  34.156 -            addr += i;
  34.157 -            len -= i;
  34.158 -            i = 0;
  34.159 -            continue;
  34.160 -        }
  34.161 -        i++;
  34.162 -    }
  34.163 -    if (len > 0) {
  34.164 -        rc = _of_write(ih, addr, len);
  34.165 -        if (rc == OF_FAILURE)
  34.166 -            return rc;
  34.167 -        sum += rc;
  34.168 -    }
  34.169 -            
  34.170 -    return sum;
  34.171 -}
  34.172 -
  34.173 -static int of_printf(const char *fmt, ...)
  34.174 -    __attribute__ ((format (printf, 1, 2)));
  34.175 -static int __init of_printf(const char *fmt, ...)
  34.176 -{
  34.177 -    static char buf[1024];
  34.178 -    va_list args;
  34.179 -    int sz;
  34.180 -
  34.181 -    if (of_out == 0) {
  34.182 -        return OF_FAILURE;
  34.183 -    }
  34.184 -
  34.185 -    va_start(args, fmt);
  34.186 -
  34.187 -    sz = vsnprintf(buf, sizeof (buf), fmt, args);
  34.188 -    if (sz <= sizeof (buf)) {
  34.189 -        of_write(of_out, buf, sz);
  34.190 -    } else {
  34.191 -        static const char trunc[] = "\n(TRUNCATED)\n";
  34.192 -
  34.193 -        sz = sizeof (buf);
  34.194 -        of_write(of_out, buf, sz);
  34.195 -        of_write(of_out, trunc, sizeof (trunc));
  34.196 -    }
  34.197 -    return sz;
  34.198 -}
  34.199 -
  34.200 -static int __init of_finddevice(const char *devspec)
  34.201 -{
  34.202 -    int rets[1] = { OF_FAILURE };
  34.203 -
  34.204 -    of_call("finddevice", 1, 1, rets, devspec);
  34.205 -    if (rets[0] == OF_FAILURE) {
  34.206 -        DBG("finddevice %s -> FAILURE %d\n",devspec,rets[0]);
  34.207 -        return OF_FAILURE;
  34.208 -    }
  34.209 -    DBG_LOW("finddevice %s -> %d\n",devspec, rets[0]);
  34.210 -    return rets[0];
  34.211 -}
  34.212 -
  34.213 -static int __init of_getprop(int ph, const char *name, void *buf, u32 buflen)
  34.214 -{
  34.215 -    int rets[1] = { OF_FAILURE };
  34.216 -
  34.217 -    of_call("getprop", 4, 1, rets, ph, name, buf, buflen);
  34.218 -
  34.219 -    if (rets[0] == OF_FAILURE) {
  34.220 -        DBG_LOW("getprop 0x%x %s -> FAILURE\n", ph, name);
  34.221 -        return OF_FAILURE;
  34.222 -    }
  34.223 -
  34.224 -    DBG_LOW("getprop 0x%x %s -> 0x%x (%s)\n", ph, name, rets[0], (char *)buf);
  34.225 -    return rets[0];
  34.226 -}
  34.227 -
  34.228 -static int __init of_setprop(
  34.229 -    int ph, const char *name, const void *buf, u32 buflen)
  34.230 -{
  34.231 -    int rets[1] = { OF_FAILURE };
  34.232 -
  34.233 -    of_call("setprop", 4, 1, rets, ph, name, buf, buflen);
  34.234 -
  34.235 -    if (rets[0] == OF_FAILURE) {
  34.236 -        DBG("setprop 0x%x %s -> FAILURE\n", ph, name);
  34.237 -        return OF_FAILURE;
  34.238 -    }
  34.239 -
  34.240 -    DBG_LOW("setprop 0x%x %s -> %s\n", ph, name, (char *)buf);
  34.241 -    return rets[0];
  34.242 -}
  34.243 -
  34.244 -/*
  34.245 - * returns 0 if there are no children (of spec)
  34.246 - */
  34.247 -static int __init of_getchild(int ph)
  34.248 -{
  34.249 -    int rets[1] = { OF_FAILURE };
  34.250 -
  34.251 -    of_call("child", 1, 1, rets, ph);
  34.252 -    DBG_LOW("getchild 0x%x -> 0x%x\n", ph, rets[0]);
  34.253 -
  34.254 -    return rets[0];
  34.255 -}
  34.256 -
  34.257 -/*
  34.258 - * returns 0 is there are no peers
  34.259 - */
  34.260 -static int __init of_getpeer(int ph)
  34.261 -{
  34.262 -    int rets[1] = { OF_FAILURE };
  34.263 -
  34.264 -    of_call("peer", 1, 1, rets, ph);
  34.265 -    DBG_LOW("getpeer 0x%x -> 0x%x\n", ph, rets[0]);
  34.266 -
  34.267 -    return rets[0];
  34.268 -}
  34.269 -
  34.270 -static int __init of_getproplen(int ph, const char *name)
  34.271 -{
  34.272 -    int rets[1] = { OF_FAILURE };
  34.273 -
  34.274 -    of_call("getproplen", 2, 1, rets, ph, name);
  34.275 -    if (rets[0] == OF_FAILURE) {
  34.276 -        DBG("getproplen 0x%x %s -> FAILURE\n", ph, name);
  34.277 -        return OF_FAILURE;
  34.278 -    }
  34.279 -    DBG_LOW("getproplen 0x%x %s -> 0x%x\n", ph, name, rets[0]);
  34.280 -    return rets[0];
  34.281 -}
  34.282 -
  34.283 -static int __init of_package_to_path(int ph, char *buffer, u32 buflen)
  34.284 -{
  34.285 -    int rets[1] = { OF_FAILURE };
  34.286 -
  34.287 -    of_call("package-to-path", 3, 1, rets, ph, buffer, buflen);
  34.288 -    if (rets[0] == OF_FAILURE) {
  34.289 -        DBG("%s 0x%x -> FAILURE\n", __func__, ph);
  34.290 -        return OF_FAILURE;
  34.291 -    }
  34.292 -    DBG_LOW("%s 0x%x %s -> 0x%x\n", __func__, ph, buffer, rets[0]);
  34.293 -    if (rets[0] <= buflen)
  34.294 -        buffer[rets[0]] = '\0';
  34.295 -    return rets[0];
  34.296 -}
  34.297 -
  34.298 -static int __init of_nextprop(int ph, const char *name, void *buf)
  34.299 -{
  34.300 -    int rets[1] = { OF_FAILURE };
  34.301 -
  34.302 -    of_call("nextprop", 3, 1, rets, ph, name, buf);
  34.303 -
  34.304 -    if (rets[0] == OF_FAILURE) {
  34.305 -        DBG("nextprop 0x%x %s -> FAILURE\n", ph, name);
  34.306 -        return OF_FAILURE;
  34.307 -    }
  34.308 -
  34.309 -    DBG_LOW("nextprop 0x%x %s -> %s\n", ph, name, (char *)buf);
  34.310 -    return rets[0];
  34.311 -}
  34.312 -
  34.313 -static int __init of_instance_to_path(int ih, char *buffer, u32 buflen)
  34.314 -{
  34.315 -    int rets[1] = { OF_FAILURE };
  34.316 -
  34.317 -    if (of_call("instance-to-path", 3, 1, rets, ih, buffer, buflen)
  34.318 -         == OF_FAILURE)
  34.319 -        return OF_FAILURE;
  34.320 -
  34.321 -    if (rets[0] <= buflen)
  34.322 -        buffer[rets[0]] = '\0';
  34.323 -    return rets[0];
  34.324 -}
  34.325 -
  34.326 -static int __init of_start_cpu(int cpu, u32 pc, u32 reg)
  34.327 -{
  34.328 -    int ret;
  34.329 -
  34.330 -    ret = of_call("start-cpu", 3, 0, NULL, cpu, pc, reg);
  34.331 -
  34.332 -    return ret;
  34.333 -}
  34.334 -
  34.335 -static void __init of_test(const char *of_method_name)
  34.336 -{
  34.337 -    int rets[1] = { OF_FAILURE };
  34.338 -    
  34.339 -    of_call("test", 1, 1, rets, of_method_name);
  34.340 -    if (rets[0] == OF_FAILURE ) {
  34.341 -        of_printf("Warning: possibly no OF method %s.\n"
  34.342 -                  "(Ignore this warning on PIBS.)\n", of_method_name);
  34.343 -    }
  34.344 -}
  34.345 -
  34.346 -static int __init of_claim(u32 virt, u32 size, u32 align)
  34.347 -{
  34.348 -    int rets[1] = { OF_FAILURE };
  34.349 -    
  34.350 -    of_call("claim", 3, 1, rets, virt, size, align);
  34.351 -    if (rets[0] == OF_FAILURE) {
  34.352 -        DBG("%s 0x%08x 0x%08x  0x%08x -> FAIL\n", __func__, virt, size, align);
  34.353 -        return OF_FAILURE;
  34.354 -    }
  34.355 -
  34.356 -    DBG_LOW("%s 0x%08x 0x%08x  0x%08x -> 0x%08x\n", __func__, virt, size, align,
  34.357 -        rets[0]);
  34.358 -    return rets[0];
  34.359 -}
  34.360 -
  34.361 -static int __init of_instance_to_package(int ih)
  34.362 -{
  34.363 -    int rets[1] = { OF_FAILURE };
  34.364 -
  34.365 -    of_call("instance-to-package", 1, 1, rets, ih);
  34.366 -    if (rets[0] == OF_FAILURE)
  34.367 -        return OF_FAILURE;
  34.368 -
  34.369 -    return rets[0];
  34.370 -}
  34.371 -
  34.372 -static int __init of_getparent(int ph)
  34.373 -{
  34.374 -    int rets[1] = { OF_FAILURE };
  34.375 -
  34.376 -    of_call("parent", 1, 1, rets, ph);
  34.377 -
  34.378 -    DBG_LOW("getparent 0x%x -> 0x%x\n", ph, rets[0]);
  34.379 -    return rets[0];
  34.380 -}
  34.381 -
  34.382 -static int __init of_open(const char *devspec)
  34.383 -{
  34.384 -    int rets[1] = { OF_FAILURE };
  34.385 -
  34.386 -    of_call("open", 1, 1, rets, devspec);
  34.387 -    return rets[0];
  34.388 -}
  34.389 -
  34.390 -static void boot_of_alloc_init(int m, uint addr_cells, uint size_cells)
  34.391 -{
  34.392 -    int rc;
  34.393 -    uint pg;
  34.394 -    uint a[64];
  34.395 -    int tst;
  34.396 -    u64 start;
  34.397 -    u64 size;
  34.398 -
  34.399 -    rc = of_getprop(m, "available", a, sizeof (a));
  34.400 -    if (rc > 0) {
  34.401 -        int l =  rc / sizeof(a[0]);
  34.402 -        int r = 0;
  34.403 -
  34.404 -#ifdef OF_DEBUG
  34.405 -        { 
  34.406 -            int i;
  34.407 -            of_printf("avail:\n");
  34.408 -            for (i = 0; i < l; i += 4)
  34.409 -                of_printf("  0x%x%x, 0x%x%x\n",
  34.410 -                          a[i], a[i + 1],
  34.411 -                          a[i + 2] ,a[i + 3]);
  34.412 -        }
  34.413 -#endif
  34.414 -            
  34.415 -        pg = 0;
  34.416 -        while (pg < MEM_AVAILABLE_PAGES && r < l) {
  34.417 -            ulong end;
  34.418 -
  34.419 -            start = a[r++];
  34.420 -            if (addr_cells == 2 && (r < l) )
  34.421 -                start = (start << 32) | a[r++];
  34.422 -            
  34.423 -            size = a[r++];
  34.424 -            if (size_cells == 2 && (r < l) )
  34.425 -                size = (size << 32) | a[r++];
  34.426 -                
  34.427 -            end = ALIGN_DOWN(start + size, PAGE_SIZE);
  34.428 -
  34.429 -            start = ALIGN_UP(start, PAGE_SIZE);
  34.430 -
  34.431 -            DBG("%s: marking 0x%x - 0x%lx\n", __func__,
  34.432 -                pg << PAGE_SHIFT, start);
  34.433 -
  34.434 -            start >>= PAGE_SHIFT;
  34.435 -            while (pg < MEM_AVAILABLE_PAGES && pg < start) {
  34.436 -                set_bit(pg, mem_available_pages);
  34.437 -                pg++;
  34.438 -            }
  34.439 -
  34.440 -            pg = end  >> PAGE_SHIFT;
  34.441 -        }
  34.442 -    }
  34.443 -
  34.444 -    /* Now make sure we mark our own memory */
  34.445 -    pg =  (ulong)_start >> PAGE_SHIFT;
  34.446 -    start = (ulong)_end >> PAGE_SHIFT;
  34.447 -
  34.448 -    DBG("%s: marking 0x%x - 0x%lx\n", __func__,
  34.449 -        pg << PAGE_SHIFT, start << PAGE_SHIFT);
  34.450 -
  34.451 -    /* Lets try and detect if our image has stepped on something. It
  34.452 -     * is possible that FW has already subtracted our image from
  34.453 -     * available memory so we must make sure that the previous bits
  34.454 -     * are the same for the whole image */
  34.455 -    tst = test_and_set_bit(pg, mem_available_pages);
  34.456 -    ++pg;
  34.457 -    while (pg <= start) {
  34.458 -        if (test_and_set_bit(pg, mem_available_pages) != tst)
  34.459 -            of_panic("%s: pg :0x%x of our image is different\n",
  34.460 -                     __func__, pg);
  34.461 -        ++pg;
  34.462 -    }
  34.463 -
  34.464 -    DBG("%s: marking 0x%x - 0x%x\n", __func__,
  34.465 -        0 << PAGE_SHIFT, 3 << PAGE_SHIFT);
  34.466 -    /* First for pages (where the vectors are) should be left alone as well */
  34.467 -    set_bit(0, mem_available_pages);
  34.468 -    set_bit(1, mem_available_pages);
  34.469 -    set_bit(2, mem_available_pages);
  34.470 -    set_bit(3, mem_available_pages);
  34.471 -}
  34.472 -
  34.473 -#ifdef BOOT_OF_FREE
  34.474 -/* this is here in case we ever need a free call at a later date */
  34.475 -static void boot_of_free(ulong addr, ulong size)
  34.476 -{
  34.477 -    ulong bits;
  34.478 -    ulong pos;
  34.479 -    ulong i;
  34.480 -
  34.481 -    size = ALIGN_UP(size, PAGE_SIZE);
  34.482 -    bits = size >> PAGE_SHIFT;
  34.483 -    pos = addr >> PAGE_SHIFT;
  34.484 -
  34.485 -    for (i = 0; i < bits; i++) {
  34.486 -        if (!test_and_clear_bit(pos + i, mem_available_pages))
  34.487 -            of_panic("%s: pg :0x%lx was never allocated\n",
  34.488 -                     __func__, pos + i);
  34.489 -    }
  34.490 -}
  34.491 -#endif
  34.492 -
  34.493 -static ulong boot_of_alloc(ulong size)
  34.494 -{
  34.495 -    ulong bits;
  34.496 -    ulong pos;
  34.497 -
  34.498 -    if (size == 0)
  34.499 -        return 0;
  34.500 -
  34.501 -    DBG("%s(0x%lx)\n", __func__, size);
  34.502 -
  34.503 -    size = ALIGN_UP(size, PAGE_SIZE);
  34.504 -    bits = size >> PAGE_SHIFT;
  34.505 -    pos = 0;
  34.506 -    for (;;) {
  34.507 -        ulong i;
  34.508 -
  34.509 -        pos = find_next_zero_bit(mem_available_pages,
  34.510 -                                 MEM_AVAILABLE_PAGES, pos);
  34.511 -        DBG("%s: found start bit at: 0x%lx\n", __func__, pos);
  34.512 -
  34.513 -        /* found nothing */
  34.514 -        if ((pos + bits) > MEM_AVAILABLE_PAGES) {
  34.515 -            of_printf("%s: allocation of size: 0x%lx failed\n",
  34.516 -                     __func__, size);
  34.517 -            return 0;
  34.518 -        }
  34.519 -
  34.520 -        /* find a set that fits */
  34.521 -        DBG("%s: checking for 0x%lx bits: 0x%lx\n", __func__, bits, pos);
  34.522 -
  34.523 -        i = find_next_bit(mem_available_pages, MEM_AVAILABLE_PAGES, pos);  
  34.524 -        if (i - pos >= bits) {
  34.525 -            uint addr = pos << PAGE_SHIFT;
  34.526 -
  34.527 -            /* make sure OF is happy with our choice */
  34.528 -            if (of_claim(addr, size, 0) != OF_FAILURE) {
  34.529 -                for (i = 0; i < bits; i++)
  34.530 -                    set_bit(pos + i, mem_available_pages);
  34.531 -
  34.532 -                DBG("%s: 0x%lx is good returning 0x%x\n",
  34.533 -                    __func__, pos, addr);
  34.534 -                return addr;
  34.535 -            }
  34.536 -            /* if OF did not like the address then simply start from
  34.537 -             * the next bit */
  34.538 -            i = 1;
  34.539 -        }
  34.540 -
  34.541 -        pos = pos + i;
  34.542 -    }
  34.543 -}
  34.544 -
  34.545 -int boot_of_mem_avail(int pos, ulong *startpage, ulong *endpage)
  34.546 -{
  34.547 -    ulong freebit;
  34.548 -    ulong usedbit;
  34.549 -
  34.550 -    if (pos >= MEM_AVAILABLE_PAGES)
  34.551 -        /* Stop iterating. */
  34.552 -        return -1;
  34.553 -
  34.554 -    /* Find first free page. */
  34.555 -    freebit = find_next_zero_bit(mem_available_pages, MEM_AVAILABLE_PAGES, pos);
  34.556 -    if (freebit >= MEM_AVAILABLE_PAGES) {
  34.557 -        /* We know everything after MEM_AVAILABLE_PAGES is still free. */
  34.558 -        *startpage = MEM_AVAILABLE_PAGES << PAGE_SHIFT;
  34.559 -        *endpage = ~0UL;
  34.560 -        return freebit;
  34.561 -    }
  34.562 -    *startpage = freebit << PAGE_SHIFT;
  34.563 -
  34.564 -    /* Now find first used page after that. */
  34.565 -    usedbit = find_next_bit(mem_available_pages, MEM_AVAILABLE_PAGES, freebit);
  34.566 -    if (usedbit >= MEM_AVAILABLE_PAGES) {
  34.567 -        /* We know everything after MEM_AVAILABLE_PAGES is still free. */
  34.568 -        *endpage = ~0UL;
  34.569 -        return usedbit;
  34.570 -    }
  34.571 -
  34.572 -    *endpage = usedbit << PAGE_SHIFT;
  34.573 -    return usedbit;
  34.574 -}
  34.575 -
  34.576 -static ulong boot_of_mem_init(void)
  34.577 -{
  34.578 -    int root;
  34.579 -    int p;
  34.580 -    int rc;
  34.581 -    uint addr_cells;
  34.582 -    uint size_cells;
  34.583 -
  34.584 -    root = of_finddevice("/");
  34.585 -    p = of_getchild(root);
  34.586 -
  34.587 -    /* code is writen to assume sizes of 1 */
  34.588 -    of_getprop(root, "#address-cells", &addr_cells,
  34.589 -               sizeof (addr_cells));
  34.590 -    of_getprop(root, "#size-cells", &size_cells,
  34.591 -               sizeof (size_cells));
  34.592 -    DBG("%s: address_cells=%d  size_cells=%d\n",
  34.593 -                    __func__, addr_cells, size_cells);
  34.594 -
  34.595 -    /* We do ream memory discovery later, for now we only want to find
  34.596 -     * the first LMB */
  34.597 -    do {
  34.598 -        const char memory[] = "memory";
  34.599 -        char type[32];
  34.600 -
  34.601 -        type[0] = '\0';
  34.602 -
  34.603 -        of_getprop(p, "device_type", type, sizeof (type));
  34.604 -        if (strncmp(type, memory, sizeof (memory)) == 0) {
  34.605 -            uint reg[48];  
  34.606 -            u64 start;
  34.607 -            u64 size;
  34.608 -            int r;
  34.609 -            int l;
  34.610 -
  34.611 -            rc = of_getprop(p, "reg", reg, sizeof (reg));
  34.612 -            if (rc == OF_FAILURE) {
  34.613 -                of_panic("no reg property for memory node: 0x%x.\n", p);
  34.614 -            }
  34.615 -
  34.616 -            l = rc / sizeof(reg[0]); /* number reg element */
  34.617 -            DBG("%s: number of bytes in property 'reg' %d\n",
  34.618 -                            __func__, rc);
  34.619 -            
  34.620 -            r = 0;
  34.621 -            while (r < l) {
  34.622 -                start = reg[r++];
  34.623 -                if (addr_cells == 2 && (r < l) )
  34.624 -                    start = (start << 32) | reg[r++];
  34.625 -
  34.626 -                if (r >= l)
  34.627 -                    break;  /* partial line.  Skip */
  34.628 -
  34.629 -                if (start > 0) {
  34.630 -                    /* this is not the first LMB so we skip it */
  34.631 -                    break;
  34.632 -                }
  34.633 -
  34.634 -                size = reg[r++];
  34.635 -                if (size_cells == 2 && (r < l) )
  34.636 -                    size = (size << 32) | reg[r++];
  34.637 -                
  34.638 -                if (r > l)
  34.639 -                    break;  /* partial line.  Skip */
  34.640 -
  34.641 -                boot_of_alloc_init(p, addr_cells, size_cells);
  34.642 -                
  34.643 -                eomem = size;
  34.644 -                return size;
  34.645 -            }
  34.646 -        }
  34.647 -        p = of_getpeer(p);
  34.648 -    } while (p != OF_FAILURE && p != 0);
  34.649 -
  34.650 -    return 0;
  34.651 -}
  34.652 -
  34.653 -static int save_props(void *m, ofdn_t n, int pkg)
  34.654 -{
  34.655 -    int ret;
  34.656 -    char name[128];
  34.657 -    int result = 1;
  34.658 -    int found_name = 0;
  34.659 -    int found_device_type = 0;
  34.660 -    const char name_str[] = "name";
  34.661 -    const char devtype_str[] = "device_type";
  34.662 -
  34.663 -    /* get first */
  34.664 -    result = of_nextprop(pkg, 0, name);
  34.665 -
  34.666 -    while (result > 0) {
  34.667 -        int sz;
  34.668 -        u64 obj[1024];
  34.669 -
  34.670 -        sz = of_getproplen(pkg, name);
  34.671 -        if (sz >= 0) {
  34.672 -            ret = OF_SUCCESS;
  34.673 -        } else {
  34.674 -            ret = OF_FAILURE;
  34.675 -        }
  34.676 -
  34.677 -        if (ret == OF_SUCCESS) {
  34.678 -            int actual = 0;
  34.679 -            ofdn_t pos;
  34.680 -
  34.681 -            if (sz > 0) {
  34.682 -                if (sz > sizeof (obj)) {
  34.683 -                    of_panic("obj array not big enough for 0x%x\n", sz);
  34.684 -                }
  34.685 -                actual = of_getprop(pkg, name, obj, sz);
  34.686 -                if (actual > sz)
  34.687 -                    of_panic("obj too small");
  34.688 -            }
  34.689 -
  34.690 -            if (strncmp(name, name_str, sizeof(name_str)) == 0) {
  34.691 -                found_name = 1;
  34.692 -            }
  34.693 -
  34.694 -            if (strncmp(name, devtype_str, sizeof(devtype_str)) == 0) {
  34.695 -                found_device_type = 1;
  34.696 -            }
  34.697 -
  34.698 -            pos = ofd_prop_add(m, n, name, obj, actual);
  34.699 -            if (pos == 0)
  34.700 -                of_panic("prop_create");
  34.701 -        }
  34.702 -
  34.703 -        result = of_nextprop(pkg, name, name);
  34.704 -    }
  34.705 -
  34.706 -    return 1;
  34.707 -}
  34.708 -
  34.709 -
  34.710 -static void do_pkg(void *m, ofdn_t n, int p, char *path, size_t psz)
  34.711 -{
  34.712 -    int pnext;
  34.713 -    ofdn_t nnext;
  34.714 -    int sz;
  34.715 -
  34.716 -retry:
  34.717 -    save_props(m, n, p);
  34.718 -
  34.719 -    /* do children first */
  34.720 -    pnext = of_getchild(p);
  34.721 -
  34.722 -    if (pnext != 0) {
  34.723 -        sz = of_package_to_path(pnext, path, psz);
  34.724 -        if (sz == OF_FAILURE)
  34.725 -            of_panic("bad path\n");
  34.726 -
  34.727 -        nnext = ofd_node_child_create(m, n, path, sz);
  34.728 -        if (nnext == 0)
  34.729 -            of_panic("out of mem\n");
  34.730 -
  34.731 -        do_pkg(m, nnext, pnext, path, psz);
  34.732 -    }
  34.733 -
  34.734 -    /* do peer */
  34.735 -    pnext = of_getpeer(p);
  34.736 -
  34.737 -    if (pnext != 0) {
  34.738 -        sz = of_package_to_path(pnext, path, psz);
  34.739 -
  34.740 -        nnext = ofd_node_peer_create(m, n, path, sz);
  34.741 -        if (nnext <= 0)
  34.742 -            of_panic("out of space in OFD tree.\n");
  34.743 -
  34.744 -        n = nnext;
  34.745 -        p = pnext;
  34.746 -        goto retry;
  34.747 -    }
  34.748 -}
  34.749 -
  34.750 -static long pkg_save(void *mem)
  34.751 -{
  34.752 -    int root;
  34.753 -    char path[256];
  34.754 -    int r;
  34.755 -
  34.756 -    path[0]='/';
  34.757 -    path[1]='\0';
  34.758 -
  34.759 -    /* get root */
  34.760 -    root = of_getpeer(0);
  34.761 -    if (root == OF_FAILURE)
  34.762 -        of_panic("no root package\n");
  34.763 -
  34.764 -    do_pkg(mem, OFD_ROOT, root, path, sizeof(path));
  34.765 -
  34.766 -    r = ofd_size(mem);
  34.767 -
  34.768 -    of_printf("%s: saved device tree in 0x%x bytes\n", __func__, r);
  34.769 -
  34.770 -    return r;
  34.771 -}
  34.772 -
  34.773 -static int boot_of_fixup_refs(void *mem)
  34.774 -{
  34.775 -    static const char *fixup_props[] = {
  34.776 -        "interrupt-parent",
  34.777 -    };
  34.778 -    int i;
  34.779 -    int count = 0;
  34.780 -
  34.781 -    for (i = 0; i < ARRAY_SIZE(fixup_props); i++) {
  34.782 -        ofdn_t c;
  34.783 -        const char *name = fixup_props[i];
  34.784 -
  34.785 -        c = ofd_node_find_by_prop(mem, OFD_ROOT, name, NULL, 0);
  34.786 -        while (c > 0) {
  34.787 -            const char *path;
  34.788 -            int rp;
  34.789 -            int ref;
  34.790 -            ofdn_t dp;
  34.791 -            int rc;
  34.792 -            ofdn_t upd;
  34.793 -            char ofpath[256];
  34.794 -
  34.795 -            path = ofd_node_path(mem, c);
  34.796 -            if (path == NULL)
  34.797 -                of_panic("no path to found prop: %s\n", name);
  34.798 -
  34.799 -            rp = of_finddevice(path);
  34.800 -            if (rp == OF_FAILURE)
  34.801 -                of_panic("no real device for: name %s, path %s\n",
  34.802 -                          name, path);
  34.803 -            /* Note: In theory 0 is a valid node handle but it is highly
  34.804 -             * unlikely.
  34.805 -             */
  34.806 -            if (rp == 0) {
  34.807 -                of_panic("%s: of_finddevice returns 0 for path %s\n",
  34.808 -                                    __func__, path);
  34.809 -            } 
  34.810 -
  34.811 -            rc = of_getprop(rp, name, &ref, sizeof(ref));
  34.812 -            if ((rc == OF_FAILURE) || (rc == 0))
  34.813 -                of_panic("no prop: name %s, path %s, device 0x%x\n",
  34.814 -                         name, path, rp);
  34.815 -
  34.816 -            rc = of_package_to_path(ref, ofpath, sizeof (ofpath));
  34.817 -            if (rc == OF_FAILURE)
  34.818 -                of_panic("no package: name %s, path %s, device 0x%x,\n"
  34.819 -                         "ref 0x%x\n", name, path, rp, ref);
  34.820 -
  34.821 -            dp = ofd_node_find(mem, ofpath);
  34.822 -            if (dp <= 0)
  34.823 -                of_panic("no ofd node for OF node[0x%x]: %s\n",
  34.824 -                         ref, ofpath);
  34.825 -
  34.826 -            ref = dp;
  34.827 -
  34.828 -            upd = ofd_prop_add(mem, c, name, &ref, sizeof(ref));
  34.829 -            if (upd <= 0)
  34.830 -                of_panic("update failed: %s\n", name);
  34.831 -
  34.832 -#ifdef DEBUG
  34.833 -            of_printf("%s: %s/%s -> %s\n", __func__,
  34.834 -                    path, name, ofpath);
  34.835 -#endif
  34.836 -            ++count;
  34.837 -            c = ofd_node_find_next(mem, c);
  34.838 -        }
  34.839 -    }
  34.840 -    return count;
  34.841 -}
  34.842 -
  34.843 -static int boot_of_fixup_chosen(void *mem)
  34.844 -{
  34.845 -    int ch;
  34.846 -    ofdn_t dn;
  34.847 -    ofdn_t dc;
  34.848 -    int val;
  34.849 -    int rc;
  34.850 -    char ofpath[256];
  34.851 -
  34.852 -    ch = of_finddevice("/chosen");
  34.853 -    if (ch == OF_FAILURE)
  34.854 -        of_panic("/chosen not found\n");
  34.855 -
  34.856 -    rc = of_getprop(ch, "cpu", &val, sizeof (val));
  34.857 -
  34.858 -    if (rc != OF_FAILURE) {
  34.859 -        rc = of_instance_to_path(val, ofpath, sizeof (ofpath));
  34.860 -
  34.861 -        if (rc > 0) {
  34.862 -            dn = ofd_node_find(mem, ofpath);
  34.863 -            if (dn <= 0)
  34.864 -                of_panic("no node for: %s\n", ofpath);
  34.865 -
  34.866 -            ofd_boot_cpu = dn;
  34.867 -            val = dn;
  34.868 -
  34.869 -            dn = ofd_node_find(mem, "/chosen");
  34.870 -            if (dn <= 0)
  34.871 -                of_panic("no /chosen node\n");
  34.872 -
  34.873 -            dc = ofd_prop_add(mem, dn, "cpu", &val, sizeof (val));
  34.874 -            if (dc <= 0)
  34.875 -                of_panic("could not fix /chosen/cpu\n");
  34.876 -            rc = 1;
  34.877 -        } else {
  34.878 -            of_printf("*** can't find path to booting cpu, "
  34.879 -                    "SMP is disabled\n");
  34.880 -            ofd_boot_cpu = -1;
  34.881 -        }
  34.882 -    }
  34.883 -    return rc;
  34.884 -}
  34.885 -
  34.886 -/* PIBS Version 1.05.0000 04/26/2005 has an incorrect /ht/isa/ranges
  34.887 - * property.  The values are bad, and it doesn't even have the
  34.888 - * right number of cells. */
  34.889 -
  34.890 -static void __init boot_of_fix_maple(void)
  34.891 -{
  34.892 -    int isa;
  34.893 -    const char *ranges = "ranges";
  34.894 -    u32 isa_ranges[3];
  34.895 -    const u32 isa_test[] = { 0x00000001, 0xf4000000, 0x00010000 };
  34.896 -    const u32 isa_fixed[] = {
  34.897 -        0x00000001,
  34.898 -        0x00000000,
  34.899 -        0x00000000, /* 0xf4000000, matt says this */
  34.900 -        0x00000000,
  34.901 -        0x00000000,
  34.902 -        0x00010000
  34.903 -    };
  34.904 -
  34.905 -    isa = of_finddevice("/ht@0/isa@4");
  34.906 -    if (isa != OF_FAILURE) {
  34.907 -        if (of_getproplen(isa, ranges) == sizeof (isa_test)) {
  34.908 -            of_getprop(isa, ranges, isa_ranges, sizeof (isa_ranges));
  34.909 -            if (memcmp(isa_ranges, isa_test, sizeof (isa_test)) == 0) {
  34.910 -                int rc;
  34.911 -
  34.912 -                of_printf("OF: fixing bogus ISA range on maple\n");
  34.913 -                rc = of_setprop(isa, ranges, isa_fixed, sizeof (isa_fixed));
  34.914 -                if (rc == OF_FAILURE) {
  34.915 -                    of_panic("of_setprop() failed\n");
  34.916 -                }
  34.917 -            }
  34.918 -        }
  34.919 -    }
  34.920 -}
  34.921 -
  34.922 -void __init boot_of_serial(void *oft)
  34.923 -{
  34.924 -    int n;
  34.925 -    int p;
  34.926 -    int rc;
  34.927 -    u32 val[3];
  34.928 -    char buf[128];
  34.929 -
  34.930 -    n = of_instance_to_package(of_out);
  34.931 -    if (n == OF_FAILURE) {
  34.932 -        of_panic("instance-to-package of /chosen/stdout: failed\n");
  34.933 -    }
  34.934 -    
  34.935 -    /* Prune all serial devices from the device tree, including the
  34.936 -     * one pointed to by /chosen/stdout, because a guest domain can
  34.937 -     * initialize them and in so doing corrupt our console output.
  34.938 -     */
  34.939 -    for (p = n; p > 0; p = of_getpeer(p)) {
  34.940 -        char type[32];
  34.941 -
  34.942 -        rc = of_package_to_path(p, buf, sizeof(buf));
  34.943 -        if (rc == OF_FAILURE)
  34.944 -            of_panic("package-to-path failed\n");
  34.945 -
  34.946 -        rc = of_getprop(p, "device_type", type, sizeof (type));
  34.947 -        if (rc == OF_FAILURE) {
  34.948 -            of_printf("%s: fetching type of `%s' failed\n", __func__, buf);
  34.949 -            continue;
  34.950 -        }
  34.951 -
  34.952 -        if (strcmp(type, "serial") != 0)
  34.953 -            continue;
  34.954 -
  34.955 -        of_printf("pruning `%s' from devtree\n", buf);
  34.956 -        rc = ofd_prune_path(oft, buf);
  34.957 -        if (rc < 0)
  34.958 -            of_panic("prune of `%s' failed\n", buf);
  34.959 -    }
  34.960 -
  34.961 -    p = of_getparent(n);
  34.962 -    if (p == OF_FAILURE) {
  34.963 -        of_panic("no parent for: 0x%x\n", n);
  34.964 -    }
  34.965 -
  34.966 -    buf[0] = '\0';
  34.967 -    of_getprop(p, "device_type", buf, sizeof (buf));
  34.968 -    if (strstr(buf, "isa") == NULL) {
  34.969 -        of_panic("only ISA UARTS supported\n");
  34.970 -    }
  34.971 -
  34.972 -    /* should get this from devtree */
  34.973 -    isa_io_base = 0xf4000000;
  34.974 -    of_printf("%s: ISA base: 0x%lx\n", __func__, isa_io_base);
  34.975 -
  34.976 -    buf[0] = '\0';
  34.977 -    of_getprop(n, "device_type", buf, sizeof (buf));
  34.978 -    if (strstr(buf, "serial") == NULL) {
  34.979 -        of_panic("only UARTS supported\n");
  34.980 -    }
  34.981 -
  34.982 -    rc = of_getprop(n, "reg", val, sizeof (val));
  34.983 -    if (rc == OF_FAILURE) {
  34.984 -        of_panic("%s: no location for serial port\n", __func__);
  34.985 -    }
  34.986 -
  34.987 -    ns16550.baud = BAUD_AUTO;
  34.988 -    ns16550.data_bits = 8;
  34.989 -    ns16550.parity = 'n';
  34.990 -    ns16550.stop_bits = 1;
  34.991 -
  34.992 -    rc = of_getprop(n, "interrupts", val, sizeof (val));
  34.993 -    if (rc == OF_FAILURE) {
  34.994 -        of_printf("%s: no ISRC, forcing poll mode\n", __func__);
  34.995 -        ns16550.irq = 0;
  34.996 -    } else {
  34.997 -        ns16550.irq = val[0];
  34.998 -        of_printf("%s: ISRC=0x%x, but forcing poll mode\n",
  34.999 -                  __func__, ns16550.irq);
 34.1000 -        ns16550.irq = 0;
 34.1001 -    }
 34.1002 -}
 34.1003 -
 34.1004 -static int __init boot_of_rtas(void)
 34.1005 -{
 34.1006 -    int rtas_node;
 34.1007 -    int rtas_instance;
 34.1008 -    uint size = 0;
 34.1009 -    int res[2];
 34.1010 -    int mem;
 34.1011 -    int ret;
 34.1012 -
 34.1013 -    rtas_node = of_finddevice("/rtas");
 34.1014 -
 34.1015 -    if (rtas_node <= 0) {
 34.1016 -        of_printf("No RTAS, Xen has no power control\n");
 34.1017 -        return 0;
 34.1018 -    }
 34.1019 -    of_getprop(rtas_node, "rtas-size", &size, sizeof (size));
 34.1020 -    if (size == 0) {
 34.1021 -        of_printf("RTAS, has no size\n");
 34.1022 -        return 0;
 34.1023 -    }
 34.1024 -
 34.1025 -    rtas_instance = of_open("/rtas");
 34.1026 -    if (rtas_instance == OF_FAILURE) {
 34.1027 -        of_printf("RTAS, could not open\n");
 34.1028 -        return 0;
 34.1029 -    }
 34.1030 -
 34.1031 -    size = ALIGN_UP(size, PAGE_SIZE);
 34.1032 -    
 34.1033 -    mem = boot_of_alloc(size);
 34.1034 -    if (mem == 0)
 34.1035 -        of_panic("Could not allocate RTAS tree\n");
 34.1036 -
 34.1037 -    of_printf("instantiating RTAS at: 0x%x\n", mem);
 34.1038 -
 34.1039 -    ret = of_call("call-method", 3, 2, res,
 34.1040 -                  "instantiate-rtas", rtas_instance, mem);
 34.1041 -    if (ret == OF_FAILURE) {
 34.1042 -        of_printf("RTAS, could not open\n");
 34.1043 -        return 0;
 34.1044 -    }
 34.1045 -    
 34.1046 -    rtas_entry = res[1];
 34.1047 -    rtas_base = mem;
 34.1048 -    rtas_end = mem + size;
 34.1049 -    rtas_msr = of_msr;
 34.1050 -
 34.1051 -    return 1;
 34.1052 -}
 34.1053 -
 34.1054 -void __init *boot_of_devtree(void)
 34.1055 -{
 34.1056 -    void *oft;
 34.1057 -    ulong oft_sz = 48 * PAGE_SIZE;
 34.1058 -    ulong alloc_sz = 32 << 10;    /* 32KiB should be plenty */
 34.1059 -    ulong sz;
 34.1060 -
 34.1061 -    /* snapshot the tree */
 34.1062 -    oft = (void *)boot_of_alloc(alloc_sz);
 34.1063 -    if (oft == NULL)
 34.1064 -        of_panic("Could not allocate OFD tree\n");
 34.1065 -
 34.1066 -    of_printf("creating oftree at: 0x%p\n", oft);
 34.1067 -    of_test("package-to-path");
 34.1068 -    oft = ofd_create(oft, alloc_sz);
 34.1069 -    pkg_save(oft);
 34.1070 -    sz = ofd_size(oft);
 34.1071 -
 34.1072 -    if (sz > alloc_sz)
 34.1073 -        of_panic("Could not fit all of native devtree in 0x%lx of memory\n",
 34.1074 -            alloc_sz);
 34.1075 -
 34.1076 -    boot_of_fixup_refs(oft);
 34.1077 -    boot_of_fixup_chosen(oft);
 34.1078 -
 34.1079 -    if (sz > alloc_sz)
 34.1080 -         of_panic("Could not fit all devtree fixupsin 0x%lx of memory\n",
 34.1081 -            alloc_sz);
 34.1082 -
 34.1083 -    ofd_walk(oft, __func__, OFD_ROOT, /* add_hype_props */ NULL, 2);
 34.1084 -
 34.1085 -    oftree = (ulong)oft;
 34.1086 -    oftree = (ulong)oft + oft_sz;
 34.1087 -    oftree_len = oft_sz; 
 34.1088 -
 34.1089 -    return oft;
 34.1090 -}
 34.1091 -
 34.1092 -static int __init boot_of_cpus(void)
 34.1093 -{
 34.1094 -    int cpus_node, cpu_node;
 34.1095 -    int bootcpu_instance, bootcpu_node;
 34.1096 -    int logical;
 34.1097 -    int result;
 34.1098 -    s32 cpuid;
 34.1099 -    u32 cpu_clock[2];
 34.1100 -    extern uint cpu_hard_id[NR_CPUS];
 34.1101 -    u32 tbf;
 34.1102 -
 34.1103 -    /* Look up which CPU we are running on right now and get all info
 34.1104 -     * from there */
 34.1105 -    result = of_getprop(bof_chosen, "cpu",
 34.1106 -                        &bootcpu_instance, sizeof (bootcpu_instance));
 34.1107 -    if (result == OF_FAILURE)
 34.1108 -        of_panic("Failed to look up boot cpu instance\n");
 34.1109 -
 34.1110 -    bootcpu_node = of_instance_to_package(bootcpu_instance);
 34.1111 -    if (result == OF_FAILURE)
 34.1112 -        of_panic("Failed to look up boot cpu package\n");
 34.1113 -
 34.1114 -    cpu_node = bootcpu_node;
 34.1115 -
 34.1116 -    result = of_getprop(cpu_node, "timebase-frequency", &tbf, sizeof(tbf));
 34.1117 -    timebase_freq = tbf;
 34.1118 -    if (result == OF_FAILURE) {
 34.1119 -        of_panic("Couldn't get timebase frequency!\n");
 34.1120 -    }
 34.1121 -    of_printf("OF: timebase-frequency = %ld Hz\n", timebase_freq);
 34.1122 -
 34.1123 -    result = of_getprop(cpu_node, "clock-frequency",
 34.1124 -                        &cpu_clock, sizeof(cpu_clock));
 34.1125 -    if (result == OF_FAILURE || (result !=4 && result != 8)) {
 34.1126 -        of_panic("Couldn't get clock frequency!\n");
 34.1127 -    }
 34.1128 -    cpu_khz = cpu_clock[0];
 34.1129 -    if (result == 8) {
 34.1130 -        cpu_khz <<= 32;
 34.1131 -        cpu_khz |= cpu_clock[1];
 34.1132 -    }
 34.1133 -    cpu_khz /= 1000;
 34.1134 -    of_printf("OF: clock-frequency = %ld KHz\n", cpu_khz);
 34.1135 -
 34.1136 -    /* We want a continuous logical cpu number space and we'll make
 34.1137 -     * the booting CPU logical 0.  */
 34.1138 -    cpu_set(0, cpu_present_map);
 34.1139 -    cpu_set(0, cpu_online_map);
 34.1140 -    cpu_set(0, cpu_possible_map);
 34.1141 -
 34.1142 -    result = of_getprop(cpu_node, "reg", &cpuid, sizeof(cpuid));
 34.1143 -    cpu_hard_id[0] = cpuid;
 34.1144 -
 34.1145 -    /* Spin up all CPUS, even if there are more than NR_CPUS or we are
 34.1146 -     * runnign nosmp, because Open Firmware has them spinning on cache
 34.1147 -     * lines which will eventually be scrubbed, which could lead to
 34.1148 -     * random CPU activation.
 34.1149 -     */
 34.1150 -
 34.1151 -    /* Find the base of the multi-CPU package node */
 34.1152 -    cpus_node = of_finddevice("/cpus");
 34.1153 -    if (cpus_node <= 0) {
 34.1154 -        of_printf("Single Processor System\n");
 34.1155 -        return 1;
 34.1156 -    }
 34.1157 -    /* Start with the first child */
 34.1158 -    cpu_node = of_getchild(cpus_node);
 34.1159 -
 34.1160 -    for (logical = 1; cpu_node > 0; logical++) {
 34.1161 -        unsigned int ping, pong;
 34.1162 -        unsigned long now, then, timeout;
 34.1163 -        
 34.1164 -        if (cpu_node == bootcpu_node) {
 34.1165 -            /* same CPU as boot CPU shich we have already made 0 so
 34.1166 -             * reduce the logical count */
 34.1167 -            --logical;
 34.1168 -        } else {
 34.1169 -            result = of_getprop(cpu_node, "reg", &cpuid, sizeof(cpuid));
 34.1170 -            if (result == OF_FAILURE)
 34.1171 -                of_panic("cpuid lookup failed\n");
 34.1172 -
 34.1173 -            cpu_hard_id[logical] = cpuid;
 34.1174 -
 34.1175 -            of_printf("spinning up secondary processor #%d: ", logical);
 34.1176 -
 34.1177 -            __spin_ack = ~0x0;
 34.1178 -            ping = __spin_ack;
 34.1179 -            pong = __spin_ack;
 34.1180 -            of_printf("ping = 0x%x: ", ping);
 34.1181 -
 34.1182 -            mb();
 34.1183 -            result = of_start_cpu(cpu_node, (ulong)spin_start, logical);
 34.1184 -            if (result == OF_FAILURE)
 34.1185 -                of_panic("start cpu failed\n");
 34.1186 -
 34.1187 -            /* We will give the secondary processor five seconds to reply.  */
 34.1188 -            then = mftb();
 34.1189 -            timeout = then + (5 * timebase_freq);
 34.1190 -
 34.1191 -            do {
 34.1192 -                now = mftb();
 34.1193 -                if (now >= timeout) {
 34.1194 -                    of_printf("BROKEN: ");
 34.1195 -                    break;
 34.1196 -                }
 34.1197 -
 34.1198 -                mb();
 34.1199 -                pong = __spin_ack;
 34.1200 -            } while (pong == ping);
 34.1201 -            of_printf("pong = 0x%x\n", pong);
 34.1202 -
 34.1203 -            if (pong != ping) {
 34.1204 -                cpu_set(logical, cpu_present_map);
 34.1205 -                cpu_set(logical, cpu_possible_map);
 34.1206 -            }
 34.1207 -        }
 34.1208 -        cpu_node = of_getpeer(cpu_node);
 34.1209 -    }
 34.1210 -    return 1;
 34.1211 -}
 34.1212 -
 34.1213 -void __init boot_of_init(ulong vec, ulong orig_msr)
 34.1214 -{
 34.1215 -    int r;
 34.1216 -
 34.1217 -    of_vec = vec;
 34.1218 -    of_msr = orig_msr;
 34.1219 -
 34.1220 -    if (is_kernel(vec)) {
 34.1221 -        of_panic("Hmm.. OF[0x%lx] seems to have stepped on our image "
 34.1222 -                "that ranges: %p .. %p.\n",
 34.1223 -                vec, _start, _end);
 34.1224 -    }
 34.1225 -    of_printf("%s: _start %p _end %p\n", __func__, _start, _end);
 34.1226 -
 34.1227 -    bof_chosen = of_finddevice("/chosen");
 34.1228 -    of_getprop(bof_chosen, "stdout", &of_out, sizeof (of_out));
 34.1229 -
 34.1230 -    of_printf("%s\n", "---------------------------------------------------");
 34.1231 -    of_printf("OF: Xen/PPC version %d.%d%s (%s@%s) (%s) %s\n",
 34.1232 -              xen_major_version(), xen_minor_version(), xen_extra_version(),
 34.1233 -              xen_compile_by(), xen_compile_domain(),
 34.1234 -              xen_compiler(), xen_compile_date());
 34.1235 -
 34.1236 -    boot_of_fix_maple();
 34.1237 -    r = boot_of_mem_init();
 34.1238 -    if (r == 0)
 34.1239 -        of_panic("failure to initialize memory allocator");
 34.1240 -
 34.1241 -    boot_of_rtas();
 34.1242 -    boot_of_cpus();
 34.1243 -}
 34.1244 -
 34.1245 -void __init boot_of_finish(void)
 34.1246 -{
 34.1247 -    /* end of OF */
 34.1248 -    of_printf("Quiescing Open Firmware ...\n");
 34.1249 -    of_call("quiesce", 0, 0, NULL);
 34.1250 -}
 34.1251 -
 34.1252 -/*
 34.1253 - * Local variables:
 34.1254 - * mode: C
 34.1255 - * c-set-style: "BSD"
 34.1256 - * c-basic-offset: 4
 34.1257 - * tab-width: 4
 34.1258 - * indent-tabs-mode: nil
 34.1259 - * End:
 34.1260 - */
    35.1 --- a/xen/arch/powerpc/cmdline.c	Thu May 08 13:15:45 2008 +0100
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,24 +0,0 @@
    35.4 -/*
    35.5 - * This program is free software; you can redistribute it and/or modify
    35.6 - * it under the terms of the GNU General Public License as published by
    35.7 - * the Free Software Foundation; either version 2 of the License, or
    35.8 - * (at your option) any later version.
    35.9 - *
   35.10 - * This program is distributed in the hope that it will be useful,
   35.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   35.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   35.13 - * GNU General Public License for more details.
   35.14 - *
   35.15 - * You should have received a copy of the GNU General Public License
   35.16 - * along with this program; if not, write to the Free Software
   35.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   35.18 - *
   35.19 - * Copyright (C) IBM Corp. 2006
   35.20 - *
   35.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   35.22 - */
   35.23 -
   35.24 -#include <asm/config.h>
   35.25 -
   35.26 -char builtin_cmdline[CONFIG_CMDLINE_SIZE] 
   35.27 -        __attribute__((section("__builtin_cmdline"))) = CMDLINE;
    36.1 --- a/xen/arch/powerpc/crash.c	Thu May 08 13:15:45 2008 +0100
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,20 +0,0 @@
    36.4 -#include <xen/lib.h>       /* for printk() used in stub */
    36.5 -#include <xen/types.h>
    36.6 -#include <xen/kexec.h>
    36.7 -#include <public/kexec.h>
    36.8 -
    36.9 -void machine_crash_shutdown(void)
   36.10 -{
   36.11 -    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
   36.12 -}
   36.13 -
   36.14 -/*
   36.15 - * Local variables:
   36.16 - * mode: C
   36.17 - * c-set-style: "BSD"
   36.18 - * c-basic-offset: 4
   36.19 - * tab-width: 4
   36.20 - * indent-tabs-mode: nil
   36.21 - * End:
   36.22 - */
   36.23 -
    37.1 --- a/xen/arch/powerpc/dart.c	Thu May 08 13:15:45 2008 +0100
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,297 +0,0 @@
    37.4 -/*
    37.5 - * This program is free software; you can redistribute it and/or modify
    37.6 - * it under the terms of the GNU General Public License as published by
    37.7 - * the Free Software Foundation; either version 2 of the License, or
    37.8 - * (at your option) any later version.
    37.9 - *
   37.10 - * This program is distributed in the hope that it will be useful,
   37.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   37.13 - * GNU General Public License for more details.
   37.14 - *
   37.15 - * You should have received a copy of the GNU General Public License
   37.16 - * along with this program; if not, write to the Free Software
   37.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   37.18 - *
   37.19 - * Copyright (C) IBM Corp. 2005
   37.20 - *
   37.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   37.22 - */
   37.23 -
   37.24 -#include <xen/config.h>
   37.25 -#include <xen/types.h>
   37.26 -#include <xen/mm.h>
   37.27 -#include <asm/cache.h>
   37.28 -#include <xen/init.h>
   37.29 -#include "tce.h"
   37.30 -#include "iommu.h"
   37.31 -#include "dart.h"
   37.32 -#include "oftree.h"
   37.33 -#include "of-devtree.h"
   37.34 -
   37.35 -#undef DEBUG
   37.36 -#ifdef DEBUG
   37.37 -#define DBG(fmt...) printk(fmt)
   37.38 -static int dbg_after;
   37.39 -#define DBG_SET_AFTER dbg_after = 1;
   37.40 -#define DBG_AFTER(fmt...) if (dbg_after) DBG(fmt)
   37.41 -#else
   37.42 -#define DBG(fmt...)
   37.43 -#define DBG_SET_AFTER
   37.44 -#define DBG_AFTER(fmt...)
   37.45 -#endif
   37.46 -
   37.47 -/* Max size of 512 pages */
   37.48 -#define U3_LOG_MAX_PAGES 9
   37.49 -
   37.50 -#define DART_DEF_BASE   0xf8033000UL
   37.51 -#define DART_NONE 0
   37.52 -#define DART_U3 3
   37.53 -#define DART_U4 4
   37.54 -#define DART_WRITE 0x1
   37.55 -#define DART_READ 0x2
   37.56 -
   37.57 -static ulong dummy_page;
   37.58 -static ulong dart_entries;
   37.59 -static struct dart_ops *dops;
   37.60 -static u32 *dart_table;
   37.61 -
   37.62 -union dart_entry {
   37.63 -    u32 de_word;
   37.64 -    struct {
   37.65 -        u32 de_v:1;             /* valid */
   37.66 -        u32 de_rp:1;             /* read protected */
   37.67 -        u32 de_wp:1;             /* write protected */
   37.68 -        u32 _de_res:5;
   37.69 -        u32 de_ppn:24;         /* 24 bit Physical Page Number
   37.70 -                                 * representing address [28:51] */
   37.71 -    } de_bits;
   37.72 -};
   37.73 -
   37.74 -struct dma_window {
   37.75 -    u32 dw_liobn;
   37.76 -    u32 dw_base_hi;
   37.77 -    u64 dw_base;
   37.78 -    u64 dw_size;
   37.79 -};
   37.80 -
   37.81 -struct dart_info {
   37.82 -    struct dma_window di_window;
   37.83 -    ulong di_base;
   37.84 -    int di_model;
   37.85 -};
   37.86 -
   37.87 -static u32 dart_encode(int perm, ulong rpn)
   37.88 -{
   37.89 -    union dart_entry e;
   37.90 -
   37.91 -    e.de_word = 0;
   37.92 -    e.de_bits.de_v = 1;
   37.93 -    e.de_bits.de_ppn = rpn;
   37.94 -
   37.95 -    /* protect the page */
   37.96 -    e.de_bits.de_rp = 1;
   37.97 -    e.de_bits.de_wp = 1;
   37.98 -    if (perm & DART_READ) {
   37.99 -        e.de_bits.de_rp = 0;
  37.100 -    }
  37.101 -    if (perm & DART_WRITE) {
  37.102 -        e.de_bits.de_wp = 0;
  37.103 -    }
  37.104 -    return e.de_word;
  37.105 -}
  37.106 -
  37.107 -static void dart_fill(ulong index, int perm, ulong rpg, ulong num_pg)
  37.108 -{
  37.109 -    u32 volatile *entry = dart_table + index;
  37.110 -    ulong i = 0;
  37.111 -    ulong last_flush = 0;
  37.112 -
  37.113 -    while (1) {
  37.114 -        entry[i] = dart_encode(perm, rpg);
  37.115 -        ++i;
  37.116 -        ++rpg;
  37.117 -        if (i == num_pg) break;
  37.118 -
  37.119 -        if ((((ulong)&entry[i]) % cpu_caches.dline_size) == 0) {
  37.120 -            last_flush = (ulong)&entry[i - 1];
  37.121 -            dcbst(last_flush);
  37.122 -        }
  37.123 -    }
  37.124 -    dcbst((ulong) &entry[i - 1]);
  37.125 -}
  37.126 -
  37.127 -static void dart_clear(ulong index, ulong num_pg)
  37.128 -{
  37.129 -    u32 *entry = dart_table + index;
  37.130 -    ulong i = 0;
  37.131 -    ulong rpg = dummy_page;
  37.132 -    ulong last_flush = 0;
  37.133 -
  37.134 -    while (1) {
  37.135 -        entry[i] = dart_encode(DART_READ | DART_WRITE, rpg);
  37.136 -        ++i;
  37.137 -        if (i == num_pg) break;
  37.138 -
  37.139 -        if ((((ulong)&entry[i]) % cpu_caches.dline_size) == 0) {
  37.140 -            last_flush = (ulong)&entry[i - 1];
  37.141 -            dcbst(last_flush);
  37.142 -        }
  37.143 -    }
  37.144 -    dcbst((ulong)&entry[i - 1]);
  37.145 -}
  37.146 -
  37.147 -static int dart_put(ulong ioba, union tce tce)
  37.148 -{
  37.149 -    ulong index = ioba >> PAGE_SHIFT;
  37.150 -
  37.151 -    if (index > dart_entries) {
  37.152 -        return -1;
  37.153 -    }
  37.154 -
  37.155 -    if (tce.tce_bits.tce_vlps  != 0 || tce.tce_bits.tce_lpx != 0) {
  37.156 -        panic("no support for large TCEs\n");
  37.157 -    }
  37.158 -
  37.159 -    if (tce.tce_bits.tce_read == 0 &&
  37.160 -        tce.tce_bits.tce_write == 0) {
  37.161 -        /* the TCE table is inited by the domain by a bunch of 0
  37.162 -         * perminssion puts.  We are only interesting in debugging the
  37.163 -         * ones after the first put */
  37.164 -        DBG_AFTER(">DART[0x%lx] clear\n", index);
  37.165 -        dart_clear(index, 1);
  37.166 -    } else {
  37.167 -        unsigned perm = 0;
  37.168 -
  37.169 -        if (tce.tce_bits.tce_read)
  37.170 -            perm |= DART_READ;
  37.171 -        if (tce.tce_bits.tce_write)
  37.172 -            perm |= DART_WRITE;
  37.173 -
  37.174 -        DBG("<DART[0x%lx]: ioba: 0x%lx perm:%x[%c%c] rpn:0x%lx\n",
  37.175 -            index, ioba, perm,
  37.176 -            (perm & DART_READ) ? 'R' : '-',
  37.177 -            (perm & DART_WRITE) ? 'W' : '-',
  37.178 -            (ulong)tce.tce_bits.tce_rpn);
  37.179 -        DBG_SET_AFTER;
  37.180 -
  37.181 -        dart_fill(index, perm, tce.tce_bits.tce_rpn, 1);
  37.182 -    }
  37.183 -    dops->do_inv_entry(tce.tce_bits.tce_rpn);
  37.184 -    
  37.185 -    return 0;
  37.186 -}
  37.187 -
  37.188 -static int find_dart(struct dart_info *di)
  37.189 -{
  37.190 -    int rc;
  37.191 -    void *ofd_p;
  37.192 -    ofdn_t n;
  37.193 -    char compat[128];
  37.194 -
  37.195 -    if (on_systemsim()) {
  37.196 -        DBG("%s: systemsim does not support a dart\n", __func__);
  37.197 -        return -1;
  37.198 -    }
  37.199 -
  37.200 -    ofd_p = (void *)oftree;
  37.201 -    n = ofd_node_find(ofd_p, "/ht");
  37.202 -    if (n <= 0)
  37.203 -        return -1;
  37.204 -
  37.205 -    /* get the defaults from the HT node model */
  37.206 -    rc = ofd_getprop(ofd_p, n, "compatible", compat, sizeof (compat));
  37.207 -    if (rc <= 0)
  37.208 -        return -1;
  37.209 -
  37.210 -    if (ofd_strstr(compat, rc, "u4"))
  37.211 -        di->di_model = DART_U4;
  37.212 -    else if (ofd_strstr(compat, rc, "u3"))
  37.213 -        di->di_model = DART_U3;
  37.214 -    else {
  37.215 -        DBG("%s: not a U3 or U4\n", __func__);
  37.216 -        return -1;
  37.217 -    }
  37.218 -        
  37.219 -    di->di_base = DART_DEF_BASE;
  37.220 -
  37.221 -    /* FIXME: this should actually be the HT reg value */
  37.222 -    di->di_window.dw_liobn = 0;
  37.223 -    di->di_window.dw_base_hi = 0;
  37.224 -    di->di_window.dw_base = 0;
  37.225 -
  37.226 -    /* lets see if the devtree has more info */
  37.227 -    n = ofd_node_find(ofd_p, "/dart");
  37.228 -    if (n > 0) {
  37.229 -        ulong base;
  37.230 -
  37.231 -        rc = ofd_getprop(ofd_p, n, "compatible", compat, sizeof (compat));
  37.232 -        if (rc > 0) {
  37.233 -            if (strstr(compat, "u4")) {
  37.234 -                di->di_model = DART_U4;
  37.235 -            }
  37.236 -        }
  37.237 -
  37.238 -        rc = ofd_getprop(ofd_p, n, "reg", &base, sizeof (base));
  37.239 -        if (rc > 0) {
  37.240 -            di->di_base = base;
  37.241 -        }
  37.242 -    }
  37.243 -    return 0;
  37.244 -}
  37.245 -
  37.246 -static int init_dart(void)
  37.247 -{
  37.248 -    ulong log_pgs;
  37.249 -    void *ofd_p;
  37.250 -    ofdn_t n;
  37.251 -    struct dart_info di;
  37.252 -
  37.253 -    if (find_dart(&di))
  37.254 -        return 0;
  37.255 -
  37.256 -    /* Max size of 512 pages == 2MB == 1<<21. That siz is good enough for U4 */
  37.257 -    log_pgs = U3_LOG_MAX_PAGES;
  37.258 -    dart_table = alloc_xenheap_pages(log_pgs);
  37.259 -    BUG_ON(dart_table == NULL);
  37.260 -
  37.261 -    dart_entries = (1UL << (log_pgs + PAGE_SHIFT)) / sizeof (union dart_entry);
  37.262 -    di.di_window.dw_size = dart_entries << PAGE_SHIFT;
  37.263 -
  37.264 -    /* Linux uses a dummy page, filling "empty" DART entries with a
  37.265 -       reference to this page to capture stray DMA's */
  37.266 -    dummy_page = (ulong)alloc_xenheap_pages(0);
  37.267 -    clear_page((void *)dummy_page);
  37.268 -    dummy_page >>= PAGE_SHIFT;
  37.269 -
  37.270 -    printk("Initializing DART 0x%lx: tbl: %p[0x%lx] entries: 0x%lx\n",
  37.271 -           di.di_base, dart_table, 1UL << log_pgs, dart_entries);
  37.272 -           
  37.273 -    /* register this iommu */
  37.274 -    iommu_register(di.di_window.dw_liobn, dart_put);
  37.275 -
  37.276 -    switch (di.di_model) {
  37.277 -    case DART_U3:
  37.278 -        dops = u3_init(di.di_base, (ulong)dart_table, 1UL << log_pgs);
  37.279 -        break;
  37.280 -    case DART_U4:
  37.281 -        dops = u4_init(di.di_base, (ulong)dart_table, 1UL << log_pgs);
  37.282 -        break;
  37.283 -    }
  37.284 -
  37.285 -    dart_clear(0, dart_entries);
  37.286 -    dops->do_inv_all();
  37.287 -
  37.288 -    /* fix up the devtree */
  37.289 -    ofd_p = (void *)oftree;
  37.290 -    n = ofd_node_find(ofd_p, "/ht");
  37.291 -    if (n > 0) {
  37.292 -        di.di_window.dw_size = dart_entries << PAGE_SHIFT;
  37.293 -        ofd_prop_add(ofd_p, n, "ibm,dma-window", &di.di_window,
  37.294 -                     sizeof (di.di_window));
  37.295 -    } else {
  37.296 -        panic("%s: no /ht node\n", __func__);
  37.297 -    }
  37.298 -    return 0;
  37.299 -}
  37.300 -__initcall(init_dart);
    38.1 --- a/xen/arch/powerpc/dart.h	Thu May 08 13:15:45 2008 +0100
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,36 +0,0 @@
    38.4 -/*
    38.5 - * This program is free software; you can redistribute it and/or modify
    38.6 - * it under the terms of the GNU General Public License as published by
    38.7 - * the Free Software Foundation; either version 2 of the License, or
    38.8 - * (at your option) any later version.
    38.9 - *
   38.10 - * This program is distributed in the hope that it will be useful,
   38.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   38.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   38.13 - * GNU General Public License for more details.
   38.14 - *
   38.15 - * You should have received a copy of the GNU General Public License
   38.16 - * along with this program; if not, write to the Free Software
   38.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   38.18 - *
   38.19 - * Copyright (C) IBM Corp. 2005
   38.20 - *
   38.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   38.22 - */
   38.23 -
   38.24 -#ifndef _DART_H
   38.25 -#define _DART_H
   38.26 -
   38.27 -#include <xen/config.h>
   38.28 -#include <xen/types.h>
   38.29 -
   38.30 -struct dart_ops {
   38.31 -    void (*do_inv_all)(void);
   38.32 -    void (*do_inv_entry)(ulong pg);
   38.33 -};
   38.34 -
   38.35 -extern struct dart_ops *u3_init(ulong base, ulong table, ulong dart_pages);
   38.36 -extern struct dart_ops *u4_init(ulong base, ulong table, ulong dart_pages);
   38.37 -
   38.38 -#endif /* _DART_H */
   38.39 -
    39.1 --- a/xen/arch/powerpc/dart_u3.c	Thu May 08 13:15:45 2008 +0100
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,108 +0,0 @@
    39.4 -/*
    39.5 - * This program is free software; you can redistribute it and/or modify
    39.6 - * it under the terms of the GNU General Public License as published by
    39.7 - * the Free Software Foundation; either version 2 of the License, or
    39.8 - * (at your option) any later version.
    39.9 - *
   39.10 - * This program is distributed in the hope that it will be useful,
   39.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   39.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   39.13 - * GNU General Public License for more details.
   39.14 - *
   39.15 - * You should have received a copy of the GNU General Public License
   39.16 - * along with this program; if not, write to the Free Software
   39.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   39.18 - *
   39.19 - * Copyright (C) IBM Corp. 2005
   39.20 - *
   39.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   39.22 - */
   39.23 -
   39.24 -#undef DEBUG
   39.25 -
   39.26 -#include <xen/config.h>
   39.27 -#include <xen/types.h>
   39.28 -#include <xen/sched.h>
   39.29 -#include <xen/mm.h>
   39.30 -#include <public/xen.h>
   39.31 -#include <asm/io.h>
   39.32 -#include <asm/current.h>
   39.33 -#include "tce.h"
   39.34 -#include "iommu.h"
   39.35 -#include "dart.h"
   39.36 -
   39.37 -union dart_ctl {
   39.38 -    u32 dc_word;
   39.39 -    struct {
   39.40 -        u32 dc_base:20;
   39.41 -        u32 dc_stop_access:1;
   39.42 -        u32 dc_invtlb:1;
   39.43 -        u32 dc_enable:1;
   39.44 -        u32 dc_size:9;
   39.45 -    } reg;
   39.46 -};
   39.47 -
   39.48 -static u32 volatile *dart_ctl_reg;
   39.49 -
   39.50 -static void u3_inv_all(void)
   39.51 -{
   39.52 -    union dart_ctl dc;
   39.53 -    ulong r = 0;
   39.54 -    int l = 0;
   39.55 -
   39.56 -    for (;;) {
   39.57 -        dc.dc_word = in_32(dart_ctl_reg);
   39.58 -        dc.reg.dc_invtlb = 1;
   39.59 -        out_32(dart_ctl_reg, dc.dc_word);
   39.60 -
   39.61 -        do {
   39.62 -            dc.dc_word = in_32(dart_ctl_reg);
   39.63 -            r++;
   39.64 -        } while ((dc.reg.dc_invtlb == 1) && (r < (1 << l)));
   39.65 -
   39.66 -        if (r == (1 << l)) {
   39.67 -            if (l < 4) {
   39.68 -                l++;
   39.69 -                dc.dc_word = in_32(dart_ctl_reg);
   39.70 -                dc.reg.dc_invtlb = 0;
   39.71 -                out_32(dart_ctl_reg, dc.dc_word);
   39.72 -                continue;
   39.73 -            } else {
   39.74 -                panic(" broken U3???\n");
   39.75 -            }
   39.76 -        }
   39.77 -        return;
   39.78 -    }
   39.79 -}
   39.80 -
   39.81 -static void u3_inv_entry(ulong pg)
   39.82 -{
   39.83 -    /* sadly single entry invalidation has been reported not to work */
   39.84 -    u3_inv_all();
   39.85 -}
   39.86 -
   39.87 -static struct dart_ops u3_ops = {
   39.88 -    .do_inv_all = u3_inv_all,
   39.89 -    .do_inv_entry = u3_inv_entry,
   39.90 -};
   39.91 -
   39.92 -struct dart_ops *u3_init(ulong base, ulong table, ulong dart_pages)
   39.93 -{
   39.94 -    union dart_ctl dc;
   39.95 -
   39.96 -    dart_ctl_reg = (u32 *)base;
   39.97 -
   39.98 -    dc.dc_word = 0;
   39.99 -
  39.100 -    dc.reg.dc_base = table >> PAGE_SHIFT;
  39.101 -    dc.reg.dc_size = dart_pages;
  39.102 -    dc.reg.dc_enable = 1;
  39.103 -
  39.104 -
  39.105 -    printk("Initializing DART Model U3: reg: %p word: %x\n",
  39.106 -           dart_ctl_reg, dc.dc_word);
  39.107 -
  39.108 -    out_32(dart_ctl_reg, dc.dc_word);
  39.109 -
  39.110 -    return &u3_ops;
  39.111 -}
    40.1 --- a/xen/arch/powerpc/dart_u4.c	Thu May 08 13:15:45 2008 +0100
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,184 +0,0 @@
    40.4 -/*
    40.5 - * This program is free software; you can redistribute it and/or modify
    40.6 - * it under the terms of the GNU General Public License as published by
    40.7 - * the Free Software Foundation; either version 2 of the License, or
    40.8 - * (at your option) any later version.
    40.9 - *
   40.10 - * This program is distributed in the hope that it will be useful,
   40.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   40.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   40.13 - * GNU General Public License for more details.
   40.14 - *
   40.15 - * You should have received a copy of the GNU General Public License
   40.16 - * along with this program; if not, write to the Free Software
   40.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   40.18 - *
   40.19 - * Copyright (C) IBM Corp. 2005
   40.20 - *
   40.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   40.22 - */
   40.23 -
   40.24 -#undef DEBUG
   40.25 -#define INVALIDATE_ALL
   40.26 -
   40.27 -#include <xen/config.h>
   40.28 -#include <xen/types.h>
   40.29 -#include <xen/sched.h>
   40.30 -#include <xen/init.h>
   40.31 -#include <xen/mm.h>
   40.32 -#include <public/xen.h>
   40.33 -#include <asm/io.h>
   40.34 -#include <asm/current.h>
   40.35 -#include "tce.h"
   40.36 -#include "iommu.h"
   40.37 -#include "dart.h"
   40.38 -
   40.39 -#define TOO_MANY_RETRIES ~0
   40.40 -
   40.41 -union dart_ctl {
   40.42 -    u32 dc_word;
   40.43 -    struct {
   40.44 -        u32 dc_darten:1;      /* DART Enable (0:disabled) */
   40.45 -        u32 dc_ione:1;        /* Invalidate one DART TLB entry (using ILPN) */
   40.46 -        u32 dc_iall:1;        /* Invalidate all DART TLB entries */
   40.47 -        u32 dc_idle:1;        /* DART is idle */
   40.48 -        u32 dc_peen:1;        /* Parity Checking is enabled */
   40.49 -        u32 dc_ilpn:27;       /* 27-bit Logical Page Address for 
   40.50 -                               * invalidating one TLB entry */
   40.51 -    } dc_bits;
   40.52 -};
   40.53 -
   40.54 -union dart_base {
   40.55 -    u32 db_word;
   40.56 -    struct {
   40.57 -        u32 _db_resv:8;
   40.58 -        u32 db_dartbase:24;     /* Base Address of DART (4K byte Alignment) */
   40.59 -    } db_bits;
   40.60 -};
   40.61 -
   40.62 -union dart_size {
   40.63 -    u32 ds_word;
   40.64 -    struct {
   40.65 -        u32 _ds_resv:15;
   40.66 -        u32 ds_dartsize:17;     /* Size of Dart in 4K-Byte Pages */
   40.67 -    } ds_bits;
   40.68 -};
   40.69 -
   40.70 -union dart_excp {
   40.71 -    u32 de_word;
   40.72 -    struct {
   40.73 -        u32 de_rqsrc:1;    /* Request Source.  [0:PCIE, 1:HT] */
   40.74 -        u32 de_lpn:27;     /* 27–bit Logical Address of Exception [25:51] */
   40.75 -        u32 de_rqop:1;     /* Request operation.  [0:Read, 1:Write] */
   40.76 -        u32 de_xcd:3;      /* Exception code */
   40.77 -    } de_bits;
   40.78 -};
   40.79 -
   40.80 -struct dart {
   40.81 -    /* 0x00 */
   40.82 -    union dart_ctl d_dartcntl;
   40.83 -    u32 _pad0x04_0x10[3];
   40.84 -    /* 0x10 */
   40.85 -    union dart_base d_dartbase;
   40.86 -    u32 _pad0x14_0x20[3];
   40.87 -    /* 0x20 */
   40.88 -    union dart_size d_dartsize;
   40.89 -    u32 _pad0x24_0x30[3];
   40.90 -    /* 0x30 */
   40.91 -    union dart_excp d_dartexcp;
   40.92 -    u32 _pad0x34_0x40[3];
   40.93 -};
   40.94 -
   40.95 -static volatile struct dart *dart;
   40.96 -
   40.97 -static void u4_inv_all(void)
   40.98 -{
   40.99 -    union dart_ctl dc;
  40.100 -    ulong r = 0;
  40.101 -    int l = 0;
  40.102 -
  40.103 -    for (;;) {
  40.104 -        dc.dc_word = in_32(&dart->d_dartcntl.dc_word);
  40.105 -        dc.dc_bits.dc_iall = 1;
  40.106 -        out_32(&dart->d_dartcntl.dc_word, dc.dc_word);
  40.107 -
  40.108 -        do {
  40.109 -            dc.dc_word = in_32(&dart->d_dartcntl.dc_word);
  40.110 -            r++;
  40.111 -        } while ((dc.dc_bits.dc_iall == 1) && (r < (1 << l)));
  40.112 -
  40.113 -        if (r == (1 << l)) {
  40.114 -            if (l < 4) {
  40.115 -                l++;
  40.116 -                dc.dc_word = in_32(&dart->d_dartcntl.dc_word);
  40.117 -                dc.dc_bits.dc_iall = 0;
  40.118 -                out_32(&dart->d_dartcntl.dc_word, dc.dc_word);
  40.119 -                continue;
  40.120 -            } else {
  40.121 -                panic(" broken U4???\n");
  40.122 -            }
  40.123 -        }
  40.124 -        return;
  40.125 -    }
  40.126 -}
  40.127 -
  40.128 -static void u4_inv_entry(ulong pgn)
  40.129 -{
  40.130 -#ifdef INVALIDATE_ALL
  40.131 -    return u4_inv_all();
  40.132 -#else
  40.133 -    union dart_ctl dc;
  40.134 -    ulong retries = 0;
  40.135 -
  40.136 -    return u4_inv_all();
  40.137 -
  40.138 -    dc.dc_word = in_32(&dart->d_dartcntl.dc_word);
  40.139 -    dc.dc_bits.dc_ilpn = pgn;
  40.140 -    dc.dc_bits.dc_ione = 1;
  40.141 -    out_32(&dart->d_dartcntl.dc_word, dc.dc_word);
  40.142 -
  40.143 -    /* wait for completion */
  40.144 -    /* FIXME: since we do this from the HV do we need to wait?! */
  40.145 -    do {
  40.146 -        dc.dc_word = in_32(&dart->d_dartcntl.dc_word);
  40.147 -        retries++;
  40.148 -        if (retries > 1000000)
  40.149 -            panic("WAY! too long\n");
  40.150 -    } while (dc.dc_bits.dc_ione != 0);
  40.151 -#endif
  40.152 -}
  40.153 -
  40.154 -static struct dart_ops u4_ops = {
  40.155 -    .do_inv_all = u4_inv_all,
  40.156 -    .do_inv_entry = u4_inv_entry,
  40.157 -};
  40.158 -
  40.159 -struct dart_ops *u4_init(ulong base, ulong table, ulong dart_pages)
  40.160 -{
  40.161 -    union dart_base db;
  40.162 -    union dart_size ds;
  40.163 -    union dart_ctl dc;
  40.164 -
  40.165 -    dart = (struct dart *)base;
  40.166 -
  40.167 -    db.db_word = 0;
  40.168 -    db.db_bits.db_dartbase = table >> PAGE_SHIFT;
  40.169 -
  40.170 -    ds.ds_word = 0;
  40.171 -    ds.ds_bits.ds_dartsize = dart_pages;
  40.172 -
  40.173 -    dc.dc_word = in_32(&dart->d_dartcntl.dc_word);
  40.174 -    if (dc.dc_bits.dc_darten == 1) {
  40.175 -        panic("%s: dart is already enabled: 0x%x\n", __func__, dc.dc_word);
  40.176 -    }
  40.177 -    dc.dc_bits.dc_darten = 1;   /* enable it */
  40.178 -
  40.179 -    printk("Initializing DART Model U4: ctl: 0x%x base: 0x%x size: 0x%x\n",
  40.180 -           dc.dc_word, db.db_word, ds.ds_word);
  40.181 -
  40.182 -    out_32(&dart->d_dartbase.db_word, db.db_word);
  40.183 -    out_32(&dart->d_dartsize.ds_word, ds.ds_word);
  40.184 -    out_32(&dart->d_dartcntl.dc_word, dc.dc_word);
  40.185 -
  40.186 -    return &u4_ops;
  40.187 -}
    41.1 --- a/xen/arch/powerpc/domain.c	Thu May 08 13:15:45 2008 +0100
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,357 +0,0 @@
    41.4 -/*
    41.5 - * This program is free software; you can redistribute it and/or modify
    41.6 - * it under the terms of the GNU General Public License as published by
    41.7 - * the Free Software Foundation; either version 2 of the License, or
    41.8 - * (at your option) any later version.
    41.9 - *
   41.10 - * This program is distributed in the hope that it will be useful,
   41.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   41.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   41.13 - * GNU General Public License for more details.
   41.14 - *
   41.15 - * You should have received a copy of the GNU General Public License
   41.16 - * along with this program; if not, write to the Free Software
   41.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   41.18 - *
   41.19 - * Copyright IBM Corp. 2005, 2006, 2007
   41.20 - *
   41.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   41.22 - *          Ryan Harper <ryanh@us.ibm.com>
   41.23 - *          Hollis Blanchard <hollisb@us.ibm.com>
   41.24 - */
   41.25 -
   41.26 -#include <stdarg.h>
   41.27 -#include <xen/config.h>
   41.28 -#include <xen/lib.h>
   41.29 -#include <xen/sched.h>
   41.30 -#include <xen/mm.h>
   41.31 -#include <xen/serial.h>
   41.32 -#include <xen/domain.h>
   41.33 -#include <xen/console.h>
   41.34 -#include <xen/shutdown.h>
   41.35 -#include <xen/paging.h>
   41.36 -#include <xen/mm.h>
   41.37 -#include <xen/softirq.h>
   41.38 -#include <asm/htab.h>
   41.39 -#include <asm/current.h>
   41.40 -#include <asm/hcalls.h>
   41.41 -#include "rtas.h"
   41.42 -#include "exceptions.h"
   41.43 -
   41.44 -#define next_arg(fmt, args) ({                                              \
   41.45 -    unsigned long __arg;                                                    \
   41.46 -    switch ( *(fmt)++ )                                                     \
   41.47 -    {                                                                       \
   41.48 -    case 'i': __arg = (unsigned long)va_arg(args, unsigned int);  break;    \
   41.49 -    case 'l': __arg = (unsigned long)va_arg(args, unsigned long); break;    \
   41.50 -    case 'p': __arg = (unsigned long)va_arg(args, void *);        break;    \
   41.51 -    case 'h': __arg = (unsigned long)va_arg(args, void *);        break;    \
   41.52 -    default:  __arg = 0; BUG();                                             \
   41.53 -    }                                                                       \
   41.54 -    __arg;                                                                  \
   41.55 -})
   41.56 -
   41.57 -unsigned long hypercall_create_continuation(unsigned int op,
   41.58 -        const char *format, ...)
   41.59 -{
   41.60 -    struct cpu_user_regs *regs = guest_cpu_user_regs();
   41.61 -    const char *p = format;
   41.62 -    va_list args;
   41.63 -    int gprnum = 4;
   41.64 -    int i;
   41.65 -
   41.66 -    va_start(args, format);
   41.67 -
   41.68 -    regs->pc -= 4; /* re-execute 'sc' */
   41.69 -
   41.70 -    for (i = 0; *p != '\0'; i++) {
   41.71 -        regs->gprs[gprnum++] = next_arg(p, args);
   41.72 -    }
   41.73 -
   41.74 -    va_end(args);
   41.75 -
   41.76 -    /* As luck would have it, we use the same register for hcall opcodes and
   41.77 -     * for hcall return values. The return value from this function is placed
   41.78 -     * in r3 on return, so modifying regs->gprs[3] would have no effect. */
   41.79 -    return XEN_MARK(op);
   41.80 -}
   41.81 -
   41.82 -int arch_domain_create(struct domain *d, unsigned int domcr_flags)
   41.83 -{
   41.84 -    if (d->domain_id == IDLE_DOMAIN_ID) {
   41.85 -        d->shared_info = (void *)alloc_xenheap_page();
   41.86 -        clear_page(d->shared_info);
   41.87 -
   41.88 -        return 0;
   41.89 -    }
   41.90 -
   41.91 -    d->arch.large_page_sizes = cpu_large_page_orders(
   41.92 -        d->arch.large_page_order, ARRAY_SIZE(d->arch.large_page_order));
   41.93 -
   41.94 -    d->arch.foreign_mfn_count = 2048;
   41.95 -    d->arch.foreign_mfns = xmalloc_array(uint, d->arch.foreign_mfn_count);
   41.96 -    BUG_ON(d->arch.foreign_mfns == NULL);
   41.97 -
   41.98 -    memset(d->arch.foreign_mfns, -1, d->arch.foreign_mfn_count * sizeof(uint));
   41.99 -
  41.100 -    return 0;
  41.101 -}
  41.102 -
  41.103 -void arch_domain_destroy(struct domain *d)
  41.104 -{
  41.105 -    shadow_teardown(d);
  41.106 -    /* shared_info is part of the RMA so no need to release it */
  41.107 -}
  41.108 -
  41.109 -static void machine_fail(const char *s)
  41.110 -{
  41.111 -    printk("%s failed, manual powercycle required!\n"
  41.112 -           "  spinning....\n", s);
  41.113 -    for (;;)
  41.114 -        sleep();
  41.115 -}
  41.116 -void machine_halt(void)
  41.117 -{
  41.118 -    console_start_sync();
  41.119 -    printk("%s called\n", __func__);
  41.120 -    rtas_halt();
  41.121 -
  41.122 -    machine_fail(__func__);
  41.123 -}
  41.124 -
  41.125 -void machine_restart(void)
  41.126 -{
  41.127 -    console_start_sync();
  41.128 -    printk("%s called\n", __func__);
  41.129 -    rtas_reboot();
  41.130 -    machine_fail(__func__);
  41.131 -}
  41.132 -
  41.133 -struct vcpu *alloc_vcpu_struct(void)
  41.134 -{
  41.135 -    struct vcpu *v;
  41.136 -    if ( (v = xmalloc(struct vcpu)) != NULL )
  41.137 -        memset(v, 0, sizeof(*v));
  41.138 -    return v;
  41.139 -}
  41.140 -
  41.141 -void free_vcpu_struct(struct vcpu *v)
  41.142 -{
  41.143 -    xfree(v);
  41.144 -}
  41.145 -
  41.146 -int vcpu_initialise(struct vcpu *v)
  41.147 -{
  41.148 -    /* Guests by default have a 100Hz ticker. */
  41.149 -    v->periodic_period = MILLISECS(10);
  41.150 -    return 0;
  41.151 -}
  41.152 -
  41.153 -void vcpu_destroy(struct vcpu *v)
  41.154 -{
  41.155 -}
  41.156 -
  41.157 -int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c)
  41.158 -{ 
  41.159 -    struct domain *d = v->domain;
  41.160 -
  41.161 -    memcpy(&v->arch.ctxt, &c.nat->user_regs, sizeof(c.nat->user_regs));
  41.162 -
  41.163 -    printk("Domain[%d].%d: initializing\n", d->domain_id, v->vcpu_id);
  41.164 -
  41.165 -    if (d->arch.htab.order == 0)
  41.166 -        panic("Page table never allocated for Domain: %d\n", d->domain_id);
  41.167 -    if (d->arch.rma_order == 0)
  41.168 -        panic("RMA never allocated for Domain: %d\n", d->domain_id);
  41.169 -
  41.170 -    d->shared_info->wc_sec = dom0->shared_info->wc_sec;
  41.171 -    d->shared_info->wc_nsec = dom0->shared_info->wc_nsec;
  41.172 -    d->shared_info->arch.boot_timebase = dom0->shared_info->arch.boot_timebase;
  41.173 -
  41.174 -    if ( !v->is_initialised )
  41.175 -    {
  41.176 -        v->is_initialised = 1;
  41.177 -        /* Auto-online VCPU0 when it is initialised. */
  41.178 -        if ( v->vcpu_id == 0 )
  41.179 -            clear_bit(_VPF_down, &v->pause_flags);
  41.180 -    }
  41.181 -
  41.182 -    cpu_init_vcpu(v);
  41.183 -
  41.184 -    return 0;
  41.185 -}
  41.186 -
  41.187 -int arch_vcpu_reset(struct vcpu *v)
  41.188 -{
  41.189 -    panic("%s: called for Dom%d[%d]\n",
  41.190 -          __func__, v->domain->domain_id, v->vcpu_id);
  41.191 -    return 0;
  41.192 -}
  41.193 -
  41.194 -void dump_pageframe_info(struct domain *d)
  41.195 -{
  41.196 -    struct page_info *page;
  41.197 -
  41.198 -    printk("Memory pages belonging to domain %u:\n", d->domain_id);
  41.199 -
  41.200 -    if ( d->tot_pages >= 10 )
  41.201 -    {
  41.202 -        printk("    DomPage list too long to display\n");
  41.203 -    }
  41.204 -    else
  41.205 -    {
  41.206 -        list_for_each_entry ( page, &d->page_list, list )
  41.207 -        {
  41.208 -            printk("    DomPage %p: mfn=%p, caf=%016lx, taf=%" PRtype_info "\n",
  41.209 -                   _p(page_to_maddr(page)), _p(page_to_mfn(page)),
  41.210 -                   page->count_info, page->u.inuse.type_info);
  41.211 -        }
  41.212 -    }
  41.213 -
  41.214 -    list_for_each_entry ( page, &d->xenpage_list, list )
  41.215 -    {
  41.216 -        printk("    XenPage %p: mfn=%p, caf=%016lx, taf=%" PRtype_info "\n",
  41.217 -               _p(page_to_maddr(page)), _p(page_to_mfn(page)),
  41.218 -               page->count_info, page->u.inuse.type_info);
  41.219 -    }
  41.220 -}
  41.221 -
  41.222 -void context_switch(struct vcpu *prev, struct vcpu *next)
  41.223 -{
  41.224 -    struct cpu_user_regs *stack_regs = guest_cpu_user_regs();
  41.225 -    cpumask_t dirty_mask = next->vcpu_dirty_cpumask;
  41.226 -    unsigned int cpu = smp_processor_id();
  41.227 -
  41.228 -#if 0
  41.229 -    printk("%s: dom %x to dom %x\n", __func__, prev->domain->domain_id,
  41.230 -            next->domain->domain_id);
  41.231 -#endif
  41.232 -
  41.233 -    /* Allow at most one CPU at a time to be dirty. */
  41.234 -    ASSERT(cpus_weight(dirty_mask) <= 1);
  41.235 -    if (unlikely(!cpu_isset(cpu, dirty_mask) && !cpus_empty(dirty_mask)))
  41.236 -    {
  41.237 -        /* Other cpus call __sync_lazy_execstate from flush ipi handler. */
  41.238 -        if (!cpus_empty(next->vcpu_dirty_cpumask))
  41.239 -            flush_tlb_mask(next->vcpu_dirty_cpumask);
  41.240 -    }
  41.241 -
  41.242 -    /* copy prev guest state off the stack into its vcpu */
  41.243 -    memcpy(&prev->arch.ctxt, stack_regs, sizeof(struct cpu_user_regs));
  41.244 -
  41.245 -    set_current(next);
  41.246 -
  41.247 -    /* copy next guest state onto the stack */
  41.248 -    memcpy(stack_regs, &next->arch.ctxt, sizeof(struct cpu_user_regs));
  41.249 -
  41.250 -    /* save old domain state */
  41.251 -    save_sprs(prev);
  41.252 -    save_float(prev);
  41.253 -    save_segments(prev);
  41.254 -
  41.255 -    context_saved(prev);
  41.256 -
  41.257 -    /* load up new domain */
  41.258 -    load_sprs(next);
  41.259 -    load_float(next);
  41.260 -    load_segments(next);
  41.261 -
  41.262 -    mtsdr1(next->domain->arch.htab.sdr1);
  41.263 -    local_flush_tlb(); /* XXX maybe flush_tlb_mask? */
  41.264 -    cpu_flush_icache();
  41.265 -
  41.266 -    if (is_idle_vcpu(next)) {
  41.267 -        reset_stack_and_jump(idle_loop);
  41.268 -    }
  41.269 -
  41.270 -    reset_stack_and_jump(full_resume);
  41.271 -    /* not reached */
  41.272 -}
  41.273 -
  41.274 -void continue_running(struct vcpu *same)
  41.275 -{
  41.276 -    /* nothing to do */
  41.277 -    return;
  41.278 -}
  41.279 -
  41.280 -void sync_vcpu_execstate(struct vcpu *v)
  41.281 -{
  41.282 -    /* do nothing */
  41.283 -    return;
  41.284 -}
  41.285 -
  41.286 -static void relinquish_memory(struct domain *d, struct list_head *list)
  41.287 -{
  41.288 -    struct list_head *ent;
  41.289 -    struct page_info  *page;
  41.290 -
  41.291 -    /* Use a recursive lock, as we may enter 'free_domheap_page'. */
  41.292 -    spin_lock_recursive(&d->page_alloc_lock);
  41.293 -
  41.294 -    ent = list->next;
  41.295 -    while ( ent != list )
  41.296 -    {
  41.297 -        page = list_entry(ent, struct page_info, list);
  41.298 -
  41.299 -        /* Grab a reference to the page so it won't disappear from under us. */
  41.300 -        if ( unlikely(!get_page(page, d)) )
  41.301 -        {
  41.302 -            /* Couldn't get a reference -- someone is freeing this page. */
  41.303 -            ent = ent->next;
  41.304 -            continue;
  41.305 -        }
  41.306 -        if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) )
  41.307 -            put_page_and_type(page);
  41.308 -
  41.309 -        if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
  41.310 -            put_page(page);
  41.311 -
  41.312 -        /* Follow the list chain and /then/ potentially free the page. */
  41.313 -        ent = ent->next;
  41.314 -        put_page(page);
  41.315 -    }
  41.316 -    spin_unlock_recursive(&d->page_alloc_lock);
  41.317 -}
  41.318 -
  41.319 -int domain_relinquish_resources(struct domain *d)
  41.320 -{
  41.321 -    relinquish_memory(d, &d->xenpage_list);
  41.322 -    relinquish_memory(d, &d->page_list);
  41.323 -    xfree(d->arch.foreign_mfns);
  41.324 -    xfree(d->arch.p2m);
  41.325 -    return 0;
  41.326 -}
  41.327 -
  41.328 -void arch_dump_domain_info(struct domain *d)
  41.329 -{
  41.330 -}
  41.331 -
  41.332 -void arch_dump_vcpu_info(struct vcpu *v)
  41.333 -{
  41.334 -}
  41.335 -
  41.336 -static void safe_halt(void)
  41.337 -{
  41.338 -    int cpu = smp_processor_id();
  41.339 -
  41.340 -    while (!softirq_pending(cpu))
  41.341 -        sleep();
  41.342 -}
  41.343 -
  41.344 -static void default_idle(void)
  41.345 -{
  41.346 -    local_irq_disable();
  41.347 -    if ( !softirq_pending(smp_processor_id()) )
  41.348 -        safe_halt();
  41.349 -    else
  41.350 -        local_irq_enable();
  41.351 -}
  41.352 -
  41.353 -void idle_loop(void)
  41.354 -{
  41.355 -    for ( ; ; ) {
  41.356 -        page_scrub_schedule_work();
  41.357 -        default_idle();
  41.358 -        do_softirq();
  41.359 -    }
  41.360 -}
    42.1 --- a/xen/arch/powerpc/domain_build.c	Thu May 08 13:15:45 2008 +0100
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,297 +0,0 @@
    42.4 -/*
    42.5 - * This program is free software; you can redistribute it and/or modify
    42.6 - * it under the terms of the GNU General Public License as published by
    42.7 - * the Free Software Foundation; either version 2 of the License, or
    42.8 - * (at your option) any later version.
    42.9 - *
   42.10 - * This program is distributed in the hope that it will be useful,
   42.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   42.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   42.13 - * GNU General Public License for more details.
   42.14 - *
   42.15 - * You should have received a copy of the GNU General Public License
   42.16 - * along with this program; if not, write to the Free Software
   42.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   42.18 - *
   42.19 - * Copyright IBM Corp. 2005, 2007
   42.20 - *
   42.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   42.22 - *          Ryan Harper <ryanh@us.ibm.com>
   42.23 - *          Hollis Blanchard <hollisb@us.ibm.com>
   42.24 - */
   42.25 -
   42.26 -#include <xen/config.h>
   42.27 -#include <xen/lib.h>
   42.28 -#include <xen/sched.h>
   42.29 -#include <xen/init.h>
   42.30 -#include <xen/ctype.h>
   42.31 -#include <xen/iocap.h>
   42.32 -#include <xen/domain.h>
   42.33 -#include <xen/version.h>
   42.34 -#include <xen/paging.h>
   42.35 -#include <asm/processor.h>
   42.36 -#include <asm/platform.h>
   42.37 -#include <asm/papr.h>
   42.38 -#include <public/arch-powerpc.h>
   42.39 -#include <public/libelf.h>
   42.40 -#include "oftree.h"
   42.41 -
   42.42 -/* opt_dom0_mem: memory allocated to domain 0. */
   42.43 -static unsigned int dom0_nrpages;
   42.44 -static void parse_dom0_mem(char *s)
   42.45 -{
   42.46 -    unsigned long long bytes;
   42.47 -
   42.48 -    bytes = parse_size_and_unit(s, NULL);
   42.49 -    dom0_nrpages = bytes >> PAGE_SHIFT;
   42.50 -}
   42.51 -custom_param("dom0_mem", parse_dom0_mem);
   42.52 -
   42.53 -static unsigned int opt_dom0_max_vcpus;
   42.54 -integer_param("dom0_max_vcpus", opt_dom0_max_vcpus);
   42.55 -
   42.56 -static unsigned int opt_dom0_shadow;
   42.57 -boolean_param("dom0_shadow", opt_dom0_shadow);
   42.58 -
   42.59 -/* adapted from common/elf.c */
   42.60 -#define RM_MASK(a,l) ((a) & ((1UL << (l)) - 1))
   42.61 -
   42.62 -int construct_dom0(struct domain *d,
   42.63 -                   unsigned long image_start, unsigned long image_len, 
   42.64 -                   unsigned long initrd_start, unsigned long initrd_len,
   42.65 -                   char *cmdline)
   42.66 -{
   42.67 -    struct elf_binary elf;
   42.68 -    struct elf_dom_parms parms;
   42.69 -    int rc;
   42.70 -    struct vcpu *v;
   42.71 -    ulong dst;
   42.72 -    u64 *ofh_tree;
   42.73 -    ulong firmware_base;
   42.74 -    uint rma_nrpages = 1 << cpu_default_rma_order_pages();
   42.75 -    ulong rma_sz;
   42.76 -    ulong rma;
   42.77 -    ulong eomem;
   42.78 -    int preempt = 0;
   42.79 -    int vcpu;
   42.80 -    ulong mod_start = 0;
   42.81 -    ulong mod_len = 0;
   42.82 -    ulong shared_info_addr;
   42.83 -    uint extent_size = 1 << cpu_extent_order();
   42.84 -    ulong sz;
   42.85 -
   42.86 -    /* Sanity! */
   42.87 -    BUG_ON(d->domain_id != 0);
   42.88 -
   42.89 -    if (image_len == 0)
   42.90 -        panic("No Dom0 image supplied\n");
   42.91 -
   42.92 -    printk("*** LOADING DOMAIN 0 ***\n");
   42.93 -
   42.94 -    /* default is the max(1/16th of memory, CONFIG_MIN_DOM0_PAGES) */
   42.95 -    if (dom0_nrpages == 0) {
   42.96 -        dom0_nrpages = total_pages >> 4;
   42.97 -
   42.98 -        if (dom0_nrpages < CONFIG_MIN_DOM0_PAGES)
   42.99 -            dom0_nrpages = CONFIG_MIN_DOM0_PAGES;
  42.100 -    }
  42.101 -
  42.102 -    /* Dom0 has to be at least RMA size. */
  42.103 -    if (dom0_nrpages < rma_nrpages) {
  42.104 -        dom0_nrpages = rma_nrpages;
  42.105 -        printk("Increasing DOM0 memory size to %u MiB for RMA.\n", 
  42.106 -                ((rma_nrpages << PAGE_SHIFT) >> 20));
  42.107 -    }
  42.108 -
  42.109 -    /* Ensure Dom0 is cpu_extent_order aligned. Round up if 
  42.110 -       not and let user know we did so. */
  42.111 -    if (dom0_nrpages != ALIGN_UP(dom0_nrpages, extent_size)) {
  42.112 -        dom0_nrpages = ALIGN_UP(dom0_nrpages, extent_size);
  42.113 -        printk("Increasing DOM0 memory size to %u MiB for large pages.\n", 
  42.114 -                ((dom0_nrpages << PAGE_SHIFT) >> 20));
  42.115 -    }
  42.116 -
  42.117 -    /* XXX Dom0 currently can't extend past the IO hole. */
  42.118 -    if (dom0_nrpages > (platform_iohole_base() >> PAGE_SHIFT)) {
  42.119 -        dom0_nrpages = (platform_iohole_base() >> PAGE_SHIFT);
  42.120 -        printk("Limiting DOM0 memory size to %u MiB to avoid IO hole.\n", 
  42.121 -                ((dom0_nrpages << PAGE_SHIFT) >> 20));
  42.122 -    }
  42.123 -
  42.124 -    /* Set Dom0 max mem, triggering p2m table creation. */
  42.125 -    if ((guest_physmap_max_mem_pages(d, dom0_nrpages)) != 0)
  42.126 -        panic("Failed to set DOM0 max mem pages value\n");
  42.127 -
  42.128 -    d->max_pages = dom0_nrpages;
  42.129 -    if (0 > allocate_rma(d, cpu_default_rma_order_pages()))
  42.130 -        panic("Error allocating domain 0 RMA\n");
  42.131 -
  42.132 -    rma_sz = rma_size(d->arch.rma_order);
  42.133 -    rma = page_to_maddr(d->arch.rma_page);
  42.134 -
  42.135 -    /* If we are bigger than RMA, allocate extents. */
  42.136 -    if (dom0_nrpages > rma_nrpages)
  42.137 -        dom0_nrpages = allocate_extents(d, dom0_nrpages, rma_nrpages);
  42.138 -
  42.139 -    ASSERT(d->tot_pages == dom0_nrpages);
  42.140 -    ASSERT(d->tot_pages >= rma_nrpages);
  42.141 -
  42.142 -    if (opt_dom0_shadow == 0) {
  42.143 -        /* 1/64 of memory  */
  42.144 -        opt_dom0_shadow = (d->tot_pages >> 6) >> (20 - PAGE_SHIFT);
  42.145 -    }
  42.146 -
  42.147 -    do {
  42.148 -        shadow_set_allocation(d, opt_dom0_shadow, &preempt);
  42.149 -    } while (preempt);
  42.150 -    if (shadow_get_allocation(d) == 0)
  42.151 -        panic("shadow allocation failed: %dMib\n", opt_dom0_shadow);
  42.152 -
  42.153 -    ASSERT( image_len < rma_sz );
  42.154 -
  42.155 -    eomem = ((ulong)d->shared_info) - rma;
  42.156 -    printk("shared_info: 0x%lx,%p\n", eomem, d->shared_info);
  42.157 -
  42.158 -    /* startup secondary processors */
  42.159 -    if ( opt_dom0_max_vcpus == 0 )
  42.160 -        opt_dom0_max_vcpus = num_online_cpus();
  42.161 -    if ( opt_dom0_max_vcpus > num_online_cpus() )
  42.162 -        opt_dom0_max_vcpus = num_online_cpus();
  42.163 -    if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS )
  42.164 -        opt_dom0_max_vcpus = MAX_VIRT_CPUS;
  42.165 -#ifdef BITS_PER_GUEST_LONG
  42.166 -    if ( opt_dom0_max_vcpus > BITS_PER_GUEST_LONG(d) )
  42.167 -        opt_dom0_max_vcpus = BITS_PER_GUEST_LONG(d);
  42.168 -#endif
  42.169 -    printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus);
  42.170 -
  42.171 -    for (vcpu = 0; vcpu < opt_dom0_max_vcpus; vcpu++) {
  42.172 -        if (NULL == alloc_vcpu(dom0, vcpu, vcpu))
  42.173 -            panic("Error creating domain 0 vcpu %d\n", vcpu);
  42.174 -        /* for now we pin Dom0 VCPUs to their coresponding CPUs */
  42.175 -        if (cpu_isset(vcpu, cpu_online_map))
  42.176 -            dom0->vcpu[vcpu]->cpu_affinity = cpumask_of_cpu(vcpu);
  42.177 -    }
  42.178 -
  42.179 -    /* Init VCPU0. */
  42.180 -    v = d->vcpu[0];
  42.181 -    cpu_init_vcpu(v);
  42.182 -
  42.183 -    /* convert xen pointer shared_info into guest physical */
  42.184 -    shared_info_addr = (ulong)d->shared_info - page_to_maddr(d->arch.rma_page);
  42.185 -
  42.186 -    /* start loading stuff */
  42.187 -    rc = elf_init(&elf, (void *)image_start, image_len);
  42.188 -    if (rc)
  42.189 -        return rc;
  42.190 -#ifdef VERBOSE
  42.191 -    elf_set_verbose(&elf);
  42.192 -#endif
  42.193 -    elf_parse_binary(&elf);
  42.194 -    if (0 != (elf_xen_parse(&elf, &parms)))
  42.195 -        return rc;
  42.196 -
  42.197 -    printk("Dom0 kernel: %s, paddr 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
  42.198 -            elf_64bit(&elf) ? "64-bit" : "32-bit",
  42.199 -            elf.pstart, elf.pend);
  42.200 -
  42.201 -    /* elf contains virtual addresses that can have the upper bits
  42.202 -     * masked while running in real mode, so we do the masking as well
  42.203 -     * as well */
  42.204 -    parms.virt_kend = RM_MASK(parms.virt_kend, 42);
  42.205 -    parms.virt_entry = RM_MASK(parms.virt_entry, 42);
  42.206 -
  42.207 -    /* set the MSR bit correctly */
  42.208 -    if (elf_64bit(&elf))
  42.209 -        v->arch.ctxt.msr = MSR_SF;
  42.210 -    else
  42.211 -        v->arch.ctxt.msr = 0;
  42.212 -
  42.213 -    /* Load the dom0 kernel. */
  42.214 -    elf.dest = (void *)(parms.virt_kstart + rma);
  42.215 -
  42.216 -    elf_load_binary(&elf);
  42.217 -    v->arch.ctxt.pc = parms.virt_entry;
  42.218 -
  42.219 -    dst = ALIGN_UP(parms.virt_kend + rma, PAGE_SIZE);
  42.220 -
  42.221 -    /* Load the initrd. */
  42.222 -    if (initrd_len > 0) {
  42.223 -        ASSERT((dst - rma) + image_len < eomem);
  42.224 -
  42.225 -        printk("loading initrd: 0x%lx, 0x%lx\n", dst, initrd_len);
  42.226 -        memcpy((void *)dst, (void *)initrd_start, initrd_len);
  42.227 -
  42.228 -        mod_start = dst - rma;
  42.229 -        mod_len = image_len;
  42.230 -
  42.231 -        dst = ALIGN_UP(dst + initrd_len, PAGE_SIZE);
  42.232 -    } else {
  42.233 -        printk("no initrd\n");
  42.234 -    }
  42.235 -
  42.236 -    v->arch.ctxt.gprs[3] = mod_start;
  42.237 -    v->arch.ctxt.gprs[4] = mod_len;
  42.238 -
  42.239 -    /* OF usually sits here:
  42.240 -     *   - Linux needs it to be loaded before the vmlinux or initrd
  42.241 -     *   - AIX demands it to be @ 32M.
  42.242 -     */
  42.243 -    firmware_base = (32 << 20);
  42.244 -    if (dst - rma > firmware_base)
  42.245 -    panic("Firmware [0x%lx] will over-write images ending: 0x%lx\n",
  42.246 -          firmware_base, dst - rma);
  42.247 -    dst = firmware_base + rma;
  42.248 -
  42.249 -    /* Put stack below firmware. */
  42.250 -    v->arch.ctxt.gprs[1] = dst - rma - STACK_FRAME_OVERHEAD;
  42.251 -    v->arch.ctxt.gprs[2] = 0;
  42.252 -
  42.253 -    ASSERT((dst - rma) + (ulong)firmware_image_size < eomem);
  42.254 -    printk("loading OFH: 0x%lx, RMA: 0x%lx\n", dst, dst - rma);
  42.255 -    memcpy((void *)dst, firmware_image_start, (ulong)firmware_image_size);
  42.256 -
  42.257 -    v->arch.ctxt.gprs[5] = (dst - rma);
  42.258 -    ofh_tree = (u64 *)(dst + 0x10);
  42.259 -    ASSERT(*ofh_tree == 0xdeadbeef00000000);
  42.260 -
  42.261 -    /* accomodate for a modest bss section */
  42.262 -    dst = ALIGN_UP(dst + (ulong)firmware_image_size + PAGE_SIZE, PAGE_SIZE);
  42.263 -
  42.264 -    ASSERT((dst - rma) + oftree_len < eomem);
  42.265 -
  42.266 -    *ofh_tree = dst - rma;
  42.267 -    printk("loading OFD: 0x%lx RMA: 0x%lx, 0x%lx\n", dst, dst - rma,
  42.268 -           oftree_len);
  42.269 -    memcpy((void *)dst, (void *)oftree, oftree_len);
  42.270 -
  42.271 -    /* fixup and add stuff for dom0 */
  42.272 -    sz = ofd_dom0_fixup(d, *ofh_tree + rma, cmdline, shared_info_addr);
  42.273 -    printk("modified OFD size: 0x%lx\n", sz);
  42.274 -    dst = ALIGN_UP(dst + sz + PAGE_SIZE, PAGE_SIZE);
  42.275 -
  42.276 -	printk("dom0 initial register state:\n"
  42.277 -			"    pc %016lx msr %016lx\n"
  42.278 -			"    r1 %016lx r2 %016lx r3 %016lx\n"
  42.279 -			"    r4 %016lx r5 %016lx\n",
  42.280 -			v->arch.ctxt.pc,
  42.281 -			v->arch.ctxt.msr,
  42.282 -			v->arch.ctxt.gprs[1],
  42.283 -			v->arch.ctxt.gprs[2],
  42.284 -			v->arch.ctxt.gprs[3],
  42.285 -			v->arch.ctxt.gprs[4],
  42.286 -			v->arch.ctxt.gprs[5]);
  42.287 -
  42.288 -    v->is_initialised = 1;
  42.289 -    clear_bit(_VPF_down, &v->pause_flags);
  42.290 -
  42.291 -    rc = 0;
  42.292 -
  42.293 -    /* DOM0 is permitted full I/O capabilities. */
  42.294 -    rc |= iomem_permit_access(dom0, 0UL, ~0UL);
  42.295 -    rc |= irqs_permit_access(dom0, 0, NR_IRQS-1);
  42.296 -
  42.297 -    BUG_ON(rc != 0);
  42.298 -
  42.299 -    return 0;
  42.300 -}
    43.1 --- a/xen/arch/powerpc/domctl.c	Thu May 08 13:15:45 2008 +0100
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,120 +0,0 @@
    43.4 -/*
    43.5 - * This program is free software; you can redistribute it and/or modify
    43.6 - * it under the terms of the GNU General Public License as published by
    43.7 - * the Free Software Foundation; either version 2 of the License, or
    43.8 - * (at your option) any later version.
    43.9 - *
   43.10 - * This program is distributed in the hope that it will be useful,
   43.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   43.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   43.13 - * GNU General Public License for more details.
   43.14 - *
   43.15 - * You should have received a copy of the GNU General Public License
   43.16 - * along with this program; if not, write to the Free Software
   43.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   43.18 - *
   43.19 - * Copyright IBM Corp. 2005, 2007
   43.20 - *
   43.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   43.22 - *          Ryan Harper <ryanh@us.ibm.com>
   43.23 - */
   43.24 -
   43.25 -#include <xen/config.h>
   43.26 -#include <xen/types.h>
   43.27 -#include <xen/lib.h>
   43.28 -#include <xen/sched.h>
   43.29 -#include <xen/domain.h>
   43.30 -#include <xen/guest_access.h>
   43.31 -#include <xen/paging.h>
   43.32 -#include <public/xen.h>
   43.33 -#include <public/domctl.h>
   43.34 -#include <public/sysctl.h>
   43.35 -#include <asm/processor.h>
   43.36 -
   43.37 -void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
   43.38 -{ 
   43.39 -    memcpy(&c.nat->user_regs, &v->arch.ctxt, sizeof(struct cpu_user_regs));
   43.40 -    /* XXX fill in rest of vcpu_guest_context_t */
   43.41 -}
   43.42 -
   43.43 -long arch_do_domctl(struct xen_domctl *domctl,
   43.44 -                    XEN_GUEST_HANDLE(xen_domctl_t) u_domctl);
   43.45 -long arch_do_domctl(struct xen_domctl *domctl,
   43.46 -                    XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
   43.47 -{
   43.48 -    long ret = 0;
   43.49 -
   43.50 -    switch (domctl->cmd) {
   43.51 -    case XEN_DOMCTL_getmemlist:
   43.52 -    {
   43.53 -        int i;
   43.54 -        struct domain *d = get_domain_by_id(domctl->domain);
   43.55 -        unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
   43.56 -        uint64_t mfn;
   43.57 -
   43.58 -        ret = -EINVAL;
   43.59 -        if ( d != NULL )
   43.60 -        {
   43.61 -            ret = 0;
   43.62 -
   43.63 -            spin_lock(&d->page_alloc_lock);
   43.64 -            for (i = 0; i < max_pfns; i++) {
   43.65 -                /* bail if index is beyond p2m size */
   43.66 -                if (i >= d->arch.p2m_entries)
   43.67 -                    break;
   43.68 -
   43.69 -                /* translate */
   43.70 -                mfn = d->arch.p2m[i];
   43.71 -
   43.72 -                if (copy_to_guest_offset(domctl->u.getmemlist.buffer,
   43.73 -                                          i, &mfn, 1))
   43.74 -                {
   43.75 -                    ret = -EFAULT;
   43.76 -                    break;
   43.77 -                }
   43.78 -            }
   43.79 -            spin_unlock(&d->page_alloc_lock);
   43.80 -
   43.81 -            domctl->u.getmemlist.num_pfns = i;
   43.82 -            copy_to_guest(u_domctl, domctl, 1);
   43.83 -            
   43.84 -            put_domain(d);
   43.85 -        }
   43.86 -    }
   43.87 -    break;
   43.88 -    case XEN_DOMCTL_shadow_op:
   43.89 -    {
   43.90 -        struct domain *d;
   43.91 -        ret = -ESRCH;
   43.92 -        d = get_domain_by_id(domctl->domain);
   43.93 -        if ( d != NULL )
   43.94 -        {
   43.95 -            ret = shadow_domctl(d, &domctl->u.shadow_op, u_domctl);
   43.96 -            put_domain(d);
   43.97 -            copy_to_guest(u_domctl, domctl, 1);
   43.98 -        } 
   43.99 -    }
  43.100 -    break;
  43.101 -    case XEN_DOMCTL_real_mode_area:
  43.102 -    {
  43.103 -        struct domain *d;
  43.104 -        unsigned int order = domctl->u.real_mode_area.log - PAGE_SHIFT;
  43.105 -
  43.106 -        ret = -ESRCH;
  43.107 -        d = get_domain_by_id(domctl->domain);
  43.108 -        if (d != NULL) {
  43.109 -            ret = -EINVAL;
  43.110 -            if (cpu_rma_valid(order))
  43.111 -                ret = allocate_rma(d, order);
  43.112 -            put_domain(d);
  43.113 -        }
  43.114 -    }
  43.115 -    break;
  43.116 -
  43.117 -    default:
  43.118 -        ret = -ENOSYS;
  43.119 -        break;
  43.120 -    }
  43.121 -
  43.122 -    return ret;
  43.123 -}
    44.1 --- a/xen/arch/powerpc/exceptions.c	Thu May 08 13:15:45 2008 +0100
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,91 +0,0 @@
    44.4 -/*
    44.5 - * This program is free software; you can redistribute it and/or modify
    44.6 - * it under the terms of the GNU General Public License as published by
    44.7 - * the Free Software Foundation; either version 2 of the License, or
    44.8 - * (at your option) any later version.
    44.9 - *
   44.10 - * This program is distributed in the hope that it will be useful,
   44.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   44.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   44.13 - * GNU General Public License for more details.
   44.14 - *
   44.15 - * You should have received a copy of the GNU General Public License
   44.16 - * along with this program; if not, write to the Free Software
   44.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   44.18 - *
   44.19 - * Copyright (C) IBM Corp. 2005, 2006
   44.20 - *
   44.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   44.22 - *          Jimi Xenidis <jimix@watson.ibm.com>
   44.23 - */
   44.24 -
   44.25 -#include <xen/config.h>
   44.26 -#include <xen/softirq.h>
   44.27 -#include <xen/sched.h>
   44.28 -#include <xen/serial.h>
   44.29 -#include <xen/gdbstub.h>
   44.30 -#include <xen/console.h>
   44.31 -#include <xen/shutdown.h>
   44.32 -#include <asm/time.h>
   44.33 -#include <asm/processor.h>
   44.34 -#include <asm/debugger.h>
   44.35 -
   44.36 -#undef DEBUG
   44.37 -
   44.38 -extern ulong ppc_do_softirq(ulong orig_msr);
   44.39 -extern void do_timer(struct cpu_user_regs *regs);
   44.40 -extern void do_dec(struct cpu_user_regs *regs);
   44.41 -extern void program_exception(struct cpu_user_regs *regs,
   44.42 -                              unsigned long cookie);
   44.43 -extern int reprogram_timer(s_time_t timeout); 
   44.44 -
   44.45 -int hdec_sample = 0;
   44.46 -
   44.47 -void do_timer(struct cpu_user_regs *regs)
   44.48 -{
   44.49 -    /* Set HDEC high so it stops firing and can be reprogrammed by
   44.50 -     * set_preempt() */
   44.51 -    /* FIXME! HACK ALERT!
   44.52 -     *
   44.53 -     * We have a bug in that if we switch domains in schedule() we
   44.54 -     * switch right away regardless of whatever else is pending.  This
   44.55 -     * means that if the timer goes off while in schedule(), the next
   44.56 -     * domain will be preempted by the interval defined below.  So
   44.57 -     * until we fix our cotnext_switch(), the follow workaround will
   44.58 -     * make sure that the domain we switch to does not run for to long
   44.59 -     * so we can continue to service the other timers in the timer
   44.60 -     * queue and that the value is long enough to escape this
   44.61 -     * particular timer event.
   44.62 -     */
   44.63 -    reprogram_timer(NOW() + MILLISECS(1));
   44.64 -
   44.65 -    raise_softirq(TIMER_SOFTIRQ);
   44.66 -}
   44.67 -
   44.68 -void do_dec(struct cpu_user_regs *regs)
   44.69 -{
   44.70 -    if (!(regs->msr & MSR_HV)) {
   44.71 -        panic("HV dec from domain\n");
   44.72 -    }
   44.73 -    printk("DEC_HV: pc: 0x%lx lr: 0x%lx \n", regs->pc, regs->lr);
   44.74 -    mtdec(INT_MAX);
   44.75 -}
   44.76 -
   44.77 -void program_exception(struct cpu_user_regs *regs, unsigned long cookie)
   44.78 -{
   44.79 -    if (cookie == 0x200) {
   44.80 -        if (cpu_machinecheck(regs))
   44.81 -            return;
   44.82 -
   44.83 -        printk("%s: machine check\n", __func__);
   44.84 -    } else {
   44.85 -#ifdef CRASH_DEBUG
   44.86 -        if (__trap_to_gdb(regs, cookie) == 0)
   44.87 -            return;
   44.88 -#endif /* CRASH_DEBUG */
   44.89 -
   44.90 -        printk("%s: type: 0x%lx\n", __func__, cookie);
   44.91 -        show_backtrace_regs(regs);
   44.92 -    }
   44.93 -    machine_halt();
   44.94 -}
    45.1 --- a/xen/arch/powerpc/exceptions.h	Thu May 08 13:15:45 2008 +0100
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,54 +0,0 @@
    45.4 -/*
    45.5 - * This program is free software; you can redistribute it and/or modify
    45.6 - * it under the terms of the GNU General Public License as published by
    45.7 - * the Free Software Foundation; either version 2 of the License, or
    45.8 - * (at your option) any later version.
    45.9 - *
   45.10 - * This program is distributed in the hope that it will be useful,
   45.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   45.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   45.13 - * GNU General Public License for more details.
   45.14 - *
   45.15 - * You should have received a copy of the GNU General Public License
   45.16 - * along with this program; if not, write to the Free Software
   45.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   45.18 - *
   45.19 - * Copyright IBM Corp. 2005, 2007
   45.20 - *
   45.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   45.22 - */
   45.23 -
   45.24 -#ifndef _ARCH_PPC_EXCEPTIONS_H_
   45.25 -#define _ARCH_PPC_EXCEPTIONS_H_
   45.26 -
   45.27 -#include <xen/types.h>
   45.28 -#include <public/xen.h>
   45.29 -#include <xen/multiboot.h>
   45.30 -
   45.31 -extern void do_hcall(struct cpu_user_regs *regs);
   45.32 -extern void do_IRQ(struct cpu_user_regs *regs);
   45.33 -extern void deliver_ee(struct cpu_user_regs *regs);
   45.34 -extern void do_external(struct cpu_user_regs *regs);
   45.35 -extern void init_IRQ(void);
   45.36 -extern void ack_APIC_irq(void);
   45.37 -extern int ioapic_guest_read(unsigned long physbase, unsigned int reg, u32 *pval);
   45.38 -extern int ioapic_guest_write(unsigned long physbase, unsigned int reg, u32 val);
   45.39 -
   45.40 -extern void do_timer(struct cpu_user_regs *regs);
   45.41 -extern void do_dec(struct cpu_user_regs *regs);
   45.42 -extern void do_perfmon(struct cpu_user_regs *regs);
   45.43 -extern void program_exception(
   45.44 -    struct cpu_user_regs *regs, unsigned long cookie);
   45.45 -
   45.46 -extern long xen_hvcall_jump(struct cpu_user_regs *regs, ulong address);
   45.47 -
   45.48 -extern void sleep(void);
   45.49 -extern void idle_loop(void);
   45.50 -
   45.51 -extern ulong *__hypercall_table[];
   45.52 -
   45.53 -extern char exception_vectors[];
   45.54 -extern char exception_vectors_end[];
   45.55 -extern int spin_start[];
   45.56 -extern void secondary_cpu_init(int cpuid, unsigned long r4);
   45.57 -#endif
    46.1 --- a/xen/arch/powerpc/external.c	Thu May 08 13:15:45 2008 +0100
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,202 +0,0 @@
    46.4 -/*
    46.5 - * This program is free software; you can redistribute it and/or modify
    46.6 - * it under the terms of the GNU General Public License as published by
    46.7 - * the Free Software Foundation; either version 2 of the License, or
    46.8 - * (at your option) any later version.
    46.9 - *
   46.10 - * This program is distributed in the hope that it will be useful,
   46.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   46.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   46.13 - * GNU General Public License for more details.
   46.14 - *
   46.15 - * You should have received a copy of the GNU General Public License
   46.16 - * along with this program; if not, write to the Free Software
   46.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   46.18 - *
   46.19 - * Copyright (C) IBM Corp. 2005, 2006
   46.20 - *
   46.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   46.22 - */
   46.23 -
   46.24 -#include <xen/config.h>
   46.25 -#include <xen/types.h>
   46.26 -#include <xen/sched.h>
   46.27 -#include <xen/lib.h>
   46.28 -#include <xen/event.h>
   46.29 -#include <xen/irq.h>
   46.30 -#include <public/xen.h>
   46.31 -#include <asm/current.h>
   46.32 -#include <asm/hardirq.h>
   46.33 -#include <asm/mpic.h>
   46.34 -#include "mpic_init.h"
   46.35 -#include "exceptions.h"
   46.36 -
   46.37 -#undef DEBUG
   46.38 -#ifdef DEBUG
   46.39 -#define DBG(fmt...) printk(fmt)
   46.40 -#else
   46.41 -#define DBG(fmt...)
   46.42 -#endif
   46.43 -
   46.44 -int vector_irq[NR_VECTORS] __read_mostly = { [0 ... NR_VECTORS - 1] = -1};
   46.45 -
   46.46 -unsigned long io_apic_irqs;
   46.47 -int ioapic_ack_new = 1;
   46.48 -
   46.49 -/* deliver_ee: called with interrupts off when resuming every vcpu */
   46.50 -void deliver_ee(struct cpu_user_regs *regs)
   46.51 -{
   46.52 -    const ulong srr_mask = ~(MSR_IR | MSR_DR | MSR_FE0 | MSR_FE1 | MSR_EE |
   46.53 -                             MSR_RI |
   46.54 -                             MSR_BE | MSR_FP | MSR_PMM | MSR_PR | MSR_SE);
   46.55 -
   46.56 -    BUG_ON(mfmsr() & MSR_EE);
   46.57 -    BUG_ON(regs->msr & MSR_HV);
   46.58 -
   46.59 -    if (!local_events_need_delivery())
   46.60 -        return;
   46.61 -
   46.62 -    /* XXX OS error: EE was set but RI was not. We could trigger a machine
   46.63 -     * check, or kill the domain... for now just crash Xen so we notice. */
   46.64 -    BUG_ON(!(regs->msr & MSR_RI));
   46.65 -
   46.66 -    regs->srr0 = regs->pc;
   46.67 -    /* zero SRR1[33:36] and SRR1[42:47] */
   46.68 -    regs->srr1 = regs->msr & ~0x00000000783f0000;
   46.69 -    regs->pc = 0x500;
   46.70 -    regs->msr &= srr_mask;
   46.71 -    regs->msr |= MSR_SF | MSR_ME;
   46.72 -
   46.73 -    DBG("<HV: pc=0x%lx, msr=0x%lx\n", regs->pc, regs->msr);
   46.74 -}
   46.75 -
   46.76 -void do_external(struct cpu_user_regs *regs)
   46.77 -{
   46.78 -    int vec;
   46.79 -    static unsigned spur_count;
   46.80 -
   46.81 -    BUG_ON(!(regs->msr & MSR_EE));
   46.82 -    BUG_ON(mfmsr() & MSR_EE);
   46.83 -
   46.84 -    vec = xen_mpic_get_irq(regs);
   46.85 -    DBG(">HV: vec=%d, pc=0x%lx, msr=0x%lx\n", vec, regs->pc, regs->msr);
   46.86 -
   46.87 -    if (irq_desc[vec].status & IRQ_PER_CPU) {
   46.88 -        /* x86 do_IRQ does not respect the per cpu flag.  */
   46.89 -        irq_desc_t *desc = &irq_desc[vec];
   46.90 -        regs->entry_vector = vec;
   46.91 -        desc->handler->ack(vec);
   46.92 -        desc->action->handler(vector_to_irq(vec), desc->action->dev_id, regs);
   46.93 -        desc->handler->end(vec);
   46.94 -    } else if (vec != -1) {
   46.95 -        regs->entry_vector = vec;
   46.96 -        do_IRQ(regs);
   46.97 -
   46.98 -        BUG_ON(mfmsr() & MSR_EE);
   46.99 -        spur_count = 0;
  46.100 -    } else {
  46.101 -        ++spur_count;
  46.102 -        if (spur_count > 100)
  46.103 -            panic("Too many (%d) spurrious interrupts in a row\n"
  46.104 -                  "  Known problem, please halt and let machine idle/cool "
  46.105 -                  "  then reboot\n",
  46.106 -                  100);
  46.107 -    }
  46.108 -}
  46.109 -
  46.110 -void init_IRQ(void)
  46.111 -{
  46.112 -    xen_mpic_init();
  46.113 -}
  46.114 -
  46.115 -void ack_APIC_irq(void)
  46.116 -{
  46.117 -    panic("%s: EOI the whole MPIC?\n", __func__);
  46.118 -}
  46.119 -
  46.120 -void ack_bad_irq(unsigned int irq)
  46.121 -{
  46.122 -    printk("unexpected IRQ trap at vector %02x\n", irq);
  46.123 -    /*
  46.124 -     * Currently unexpected vectors happen only on SMP and APIC.
  46.125 -     * We _must_ ack these because every local APIC has only N
  46.126 -     * irq slots per priority level, and a 'hanging, unacked' IRQ
  46.127 -     * holds up an irq slot - in excessive cases (when multiple
  46.128 -     * unexpected vectors occur) that might lock up the APIC
  46.129 -     * completely.
  46.130 -     */
  46.131 -    ack_APIC_irq();
  46.132 -}
  46.133 -
  46.134 -extern void dump_ioapic_irq_info(void);
  46.135 -void dump_ioapic_irq_info(void)
  46.136 -{
  46.137 -    printk("%s: can't dump yet\n", __func__);
  46.138 -}
  46.139 -
  46.140 -/* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */
  46.141 -u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 };
  46.142 -int assign_irq_vector(int irq)
  46.143 -{
  46.144 -    static int current_vector = FIRST_DEVICE_VECTOR, offset = 0;
  46.145 -
  46.146 -    BUG_ON(irq >= NR_IRQ_VECTORS);
  46.147 -    if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0)
  46.148 -        return IO_APIC_VECTOR(irq);
  46.149 -next:
  46.150 -    current_vector += 8;
  46.151 -
  46.152 -    /* Skip the hypercall vector. */
  46.153 -    if (current_vector == HYPERCALL_VECTOR)
  46.154 -        goto next;
  46.155 -
  46.156 -    /* Skip the Linux/BSD fast-trap vector. */
  46.157 -    if (current_vector == FAST_TRAP)
  46.158 -        goto next;
  46.159 -
  46.160 -    if (current_vector >= FIRST_SYSTEM_VECTOR) {
  46.161 -        offset++;
  46.162 -        if (!(offset%8))
  46.163 -            return -ENOSPC;
  46.164 -        current_vector = FIRST_DEVICE_VECTOR + offset;
  46.165 -    }
  46.166 -
  46.167 -    vector_irq[current_vector] = irq;
  46.168 -    if (irq != AUTO_ASSIGN)
  46.169 -        IO_APIC_VECTOR(irq) = current_vector;
  46.170 -
  46.171 -    return current_vector;
  46.172 -}
  46.173 -
  46.174 -int ioapic_guest_read(unsigned long physbase, unsigned int reg, u32 *pval)
  46.175 -{
  46.176 -    BUG_ON(pval != pval);
  46.177 -    return 0;
  46.178 -}
  46.179 -
  46.180 -int ioapic_guest_write(unsigned long physbase, unsigned int reg, u32 val)
  46.181 -{
  46.182 -    BUG_ON(val != val);
  46.183 -    return 0;
  46.184 -}
  46.185 -
  46.186 -void send_IPI_mask(cpumask_t mask, int vector)
  46.187 -{
  46.188 -    unsigned int cpus;
  46.189 -    int const bits = 8 * sizeof(cpus);
  46.190 -
  46.191 -    switch(vector) {
  46.192 -    case CALL_FUNCTION_VECTOR:
  46.193 -    case EVENT_CHECK_VECTOR:
  46.194 -        break;
  46.195 -    default:
  46.196 -        BUG();
  46.197 -        return;
  46.198 -    }
  46.199 -
  46.200 -    BUG_ON(NR_CPUS > bits);
  46.201 -    BUG_ON(fls(mask.bits[0]) > bits);
  46.202 -
  46.203 -    cpus = mask.bits[0];
  46.204 -    mpic_send_ipi(vector, cpus);
  46.205 -}
    47.1 --- a/xen/arch/powerpc/float.S	Thu May 08 13:15:45 2008 +0100
    47.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.3 @@ -1,243 +0,0 @@
    47.4 -/*
    47.5 - * Copyright (C) 2005 Jimi Xenidis <jimix@watson.ibm.com>, IBM Corporation
    47.6 - *
    47.7 - * This program is free software; you can redistribute it and/or modify
    47.8 - * it under the terms of the GNU General Public License as published by
    47.9 - * the Free Software Foundation; either version 2 of the License, or
   47.10 - * (at your option) any later version.
   47.11 - * 
   47.12 - * This program is distributed in the hope that it will be useful,
   47.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   47.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   47.15 - * GNU General Public License for more details.
   47.16 - * 
   47.17 - * You should have received a copy of the GNU General Public License
   47.18 - * along with this program; if not, write to the Free Software
   47.19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
   47.20 - */
   47.21 -
   47.22 -#include <asm/config.h>
   47.23 -#include <asm/asm-offsets.h>
   47.24 -#include <asm/reg_defs.h>
   47.25 -#include <asm/msr.h>
   47.26 -#include <asm/processor.h>
   47.27 -
   47.28 -#ifdef HAS_FLOAT
   47.29 -save_fp:
   47.30 -	addi	r4, r3, VCPU_fprs - FPR_WIDTH
   47.31 -	stfdu	fr0,FPR_WIDTH(r4)
   47.32 -	stfdu	fr1,FPR_WIDTH(r4)
   47.33 -	stfdu	fr2,FPR_WIDTH(r4)
   47.34 -	stfdu	fr3,FPR_WIDTH(r4)
   47.35 -	stfdu	fr4,FPR_WIDTH(r4)
   47.36 -	stfdu	fr5,FPR_WIDTH(r4)
   47.37 -	stfdu	fr6,FPR_WIDTH(r4)
   47.38 -	stfdu	fr7,FPR_WIDTH(r4)
   47.39 -	stfdu	fr8,FPR_WIDTH(r4)
   47.40 -	stfdu	fr9,FPR_WIDTH(r4)
   47.41 -	stfdu	fr10,FPR_WIDTH(r4)
   47.42 -	stfdu	fr11,FPR_WIDTH(r4)
   47.43 -	stfdu	fr12,FPR_WIDTH(r4)
   47.44 -	stfdu	fr13,FPR_WIDTH(r4)
   47.45 -	stfdu	fr14,FPR_WIDTH(r4)
   47.46 -	stfdu	fr15,FPR_WIDTH(r4)
   47.47 -	stfdu	fr16,FPR_WIDTH(r4)
   47.48 -	stfdu	fr17,FPR_WIDTH(r4)
   47.49 -	stfdu	fr18,FPR_WIDTH(r4)
   47.50 -	stfdu	fr19,FPR_WIDTH(r4)
   47.51 -	stfdu	fr20,FPR_WIDTH(r4)
   47.52 -	stfdu	fr21,FPR_WIDTH(r4)
   47.53 -	stfdu	fr22,FPR_WIDTH(r4)
   47.54 -	stfdu	fr23,FPR_WIDTH(r4)
   47.55 -	stfdu	fr24,FPR_WIDTH(r4)
   47.56 -	stfdu	fr25,FPR_WIDTH(r4)
   47.57 -	stfdu	fr26,FPR_WIDTH(r4)
   47.58 -	stfdu	fr27,FPR_WIDTH(r4)
   47.59 -	stfdu	fr28,FPR_WIDTH(r4)
   47.60 -	stfdu	fr29,FPR_WIDTH(r4)
   47.61 -	stfdu	fr30,FPR_WIDTH(r4)
   47.62 -	stfdu	fr31,FPR_WIDTH(r4)
   47.63 -	mffs	fr0
   47.64 -	stfd	fr0,VCPU_fpscr(r3)
   47.65 -	blr
   47.66 -
   47.67 -load_fp:
   47.68 -	lfd	fr0,VCPU_fpscr(r3)
   47.69 -	mtfsf	0xff,fr0
   47.70 -
   47.71 -	addi	r4, r3, VCPU_fprs - FPR_WIDTH
   47.72 -	lfdu	fr0,FPR_WIDTH(r4)
   47.73 -	lfdu	fr1,FPR_WIDTH(r4)
   47.74 -	lfdu	fr2,FPR_WIDTH(r4)
   47.75 -	lfdu	fr3,FPR_WIDTH(r4)
   47.76 -	lfdu	fr4,FPR_WIDTH(r4)
   47.77 -	lfdu	fr5,FPR_WIDTH(r4)
   47.78 -	lfdu	fr6,FPR_WIDTH(r4)
   47.79 -	lfdu	fr7,FPR_WIDTH(r4)
   47.80 -	lfdu	fr8,FPR_WIDTH(r4)
   47.81 -	lfdu	fr9,FPR_WIDTH(r4)
   47.82 -	lfdu	fr10,FPR_WIDTH(r4)
   47.83 -	lfdu	fr11,FPR_WIDTH(r4)
   47.84 -	lfdu	fr12,FPR_WIDTH(r4)
   47.85 -	lfdu	fr13,FPR_WIDTH(r4)
   47.86 -	lfdu	fr14,FPR_WIDTH(r4)
   47.87 -	lfdu	fr15,FPR_WIDTH(r4)
   47.88 -	lfdu	fr16,FPR_WIDTH(r4)
   47.89 -	lfdu	fr17,FPR_WIDTH(r4)
   47.90 -	lfdu	fr18,FPR_WIDTH(r4)
   47.91 -	lfdu	fr19,FPR_WIDTH(r4)
   47.92 -	lfdu	fr20,FPR_WIDTH(r4)
   47.93 -	lfdu	fr21,FPR_WIDTH(r4)
   47.94 -	lfdu	fr22,FPR_WIDTH(r4)
   47.95 -	lfdu	fr23,FPR_WIDTH(r4)
   47.96 -	lfdu	fr24,FPR_WIDTH(r4)
   47.97 -	lfdu	fr25,FPR_WIDTH(r4)
   47.98 -	lfdu	fr26,FPR_WIDTH(r4)
   47.99 -	lfdu	fr27,FPR_WIDTH(r4)
  47.100 -	lfdu	fr28,FPR_WIDTH(r4)
  47.101 -	lfdu	fr29,FPR_WIDTH(r4)
  47.102 -	lfdu	fr30,FPR_WIDTH(r4)
  47.103 -	lfdu	fr31,FPR_WIDTH(r4)
  47.104 -	blr
  47.105 -#endif /* HAS_FLOAT */
  47.106 -
  47.107 -#ifdef HAS_VMX
  47.108 -
  47.109 -#define VCPU_vr(n) (VCPU_vrs + ((n) * 16))
  47.110 -
  47.111 -/*
  47.112 - * We cannot rely on the domain to correctly use VRSAVE
  47.113 - * so it is required that all VMX registers are saved and restored.
  47.114 - */
  47.115 -save_vmx:
  47.116 -	mfspr	r0,SPRN_VRSAVE
  47.117 -	stw	r0,VCPU_vrsave(r3)
  47.118 -
  47.119 -	addi r0,r3,VCPU_vr(0);	stvxl	vr0,0,r0
  47.120 -	addi r0,r3,VCPU_vr(1);	stvxl	vr1,0,r0
  47.121 -	addi r0,r3,VCPU_vr(2);	stvxl	vr2,0,r0
  47.122 -	addi r0,r3,VCPU_vr(3);	stvxl	vr3,0,r0
  47.123 -	addi r0,r3,VCPU_vr(4);	stvxl	vr4,0,r0
  47.124 -	addi r0,r3,VCPU_vr(5);	stvxl	vr5,0,r0
  47.125 -	addi r0,r3,VCPU_vr(6);	stvxl	vr6,0,r0
  47.126 -	addi r0,r3,VCPU_vr(7);	stvxl	vr7,0,r0
  47.127 -	addi r0,r3,VCPU_vr(8);	stvxl	vr8,0,r0
  47.128 -
  47.129 -	/*
  47.130 -	 * By now vr0 should be pushed out so now is a good time to
  47.131 -	 * get the VRSCR which can take a long time and has no dependcies
  47.132 -	 * on the following operations.
  47.133 -	 */
  47.134 -	mfvscr	vr0
  47.135 -	addi r0,r3,VCPU_vscr ;	stvxl	vr0,0,r0
  47.136 -
  47.137 -	addi r0,r3,VCPU_vr(9);	stvxl	vr9,0,r0
  47.138 -	addi r0,r3,VCPU_vr(10);	stvxl	vr10,0,r0
  47.139 -	addi r0,r3,VCPU_vr(11);	stvxl	vr11,0,r0
  47.140 -	addi r0,r3,VCPU_vr(12);	stvxl	vr12,0,r0
  47.141 -	addi r0,r3,VCPU_vr(13);	stvxl	vr13,0,r0
  47.142 -	addi r0,r3,VCPU_vr(14);	stvxl	vr14,0,r0
  47.143 -	addi r0,r3,VCPU_vr(15);	stvxl	vr15,0,r0
  47.144 -	addi r0,r3,VCPU_vr(16);	stvxl	vr16,0,r0
  47.145 -	addi r0,r3,VCPU_vr(17);	stvxl	vr17,0,r0
  47.146 -	addi r0,r3,VCPU_vr(18);	stvxl	vr18,0,r0
  47.147 -	addi r0,r3,VCPU_vr(19);	stvxl	vr19,0,r0
  47.148 -	addi r0,r3,VCPU_vr(20);	stvxl	vr20,0,r0
  47.149 -	addi r0,r3,VCPU_vr(21);	stvxl	vr21,0,r0
  47.150 -	addi r0,r3,VCPU_vr(22);	stvxl	vr22,0,r0
  47.151 -	addi r0,r3,VCPU_vr(23);	stvxl	vr23,0,r0
  47.152 -	addi r0,r3,VCPU_vr(24);	stvxl	vr24,0,r0
  47.153 -	addi r0,r3,VCPU_vr(25);	stvxl	vr25,0,r0
  47.154 -	addi r0,r3,VCPU_vr(26);	stvxl	vr26,0,r0
  47.155 -	addi r0,r3,VCPU_vr(27);	stvxl	vr27,0,r0
  47.156 -	addi r0,r3,VCPU_vr(28);	stvxl	vr28,0,r0
  47.157 -	addi r0,r3,VCPU_vr(29);	stvxl	vr29,0,r0
  47.158 -	addi r0,r3,VCPU_vr(30);	stvxl	vr30,0,r0
  47.159 -	addi r0,r3,VCPU_vr(31);	stvxl	vr31,0,r0
  47.160 -	blr
  47.161 -
  47.162 -load_vmx:
  47.163 -	lwz	r0,VCPU_vrsave(r3)
  47.164 -	mtspr	SPRN_VRSAVE,r0
  47.165 -
  47.166 -	/*
  47.167 -	 * This operation can take a long time so we use vr31 to
  47.168 -	 * eliminate the depency on r0 for the next load
  47.169 -	 */
  47.170 -	addi r0,r3,VCPU_vscr ;	lvxl	vr31,0,r0
  47.171 -	mtvscr	vr31
  47.172 -
  47.173 -	addi r0,r3,VCPU_vr(0);	lvxl	vr0,0,r0
  47.174 -	addi r0,r3,VCPU_vr(1);	lvxl	vr1,0,r0
  47.175 -	addi r0,r3,VCPU_vr(2);	lvxl	vr2,0,r0
  47.176 -	addi r0,r3,VCPU_vr(3);	lvxl	vr3,0,r0
  47.177 -	addi r0,r3,VCPU_vr(4);	lvxl	vr4,0,r0
  47.178 -	addi r0,r3,VCPU_vr(5);	lvxl	vr5,0,r0
  47.179 -	addi r0,r3,VCPU_vr(6);	lvxl	vr6,0,r0
  47.180 -	addi r0,r3,VCPU_vr(7);	lvxl	vr7,0,r0
  47.181 -	addi r0,r3,VCPU_vr(8);	lvxl	vr8,0,r0
  47.182 -	addi r0,r3,VCPU_vr(9);	lvxl	vr9,0,r0
  47.183 -	addi r0,r3,VCPU_vr(10);	lvxl	vr10,0,r0
  47.184 -	addi r0,r3,VCPU_vr(11);	lvxl	vr11,0,r0
  47.185 -	addi r0,r3,VCPU_vr(12);	lvxl	vr12,0,r0
  47.186 -	addi r0,r3,VCPU_vr(13);	lvxl	vr13,0,r0
  47.187 -	addi r0,r3,VCPU_vr(14);	lvxl	vr14,0,r0
  47.188 -	addi r0,r3,VCPU_vr(15);	lvxl	vr15,0,r0
  47.189 -	addi r0,r3,VCPU_vr(16);	lvxl	vr16,0,r0
  47.190 -	addi r0,r3,VCPU_vr(17);	lvxl	vr17,0,r0
  47.191 -	addi r0,r3,VCPU_vr(18);	lvxl	vr18,0,r0
  47.192 -	addi r0,r3,VCPU_vr(19);	lvxl	vr19,0,r0
  47.193 -	addi r0,r3,VCPU_vr(20);	lvxl	vr20,0,r0
  47.194 -	addi r0,r3,VCPU_vr(21);	lvxl	vr21,0,r0
  47.195 -	addi r0,r3,VCPU_vr(22);	lvxl	vr22,0,r0
  47.196 -	addi r0,r3,VCPU_vr(23);	lvxl	vr23,0,r0
  47.197 -	addi r0,r3,VCPU_vr(24);	lvxl	vr24,0,r0
  47.198 -	addi r0,r3,VCPU_vr(25);	lvxl	vr25,0,r0
  47.199 -	addi r0,r3,VCPU_vr(26);	lvxl	vr26,0,r0
  47.200 -	addi r0,r3,VCPU_vr(27);	lvxl	vr27,0,r0
  47.201 -	addi r0,r3,VCPU_vr(28);	lvxl	vr28,0,r0
  47.202 -	addi r0,r3,VCPU_vr(29);	lvxl	vr29,0,r0
  47.203 -	addi r0,r3,VCPU_vr(30);	lvxl	vr30,0,r0
  47.204 -	addi r0,r3,VCPU_vr(31);	lvxl	vr31,0,r0
  47.205 -	blr
  47.206 -#endif /* HAS_VMX */
  47.207 -
  47.208 -/* void save_float(struct exec_domain *ed) */
  47.209 -_GLOBAL(save_float)
  47.210 -	mflr	r8
  47.211 -#ifdef HAS_FLOAT
  47.212 -	mfmsr	r9		# save msr
  47.213 -	ori	r0,r9,MSR_FP	# turn on FPU
  47.214 -	mtmsr	r0
  47.215 -	bl	save_fp		# uses r3, r4
  47.216 -	mtmsr	r9		# restore msr
  47.217 -#endif /* HAS_FLOAT */
  47.218 -#ifdef HAS_VMX
  47.219 -	mfmsr	r9		# save msr
  47.220 -	oris	r0,r9,MSR_VMX@h	# turn on VMX
  47.221 -	mtmsr	r0
  47.222 -	bl	save_vmx	# uses r3
  47.223 -	mtmsr	r9		# restore msr
  47.224 -#endif /* HAS_VMX */
  47.225 -	mtlr	r8
  47.226 -	blr
  47.227 -
  47.228 -/* void load_float(struct exec_domain *ed) */
  47.229 -_GLOBAL(load_float)
  47.230 -	mflr	r8
  47.231 -#ifdef HAS_FLOAT
  47.232 -	mfmsr	r9		# save msr
  47.233 -	ori	r0,r9,MSR_FP	# turn on FPU
  47.234 -	mtmsr	r0
  47.235 -	bl	load_fp	# uses r3, r4
  47.236 -	mtmsr	r9		# restore msr
  47.237 -#endif /* HAS_FLOAT */
  47.238 -#ifdef HAS_VMX
  47.239 -	mfmsr	r9		# save msr
  47.240 -	oris	r0,r9,MSR_VMX@h	# turn on VMX
  47.241 -	mtmsr	r0
  47.242 -	bl	load_vmx	# uses r3
  47.243 -	mtmsr	r9		# restore msr
  47.244 -#endif /* HAS_VMX */
  47.245 -	mtlr	r8
  47.246 -	blr
    48.1 --- a/xen/arch/powerpc/gdbstub.c	Thu May 08 13:15:45 2008 +0100
    48.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.3 @@ -1,216 +0,0 @@
    48.4 -/*
    48.5 - * This program is free software; you can redistribute it and/or modify
    48.6 - * it under the terms of the GNU General Public License as published by
    48.7 - * the Free Software Foundation; either version 2 of the License, or
    48.8 - * (at your option) any later version.
    48.9 - *
   48.10 - * This program is distributed in the hope that it will be useful,
   48.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   48.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   48.13 - * GNU General Public License for more details.
   48.14 - *
   48.15 - * You should have received a copy of the GNU General Public License
   48.16 - * along with this program; if not, write to the Free Software
   48.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   48.18 - *
   48.19 - * Copyright (C) IBM Corp. 2005
   48.20 - *
   48.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   48.22 - */
   48.23 -
   48.24 -#include <xen/types.h>
   48.25 -#include <xen/lib.h>
   48.26 -#include <xen/gdbstub.h>
   48.27 -#include <public/xen.h>
   48.28 -#include <asm/msr.h>
   48.29 -#include <asm/bitops.h>
   48.30 -#include <asm/cache.h>
   48.31 -#include <asm/debugger.h>
   48.32 -#include <asm/processor.h>
   48.33 -
   48.34 -asm(".globl trap_instruction\n"
   48.35 -        "trap_instruction:\n"
   48.36 -        "trap\n");
   48.37 -extern u32 trap_instruction[];
   48.38 -
   48.39 -static unsigned int dec_entry;
   48.40 -static unsigned int hdec_entry;
   48.41 -
   48.42 -static inline ulong
   48.43 -gdb_ppc_0x700(struct cpu_user_regs *state)
   48.44 -{
   48.45 -    ulong instr;
   48.46 -
   48.47 -    switch (state->msr & MSR_TRAP_BITS) {
   48.48 -        case MSR_TRAP_FE:
   48.49 -            return SIGFPE;
   48.50 -        case MSR_TRAP_IOP:
   48.51 -        case MSR_TRAP_PRIV:
   48.52 -            return SIGILL;
   48.53 -        case MSR_TRAP:
   48.54 -            instr = *((u32 *)state->pc);
   48.55 -
   48.56 -            /* if this was a hardcoded trap in the source, step past it */
   48.57 -            if (instr == *trap_instruction) {
   48.58 -                state->pc += sizeof (u32);
   48.59 -            }
   48.60 -            return SIGTRAP;
   48.61 -    }
   48.62 -    return SIGBUS;
   48.63 -}
   48.64 -
   48.65 -u16 gdb_arch_signal_num(struct cpu_user_regs *regs, unsigned long cookie)
   48.66 -{
   48.67 -    /* exception type identifies, trap or bad address */
   48.68 -    switch (cookie) {
   48.69 -        case 0x200: /* Machine Check */
   48.70 -            return SIGTERM;
   48.71 -        case 0x300: /* DSI */
   48.72 -        case 0x380: /* Data SLB */
   48.73 -        case 0x400: /* ISI */
   48.74 -        case 0x480: /* Instruction SLB */
   48.75 -            return SIGSEGV;
   48.76 -        case 0x600: /* Alignment SLB */
   48.77 -            return SIGBUS;
   48.78 -        case 0x700: /* Program */
   48.79 -            return gdb_ppc_0x700(regs);
   48.80 -        case 0x800: /* Float */
   48.81 -            return SIGFPE;
   48.82 -        case 0x900: /* Decrementer */
   48.83 -            return SIGALRM; /* is this right? */
   48.84 -        case 0xd00: /* TRAP */
   48.85 -            return SIGTRAP;
   48.86 -        case 0xe00: /* FP */
   48.87 -            return SIGFPE;
   48.88 -    }
   48.89 -    return SIGBUS;
   48.90 -}
   48.91 -
   48.92 -void
   48.93 -gdb_arch_resume(struct cpu_user_regs *regs,
   48.94 -                unsigned long addr, unsigned long type,
   48.95 -                struct gdb_context *ctx)
   48.96 -{
   48.97 -    if (addr != ~((ulong)0)) {
   48.98 -        regs->pc = addr;
   48.99 -    }
  48.100 -
  48.101 -    if (type == GDB_CONTINUE) {
  48.102 -        regs->msr &= ~MSR_SE;
  48.103 -    } else {
  48.104 -        regs->msr |= MSR_SE;
  48.105 -    }
  48.106 -}
  48.107 -
  48.108 -void 
  48.109 -gdb_arch_read_reg(unsigned long regnum, struct cpu_user_regs *regs,
  48.110 -                  struct gdb_context *ctx)
  48.111 -{
  48.112 -    unimplemented();
  48.113 -    gdb_send_reply("", ctx);
  48.114 -}
  48.115 -
  48.116 -void
  48.117 -gdb_arch_read_reg_array(struct cpu_user_regs *state, struct gdb_context *ctx)
  48.118 -{
  48.119 -    ulong i = 0;
  48.120 -
  48.121 -    for (i = 0; i < 32; ++i) {
  48.122 -        gdb_write_to_packet_hex(state->gprs[i], sizeof(state->gprs[i]), ctx);
  48.123 -    }
  48.124 -    /* Avoid floating point for now */
  48.125 -    for (i = 0; i < 32; ++i) {
  48.126 -        gdb_write_to_packet_hex(0, sizeof(u64), ctx);
  48.127 -    }
  48.128 -    gdb_write_to_packet_hex(state->pc, sizeof (state->pc), ctx);
  48.129 -    gdb_write_to_packet_hex(state->msr, sizeof (state->msr), ctx);
  48.130 -    gdb_write_to_packet_hex(state->cr, sizeof (state->cr), ctx);
  48.131 -    gdb_write_to_packet_hex(state->lr, sizeof (state->lr), ctx);
  48.132 -    gdb_write_to_packet_hex(state->ctr, sizeof (state->ctr), ctx);
  48.133 -    gdb_write_to_packet_hex(state->xer, sizeof (u32), ctx);
  48.134 -    gdb_write_to_packet_hex(0, sizeof(u32), ctx); /* fpscr */
  48.135 -    gdb_send_packet(ctx);
  48.136 -}
  48.137 -
  48.138 -void 
  48.139 -gdb_arch_write_reg(unsigned long regnum, unsigned long val, 
  48.140 -                    struct cpu_user_regs *regs, struct gdb_context *ctx)
  48.141 -{
  48.142 -    unimplemented();
  48.143 -    gdb_send_reply("", ctx);
  48.144 -}
  48.145 - 
  48.146 -void
  48.147 -gdb_arch_write_reg_array(struct cpu_user_regs *regs, const char *buf,
  48.148 -                         struct gdb_context *ctx)
  48.149 -{
  48.150 -    ulong i;
  48.151 -
  48.152 -    for (i = 0; i < 32; ++i) {
  48.153 -        regs->gprs[i] = str2ulong(buf, sizeof (ulong));
  48.154 -        buf += sizeof (regs->gprs[0]) * 2;
  48.155 -    }
  48.156 -    /* Avoid floating point for now */
  48.157 -    for (i = 0; i < 32; ++i) {
  48.158 -        buf += sizeof (u64) * 2;
  48.159 -    }
  48.160 -
  48.161 -    regs->pc = str2ulong(buf, sizeof (regs->pc));
  48.162 -    buf += sizeof (regs->pc) * 2;
  48.163 -    regs->msr = str2ulong(buf, sizeof (regs->msr));
  48.164 -    buf += sizeof (regs->msr) * 2;
  48.165 -    regs->cr = str2ulong(buf, sizeof (regs->cr));
  48.166 -    buf += sizeof (regs->cr) * 2;
  48.167 -    regs->lr = str2ulong(buf, sizeof (regs->lr));
  48.168 -    buf += sizeof (regs->lr) * 2;
  48.169 -    regs->ctr = str2ulong(buf, sizeof (regs->ctr));
  48.170 -    buf += sizeof (regs->ctr) * 2;
  48.171 -    regs->xer = str2ulong(buf, sizeof (u32));
  48.172 -    buf += sizeof (u32) * 2;
  48.173 -}
  48.174 -
  48.175 -unsigned int
  48.176 -gdb_arch_copy_from_user(void *dest, const void *src, unsigned len)
  48.177 -{
  48.178 -    memcpy(dest, src, len);
  48.179 -    return 0;
  48.180 -}
  48.181 -
  48.182 -unsigned int
  48.183 -gdb_arch_copy_to_user(void *dest, const void *src, unsigned len)
  48.184 -{
  48.185 -    memcpy(dest, src, len);
  48.186 -    synchronize_caches((ulong)dest, len);
  48.187 -    return 0;
  48.188 -}
  48.189 -
  48.190 -void
  48.191 -gdb_arch_print_state(struct cpu_user_regs *state)
  48.192 -{
  48.193 -    int i = 0;
  48.194 -    printk("PC: 0x%016lx MSR: 0x%016lx\n", state->pc, state->msr);
  48.195 -    printk("LR: 0x%016lx CTR: 0x%016lx\n", state->lr, state->ctr);
  48.196 -    /* XXX
  48.197 -       printk("DAR: 0x%016lx DSISR: 0x%016lx\n", state->dar, state->dsisr);
  48.198 -       */
  48.199 -    printk("CR: 0x%08x XER: 0x%016lx\n", state->cr, state->xer);
  48.200 -    for (; i < 32; i+=4) {
  48.201 -        printk("%02d: 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n",
  48.202 -                i, state->gprs[i], state->gprs[i+1],
  48.203 -                state->gprs[i+2], state->gprs[i+3]);
  48.204 -    }
  48.205 -}
  48.206 -
  48.207 -void
  48.208 -gdb_arch_enter(struct cpu_user_regs *state)
  48.209 -{
  48.210 -    dec_entry = mfdec();
  48.211 -    hdec_entry = mfhdec();
  48.212 -}
  48.213 -
  48.214 -void
  48.215 -gdb_arch_exit(struct cpu_user_regs *state)
  48.216 -{
  48.217 -    mtdec(dec_entry);
  48.218 -    mthdec(hdec_entry);
  48.219 -}
    49.1 --- a/xen/arch/powerpc/hcalls.c	Thu May 08 13:15:45 2008 +0100
    49.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.3 @@ -1,171 +0,0 @@
    49.4 -/*
    49.5 - * This program is free software; you can redistribute it and/or modify
    49.6 - * it under the terms of the GNU General Public License as published by
    49.7 - * the Free Software Foundation; either version 2 of the License, or
    49.8 - * (at your option) any later version.
    49.9 - *
   49.10 - * This program is distributed in the hope that it will be useful,
   49.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   49.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   49.13 - * GNU General Public License for more details.
   49.14 - *
   49.15 - * You should have received a copy of the GNU General Public License
   49.16 - * along with this program; if not, write to the Free Software
   49.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   49.18 - *
   49.19 - * Copyright IBM Corp. 2005, 2006, 2007
   49.20 - *
   49.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   49.22 - */
   49.23 -
   49.24 -#include <xen/config.h>
   49.25 -#include <xen/types.h>
   49.26 -#include <xen/sched.h>
   49.27 -#include <xen/lib.h>
   49.28 -#include <xen/init.h>
   49.29 -#include <xen/multicall.h>
   49.30 -#include <public/xen.h>
   49.31 -#include <asm/current.h>
   49.32 -#include <asm/papr.h>
   49.33 -#include <asm/hcalls.h>
   49.34 -#include <asm/debugger.h>
   49.35 -#include <asm/msr.h>
   49.36 -#include "exceptions.h"
   49.37 -
   49.38 -u32 *papr_hcalls;               /* PAPR Hypervisor Calls */
   49.39 -u32 *hypercall_table;           /* Xen Hypervisor Calls */
   49.40 -
   49.41 -static void hcall_papr(ulong num, struct cpu_user_regs *regs)
   49.42 -{
   49.43 -    u32 address;
   49.44 -
   49.45 -    if (regs->msr & MSR_PR) {
   49.46 -        regs->gprs[3] = H_Privilege;
   49.47 -        return;
   49.48 -    }
   49.49 -
   49.50 -    if ((num & 0x3) || (num > RPA_HCALL_END)) {
   49.51 -        regs->gprs[3] = H_Parameter;
   49.52 -        return;
   49.53 -    }
   49.54 -
   49.55 -    address = papr_hcalls[num/4];
   49.56 -    papr_hcall_jump(regs, address);
   49.57 -}
   49.58 -
   49.59 -static void hcall_xen(ulong num, struct cpu_user_regs *regs)
   49.60 -{
   49.61 -    u32 address;
   49.62 -
   49.63 -    if (regs->msr & MSR_PR) {
   49.64 -        regs->gprs[3] = -EPERM;
   49.65 -        return;
   49.66 -    }
   49.67 -
   49.68 -    if ((num >= NR_hypercalls)) {
   49.69 -        regs->gprs[3] = -ENOSYS;
   49.70 -        return;
   49.71 -    }
   49.72 -    address = hypercall_table[num];
   49.73 -    if (address == 0) {
   49.74 -        printk("unsupported Xen hypercall: 0x%lx\n", num);
   49.75 -        regs->gprs[3] = -ENOSYS;
   49.76 -        return;
   49.77 -    }
   49.78 -
   49.79 -    regs->gprs[3] = xen_hvcall_jump(regs, address);
   49.80 -}
   49.81 -
   49.82 -void do_multicall_call(multicall_entry_t *call)
   49.83 -{
   49.84 -    struct cpu_user_regs regs;
   49.85 -
   49.86 -    regs.gprs[3] = call->args[0];
   49.87 -    regs.gprs[4] = call->args[1];
   49.88 -    regs.gprs[5] = call->args[2];
   49.89 -    regs.gprs[6] = call->args[3];
   49.90 -    regs.gprs[7] = call->args[4];
   49.91 -    regs.gprs[8] = call->args[5];
   49.92 -
   49.93 -    hcall_xen(call->op, &regs);
   49.94 -
   49.95 -    call->result = regs.gprs[3];
   49.96 -}
   49.97 -
   49.98 -void do_hcall(struct cpu_user_regs *regs)
   49.99 -{
  49.100 -    ulong num = regs->gprs[3];
  49.101 -
  49.102 -    local_irq_enable();
  49.103 -
  49.104 -    if ((num & XEN_MARK(0)) == XEN_MARK(0)) {
  49.105 -        /* it's a Xen call */
  49.106 -        num &= ~XEN_MARK(0);
  49.107 -        hcall_xen(num, regs);
  49.108 -    } else {
  49.109 -        /* it's a PAPR call */
  49.110 -        hcall_papr(num, regs);
  49.111 -    }
  49.112 -}
  49.113 -
  49.114 -static void do_ni_papr_hypercall(struct cpu_user_regs *regs)
  49.115 -{
  49.116 -    struct vcpu *v = get_current();
  49.117 -
  49.118 -    printk("unsupported PAPR hcall 0x%lx was called by dom0x%x\n",
  49.119 -            regs->gprs[3], v->domain->domain_id);
  49.120 -
  49.121 -    regs->gprs[3] = H_Parameter;
  49.122 -}
  49.123 -
  49.124 -/* store low 32 bits of 64-bit address in hcall table (this is safe because we
  49.125 - * know we will not link above 4GB). We don't need to preserve the TOC
  49.126 - * because that only changes when calling dynamically linked objects. */
  49.127 -static void register_papr_hcall(ulong num, hcall_handler_t handler)
  49.128 -{
  49.129 -    int index = num/4;
  49.130 -
  49.131 -    papr_hcalls[index] = (u32)(*(u64 *)handler);
  49.132 -}
  49.133 -
  49.134 -static void init_papr_hcalls(void)
  49.135 -{
  49.136 -    init_hcall_t *hcall;
  49.137 -    int i;
  49.138 -
  49.139 -    /* initialize PAPR hcall table */
  49.140 -    papr_hcalls = xmalloc_array(u32, RPA_HCALL_END/4);
  49.141 -    ASSERT(papr_hcalls != NULL);
  49.142 -    for (i = 0; i <= RPA_HCALL_END; i += 4)
  49.143 -        register_papr_hcall(i, do_ni_papr_hypercall);
  49.144 -
  49.145 -    /* register the PAPR hcalls */
  49.146 -    for (hcall = &__init_hcall_start; hcall < &__init_hcall_end; hcall++) {
  49.147 -        register_papr_hcall(hcall->number, hcall->handler);
  49.148 -    }
  49.149 -}
  49.150 -
  49.151 -static void init_hypercall_table(void)
  49.152 -{
  49.153 -    int i;
  49.154 -
  49.155 -    hypercall_table = xmalloc_array(u32, NR_hypercalls);
  49.156 -    ASSERT(hypercall_table != NULL);
  49.157 -
  49.158 -    for (i = 0; i < NR_hypercalls; i++) {
  49.159 -        if (__hypercall_table[i] == NULL ) {
  49.160 -            hypercall_table[i] = 0;
  49.161 -        } else {
  49.162 -            hypercall_table[i] = (u32)(*__hypercall_table[i]);
  49.163 -        }
  49.164 -    }
  49.165 -}
  49.166 -
  49.167 -static int init_hcalls(void)
  49.168 -{
  49.169 -    init_papr_hcalls();
  49.170 -    init_hypercall_table();
  49.171 -
  49.172 -    return 0;
  49.173 -}
  49.174 -__initcall(init_hcalls);
    50.1 --- a/xen/arch/powerpc/iommu.c	Thu May 08 13:15:45 2008 +0100
    50.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.3 @@ -1,95 +0,0 @@
    50.4 -/*
    50.5 - * This program is free software; you can redistribute it and/or modify
    50.6 - * it under the terms of the GNU General Public License as published by
    50.7 - * the Free Software Foundation; either version 2 of the License, or
    50.8 - * (at your option) any later version.
    50.9 - *
   50.10 - * This program is distributed in the hope that it will be useful,
   50.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   50.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   50.13 - * GNU General Public License for more details.
   50.14 - *
   50.15 - * You should have received a copy of the GNU General Public License
   50.16 - * along with this program; if not, write to the Free Software
   50.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   50.18 - *
   50.19 - * Copyright IBM Corp. 2005, 2007
   50.20 - *
   50.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   50.22 - */
   50.23 -
   50.24 -#undef DEBUG
   50.25 -
   50.26 -#include <xen/config.h>
   50.27 -#include <xen/types.h>
   50.28 -#include <xen/sched.h>
   50.29 -#include <xen/init.h>
   50.30 -#include <xen/mm.h>
   50.31 -#include <asm/current.h>
   50.32 -#include <asm/papr.h>
   50.33 -#include <asm/hcalls.h>
   50.34 -#include <public/xen.h>
   50.35 -#include "tce.h"
   50.36 -#include "iommu.h"
   50.37 -
   50.38 -#ifdef DEBUG
   50.39 -#define DBG(fmt...) printk(fmt)
   50.40 -#else
   50.41 -#define DBG(fmt...)
   50.42 -#endif
   50.43 -
   50.44 -struct iommu_funcs {
   50.45 -    int (*iommu_put)(ulong, union tce);
   50.46 -};
   50.47 -
   50.48 -/* individual host bridges */
   50.49 -static struct iommu_funcs iommu_phbs[16];
   50.50 -static u32 iommu_phbs_num = ARRAY_SIZE(iommu_phbs);
   50.51 -
   50.52 -int iommu_put(u32 buid, ulong ioba, union tce tce)
   50.53 -{
   50.54 -    struct vcpu *v = get_current();
   50.55 -    struct domain *d = v->domain;
   50.56 -
   50.57 -    if (buid < iommu_phbs_num && iommu_phbs[buid].iommu_put != NULL) {
   50.58 -        ulong gmfn;
   50.59 -        ulong mfn;
   50.60 -        int mtype;
   50.61 -
   50.62 -        gmfn = tce.tce_bits.tce_rpn;
   50.63 -
   50.64 -        
   50.65 -        mfn = pfn2mfn(d, gmfn, &mtype);
   50.66 -        if (mfn != INVALID_MFN) {
   50.67 -            switch (mtype) {
   50.68 -            case PFN_TYPE_LOGICAL:
   50.69 -                break;
   50.70 -            case PFN_TYPE_FOREIGN:
   50.71 -                DBG("%s: assigning to Foriegn page: "
   50.72 -                    "gmfn: 0x%lx mfn: 0x%lx\n",  __func__, gmfn, mfn);
   50.73 -                break;
   50.74 -            default:
   50.75 -                printk("%s: unsupported type[%d]: gmfn: 0x%lx mfn: 0x%lx\n",
   50.76 -                       __func__, mtype, gmfn, mfn);
   50.77 -                return -1;
   50.78 -            break;
   50.79 -            }
   50.80 -            DBG("%s: ioba=0x%lx gmfn=0x%lx mfn=0x%lx\n", __func__,
   50.81 -                ioba, gmfn, mfn);
   50.82 -            tce.tce_bits.tce_rpn = mfn;
   50.83 -            return iommu_phbs[buid].iommu_put(ioba, tce);
   50.84 -        }
   50.85 -    }
   50.86 -    return -1;
   50.87 -}
   50.88 -
   50.89 -int iommu_register(u32 buid, int (*put)(ulong ioba, union tce ltce))
   50.90 -{
   50.91 -
   50.92 -    if (buid < iommu_phbs_num && iommu_phbs[buid].iommu_put == NULL) {
   50.93 -        iommu_phbs[0].iommu_put = put;
   50.94 -        return 0;
   50.95 -    }
   50.96 -    panic("bad IOMMU registration\n");
   50.97 -    return -1;
   50.98 -}
    51.1 --- a/xen/arch/powerpc/iommu.h	Thu May 08 13:15:45 2008 +0100
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,28 +0,0 @@
    51.4 -/*
    51.5 - * This program is free software; you can redistribute it and/or modify
    51.6 - * it under the terms of the GNU General Public License as published by
    51.7 - * the Free Software Foundation; either version 2 of the License, or
    51.8 - * (at your option) any later version.
    51.9 - *
   51.10 - * This program is distributed in the hope that it will be useful,
   51.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   51.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   51.13 - * GNU General Public License for more details.
   51.14 - *
   51.15 - * You should have received a copy of the GNU General Public License
   51.16 - * along with this program; if not, write to the Free Software
   51.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   51.18 - *
   51.19 - * Copyright (C) IBM Corp. 2005
   51.20 - *
   51.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   51.22 - */
   51.23 -
   51.24 -#ifndef _IOMMU_H
   51.25 -#define _IOMMU_H
   51.26 -
   51.27 -extern int iommu_put(u32 buid, ulong ioba, union tce tce);
   51.28 -extern int iommu_register(u32 buid, int (*put)(ulong, union tce));
   51.29 -
   51.30 -#endif /* _IOMMU_H */
   51.31 -
    52.1 --- a/xen/arch/powerpc/irq.c	Thu May 08 13:15:45 2008 +0100
    52.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.3 @@ -1,22 +0,0 @@
    52.4 -/*
    52.5 - * This program is free software; you can redistribute it and/or modify
    52.6 - * it under the terms of the GNU General Public License as published by
    52.7 - * the Free Software Foundation; either version 2 of the License, or
    52.8 - * (at your option) any later version.
    52.9 - *
   52.10 - * This program is distributed in the hope that it will be useful,
   52.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   52.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   52.13 - * GNU General Public License for more details.
   52.14 - *
   52.15 - * You should have received a copy of the GNU General Public License
   52.16 - * along with this program; if not, write to the Free Software
   52.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   52.18 - *
   52.19 - * Copyright (C) IBM Corp. 2005
   52.20 - *
   52.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   52.22 - */
   52.23 -
   52.24 -#include "exceptions.h"
   52.25 -#include "../x86/irq.c"
    53.1 --- a/xen/arch/powerpc/machine_kexec.c	Thu May 08 13:15:45 2008 +0100
    53.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.3 @@ -1,41 +0,0 @@
    53.4 -#include <xen/lib.h>       /* for printk() used in stubs */
    53.5 -#include <xen/types.h>
    53.6 -#include <xen/kexec.h>
    53.7 -#include <public/kexec.h>
    53.8 -
    53.9 -int machine_kexec_load(int type, int slot, xen_kexec_image_t *image)
   53.10 -{
   53.11 -    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
   53.12 -    return -1;
   53.13 -}
   53.14 -
   53.15 -void machine_kexec_unload(int type, int slot, xen_kexec_image_t *image)
   53.16 -{
   53.17 -    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
   53.18 -}
   53.19 -
   53.20 -void machine_reboot_kexec(xen_kexec_image_t *image)
   53.21 -{
   53.22 -    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
   53.23 -}
   53.24 -
   53.25 -void machine_kexec(xen_kexec_image_t *image)
   53.26 -{
   53.27 -    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
   53.28 -}
   53.29 -
   53.30 -int machine_kexec_get(xen_kexec_image_t *image)
   53.31 -{
   53.32 -    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
   53.33 -    return -1;
   53.34 -}
   53.35 -
   53.36 -/*
   53.37 - * Local variables:
   53.38 - * mode: C
   53.39 - * c-set-style: "BSD"
   53.40 - * c-basic-offset: 4
   53.41 - * tab-width: 4
   53.42 - * indent-tabs-mode: nil
   53.43 - * End:
   53.44 - */
    54.1 --- a/xen/arch/powerpc/memory.c	Thu May 08 13:15:45 2008 +0100
    54.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.3 @@ -1,224 +0,0 @@
    54.4 -/*
    54.5 - * This program is free software; you can redistribute it and/or modify
    54.6 - * it under the terms of the GNU General Public License as published by
    54.7 - * the Free Software Foundation; either version 2 of the License, or
    54.8 - * (at your option) any later version.
    54.9 - *
   54.10 - * This program is distributed in the hope that it will be useful,
   54.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   54.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   54.13 - * GNU General Public License for more details.
   54.14 - *
   54.15 - * You should have received a copy of the GNU General Public License
   54.16 - * along with this program; if not, write to the Free Software
   54.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   54.18 - *
   54.19 - * Copyright IBM Corp. 2006, 2007
   54.20 - *
   54.21 - * Authors: Dan Poff <poff@us.ibm.com>
   54.22 - *          Jimi Xenidis <jimix@watson.ibm.com>
   54.23 - */
   54.24 -#include <xen/sched.h>
   54.25 -#include <xen/mm.h>
   54.26 -#include <xen/numa.h>
   54.27 -#include <asm/boot.h>
   54.28 -#include "of-devtree.h"
   54.29 -#include "oftree.h"
   54.30 -#include "rtas.h"
   54.31 -
   54.32 -#define DEBUG
   54.33 -#ifdef DEBUG
   54.34 -#define DBG(fmt...) printk(fmt)
   54.35 -#else
   54.36 -#define DBG(fmt...)
   54.37 -#endif
   54.38 -
   54.39 -/*
   54.40 - * opt_xenheap_megabytes: Size of Xen heap in megabytes, excluding the
   54.41 - * page_info table and allocation bitmap.
   54.42 - */
   54.43 -static unsigned int opt_xenheap_megabytes = XENHEAP_DEFAULT_MB;
   54.44 -integer_param("xenheap_megabytes", opt_xenheap_megabytes);
   54.45 -
   54.46 -unsigned long xenheap_phys_end;
   54.47 -static uint nr_pages;
   54.48 -static ulong xenheap_size;
   54.49 -
   54.50 -struct membuf {
   54.51 -    ulong start;
   54.52 -    ulong size;
   54.53 -};
   54.54 -
   54.55 -typedef void (*walk_mem_fn)(struct membuf *, uint);
   54.56 -
   54.57 -static void set_max_page(struct membuf *mb, uint entries)
   54.58 -{
   54.59 -    int i;
   54.60 -
   54.61 -    for (i = 0; i < entries; i++) {
   54.62 -        ulong end_page;
   54.63 -
   54.64 -        printk("  %016lx: %016lx\n", mb[i].start, mb[i].size);
   54.65 -        nr_pages += mb[i].size >> PAGE_SHIFT;
   54.66 -
   54.67 -        end_page = (mb[i].start + mb[i].size) >> PAGE_SHIFT;
   54.68 -        if (end_page > max_page)
   54.69 -            max_page = end_page;
   54.70 -    }
   54.71 -}
   54.72 -
   54.73 -/* mark all memory from modules onward as unused */
   54.74 -static void heap_init(struct membuf *mb, uint entries)
   54.75 -{
   54.76 -    int i;
   54.77 -    ulong start_blk;
   54.78 -    ulong end_blk = 0;
   54.79 -
   54.80 -    for (i = 0; i < entries; i++) {
   54.81 -        start_blk = mb[i].start;
   54.82 -        end_blk = start_blk + mb[i].size;
   54.83 -
   54.84 -        if (start_blk < xenheap_phys_end) {
   54.85 -            if (xenheap_phys_end > end_blk) {
   54.86 -                panic("xenheap spans LMB\n");
   54.87 -            }
   54.88 -            if (xenheap_phys_end == end_blk)
   54.89 -                continue;
   54.90 -
   54.91 -            start_blk = xenheap_phys_end;
   54.92 -        }
   54.93 -
   54.94 -        DBG("boot free: %016lx - %016lx\n", start_blk, end_blk);
   54.95 -        init_boot_pages(start_blk, end_blk);
   54.96 -        total_pages += (end_blk - start_blk) >> PAGE_SHIFT;
   54.97 -    }
   54.98 -}
   54.99 -
  54.100 -static void ofd_walk_mem(void *m, walk_mem_fn fn)
  54.101 -{
  54.102 -    ofdn_t n;
  54.103 -    uint p_len;
  54.104 -    struct membuf mb[8];
  54.105 -    static char name[] = "memory";
  54.106 -
  54.107 -    n = ofd_node_find_by_prop(m, OFD_ROOT, "device_type", name, sizeof(name));
  54.108 -    while (n > 0) {
  54.109 -
  54.110 -        p_len = ofd_getprop(m, n, "reg", mb, sizeof (mb));
  54.111 -        if (p_len <= 0) {
  54.112 -            panic("ofd_getprop(): failed\n");
  54.113 -        }
  54.114 -        if (p_len > sizeof(mb))
  54.115 -            panic("%s: buffer is not big enuff for this firmware: "
  54.116 -                  "0x%lx < 0x%x\n", __func__, sizeof(mb), p_len);
  54.117 -
  54.118 -        fn(mb, p_len / sizeof(mb[0]));
  54.119 -        n = ofd_node_find_next(m, n);
  54.120 -    }
  54.121 -}
  54.122 -
  54.123 -void memory_init(void)
  54.124 -{
  54.125 -    ulong eomem;
  54.126 -    ulong bitmap_start = ~0UL;
  54.127 -    ulong bitmap_end = 0;
  54.128 -    ulong bitmap_size;
  54.129 -    ulong xh_pages;
  54.130 -    ulong start;
  54.131 -    ulong end;
  54.132 -    int pos;
  54.133 -
  54.134 -    /* lets find out how much memory there is and set max_page */
  54.135 -    max_page = 0;
  54.136 -    printk("Physical RAM map:\n");
  54.137 -    ofd_walk_mem((void *)oftree, set_max_page);
  54.138 -    eomem = max_page << PAGE_SHIFT;
  54.139 -    if (eomem == 0) {
  54.140 -        panic("ofd_walk_mem() failed\n");
  54.141 -    }
  54.142 -
  54.143 -    xh_pages = opt_xenheap_megabytes << (20 - PAGE_SHIFT);
  54.144 -
  54.145 -    /* While we are allocating HTABS from The Xen Heap we need it to
  54.146 -     * be larger */
  54.147 -    xh_pages += nr_pages >> 5;
  54.148 -
  54.149 -    xenheap_phys_end = xh_pages << PAGE_SHIFT;
  54.150 -    printk("End of Xen Area: %luMiB (%luKiB)\n",
  54.151 -           xenheap_phys_end >> 20, xenheap_phys_end >> 10);
  54.152 -
  54.153 -    printk("End of RAM: %luMiB (%luKiB)\n", eomem >> 20, eomem >> 10);
  54.154 -
  54.155 -    /* The boot allocator requires one bit per page. Find a spot for it. */
  54.156 -    bitmap_size = max_page / 8;
  54.157 -    pos = boot_of_mem_avail(0, &start, &end);
  54.158 -    while (pos >= 0) {
  54.159 -        if (end - start >= bitmap_size) {
  54.160 -            bitmap_start = start;
  54.161 -            bitmap_end = init_boot_allocator(bitmap_start);
  54.162 -            printk("boot allocator @ %lx - %lx\n", bitmap_start, bitmap_end);
  54.163 -            break;
  54.164 -        }
  54.165 -        pos = boot_of_mem_avail(pos, &start, &end);
  54.166 -    }
  54.167 -    if (bitmap_start == ~0UL)
  54.168 -        panic("Couldn't find 0x%lx bytes for boot allocator.", bitmap_size);
  54.169 -
  54.170 -    /* allow everything else to be allocated */
  54.171 -    total_pages = 0;
  54.172 -    ofd_walk_mem((void *)oftree, heap_init);
  54.173 -    if (total_pages == 0)
  54.174 -        panic("heap_init: failed");
  54.175 -
  54.176 -    if (total_pages > max_page)
  54.177 -        panic("total_pages > max_page: 0x%lx > 0x%lx\n",
  54.178 -              total_pages, max_page);
  54.179 -
  54.180 -    DBG("total_pages: 0x%016lx\n", total_pages);
  54.181 -
  54.182 -    init_frametable();
  54.183 -    init_machine_to_phys_table();
  54.184 -
  54.185 -    numa_initmem_init(0, max_page);
  54.186 -
  54.187 -    /* Domain heap gets all the unclaimed memory. */
  54.188 -    end_boot_allocator();
  54.189 -
  54.190 -    /* Create initial xen heap by finding non-reserved memory. */
  54.191 -    pos = boot_of_mem_avail(0, &start, &end);
  54.192 -    while (pos >= 0) {
  54.193 -        if (end == ~0UL)
  54.194 -            end = xenheap_phys_end;
  54.195 -
  54.196 -        /* Problem: the bitmap itself is not reserved. */
  54.197 -        if ((start >= bitmap_start) && (start < bitmap_end)) {
  54.198 -            /* Start is inside bitmap. */
  54.199 -            start = bitmap_end;
  54.200 -        }
  54.201 -        if ((end > bitmap_start) && (end <= bitmap_end)) {
  54.202 -            /* End is inside bitmap. */
  54.203 -            end = bitmap_start;
  54.204 -        }
  54.205 -        if ((start < bitmap_start) && (end > bitmap_end)) {
  54.206 -            /* Range encompasses bitmap. First free low part, then high. */
  54.207 -            xenheap_size += bitmap_start - start;
  54.208 -            DBG("xenheap: %016lx - %016lx\n", start, bitmap_start);
  54.209 -            init_xenheap_pages(start, bitmap_start);
  54.210 -            start = bitmap_end;
  54.211 -        }
  54.212 -
  54.213 -        xenheap_size += end - start;
  54.214 -        DBG("xenheap: %016lx - %016lx\n", start, end);
  54.215 -        init_xenheap_pages(start, end);
  54.216 -
  54.217 -        pos = boot_of_mem_avail(pos, &start, &end);
  54.218 -    }
  54.219 -
  54.220 -    printk("Xen Heap: %luMiB (%luKiB)\n",
  54.221 -           xenheap_size >> 20, xenheap_size >> 10);
  54.222 -
  54.223 -    eomem = avail_domheap_pages();
  54.224 -    printk("Dom Heap: %luMiB (%luKiB)\n",
  54.225 -           (eomem << PAGE_SHIFT) >> 20,
  54.226 -           (eomem << PAGE_SHIFT) >> 10);
  54.227 -}
    55.1 --- a/xen/arch/powerpc/mm.c	Thu May 08 13:15:45 2008 +0100
    55.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.3 @@ -1,617 +0,0 @@
    55.4 -/*
    55.5 - * This program is free software; you can redistribute it and/or modify
    55.6 - * it under the terms of the GNU General Public License as published by
    55.7 - * the Free Software Foundation; either version 2 of the License, or
    55.8 - * (at your option) any later version.
    55.9 - *
   55.10 - * This program is distributed in the hope that it will be useful,
   55.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   55.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   55.13 - * GNU General Public License for more details.
   55.14 - *
   55.15 - * You should have received a copy of the GNU General Public License
   55.16 - * along with this program; if not, write to the Free Software
   55.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   55.18 - *
   55.19 - * Copyright (C) IBM Corp. 2005, 2006
   55.20 - *
   55.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   55.22 - *          Jimi Xenidis <jimix@watson.ibm.com>
   55.23 - *          Ryan Harper <ryanh@us.ibm.com>
   55.24 - */
   55.25 -
   55.26 -#include <xen/config.h>
   55.27 -#include <xen/mm.h>
   55.28 -#include <xen/paging.h>
   55.29 -#include <xen/kernel.h>
   55.30 -#include <xen/sched.h>
   55.31 -#include <xen/perfc.h>
   55.32 -#include <asm/init.h>
   55.33 -#include <asm/page.h>
   55.34 -#include <asm/platform.h>
   55.35 -#include <asm/string.h>
   55.36 -#include <asm/platform.h>
   55.37 -#include <public/arch-powerpc.h>
   55.38 -
   55.39 -#ifdef VERBOSE
   55.40 -#define MEM_LOG(_f, _a...)                                  \
   55.41 -  printk("DOM%u: (file=mm.c, line=%d) " _f "\n",            \
   55.42 -         current->domain->domain_id , __LINE__ , ## _a )
   55.43 -#else
   55.44 -#define MEM_LOG(_f, _a...) ((void)0)
   55.45 -#endif
   55.46 -
   55.47 -/* Frame table and its size in pages. */
   55.48 -struct page_info *frame_table;
   55.49 -unsigned long max_page;
   55.50 -unsigned long total_pages;
   55.51 -
   55.52 -/* machine to phys mapping to used by all domains */
   55.53 -unsigned long *machine_phys_mapping;
   55.54 -
   55.55 -void __init init_frametable(void)
   55.56 -{
   55.57 -    unsigned long p;
   55.58 -    unsigned long nr_pages;
   55.59 -    int i;
   55.60 -
   55.61 -    nr_pages = PFN_UP(max_page * sizeof(struct page_info));
   55.62 -
   55.63 -    p = alloc_boot_pages(nr_pages, 1);
   55.64 -    if (p == 0)
   55.65 -        panic("Not enough memory for frame table\n");
   55.66 -
   55.67 -    frame_table = (struct page_info *)(p << PAGE_SHIFT);
   55.68 -    for (i = 0; i < nr_pages; i += 1)
   55.69 -        clear_page((void *)((p + i) << PAGE_SHIFT));
   55.70 -}
   55.71 -
   55.72 -/* Array of PFNs, indexed by MFN. */
   55.73 -void __init init_machine_to_phys_table(void)
   55.74 -{
   55.75 -    unsigned long p;
   55.76 -    unsigned long nr_pages;
   55.77 -    int i;
   55.78 -
   55.79 -    nr_pages = PFN_UP(max_page * sizeof(unsigned long));
   55.80 -
   55.81 -    p = alloc_boot_pages(nr_pages, 1);
   55.82 -    if (p == 0)
   55.83 -        panic("Not enough memory for machine phys mapping table\n");
   55.84 -
   55.85 -    machine_phys_mapping = (unsigned long *)(p << PAGE_SHIFT);
   55.86 -    for (i = 0; i < nr_pages; i += 1)
   55.87 -        clear_page((void *)((p + i) << PAGE_SHIFT));
   55.88 -}
   55.89 -
   55.90 -void share_xen_page_with_guest(
   55.91 -    struct page_info *page, struct domain *d, int readonly)
   55.92 -{
   55.93 -    if ( page_get_owner(page) == d )
   55.94 -        return;
   55.95 -
   55.96 -    /* this causes us to leak pages in the Domain and reuslts in
   55.97 -     * Zombie domains, I think we are missing a piece, until we find
   55.98 -     * it we disable the following code */
   55.99 -    set_gpfn_from_mfn(page_to_mfn(page), INVALID_M2P_ENTRY);
  55.100 -
  55.101 -    spin_lock(&d->page_alloc_lock);
  55.102 -
  55.103 -    /* The incremented type count pins as writable or read-only. */
  55.104 -    page->u.inuse.type_info  = (readonly ? PGT_none : PGT_writable_page);
  55.105 -    page->u.inuse.type_info |= PGT_validated | 1;
  55.106 -
  55.107 -    page_set_owner(page, d);
  55.108 -    wmb(); /* install valid domain ptr before updating refcnt. */
  55.109 -    ASSERT(page->count_info == 0);
  55.110 -
  55.111 -    /* Only add to the allocation list if the domain isn't dying. */
  55.112 -    if ( !d->is_dying )
  55.113 -    {
  55.114 -        page->count_info |= PGC_allocated | 1;
  55.115 -        if ( unlikely(d->xenheap_pages++ == 0) )
  55.116 -            get_knownalive_domain(d);
  55.117 -        list_add_tail(&page->list, &d->xenpage_list);
  55.118 -    }
  55.119 -
  55.120 -    spin_unlock(&d->page_alloc_lock);
  55.121 -}
  55.122 -
  55.123 -void share_xen_page_with_privileged_guests(
  55.124 -    struct page_info *page, int readonly)
  55.125 -{
  55.126 -        unimplemented();
  55.127 -}
  55.128 -
  55.129 -static ulong foreign_to_mfn(struct domain *d, ulong pfn)
  55.130 -{
  55.131 -
  55.132 -    pfn -= 1UL << cpu_foreign_map_order();
  55.133 -
  55.134 -    BUG_ON(pfn >= d->arch.foreign_mfn_count);
  55.135 -
  55.136 -    return d->arch.foreign_mfns[pfn];
  55.137 -}
  55.138 -
  55.139 -static int set_foreign(struct domain *d, ulong pfn, ulong mfn)
  55.140 -{
  55.141 -    pfn -= 1UL << cpu_foreign_map_order();
  55.142 -
  55.143 -    BUG_ON(pfn >= d->arch.foreign_mfn_count);
  55.144 -    d->arch.foreign_mfns[pfn] = mfn;
  55.145 -
  55.146 -    return 0;
  55.147 -}
  55.148 -
  55.149 -static int create_grant_va_mapping(
  55.150 -    unsigned long va, unsigned long frame, struct vcpu *v)
  55.151 -{
  55.152 -    if (v->domain->domain_id != 0) {
  55.153 -        printk("only Dom0 can map a grant entry\n");
  55.154 -        BUG();
  55.155 -        return GNTST_permission_denied;
  55.156 -    }
  55.157 -    set_foreign(v->domain, va >> PAGE_SHIFT, frame);
  55.158 -    return GNTST_okay;
  55.159 -}
  55.160 -
  55.161 -static int destroy_grant_va_mapping(
  55.162 -    unsigned long addr, unsigned long frame, struct domain *d)
  55.163 -{
  55.164 -    if (d->domain_id != 0) {
  55.165 -        printk("only Dom0 can map a grant entry\n");
  55.166 -        BUG();
  55.167 -        return GNTST_permission_denied;
  55.168 -    }
  55.169 -    set_foreign(d, addr >> PAGE_SHIFT, ~0UL);
  55.170 -    return GNTST_okay;
  55.171 -}
  55.172 -
  55.173 -int create_grant_host_mapping(
  55.174 -    unsigned long addr, unsigned long frame, unsigned int flags, unsigned int cache_flags)
  55.175 -{
  55.176 -    if (flags & GNTMAP_application_map) {
  55.177 -        printk("%s: GNTMAP_application_map not supported\n", __func__);
  55.178 -        BUG();
  55.179 -        return GNTST_general_error;
  55.180 -    }
  55.181 -    if (flags & GNTMAP_contains_pte) {
  55.182 -        printk("%s: GNTMAP_contains_pte not supported\n", __func__);
  55.183 -        BUG();
  55.184 -        return GNTST_general_error;
  55.185 -    }
  55.186 -    if (cache_flags) {
  55.187 -        printk("%s: cache_flags not supported\n", __func__);
  55.188 -        BUG();
  55.189 -        return GNTST_general_error;
  55.190 -    }
  55.191 -    return create_grant_va_mapping(addr, frame, current);
  55.192 -}
  55.193 -
  55.194 -int replace_grant_host_mapping(
  55.195 -    unsigned long addr, unsigned long frame, unsigned long new_addr,
  55.196 -    unsigned int flags)
  55.197 -{
  55.198 -    if (new_addr) {
  55.199 -        printk("%s: new_addr not supported\n", __func__);
  55.200 -        BUG();
  55.201 -        return GNTST_general_error;
  55.202 -    }
  55.203 -
  55.204 -    if (flags & GNTMAP_contains_pte) {
  55.205 -        printk("%s: GNTMAP_contains_pte not supported\n", __func__);
  55.206 -        BUG();
  55.207 -        return GNTST_general_error;
  55.208 -    }
  55.209 -
  55.210 -    /* may have force the remove here */
  55.211 -    return destroy_grant_va_mapping(addr, frame, current->domain);
  55.212 -}
  55.213 -
  55.214 -int steal_page(struct domain *d, struct page_info *page, unsigned int memflags)
  55.215 -{
  55.216 -    panic("%s called\n", __func__);
  55.217 -    return 1;
  55.218 -}
  55.219 -
  55.220 -void put_page_type(struct page_info *page)
  55.221 -{
  55.222 -    unsigned long nx, x, y = page->u.inuse.type_info;
  55.223 -
  55.224 -    do {
  55.225 -        x  = y;
  55.226 -        nx = x - 1;
  55.227 -
  55.228 -        ASSERT((x & PGT_count_mask) != 0);
  55.229 -
  55.230 -        /*
  55.231 -         * The page should always be validated while a reference is held. The 
  55.232 -         * exception is during domain destruction, when we forcibly invalidate 
  55.233 -         * page-table pages if we detect a referential loop.
  55.234 -         * See domain.c:relinquish_list().
  55.235 -         */
  55.236 -        ASSERT((x & PGT_validated) || page_get_owner(page)->is_dying);
  55.237 -
  55.238 -        if ( unlikely((nx & PGT_count_mask) == 0) )
  55.239 -        {
  55.240 -            /* Record TLB information for flush later. */
  55.241 -            page->tlbflush_timestamp = tlbflush_current_time();
  55.242 -        }
  55.243 -    }
  55.244 -    while ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) != x) );
  55.245 -}
  55.246 -
  55.247 -
  55.248 -int get_page_type(struct page_info *page, unsigned long type)
  55.249 -{
  55.250 -    unsigned long nx, x, y = page->u.inuse.type_info;
  55.251 -
  55.252 -    ASSERT(!(type & ~PGT_type_mask));
  55.253 -
  55.254 - again:
  55.255 -    do {
  55.256 -        x  = y;
  55.257 -        nx = x + 1;
  55.258 -        if ( unlikely((nx & PGT_count_mask) == 0) )
  55.259 -        {
  55.260 -            MEM_LOG("Type count overflow on pfn %lx", page_to_mfn(page));
  55.261 -            return 0;
  55.262 -        }
  55.263 -        else if ( unlikely((x & PGT_count_mask) == 0) )
  55.264 -        {
  55.265 -            if ( (x & PGT_type_mask) != type )
  55.266 -            {
  55.267 -                /*
  55.268 -                 * On type change we check to flush stale TLB entries. This 
  55.269 -                 * may be unnecessary (e.g., page was GDT/LDT) but those 
  55.270 -                 * circumstances should be very rare.
  55.271 -                 */
  55.272 -                cpumask_t mask =
  55.273 -                    page_get_owner(page)->domain_dirty_cpumask;
  55.274 -                tlbflush_filter(mask, page->tlbflush_timestamp);
  55.275 -
  55.276 -                if ( unlikely(!cpus_empty(mask)) )
  55.277 -                {
  55.278 -                    perfc_incr(need_flush_tlb_flush);
  55.279 -                    flush_tlb_mask(mask);
  55.280 -                }
  55.281 -
  55.282 -                /* We lose existing type, back pointer, and validity. */
  55.283 -                nx &= ~(PGT_type_mask | PGT_validated);
  55.284 -                nx |= type;
  55.285 -
  55.286 -                /* No special validation needed for writable pages. */
  55.287 -                /* Page tables and GDT/LDT need to be scanned for validity. */
  55.288 -                if ( type == PGT_writable_page )
  55.289 -                    nx |= PGT_validated;
  55.290 -            }
  55.291 -        }
  55.292 -        else if ( unlikely((x & PGT_type_mask) != type) )
  55.293 -        {
  55.294 -            return 0;
  55.295 -        }
  55.296 -        else if ( unlikely(!(x & PGT_validated)) )
  55.297 -        {
  55.298 -            /* Someone else is updating validation of this page. Wait... */
  55.299 -            while ( (y = page->u.inuse.type_info) == x )
  55.300 -                cpu_relax();
  55.301 -            goto again;
  55.302 -        }
  55.303 -    }
  55.304 -    while ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) != x) );
  55.305 -
  55.306 -    if ( unlikely(!(nx & PGT_validated)) )
  55.307 -    {
  55.308 -        /* Noone else is updating simultaneously. */
  55.309 -        __set_bit(_PGT_validated, &page->u.inuse.type_info);
  55.310 -    }
  55.311 -
  55.312 -    return 1;
  55.313 -}
  55.314 -
  55.315 -long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
  55.316 -{
  55.317 -    printk("%s: no PPC specific memory ops\n", __func__);
  55.318 -    return -ENOSYS;
  55.319 -}
  55.320 -
  55.321 -extern void copy_page(void *dp, void *sp)
  55.322 -{
  55.323 -    if (on_systemsim()) {
  55.324 -        systemsim_memcpy(dp, sp, PAGE_SIZE);
  55.325 -    } else {
  55.326 -        memcpy(dp, sp, PAGE_SIZE);
  55.327 -    }
  55.328 -}
  55.329 -
  55.330 -/* Allocate (rma_nrpages - nrpages) more memory for domain in proper size. */
  55.331 -uint allocate_extents(struct domain *d, uint nrpages, uint rma_nrpages)
  55.332 -{
  55.333 -    struct page_info *pg;
  55.334 -    ulong mfn;
  55.335 -    ulong gpfn = rma_nrpages; /* starting PFN at end of RMA */
  55.336 -    uint ext_order;
  55.337 -    uint ext_nrpages;
  55.338 -    uint total_nrpages;
  55.339 -    int i;
  55.340 -
  55.341 -    ext_order = cpu_extent_order();
  55.342 -    ext_nrpages = 1 << ext_order;
  55.343 -
  55.344 -    total_nrpages = rma_nrpages;
  55.345 -
  55.346 -    /* We only allocate in nr_extsz chunks so if you are not divisible
  55.347 -     * you get more than you asked for. */
  55.348 -    while (total_nrpages < nrpages) {
  55.349 -        pg = alloc_domheap_pages(d, ext_order, 0);
  55.350 -        if (pg == NULL)
  55.351 -            return total_nrpages;
  55.352 -
  55.353 -        /* Build p2m mapping for newly allocated extent. */
  55.354 -        mfn = page_to_mfn(pg);
  55.355 -        for (i = 0; i < (1 << ext_order); i++)
  55.356 -            guest_physmap_add_page(d, gpfn + i, mfn + i);
  55.357 -
  55.358 -        /* Bump starting PFN by extent size pages. */
  55.359 -        gpfn += ext_nrpages;
  55.360 -
  55.361 -        total_nrpages += ext_nrpages;
  55.362 -    }
  55.363 -
  55.364 -    return total_nrpages;
  55.365 -}
  55.366 -
  55.367 -int allocate_rma(struct domain *d, unsigned int order)
  55.368 -{
  55.369 -    struct vcpu *v;
  55.370 -    ulong rma_base;
  55.371 -    ulong rma_sz;
  55.372 -    ulong mfn;
  55.373 -    int i;
  55.374 -
  55.375 -    if (d->arch.rma_page)
  55.376 -        return -EINVAL;
  55.377 -
  55.378 -    d->arch.rma_page = alloc_domheap_pages(d, order, 0);
  55.379 -    if (d->arch.rma_page == NULL) {
  55.380 -        gdprintk(XENLOG_INFO, "Could not allocate order=%d RMA for domain %u\n",
  55.381 -                order, d->domain_id);
  55.382 -        return -ENOMEM;
  55.383 -    }
  55.384 -    d->arch.rma_order = order;
  55.385 -
  55.386 -    rma_base = page_to_maddr(d->arch.rma_page);
  55.387 -    rma_sz = rma_size(d->arch.rma_order);
  55.388 -
  55.389 -    BUG_ON(rma_base & (rma_sz - 1)); /* check alignment */
  55.390 -
  55.391 -    printk("allocated RMA for Dom[%d]: 0x%lx[0x%lx]\n",
  55.392 -           d->domain_id, rma_base, rma_sz);
  55.393 -
  55.394 -    mfn = page_to_mfn(d->arch.rma_page);
  55.395 -
  55.396 -    for (i = 0; i < (1 << d->arch.rma_order); i++ ) {
  55.397 -        d->arch.rma_page[i].count_info |= PGC_page_RMA;
  55.398 -        clear_page((void *)page_to_maddr(&d->arch.rma_page[i]));
  55.399 -
  55.400 -        /* Set up p2m mapping for RMA. */
  55.401 -        guest_physmap_add_page(d, i, mfn+i);
  55.402 -    }
  55.403 -
  55.404 -    /* shared_info uses last page of RMA */
  55.405 -    d->shared_info = (shared_info_t *) (rma_base + rma_sz - PAGE_SIZE);
  55.406 -
  55.407 -    /* if there are already running vcpus, adjust v->vcpu_info */
  55.408 -    /* XXX untested */
  55.409 -    for_each_vcpu(d, v) {
  55.410 -        v->vcpu_info = &d->shared_info->vcpu_info[v->vcpu_id];
  55.411 -    }
  55.412 -
  55.413 -    return 0;
  55.414 -}
  55.415 -
  55.416 -void free_rma_check(struct page_info *page)
  55.417 -{
  55.418 -    if (test_bit(_PGC_page_RMA, &page->count_info)) {
  55.419 -        if (!page_get_owner(page)->is_dying) {
  55.420 -            panic("Attempt to free an RMA page: 0x%lx\n", page_to_mfn(page));
  55.421 -        } else {
  55.422 -            clear_bit(_PGC_page_RMA, &page->count_info);
  55.423 -        }
  55.424 -    }
  55.425 -}
  55.426 -
  55.427 -ulong pfn2mfn(struct domain *d, ulong pfn, int *type)
  55.428 -{
  55.429 -    ulong mfn = INVALID_MFN;
  55.430 -    int t = PFN_TYPE_NONE;
  55.431 -    ulong foreign_map_pfn = 1UL << cpu_foreign_map_order();
  55.432 -
  55.433 -    /* quick tests first */
  55.434 -    if (pfn & foreign_map_pfn) {
  55.435 -        t = PFN_TYPE_FOREIGN;
  55.436 -        mfn = foreign_to_mfn(d, pfn);
  55.437 -    } else if (pfn >= max_page && pfn <
  55.438 -	       (max_page + nr_grant_frames(d->grant_table))) {
  55.439 -        /* XXX access d->grant_table->nr_grant_frames without lock.
  55.440 -         * Currently on powerpc dynamic expanding grant table is
  55.441 -         * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES
  55.442 -         * so that this access is safe.
  55.443 -         */
  55.444 -        /* Its a grant table access */
  55.445 -        t = PFN_TYPE_GNTTAB;
  55.446 -        mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page));
  55.447 -    } else if (d->is_privileged && platform_io_mfn(pfn)) {
  55.448 -        t = PFN_TYPE_IO;
  55.449 -        mfn = pfn;
  55.450 -    } else {
  55.451 -        if (pfn < d->arch.p2m_entries) {
  55.452 -            t = PFN_TYPE_LOGICAL;
  55.453 -            mfn = d->arch.p2m[pfn];
  55.454 -        }
  55.455 -#ifdef DEBUG
  55.456 -        if (t != PFN_TYPE_NONE && d->is_dying &&
  55.457 -            page_get_owner(mfn_to_page(mfn)) != d) {
  55.458 -            printk("%s: page type: %d owner Dom[%d]:%p expected Dom[%d]:%p\n",
  55.459 -                   __func__, t,
  55.460 -                   page_get_owner(mfn_to_page(mfn))->domain_id,
  55.461 -                   page_get_owner(mfn_to_page(mfn)),
  55.462 -                   d->domain_id, d);
  55.463 -            BUG();
  55.464 -        }
  55.465 -#endif
  55.466 -    }
  55.467 -
  55.468 -    if (t == PFN_TYPE_NONE) {
  55.469 -        /* This hack allows dom0 to map all memory, necessary to
  55.470 -         * initialize domU state. */
  55.471 -        if (d->is_privileged && mfn_valid(pfn)) {
  55.472 -            struct page_info *pg;
  55.473 -
  55.474 -            /* page better be allocated to some domain but not the caller */
  55.475 -            pg = mfn_to_page(pfn);
  55.476 -            if (!(pg->count_info & PGC_allocated))
  55.477 -                panic("Foreign page: 0x%lx is not owned by any domain\n",
  55.478 -                      mfn);
  55.479 -            if (page_get_owner(pg) == d)
  55.480 -                panic("Foreign page: 0x%lx is owned by this domain\n",
  55.481 -                      mfn);
  55.482 -                
  55.483 -            t = PFN_TYPE_FOREIGN;
  55.484 -            mfn = pfn;
  55.485 -        }
  55.486 -    }
  55.487 -
  55.488 -    if (mfn == INVALID_MFN) {
  55.489 -        printk("%s: Dom[%d] pfn 0x%lx is not a valid page\n",
  55.490 -               __func__, d->domain_id, pfn);
  55.491 -    }
  55.492 -
  55.493 -    if (type)
  55.494 -        *type = t;
  55.495 -
  55.496 -    return mfn;
  55.497 -}
  55.498 -
  55.499 -unsigned long mfn_to_gmfn(struct domain *d, unsigned long mfn)
  55.500 -{
  55.501 -    struct page_info *pg = mfn_to_page(mfn);
  55.502 -    ulong gnttab_mfn;
  55.503 -
  55.504 -    /* is this our mfn? */
  55.505 -    if (page_get_owner(pg) != d)
  55.506 -        return INVALID_M2P_ENTRY;
  55.507 -
  55.508 -    /* XXX access d->grant_table->nr_grant_frames without lock.
  55.509 -     * Currently on powerpc dynamic expanding grant table is
  55.510 -     * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES
  55.511 -     * so that this access is safe.
  55.512 -     */
  55.513 -    /* grant? */
  55.514 -    gnttab_mfn = gnttab_shared_mfn(d, d->grant_table, 0);
  55.515 -    if (mfn >= gnttab_mfn && mfn <
  55.516 -	(gnttab_mfn + nr_grant_frames(d->grant_table)))
  55.517 -        return max_page + (mfn - gnttab_mfn);
  55.518 -
  55.519 -    /* IO? */
  55.520 -    if (d->is_privileged && platform_io_mfn(mfn))
  55.521 -        return mfn;
  55.522 -
  55.523 -    /* check m2p table */
  55.524 -    return get_gpfn_from_mfn(mfn);
  55.525 -}
  55.526 -
  55.527 -/* NB: caller holds d->page_alloc lock, sets d->max_pages = new_max */
  55.528 -int guest_physmap_max_mem_pages(struct domain *d, unsigned long new_max_pages)
  55.529 -{
  55.530 -    u32 *p2m_array = NULL;
  55.531 -    u32 *p2m_old = NULL;
  55.532 -    ulong i;
  55.533 -
  55.534 -    /* XXX We probably could, but right now we don't shrink the p2m array.
  55.535 -     * NB: d->max_pages >= d->arch.p2m_entries */
  55.536 -    if (new_max_pages < d->max_pages) {
  55.537 -        printk("Can't shrink DOM%d max memory pages\n", d->domain_id);
  55.538 -        return -EINVAL;
  55.539 -    }
  55.540 -
  55.541 -    /* Allocate one u32 per page. */
  55.542 -    p2m_array = xmalloc_array(u32, new_max_pages);
  55.543 -    if (p2m_array == NULL)
  55.544 -        return -ENOMEM;
  55.545 -
  55.546 -    /* Copy old mappings into new array. */
  55.547 -    if (d->arch.p2m != NULL) {
  55.548 -        /* XXX This could take a long time; we should use a continuation. */
  55.549 -        memcpy(p2m_array, d->arch.p2m, d->arch.p2m_entries * sizeof(u32));
  55.550 -        p2m_old = d->arch.p2m;
  55.551 -    }
  55.552 -
  55.553 -    /* Mark new mfns as invalid. */
  55.554 -    for (i = d->arch.p2m_entries; i < new_max_pages; i++)
  55.555 -        p2m_array[i] = INVALID_MFN;
  55.556 -
  55.557 -    /* Set new p2m pointer and size. */
  55.558 -    d->arch.p2m = p2m_array;
  55.559 -    d->arch.p2m_entries = new_max_pages;
  55.560 -
  55.561 -    /* Free old p2m array if present. */
  55.562 -    if (p2m_old)
  55.563 -        xfree(p2m_old);
  55.564 -
  55.565 -    return 0;
  55.566 -}
  55.567 -
  55.568 -void guest_physmap_add_page(
  55.569 -    struct domain *d, unsigned long gpfn, unsigned long mfn)
  55.570 -{
  55.571 -    if (page_get_owner(mfn_to_page(mfn)) != d) {
  55.572 -        printk("Won't map foreign MFN 0x%lx for DOM%d\n", mfn, d->domain_id);
  55.573 -        return;
  55.574 -    }
  55.575 -
  55.576 -    /* Check that pfn is within guest table. */
  55.577 -    if (gpfn >= d->arch.p2m_entries) {
  55.578 -        printk("Won't map invalid PFN 0x%lx for DOM%d\n", gpfn, d->domain_id);
  55.579 -        return;
  55.580 -    }
  55.581 -
  55.582 -    /* Warn if there is an existing mapping. */
  55.583 -    /* XXX: probably shouldn't let this happen, but
  55.584 -       current interface doesn't throw errors.  =( */
  55.585 -    if (d->arch.p2m[gpfn] != INVALID_MFN)
  55.586 -        printk("Ack! PFN aliased. PFN%lx, old MFN=%x, new MFN=%lx\n",
  55.587 -                gpfn, d->arch.p2m[gpfn], mfn);
  55.588 -
  55.589 -    /* PFN and MFN ok, map in p2m table. */
  55.590 -    d->arch.p2m[gpfn] = mfn;
  55.591 -
  55.592 -    /* Map in m2p table. */
  55.593 -    set_gpfn_from_mfn(mfn, gpfn);
  55.594 -}
  55.595 -
  55.596 -void guest_physmap_remove_page(
  55.597 -    struct domain *d, unsigned long gpfn, unsigned long mfn)
  55.598 -{
  55.599 -    if (page_get_owner(mfn_to_page(mfn)) != d) {
  55.600 -        printk("Won't unmap foreign MFN 0x%lx for DOM%d\n", mfn, d->domain_id);
  55.601 -        return;
  55.602 -    }
  55.603 -
  55.604 -    /* check that pfn is within guest table */
  55.605 -    if (gpfn >= d->arch.p2m_entries) {
  55.606 -        printk("Won't unmap invalid PFN 0x%lx for DOM%d\n", gpfn, d->domain_id);
  55.607 -        return;
  55.608 -    }
  55.609 -
  55.610 -    /* PFN and MFN ok, unmap from p2m table. */
  55.611 -    d->arch.p2m[gpfn] = INVALID_MFN;
  55.612 -
  55.613 -    /* Unmap from m2p table. */
  55.614 -    set_gpfn_from_mfn(mfn, INVALID_M2P_ENTRY);
  55.615 -}
  55.616 -
  55.617 -void shadow_drop_references(
  55.618 -    struct domain *d, struct page_info *page)
  55.619 -{
  55.620 -}
    56.1 --- a/xen/arch/powerpc/mpic.c	Thu May 08 13:15:45 2008 +0100
    56.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.3 @@ -1,1100 +0,0 @@
    56.4 -/*
    56.5 - *  arch/powerpc/kernel/mpic.c
    56.6 - *
    56.7 - *  Driver for interrupt controllers following the OpenPIC standard, the
    56.8 - *  common implementation beeing IBM's MPIC. This driver also can deal
    56.9 - *  with various broken implementations of this HW.
   56.10 - *
   56.11 - *  Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
   56.12 - *
   56.13 - *  This file is subject to the terms and conditions of the GNU General Public
   56.14 - *  License.  See the file COPYING in the main directory of this archive
   56.15 - *  for more details.
   56.16 - */
   56.17 -
   56.18 -/* XXX Xen hacks ... */
   56.19 -/* make this generic */
   56.20 -
   56.21 -#define le32_to_cpu(x)                                          \
   56.22 -    ({                                                          \
   56.23 -        __u32 __x = (x);                                        \
   56.24 -        ((__u32)(                                               \
   56.25 -             (((__u32)(__x) & (__u32)0x000000ffUL) << 24) |     \
   56.26 -             (((__u32)(__x) & (__u32)0x0000ff00UL) <<  8) |     \
   56.27 -             (((__u32)(__x) & (__u32)0x00ff0000UL) >>  8) |     \
   56.28 -             (((__u32)(__x) & (__u32)0xff000000UL) >> 24) ));   \
   56.29 -    })
   56.30 -
   56.31 -
   56.32 -#define alloc_bootmem(x) xmalloc_bytes(x)
   56.33 -
   56.34 -#define IRQ_NONE	(0)
   56.35 -#define IRQ_HANDLED	(1)
   56.36 -#define IRQ_RETVAL(x)	((x) != 0)
   56.37 -
   56.38 -#define IRQ_SENSE_MASK		0x1
   56.39 -#define IRQ_SENSE_LEVEL		0x1	/* interrupt on active level */
   56.40 -#define IRQ_SENSE_EDGE		0x0	/* interrupt triggered by edge */
   56.41 -
   56.42 -#define IRQ_POLARITY_MASK	0x2
   56.43 -#define IRQ_POLARITY_POSITIVE	0x2	/* high level or low->high edge */
   56.44 -#define IRQ_POLARITY_NEGATIVE	0x0	/* low level or high->low edge */
   56.45 -
   56.46 -#define CONFIG_IRQ_ALL_CPUS 0
   56.47 -#define distribute_irqs	CONFIG_IRQ_ALL_CPUS
   56.48 -#define CONFIG_MPIC_BROKEN_U3
   56.49 -
   56.50 -#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
   56.51 -#define PCI_FUNC(devfn) ((devfn) & 0x07)
   56.52 -#define PCI_HEADER_TYPE		0x0e	/* 8 bits */
   56.53 -#define PCI_VENDOR_ID		0x00	/* 16 bits */
   56.54 -#define PCI_VENDOR_ID_AMD 0x1022
   56.55 -#define PCI_CAPABILITY_LIST	0x34	/* Offset of first capability list entry */
   56.56 -#define PCI_CAP_LIST_NEXT	1	/* Next capability in the list */
   56.57 -#define PCI_CAP_LIST_ID		0	/* Capability ID */
   56.58 -#define  PCI_CAP_ID_HT_IRQCONF	0x08	/* HyperTransport IRQ Configuration */
   56.59 -#define PCI_STATUS		0x06	/* 16 bits */
   56.60 -#define  PCI_STATUS_CAP_LIST	0x10	/* Support Capability List */
   56.61 -#define MSG_ALL 0x8001
   56.62 -#define MSG_ALL_BUT_SELF 0x8000
   56.63 -
   56.64 -/* keeps file even closer to the original */
   56.65 -#define pt_regs cpu_user_regs
   56.66 -/* XXX ... Xen hacks */
   56.67 -
   56.68 -#undef DEBUG
   56.69 -#undef DEBUG_IPI
   56.70 -#undef DEBUG_IRQ
   56.71 -#undef DEBUG_LOW
   56.72 -
   56.73 -#include <xen/config.h>
   56.74 -#include <xen/types.h>
   56.75 -#include <xen/kernel.h>
   56.76 -#include <xen/init.h>
   56.77 -#include <xen/irq.h>
   56.78 -#include <xen/smp.h>
   56.79 -#ifndef __XEN__ 
   56.80 -#include <linux/interrupt.h>
   56.81 -#include <linux/bootmem.h>
   56.82 -#endif
   56.83 -#include <xen/spinlock.h>
   56.84 -#ifndef __XEN__
   56.85 -#include <asm/pci.h>
   56.86 -
   56.87 -#include <asm/ptrace.h>
   56.88 -#include <asm/signal.h>
   56.89 -#endif
   56.90 -#include <asm/io.h>
   56.91 -#ifndef __XEN__
   56.92 -#include <asm/pgtable.h>
   56.93 -#include <asm/irq.h>
   56.94 -#include <asm/machdep.h>
   56.95 -#endif
   56.96 -#include <asm/mpic.h>
   56.97 -#include <asm/smp.h>
   56.98 -
   56.99 -#ifdef DEBUG
  56.100 -#define DBG(fmt...) printk(fmt)
  56.101 -#else
  56.102 -#define DBG(fmt...)
  56.103 -#endif
  56.104 -
  56.105 -static struct mpic *mpics;
  56.106 -static struct mpic *mpic_primary;
  56.107 -static DEFINE_SPINLOCK(mpic_lock);
  56.108 -
  56.109 -#ifdef CONFIG_PPC32	/* XXX for now */
  56.110 -#ifdef CONFIG_IRQ_ALL_CPUS
  56.111 -#define distribute_irqs	(1)
  56.112 -#else
  56.113 -#define distribute_irqs	(0)
  56.114 -#endif
  56.115 -#endif
  56.116 -
  56.117 -/*
  56.118 - * Register accessor functions
  56.119 - */
  56.120 -
  56.121 -
  56.122 -static inline u32 _mpic_read(unsigned int be, volatile u32 __iomem *base,
  56.123 -                             unsigned int reg)
  56.124 -{
  56.125 -	if (be)
  56.126 -		return in_be32(base + (reg >> 2));
  56.127 -	else
  56.128 -		return in_le32(base + (reg >> 2));
  56.129 -}
  56.130 -
  56.131 -static inline void _mpic_write(unsigned int be, volatile u32 __iomem *base,
  56.132 -                               unsigned int reg, u32 value)
  56.133 -{
  56.134 -	if (be)
  56.135 -		out_be32(base + (reg >> 2), value);
  56.136 -	else
  56.137 -		out_le32(base + (reg >> 2), value);
  56.138 -}
  56.139 -
  56.140 -static inline u32 _mpic_ipi_read(struct mpic *mpic, unsigned int ipi)
  56.141 -{
  56.142 -	unsigned int be = (mpic->flags & MPIC_BIG_ENDIAN) != 0;
  56.143 -	unsigned int offset = MPIC_GREG_IPI_VECTOR_PRI_0 + (ipi * 0x10);
  56.144 -
  56.145 -	if (mpic->flags & MPIC_BROKEN_IPI)
  56.146 -		be = !be;
  56.147 -	return _mpic_read(be, mpic->gregs, offset);
  56.148 -}
  56.149 -
  56.150 -static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 value)
  56.151 -{
  56.152 -	unsigned int offset = MPIC_GREG_IPI_VECTOR_PRI_0 + (ipi * 0x10);
  56.153 -
  56.154 -	_mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->gregs, offset, value);
  56.155 -}
  56.156 -
  56.157 -static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg)
  56.158 -{
  56.159 -	unsigned int cpu = 0;
  56.160 -
  56.161 -	if (mpic->flags & MPIC_PRIMARY)
  56.162 -		cpu = hard_smp_processor_id();
  56.163 -
  56.164 -	return _mpic_read(mpic->flags & MPIC_BIG_ENDIAN, mpic->cpuregs[cpu], reg);
  56.165 -}
  56.166 -
  56.167 -static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value)
  56.168 -{
  56.169 -	unsigned int cpu = 0;
  56.170 -
  56.171 -	if (mpic->flags & MPIC_PRIMARY)
  56.172 -		cpu = hard_smp_processor_id();
  56.173 -
  56.174 -	_mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->cpuregs[cpu], reg, value);
  56.175 -}
  56.176 -
  56.177 -static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigned int reg)
  56.178 -{
  56.179 -	unsigned int	isu = src_no >> mpic->isu_shift;
  56.180 -	unsigned int	idx = src_no & mpic->isu_mask;
  56.181 -
  56.182 -	return _mpic_read(mpic->flags & MPIC_BIG_ENDIAN, mpic->isus[isu],
  56.183 -                      reg + (idx * MPIC_IRQ_STRIDE));
  56.184 -}
  56.185 -
  56.186 -static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no,
  56.187 -                                   unsigned int reg, u32 value)
  56.188 -{
  56.189 -	unsigned int	isu = src_no >> mpic->isu_shift;
  56.190 -	unsigned int	idx = src_no & mpic->isu_mask;
  56.191 -
  56.192 -	_mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->isus[isu],
  56.193 -                reg + (idx * MPIC_IRQ_STRIDE), value);
  56.194 -}
  56.195 -
  56.196 -#define mpic_read(b,r)		_mpic_read(mpic->flags & MPIC_BIG_ENDIAN,(b),(r))
  56.197 -#define mpic_write(b,r,v)	_mpic_write(mpic->flags & MPIC_BIG_ENDIAN,(b),(r),(v))
  56.198 -#define mpic_ipi_read(i)	_mpic_ipi_read(mpic,(i))
  56.199 -#define mpic_ipi_write(i,v)	_mpic_ipi_write(mpic,(i),(v))
  56.200 -#define mpic_cpu_read(i)	_mpic_cpu_read(mpic,(i))
  56.201 -#define mpic_cpu_write(i,v)	_mpic_cpu_write(mpic,(i),(v))
  56.202 -#define mpic_irq_read(s,r)	_mpic_irq_read(mpic,(s),(r))
  56.203 -#define mpic_irq_write(s,r,v)	_mpic_irq_write(mpic,(s),(r),(v))
  56.204 -
  56.205 -
  56.206 -/*
  56.207 - * Low level utility functions
  56.208 - */
  56.209 -
  56.210 -
  56.211 -
  56.212 -/* Check if we have one of those nice broken MPICs with a flipped endian on
  56.213 - * reads from IPI registers
  56.214 - */
  56.215 -static void __init mpic_test_broken_ipi(struct mpic *mpic)
  56.216 -{
  56.217 -	u32 r;
  56.218 -
  56.219 -	mpic_write(mpic->gregs, MPIC_GREG_IPI_VECTOR_PRI_0, MPIC_VECPRI_MASK);
  56.220 -	r = mpic_read(mpic->gregs, MPIC_GREG_IPI_VECTOR_PRI_0);
  56.221 -
  56.222 -	if (r == le32_to_cpu(MPIC_VECPRI_MASK)) {
  56.223 -		printk(KERN_INFO "mpic: Detected reversed IPI registers\n");
  56.224 -		mpic->flags |= MPIC_BROKEN_IPI;
  56.225 -	}
  56.226 -}
  56.227 -
  56.228 -#ifdef CONFIG_MPIC_BROKEN_U3
  56.229 -
  56.230 -/* Test if an interrupt is sourced from HyperTransport (used on broken U3s)
  56.231 - * to force the edge setting on the MPIC and do the ack workaround.
  56.232 - */
  56.233 -static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source)
  56.234 -{
  56.235 -	if (source >= 128 || !mpic->fixups)
  56.236 -		return 0;
  56.237 -	return mpic->fixups[source].base != NULL;
  56.238 -}
  56.239 -
  56.240 -
  56.241 -static inline void mpic_ht_end_irq(struct mpic *mpic, unsigned int source)
  56.242 -{
  56.243 -	struct mpic_irq_fixup *fixup = &mpic->fixups[source];
  56.244 -
  56.245 -	if (fixup->applebase) {
  56.246 -		unsigned int soff = (fixup->index >> 3) & ~3;
  56.247 -		unsigned int mask = 1U << (fixup->index & 0x1f);
  56.248 -		writel(mask, fixup->applebase + soff);
  56.249 -	} else {
  56.250 -		spin_lock(&mpic->fixup_lock);
  56.251 -		writeb(0x11 + 2 * fixup->index, fixup->base + 2);
  56.252 -		writel(fixup->data, fixup->base + 4);
  56.253 -		spin_unlock(&mpic->fixup_lock);
  56.254 -	}
  56.255 -}
  56.256 -
  56.257 -static void mpic_startup_ht_interrupt(struct mpic *mpic, unsigned int source,
  56.258 -                                      unsigned int irqflags)
  56.259 -{
  56.260 -	struct mpic_irq_fixup *fixup = &mpic->fixups[source];
  56.261 -	unsigned long flags;
  56.262 -	u32 tmp;
  56.263 -
  56.264 -	if (fixup->base == NULL)
  56.265 -		return;
  56.266 -
  56.267 -	DBG("startup_ht_interrupt(%u, %u) index: %d\n",
  56.268 -	    source, irqflags, fixup->index);
  56.269 -	spin_lock_irqsave(&mpic->fixup_lock, flags);
  56.270 -	/* Enable and configure */
  56.271 -	writeb(0x10 + 2 * fixup->index, fixup->base + 2);
  56.272 -	tmp = readl(fixup->base + 4);
  56.273 -	tmp &= ~(0x23U);
  56.274 -	if (irqflags & IRQ_LEVEL)
  56.275 -		tmp |= 0x22;
  56.276 -	writel(tmp, fixup->base + 4);
  56.277 -	spin_unlock_irqrestore(&mpic->fixup_lock, flags);
  56.278 -}
  56.279 -
  56.280 -static void mpic_shutdown_ht_interrupt(struct mpic *mpic, unsigned int source,
  56.281 -                                       unsigned int irqflags)
  56.282 -{
  56.283 -	struct mpic_irq_fixup *fixup = &mpic->fixups[source];
  56.284 -	unsigned long flags;
  56.285 -	u32 tmp;
  56.286 -
  56.287 -	if (fixup->base == NULL)
  56.288 -		return;
  56.289 -
  56.290 -	DBG("shutdown_ht_interrupt(%u, %u)\n", source, irqflags);
  56.291 -
  56.292 -	/* Disable */
  56.293 -	spin_lock_irqsave(&mpic->fixup_lock, flags);
  56.294 -	writeb(0x10 + 2 * fixup->index, fixup->base + 2);
  56.295 -	tmp = readl(fixup->base + 4);
  56.296 -	tmp |= 1;
  56.297 -	writel(tmp, fixup->base + 4);
  56.298 -	spin_unlock_irqrestore(&mpic->fixup_lock, flags);
  56.299 -}
  56.300 -
  56.301 -static void __init mpic_scan_ht_pic(struct mpic *mpic, u8 __iomem *devbase,
  56.302 -                                    unsigned int devfn, u32 vdid)
  56.303 -{
  56.304 -	int i, irq, n;
  56.305 -	u8 __iomem *base;
  56.306 -	u32 tmp;
  56.307 -	u8 pos;
  56.308 -
  56.309 -	for (pos = readb(devbase + PCI_CAPABILITY_LIST); pos != 0;
  56.310 -	     pos = readb(devbase + pos + PCI_CAP_LIST_NEXT)) {
  56.311 -		u8 id = readb(devbase + pos + PCI_CAP_LIST_ID);
  56.312 -		if (id == PCI_CAP_ID_HT_IRQCONF) {
  56.313 -			id = readb(devbase + pos + 3);
  56.314 -			if (id == 0x80)
  56.315 -				break;
  56.316 -		}
  56.317 -	}
  56.318 -	if (pos == 0)
  56.319 -		return;
  56.320 -
  56.321 -	base = devbase + pos;
  56.322 -	writeb(0x01, base + 2);
  56.323 -	n = (readl(base + 4) >> 16) & 0xff;
  56.324 -
  56.325 -	printk(KERN_INFO "mpic:   - HT:%02x.%x [0x%02x] vendor %04x device %04x"
  56.326 -	       " has %d irqs\n",
  56.327 -	       devfn >> 3, devfn & 0x7, pos, vdid & 0xffff, vdid >> 16, n + 1);
  56.328 -
  56.329 -	for (i = 0; i <= n; i++) {
  56.330 -		writeb(0x10 + 2 * i, base + 2);
  56.331 -		tmp = readl(base + 4);
  56.332 -		irq = (tmp >> 16) & 0xff;
  56.333 -		DBG("HT PIC index 0x%x, irq 0x%x, tmp: %08x\n", i, irq, tmp);
  56.334 -		/* mask it , will be unmasked later */
  56.335 -		tmp |= 0x1;
  56.336 -		writel(tmp, base + 4);
  56.337 -		mpic->fixups[irq].index = i;
  56.338 -		mpic->fixups[irq].base = base;
  56.339 -		/* Apple HT PIC has a non-standard way of doing EOIs */
  56.340 -		if ((vdid & 0xffff) == 0x106b)
  56.341 -			mpic->fixups[irq].applebase = devbase + 0x60;
  56.342 -		else
  56.343 -			mpic->fixups[irq].applebase = NULL;
  56.344 -		writeb(0x11 + 2 * i, base + 2);
  56.345 -		mpic->fixups[irq].data = readl(base + 4) | 0x80000000;
  56.346 -	}
  56.347 -}
  56.348 - 
  56.349 -
  56.350 -static void __init mpic_scan_ht_pics(struct mpic *mpic)
  56.351 -{
  56.352 -	unsigned int devfn;
  56.353 -	u8 __iomem *cfgspace;
  56.354 -
  56.355 -	printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n");
  56.356 -
  56.357 -	/* Allocate fixups array */
  56.358 -	mpic->fixups = alloc_bootmem(128 * sizeof(struct mpic_irq_fixup));
  56.359 -	BUG_ON(mpic->fixups == NULL);
  56.360 -	memset(mpic->fixups, 0, 128 * sizeof(struct mpic_irq_fixup));
  56.361 -
  56.362 -	/* Init spinlock */
  56.363 -	spin_lock_init(&mpic->fixup_lock);
  56.364 -
  56.365 -	/* Map U3 config space. We assume all IO-APICs are on the primary bus
  56.366 -	 * so we only need to map 64kB.
  56.367 -	 */
  56.368 -	cfgspace = ioremap(0xf2000000, 0x10000);
  56.369 -	BUG_ON(cfgspace == NULL);
  56.370 -
  56.371 -	/* Now we scan all slots. We do a very quick scan, we read the header
  56.372 -	 * type, vendor ID and device ID only, that's plenty enough
  56.373 -	 */
  56.374 -	for (devfn = 0; devfn < 0x100; devfn++) {
  56.375 -		u8 __iomem *devbase = cfgspace + (devfn << 8);
  56.376 -		u8 hdr_type = readb(devbase + PCI_HEADER_TYPE);
  56.377 -		u32 l = readl(devbase + PCI_VENDOR_ID);
  56.378 -		u16 s;
  56.379 -
  56.380 -		DBG("devfn %x, l: %x\n", devfn, l);
  56.381 -
  56.382 -		/* If no device, skip */
  56.383 -		if (l == 0xffffffff || l == 0x00000000 ||
  56.384 -		    l == 0x0000ffff || l == 0xffff0000)
  56.385 -			goto next;
  56.386 -		/* Check if is supports capability lists */
  56.387 -		s = readw(devbase + PCI_STATUS);
  56.388 -		if (!(s & PCI_STATUS_CAP_LIST))
  56.389 -			goto next;
  56.390 -
  56.391 -		mpic_scan_ht_pic(mpic, devbase, devfn, l);
  56.392 -
  56.393 -	next:
  56.394 -		/* next device, if function 0 */
  56.395 -		if (PCI_FUNC(devfn) == 0 && (hdr_type & 0x80) == 0)
  56.396 -			devfn += 7;
  56.397 -	}
  56.398 -}
  56.399 -
  56.400 -#endif /* CONFIG_MPIC_BROKEN_U3 */
  56.401 -
  56.402 -
  56.403 -/* Find an mpic associated with a given linux interrupt */
  56.404 -static struct mpic *mpic_find(unsigned int irq, unsigned int *is_ipi)
  56.405 -{
  56.406 -	struct mpic *mpic = mpics;
  56.407 -
  56.408 -	while(mpic) {
  56.409 -		/* search IPIs first since they may override the main interrupts */
  56.410 -		if (irq >= mpic->ipi_offset && irq < (mpic->ipi_offset + 4)) {
  56.411 -			if (is_ipi)
  56.412 -				*is_ipi = 1;
  56.413 -			return mpic;
  56.414 -		}
  56.415 -		if (irq >= mpic->irq_offset &&
  56.416 -		    irq < (mpic->irq_offset + mpic->irq_count)) {
  56.417 -			if (is_ipi)
  56.418 -				*is_ipi = 0;
  56.419 -			return mpic;
  56.420 -		}
  56.421 -		mpic = mpic -> next;
  56.422 -	}
  56.423 -	return NULL;
  56.424 -}
  56.425 -
  56.426 -/* Convert a cpu mask from logical to physical cpu numbers. */
  56.427 -static inline u32 mpic_physmask(u32 cpumask)
  56.428 -{
  56.429 -	int i;
  56.430 -	u32 mask = 0;
  56.431 -
  56.432 -	for (i = 0; i < NR_CPUS; ++i, cpumask >>= 1)
  56.433 -		mask |= (cpumask & 1) << get_hard_smp_processor_id(i);
  56.434 -	return mask;
  56.435 -}
  56.436 -
  56.437 -#ifdef CONFIG_SMP
  56.438 -/* Get the mpic structure from the IPI number */
  56.439 -static inline struct mpic * mpic_from_ipi(unsigned int ipi)
  56.440 -{
  56.441 -	return container_of(irq_desc[ipi].handler, struct mpic, hc_ipi);
  56.442 -}
  56.443 -#endif
  56.444 -
  56.445 -/* Get the mpic structure from the irq number */
  56.446 -static inline struct mpic * mpic_from_irq(unsigned int irq)
  56.447 -{
  56.448 -	return container_of(irq_desc[irq].handler, struct mpic, hc_irq);
  56.449 -}
  56.450 -
  56.451 -/* Send an EOI */
  56.452 -static inline void mpic_eoi(struct mpic *mpic)
  56.453 -{
  56.454 -	mpic_cpu_write(MPIC_CPU_EOI, 0);
  56.455 -	(void)mpic_cpu_read(MPIC_CPU_WHOAMI);
  56.456 -}
  56.457 -
  56.458 -#ifdef CONFIG_SMP
  56.459 -static irqreturn_t mpic_ipi_action(int irq, void *dev_id, struct pt_regs *regs)
  56.460 -{
  56.461 -	struct mpic *mpic = dev_id;
  56.462 -
  56.463 -	smp_message_recv(irq - mpic->ipi_offset, regs);
  56.464 -	return IRQ_HANDLED;
  56.465 -}
  56.466 -#endif /* CONFIG_SMP */
  56.467 -
  56.468 -/*
  56.469 - * Linux descriptor level callbacks
  56.470 - */
  56.471 -
  56.472 -
  56.473 -static void mpic_enable_irq(unsigned int irq)
  56.474 -{
  56.475 -	unsigned int loops = 100000;
  56.476 -	struct mpic *mpic = mpic_from_irq(irq);
  56.477 -	unsigned int src = irq - mpic->irq_offset;
  56.478 -
  56.479 -	DBG("%p: %s: enable_irq: %d (src %d)\n", mpic, mpic->name, irq, src);
  56.480 -
  56.481 -	mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
  56.482 -                   mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) &
  56.483 -                   ~MPIC_VECPRI_MASK);
  56.484 -
  56.485 -	/* make sure mask gets to controller before we return to user */
  56.486 -	do {
  56.487 -		if (!loops--) {
  56.488 -			printk(KERN_ERR "mpic_enable_irq timeout\n");
  56.489 -			break;
  56.490 -		}
  56.491 -	} while(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK);	
  56.492 -
  56.493 -#ifdef CONFIG_MPIC_BROKEN_U3
  56.494 -	if (mpic->flags & MPIC_BROKEN_U3) {
  56.495 -		unsigned int bsrc = irq - mpic->irq_offset;
  56.496 -		if (mpic_is_ht_interrupt(mpic, bsrc) &&
  56.497 -		    (irq_desc[irq].status & IRQ_LEVEL))
  56.498 -			mpic_ht_end_irq(mpic, bsrc);
  56.499 -	}
  56.500 -#endif /* CONFIG_MPIC_BROKEN_U3 */
  56.501 -}
  56.502 -
  56.503 -static unsigned int mpic_startup_irq(unsigned int irq)
  56.504 -{
  56.505 -#ifdef CONFIG_MPIC_BROKEN_U3
  56.506 -	struct mpic *mpic = mpic_from_irq(irq);
  56.507 -	unsigned int src = irq - mpic->irq_offset;
  56.508 -#endif /* CONFIG_MPIC_BROKEN_U3 */
  56.509 -
  56.510 -	mpic_enable_irq(irq);
  56.511 -
  56.512 -#ifdef CONFIG_MPIC_BROKEN_U3
  56.513 -	if (mpic_is_ht_interrupt(mpic, src))
  56.514 -		mpic_startup_ht_interrupt(mpic, src, irq_desc[irq].status);
  56.515 -#endif /* CONFIG_MPIC_BROKEN_U3 */
  56.516 -
  56.517 -	return 0;
  56.518 -}
  56.519 -
  56.520 -static void mpic_disable_irq(unsigned int irq)
  56.521 -{
  56.522 -	unsigned int loops = 100000;
  56.523 -	struct mpic *mpic = mpic_from_irq(irq);
  56.524 -	unsigned int src = irq - mpic->irq_offset;
  56.525 -
  56.526 -	DBG("%s: disable_irq: %d (src %d)\n", mpic->name, irq, src);
  56.527 -
  56.528 -	mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
  56.529 -                   mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) |
  56.530 -                   MPIC_VECPRI_MASK);
  56.531 -
  56.532 -	/* make sure mask gets to controller before we return to user */
  56.533 -	do {
  56.534 -		if (!loops--) {
  56.535 -			printk(KERN_ERR "mpic_enable_irq timeout\n");
  56.536 -			break;
  56.537 -		}
  56.538 -	} while(!(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK));
  56.539 -}
  56.540 -
  56.541 -static void mpic_shutdown_irq(unsigned int irq)
  56.542 -{
  56.543 -#ifdef CONFIG_MPIC_BROKEN_U3
  56.544 -	struct mpic *mpic = mpic_from_irq(irq);
  56.545 -	unsigned int src = irq - mpic->irq_offset;
  56.546 -
  56.547 -	if (mpic_is_ht_interrupt(mpic, src))
  56.548 -		mpic_shutdown_ht_interrupt(mpic, src, irq_desc[irq].status);
  56.549 -
  56.550 -#endif /* CONFIG_MPIC_BROKEN_U3 */
  56.551 -
  56.552 -	mpic_disable_irq(irq);
  56.553 -}
  56.554 -
  56.555 -static void mpic_end_irq(unsigned int irq)
  56.556 -{
  56.557 -	struct mpic *mpic = mpic_from_irq(irq);
  56.558 -
  56.559 -#ifdef DEBUG_IRQ
  56.560 -	DBG("%s: end_irq: %d\n", mpic->name, irq);
  56.561 -#endif
  56.562 -	/* We always EOI on end_irq() even for edge interrupts since that
  56.563 -	 * should only lower the priority, the MPIC should have properly
  56.564 -	 * latched another edge interrupt coming in anyway
  56.565 -	 */
  56.566 -
  56.567 -#ifdef CONFIG_MPIC_BROKEN_U3
  56.568 -	if (mpic->flags & MPIC_BROKEN_U3) {
  56.569 -		unsigned int src = irq - mpic->irq_offset;
  56.570 -		if (mpic_is_ht_interrupt(mpic, src) &&
  56.571 -		    (irq_desc[irq].status & IRQ_LEVEL))
  56.572 -			mpic_ht_end_irq(mpic, src);
  56.573 -	}
  56.574 -#endif /* CONFIG_MPIC_BROKEN_U3 */
  56.575 -
  56.576 -	mpic_eoi(mpic);
  56.577 -}
  56.578 -
  56.579 -#ifdef CONFIG_SMP
  56.580 -
  56.581 -static void mpic_enable_ipi(unsigned int irq)
  56.582 -{
  56.583 -	struct mpic *mpic = mpic_from_ipi(irq);
  56.584 -	unsigned int src = irq - mpic->ipi_offset;
  56.585 -
  56.586 -	DBG("%s: enable_ipi: %d (ipi %d)\n", mpic->name, irq, src);
  56.587 -	mpic_ipi_write(src, mpic_ipi_read(src) & ~MPIC_VECPRI_MASK);
  56.588 -}
  56.589 -
  56.590 -static void mpic_disable_ipi(unsigned int irq)
  56.591 -{
  56.592 -	/* NEVER disable an IPI... that's just plain wrong! */
  56.593 -}
  56.594 -
  56.595 -static void mpic_end_ipi(unsigned int irq)
  56.596 -{
  56.597 -	struct mpic *mpic = mpic_from_ipi(irq);
  56.598 -
  56.599 -	/*
  56.600 -	 * IPIs are marked IRQ_PER_CPU. This has the side effect of
  56.601 -	 * preventing the IRQ_PENDING/IRQ_INPROGRESS logic from
  56.602 -	 * applying to them. We EOI them late to avoid re-entering.
  56.603 -	 * We mark IPI's with SA_INTERRUPT as they must run with
  56.604 -	 * irqs disabled.
  56.605 -	 */
  56.606 -	mpic_eoi(mpic);
  56.607 -}
  56.608 -
  56.609 -#endif /* CONFIG_SMP */
  56.610 -
  56.611 -static void mpic_set_affinity(unsigned int irq, cpumask_t cpumask)
  56.612 -{
  56.613 -	struct mpic *mpic = mpic_from_irq(irq);
  56.614 -
  56.615 -	cpumask_t tmp;
  56.616 -
  56.617 -	cpus_and(tmp, cpumask, cpu_online_map);
  56.618 -
  56.619 -	mpic_irq_write(irq - mpic->irq_offset, MPIC_IRQ_DESTINATION,
  56.620 -                   mpic_physmask(cpus_addr(tmp)[0]));	
  56.621 -}
  56.622 -
  56.623 -
  56.624 -/*
  56.625 - * Exported functions
  56.626 - */
  56.627 -
  56.628 -
  56.629 -struct mpic * __init mpic_alloc(unsigned long phys_addr,
  56.630 -                                unsigned int flags,
  56.631 -                                unsigned int isu_size,
  56.632 -                                unsigned int irq_offset,
  56.633 -                                unsigned int irq_count,
  56.634 -                                unsigned int ipi_offset,
  56.635 -                                unsigned char *senses,
  56.636 -                                unsigned int senses_count,
  56.637 -                                const char *name)
  56.638 -{
  56.639 -	struct mpic	*mpic;
  56.640 -	u32		reg;
  56.641 -	const char	*vers;
  56.642 -	int		i;
  56.643 -
  56.644 -	mpic = alloc_bootmem(sizeof(struct mpic));
  56.645 -	if (mpic == NULL)
  56.646 -		return NULL;
  56.647 -	
  56.648 -
  56.649 -	memset(mpic, 0, sizeof(struct mpic));
  56.650 -	mpic->name = name;
  56.651 -
  56.652 -	mpic->hc_irq.typename = name;
  56.653 -	mpic->hc_irq.startup = mpic_startup_irq;
  56.654 -	mpic->hc_irq.shutdown = mpic_shutdown_irq;
  56.655 -	mpic->hc_irq.enable = mpic_enable_irq;
  56.656 -	mpic->hc_irq.disable = mpic_disable_irq;
  56.657 -	mpic->hc_irq.end = mpic_end_irq;
  56.658 -	if (flags & MPIC_PRIMARY)
  56.659 -		mpic->hc_irq.set_affinity = mpic_set_affinity;
  56.660 -#ifdef CONFIG_SMP
  56.661 -	mpic->hc_ipi.typename = name;
  56.662 -	mpic->hc_ipi.enable = mpic_enable_ipi;
  56.663 -	mpic->hc_ipi.disable = mpic_disable_ipi;
  56.664 -	mpic->hc_ipi.end = mpic_end_ipi;
  56.665 -#endif /* CONFIG_SMP */
  56.666 -
  56.667 -	mpic->flags = flags;
  56.668 -	mpic->isu_size = isu_size;
  56.669 -	mpic->irq_offset = irq_offset;
  56.670 -	mpic->irq_count = irq_count;
  56.671 -	mpic->ipi_offset = ipi_offset;
  56.672 -	mpic->num_sources = 0; /* so far */
  56.673 -	mpic->senses = senses;
  56.674 -	mpic->senses_count = senses_count;
  56.675 -
  56.676 -	/* Map the global registers */
  56.677 -	mpic->gregs = ioremap(phys_addr + MPIC_GREG_BASE, 0x1000);
  56.678 -	mpic->tmregs = mpic->gregs + ((MPIC_TIMER_BASE - MPIC_GREG_BASE) >> 2);
  56.679 -	BUG_ON(mpic->gregs == NULL);
  56.680 -
  56.681 -	/* Reset */
  56.682 -	if (flags & MPIC_WANTS_RESET) {
  56.683 -		mpic_write(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0,
  56.684 -                   mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
  56.685 -                   | MPIC_GREG_GCONF_RESET);
  56.686 -		while( mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
  56.687 -		       & MPIC_GREG_GCONF_RESET)
  56.688 -			mb();
  56.689 -	}
  56.690 -
  56.691 -	/* Read feature register, calculate num CPUs and, for non-ISU
  56.692 -	 * MPICs, num sources as well. On ISU MPICs, sources are counted
  56.693 -	 * as ISUs are added
  56.694 -	 */
  56.695 -	reg = mpic_read(mpic->gregs, MPIC_GREG_FEATURE_0);
  56.696 -	mpic->num_cpus = ((reg & MPIC_GREG_FEATURE_LAST_CPU_MASK)
  56.697 -                      >> MPIC_GREG_FEATURE_LAST_CPU_SHIFT) + 1;
  56.698 -	if (isu_size == 0)
  56.699 -		mpic->num_sources = ((reg & MPIC_GREG_FEATURE_LAST_SRC_MASK)
  56.700 -                             >> MPIC_GREG_FEATURE_LAST_SRC_SHIFT) + 1;
  56.701 -
  56.702 -	/* Map the per-CPU registers */
  56.703 -	for (i = 0; i < mpic->num_cpus; i++) {
  56.704 -		mpic->cpuregs[i] = ioremap(phys_addr + MPIC_CPU_BASE +
  56.705 -                                   i * MPIC_CPU_STRIDE, 0x1000);
  56.706 -		BUG_ON(mpic->cpuregs[i] == NULL);
  56.707 -	}
  56.708 -
  56.709 -	/* Initialize main ISU if none provided */
  56.710 -	if (mpic->isu_size == 0) {
  56.711 -		mpic->isu_size = mpic->num_sources;
  56.712 -		mpic->isus[0] = ioremap(phys_addr + MPIC_IRQ_BASE,
  56.713 -                                MPIC_IRQ_STRIDE * mpic->isu_size);
  56.714 -		BUG_ON(mpic->isus[0] == NULL);
  56.715 -	}
  56.716 -	mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
  56.717 -	mpic->isu_mask = (1 << mpic->isu_shift) - 1;
  56.718 -
  56.719 -	/* Display version */
  56.720 -	switch (reg & MPIC_GREG_FEATURE_VERSION_MASK) {
  56.721 -	case 1:
  56.722 -		vers = "1.0";
  56.723 -		break;
  56.724 -	case 2:
  56.725 -		vers = "1.2";
  56.726 -		break;
  56.727 -	case 3:
  56.728 -		vers = "1.3";
  56.729 -		break;
  56.730 -	default:
  56.731 -		vers = "<unknown>";
  56.732 -		break;
  56.733 -	}
  56.734 -	printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %lx, max %d CPUs\n",
  56.735 -	       name, vers, phys_addr, mpic->num_cpus);
  56.736 -	printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n", mpic->isu_size,
  56.737 -	       mpic->isu_shift, mpic->isu_mask);
  56.738 -
  56.739 -	mpic->next = mpics;
  56.740 -	mpics = mpic;
  56.741 -
  56.742 -	if (flags & MPIC_PRIMARY)
  56.743 -		mpic_primary = mpic;
  56.744 -
  56.745 -	return mpic;
  56.746 -}
  56.747 -
  56.748 -void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
  56.749 -                            unsigned long phys_addr)
  56.750 -{
  56.751 -	unsigned int isu_first = isu_num * mpic->isu_size;
  56.752 -
  56.753 -	BUG_ON(isu_num >= MPIC_MAX_ISU);
  56.754 -
  56.755 -	mpic->isus[isu_num] = ioremap(phys_addr, MPIC_IRQ_STRIDE * mpic->isu_size);
  56.756 -	if ((isu_first + mpic->isu_size) > mpic->num_sources)
  56.757 -		mpic->num_sources = isu_first + mpic->isu_size;
  56.758 -}
  56.759 -
  56.760 -void __init mpic_setup_cascade(unsigned int irq, mpic_cascade_t handler,
  56.761 -                               void *data)
  56.762 -{
  56.763 -	struct mpic *mpic = mpic_find(irq, NULL);
  56.764 -	unsigned long flags;
  56.765 -
  56.766 -	/* Synchronization here is a bit dodgy, so don't try to replace cascade
  56.767 -	 * interrupts on the fly too often ... but normally it's set up at boot.
  56.768 -	 */
  56.769 -	spin_lock_irqsave(&mpic_lock, flags);
  56.770 -	if (mpic->cascade)	       
  56.771 -		mpic_disable_irq(mpic->cascade_vec + mpic->irq_offset);
  56.772 -	mpic->cascade = NULL;
  56.773 -	wmb();
  56.774 -	mpic->cascade_vec = irq - mpic->irq_offset;
  56.775 -	mpic->cascade_data = data;
  56.776 -	wmb();
  56.777 -	mpic->cascade = handler;
  56.778 -	mpic_enable_irq(irq);
  56.779 -	spin_unlock_irqrestore(&mpic_lock, flags);
  56.780 -}
  56.781 -
  56.782 -void __init mpic_init(struct mpic *mpic)
  56.783 -{
  56.784 -	int i;
  56.785 -
  56.786 -	BUG_ON(mpic->num_sources == 0);
  56.787 -
  56.788 -	printk(KERN_INFO "mpic: Initializing for %d sources\n", mpic->num_sources);
  56.789 -
  56.790 -	/* Set current processor priority to max */
  56.791 -	mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0xf);
  56.792 -
  56.793 -	/* Initialize timers: just disable them all */
  56.794 -	for (i = 0; i < 4; i++) {
  56.795 -		mpic_write(mpic->tmregs,
  56.796 -                   i * MPIC_TIMER_STRIDE + MPIC_TIMER_DESTINATION, 0);
  56.797 -		mpic_write(mpic->tmregs,
  56.798 -                   i * MPIC_TIMER_STRIDE + MPIC_TIMER_VECTOR_PRI,
  56.799 -                   MPIC_VECPRI_MASK |
  56.800 -                   (MPIC_VEC_TIMER_0 + i));
  56.801 -	}
  56.802 -
  56.803 -	/* Initialize IPIs to our reserved vectors and mark them disabled for now */
  56.804 -	mpic_test_broken_ipi(mpic);
  56.805 -	for (i = 0; i < 4; i++) {
  56.806 -		mpic_ipi_write(i,
  56.807 -                       MPIC_VECPRI_MASK |
  56.808 -                       (10 << MPIC_VECPRI_PRIORITY_SHIFT) |
  56.809 -                       (MPIC_VEC_IPI_0 + i));
  56.810 -#ifdef CONFIG_SMP
  56.811 -		if (!(mpic->flags & MPIC_PRIMARY))
  56.812 -			continue;
  56.813 -		irq_desc[mpic->ipi_offset+i].status |= IRQ_PER_CPU;
  56.814 -		irq_desc[mpic->ipi_offset+i].handler = &mpic->hc_ipi;
  56.815 -#endif /* CONFIG_SMP */
  56.816 -	}
  56.817 -
  56.818 -	/* Initialize interrupt sources */
  56.819 -	if (mpic->irq_count == 0)
  56.820 -		mpic->irq_count = mpic->num_sources;
  56.821 -
  56.822 -#ifdef CONFIG_MPIC_BROKEN_U3
  56.823 -	/* Do the HT PIC fixups on U3 broken mpic */
  56.824 -	DBG("MPIC flags: %x\n", mpic->flags);
  56.825 -	if ((mpic->flags & MPIC_BROKEN_U3) && (mpic->flags & MPIC_PRIMARY))
  56.826 -		mpic_scan_ht_pics(mpic);
  56.827 -#endif /* CONFIG_MPIC_BROKEN_U3 */
  56.828 -
  56.829 -	for (i = 0; i < mpic->num_sources; i++) {
  56.830 -		/* start with vector = source number, and masked */
  56.831 -		u32 vecpri = MPIC_VECPRI_MASK | i | (8 << MPIC_VECPRI_PRIORITY_SHIFT);
  56.832 -		int level = 0;
  56.833 -		
  56.834 -		/* if it's an IPI, we skip it */
  56.835 -		if ((mpic->irq_offset + i) >= (mpic->ipi_offset + i) &&
  56.836 -		    (mpic->irq_offset + i) <  (mpic->ipi_offset + i + 4))
  56.837 -			continue;
  56.838 -
  56.839 -		/* do senses munging */
  56.840 -		if (mpic->senses && i < mpic->senses_count) {
  56.841 -			if (mpic->senses[i] & IRQ_SENSE_LEVEL)
  56.842 -				vecpri |= MPIC_VECPRI_SENSE_LEVEL;
  56.843 -			if (mpic->senses[i] & IRQ_POLARITY_POSITIVE)
  56.844 -				vecpri |= MPIC_VECPRI_POLARITY_POSITIVE;
  56.845 -		} else
  56.846 -			vecpri |= MPIC_VECPRI_SENSE_LEVEL;
  56.847 -
  56.848 -		/* remember if it was a level interrupts */
  56.849 -		level = (vecpri & MPIC_VECPRI_SENSE_LEVEL);
  56.850 -
  56.851 -		/* deal with broken U3 */
  56.852 -		if (mpic->flags & MPIC_BROKEN_U3) {
  56.853 -#ifdef CONFIG_MPIC_BROKEN_U3
  56.854 -			if (mpic_is_ht_interrupt(mpic, i)) {
  56.855 -				vecpri &= ~(MPIC_VECPRI_SENSE_MASK |
  56.856 -                            MPIC_VECPRI_POLARITY_MASK);
  56.857 -				vecpri |= MPIC_VECPRI_POLARITY_POSITIVE;
  56.858 -			}
  56.859 -#else
  56.860 -			printk(KERN_ERR "mpic: BROKEN_U3 set, but CONFIG doesn't match\n");
  56.861 -#endif
  56.862 -		}
  56.863 -
  56.864 -		DBG("setup source %d, vecpri: %08x, level: %d\n", i, vecpri,
  56.865 -		    (level != 0));
  56.866 -
  56.867 -		/* init hw */
  56.868 -		mpic_irq_write(i, MPIC_IRQ_VECTOR_PRI, vecpri);
  56.869 -		mpic_irq_write(i, MPIC_IRQ_DESTINATION,
  56.870 -                       1 << hard_smp_processor_id());
  56.871 -
  56.872 -		/* init linux descriptors */
  56.873 -		if (i < mpic->irq_count) {
  56.874 -			irq_desc[mpic->irq_offset+i].status = level ? IRQ_LEVEL : 0;
  56.875 -			irq_desc[mpic->irq_offset+i].handler = &mpic->hc_irq;
  56.876 -		}
  56.877 -	}
  56.878 -	
  56.879 -	/* Init spurrious vector */
  56.880 -	mpic_write(mpic->gregs, MPIC_GREG_SPURIOUS, MPIC_VEC_SPURRIOUS);
  56.881 -
  56.882 -	/* Disable 8259 passthrough */
  56.883 -	mpic_write(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0,
  56.884 -               mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
  56.885 -               | MPIC_GREG_GCONF_8259_PTHROU_DIS);
  56.886 -
  56.887 -	/* Set current processor priority to 0 */
  56.888 -	mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0);
  56.889 -}
  56.890 -
  56.891 -
  56.892 -
  56.893 -void mpic_irq_set_priority(unsigned int irq, unsigned int pri)
  56.894 -{
  56.895 -	unsigned is_ipi;
  56.896 -	struct mpic *mpic = mpic_find(irq, &is_ipi);
  56.897 -	unsigned long flags;
  56.898 -	u32 reg;
  56.899 -
  56.900 -	spin_lock_irqsave(&mpic_lock, flags);
  56.901 -	if (is_ipi) {
  56.902 -		reg = mpic_ipi_read(irq - mpic->ipi_offset) &
  56.903 -			~MPIC_VECPRI_PRIORITY_MASK;
  56.904 -		mpic_ipi_write(irq - mpic->ipi_offset,
  56.905 -                       reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT));
  56.906 -	} else {
  56.907 -		reg = mpic_irq_read(irq - mpic->irq_offset,MPIC_IRQ_VECTOR_PRI)
  56.908 -			& ~MPIC_VECPRI_PRIORITY_MASK;
  56.909 -		mpic_irq_write(irq - mpic->irq_offset, MPIC_IRQ_VECTOR_PRI,
  56.910 -                       reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT));
  56.911 -	}
  56.912 -	spin_unlock_irqrestore(&mpic_lock, flags);
  56.913 -}
  56.914 -
  56.915 -unsigned int mpic_irq_get_priority(unsigned int irq)
  56.916 -{
  56.917 -	unsigned is_ipi;
  56.918 -	struct mpic *mpic = mpic_find(irq, &is_ipi);
  56.919 -	unsigned long flags;
  56.920 -	u32 reg;
  56.921 -
  56.922 -	spin_lock_irqsave(&mpic_lock, flags);
  56.923 -	if (is_ipi)
  56.924 -		reg = mpic_ipi_read(irq - mpic->ipi_offset);
  56.925 -	else
  56.926 -		reg = mpic_irq_read(irq - mpic->irq_offset, MPIC_IRQ_VECTOR_PRI);
  56.927 -	spin_unlock_irqrestore(&mpic_lock, flags);
  56.928 -	return (reg & MPIC_VECPRI_PRIORITY_MASK) >> MPIC_VECPRI_PRIORITY_SHIFT;
  56.929 -}
  56.930 -
  56.931 -void mpic_setup_this_cpu(void)
  56.932 -{
  56.933 -#ifdef CONFIG_SMP
  56.934 -	struct mpic *mpic = mpic_primary;
  56.935 -	unsigned long flags;
  56.936 -	u32 msk = 1 << hard_smp_processor_id();
  56.937 -	unsigned int i;
  56.938 -
  56.939 -	BUG_ON(mpic == NULL);
  56.940 -
  56.941 -	DBG("%s: setup_this_cpu(%d)\n", mpic->name, hard_smp_processor_id());
  56.942 -
  56.943 -	spin_lock_irqsave(&mpic_lock, flags);
  56.944 -
  56.945 - 	/* let the mpic know we want intrs. default affinity is 0xffffffff
  56.946 -	 * until changed via /proc. That's how it's done on x86. If we want
  56.947 -	 * it differently, then we should make sure we also change the default
  56.948 -	 * values of irq_affinity in irq.c.
  56.949 - 	 */
  56.950 -	if (distribute_irqs) {
  56.951 -	 	for (i = 0; i < mpic->num_sources ; i++)
  56.952 -			mpic_irq_write(i, MPIC_IRQ_DESTINATION,
  56.953 -                           mpic_irq_read(i, MPIC_IRQ_DESTINATION) | msk);
  56.954 -	}
  56.955 -
  56.956 -	/* Set current processor priority to 0 */
  56.957 -	mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0);
  56.958 -
  56.959 -	spin_unlock_irqrestore(&mpic_lock, flags);
  56.960 -#endif /* CONFIG_SMP */
  56.961 -}
  56.962 -
  56.963 -int mpic_cpu_get_priority(void)
  56.964 -{
  56.965 -	struct mpic *mpic = mpic_primary;
  56.966 -
  56.967 -	return mpic_cpu_read(MPIC_CPU_CURRENT_TASK_PRI);
  56.968 -}
  56.969 -
  56.970 -void mpic_cpu_set_priority(int prio)
  56.971 -{
  56.972 -	struct mpic *mpic = mpic_primary;
  56.973 -
  56.974 -	prio &= MPIC_CPU_TASKPRI_MASK;
  56.975 -	mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, prio);
  56.976 -}
  56.977 -
  56.978 -/*
  56.979 - * XXX: someone who knows mpic should check this.
  56.980 - * do we need to eoi the ipi including for kexec cpu here (see xics comments)?
  56.981 - * or can we reset the mpic in the new kernel?
  56.982 - */
  56.983 -void mpic_teardown_this_cpu(int secondary)
  56.984 -{
  56.985 -	struct mpic *mpic = mpic_primary;
  56.986 -	unsigned long flags;
  56.987 -	u32 msk = 1 << hard_smp_processor_id();
  56.988 -	unsigned int i;
  56.989 -
  56.990 -	BUG_ON(mpic == NULL);
  56.991 -
  56.992 -	DBG("%s: teardown_this_cpu(%d)\n", mpic->name, hard_smp_processor_id());
  56.993 -	spin_lock_irqsave(&mpic_lock, flags);
  56.994 -
  56.995 -	/* let the mpic know we don't want intrs.  */
  56.996 -	for (i = 0; i < mpic->num_sources ; i++)
  56.997 -		mpic_irq_write(i, MPIC_IRQ_DESTINATION,
  56.998 -                       mpic_irq_read(i, MPIC_IRQ_DESTINATION) & ~msk);
  56.999 -
 56.1000 -	/* Set current processor priority to max */
 56.1001 -	mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0xf);
 56.1002 -
 56.1003 -	spin_unlock_irqrestore(&mpic_lock, flags);
 56.1004 -}
 56.1005 -
 56.1006 -
 56.1007 -void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask)
 56.1008 -{
 56.1009 -	struct mpic *mpic = mpic_primary;
 56.1010 -
 56.1011 -	BUG_ON(mpic == NULL);
 56.1012 -
 56.1013 -#ifdef DEBUG_IPI
 56.1014 -	DBG("%s: send_ipi(ipi_no: %d)\n", mpic->name, ipi_no);
 56.1015 -#endif
 56.1016 -
 56.1017 -	mpic_cpu_write(MPIC_CPU_IPI_DISPATCH_0 + ipi_no * 0x10,
 56.1018 -                   mpic_physmask(cpu_mask & cpus_addr(cpu_online_map)[0]));
 56.1019 -}
 56.1020 -
 56.1021 -int mpic_get_one_irq(struct mpic *mpic, struct pt_regs *regs)
 56.1022 -{
 56.1023 -	u32 irq;
 56.1024 -
 56.1025 -	irq = mpic_cpu_read(MPIC_CPU_INTACK) & MPIC_VECPRI_VECTOR_MASK;
 56.1026 -#ifdef DEBUG_LOW
 56.1027 -	DBG("%s: get_one_irq(): %d\n", mpic->name, irq);
 56.1028 -#endif
 56.1029 -	if (mpic->cascade && irq == mpic->cascade_vec) {
 56.1030 -#ifdef DEBUG_LOW
 56.1031 -		DBG("%s: cascading ...\n", mpic->name);
 56.1032 -#endif
 56.1033 -		irq = mpic->cascade(regs, mpic->cascade_data);
 56.1034 -		mpic_eoi(mpic);
 56.1035 -		return irq;
 56.1036 -	}
 56.1037 -	if (unlikely(irq == MPIC_VEC_SPURRIOUS))
 56.1038 -		return -1;
 56.1039 -	if (irq < MPIC_VEC_IPI_0) {
 56.1040 -#ifdef DEBUG_IRQ
 56.1041 -		DBG("%s: irq %d\n", mpic->name, irq + mpic->irq_offset);
 56.1042 -#endif
 56.1043 -		return irq + mpic->irq_offset;
 56.1044 -	}
 56.1045 -#ifdef DEBUG_IPI
 56.1046 -    DBG("%s: ipi %d !\n", mpic->name, irq - MPIC_VEC_IPI_0);
 56.1047 -#endif
 56.1048 -	return irq - MPIC_VEC_IPI_0 + mpic->ipi_offset;
 56.1049 -}
 56.1050 -
 56.1051 -int mpic_get_irq(struct pt_regs *regs)
 56.1052 -{
 56.1053 -	struct mpic *mpic = mpic_primary;
 56.1054 -
 56.1055 -	BUG_ON(mpic == NULL);
 56.1056 -
 56.1057 -	return mpic_get_one_irq(mpic, regs);
 56.1058 -}
 56.1059 -
 56.1060 -
 56.1061 -#ifdef CONFIG_SMP
 56.1062 -void mpic_request_ipis(void)
 56.1063 -{
 56.1064 -	struct mpic *mpic = mpic_primary;
 56.1065 -
 56.1066 -	BUG_ON(mpic == NULL);
 56.1067 -	
 56.1068 -	printk("requesting IPIs ... \n");
 56.1069 -
 56.1070 -	/* IPIs are marked SA_INTERRUPT as they must run with irqs disabled */
 56.1071 -	request_irq(mpic->ipi_offset+0, mpic_ipi_action, SA_INTERRUPT,
 56.1072 -                "IPI0 (call function)", mpic);
 56.1073 -	request_irq(mpic->ipi_offset+1, mpic_ipi_action, SA_INTERRUPT,
 56.1074 -                "IPI1 (reschedule)", mpic);
 56.1075 -	request_irq(mpic->ipi_offset+2, mpic_ipi_action, SA_INTERRUPT,
 56.1076 -                "IPI2 (unused)", mpic);
 56.1077 -	request_irq(mpic->ipi_offset+3, mpic_ipi_action, SA_INTERRUPT,
 56.1078 -                "IPI3 (debugger break)", mpic);
 56.1079 -
 56.1080 -	printk("IPIs requested... \n");
 56.1081 -}
 56.1082 -
 56.1083 -void smp_mpic_message_pass(int target, int msg)
 56.1084 -{
 56.1085 -	/* make sure we're sending something that translates to an IPI */
 56.1086 -	if ((unsigned int)msg > 3) {
 56.1087 -		printk("SMP %d: smp_message_pass: unknown msg %d\n",
 56.1088 -		       smp_processor_id(), msg);
 56.1089 -		return;
 56.1090 -	}
 56.1091 -	switch (target) {
 56.1092 -	case MSG_ALL:
 56.1093 -		mpic_send_ipi(msg, 0xffffffff);
 56.1094 -		break;
 56.1095 -	case MSG_ALL_BUT_SELF:
 56.1096 -		mpic_send_ipi(msg, 0xffffffff & ~(1 << smp_processor_id()));
 56.1097 -		break;
 56.1098 -	default:
 56.1099 -		mpic_send_ipi(msg, 1 << target);
 56.1100 -		break;
 56.1101 -	}
 56.1102 -}
 56.1103 -#endif /* CONFIG_SMP */
    57.1 --- a/xen/arch/powerpc/mpic_init.c	Thu May 08 13:15:45 2008 +0100
    57.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.3 @@ -1,416 +0,0 @@
    57.4 -/*
    57.5 - * This program is free software; you can redistribute it and/or modify
    57.6 - * it under the terms of the GNU General Public License as published by
    57.7 - * the Free Software Foundation; either version 2 of the License, or
    57.8 - * (at your option) any later version.
    57.9 - *
   57.10 - * This program is distributed in the hope that it will be useful,
   57.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   57.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   57.13 - * GNU General Public License for more details.
   57.14 - *
   57.15 - * You should have received a copy of the GNU General Public License
   57.16 - * along with this program; if not, write to the Free Software
   57.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   57.18 - *
   57.19 - * Copyright (C) IBM Corp. 2005
   57.20 - *
   57.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   57.22 - */
   57.23 -
   57.24 -#include <xen/config.h>
   57.25 -#include <xen/init.h>
   57.26 -#include <xen/lib.h>
   57.27 -#include <asm/mpic.h>
   57.28 -#include <errno.h>
   57.29 -#include "mpic_init.h"
   57.30 -#include "oftree.h"
   57.31 -#include "of-devtree.h"
   57.32 -
   57.33 -#undef DEBUG
   57.34 -#define CONFIG_SHARE_MPIC
   57.35 -
   57.36 -#ifdef DEBUG
   57.37 -#define DBG(fmt...) printk(fmt)
   57.38 -#else
   57.39 -#define DBG(fmt...)
   57.40 -#endif
   57.41 -
   57.42 -#define PANIC(fmt...) DBG(fmt)
   57.43 -
   57.44 -static struct mpic *mpic;
   57.45 -static unsigned long opic_addr;
   57.46 -static unsigned int opic_flags;
   57.47 -
   57.48 -/*
   57.49 - * from OF_IEEE_1275
   57.50 - *
   57.51 - * pg 175, property "ranges"
   57.52 - *
   57.53 - * The number of integers in each size entry is determined by the
   57.54 - * value of the #size-cells property of this node (the node in which
   57.55 - * the ranges property appears) or 1 if the #size-cells property is
   57.56 - * absent.
   57.57 - *
   57.58 - *
   57.59 - * pg 177, property "reg"
   57.60 - *
   57.61 - * The number of integers in each size entry is determined by the
   57.62 - * value of the "#size-cells" property in the parent node.  If the
   57.63 - * parent node has no such property, the value is one.
   57.64 - */
   57.65 -static unsigned long reg2(void *oft_p, ofdn_t c)
   57.66 -{
   57.67 -    int rc;
   57.68 -    /* the struct isa_reg_property is for a value of 2 for
   57.69 -     * #address-cells and a value of 1 for #size-cells (of the
   57.70 -     * parent).
   57.71 -     */
   57.72 -    struct isa_reg_property {
   57.73 -        u32 space;
   57.74 -        u32 address;
   57.75 -        u32 size;
   57.76 -    } isa_reg;
   57.77 -
   57.78 -    rc = ofd_getprop(oft_p, c, "reg", &isa_reg, sizeof(isa_reg));
   57.79 -
   57.80 -    DBG("%s: reg property address=0x%08x  size=0x%08x\n", __func__,
   57.81 -        isa_reg.address, isa_reg.size);
   57.82 -    return isa_reg.address;
   57.83 -}
   57.84 -
   57.85 -static unsigned long reg1(void *oft_p, ofdn_t c)
   57.86 -{
   57.87 -    int rc;
   57.88 -    /* the struct reg_property32 is for a value of 1 for
   57.89 -     * #address-cells and a value of 1 for #size-cells.
   57.90 -     */
   57.91 -    struct reg_property32 {
   57.92 -        u32 address;
   57.93 -        u32 size;
   57.94 -    } reg;
   57.95 -
   57.96 -    rc = ofd_getprop(oft_p, c, "reg", &reg, sizeof(reg));
   57.97 -
   57.98 -    DBG("%s: reg property address=0x%08x  size=0x%08x\n", __func__,
   57.99 -        reg.address, reg.size);
  57.100 -    return reg.address;
  57.101 -}
  57.102 -
  57.103 -static unsigned long find_reg_addr_from_node(void *oft_p, ofdn_t c)
  57.104 -{
  57.105 -    int p_len;
  57.106 -    unsigned long reg_addr = 0;
  57.107 -    u32 size_c = 1;
  57.108 -    u32 addr_c = 2;
  57.109 -    ofdn_t parent;
  57.110 -
  57.111 -    if (c == OFD_ROOT) {
  57.112 -        parent = c;
  57.113 -    } else {
  57.114 -        parent = ofd_node_parent(oft_p, c);
  57.115 -    }
  57.116 -
  57.117 -    p_len = ofd_getprop(oft_p, parent, "#size-cells", &size_c, sizeof(size_c));
  57.118 -    DBG("%s size is %d\n", __func__, size_c);
  57.119 -
  57.120 -    p_len = ofd_getprop(oft_p, parent, "#address-cells", &addr_c,
  57.121 -                        sizeof(addr_c));
  57.122 -    DBG("%s address is %d\n", __func__, addr_c);
  57.123 -
  57.124 -    if ( 1 != size_c ) {
  57.125 -        PANIC("Unsupported size for reg property\n");
  57.126 -    }
  57.127 -    
  57.128 -    if ( 1 == addr_c) {
  57.129 -        reg_addr = reg1(oft_p, c);
  57.130 -    } else if ( 2 == addr_c ) {
  57.131 -        reg_addr = reg2(oft_p, c);
  57.132 -    } else {
  57.133 -        PANIC("Unsupported address size for reg property\n");
  57.134 -    }
  57.135 -    DBG("%s: address 0x%lx\n", __func__, reg_addr);
  57.136 -    return reg_addr;
  57.137 -}
  57.138 -
  57.139 -/*
  57.140 - * from OF_IEEE_1275
  57.141 - *
  57.142 - * pg 175, property "ranges"
  57.143 - * 
  57.144 - * The ranges property value is a sequence of child-phys parent-phys
  57.145 - * size specifications. Child-phys is an address, encoded as with
  57.146 - * encode-phys, in the child address space. Parent-phys is an address
  57.147 - * (likewise encoded as with encode-phys) in the parent address
  57.148 - * space. Size is a list of integers, each encoded as with encode-int,
  57.149 - * denoting the length of the child's address range.
  57.150 - */
  57.151 -static unsigned long find_ranges_addr_from_node(void *oft_p, ofdn_t c)
  57.152 -{
  57.153 -    unsigned long ranges_addr = 0;
  57.154 -    int ranges_i;
  57.155 -    ofdn_t parent;
  57.156 -    u32 addr_c = 2;
  57.157 -    u32 ranges[64];
  57.158 -    int p_len;
  57.159 -    int i;
  57.160 -
  57.161 -    parent = ofd_node_parent(oft_p, c);
  57.162 -    parent = ofd_node_parent(oft_p, parent);
  57.163 -
  57.164 -    p_len = ofd_getprop(oft_p, parent, "ranges", &ranges, sizeof(ranges));
  57.165 -    DBG("%s: ranges\n", __func__);
  57.166 -    for (i=0; i<p_len; i++)
  57.167 -        DBG("%08x ", ranges[i]);
  57.168 -    DBG("\n");
  57.169 -
  57.170 -    p_len = ofd_getprop(oft_p, parent, "#address-cells",
  57.171 -                        &addr_c, sizeof(addr_c));
  57.172 -    DBG("%s address is %d\n", __func__, addr_c);
  57.173 -    ranges_i = addr_c;  /* skip over the child address */
  57.174 -    
  57.175 -    DBG("%s address is %d\n", __func__, addr_c);
  57.176 -    switch (addr_c) {
  57.177 -    case 1: 
  57.178 -        ranges_addr = ranges[ranges_i];
  57.179 -        break;
  57.180 -    case 2:
  57.181 -        ranges_addr = (((u64)ranges[ranges_i]) << 32) |
  57.182 -            ranges[ranges_i + 1];
  57.183 -        break;
  57.184 -    case 3:  /* the G5 case, how to squeeze 96 bits into 64 */
  57.185 -        ranges_addr = (((u64)ranges[ranges_i+1]) << 32) |
  57.186 -            ranges[ranges_i + 2];
  57.187 -        break;
  57.188 -    case 4:
  57.189 -        ranges_addr = (((u64)ranges[ranges_i+2]) << 32) |
  57.190 -            ranges[ranges_i + 4];
  57.191 -        break;
  57.192 -    default:
  57.193 -        PANIC("#address-cells out of range\n");
  57.194 -        break;
  57.195 -    }
  57.196 -    
  57.197 -    DBG("%s: address 0x%lx\n", __func__, ranges_addr);
  57.198 -    return ranges_addr;
  57.199 -}
  57.200 -
  57.201 -static unsigned long find_pic_address_from_node(void *oft_p, ofdn_t c)
  57.202 -{
  57.203 -    unsigned long reg_addr, range_addr, addr;
  57.204 -
  57.205 -    /*
  57.206 -     * The address is the sum of the address in the reg property of this node
  57.207 -     * and the ranges property of the granparent node.
  57.208 -     */
  57.209 -    reg_addr = find_reg_addr_from_node(oft_p, c);
  57.210 -    range_addr = find_ranges_addr_from_node(oft_p, c);
  57.211 -    addr = reg_addr + range_addr;
  57.212 -    DBG("%s: address 0x%lx\n", __func__, addr);
  57.213 -    return addr;
  57.214 -}
  57.215 -
  57.216 -static unsigned int find_pic_flags_from_node(void *oft_p, ofdn_t c)
  57.217 -{
  57.218 -    int be_len;
  57.219 -    unsigned int flags = 0;
  57.220 -
  57.221 -    /* does it have the property big endian? */
  57.222 -    be_len = ofd_getprop(oft_p, c, "big_endian", NULL, 0);
  57.223 -    if (be_len >= 0) {
  57.224 -        DBG("%s: Big Endian found\n", __func__);
  57.225 -        flags |= MPIC_BIG_ENDIAN;
  57.226 -    }
  57.227 -    DBG("%s: flags 0x%x\n", __func__, flags);
  57.228 -    return flags;
  57.229 -}
  57.230 -
  57.231 -static int find_mpic_simple_probe(void *oft_p)
  57.232 -{
  57.233 -    u32 addr_cells;
  57.234 -    int rc;
  57.235 -    u32 addr[2];
  57.236 -
  57.237 -    rc = ofd_getprop(oft_p, OFD_ROOT, "#address-cells",
  57.238 -                     &addr_cells, sizeof(addr_cells));
  57.239 -    if ( rc < 0 ) {
  57.240 -        /* if the property does not exist use its default value, 2 */
  57.241 -        addr_cells = 2;
  57.242 -    }
  57.243 -
  57.244 -    rc = ofd_getprop(oft_p, OFD_ROOT, "platform-open-pic", addr, sizeof(addr));
  57.245 -    if (rc < 0) {
  57.246 -        return rc;
  57.247 -    }
  57.248 -
  57.249 -    opic_addr = addr[0];
  57.250 -    if (addr_cells == 2) {
  57.251 -        opic_addr <<= 32;
  57.252 -        opic_addr |= addr[1];
  57.253 -    }
  57.254 -    DBG("%s: found OpenPIC at: 0x%lx\n", __func__, opic_addr);
  57.255 -    /* we did not really find the pic device, only its address. 
  57.256 -     * We use big endian and broken u3 by default.
  57.257 -     */
  57.258 -    opic_flags |= MPIC_BIG_ENDIAN | MPIC_BROKEN_U3;
  57.259 -    return 0;
  57.260 -}
  57.261 -
  57.262 -static int find_mpic_canonical_probe(void *oft_p)
  57.263 -{
  57.264 -    ofdn_t c;
  57.265 -    const char mpic_type[] = "open-pic";
  57.266 -    /* some paths are special and we cannot find the address
  57.267 -     * by the usual method */
  57.268 -    const char *excluded_paths[] = { "/interrupt-controller" };
  57.269 -
  57.270 -    /*
  57.271 -     * Search through the OFD tree for all devices of type 'open_pic'.
  57.272 -     * We select the one without an 'interrupt' property.
  57.273 -     */
  57.274 -    c = ofd_node_find_by_prop(oft_p, OFD_ROOT, "device_type", mpic_type,
  57.275 -                              sizeof(mpic_type));
  57.276 -    while (c > 0) {
  57.277 -        int int_len;
  57.278 -        int good_mpic;
  57.279 -        const char * path = ofd_node_path(oft_p, c);
  57.280 -
  57.281 -        good_mpic = 0;
  57.282 -        int_len = ofd_getprop(oft_p, c, "interrupts", NULL, 0);
  57.283 -        if (int_len < 0) {
  57.284 -            int i;
  57.285 -
  57.286 -            /* there is no property interrupt.  This could be the pic */
  57.287 -            DBG("%s: potential OpenPIC in: %s\n", __func__, path);
  57.288 -            good_mpic = 1;
  57.289 -
  57.290 -            for (i = 0; i < ARRAY_SIZE(excluded_paths) && good_mpic; i++) {
  57.291 -                const char *excluded_path = excluded_paths[i];
  57.292 -                if (!strncmp(path, excluded_path, strlen(excluded_path)))
  57.293 -                    good_mpic = 0;
  57.294 -            }
  57.295 -        }
  57.296 -
  57.297 -        if (good_mpic) {
  57.298 -            DBG("%s: found OpenPIC in: %s\n", __func__, path);
  57.299 -            opic_addr = find_pic_address_from_node(oft_p, c);
  57.300 -            opic_flags = find_pic_flags_from_node(oft_p, c);
  57.301 -            return 0;
  57.302 -        }
  57.303 -
  57.304 -        c = ofd_node_find_next(oft_p, c);
  57.305 -    }
  57.306 -
  57.307 -    DBG("%s: Could not find a pic\n", __func__);
  57.308 -    return -1;
  57.309 -}
  57.310 -
  57.311 -static int find_mpic(void)
  57.312 -{
  57.313 -    void *oft_p;
  57.314 -    int rc;
  57.315 -
  57.316 -    opic_addr = (unsigned long)-1;
  57.317 -    opic_flags = 0;
  57.318 -
  57.319 -    oft_p = (void *)oftree;
  57.320 -    rc = find_mpic_simple_probe(oft_p);
  57.321 -
  57.322 -    if (rc < 0) {
  57.323 -        DBG("%s: Searching for pic ...\n", __func__);
  57.324 -        rc = find_mpic_canonical_probe(oft_p);
  57.325 -    }
  57.326 -
  57.327 -    return rc;
  57.328 -}
  57.329 -
  57.330 -static unsigned int mpic_startup_ipi(unsigned int irq)
  57.331 -{
  57.332 -    mpic->hc_ipi.enable(irq);
  57.333 -    return 0;
  57.334 -}
  57.335 -
  57.336 -int request_irq(unsigned int irq,
  57.337 -                irqreturn_t (*handler)(int, void *, struct cpu_user_regs *),
  57.338 -                unsigned long irqflags, const char * devname, void *dev_id)
  57.339 -{
  57.340 -    int retval;
  57.341 -    struct irqaction *action;
  57.342 -    void (*func)(int, void *, struct cpu_user_regs *);
  57.343 -
  57.344 -    action = xmalloc(struct irqaction);
  57.345 -    if (!action) {
  57.346 -        BUG();
  57.347 -        return -ENOMEM;
  57.348 -    }
  57.349 -
  57.350 -    /* Xen's handler prototype is slightly different than Linux's.  */
  57.351 -    func = (void (*)(int, void *, struct cpu_user_regs *))handler;
  57.352 -
  57.353 -    action->handler = func;
  57.354 -    action->name = devname;
  57.355 -    action->dev_id = dev_id;
  57.356 -
  57.357 -    retval = setup_irq(irq, action);
  57.358 -    if (retval) {
  57.359 -        BUG();
  57.360 -        xfree(action);
  57.361 -    }
  57.362 -
  57.363 -    return retval;
  57.364 -}
  57.365 -
  57.366 -static void dummy_ack(unsigned int irq)
  57.367 -{
  57.368 -}
  57.369 -
  57.370 -void xen_mpic_init(void)
  57.371 -{
  57.372 -    unsigned int isu_size;
  57.373 -    unsigned int irq_offset;
  57.374 -    unsigned int irq_count;
  57.375 -    unsigned int ipi_offset;
  57.376 -    unsigned char *senses;
  57.377 -    unsigned int senses_count;
  57.378 -
  57.379 -    printk("%s: start\n", __func__);
  57.380 -
  57.381 -    io_apic_irqs = ~0;  /* all IRQs go through IOAPIC */
  57.382 -	irq_vector[0] = FIRST_DEVICE_VECTOR;
  57.383 -	vector_irq[FIRST_DEVICE_VECTOR] = 0;
  57.384 -
  57.385 -    isu_size = 0;
  57.386 -    irq_offset = 0;
  57.387 -    irq_count = 128;
  57.388 -    ipi_offset = 128;
  57.389 -    senses = NULL;
  57.390 -    senses_count = 0;
  57.391 -
  57.392 -    if (find_mpic()) {
  57.393 -        printk("%s: ERROR: Could not find open pic.\n", __func__);
  57.394 -        return;
  57.395 -    }
  57.396 -
  57.397 -    mpic = mpic_alloc(opic_addr,
  57.398 -                      opic_flags | MPIC_PRIMARY | MPIC_WANTS_RESET,
  57.399 -                      isu_size, irq_offset, irq_count,
  57.400 -                      ipi_offset, senses, senses_count, "Xen-U3-MPIC");
  57.401 -
  57.402 -    BUG_ON(mpic == NULL);
  57.403 -    mpic_init(mpic);
  57.404 -
  57.405 -    printk("%s: success\n", __func__);
  57.406 -
  57.407 -    mpic->hc_irq.ack = dummy_ack;
  57.408 -    mpic->hc_ipi.ack = dummy_ack;
  57.409 -    mpic->hc_ipi.startup = mpic_startup_ipi;
  57.410 -    mpic_request_ipis();
  57.411 -}
  57.412 -
  57.413 -/* Note: reading the vector implicitly ACKs it in hardware. */
  57.414 -int xen_mpic_get_irq(struct cpu_user_regs *regs)
  57.415 -{
  57.416 -    BUG_ON(mpic == NULL);
  57.417 -
  57.418 -	return mpic_get_one_irq(mpic, regs);
  57.419 -}
    58.1 --- a/xen/arch/powerpc/mpic_init.h	Thu May 08 13:15:45 2008 +0100
    58.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.3 @@ -1,27 +0,0 @@
    58.4 -/*
    58.5 - * This program is free software; you can redistribute it and/or modify
    58.6 - * it under the terms of the GNU General Public License as published by
    58.7 - * the Free Software Foundation; either version 2 of the License, or
    58.8 - * (at your option) any later version.
    58.9 - *
   58.10 - * This program is distributed in the hope that it will be useful,
   58.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   58.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   58.13 - * GNU General Public License for more details.
   58.14 - *
   58.15 - * You should have received a copy of the GNU General Public License
   58.16 - * along with this program; if not, write to the Free Software
   58.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   58.18 - *
   58.19 - * Copyright (C) IBM Corp. 2005
   58.20 - *
   58.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   58.22 - */
   58.23 -
   58.24 -#ifndef _MPIC_INIT_H
   58.25 -#define _MPIC_INIT_H
   58.26 -
   58.27 -extern void xen_mpic_init(void);
   58.28 -extern int xen_mpic_get_irq(struct cpu_user_regs *regs);
   58.29 -
   58.30 -#endif  /* #ifndef _MPIC_INIT_H */
    59.1 --- a/xen/arch/powerpc/multiboot2.c	Thu May 08 13:15:45 2008 +0100
    59.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.3 @@ -1,67 +0,0 @@
    59.4 -/*
    59.5 - * This program is free software; you can redistribute it and/or
    59.6 - * modify it under the terms of the GNU General Public License as
    59.7 - * published by the Free Software Foundation; either version 2 of the
    59.8 - * License, or (at your option) any later version.
    59.9 - *
   59.10 - * This program is distributed in the hope that it will be useful,
   59.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   59.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   59.13 - * GNU General Public License for more details.
   59.14 - *
   59.15 - * You should have received a copy of the GNU General Public License
   59.16 - * along with this program; if not, write to the Free Software
   59.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   59.18 - *
   59.19 - * Copyright IBM Corp. 2006, 2007
   59.20 - *
   59.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   59.22 - */
   59.23 -
   59.24 -#include <xen/config.h>
   59.25 -#include <xen/lib.h>
   59.26 -#include <xen/multiboot2.h>
   59.27 -#include <asm/boot.h>
   59.28 -#include <asm/init.h>
   59.29 -
   59.30 -static struct mb2_tag_module *mb2_tag_mod_find(struct mb2_tag_header *tags,
   59.31 -                                                const char *type)
   59.32 -{
   59.33 -    struct mb2_tag_header *tag;
   59.34 -
   59.35 -    for_each_tag(tag, tags) {
   59.36 -        if (tag->key == MB2_TAG_MODULE) {
   59.37 -            struct mb2_tag_module *mod = (struct mb2_tag_module *)tag;
   59.38 -            if (!strcmp((char *)mod->type, type))
   59.39 -                return mod;
   59.40 -        }
   59.41 -    }
   59.42 -    return NULL;
   59.43 -}
   59.44 -
   59.45 -void parse_multiboot(ulong tags_addr)
   59.46 -{
   59.47 -    struct mb2_tag_header *tags = (struct mb2_tag_header *)tags_addr;
   59.48 -    struct mb2_tag_module *mod;
   59.49 -
   59.50 -    if (tags->key != MB2_TAG_START)
   59.51 -        return;
   59.52 -
   59.53 -    mod = mb2_tag_mod_find(tags, "kernel");
   59.54 -    if (mod) {
   59.55 -        xen_cmdline = (char *)mod->cmdline;
   59.56 -    }
   59.57 -
   59.58 -    mod = mb2_tag_mod_find(tags, "dom0");
   59.59 -    if (mod) {
   59.60 -        dom0_addr = mod->addr;
   59.61 -        dom0_len = mod->size;
   59.62 -        dom0_cmdline = (char *)mod->cmdline;
   59.63 -    }
   59.64 -
   59.65 -    mod = mb2_tag_mod_find(tags, "initrd");
   59.66 -    if (mod) {
   59.67 -        initrd_start = mod->addr;
   59.68 -        initrd_len = mod->size;
   59.69 -    }
   59.70 -}
    60.1 --- a/xen/arch/powerpc/numa.c	Thu May 08 13:15:45 2008 +0100
    60.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.3 @@ -1,1 +0,0 @@
    60.4 -#include "../x86/numa.c"
    61.1 --- a/xen/arch/powerpc/of-devtree.c	Thu May 08 13:15:45 2008 +0100
    61.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.3 @@ -1,1087 +0,0 @@
    61.4 -/*
    61.5 - * This program is free software; you can redistribute it and/or modify
    61.6 - * it under the terms of the GNU General Public License as published by
    61.7 - * the Free Software Foundation; either version 2 of the License, or
    61.8 - * (at your option) any later version.
    61.9 - *
   61.10 - * This program is distributed in the hope that it will be useful,
   61.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   61.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   61.13 - * GNU General Public License for more details.
   61.14 - *
   61.15 - * You should have received a copy of the GNU General Public License
   61.16 - * along with this program; if not, write to the Free Software
   61.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   61.18 - *
   61.19 - * Copyright (C) IBM Corp. 2005
   61.20 - *
   61.21 - * Authors: Jimi Xenidis <jimix@watson.ibm.com>
   61.22 - */
   61.23 -
   61.24 -/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
   61.25 - * This code is intended to be used but relocatable routines So PLEASE
   61.26 - * do not place any global data here including const integrals or
   61.27 - * literals.
   61.28 - * The local assert() is ok for string literal usage.. but thats it.
   61.29 - */
   61.30 -
   61.31 -
   61.32 -#include <xen/config.h>
   61.33 -#include <xen/init.h>
   61.34 -#include <xen/lib.h>
   61.35 -#include "of-devtree.h"
   61.36 -
   61.37 -static int (*ofd_write)(const char *, size_t len) = NULL;
   61.38 -
   61.39 -void ofd_init(int (*write)(const char *, size_t len))
   61.40 -{
   61.41 -    ofd_write = write;
   61.42 -}
   61.43 -                  
   61.44 -
   61.45 -static void ofd_stop(void)
   61.46 -{
   61.47 -    for ( ; ; ) ;
   61.48 -}
   61.49 -
   61.50 -/* this is so it can be called from anywhere */
   61.51 -static void ofd_assprint(int line)
   61.52 -{
   61.53 -    char a[13];
   61.54 -    char num[20];
   61.55 -    int i;
   61.56 -
   61.57 -    a[0]  = '\n';
   61.58 -    a[1]  = '\n';
   61.59 -    a[2]  = 'O';
   61.60 -    a[3]  = 'F';
   61.61 -    a[4]  = 'D';
   61.62 -    a[5]  = ':';
   61.63 -    a[6]  = 'A';
   61.64 -    a[7]  = 'S';
   61.65 -    a[8]  = 'S';
   61.66 -    a[9]  = 'E';
   61.67 -    a[10] = 'R';
   61.68 -    a[11] = 'T';
   61.69 -    a[12] = ':';
   61.70 -
   61.71 -
   61.72 -    ofd_write(a, sizeof (a) - 1);
   61.73 -    
   61.74 -    /* put the number in backwards */
   61.75 -    i = 0;
   61.76 -    while ( line > 0 ) {
   61.77 -        num[i++] = '0' + (line % 10);
   61.78 -        line /= 10;
   61.79 -    }
   61.80 -    /* print it */
   61.81 -    /* number */
   61.82 -    while (i-- > 0) {
   61.83 -        ofd_write(&num[i], 1);
   61.84 -    }
   61.85 -    ofd_write("\n", 1);
   61.86 -
   61.87 -    ofd_stop();
   61.88 -}
   61.89 -
   61.90 -#ifdef assert
   61.91 -#undef assert
   61.92 -#endif
   61.93 -
   61.94 -#define assert(EX)                                              \
   61.95 -    do {                                                        \
   61.96 -        if ( !(EX) ) {                                          \
   61.97 -            ofd_assprint(__LINE__);                             \
   61.98 -        }                                                       \
   61.99 -    } while (0)
  61.100 -
  61.101 -/*
  61.102 - * We treat memory like an array of u64.  For the sake of
  61.103 - * compactness we assume that a short is big enough as an index.
  61.104 - */
  61.105 -struct ofd_node {
  61.106 -    ofdn_t on_ima;
  61.107 -    ofdn_t on_parent;
  61.108 -    ofdn_t on_child;
  61.109 -    ofdn_t on_peer;
  61.110 -    ofdn_t on_io;
  61.111 -    ofdn_t on_next;     /* for search lists */
  61.112 -    ofdn_t on_prev;
  61.113 -    ofdn_t on_prop;
  61.114 -    u32 on_pathlen;
  61.115 -    u32 on_last;
  61.116 -    char on_path[0];
  61.117 -};
  61.118 -
  61.119 -struct ofd_prop {
  61.120 -    ofdn_t op_ima;
  61.121 -    ofdn_t op_next;
  61.122 -    u32 op_objsz;
  61.123 -    u32 op_namesz;
  61.124 -    /* must have 64bit alignment */
  61.125 -    char op_data[0]  __attribute__ ((aligned(8)));
  61.126 -};
  61.127 -
  61.128 -struct ofd_io {
  61.129 -    ofdn_t oi_ima;
  61.130 -    ofdn_t oi_node;
  61.131 -    u64 oi_open   __attribute__ ((aligned(8)));
  61.132 -};
  61.133 -
  61.134 -struct ofd_free {
  61.135 -    ofdn_t of_cells;
  61.136 -    ofdn_t of_next;
  61.137 -};
  61.138 -
  61.139 -struct ofd_mem {
  61.140 -    ofdn_t om_num;
  61.141 -    ofdn_t om_next;
  61.142 -    ofdn_t om_free;     /* Future site of a free list */
  61.143 -    ofdn_t _om_pad;
  61.144 -    u64 om_mem[0] __attribute__((aligned(8)));
  61.145 -};
  61.146 -
  61.147 -#define NODE_PAT    0x0f01
  61.148 -#define PROP_PAT    0x0f03
  61.149 -#define IO_PAT      0x0f05
  61.150 -
  61.151 -
  61.152 -size_t ofd_size(void *mem)
  61.153 -{
  61.154 -    struct ofd_mem *m = (struct ofd_mem *)mem;
  61.155 -    size_t sz;
  61.156 -
  61.157 -    sz = m->om_next * sizeof (u64) + sizeof(*m);
  61.158 -    return sz;
  61.159 -}
  61.160 -
  61.161 -size_t ofd_space(void *mem)
  61.162 -{
  61.163 -    struct ofd_mem *m = (struct ofd_mem *)mem;
  61.164 -    size_t sz;
  61.165 -
  61.166 -    sz = m->om_num * sizeof (u64);