blob: 0854849e4d9695ada9bee4546129dfd3970290ee [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Russell King4baa9922008-08-02 10:55:55 +01002 * arch/arm/include/asm/domain.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (C) 1999 Russell King.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005 * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef __ASM_PROC_DOMAIN_H
12#define __ASM_PROC_DOMAIN_H
13
14/*
15 * Domain numbers
16 *
17 * DOMAIN_IO - domain 2 includes all IO only
18 * DOMAIN_USER - domain 1 includes all user memory only
19 * DOMAIN_KERNEL - domain 0 includes all kernel memory only
Lennert Buytenhek23bdf862006-03-28 21:00:40 +010020 *
21 * The domain numbering depends on whether we support 36 physical
22 * address for I/O or not. Addresses above the 32 bit boundary can
23 * only be mapped using supersections and supersections can only
24 * be set for domain 0. We could just default to DOMAIN_IO as zero,
25 * but there may be systems with supersection support and no 36-bit
26 * addressing. In such cases, we want to map system memory with
27 * supersections to reduce TLB misses and footprint.
28 *
29 * 36-bit addressing and supersections are only available on
30 * CPUs based on ARMv6+ or the Intel XSC3 core.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031 *
32 * We cannot use domain 0 for the kernel on QSD8x50 since the kernel domain
33 * is set to manager mode when set_fs(KERNEL_DS) is called. Setting domain 0
34 * to manager mode will disable the workaround for a cpu bug that can cause an
35 * invalid fault status and/or tlb corruption (CONFIG_VERIFY_PERMISSION_FAULT).
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037#if !defined(CONFIG_IO_36) && !defined(CONFIG_VERIFY_PERMISSION_FAULT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define DOMAIN_KERNEL 0
39#define DOMAIN_TABLE 0
40#define DOMAIN_USER 1
41#define DOMAIN_IO 2
Lennert Buytenhek23bdf862006-03-28 21:00:40 +010042#else
43#define DOMAIN_KERNEL 2
44#define DOMAIN_TABLE 2
45#define DOMAIN_USER 1
46#define DOMAIN_IO 0
47#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49/*
50 * Domain types
51 */
52#define DOMAIN_NOACCESS 0
53#define DOMAIN_CLIENT 1
Catalin Marinas247055a2010-09-13 16:03:21 +010054#ifdef CONFIG_CPU_USE_DOMAINS
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define DOMAIN_MANAGER 3
Catalin Marinas247055a2010-09-13 16:03:21 +010056#else
57#define DOMAIN_MANAGER 1
58#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#define domain_val(dom,type) ((type) << (2*(dom)))
61
62#ifndef __ASSEMBLY__
Russell King002547b2006-06-20 20:46:52 +010063
Catalin Marinas247055a2010-09-13 16:03:21 +010064#ifdef CONFIG_CPU_USE_DOMAINS
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065#ifdef CONFIG_EMULATE_DOMAIN_MANAGER_V7
66void emulate_domain_manager_set(u32 domain);
67int emulate_domain_manager_data_abort(u32 dfsr, u32 dfar);
68int emulate_domain_manager_prefetch_abort(u32 ifsr, u32 ifar);
69void emulate_domain_manager_switch_mm(
70 unsigned long pgd_phys,
71 struct mm_struct *mm,
72 void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *));
73
74#define set_domain(x) emulate_domain_manager_set(x)
75#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#define set_domain(x) \
77 do { \
78 __asm__ __volatile__( \
79 "mcr p15, 0, %0, c3, c0 @ set domain" \
80 : : "r" (x)); \
Catalin Marinas620879c2007-02-05 14:47:46 +010081 isb(); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 } while (0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85#define modify_domain(dom,type) \
86 do { \
87 struct thread_info *thread = current_thread_info(); \
88 unsigned int domain = thread->cpu_domain; \
89 domain &= ~domain_val(dom, DOMAIN_MANAGER); \
90 thread->cpu_domain = domain | domain_val(dom, type); \
91 set_domain(thread->cpu_domain); \
92 } while (0)
93
Russell King002547b2006-06-20 20:46:52 +010094#else
95#define set_domain(x) do { } while (0)
96#define modify_domain(dom,type) do { } while (0)
97#endif
98
Catalin Marinas247055a2010-09-13 16:03:21 +010099/*
100 * Generate the T (user) versions of the LDR/STR and related
101 * instructions (inline assembly)
102 */
103#ifdef CONFIG_CPU_USE_DOMAINS
104#define T(instr) #instr "t"
105#else
106#define T(instr) #instr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107#endif
Catalin Marinas247055a2010-09-13 16:03:21 +0100108
109#else /* __ASSEMBLY__ */
110
111/*
112 * Generate the T (user) versions of the LDR/STR and related
113 * instructions
114 */
115#ifdef CONFIG_CPU_USE_DOMAINS
116#define T(instr) instr ## t
117#else
118#define T(instr) instr
119#endif
120
121#endif /* __ASSEMBLY__ */
122
123#endif /* !__ASM_PROC_DOMAIN_H */