Nicholas Flintham | 1e3d311 | 2013-04-10 10:48:38 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * arch/arm/include/asm/proc-fns.h |
| 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 | |
| 16 | #include <asm/glue-proc.h> |
| 17 | #include <asm/page.h> |
| 18 | |
| 19 | #ifndef __ASSEMBLY__ |
| 20 | |
| 21 | struct mm_struct; |
| 22 | |
| 23 | extern struct processor { |
| 24 | void (*_data_abort)(unsigned long pc); |
| 25 | unsigned long (*_prefetch_abort)(unsigned long lr); |
| 26 | void (*_proc_init)(void); |
| 27 | void (*_proc_fin)(void); |
| 28 | void (*reset)(unsigned long addr) __attribute__((noreturn)); |
| 29 | int (*_do_idle)(void); |
| 30 | void (*dcache_clean_area)(void *addr, int size); |
| 31 | |
| 32 | void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *mm); |
| 33 | #ifdef CONFIG_ARM_LPAE |
| 34 | void (*set_pte_ext)(pte_t *ptep, pte_t pte); |
| 35 | #else |
| 36 | void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext); |
| 37 | #endif |
| 38 | |
| 39 | |
| 40 | unsigned int suspend_size; |
| 41 | void (*do_suspend)(void *); |
| 42 | void (*do_resume)(void *); |
| 43 | } processor; |
| 44 | |
| 45 | #ifndef MULTI_CPU |
| 46 | extern void cpu_proc_init(void); |
| 47 | extern void cpu_proc_fin(void); |
| 48 | extern int cpu_do_idle(void); |
| 49 | extern void cpu_dcache_clean_area(void *, int); |
| 50 | extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm); |
| 51 | #ifdef CONFIG_ARM_LPAE |
| 52 | extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte); |
| 53 | #else |
| 54 | extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext); |
| 55 | #endif |
| 56 | extern void cpu_reset(unsigned long addr) __attribute__((noreturn)); |
| 57 | |
| 58 | extern void cpu_do_suspend(void *); |
| 59 | extern void cpu_do_resume(void *); |
| 60 | #else |
| 61 | #define cpu_proc_init processor._proc_init |
| 62 | #define cpu_proc_fin processor._proc_fin |
| 63 | #define cpu_reset processor.reset |
| 64 | #define cpu_do_idle processor._do_idle |
| 65 | #define cpu_dcache_clean_area processor.dcache_clean_area |
| 66 | #define cpu_set_pte_ext processor.set_pte_ext |
| 67 | #define cpu_do_switch_mm processor.switch_mm |
| 68 | |
| 69 | #define cpu_do_suspend processor.do_suspend |
| 70 | #define cpu_do_resume processor.do_resume |
| 71 | #endif |
| 72 | |
| 73 | extern void cpu_resume(void); |
| 74 | |
| 75 | #include <asm/memory.h> |
| 76 | |
| 77 | #ifdef CONFIG_MMU |
| 78 | |
| 79 | #define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm) |
| 80 | |
| 81 | #ifdef CONFIG_ARM_LPAE |
| 82 | #define cpu_get_pgd() \ |
| 83 | ({ \ |
| 84 | unsigned long pg, pg2; \ |
| 85 | __asm__("mrrc p15, 0, %0, %1, c2" \ |
| 86 | : "=r" (pg), "=r" (pg2) \ |
| 87 | : \ |
| 88 | : "cc"); \ |
| 89 | pg &= ~(PTRS_PER_PGD*sizeof(pgd_t)-1); \ |
| 90 | (pgd_t *)phys_to_virt(pg); \ |
| 91 | }) |
| 92 | #else |
| 93 | #define cpu_get_pgd() \ |
| 94 | ({ \ |
| 95 | unsigned long pg; \ |
| 96 | __asm__("mrc p15, 0, %0, c2, c0, 0" \ |
| 97 | : "=r" (pg) : : "cc"); \ |
| 98 | pg &= ~0x3fff; \ |
| 99 | (pgd_t *)phys_to_virt(pg); \ |
| 100 | }) |
| 101 | #endif |
| 102 | |
| 103 | #endif |
| 104 | |
| 105 | #endif |
| 106 | #endif |
| 107 | #endif |