ia64/xen-unstable

changeset 15375:7d4c40c21690

[IA64] Introduce machine vector for platform specific fixups for dom0.

This is required to map SN2 specific registers to dom0.

Signed-off-by: Jes Sorensen <jes@sgi.com>
author Alex Williamson <alex.williamson@hp.com>
date Mon Jun 18 13:50:42 2007 -0600 (2007-06-18)
parents 0944634d4639
children 39a95178edbf
files xen/arch/ia64/xen/Makefile xen/arch/ia64/xen/dom_fw_sn2.c xen/arch/ia64/xen/dom_fw_utils.c xen/include/asm-ia64/linux-xen/asm/machvec.h xen/include/asm-ia64/linux-xen/asm/machvec_sn2.h
line diff
     1.1 --- a/xen/arch/ia64/xen/Makefile	Mon Jun 18 13:41:31 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/Makefile	Mon Jun 18 13:50:42 2007 -0600
     1.3 @@ -10,6 +10,7 @@ obj-y += dom_fw_common.o
     1.4  obj-y += dom_fw_dom0.o
     1.5  obj-y += dom_fw_domu.o
     1.6  obj-y += dom_fw_utils.o
     1.7 +obj-y += dom_fw_sn2.o
     1.8  obj-y += fw_emul.o
     1.9  obj-y += hpsimserial.o
    1.10  obj-y += hypercall.o
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xen/arch/ia64/xen/dom_fw_sn2.c	Mon Jun 18 13:50:42 2007 -0600
     2.3 @@ -0,0 +1,92 @@
     2.4 +/*
     2.5 + *  Xen domain0 platform firmware fixups for sn2
     2.6 + *  Copyright (C) 2007 Silicon Graphics Inc.
     2.7 + *       Jes Sorensen <jes@sgi.com>
     2.8 + *
     2.9 + * This program is free software; you can redistribute it and/or modify
    2.10 + * it under the terms of the GNU General Public License as published by
    2.11 + * the Free Software Foundation; version 2.
    2.12 + *
    2.13 + * This program is distributed in the hope that it will be useful,
    2.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.16 + * GNU General Public License for more details.
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License
    2.19 + * along with this program; if not, write to the Free Software
    2.20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.21 + */
    2.22 +
    2.23 +#include <xen/config.h>
    2.24 +#include <xen/acpi.h>
    2.25 +#include <xen/errno.h>
    2.26 +#include <xen/sched.h>
    2.27 +#include <xen/nodemask.h>
    2.28 +
    2.29 +#include <asm/dom_fw.h>
    2.30 +#include <asm/dom_fw_common.h>
    2.31 +#include <asm/dom_fw_dom0.h>
    2.32 +#include <asm/dom_fw_utils.h>
    2.33 +
    2.34 +#include <asm/sn/arch.h>
    2.35 +#include <asm/sn/addrs.h>
    2.36 +#include <asm/sn/shub_mmr.h>
    2.37 +
    2.38 +#define SWAP_NASID(n, x)       ((x & ~NASID_MASK) | NASID_SPACE(n))
    2.39 +
    2.40 +int __init
    2.41 +sn2_dom_fw_init(domain_t *d,
    2.42 +		struct xen_ia64_boot_param *bp,
    2.43 +		struct fw_tables *tables)
    2.44 +{
    2.45 +	int node;
    2.46 +	short nasid;
    2.47 +	unsigned long shubid, shubpicam, shubpiowrite;
    2.48 +
    2.49 +	printk("SN2 mapping specific registers to dom0\n");
    2.50 +
    2.51 +	assign_domain_mach_page(d, LOCAL_MMR_OFFSET | SH_RTC, PAGE_SIZE,
    2.52 +				ASSIGN_nocache);
    2.53 +
    2.54 +	if (is_shub1()) {
    2.55 +		/* 0x110060000 */
    2.56 +		shubid = SH1_GLOBAL_MMR_OFFSET + (SH1_SHUB_ID & PAGE_MASK);
    2.57 +		/* 0x120050000 */
    2.58 +		shubpicam = SH1_GLOBAL_MMR_OFFSET +
    2.59 +			(SH1_PI_CAM_CONTROL & PAGE_MASK);
    2.60 +		/* 0x120070000 */
    2.61 +		shubpiowrite = SH1_GLOBAL_MMR_OFFSET +
    2.62 +			(SH1_PIO_WRITE_STATUS_0 & PAGE_MASK);
    2.63 +
    2.64 +		for_each_online_node(node) {
    2.65 +			nasid = cnodeid_to_nasid(node);
    2.66 +			shubid = SWAP_NASID(nasid, shubid);
    2.67 +			shubpicam = SWAP_NASID(nasid, shubpicam);
    2.68 +			shubpiowrite = SWAP_NASID(nasid, shubpiowrite);
    2.69 +
    2.70 +			assign_domain_mach_page(d, shubid, PAGE_SIZE,
    2.71 +						ASSIGN_nocache);
    2.72 +			assign_domain_mach_page(d, shubpicam, PAGE_SIZE,
    2.73 +						ASSIGN_nocache);
    2.74 +			assign_domain_mach_page(d, shubpiowrite, PAGE_SIZE,
    2.75 +						ASSIGN_nocache);
    2.76 +		}
    2.77 +
    2.78 +		/* map leds */
    2.79 +		assign_domain_mach_page(d, LOCAL_MMR_OFFSET |
    2.80 +					SH1_REAL_JUNK_BUS_LED0,
    2.81 +					PAGE_SIZE, ASSIGN_nocache);
    2.82 +		assign_domain_mach_page(d, LOCAL_MMR_OFFSET |
    2.83 +					SH1_REAL_JUNK_BUS_LED1,
    2.84 +					PAGE_SIZE, ASSIGN_nocache);
    2.85 +		assign_domain_mach_page(d, LOCAL_MMR_OFFSET |
    2.86 +					SH1_REAL_JUNK_BUS_LED2,
    2.87 +					PAGE_SIZE, ASSIGN_nocache);
    2.88 +		assign_domain_mach_page(d, LOCAL_MMR_OFFSET |
    2.89 +					SH1_REAL_JUNK_BUS_LED3,
    2.90 +					PAGE_SIZE, ASSIGN_nocache);
    2.91 +	} else
    2.92 +		panic("Unable to build EFI entry for SHUB 2 MMR\n");
    2.93 +
    2.94 +	return 0;
    2.95 +}
     3.1 --- a/xen/arch/ia64/xen/dom_fw_utils.c	Mon Jun 18 13:41:31 2007 -0600
     3.2 +++ b/xen/arch/ia64/xen/dom_fw_utils.c	Mon Jun 18 13:50:42 2007 -0600
     3.3 @@ -292,6 +292,13 @@ int dom_fw_setup(domain_t * d, unsigned 
     3.4  			xfree(fw_tables);
     3.5  			return ret;
     3.6  		}
     3.7 +
     3.8 +		ret = platform_fw_init(d, bp, fw_tables);
     3.9 +		if (ret < 0) {
    3.10 +			xfree(fw_tables);
    3.11 +			return ret;
    3.12 +		}
    3.13 +
    3.14  		if (sizeof(*fw_tables) +
    3.15  		    fw_tables->num_mds * sizeof(fw_tables->efi_memmap[0]) >
    3.16  		    fw_tables_size) {
     4.1 --- a/xen/include/asm-ia64/linux-xen/asm/machvec.h	Mon Jun 18 13:41:31 2007 -0600
     4.2 +++ b/xen/include/asm-ia64/linux-xen/asm/machvec.h	Mon Jun 18 13:50:42 2007 -0600
     4.3 @@ -191,6 +191,15 @@ machvec_noop_pci_legacy_write (struct pc
     4.4  	panic("%s() called", __FUNCTION__);
     4.5  	return 0;
     4.6  }
     4.7 +
     4.8 +typedef int ia64_mv_fw_init_t (void *d, void *bp, void *tables);
     4.9 +
    4.10 +static inline int
    4.11 +machvec_noop_platform_fw_init (void *d, void *bp, void *tables)
    4.12 +{
    4.13 +	return 0;
    4.14 +}
    4.15 +
    4.16  #endif
    4.17  
    4.18  extern void machvec_setup (char **);
    4.19 @@ -254,6 +263,9 @@ extern void machvec_tlb_migrate_finish (
    4.20  #  define platform_readw_relaxed        ia64_mv.readw_relaxed
    4.21  #  define platform_readl_relaxed        ia64_mv.readl_relaxed
    4.22  #  define platform_readq_relaxed        ia64_mv.readq_relaxed
    4.23 +#ifdef XEN
    4.24 +#  define platform_fw_init      ia64_mv.fw_init
    4.25 +#endif
    4.26  # endif
    4.27  
    4.28  /* __attribute__((__aligned__(16))) is required to make size of the
    4.29 @@ -302,8 +314,57 @@ struct ia64_machine_vector {
    4.30  	ia64_mv_readw_relaxed_t *readw_relaxed;
    4.31  	ia64_mv_readl_relaxed_t *readl_relaxed;
    4.32  	ia64_mv_readq_relaxed_t *readq_relaxed;
    4.33 +#ifdef XEN
    4.34 +	ia64_mv_fw_init_t *fw_init;
    4.35 +#endif
    4.36  } __attribute__((__aligned__(16))); /* align attrib? see above comment */
    4.37  
    4.38 +#ifdef XEN
    4.39 +#define MACHVEC_INIT(name)			\
    4.40 +{						\
    4.41 +	#name,					\
    4.42 +	platform_setup,				\
    4.43 +	platform_cpu_init,			\
    4.44 +	platform_irq_init,			\
    4.45 +	platform_send_ipi,			\
    4.46 +	platform_timer_interrupt,		\
    4.47 +	platform_global_tlb_purge,		\
    4.48 +	platform_tlb_migrate_finish,		\
    4.49 +	platform_dma_init,			\
    4.50 +	platform_dma_alloc_coherent,		\
    4.51 +	platform_dma_free_coherent,		\
    4.52 +	platform_dma_map_single,		\
    4.53 +	platform_dma_unmap_single,		\
    4.54 +	platform_dma_map_sg,			\
    4.55 +	platform_dma_unmap_sg,			\
    4.56 +	platform_dma_sync_single_for_cpu,	\
    4.57 +	platform_dma_sync_sg_for_cpu,		\
    4.58 +	platform_dma_sync_single_for_device,	\
    4.59 +	platform_dma_sync_sg_for_device,	\
    4.60 +	platform_dma_mapping_error,			\
    4.61 +	platform_dma_supported,			\
    4.62 +	platform_local_vector_to_irq,		\
    4.63 +	platform_pci_get_legacy_mem,		\
    4.64 +	platform_pci_legacy_read,		\
    4.65 +	platform_pci_legacy_write,		\
    4.66 +	platform_inb,				\
    4.67 +	platform_inw,				\
    4.68 +	platform_inl,				\
    4.69 +	platform_outb,				\
    4.70 +	platform_outw,				\
    4.71 +	platform_outl,				\
    4.72 +	platform_mmiowb,			\
    4.73 +	platform_readb,				\
    4.74 +	platform_readw,				\
    4.75 +	platform_readl,				\
    4.76 +	platform_readq,				\
    4.77 +	platform_readb_relaxed,			\
    4.78 +	platform_readw_relaxed,			\
    4.79 +	platform_readl_relaxed,			\
    4.80 +	platform_readq_relaxed,			\
    4.81 +	platform_fw_init,			\
    4.82 +}
    4.83 +#else
    4.84  #define MACHVEC_INIT(name)			\
    4.85  {						\
    4.86  	#name,					\
    4.87 @@ -347,6 +408,7 @@ struct ia64_machine_vector {
    4.88  	platform_readl_relaxed,			\
    4.89  	platform_readq_relaxed,			\
    4.90  }
    4.91 +#endif
    4.92  
    4.93  extern struct ia64_machine_vector ia64_mv;
    4.94  extern void machvec_init (const char *name);
    4.95 @@ -494,5 +556,10 @@ extern ia64_mv_dma_supported		swiotlb_dm
    4.96  #ifndef platform_readq_relaxed
    4.97  # define platform_readq_relaxed	__ia64_readq_relaxed
    4.98  #endif
    4.99 +#ifdef XEN
   4.100 +#ifndef platform_fw_init
   4.101 +# define platform_fw_init	machvec_noop_platform_fw_init
   4.102 +#endif
   4.103 +#endif
   4.104  
   4.105  #endif /* _ASM_IA64_MACHVEC_H */
     5.1 --- a/xen/include/asm-ia64/linux-xen/asm/machvec_sn2.h	Mon Jun 18 13:41:31 2007 -0600
     5.2 +++ b/xen/include/asm-ia64/linux-xen/asm/machvec_sn2.h	Mon Jun 18 13:50:42 2007 -0600
     5.3 @@ -71,6 +71,9 @@ extern ia64_mv_migrate_t		sn_migrate;
     5.4  extern ia64_mv_setup_msi_irq_t		sn_setup_msi_irq;
     5.5  extern ia64_mv_teardown_msi_irq_t	sn_teardown_msi_irq;
     5.6  #endif
     5.7 +#ifdef XEN
     5.8 +extern ia64_mv_fw_init_t		sn2_dom_fw_init;
     5.9 +#endif
    5.10  
    5.11  
    5.12  /*
    5.13 @@ -161,6 +164,10 @@ extern ia64_mv_teardown_msi_irq_t	sn_tea
    5.14  #endif
    5.15  #endif
    5.16  
    5.17 +#ifdef XEN
    5.18 +#define platform_fw_init		sn2_dom_fw_init
    5.19 +#endif
    5.20 +
    5.21  #include <asm/sn/io.h>
    5.22  
    5.23  #endif /* _ASM_IA64_MACHVEC_SN2_H */