blob: 69802150be227c03cb74f442efb3188b5a09e1d2 [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 /*
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 */
63 void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *mm);
64 /*
65 * Set a possibly extended PTE. Non-extended PTEs should
66 * ignore 'ext'.
67 */
68 void (*set_pte_ext)(pte_t *ptep, pte_t pte, unsigned int ext);
69} processor;
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#ifndef MULTI_CPU
Russell King753790e2011-02-06 15:32:24 +000072extern void cpu_proc_init(void);
73extern void cpu_proc_fin(void);
74extern int cpu_do_idle(void);
75extern void cpu_dcache_clean_area(void *, int);
76extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm);
77extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext);
78extern void cpu_reset(unsigned long addr) __attribute__((noreturn));
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#else
Russell King753790e2011-02-06 15:32:24 +000080#define cpu_proc_init() processor._proc_init()
81#define cpu_proc_fin() processor._proc_fin()
82#define cpu_reset(addr) processor.reset(addr)
83#define cpu_do_idle() processor._do_idle()
84#define cpu_dcache_clean_area(addr,sz) processor.dcache_clean_area(addr,sz)
85#define cpu_set_pte_ext(ptep,pte,ext) processor.set_pte_ext(ptep,pte,ext)
86#define cpu_do_switch_mm(pgd,mm) processor.switch_mm(pgd,mm)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087#endif
88
89#include <asm/memory.h>
90
Russell King002547b2006-06-20 20:46:52 +010091#ifdef CONFIG_MMU
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm)
94
95#define cpu_get_pgd() \
96 ({ \
97 unsigned long pg; \
98 __asm__("mrc p15, 0, %0, c2, c0, 0" \
99 : "=r" (pg) : : "cc"); \
100 pg &= ~0x3fff; \
101 (pgd_t *)phys_to_virt(pg); \
102 })
103
Russell King002547b2006-06-20 20:46:52 +0100104#endif
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#endif /* __ASSEMBLY__ */
107#endif /* __KERNEL__ */
108#endif /* __ASM_PROCFNS_H */