blob: e25f4392e1b2868446de858701d408aaaee26eab [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Russell King4baa9922008-08-02 10:55:55 +01002 * arch/arm/include/asm/proc-fns.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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 King753790e2011-02-06 15:32:24 +000016#include <asm/glue-proc.h>
17#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19#ifndef __ASSEMBLY__
20
Russell King753790e2011-02-06 15:32:24 +000021struct mm_struct;
22
23/*
24 * Don't change this structure - ASM code relies on it.
25 */
26extern 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 /*
Russell King9d3a0492018-05-10 13:07:29 +010040 * Check for processor bugs
41 */
42 void (*check_bugs)(void);
43 /*
Russell King753790e2011-02-06 15:32:24 +000044 * Disable any processor specifics
45 */
46 void (*_proc_fin)(void);
47 /*
48 * Special stuff for a reset
49 */
Russell King9da5ac22017-04-03 19:37:46 +010050 void (*reset)(unsigned long addr, bool hvc) __attribute__((noreturn));
Russell King753790e2011-02-06 15:32:24 +000051 /*
52 * Idle the processor
53 */
54 int (*_do_idle)(void);
55 /*
56 * Processor architecture specific
57 */
58 /*
59 * clean a virtual address range from the
60 * D-cache without flushing the cache.
61 */
62 void (*dcache_clean_area)(void *addr, int size);
63
64 /*
65 * Set the page table
66 */
Cyril Chemparathy13f659b2012-07-16 15:37:06 -040067 void (*switch_mm)(phys_addr_t pgd_phys, struct mm_struct *mm);
Russell King753790e2011-02-06 15:32:24 +000068 /*
69 * Set a possibly extended PTE. Non-extended PTEs should
70 * ignore 'ext'.
71 */
Catalin Marinasda028772011-11-22 17:30:29 +000072#ifdef CONFIG_ARM_LPAE
73 void (*set_pte_ext)(pte_t *ptep, pte_t pte);
74#else
Russell King753790e2011-02-06 15:32:24 +000075 void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext);
Catalin Marinasda028772011-11-22 17:30:29 +000076#endif
Russell Kingf6b0fa02011-02-06 15:48:39 +000077
78 /* Suspend/resume */
79 unsigned int suspend_size;
80 void (*do_suspend)(void *);
81 void (*do_resume)(void *);
Russell King753790e2011-02-06 15:32:24 +000082} processor;
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#ifndef MULTI_CPU
Russell King753790e2011-02-06 15:32:24 +000085extern void cpu_proc_init(void);
86extern void cpu_proc_fin(void);
87extern int cpu_do_idle(void);
88extern void cpu_dcache_clean_area(void *, int);
Cyril Chemparathy13f659b2012-07-16 15:37:06 -040089extern void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
Catalin Marinasda028772011-11-22 17:30:29 +000090#ifdef CONFIG_ARM_LPAE
91extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte);
92#else
Russell King753790e2011-02-06 15:32:24 +000093extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext);
Catalin Marinasda028772011-11-22 17:30:29 +000094#endif
Russell King9da5ac22017-04-03 19:37:46 +010095extern void cpu_reset(unsigned long addr, bool hvc) __attribute__((noreturn));
Russell Kingabda1bd2011-09-01 11:52:33 +010096
97/* These three are private to arch/arm/kernel/suspend.c */
98extern void cpu_do_suspend(void *);
99extern void cpu_do_resume(void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100#else
Will Deaconeca5dc22011-07-01 14:37:08 +0100101#define cpu_proc_init processor._proc_init
102#define cpu_proc_fin processor._proc_fin
103#define cpu_reset processor.reset
104#define cpu_do_idle processor._do_idle
105#define cpu_dcache_clean_area processor.dcache_clean_area
106#define cpu_set_pte_ext processor.set_pte_ext
107#define cpu_do_switch_mm processor.switch_mm
Russell Kingabda1bd2011-09-01 11:52:33 +0100108
109/* These three are private to arch/arm/kernel/suspend.c */
110#define cpu_do_suspend processor.do_suspend
111#define cpu_do_resume processor.do_resume
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#endif
113
Russell Kingf6b0fa02011-02-06 15:48:39 +0000114extern void cpu_resume(void);
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#include <asm/memory.h>
117
Russell King002547b2006-06-20 20:46:52 +0100118#ifdef CONFIG_MMU
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120#define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm)
121
Catalin Marinasda028772011-11-22 17:30:29 +0000122#ifdef CONFIG_ARM_LPAE
Cyril Chemparathy1fc84ae2012-07-16 17:20:17 -0400123
124#define cpu_get_ttbr(nr) \
125 ({ \
126 u64 ttbr; \
127 __asm__("mrrc p15, " #nr ", %Q0, %R0, c2" \
128 : "=r" (ttbr)); \
129 ttbr; \
130 })
131
Catalin Marinasda028772011-11-22 17:30:29 +0000132#define cpu_get_pgd() \
133 ({ \
Cyril Chemparathy1fc84ae2012-07-16 17:20:17 -0400134 u64 pg = cpu_get_ttbr(0); \
Catalin Marinasda028772011-11-22 17:30:29 +0000135 pg &= ~(PTRS_PER_PGD*sizeof(pgd_t)-1); \
136 (pgd_t *)phys_to_virt(pg); \
137 })
138#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#define cpu_get_pgd() \
140 ({ \
141 unsigned long pg; \
142 __asm__("mrc p15, 0, %0, c2, c0, 0" \
143 : "=r" (pg) : : "cc"); \
144 pg &= ~0x3fff; \
145 (pgd_t *)phys_to_virt(pg); \
146 })
Catalin Marinasda028772011-11-22 17:30:29 +0000147#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Will Deacon02ed1c72012-02-28 14:26:42 +0000149#else /*!CONFIG_MMU */
150
151#define cpu_switch_mm(pgd,mm) { }
152
Russell King002547b2006-06-20 20:46:52 +0100153#endif
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#endif /* __ASSEMBLY__ */
156#endif /* __KERNEL__ */
157#endif /* __ASM_PROCFNS_H */