Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * Cross Partition (XP) uv-based functions. |
| 11 | * |
| 12 | * Architecture specific implementation of common functions. |
| 13 | * |
| 14 | */ |
| 15 | |
Dean Nelson | a812dcc | 2008-07-29 22:34:16 -0700 | [diff] [blame] | 16 | #include <linux/device.h> |
| 17 | #include <asm/uv/uv_hub.h> |
| 18 | #include "../sgi-gru/grukservices.h" |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame] | 19 | #include "xp.h" |
| 20 | |
Dean Nelson | a812dcc | 2008-07-29 22:34:16 -0700 | [diff] [blame] | 21 | /* |
| 22 | * Convert a virtual memory address to a physical memory address. |
| 23 | */ |
| 24 | static unsigned long |
| 25 | xp_pa_uv(void *addr) |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame] | 26 | { |
Dean Nelson | a812dcc | 2008-07-29 22:34:16 -0700 | [diff] [blame] | 27 | return uv_gpa(addr); |
| 28 | } |
| 29 | |
| 30 | static enum xp_retval |
| 31 | xp_remote_memcpy_uv(unsigned long dst_gpa, const unsigned long src_gpa, |
| 32 | size_t len) |
| 33 | { |
| 34 | int ret; |
| 35 | |
| 36 | ret = gru_copy_gpa(dst_gpa, src_gpa, len); |
| 37 | if (ret == 0) |
| 38 | return xpSuccess; |
| 39 | |
| 40 | dev_err(xp, "gru_copy_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx " |
| 41 | "len=%ld\n", dst_gpa, src_gpa, len); |
| 42 | return xpGruCopyError; |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Dean Nelson | 5b8669d | 2008-07-29 22:34:18 -0700 | [diff] [blame] | 45 | static int |
| 46 | xp_cpu_to_nasid_uv(int cpuid) |
| 47 | { |
| 48 | /* ??? Is this same as sn2 nasid in mach/part bitmaps set up by SAL? */ |
| 49 | return UV_PNODE_TO_NASID(uv_cpu_to_pnode(cpuid)); |
| 50 | } |
| 51 | |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame] | 52 | enum xp_retval |
| 53 | xp_init_uv(void) |
| 54 | { |
| 55 | BUG_ON(!is_uv()); |
| 56 | |
| 57 | xp_max_npartitions = XP_MAX_NPARTITIONS_UV; |
Dean Nelson | 5b8669d | 2008-07-29 22:34:18 -0700 | [diff] [blame] | 58 | xp_partition_id = 0; /* !!! not correct value */ |
| 59 | xp_region_size = 0; /* !!! not correct value */ |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame] | 60 | |
Dean Nelson | a812dcc | 2008-07-29 22:34:16 -0700 | [diff] [blame] | 61 | xp_pa = xp_pa_uv; |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame] | 62 | xp_remote_memcpy = xp_remote_memcpy_uv; |
Dean Nelson | 5b8669d | 2008-07-29 22:34:18 -0700 | [diff] [blame] | 63 | xp_cpu_to_nasid = xp_cpu_to_nasid_uv; |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame] | 64 | |
| 65 | return xpSuccess; |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | void |
| 69 | xp_exit_uv(void) |
| 70 | { |
| 71 | BUG_ON(!is_uv()); |
| 72 | } |