Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Russell King | 4baa992 | 2008-08-02 10:55:55 +0100 | [diff] [blame] | 2 | * arch/arm/include/asm/proc-fns.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 1997-1999 Russell King |
| 5 | * Copyright (C) 2000 Deep Blue Solutions Ltd |
| 6 | * |
| 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_PROCFNS_H |
| 12 | #define __ASM_PROCFNS_H |
| 13 | |
| 14 | #ifdef __KERNEL__ |
| 15 | |
Russell King | 753790e | 2011-02-06 15:32:24 +0000 | [diff] [blame] | 16 | #include <asm/glue-proc.h> |
| 17 | #include <asm/page.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
| 19 | #ifndef __ASSEMBLY__ |
| 20 | |
Russell King | 753790e | 2011-02-06 15:32:24 +0000 | [diff] [blame] | 21 | struct mm_struct; |
| 22 | |
| 23 | /* |
| 24 | * Don't change this structure - ASM code relies on it. |
| 25 | */ |
| 26 | extern struct processor { |
| 27 | /* MISC |
| 28 | * get data abort address/flags |
| 29 | */ |
| 30 | void (*_data_abort)(unsigned long pc); |
| 31 | /* |
| 32 | * Retrieve prefetch fault address |
| 33 | */ |
| 34 | unsigned long (*_prefetch_abort)(unsigned long lr); |
| 35 | /* |
| 36 | * Set up any processor specifics |
| 37 | */ |
| 38 | void (*_proc_init)(void); |
| 39 | /* |
| 40 | * Disable any processor specifics |
| 41 | */ |
| 42 | void (*_proc_fin)(void); |
| 43 | /* |
| 44 | * Special stuff for a reset |
| 45 | */ |
| 46 | void (*reset)(unsigned long addr) __attribute__((noreturn)); |
| 47 | /* |
| 48 | * Idle the processor |
| 49 | */ |
| 50 | int (*_do_idle)(void); |
| 51 | /* |
| 52 | * Processor architecture specific |
| 53 | */ |
| 54 | /* |
| 55 | * clean a virtual address range from the |
| 56 | * D-cache without flushing the cache. |
| 57 | */ |
| 58 | void (*dcache_clean_area)(void *addr, int size); |
| 59 | |
| 60 | /* |
| 61 | * Set the page table |
| 62 | */ |
Cyril Chemparathy | 13f659b | 2012-07-16 15:37:06 -0400 | [diff] [blame] | 63 | void (*switch_mm)(phys_addr_t pgd_phys, struct mm_struct *mm); |
Russell King | 753790e | 2011-02-06 15:32:24 +0000 | [diff] [blame] | 64 | /* |
| 65 | * Set a possibly extended PTE. Non-extended PTEs should |
| 66 | * ignore 'ext'. |
| 67 | */ |
Catalin Marinas | da02877 | 2011-11-22 17:30:29 +0000 | [diff] [blame] | 68 | #ifdef CONFIG_ARM_LPAE |
| 69 | void (*set_pte_ext)(pte_t *ptep, pte_t pte); |
| 70 | #else |
Russell King | 753790e | 2011-02-06 15:32:24 +0000 | [diff] [blame] | 71 | void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext); |
Catalin Marinas | da02877 | 2011-11-22 17:30:29 +0000 | [diff] [blame] | 72 | #endif |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 73 | |
| 74 | /* Suspend/resume */ |
| 75 | unsigned int suspend_size; |
| 76 | void (*do_suspend)(void *); |
| 77 | void (*do_resume)(void *); |
Russell King | 753790e | 2011-02-06 15:32:24 +0000 | [diff] [blame] | 78 | } processor; |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #ifndef MULTI_CPU |
Russell King | 753790e | 2011-02-06 15:32:24 +0000 | [diff] [blame] | 81 | extern void cpu_proc_init(void); |
| 82 | extern void cpu_proc_fin(void); |
| 83 | extern int cpu_do_idle(void); |
| 84 | extern void cpu_dcache_clean_area(void *, int); |
Cyril Chemparathy | 13f659b | 2012-07-16 15:37:06 -0400 | [diff] [blame] | 85 | extern void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm); |
Catalin Marinas | da02877 | 2011-11-22 17:30:29 +0000 | [diff] [blame] | 86 | #ifdef CONFIG_ARM_LPAE |
| 87 | extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte); |
| 88 | #else |
Russell King | 753790e | 2011-02-06 15:32:24 +0000 | [diff] [blame] | 89 | extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext); |
Catalin Marinas | da02877 | 2011-11-22 17:30:29 +0000 | [diff] [blame] | 90 | #endif |
Russell King | 753790e | 2011-02-06 15:32:24 +0000 | [diff] [blame] | 91 | extern void cpu_reset(unsigned long addr) __attribute__((noreturn)); |
Russell King | abda1bd | 2011-09-01 11:52:33 +0100 | [diff] [blame] | 92 | |
| 93 | /* These three are private to arch/arm/kernel/suspend.c */ |
| 94 | extern void cpu_do_suspend(void *); |
| 95 | extern void cpu_do_resume(void *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | #else |
Will Deacon | eca5dc2 | 2011-07-01 14:37:08 +0100 | [diff] [blame] | 97 | #define cpu_proc_init processor._proc_init |
| 98 | #define cpu_proc_fin processor._proc_fin |
| 99 | #define cpu_reset processor.reset |
| 100 | #define cpu_do_idle processor._do_idle |
| 101 | #define cpu_dcache_clean_area processor.dcache_clean_area |
| 102 | #define cpu_set_pte_ext processor.set_pte_ext |
| 103 | #define cpu_do_switch_mm processor.switch_mm |
Russell King | abda1bd | 2011-09-01 11:52:33 +0100 | [diff] [blame] | 104 | |
| 105 | /* These three are private to arch/arm/kernel/suspend.c */ |
| 106 | #define cpu_do_suspend processor.do_suspend |
| 107 | #define cpu_do_resume processor.do_resume |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | #endif |
| 109 | |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 110 | extern void cpu_resume(void); |
| 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #include <asm/memory.h> |
| 113 | |
Russell King | 002547b | 2006-06-20 20:46:52 +0100 | [diff] [blame] | 114 | #ifdef CONFIG_MMU |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | #define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm) |
| 117 | |
Catalin Marinas | da02877 | 2011-11-22 17:30:29 +0000 | [diff] [blame] | 118 | #ifdef CONFIG_ARM_LPAE |
Cyril Chemparathy | 1fc84ae | 2012-07-16 17:20:17 -0400 | [diff] [blame] | 119 | |
| 120 | #define cpu_get_ttbr(nr) \ |
| 121 | ({ \ |
| 122 | u64 ttbr; \ |
| 123 | __asm__("mrrc p15, " #nr ", %Q0, %R0, c2" \ |
| 124 | : "=r" (ttbr)); \ |
| 125 | ttbr; \ |
| 126 | }) |
| 127 | |
Catalin Marinas | da02877 | 2011-11-22 17:30:29 +0000 | [diff] [blame] | 128 | #define cpu_get_pgd() \ |
| 129 | ({ \ |
Cyril Chemparathy | 1fc84ae | 2012-07-16 17:20:17 -0400 | [diff] [blame] | 130 | u64 pg = cpu_get_ttbr(0); \ |
Catalin Marinas | da02877 | 2011-11-22 17:30:29 +0000 | [diff] [blame] | 131 | pg &= ~(PTRS_PER_PGD*sizeof(pgd_t)-1); \ |
| 132 | (pgd_t *)phys_to_virt(pg); \ |
| 133 | }) |
| 134 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | #define cpu_get_pgd() \ |
| 136 | ({ \ |
| 137 | unsigned long pg; \ |
| 138 | __asm__("mrc p15, 0, %0, c2, c0, 0" \ |
| 139 | : "=r" (pg) : : "cc"); \ |
| 140 | pg &= ~0x3fff; \ |
| 141 | (pgd_t *)phys_to_virt(pg); \ |
| 142 | }) |
Catalin Marinas | da02877 | 2011-11-22 17:30:29 +0000 | [diff] [blame] | 143 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
Will Deacon | 02ed1c7 | 2012-02-28 14:26:42 +0000 | [diff] [blame] | 145 | #else /*!CONFIG_MMU */ |
| 146 | |
| 147 | #define cpu_switch_mm(pgd,mm) { } |
| 148 | |
Russell King | 002547b | 2006-06-20 20:46:52 +0100 | [diff] [blame] | 149 | #endif |
| 150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | #endif /* __ASSEMBLY__ */ |
| 152 | #endif /* __KERNEL__ */ |
| 153 | #endif /* __ASM_PROCFNS_H */ |