diff options
Diffstat (limited to 'arch/sh')
68 files changed, 4081 insertions, 0 deletions
diff --git a/arch/sh/include/asm/auxvec.h b/arch/sh/include/asm/auxvec.h new file mode 100644 index 00000000000..483effd65e0 --- /dev/null +++ b/arch/sh/include/asm/auxvec.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef __ASM_SH_AUXVEC_H | ||
2 | #define __ASM_SH_AUXVEC_H | ||
3 | |||
4 | /* | ||
5 | * Architecture-neutral AT_ values in 0-17, leave some room | ||
6 | * for more of them. | ||
7 | */ | ||
8 | |||
9 | /* | ||
10 | * This entry gives some information about the FPU initialization | ||
11 | * performed by the kernel. | ||
12 | */ | ||
13 | #define AT_FPUCW 18 /* Used FPU control word. */ | ||
14 | |||
15 | #if defined(CONFIG_VSYSCALL) || !defined(__KERNEL__) | ||
16 | /* | ||
17 | * Only define this in the vsyscall case, the entry point to | ||
18 | * the vsyscall page gets placed here. The kernel will attempt | ||
19 | * to build a gate VMA we don't care about otherwise.. | ||
20 | */ | ||
21 | #define AT_SYSINFO_EHDR 33 | ||
22 | #endif | ||
23 | |||
24 | /* | ||
25 | * More complete cache descriptions than AT_[DIU]CACHEBSIZE. If the | ||
26 | * value is -1, then the cache doesn't exist. Otherwise: | ||
27 | * | ||
28 | * bit 0-3: Cache set-associativity; 0 means fully associative. | ||
29 | * bit 4-7: Log2 of cacheline size. | ||
30 | * bit 8-31: Size of the entire cache >> 8. | ||
31 | */ | ||
32 | #define AT_L1I_CACHESHAPE 34 | ||
33 | #define AT_L1D_CACHESHAPE 35 | ||
34 | #define AT_L2_CACHESHAPE 36 | ||
35 | |||
36 | #endif /* __ASM_SH_AUXVEC_H */ | ||
diff --git a/arch/sh/include/asm/bitsperlong.h b/arch/sh/include/asm/bitsperlong.h new file mode 100644 index 00000000000..6dc0bb0c13b --- /dev/null +++ b/arch/sh/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/sh/include/asm/byteorder.h b/arch/sh/include/asm/byteorder.h new file mode 100644 index 00000000000..db2f5d7cb17 --- /dev/null +++ b/arch/sh/include/asm/byteorder.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __ASM_SH_BYTEORDER_H | ||
2 | #define __ASM_SH_BYTEORDER_H | ||
3 | |||
4 | #ifdef __LITTLE_ENDIAN__ | ||
5 | #include <linux/byteorder/little_endian.h> | ||
6 | #else | ||
7 | #include <linux/byteorder/big_endian.h> | ||
8 | #endif | ||
9 | |||
10 | #endif /* __ASM_SH_BYTEORDER_H */ | ||
diff --git a/arch/sh/include/asm/cachectl.h b/arch/sh/include/asm/cachectl.h new file mode 100644 index 00000000000..6ffb4b7a212 --- /dev/null +++ b/arch/sh/include/asm/cachectl.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef _SH_CACHECTL_H | ||
2 | #define _SH_CACHECTL_H | ||
3 | |||
4 | /* Definitions for the cacheflush system call. */ | ||
5 | |||
6 | #define CACHEFLUSH_D_INVAL 0x1 /* invalidate (without write back) */ | ||
7 | #define CACHEFLUSH_D_WB 0x2 /* write back (without invalidate) */ | ||
8 | #define CACHEFLUSH_D_PURGE 0x3 /* writeback and invalidate */ | ||
9 | |||
10 | #define CACHEFLUSH_I 0x4 | ||
11 | |||
12 | /* | ||
13 | * Options for cacheflush system call | ||
14 | */ | ||
15 | #define ICACHE CACHEFLUSH_I /* flush instruction cache */ | ||
16 | #define DCACHE CACHEFLUSH_D_PURGE /* writeback and flush data cache */ | ||
17 | #define BCACHE (ICACHE|DCACHE) /* flush both caches */ | ||
18 | |||
19 | #endif /* _SH_CACHECTL_H */ | ||
diff --git a/arch/sh/include/asm/cpu-features.h b/arch/sh/include/asm/cpu-features.h new file mode 100644 index 00000000000..694abe490ed --- /dev/null +++ b/arch/sh/include/asm/cpu-features.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef __ASM_SH_CPU_FEATURES_H | ||
2 | #define __ASM_SH_CPU_FEATURES_H | ||
3 | |||
4 | /* | ||
5 | * Processor flags | ||
6 | * | ||
7 | * Note: When adding a new flag, keep cpu_flags[] in | ||
8 | * arch/sh/kernel/setup.c in sync so symbolic name | ||
9 | * mapping of the processor flags has a chance of being | ||
10 | * reasonably accurate. | ||
11 | * | ||
12 | * These flags are also available through the ELF | ||
13 | * auxiliary vector as AT_HWCAP. | ||
14 | */ | ||
15 | #define CPU_HAS_FPU 0x0001 /* Hardware FPU support */ | ||
16 | #define CPU_HAS_P2_FLUSH_BUG 0x0002 /* Need to flush the cache in P2 area */ | ||
17 | #define CPU_HAS_MMU_PAGE_ASSOC 0x0004 /* SH3: TLB way selection bit support */ | ||
18 | #define CPU_HAS_DSP 0x0008 /* SH-DSP: DSP support */ | ||
19 | #define CPU_HAS_PERF_COUNTER 0x0010 /* Hardware performance counters */ | ||
20 | #define CPU_HAS_PTEA 0x0020 /* PTEA register */ | ||
21 | #define CPU_HAS_LLSC 0x0040 /* movli.l/movco.l */ | ||
22 | #define CPU_HAS_L2_CACHE 0x0080 /* Secondary cache / URAM */ | ||
23 | #define CPU_HAS_OP32 0x0100 /* 32-bit instruction support */ | ||
24 | #define CPU_HAS_PTEAEX 0x0200 /* PTE ASID Extension support */ | ||
25 | |||
26 | #endif /* __ASM_SH_CPU_FEATURES_H */ | ||
diff --git a/arch/sh/include/asm/cputime.h b/arch/sh/include/asm/cputime.h new file mode 100644 index 00000000000..6ca395d1393 --- /dev/null +++ b/arch/sh/include/asm/cputime.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __SH_CPUTIME_H | ||
2 | #define __SH_CPUTIME_H | ||
3 | |||
4 | #include <asm-generic/cputime.h> | ||
5 | |||
6 | #endif /* __SH_CPUTIME_H */ | ||
diff --git a/arch/sh/include/asm/current.h b/arch/sh/include/asm/current.h new file mode 100644 index 00000000000..4c51401b553 --- /dev/null +++ b/arch/sh/include/asm/current.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/current.h> | |||
diff --git a/arch/sh/include/asm/delay.h b/arch/sh/include/asm/delay.h new file mode 100644 index 00000000000..9670e127b7b --- /dev/null +++ b/arch/sh/include/asm/delay.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/delay.h> | |||
diff --git a/arch/sh/include/asm/div64.h b/arch/sh/include/asm/div64.h new file mode 100644 index 00000000000..6cd978cefb2 --- /dev/null +++ b/arch/sh/include/asm/div64.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/div64.h> | |||
diff --git a/arch/sh/include/asm/dma-sh.h b/arch/sh/include/asm/dma-sh.h new file mode 100644 index 00000000000..f3acb8e34c6 --- /dev/null +++ b/arch/sh/include/asm/dma-sh.h | |||
@@ -0,0 +1,87 @@ | |||
1 | /* | ||
2 | * arch/sh/include/asm/dma-sh.h | ||
3 | * | ||
4 | * Copyright (C) 2000 Takashi YOSHII | ||
5 | * Copyright (C) 2003 Paul Mundt | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file "COPYING" in the main directory of this archive | ||
9 | * for more details. | ||
10 | */ | ||
11 | #ifndef __DMA_SH_H | ||
12 | #define __DMA_SH_H | ||
13 | |||
14 | #include <asm/dma-register.h> | ||
15 | #include <cpu/dma-register.h> | ||
16 | #include <cpu/dma.h> | ||
17 | |||
18 | /* DMAOR contorl: The DMAOR access size is different by CPU.*/ | ||
19 | #if defined(CONFIG_CPU_SUBTYPE_SH7723) || \ | ||
20 | defined(CONFIG_CPU_SUBTYPE_SH7724) || \ | ||
21 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ | ||
22 | defined(CONFIG_CPU_SUBTYPE_SH7785) | ||
23 | #define dmaor_read_reg(n) \ | ||
24 | (n ? __raw_readw(SH_DMAC_BASE1 + DMAOR) \ | ||
25 | : __raw_readw(SH_DMAC_BASE0 + DMAOR)) | ||
26 | #define dmaor_write_reg(n, data) \ | ||
27 | (n ? __raw_writew(data, SH_DMAC_BASE1 + DMAOR) \ | ||
28 | : __raw_writew(data, SH_DMAC_BASE0 + DMAOR)) | ||
29 | #else /* Other CPU */ | ||
30 | #define dmaor_read_reg(n) __raw_readw(SH_DMAC_BASE0 + DMAOR) | ||
31 | #define dmaor_write_reg(n, data) __raw_writew(data, SH_DMAC_BASE0 + DMAOR) | ||
32 | #endif | ||
33 | |||
34 | static int dmte_irq_map[] __maybe_unused = { | ||
35 | #if (MAX_DMA_CHANNELS >= 4) | ||
36 | DMTE0_IRQ, | ||
37 | DMTE0_IRQ + 1, | ||
38 | DMTE0_IRQ + 2, | ||
39 | DMTE0_IRQ + 3, | ||
40 | #endif | ||
41 | #if (MAX_DMA_CHANNELS >= 6) | ||
42 | DMTE4_IRQ, | ||
43 | DMTE4_IRQ + 1, | ||
44 | #endif | ||
45 | #if (MAX_DMA_CHANNELS >= 8) | ||
46 | DMTE6_IRQ, | ||
47 | DMTE6_IRQ + 1, | ||
48 | #endif | ||
49 | #if (MAX_DMA_CHANNELS >= 12) | ||
50 | DMTE8_IRQ, | ||
51 | DMTE9_IRQ, | ||
52 | DMTE10_IRQ, | ||
53 | DMTE11_IRQ, | ||
54 | #endif | ||
55 | }; | ||
56 | |||
57 | /* | ||
58 | * Define the default configuration for dual address memory-memory transfer. | ||
59 | * The 0x400 value represents auto-request, external->external. | ||
60 | */ | ||
61 | #define RS_DUAL (DM_INC | SM_INC | 0x400 | TS_INDEX2VAL(XMIT_SZ_32BIT)) | ||
62 | |||
63 | /* DMA base address */ | ||
64 | static u32 dma_base_addr[] __maybe_unused = { | ||
65 | #if (MAX_DMA_CHANNELS >= 4) | ||
66 | SH_DMAC_BASE0 + 0x00, /* channel 0 */ | ||
67 | SH_DMAC_BASE0 + 0x10, | ||
68 | SH_DMAC_BASE0 + 0x20, | ||
69 | SH_DMAC_BASE0 + 0x30, | ||
70 | #endif | ||
71 | #if (MAX_DMA_CHANNELS >= 6) | ||
72 | SH_DMAC_BASE0 + 0x50, | ||
73 | SH_DMAC_BASE0 + 0x60, | ||
74 | #endif | ||
75 | #if (MAX_DMA_CHANNELS >= 8) | ||
76 | SH_DMAC_BASE1 + 0x00, | ||
77 | SH_DMAC_BASE1 + 0x10, | ||
78 | #endif | ||
79 | #if (MAX_DMA_CHANNELS >= 12) | ||
80 | SH_DMAC_BASE1 + 0x20, | ||
81 | SH_DMAC_BASE1 + 0x30, | ||
82 | SH_DMAC_BASE1 + 0x50, | ||
83 | SH_DMAC_BASE1 + 0x60, /* channel 11 */ | ||
84 | #endif | ||
85 | }; | ||
86 | |||
87 | #endif /* __DMA_SH_H */ | ||
diff --git a/arch/sh/include/asm/emergency-restart.h b/arch/sh/include/asm/emergency-restart.h new file mode 100644 index 00000000000..108d8c48e42 --- /dev/null +++ b/arch/sh/include/asm/emergency-restart.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASM_EMERGENCY_RESTART_H | ||
2 | #define _ASM_EMERGENCY_RESTART_H | ||
3 | |||
4 | #include <asm-generic/emergency-restart.h> | ||
5 | |||
6 | #endif /* _ASM_EMERGENCY_RESTART_H */ | ||
diff --git a/arch/sh/include/asm/errno.h b/arch/sh/include/asm/errno.h new file mode 100644 index 00000000000..51cf6f9cebb --- /dev/null +++ b/arch/sh/include/asm/errno.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_SH_ERRNO_H | ||
2 | #define __ASM_SH_ERRNO_H | ||
3 | |||
4 | #include <asm-generic/errno.h> | ||
5 | |||
6 | #endif /* __ASM_SH_ERRNO_H */ | ||
diff --git a/arch/sh/include/asm/fcntl.h b/arch/sh/include/asm/fcntl.h new file mode 100644 index 00000000000..46ab12db573 --- /dev/null +++ b/arch/sh/include/asm/fcntl.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/fcntl.h> | |||
diff --git a/arch/sh/include/asm/hwblk.h b/arch/sh/include/asm/hwblk.h new file mode 100644 index 00000000000..855e945c619 --- /dev/null +++ b/arch/sh/include/asm/hwblk.h | |||
@@ -0,0 +1,70 @@ | |||
1 | #ifndef __ASM_SH_HWBLK_H | ||
2 | #define __ASM_SH_HWBLK_H | ||
3 | |||
4 | #include <asm/clock.h> | ||
5 | #include <asm/io.h> | ||
6 | |||
7 | #define HWBLK_CNT_USAGE 0 | ||
8 | #define HWBLK_CNT_IDLE 1 | ||
9 | #define HWBLK_CNT_DEVICES 2 | ||
10 | #define HWBLK_CNT_NR 3 | ||
11 | |||
12 | #define HWBLK_AREA_FLAG_PARENT (1 << 0) /* valid parent */ | ||
13 | |||
14 | #define HWBLK_AREA(_flags, _parent) \ | ||
15 | { \ | ||
16 | .flags = _flags, \ | ||
17 | .parent = _parent, \ | ||
18 | } | ||
19 | |||
20 | struct hwblk_area { | ||
21 | int cnt[HWBLK_CNT_NR]; | ||
22 | unsigned char parent; | ||
23 | unsigned char flags; | ||
24 | }; | ||
25 | |||
26 | #define HWBLK(_mstp, _bit, _area) \ | ||
27 | { \ | ||
28 | .mstp = (void __iomem *)_mstp, \ | ||
29 | .bit = _bit, \ | ||
30 | .area = _area, \ | ||
31 | } | ||
32 | |||
33 | struct hwblk { | ||
34 | void __iomem *mstp; | ||
35 | unsigned char bit; | ||
36 | unsigned char area; | ||
37 | int cnt[HWBLK_CNT_NR]; | ||
38 | }; | ||
39 | |||
40 | struct hwblk_info { | ||
41 | struct hwblk_area *areas; | ||
42 | int nr_areas; | ||
43 | struct hwblk *hwblks; | ||
44 | int nr_hwblks; | ||
45 | }; | ||
46 | |||
47 | /* Should be defined by processor-specific code */ | ||
48 | int arch_hwblk_init(void); | ||
49 | int arch_hwblk_sleep_mode(void); | ||
50 | |||
51 | int hwblk_register(struct hwblk_info *info); | ||
52 | int hwblk_init(void); | ||
53 | |||
54 | void hwblk_enable(struct hwblk_info *info, int hwblk); | ||
55 | void hwblk_disable(struct hwblk_info *info, int hwblk); | ||
56 | |||
57 | void hwblk_cnt_inc(struct hwblk_info *info, int hwblk, int cnt); | ||
58 | void hwblk_cnt_dec(struct hwblk_info *info, int hwblk, int cnt); | ||
59 | |||
60 | /* allow clocks to enable and disable hardware blocks */ | ||
61 | #define SH_HWBLK_CLK(_hwblk, _parent, _flags) \ | ||
62 | [_hwblk] = { \ | ||
63 | .parent = _parent, \ | ||
64 | .arch_flags = _hwblk, \ | ||
65 | .flags = _flags, \ | ||
66 | } | ||
67 | |||
68 | int sh_hwblk_clk_register(struct clk *clks, int nr); | ||
69 | |||
70 | #endif /* __ASM_SH_HWBLK_H */ | ||
diff --git a/arch/sh/include/asm/ioctl.h b/arch/sh/include/asm/ioctl.h new file mode 100644 index 00000000000..b279fe06dfe --- /dev/null +++ b/arch/sh/include/asm/ioctl.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/ioctl.h> | |||
diff --git a/arch/sh/include/asm/ioctls.h b/arch/sh/include/asm/ioctls.h new file mode 100644 index 00000000000..a6769f352bf --- /dev/null +++ b/arch/sh/include/asm/ioctls.h | |||
@@ -0,0 +1,107 @@ | |||
1 | #ifndef __ASM_SH_IOCTLS_H | ||
2 | #define __ASM_SH_IOCTLS_H | ||
3 | |||
4 | #include <asm/ioctl.h> | ||
5 | |||
6 | #define FIOCLEX _IO('f', 1) | ||
7 | #define FIONCLEX _IO('f', 2) | ||
8 | #define FIOASYNC _IOW('f', 125, int) | ||
9 | #define FIONBIO _IOW('f', 126, int) | ||
10 | #define FIONREAD _IOR('f', 127, int) | ||
11 | #define TIOCINQ FIONREAD | ||
12 | #define FIOQSIZE _IOR('f', 128, loff_t) | ||
13 | |||
14 | #define TCGETS 0x5401 | ||
15 | #define TCSETS 0x5402 | ||
16 | #define TCSETSW 0x5403 | ||
17 | #define TCSETSF 0x5404 | ||
18 | |||
19 | #define TCGETA 0x80127417 /* _IOR('t', 23, struct termio) */ | ||
20 | #define TCSETA 0x40127418 /* _IOW('t', 24, struct termio) */ | ||
21 | #define TCSETAW 0x40127419 /* _IOW('t', 25, struct termio) */ | ||
22 | #define TCSETAF 0x4012741C /* _IOW('t', 28, struct termio) */ | ||
23 | |||
24 | #define TCSBRK _IO('t', 29) | ||
25 | #define TCXONC _IO('t', 30) | ||
26 | #define TCFLSH _IO('t', 31) | ||
27 | |||
28 | #define TIOCSWINSZ 0x40087467 /* _IOW('t', 103, struct winsize) */ | ||
29 | #define TIOCGWINSZ 0x80087468 /* _IOR('t', 104, struct winsize) */ | ||
30 | #define TIOCSTART _IO('t', 110) /* start output, like ^Q */ | ||
31 | #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ | ||
32 | #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ | ||
33 | |||
34 | #define TIOCSPGRP _IOW('t', 118, int) | ||
35 | #define TIOCGPGRP _IOR('t', 119, int) | ||
36 | |||
37 | #define TIOCEXCL _IO('T', 12) /* 0x540C */ | ||
38 | #define TIOCNXCL _IO('T', 13) /* 0x540D */ | ||
39 | #define TIOCSCTTY _IO('T', 14) /* 0x540E */ | ||
40 | |||
41 | #define TIOCSTI _IOW('T', 18, char) /* 0x5412 */ | ||
42 | #define TIOCMGET _IOR('T', 21, unsigned int) /* 0x5415 */ | ||
43 | #define TIOCMBIS _IOW('T', 22, unsigned int) /* 0x5416 */ | ||
44 | #define TIOCMBIC _IOW('T', 23, unsigned int) /* 0x5417 */ | ||
45 | #define TIOCMSET _IOW('T', 24, unsigned int) /* 0x5418 */ | ||
46 | # define TIOCM_LE 0x001 | ||
47 | # define TIOCM_DTR 0x002 | ||
48 | # define TIOCM_RTS 0x004 | ||
49 | # define TIOCM_ST 0x008 | ||
50 | # define TIOCM_SR 0x010 | ||
51 | # define TIOCM_CTS 0x020 | ||
52 | # define TIOCM_CAR 0x040 | ||
53 | # define TIOCM_RNG 0x080 | ||
54 | # define TIOCM_DSR 0x100 | ||
55 | # define TIOCM_CD TIOCM_CAR | ||
56 | # define TIOCM_RI TIOCM_RNG | ||
57 | |||
58 | #define TIOCGSOFTCAR _IOR('T', 25, unsigned int) /* 0x5419 */ | ||
59 | #define TIOCSSOFTCAR _IOW('T', 26, unsigned int) /* 0x541A */ | ||
60 | #define TIOCLINUX _IOW('T', 28, char) /* 0x541C */ | ||
61 | #define TIOCCONS _IO('T', 29) /* 0x541D */ | ||
62 | #define TIOCGSERIAL 0x803C541E /* _IOR('T', 30, struct serial_struct) 0x541E */ | ||
63 | #define TIOCSSERIAL 0x403C541F /* _IOW('T', 31, struct serial_struct) 0x541F */ | ||
64 | #define TIOCPKT _IOW('T', 32, int) /* 0x5420 */ | ||
65 | # define TIOCPKT_DATA 0 | ||
66 | # define TIOCPKT_FLUSHREAD 1 | ||
67 | # define TIOCPKT_FLUSHWRITE 2 | ||
68 | # define TIOCPKT_STOP 4 | ||
69 | # define TIOCPKT_START 8 | ||
70 | # define TIOCPKT_NOSTOP 16 | ||
71 | # define TIOCPKT_DOSTOP 32 | ||
72 | # define TIOCPKT_IOCTL 64 | ||
73 | |||
74 | |||
75 | #define TIOCNOTTY _IO('T', 34) /* 0x5422 */ | ||
76 | #define TIOCSETD _IOW('T', 35, int) /* 0x5423 */ | ||
77 | #define TIOCGETD _IOR('T', 36, int) /* 0x5424 */ | ||
78 | #define TCSBRKP _IOW('T', 37, int) /* 0x5425 */ /* Needed for POSIX tcsendbreak() */ | ||
79 | #define TIOCSBRK _IO('T', 39) /* 0x5427 */ /* BSD compatibility */ | ||
80 | #define TIOCCBRK _IO('T', 40) /* 0x5428 */ /* BSD compatibility */ | ||
81 | #define TIOCGSID _IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session ID of FD */ | ||
82 | #define TCGETS2 _IOR('T', 42, struct termios2) | ||
83 | #define TCSETS2 _IOW('T', 43, struct termios2) | ||
84 | #define TCSETSW2 _IOW('T', 44, struct termios2) | ||
85 | #define TCSETSF2 _IOW('T', 45, struct termios2) | ||
86 | #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ | ||
87 | #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ | ||
88 | #define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */ | ||
89 | #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ | ||
90 | #define TIOCVHANGUP _IO('T', 0x37) | ||
91 | |||
92 | #define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */ | ||
93 | #define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */ | ||
94 | #define TIOCSERSWILD _IOW('T', 85, int) /* 0x5455 */ | ||
95 | #define TIOCGLCKTRMIOS 0x5456 | ||
96 | #define TIOCSLCKTRMIOS 0x5457 | ||
97 | #define TIOCSERGSTRUCT 0x80d85458 /* _IOR('T', 88, struct async_struct) 0x5458 */ /* For debugging only */ | ||
98 | #define TIOCSERGETLSR _IOR('T', 89, unsigned int) /* 0x5459 */ /* Get line status register */ | ||
99 | /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ | ||
100 | # define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ | ||
101 | #define TIOCSERGETMULTI 0x80A8545A /* _IOR('T', 90, struct serial_multiport_struct) 0x545A */ /* Get multiport config */ | ||
102 | #define TIOCSERSETMULTI 0x40A8545B /* _IOW('T', 91, struct serial_multiport_struct) 0x545B */ /* Set multiport config */ | ||
103 | |||
104 | #define TIOCMIWAIT _IO('T', 92) /* 0x545C */ /* wait for a change on serial input line(s) */ | ||
105 | #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ | ||
106 | |||
107 | #endif /* __ASM_SH_IOCTLS_H */ | ||
diff --git a/arch/sh/include/asm/ipcbuf.h b/arch/sh/include/asm/ipcbuf.h new file mode 100644 index 00000000000..84c7e51cb6d --- /dev/null +++ b/arch/sh/include/asm/ipcbuf.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/ipcbuf.h> | |||
diff --git a/arch/sh/include/asm/irq_regs.h b/arch/sh/include/asm/irq_regs.h new file mode 100644 index 00000000000..3dd9c0b7027 --- /dev/null +++ b/arch/sh/include/asm/irq_regs.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/irq_regs.h> | |||
diff --git a/arch/sh/include/asm/local.h b/arch/sh/include/asm/local.h new file mode 100644 index 00000000000..9ed9b9cb459 --- /dev/null +++ b/arch/sh/include/asm/local.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef __ASM_SH_LOCAL_H | ||
2 | #define __ASM_SH_LOCAL_H | ||
3 | |||
4 | #include <asm-generic/local.h> | ||
5 | |||
6 | #endif /* __ASM_SH_LOCAL_H */ | ||
7 | |||
diff --git a/arch/sh/include/asm/local64.h b/arch/sh/include/asm/local64.h new file mode 100644 index 00000000000..36c93b5cc23 --- /dev/null +++ b/arch/sh/include/asm/local64.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/local64.h> | |||
diff --git a/arch/sh/include/asm/memblock.h b/arch/sh/include/asm/memblock.h new file mode 100644 index 00000000000..e87063fad2e --- /dev/null +++ b/arch/sh/include/asm/memblock.h | |||
@@ -0,0 +1,4 @@ | |||
1 | #ifndef __ASM_SH_MEMBLOCK_H | ||
2 | #define __ASM_SH_MEMBLOCK_H | ||
3 | |||
4 | #endif /* __ASM_SH_MEMBLOCK_H */ | ||
diff --git a/arch/sh/include/asm/mman.h b/arch/sh/include/asm/mman.h new file mode 100644 index 00000000000..8eebf89f5ab --- /dev/null +++ b/arch/sh/include/asm/mman.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/mman.h> | |||
diff --git a/arch/sh/include/asm/msgbuf.h b/arch/sh/include/asm/msgbuf.h new file mode 100644 index 00000000000..809134c644a --- /dev/null +++ b/arch/sh/include/asm/msgbuf.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/msgbuf.h> | |||
diff --git a/arch/sh/include/asm/param.h b/arch/sh/include/asm/param.h new file mode 100644 index 00000000000..965d4542797 --- /dev/null +++ b/arch/sh/include/asm/param.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/param.h> | |||
diff --git a/arch/sh/include/asm/parport.h b/arch/sh/include/asm/parport.h new file mode 100644 index 00000000000..cf252af6459 --- /dev/null +++ b/arch/sh/include/asm/parport.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/parport.h> | |||
diff --git a/arch/sh/include/asm/percpu.h b/arch/sh/include/asm/percpu.h new file mode 100644 index 00000000000..4db4b39a439 --- /dev/null +++ b/arch/sh/include/asm/percpu.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ARCH_SH_PERCPU | ||
2 | #define __ARCH_SH_PERCPU | ||
3 | |||
4 | #include <asm-generic/percpu.h> | ||
5 | |||
6 | #endif /* __ARCH_SH_PERCPU */ | ||
diff --git a/arch/sh/include/asm/poll.h b/arch/sh/include/asm/poll.h new file mode 100644 index 00000000000..c98509d3149 --- /dev/null +++ b/arch/sh/include/asm/poll.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/poll.h> | |||
diff --git a/arch/sh/include/asm/posix_types_32.h b/arch/sh/include/asm/posix_types_32.h new file mode 100644 index 00000000000..6a9ceaaf1ae --- /dev/null +++ b/arch/sh/include/asm/posix_types_32.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef __ASM_SH_POSIX_TYPES_32_H | ||
2 | #define __ASM_SH_POSIX_TYPES_32_H | ||
3 | |||
4 | typedef unsigned short __kernel_mode_t; | ||
5 | #define __kernel_mode_t __kernel_mode_t | ||
6 | typedef unsigned short __kernel_nlink_t; | ||
7 | #define __kernel_nlink_t __kernel_nlink_t | ||
8 | typedef unsigned short __kernel_ipc_pid_t; | ||
9 | #define __kernel_ipc_pid_t __kernel_ipc_pid_t | ||
10 | typedef unsigned short __kernel_uid_t; | ||
11 | #define __kernel_uid_t __kernel_uid_t | ||
12 | typedef unsigned short __kernel_gid_t; | ||
13 | #define __kernel_gid_t __kernel_gid_t | ||
14 | |||
15 | typedef unsigned int __kernel_uid32_t; | ||
16 | #define __kernel_uid32_t __kernel_uid32_t | ||
17 | typedef unsigned int __kernel_gid32_t; | ||
18 | #define __kernel_gid32_t __kernel_gid32_t | ||
19 | |||
20 | typedef unsigned short __kernel_old_uid_t; | ||
21 | #define __kernel_old_uid_t __kernel_old_uid_t | ||
22 | typedef unsigned short __kernel_old_gid_t; | ||
23 | #define __kernel_old_gid_t __kernel_old_gid_t | ||
24 | typedef unsigned short __kernel_old_dev_t; | ||
25 | #define __kernel_old_dev_t __kernel_old_dev_t | ||
26 | |||
27 | #include <asm-generic/posix_types.h> | ||
28 | |||
29 | #endif /* __ASM_SH_POSIX_TYPES_32_H */ | ||
diff --git a/arch/sh/include/asm/posix_types_64.h b/arch/sh/include/asm/posix_types_64.h new file mode 100644 index 00000000000..8cd11485c06 --- /dev/null +++ b/arch/sh/include/asm/posix_types_64.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef __ASM_SH_POSIX_TYPES_64_H | ||
2 | #define __ASM_SH_POSIX_TYPES_64_H | ||
3 | |||
4 | typedef unsigned short __kernel_mode_t; | ||
5 | #define __kernel_mode_t __kernel_mode_t | ||
6 | typedef unsigned short __kernel_nlink_t; | ||
7 | #define __kernel_nlink_t __kernel_nlink_t | ||
8 | typedef unsigned short __kernel_ipc_pid_t; | ||
9 | #define __kernel_ipc_pid_t __kernel_ipc_pid_t | ||
10 | typedef unsigned short __kernel_uid_t; | ||
11 | #define __kernel_uid_t __kernel_uid_t | ||
12 | typedef unsigned short __kernel_gid_t; | ||
13 | #define __kernel_gid_t __kernel_gid_t | ||
14 | typedef long unsigned int __kernel_size_t; | ||
15 | #define __kernel_size_t __kernel_size_t | ||
16 | typedef int __kernel_ssize_t; | ||
17 | #define __kernel_ssize_t __kernel_ssize_t | ||
18 | typedef int __kernel_ptrdiff_t; | ||
19 | #define __kernel_ptrdiff_t __kernel_ptrdiff_t | ||
20 | typedef unsigned int __kernel_uid32_t; | ||
21 | #define __kernel_uid32_t __kernel_uid32_t | ||
22 | typedef unsigned int __kernel_gid32_t; | ||
23 | #define __kernel_gid32_t __kernel_gid32_t | ||
24 | |||
25 | typedef unsigned short __kernel_old_uid_t; | ||
26 | #define __kernel_old_uid_t __kernel_old_uid_t | ||
27 | typedef unsigned short __kernel_old_gid_t; | ||
28 | #define __kernel_old_gid_t __kernel_old_gid_t | ||
29 | typedef unsigned short __kernel_old_dev_t; | ||
30 | #define __kernel_old_dev_t __kernel_old_dev_t | ||
31 | |||
32 | #include <asm-generic/posix_types.h> | ||
33 | |||
34 | #endif /* __ASM_SH_POSIX_TYPES_64_H */ | ||
diff --git a/arch/sh/include/asm/resource.h b/arch/sh/include/asm/resource.h new file mode 100644 index 00000000000..9c2499a86ec --- /dev/null +++ b/arch/sh/include/asm/resource.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_SH_RESOURCE_H | ||
2 | #define __ASM_SH_RESOURCE_H | ||
3 | |||
4 | #include <asm-generic/resource.h> | ||
5 | |||
6 | #endif /* __ASM_SH_RESOURCE_H */ | ||
diff --git a/arch/sh/include/asm/scatterlist.h b/arch/sh/include/asm/scatterlist.h new file mode 100644 index 00000000000..98dfc3510f1 --- /dev/null +++ b/arch/sh/include/asm/scatterlist.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_SH_SCATTERLIST_H | ||
2 | #define __ASM_SH_SCATTERLIST_H | ||
3 | |||
4 | #include <asm-generic/scatterlist.h> | ||
5 | |||
6 | #endif /* __ASM_SH_SCATTERLIST_H */ | ||
diff --git a/arch/sh/include/asm/sembuf.h b/arch/sh/include/asm/sembuf.h new file mode 100644 index 00000000000..7673b83cfef --- /dev/null +++ b/arch/sh/include/asm/sembuf.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/sembuf.h> | |||
diff --git a/arch/sh/include/asm/serial.h b/arch/sh/include/asm/serial.h new file mode 100644 index 00000000000..a0cb0caff15 --- /dev/null +++ b/arch/sh/include/asm/serial.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/serial.h> | |||
diff --git a/arch/sh/include/asm/sh_eth.h b/arch/sh/include/asm/sh_eth.h new file mode 100644 index 00000000000..0f325da0f92 --- /dev/null +++ b/arch/sh/include/asm/sh_eth.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef __ASM_SH_ETH_H__ | ||
2 | #define __ASM_SH_ETH_H__ | ||
3 | |||
4 | #include <linux/phy.h> | ||
5 | |||
6 | enum {EDMAC_LITTLE_ENDIAN, EDMAC_BIG_ENDIAN}; | ||
7 | enum { | ||
8 | SH_ETH_REG_GIGABIT, | ||
9 | SH_ETH_REG_FAST_SH4, | ||
10 | SH_ETH_REG_FAST_SH3_SH2 | ||
11 | }; | ||
12 | |||
13 | struct sh_eth_plat_data { | ||
14 | int phy; | ||
15 | int edmac_endian; | ||
16 | int register_type; | ||
17 | phy_interface_t phy_interface; | ||
18 | void (*set_mdio_gate)(unsigned long addr); | ||
19 | |||
20 | unsigned char mac_addr[6]; | ||
21 | unsigned no_ether_link:1; | ||
22 | unsigned ether_link_active_low:1; | ||
23 | }; | ||
24 | |||
25 | #endif | ||
diff --git a/arch/sh/include/asm/shmbuf.h b/arch/sh/include/asm/shmbuf.h new file mode 100644 index 00000000000..83c05fc2de3 --- /dev/null +++ b/arch/sh/include/asm/shmbuf.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/shmbuf.h> | |||
diff --git a/arch/sh/include/asm/sigcontext.h b/arch/sh/include/asm/sigcontext.h new file mode 100644 index 00000000000..8ce1435bc0b --- /dev/null +++ b/arch/sh/include/asm/sigcontext.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef __ASM_SH_SIGCONTEXT_H | ||
2 | #define __ASM_SH_SIGCONTEXT_H | ||
3 | |||
4 | struct sigcontext { | ||
5 | unsigned long oldmask; | ||
6 | |||
7 | #if defined(__SH5__) || defined(CONFIG_CPU_SH5) | ||
8 | /* CPU registers */ | ||
9 | unsigned long long sc_regs[63]; | ||
10 | unsigned long long sc_tregs[8]; | ||
11 | unsigned long long sc_pc; | ||
12 | unsigned long long sc_sr; | ||
13 | |||
14 | /* FPU registers */ | ||
15 | unsigned long long sc_fpregs[32]; | ||
16 | unsigned int sc_fpscr; | ||
17 | unsigned int sc_fpvalid; | ||
18 | #else | ||
19 | /* CPU registers */ | ||
20 | unsigned long sc_regs[16]; | ||
21 | unsigned long sc_pc; | ||
22 | unsigned long sc_pr; | ||
23 | unsigned long sc_sr; | ||
24 | unsigned long sc_gbr; | ||
25 | unsigned long sc_mach; | ||
26 | unsigned long sc_macl; | ||
27 | |||
28 | #if defined(__SH4__) || defined(CONFIG_CPU_SH4) || \ | ||
29 | defined(__SH2A__) || defined(CONFIG_CPU_SH2A) | ||
30 | /* FPU registers */ | ||
31 | unsigned long sc_fpregs[16]; | ||
32 | unsigned long sc_xfpregs[16]; | ||
33 | unsigned int sc_fpscr; | ||
34 | unsigned int sc_fpul; | ||
35 | unsigned int sc_ownedfp; | ||
36 | #endif | ||
37 | #endif | ||
38 | }; | ||
39 | |||
40 | #endif /* __ASM_SH_SIGCONTEXT_H */ | ||
diff --git a/arch/sh/include/asm/siginfo.h b/arch/sh/include/asm/siginfo.h new file mode 100644 index 00000000000..813040ed68a --- /dev/null +++ b/arch/sh/include/asm/siginfo.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_SH_SIGINFO_H | ||
2 | #define __ASM_SH_SIGINFO_H | ||
3 | |||
4 | #include <asm-generic/siginfo.h> | ||
5 | |||
6 | #endif /* __ASM_SH_SIGINFO_H */ | ||
diff --git a/arch/sh/include/asm/signal.h b/arch/sh/include/asm/signal.h new file mode 100644 index 00000000000..9ac530a90bc --- /dev/null +++ b/arch/sh/include/asm/signal.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef __ASM_SH_SIGNAL_H | ||
2 | #define __ASM_SH_SIGNAL_H | ||
3 | |||
4 | #define SA_RESTORER 0x04000000 | ||
5 | |||
6 | #include <asm-generic/signal.h> | ||
7 | |||
8 | struct old_sigaction { | ||
9 | __sighandler_t sa_handler; | ||
10 | old_sigset_t sa_mask; | ||
11 | unsigned long sa_flags; | ||
12 | void (*sa_restorer)(void); | ||
13 | }; | ||
14 | |||
15 | #endif /* __ASM_SH_SIGNAL_H */ | ||
diff --git a/arch/sh/include/asm/sizes.h b/arch/sh/include/asm/sizes.h new file mode 100644 index 00000000000..dd248c2e108 --- /dev/null +++ b/arch/sh/include/asm/sizes.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/sizes.h> | |||
diff --git a/arch/sh/include/asm/socket.h b/arch/sh/include/asm/socket.h new file mode 100644 index 00000000000..6b71384b9d8 --- /dev/null +++ b/arch/sh/include/asm/socket.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/socket.h> | |||
diff --git a/arch/sh/include/asm/sockios.h b/arch/sh/include/asm/sockios.h new file mode 100644 index 00000000000..cf8b96b1f9a --- /dev/null +++ b/arch/sh/include/asm/sockios.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef __ASM_SH_SOCKIOS_H | ||
2 | #define __ASM_SH_SOCKIOS_H | ||
3 | |||
4 | /* Socket-level I/O control calls. */ | ||
5 | #define FIOGETOWN _IOR('f', 123, int) | ||
6 | #define FIOSETOWN _IOW('f', 124, int) | ||
7 | |||
8 | #define SIOCATMARK _IOR('s', 7, int) | ||
9 | #define SIOCSPGRP _IOW('s', 8, pid_t) | ||
10 | #define SIOCGPGRP _IOR('s', 9, pid_t) | ||
11 | |||
12 | #define SIOCGSTAMP _IOR('s', 100, struct timeval) /* Get stamp (timeval) */ | ||
13 | #define SIOCGSTAMPNS _IOR('s', 101, struct timespec) /* Get stamp (timespec) */ | ||
14 | #endif /* __ASM_SH_SOCKIOS_H */ | ||
diff --git a/arch/sh/include/asm/stat.h b/arch/sh/include/asm/stat.h new file mode 100644 index 00000000000..e1810cc6e3d --- /dev/null +++ b/arch/sh/include/asm/stat.h | |||
@@ -0,0 +1,138 @@ | |||
1 | #ifndef __ASM_SH_STAT_H | ||
2 | #define __ASM_SH_STAT_H | ||
3 | |||
4 | struct __old_kernel_stat { | ||
5 | unsigned short st_dev; | ||
6 | unsigned short st_ino; | ||
7 | unsigned short st_mode; | ||
8 | unsigned short st_nlink; | ||
9 | unsigned short st_uid; | ||
10 | unsigned short st_gid; | ||
11 | unsigned short st_rdev; | ||
12 | unsigned long st_size; | ||
13 | unsigned long st_atime; | ||
14 | unsigned long st_mtime; | ||
15 | unsigned long st_ctime; | ||
16 | }; | ||
17 | |||
18 | #if defined(__SH5__) || defined(CONFIG_CPU_SH5) | ||
19 | struct stat { | ||
20 | unsigned short st_dev; | ||
21 | unsigned short __pad1; | ||
22 | unsigned long st_ino; | ||
23 | unsigned short st_mode; | ||
24 | unsigned short st_nlink; | ||
25 | unsigned short st_uid; | ||
26 | unsigned short st_gid; | ||
27 | unsigned short st_rdev; | ||
28 | unsigned short __pad2; | ||
29 | unsigned long st_size; | ||
30 | unsigned long st_blksize; | ||
31 | unsigned long st_blocks; | ||
32 | unsigned long st_atime; | ||
33 | unsigned long st_atime_nsec; | ||
34 | unsigned long st_mtime; | ||
35 | unsigned long st_mtime_nsec; | ||
36 | unsigned long st_ctime; | ||
37 | unsigned long st_ctime_nsec; | ||
38 | unsigned long __unused4; | ||
39 | unsigned long __unused5; | ||
40 | }; | ||
41 | |||
42 | /* This matches struct stat64 in glibc2.1, hence the absolutely | ||
43 | * insane amounts of padding around dev_t's. | ||
44 | */ | ||
45 | struct stat64 { | ||
46 | unsigned short st_dev; | ||
47 | unsigned char __pad0[10]; | ||
48 | |||
49 | unsigned long st_ino; | ||
50 | unsigned int st_mode; | ||
51 | unsigned int st_nlink; | ||
52 | |||
53 | unsigned long st_uid; | ||
54 | unsigned long st_gid; | ||
55 | |||
56 | unsigned short st_rdev; | ||
57 | unsigned char __pad3[10]; | ||
58 | |||
59 | long long st_size; | ||
60 | unsigned long st_blksize; | ||
61 | |||
62 | unsigned long st_blocks; /* Number 512-byte blocks allocated. */ | ||
63 | unsigned long __pad4; /* future possible st_blocks high bits */ | ||
64 | |||
65 | unsigned long st_atime; | ||
66 | unsigned long st_atime_nsec; | ||
67 | |||
68 | unsigned long st_mtime; | ||
69 | unsigned long st_mtime_nsec; | ||
70 | |||
71 | unsigned long st_ctime; | ||
72 | unsigned long st_ctime_nsec; /* will be high 32 bits of ctime someday */ | ||
73 | |||
74 | unsigned long __unused1; | ||
75 | unsigned long __unused2; | ||
76 | }; | ||
77 | #else | ||
78 | struct stat { | ||
79 | unsigned long st_dev; | ||
80 | unsigned long st_ino; | ||
81 | unsigned short st_mode; | ||
82 | unsigned short st_nlink; | ||
83 | unsigned short st_uid; | ||
84 | unsigned short st_gid; | ||
85 | unsigned long st_rdev; | ||
86 | unsigned long st_size; | ||
87 | unsigned long st_blksize; | ||
88 | unsigned long st_blocks; | ||
89 | unsigned long st_atime; | ||
90 | unsigned long st_atime_nsec; | ||
91 | unsigned long st_mtime; | ||
92 | unsigned long st_mtime_nsec; | ||
93 | unsigned long st_ctime; | ||
94 | unsigned long st_ctime_nsec; | ||
95 | unsigned long __unused4; | ||
96 | unsigned long __unused5; | ||
97 | }; | ||
98 | |||
99 | /* This matches struct stat64 in glibc2.1, hence the absolutely | ||
100 | * insane amounts of padding around dev_t's. | ||
101 | */ | ||
102 | struct stat64 { | ||
103 | unsigned long long st_dev; | ||
104 | unsigned char __pad0[4]; | ||
105 | |||
106 | #define STAT64_HAS_BROKEN_ST_INO 1 | ||
107 | unsigned long __st_ino; | ||
108 | |||
109 | unsigned int st_mode; | ||
110 | unsigned int st_nlink; | ||
111 | |||
112 | unsigned long st_uid; | ||
113 | unsigned long st_gid; | ||
114 | |||
115 | unsigned long long st_rdev; | ||
116 | unsigned char __pad3[4]; | ||
117 | |||
118 | long long st_size; | ||
119 | unsigned long st_blksize; | ||
120 | |||
121 | unsigned long long st_blocks; /* Number 512-byte blocks allocated. */ | ||
122 | |||
123 | unsigned long st_atime; | ||
124 | unsigned long st_atime_nsec; | ||
125 | |||
126 | unsigned long st_mtime; | ||
127 | unsigned long st_mtime_nsec; | ||
128 | |||
129 | unsigned long st_ctime; | ||
130 | unsigned long st_ctime_nsec; | ||
131 | |||
132 | unsigned long long st_ino; | ||
133 | }; | ||
134 | |||
135 | #define STAT_HAVE_NSEC 1 | ||
136 | #endif | ||
137 | |||
138 | #endif /* __ASM_SH_STAT_H */ | ||
diff --git a/arch/sh/include/asm/statfs.h b/arch/sh/include/asm/statfs.h new file mode 100644 index 00000000000..9202a023328 --- /dev/null +++ b/arch/sh/include/asm/statfs.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_SH_STATFS_H | ||
2 | #define __ASM_SH_STATFS_H | ||
3 | |||
4 | #include <asm-generic/statfs.h> | ||
5 | |||
6 | #endif /* __ASM_SH_STATFS_H */ | ||
diff --git a/arch/sh/include/asm/swab.h b/arch/sh/include/asm/swab.h new file mode 100644 index 00000000000..1cd09767a7a --- /dev/null +++ b/arch/sh/include/asm/swab.h | |||
@@ -0,0 +1,59 @@ | |||
1 | #ifndef __ASM_SH_SWAB_H | ||
2 | #define __ASM_SH_SWAB_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 1999 Niibe Yutaka | ||
6 | * Copyright (C) 2000, 2001 Paolo Alberelli | ||
7 | */ | ||
8 | #include <linux/compiler.h> | ||
9 | #include <linux/types.h> | ||
10 | #include <asm-generic/swab.h> | ||
11 | |||
12 | static inline __attribute_const__ __u32 __arch_swab32(__u32 x) | ||
13 | { | ||
14 | __asm__( | ||
15 | #ifdef __SH5__ | ||
16 | "byterev %1, %0\n\t" | ||
17 | "shari %0, 32, %0" | ||
18 | #else | ||
19 | "swap.b %1, %0\n\t" | ||
20 | "swap.w %0, %0\n\t" | ||
21 | "swap.b %0, %0" | ||
22 | #endif | ||
23 | : "=r" (x) | ||
24 | : "r" (x)); | ||
25 | |||
26 | return x; | ||
27 | } | ||
28 | #define __arch_swab32 __arch_swab32 | ||
29 | |||
30 | static inline __attribute_const__ __u16 __arch_swab16(__u16 x) | ||
31 | { | ||
32 | __asm__( | ||
33 | #ifdef __SH5__ | ||
34 | "byterev %1, %0\n\t" | ||
35 | "shari %0, 32, %0" | ||
36 | #else | ||
37 | "swap.b %1, %0" | ||
38 | #endif | ||
39 | : "=r" (x) | ||
40 | : "r" (x)); | ||
41 | |||
42 | return x; | ||
43 | } | ||
44 | #define __arch_swab16 __arch_swab16 | ||
45 | |||
46 | static inline __u64 __arch_swab64(__u64 val) | ||
47 | { | ||
48 | union { | ||
49 | struct { __u32 a,b; } s; | ||
50 | __u64 u; | ||
51 | } v, w; | ||
52 | v.u = val; | ||
53 | w.s.b = __arch_swab32(v.s.a); | ||
54 | w.s.a = __arch_swab32(v.s.b); | ||
55 | return w.u; | ||
56 | } | ||
57 | #define __arch_swab64 __arch_swab64 | ||
58 | |||
59 | #endif /* __ASM_SH_SWAB_H */ | ||
diff --git a/arch/sh/include/asm/system.h b/arch/sh/include/asm/system.h new file mode 100644 index 00000000000..10c8b1823a1 --- /dev/null +++ b/arch/sh/include/asm/system.h | |||
@@ -0,0 +1,184 @@ | |||
1 | #ifndef __ASM_SH_SYSTEM_H | ||
2 | #define __ASM_SH_SYSTEM_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima | ||
6 | * Copyright (C) 2002 Paul Mundt | ||
7 | */ | ||
8 | |||
9 | #include <linux/irqflags.h> | ||
10 | #include <linux/compiler.h> | ||
11 | #include <linux/linkage.h> | ||
12 | #include <asm/types.h> | ||
13 | #include <asm/uncached.h> | ||
14 | |||
15 | #define AT_VECTOR_SIZE_ARCH 5 /* entries in ARCH_DLINFO */ | ||
16 | |||
17 | /* | ||
18 | * A brief note on ctrl_barrier(), the control register write barrier. | ||
19 | * | ||
20 | * Legacy SH cores typically require a sequence of 8 nops after | ||
21 | * modification of a control register in order for the changes to take | ||
22 | * effect. On newer cores (like the sh4a and sh5) this is accomplished | ||
23 | * with icbi. | ||
24 | * | ||
25 | * Also note that on sh4a in the icbi case we can forego a synco for the | ||
26 | * write barrier, as it's not necessary for control registers. | ||
27 | * | ||
28 | * Historically we have only done this type of barrier for the MMUCR, but | ||
29 | * it's also necessary for the CCR, so we make it generic here instead. | ||
30 | */ | ||
31 | #if defined(CONFIG_CPU_SH4A) || defined(CONFIG_CPU_SH5) | ||
32 | #define mb() __asm__ __volatile__ ("synco": : :"memory") | ||
33 | #define rmb() mb() | ||
34 | #define wmb() __asm__ __volatile__ ("synco": : :"memory") | ||
35 | #define ctrl_barrier() __icbi(PAGE_OFFSET) | ||
36 | #define read_barrier_depends() do { } while(0) | ||
37 | #else | ||
38 | #define mb() __asm__ __volatile__ ("": : :"memory") | ||
39 | #define rmb() mb() | ||
40 | #define wmb() __asm__ __volatile__ ("": : :"memory") | ||
41 | #define ctrl_barrier() __asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop") | ||
42 | #define read_barrier_depends() do { } while(0) | ||
43 | #endif | ||
44 | |||
45 | #ifdef CONFIG_SMP | ||
46 | #define smp_mb() mb() | ||
47 | #define smp_rmb() rmb() | ||
48 | #define smp_wmb() wmb() | ||
49 | #define smp_read_barrier_depends() read_barrier_depends() | ||
50 | #else | ||
51 | #define smp_mb() barrier() | ||
52 | #define smp_rmb() barrier() | ||
53 | #define smp_wmb() barrier() | ||
54 | #define smp_read_barrier_depends() do { } while(0) | ||
55 | #endif | ||
56 | |||
57 | #define set_mb(var, value) do { (void)xchg(&var, value); } while (0) | ||
58 | |||
59 | #ifdef CONFIG_GUSA_RB | ||
60 | #include <asm/cmpxchg-grb.h> | ||
61 | #elif defined(CONFIG_CPU_SH4A) | ||
62 | #include <asm/cmpxchg-llsc.h> | ||
63 | #else | ||
64 | #include <asm/cmpxchg-irq.h> | ||
65 | #endif | ||
66 | |||
67 | extern void __xchg_called_with_bad_pointer(void); | ||
68 | |||
69 | #define __xchg(ptr, x, size) \ | ||
70 | ({ \ | ||
71 | unsigned long __xchg__res; \ | ||
72 | volatile void *__xchg_ptr = (ptr); \ | ||
73 | switch (size) { \ | ||
74 | case 4: \ | ||
75 | __xchg__res = xchg_u32(__xchg_ptr, x); \ | ||
76 | break; \ | ||
77 | case 1: \ | ||
78 | __xchg__res = xchg_u8(__xchg_ptr, x); \ | ||
79 | break; \ | ||
80 | default: \ | ||
81 | __xchg_called_with_bad_pointer(); \ | ||
82 | __xchg__res = x; \ | ||
83 | break; \ | ||
84 | } \ | ||
85 | \ | ||
86 | __xchg__res; \ | ||
87 | }) | ||
88 | |||
89 | #define xchg(ptr,x) \ | ||
90 | ((__typeof__(*(ptr)))__xchg((ptr),(unsigned long)(x), sizeof(*(ptr)))) | ||
91 | |||
92 | /* This function doesn't exist, so you'll get a linker error | ||
93 | * if something tries to do an invalid cmpxchg(). */ | ||
94 | extern void __cmpxchg_called_with_bad_pointer(void); | ||
95 | |||
96 | #define __HAVE_ARCH_CMPXCHG 1 | ||
97 | |||
98 | static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old, | ||
99 | unsigned long new, int size) | ||
100 | { | ||
101 | switch (size) { | ||
102 | case 4: | ||
103 | return __cmpxchg_u32(ptr, old, new); | ||
104 | } | ||
105 | __cmpxchg_called_with_bad_pointer(); | ||
106 | return old; | ||
107 | } | ||
108 | |||
109 | #define cmpxchg(ptr,o,n) \ | ||
110 | ({ \ | ||
111 | __typeof__(*(ptr)) _o_ = (o); \ | ||
112 | __typeof__(*(ptr)) _n_ = (n); \ | ||
113 | (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ | ||
114 | (unsigned long)_n_, sizeof(*(ptr))); \ | ||
115 | }) | ||
116 | |||
117 | struct pt_regs; | ||
118 | |||
119 | extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn)); | ||
120 | void free_initmem(void); | ||
121 | void free_initrd_mem(unsigned long start, unsigned long end); | ||
122 | |||
123 | extern void *set_exception_table_vec(unsigned int vec, void *handler); | ||
124 | |||
125 | static inline void *set_exception_table_evt(unsigned int evt, void *handler) | ||
126 | { | ||
127 | return set_exception_table_vec(evt >> 5, handler); | ||
128 | } | ||
129 | |||
130 | /* | ||
131 | * SH-2A has both 16 and 32-bit opcodes, do lame encoding checks. | ||
132 | */ | ||
133 | #ifdef CONFIG_CPU_SH2A | ||
134 | extern unsigned int instruction_size(unsigned int insn); | ||
135 | #elif defined(CONFIG_SUPERH32) | ||
136 | #define instruction_size(insn) (2) | ||
137 | #else | ||
138 | #define instruction_size(insn) (4) | ||
139 | #endif | ||
140 | |||
141 | void per_cpu_trap_init(void); | ||
142 | void default_idle(void); | ||
143 | void cpu_idle_wait(void); | ||
144 | void stop_this_cpu(void *); | ||
145 | |||
146 | #ifdef CONFIG_SUPERH32 | ||
147 | #define BUILD_TRAP_HANDLER(name) \ | ||
148 | asmlinkage void name##_trap_handler(unsigned long r4, unsigned long r5, \ | ||
149 | unsigned long r6, unsigned long r7, \ | ||
150 | struct pt_regs __regs) | ||
151 | |||
152 | #define TRAP_HANDLER_DECL \ | ||
153 | struct pt_regs *regs = RELOC_HIDE(&__regs, 0); \ | ||
154 | unsigned int vec = regs->tra; \ | ||
155 | (void)vec; | ||
156 | #else | ||
157 | #define BUILD_TRAP_HANDLER(name) \ | ||
158 | asmlinkage void name##_trap_handler(unsigned int vec, struct pt_regs *regs) | ||
159 | #define TRAP_HANDLER_DECL | ||
160 | #endif | ||
161 | |||
162 | BUILD_TRAP_HANDLER(address_error); | ||
163 | BUILD_TRAP_HANDLER(debug); | ||
164 | BUILD_TRAP_HANDLER(bug); | ||
165 | BUILD_TRAP_HANDLER(breakpoint); | ||
166 | BUILD_TRAP_HANDLER(singlestep); | ||
167 | BUILD_TRAP_HANDLER(fpu_error); | ||
168 | BUILD_TRAP_HANDLER(fpu_state_restore); | ||
169 | BUILD_TRAP_HANDLER(nmi); | ||
170 | |||
171 | #define arch_align_stack(x) (x) | ||
172 | |||
173 | struct mem_access { | ||
174 | unsigned long (*from)(void *dst, const void __user *src, unsigned long cnt); | ||
175 | unsigned long (*to)(void __user *dst, const void *src, unsigned long cnt); | ||
176 | }; | ||
177 | |||
178 | #ifdef CONFIG_SUPERH32 | ||
179 | # include "system_32.h" | ||
180 | #else | ||
181 | # include "system_64.h" | ||
182 | #endif | ||
183 | |||
184 | #endif | ||
diff --git a/arch/sh/include/asm/system_32.h b/arch/sh/include/asm/system_32.h new file mode 100644 index 00000000000..a4ad1cd9bc4 --- /dev/null +++ b/arch/sh/include/asm/system_32.h | |||
@@ -0,0 +1,236 @@ | |||
1 | #ifndef __ASM_SH_SYSTEM_32_H | ||
2 | #define __ASM_SH_SYSTEM_32_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <asm/mmu.h> | ||
6 | |||
7 | #ifdef CONFIG_SH_DSP | ||
8 | |||
9 | #define is_dsp_enabled(tsk) \ | ||
10 | (!!(tsk->thread.dsp_status.status & SR_DSP)) | ||
11 | |||
12 | #define __restore_dsp(tsk) \ | ||
13 | do { \ | ||
14 | register u32 *__ts2 __asm__ ("r2") = \ | ||
15 | (u32 *)&tsk->thread.dsp_status; \ | ||
16 | __asm__ __volatile__ ( \ | ||
17 | ".balign 4\n\t" \ | ||
18 | "movs.l @r2+, a0\n\t" \ | ||
19 | "movs.l @r2+, a1\n\t" \ | ||
20 | "movs.l @r2+, a0g\n\t" \ | ||
21 | "movs.l @r2+, a1g\n\t" \ | ||
22 | "movs.l @r2+, m0\n\t" \ | ||
23 | "movs.l @r2+, m1\n\t" \ | ||
24 | "movs.l @r2+, x0\n\t" \ | ||
25 | "movs.l @r2+, x1\n\t" \ | ||
26 | "movs.l @r2+, y0\n\t" \ | ||
27 | "movs.l @r2+, y1\n\t" \ | ||
28 | "lds.l @r2+, dsr\n\t" \ | ||
29 | "ldc.l @r2+, rs\n\t" \ | ||
30 | "ldc.l @r2+, re\n\t" \ | ||
31 | "ldc.l @r2+, mod\n\t" \ | ||
32 | : : "r" (__ts2)); \ | ||
33 | } while (0) | ||
34 | |||
35 | |||
36 | #define __save_dsp(tsk) \ | ||
37 | do { \ | ||
38 | register u32 *__ts2 __asm__ ("r2") = \ | ||
39 | (u32 *)&tsk->thread.dsp_status + 14; \ | ||
40 | \ | ||
41 | __asm__ __volatile__ ( \ | ||
42 | ".balign 4\n\t" \ | ||
43 | "stc.l mod, @-r2\n\t" \ | ||
44 | "stc.l re, @-r2\n\t" \ | ||
45 | "stc.l rs, @-r2\n\t" \ | ||
46 | "sts.l dsr, @-r2\n\t" \ | ||
47 | "movs.l y1, @-r2\n\t" \ | ||
48 | "movs.l y0, @-r2\n\t" \ | ||
49 | "movs.l x1, @-r2\n\t" \ | ||
50 | "movs.l x0, @-r2\n\t" \ | ||
51 | "movs.l m1, @-r2\n\t" \ | ||
52 | "movs.l m0, @-r2\n\t" \ | ||
53 | "movs.l a1g, @-r2\n\t" \ | ||
54 | "movs.l a0g, @-r2\n\t" \ | ||
55 | "movs.l a1, @-r2\n\t" \ | ||
56 | "movs.l a0, @-r2\n\t" \ | ||
57 | : : "r" (__ts2)); \ | ||
58 | } while (0) | ||
59 | |||
60 | #else | ||
61 | |||
62 | #define is_dsp_enabled(tsk) (0) | ||
63 | #define __save_dsp(tsk) do { } while (0) | ||
64 | #define __restore_dsp(tsk) do { } while (0) | ||
65 | #endif | ||
66 | |||
67 | #if defined(CONFIG_CPU_SH4A) | ||
68 | #define __icbi(addr) __asm__ __volatile__ ( "icbi @%0\n\t" : : "r" (addr)) | ||
69 | #else | ||
70 | #define __icbi(addr) mb() | ||
71 | #endif | ||
72 | |||
73 | #define __ocbp(addr) __asm__ __volatile__ ( "ocbp @%0\n\t" : : "r" (addr)) | ||
74 | #define __ocbi(addr) __asm__ __volatile__ ( "ocbi @%0\n\t" : : "r" (addr)) | ||
75 | #define __ocbwb(addr) __asm__ __volatile__ ( "ocbwb @%0\n\t" : : "r" (addr)) | ||
76 | |||
77 | struct task_struct *__switch_to(struct task_struct *prev, | ||
78 | struct task_struct *next); | ||
79 | |||
80 | /* | ||
81 | * switch_to() should switch tasks to task nr n, first | ||
82 | */ | ||
83 | #define switch_to(prev, next, last) \ | ||
84 | do { \ | ||
85 | register u32 *__ts1 __asm__ ("r1"); \ | ||
86 | register u32 *__ts2 __asm__ ("r2"); \ | ||
87 | register u32 *__ts4 __asm__ ("r4"); \ | ||
88 | register u32 *__ts5 __asm__ ("r5"); \ | ||
89 | register u32 *__ts6 __asm__ ("r6"); \ | ||
90 | register u32 __ts7 __asm__ ("r7"); \ | ||
91 | struct task_struct *__last; \ | ||
92 | \ | ||
93 | if (is_dsp_enabled(prev)) \ | ||
94 | __save_dsp(prev); \ | ||
95 | \ | ||
96 | __ts1 = (u32 *)&prev->thread.sp; \ | ||
97 | __ts2 = (u32 *)&prev->thread.pc; \ | ||
98 | __ts4 = (u32 *)prev; \ | ||
99 | __ts5 = (u32 *)next; \ | ||
100 | __ts6 = (u32 *)&next->thread.sp; \ | ||
101 | __ts7 = next->thread.pc; \ | ||
102 | \ | ||
103 | __asm__ __volatile__ ( \ | ||
104 | ".balign 4\n\t" \ | ||
105 | "stc.l gbr, @-r15\n\t" \ | ||
106 | "sts.l pr, @-r15\n\t" \ | ||
107 | "mov.l r8, @-r15\n\t" \ | ||
108 | "mov.l r9, @-r15\n\t" \ | ||
109 | "mov.l r10, @-r15\n\t" \ | ||
110 | "mov.l r11, @-r15\n\t" \ | ||
111 | "mov.l r12, @-r15\n\t" \ | ||
112 | "mov.l r13, @-r15\n\t" \ | ||
113 | "mov.l r14, @-r15\n\t" \ | ||
114 | "mov.l r15, @r1\t! save SP\n\t" \ | ||
115 | "mov.l @r6, r15\t! change to new stack\n\t" \ | ||
116 | "mova 1f, %0\n\t" \ | ||
117 | "mov.l %0, @r2\t! save PC\n\t" \ | ||
118 | "mov.l 2f, %0\n\t" \ | ||
119 | "jmp @%0\t! call __switch_to\n\t" \ | ||
120 | " lds r7, pr\t! with return to new PC\n\t" \ | ||
121 | ".balign 4\n" \ | ||
122 | "2:\n\t" \ | ||
123 | ".long __switch_to\n" \ | ||
124 | "1:\n\t" \ | ||
125 | "mov.l @r15+, r14\n\t" \ | ||
126 | "mov.l @r15+, r13\n\t" \ | ||
127 | "mov.l @r15+, r12\n\t" \ | ||
128 | "mov.l @r15+, r11\n\t" \ | ||
129 | "mov.l @r15+, r10\n\t" \ | ||
130 | "mov.l @r15+, r9\n\t" \ | ||
131 | "mov.l @r15+, r8\n\t" \ | ||
132 | "lds.l @r15+, pr\n\t" \ | ||
133 | "ldc.l @r15+, gbr\n\t" \ | ||
134 | : "=z" (__last) \ | ||
135 | : "r" (__ts1), "r" (__ts2), "r" (__ts4), \ | ||
136 | "r" (__ts5), "r" (__ts6), "r" (__ts7) \ | ||
137 | : "r3", "t"); \ | ||
138 | \ | ||
139 | last = __last; \ | ||
140 | } while (0) | ||
141 | |||
142 | #define finish_arch_switch(prev) \ | ||
143 | do { \ | ||
144 | if (is_dsp_enabled(prev)) \ | ||
145 | __restore_dsp(prev); \ | ||
146 | } while (0) | ||
147 | |||
148 | #ifdef CONFIG_CPU_HAS_SR_RB | ||
149 | #define lookup_exception_vector() \ | ||
150 | ({ \ | ||
151 | unsigned long _vec; \ | ||
152 | \ | ||
153 | __asm__ __volatile__ ( \ | ||
154 | "stc r2_bank, %0\n\t" \ | ||
155 | : "=r" (_vec) \ | ||
156 | ); \ | ||
157 | \ | ||
158 | _vec; \ | ||
159 | }) | ||
160 | #else | ||
161 | #define lookup_exception_vector() \ | ||
162 | ({ \ | ||
163 | unsigned long _vec; \ | ||
164 | __asm__ __volatile__ ( \ | ||
165 | "mov r4, %0\n\t" \ | ||
166 | : "=r" (_vec) \ | ||
167 | ); \ | ||
168 | \ | ||
169 | _vec; \ | ||
170 | }) | ||
171 | #endif | ||
172 | |||
173 | static inline reg_size_t register_align(void *val) | ||
174 | { | ||
175 | return (unsigned long)(signed long)val; | ||
176 | } | ||
177 | |||
178 | int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs, | ||
179 | struct mem_access *ma, int, unsigned long address); | ||
180 | |||
181 | static inline void trigger_address_error(void) | ||
182 | { | ||
183 | __asm__ __volatile__ ( | ||
184 | "ldc %0, sr\n\t" | ||
185 | "mov.l @%1, %0" | ||
186 | : | ||
187 | : "r" (0x10000000), "r" (0x80000001) | ||
188 | ); | ||
189 | } | ||
190 | |||
191 | asmlinkage void do_address_error(struct pt_regs *regs, | ||
192 | unsigned long writeaccess, | ||
193 | unsigned long address); | ||
194 | asmlinkage void do_divide_error(unsigned long r4, unsigned long r5, | ||
195 | unsigned long r6, unsigned long r7, | ||
196 | struct pt_regs __regs); | ||
197 | asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5, | ||
198 | unsigned long r6, unsigned long r7, | ||
199 | struct pt_regs __regs); | ||
200 | asmlinkage void do_illegal_slot_inst(unsigned long r4, unsigned long r5, | ||
201 | unsigned long r6, unsigned long r7, | ||
202 | struct pt_regs __regs); | ||
203 | asmlinkage void do_exception_error(unsigned long r4, unsigned long r5, | ||
204 | unsigned long r6, unsigned long r7, | ||
205 | struct pt_regs __regs); | ||
206 | |||
207 | static inline void set_bl_bit(void) | ||
208 | { | ||
209 | unsigned long __dummy0, __dummy1; | ||
210 | |||
211 | __asm__ __volatile__ ( | ||
212 | "stc sr, %0\n\t" | ||
213 | "or %2, %0\n\t" | ||
214 | "and %3, %0\n\t" | ||
215 | "ldc %0, sr\n\t" | ||
216 | : "=&r" (__dummy0), "=r" (__dummy1) | ||
217 | : "r" (0x10000000), "r" (0xffffff0f) | ||
218 | : "memory" | ||
219 | ); | ||
220 | } | ||
221 | |||
222 | static inline void clear_bl_bit(void) | ||
223 | { | ||
224 | unsigned long __dummy0, __dummy1; | ||
225 | |||
226 | __asm__ __volatile__ ( | ||
227 | "stc sr, %0\n\t" | ||
228 | "and %2, %0\n\t" | ||
229 | "ldc %0, sr\n\t" | ||
230 | : "=&r" (__dummy0), "=r" (__dummy1) | ||
231 | : "1" (~0x10000000) | ||
232 | : "memory" | ||
233 | ); | ||
234 | } | ||
235 | |||
236 | #endif /* __ASM_SH_SYSTEM_32_H */ | ||
diff --git a/arch/sh/include/asm/system_64.h b/arch/sh/include/asm/system_64.h new file mode 100644 index 00000000000..8593bc8d1a4 --- /dev/null +++ b/arch/sh/include/asm/system_64.h | |||
@@ -0,0 +1,79 @@ | |||
1 | #ifndef __ASM_SH_SYSTEM_64_H | ||
2 | #define __ASM_SH_SYSTEM_64_H | ||
3 | |||
4 | /* | ||
5 | * include/asm-sh/system_64.h | ||
6 | * | ||
7 | * Copyright (C) 2000, 2001 Paolo Alberelli | ||
8 | * Copyright (C) 2003 Paul Mundt | ||
9 | * Copyright (C) 2004 Richard Curnow | ||
10 | * | ||
11 | * This file is subject to the terms and conditions of the GNU General Public | ||
12 | * License. See the file "COPYING" in the main directory of this archive | ||
13 | * for more details. | ||
14 | */ | ||
15 | #include <cpu/registers.h> | ||
16 | #include <asm/processor.h> | ||
17 | |||
18 | /* | ||
19 | * switch_to() should switch tasks to task nr n, first | ||
20 | */ | ||
21 | struct thread_struct; | ||
22 | struct task_struct *sh64_switch_to(struct task_struct *prev, | ||
23 | struct thread_struct *prev_thread, | ||
24 | struct task_struct *next, | ||
25 | struct thread_struct *next_thread); | ||
26 | |||
27 | #define switch_to(prev,next,last) \ | ||
28 | do { \ | ||
29 | if (last_task_used_math != next) { \ | ||
30 | struct pt_regs *regs = next->thread.uregs; \ | ||
31 | if (regs) regs->sr |= SR_FD; \ | ||
32 | } \ | ||
33 | last = sh64_switch_to(prev, &prev->thread, next, \ | ||
34 | &next->thread); \ | ||
35 | } while (0) | ||
36 | |||
37 | #define __icbi(addr) __asm__ __volatile__ ( "icbi %0, 0\n\t" : : "r" (addr)) | ||
38 | #define __ocbp(addr) __asm__ __volatile__ ( "ocbp %0, 0\n\t" : : "r" (addr)) | ||
39 | #define __ocbi(addr) __asm__ __volatile__ ( "ocbi %0, 0\n\t" : : "r" (addr)) | ||
40 | #define __ocbwb(addr) __asm__ __volatile__ ( "ocbwb %0, 0\n\t" : : "r" (addr)) | ||
41 | |||
42 | static inline reg_size_t register_align(void *val) | ||
43 | { | ||
44 | return (unsigned long long)(signed long long)(signed long)val; | ||
45 | } | ||
46 | |||
47 | extern void phys_stext(void); | ||
48 | |||
49 | static inline void trigger_address_error(void) | ||
50 | { | ||
51 | phys_stext(); | ||
52 | } | ||
53 | |||
54 | #define SR_BL_LL 0x0000000010000000LL | ||
55 | |||
56 | static inline void set_bl_bit(void) | ||
57 | { | ||
58 | unsigned long long __dummy0, __dummy1 = SR_BL_LL; | ||
59 | |||
60 | __asm__ __volatile__("getcon " __SR ", %0\n\t" | ||
61 | "or %0, %1, %0\n\t" | ||
62 | "putcon %0, " __SR "\n\t" | ||
63 | : "=&r" (__dummy0) | ||
64 | : "r" (__dummy1)); | ||
65 | |||
66 | } | ||
67 | |||
68 | static inline void clear_bl_bit(void) | ||
69 | { | ||
70 | unsigned long long __dummy0, __dummy1 = ~SR_BL_LL; | ||
71 | |||
72 | __asm__ __volatile__("getcon " __SR ", %0\n\t" | ||
73 | "and %0, %1, %0\n\t" | ||
74 | "putcon %0, " __SR "\n\t" | ||
75 | : "=&r" (__dummy0) | ||
76 | : "r" (__dummy1)); | ||
77 | } | ||
78 | |||
79 | #endif /* __ASM_SH_SYSTEM_64_H */ | ||
diff --git a/arch/sh/include/asm/termbits.h b/arch/sh/include/asm/termbits.h new file mode 100644 index 00000000000..3935b106de7 --- /dev/null +++ b/arch/sh/include/asm/termbits.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/termbits.h> | |||
diff --git a/arch/sh/include/asm/termios.h b/arch/sh/include/asm/termios.h new file mode 100644 index 00000000000..280d78a9d96 --- /dev/null +++ b/arch/sh/include/asm/termios.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/termios.h> | |||
diff --git a/arch/sh/include/asm/ucontext.h b/arch/sh/include/asm/ucontext.h new file mode 100644 index 00000000000..9bc07b9f30f --- /dev/null +++ b/arch/sh/include/asm/ucontext.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/ucontext.h> | |||
diff --git a/arch/sh/include/asm/unistd_32.h b/arch/sh/include/asm/unistd_32.h new file mode 100644 index 00000000000..3432008d288 --- /dev/null +++ b/arch/sh/include/asm/unistd_32.h | |||
@@ -0,0 +1,420 @@ | |||
1 | #ifndef __ASM_SH_UNISTD_H | ||
2 | #define __ASM_SH_UNISTD_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 1999 Niibe Yutaka | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * This file contains the system call numbers. | ||
10 | */ | ||
11 | |||
12 | #define __NR_restart_syscall 0 | ||
13 | #define __NR_exit 1 | ||
14 | #define __NR_fork 2 | ||
15 | #define __NR_read 3 | ||
16 | #define __NR_write 4 | ||
17 | #define __NR_open 5 | ||
18 | #define __NR_close 6 | ||
19 | #define __NR_waitpid 7 | ||
20 | #define __NR_creat 8 | ||
21 | #define __NR_link 9 | ||
22 | #define __NR_unlink 10 | ||
23 | #define __NR_execve 11 | ||
24 | #define __NR_chdir 12 | ||
25 | #define __NR_time 13 | ||
26 | #define __NR_mknod 14 | ||
27 | #define __NR_chmod 15 | ||
28 | #define __NR_lchown 16 | ||
29 | #define __NR_break 17 | ||
30 | #define __NR_oldstat 18 | ||
31 | #define __NR_lseek 19 | ||
32 | #define __NR_getpid 20 | ||
33 | #define __NR_mount 21 | ||
34 | #define __NR_umount 22 | ||
35 | #define __NR_setuid 23 | ||
36 | #define __NR_getuid 24 | ||
37 | #define __NR_stime 25 | ||
38 | #define __NR_ptrace 26 | ||
39 | #define __NR_alarm 27 | ||
40 | #define __NR_oldfstat 28 | ||
41 | #define __NR_pause 29 | ||
42 | #define __NR_utime 30 | ||
43 | #define __NR_stty 31 | ||
44 | #define __NR_gtty 32 | ||
45 | #define __NR_access 33 | ||
46 | #define __NR_nice 34 | ||
47 | #define __NR_ftime 35 | ||
48 | #define __NR_sync 36 | ||
49 | #define __NR_kill 37 | ||
50 | #define __NR_rename 38 | ||
51 | #define __NR_mkdir 39 | ||
52 | #define __NR_rmdir 40 | ||
53 | #define __NR_dup 41 | ||
54 | #define __NR_pipe 42 | ||
55 | #define __NR_times 43 | ||
56 | #define __NR_prof 44 | ||
57 | #define __NR_brk 45 | ||
58 | #define __NR_setgid 46 | ||
59 | #define __NR_getgid 47 | ||
60 | #define __NR_signal 48 | ||
61 | #define __NR_geteuid 49 | ||
62 | #define __NR_getegid 50 | ||
63 | #define __NR_acct 51 | ||
64 | #define __NR_umount2 52 | ||
65 | #define __NR_lock 53 | ||
66 | #define __NR_ioctl 54 | ||
67 | #define __NR_fcntl 55 | ||
68 | #define __NR_mpx 56 | ||
69 | #define __NR_setpgid 57 | ||
70 | #define __NR_ulimit 58 | ||
71 | #define __NR_oldolduname 59 | ||
72 | #define __NR_umask 60 | ||
73 | #define __NR_chroot 61 | ||
74 | #define __NR_ustat 62 | ||
75 | #define __NR_dup2 63 | ||
76 | #define __NR_getppid 64 | ||
77 | #define __NR_getpgrp 65 | ||
78 | #define __NR_setsid 66 | ||
79 | #define __NR_sigaction 67 | ||
80 | #define __NR_sgetmask 68 | ||
81 | #define __NR_ssetmask 69 | ||
82 | #define __NR_setreuid 70 | ||
83 | #define __NR_setregid 71 | ||
84 | #define __NR_sigsuspend 72 | ||
85 | #define __NR_sigpending 73 | ||
86 | #define __NR_sethostname 74 | ||
87 | #define __NR_setrlimit 75 | ||
88 | #define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ | ||
89 | #define __NR_getrusage 77 | ||
90 | #define __NR_gettimeofday 78 | ||
91 | #define __NR_settimeofday 79 | ||
92 | #define __NR_getgroups 80 | ||
93 | #define __NR_setgroups 81 | ||
94 | #define __NR_select 82 | ||
95 | #define __NR_symlink 83 | ||
96 | #define __NR_oldlstat 84 | ||
97 | #define __NR_readlink 85 | ||
98 | #define __NR_uselib 86 | ||
99 | #define __NR_swapon 87 | ||
100 | #define __NR_reboot 88 | ||
101 | #define __NR_readdir 89 | ||
102 | #define __NR_mmap 90 | ||
103 | #define __NR_munmap 91 | ||
104 | #define __NR_truncate 92 | ||
105 | #define __NR_ftruncate 93 | ||
106 | #define __NR_fchmod 94 | ||
107 | #define __NR_fchown 95 | ||
108 | #define __NR_getpriority 96 | ||
109 | #define __NR_setpriority 97 | ||
110 | #define __NR_profil 98 | ||
111 | #define __NR_statfs 99 | ||
112 | #define __NR_fstatfs 100 | ||
113 | #define __NR_ioperm 101 | ||
114 | #define __NR_socketcall 102 | ||
115 | #define __NR_syslog 103 | ||
116 | #define __NR_setitimer 104 | ||
117 | #define __NR_getitimer 105 | ||
118 | #define __NR_stat 106 | ||
119 | #define __NR_lstat 107 | ||
120 | #define __NR_fstat 108 | ||
121 | #define __NR_olduname 109 | ||
122 | #define __NR_iopl 110 | ||
123 | #define __NR_vhangup 111 | ||
124 | #define __NR_idle 112 | ||
125 | #define __NR_vm86old 113 | ||
126 | #define __NR_wait4 114 | ||
127 | #define __NR_swapoff 115 | ||
128 | #define __NR_sysinfo 116 | ||
129 | #define __NR_ipc 117 | ||
130 | #define __NR_fsync 118 | ||
131 | #define __NR_sigreturn 119 | ||
132 | #define __NR_clone 120 | ||
133 | #define __NR_setdomainname 121 | ||
134 | #define __NR_uname 122 | ||
135 | #define __NR_cacheflush 123 | ||
136 | #define __NR_adjtimex 124 | ||
137 | #define __NR_mprotect 125 | ||
138 | #define __NR_sigprocmask 126 | ||
139 | #define __NR_create_module 127 | ||
140 | #define __NR_init_module 128 | ||
141 | #define __NR_delete_module 129 | ||
142 | #define __NR_get_kernel_syms 130 | ||
143 | #define __NR_quotactl 131 | ||
144 | #define __NR_getpgid 132 | ||
145 | #define __NR_fchdir 133 | ||
146 | #define __NR_bdflush 134 | ||
147 | #define __NR_sysfs 135 | ||
148 | #define __NR_personality 136 | ||
149 | #define __NR_afs_syscall 137 /* Syscall for Andrew File System */ | ||
150 | #define __NR_setfsuid 138 | ||
151 | #define __NR_setfsgid 139 | ||
152 | #define __NR__llseek 140 | ||
153 | #define __NR_getdents 141 | ||
154 | #define __NR__newselect 142 | ||
155 | #define __NR_flock 143 | ||
156 | #define __NR_msync 144 | ||
157 | #define __NR_readv 145 | ||
158 | #define __NR_writev 146 | ||
159 | #define __NR_getsid 147 | ||
160 | #define __NR_fdatasync 148 | ||
161 | #define __NR__sysctl 149 | ||
162 | #define __NR_mlock 150 | ||
163 | #define __NR_munlock 151 | ||
164 | #define __NR_mlockall 152 | ||
165 | #define __NR_munlockall 153 | ||
166 | #define __NR_sched_setparam 154 | ||
167 | #define __NR_sched_getparam 155 | ||
168 | #define __NR_sched_setscheduler 156 | ||
169 | #define __NR_sched_getscheduler 157 | ||
170 | #define __NR_sched_yield 158 | ||
171 | #define __NR_sched_get_priority_max 159 | ||
172 | #define __NR_sched_get_priority_min 160 | ||
173 | #define __NR_sched_rr_get_interval 161 | ||
174 | #define __NR_nanosleep 162 | ||
175 | #define __NR_mremap 163 | ||
176 | #define __NR_setresuid 164 | ||
177 | #define __NR_getresuid 165 | ||
178 | #define __NR_vm86 166 | ||
179 | #define __NR_query_module 167 | ||
180 | #define __NR_poll 168 | ||
181 | #define __NR_nfsservctl 169 | ||
182 | #define __NR_setresgid 170 | ||
183 | #define __NR_getresgid 171 | ||
184 | #define __NR_prctl 172 | ||
185 | #define __NR_rt_sigreturn 173 | ||
186 | #define __NR_rt_sigaction 174 | ||
187 | #define __NR_rt_sigprocmask 175 | ||
188 | #define __NR_rt_sigpending 176 | ||
189 | #define __NR_rt_sigtimedwait 177 | ||
190 | #define __NR_rt_sigqueueinfo 178 | ||
191 | #define __NR_rt_sigsuspend 179 | ||
192 | #define __NR_pread64 180 | ||
193 | #define __NR_pwrite64 181 | ||
194 | #define __NR_chown 182 | ||
195 | #define __NR_getcwd 183 | ||
196 | #define __NR_capget 184 | ||
197 | #define __NR_capset 185 | ||
198 | #define __NR_sigaltstack 186 | ||
199 | #define __NR_sendfile 187 | ||
200 | #define __NR_streams1 188 /* some people actually want it */ | ||
201 | #define __NR_streams2 189 /* some people actually want it */ | ||
202 | #define __NR_vfork 190 | ||
203 | #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ | ||
204 | #define __NR_mmap2 192 | ||
205 | #define __NR_truncate64 193 | ||
206 | #define __NR_ftruncate64 194 | ||
207 | #define __NR_stat64 195 | ||
208 | #define __NR_lstat64 196 | ||
209 | #define __NR_fstat64 197 | ||
210 | #define __NR_lchown32 198 | ||
211 | #define __NR_getuid32 199 | ||
212 | #define __NR_getgid32 200 | ||
213 | #define __NR_geteuid32 201 | ||
214 | #define __NR_getegid32 202 | ||
215 | #define __NR_setreuid32 203 | ||
216 | #define __NR_setregid32 204 | ||
217 | #define __NR_getgroups32 205 | ||
218 | #define __NR_setgroups32 206 | ||
219 | #define __NR_fchown32 207 | ||
220 | #define __NR_setresuid32 208 | ||
221 | #define __NR_getresuid32 209 | ||
222 | #define __NR_setresgid32 210 | ||
223 | #define __NR_getresgid32 211 | ||
224 | #define __NR_chown32 212 | ||
225 | #define __NR_setuid32 213 | ||
226 | #define __NR_setgid32 214 | ||
227 | #define __NR_setfsuid32 215 | ||
228 | #define __NR_setfsgid32 216 | ||
229 | #define __NR_pivot_root 217 | ||
230 | #define __NR_mincore 218 | ||
231 | #define __NR_madvise 219 | ||
232 | #define __NR_getdents64 220 | ||
233 | #define __NR_fcntl64 221 | ||
234 | /* 223 is unused */ | ||
235 | #define __NR_gettid 224 | ||
236 | #define __NR_readahead 225 | ||
237 | #define __NR_setxattr 226 | ||
238 | #define __NR_lsetxattr 227 | ||
239 | #define __NR_fsetxattr 228 | ||
240 | #define __NR_getxattr 229 | ||
241 | #define __NR_lgetxattr 230 | ||
242 | #define __NR_fgetxattr 231 | ||
243 | #define __NR_listxattr 232 | ||
244 | #define __NR_llistxattr 233 | ||
245 | #define __NR_flistxattr 234 | ||
246 | #define __NR_removexattr 235 | ||
247 | #define __NR_lremovexattr 236 | ||
248 | #define __NR_fremovexattr 237 | ||
249 | #define __NR_tkill 238 | ||
250 | #define __NR_sendfile64 239 | ||
251 | #define __NR_futex 240 | ||
252 | #define __NR_sched_setaffinity 241 | ||
253 | #define __NR_sched_getaffinity 242 | ||
254 | #define __NR_set_thread_area 243 | ||
255 | #define __NR_get_thread_area 244 | ||
256 | #define __NR_io_setup 245 | ||
257 | #define __NR_io_destroy 246 | ||
258 | #define __NR_io_getevents 247 | ||
259 | #define __NR_io_submit 248 | ||
260 | #define __NR_io_cancel 249 | ||
261 | #define __NR_fadvise64 250 | ||
262 | |||
263 | #define __NR_exit_group 252 | ||
264 | #define __NR_lookup_dcookie 253 | ||
265 | #define __NR_epoll_create 254 | ||
266 | #define __NR_epoll_ctl 255 | ||
267 | #define __NR_epoll_wait 256 | ||
268 | #define __NR_remap_file_pages 257 | ||
269 | #define __NR_set_tid_address 258 | ||
270 | #define __NR_timer_create 259 | ||
271 | #define __NR_timer_settime (__NR_timer_create+1) | ||
272 | #define __NR_timer_gettime (__NR_timer_create+2) | ||
273 | #define __NR_timer_getoverrun (__NR_timer_create+3) | ||
274 | #define __NR_timer_delete (__NR_timer_create+4) | ||
275 | #define __NR_clock_settime (__NR_timer_create+5) | ||
276 | #define __NR_clock_gettime (__NR_timer_create+6) | ||
277 | #define __NR_clock_getres (__NR_timer_create+7) | ||
278 | #define __NR_clock_nanosleep (__NR_timer_create+8) | ||
279 | #define __NR_statfs64 268 | ||
280 | #define __NR_fstatfs64 269 | ||
281 | #define __NR_tgkill 270 | ||
282 | #define __NR_utimes 271 | ||
283 | #define __NR_fadvise64_64 272 | ||
284 | #define __NR_vserver 273 | ||
285 | #define __NR_mbind 274 | ||
286 | #define __NR_get_mempolicy 275 | ||
287 | #define __NR_set_mempolicy 276 | ||
288 | #define __NR_mq_open 277 | ||
289 | #define __NR_mq_unlink (__NR_mq_open+1) | ||
290 | #define __NR_mq_timedsend (__NR_mq_open+2) | ||
291 | #define __NR_mq_timedreceive (__NR_mq_open+3) | ||
292 | #define __NR_mq_notify (__NR_mq_open+4) | ||
293 | #define __NR_mq_getsetattr (__NR_mq_open+5) | ||
294 | #define __NR_kexec_load 283 | ||
295 | #define __NR_waitid 284 | ||
296 | #define __NR_add_key 285 | ||
297 | #define __NR_request_key 286 | ||
298 | #define __NR_keyctl 287 | ||
299 | #define __NR_ioprio_set 288 | ||
300 | #define __NR_ioprio_get 289 | ||
301 | #define __NR_inotify_init 290 | ||
302 | #define __NR_inotify_add_watch 291 | ||
303 | #define __NR_inotify_rm_watch 292 | ||
304 | /* 293 is unused */ | ||
305 | #define __NR_migrate_pages 294 | ||
306 | #define __NR_openat 295 | ||
307 | #define __NR_mkdirat 296 | ||
308 | #define __NR_mknodat 297 | ||
309 | #define __NR_fchownat 298 | ||
310 | #define __NR_futimesat 299 | ||
311 | #define __NR_fstatat64 300 | ||
312 | #define __NR_unlinkat 301 | ||
313 | #define __NR_renameat 302 | ||
314 | #define __NR_linkat 303 | ||
315 | #define __NR_symlinkat 304 | ||
316 | #define __NR_readlinkat 305 | ||
317 | #define __NR_fchmodat 306 | ||
318 | #define __NR_faccessat 307 | ||
319 | #define __NR_pselect6 308 | ||
320 | #define __NR_ppoll 309 | ||
321 | #define __NR_unshare 310 | ||
322 | #define __NR_set_robust_list 311 | ||
323 | #define __NR_get_robust_list 312 | ||
324 | #define __NR_splice 313 | ||
325 | #define __NR_sync_file_range 314 | ||
326 | #define __NR_tee 315 | ||
327 | #define __NR_vmsplice 316 | ||
328 | #define __NR_move_pages 317 | ||
329 | #define __NR_getcpu 318 | ||
330 | #define __NR_epoll_pwait 319 | ||
331 | #define __NR_utimensat 320 | ||
332 | #define __NR_signalfd 321 | ||
333 | #define __NR_timerfd_create 322 | ||
334 | #define __NR_eventfd 323 | ||
335 | #define __NR_fallocate 324 | ||
336 | #define __NR_timerfd_settime 325 | ||
337 | #define __NR_timerfd_gettime 326 | ||
338 | #define __NR_signalfd4 327 | ||
339 | #define __NR_eventfd2 328 | ||
340 | #define __NR_epoll_create1 329 | ||
341 | #define __NR_dup3 330 | ||
342 | #define __NR_pipe2 331 | ||
343 | #define __NR_inotify_init1 332 | ||
344 | #define __NR_preadv 333 | ||
345 | #define __NR_pwritev 334 | ||
346 | #define __NR_rt_tgsigqueueinfo 335 | ||
347 | #define __NR_perf_event_open 336 | ||
348 | #define __NR_fanotify_init 337 | ||
349 | #define __NR_fanotify_mark 338 | ||
350 | #define __NR_prlimit64 339 | ||
351 | |||
352 | /* Non-multiplexed socket family */ | ||
353 | #define __NR_socket 340 | ||
354 | #define __NR_bind 341 | ||
355 | #define __NR_connect 342 | ||
356 | #define __NR_listen 343 | ||
357 | #define __NR_accept 344 | ||
358 | #define __NR_getsockname 345 | ||
359 | #define __NR_getpeername 346 | ||
360 | #define __NR_socketpair 347 | ||
361 | #define __NR_send 348 | ||
362 | #define __NR_sendto 349 | ||
363 | #define __NR_recv 350 | ||
364 | #define __NR_recvfrom 351 | ||
365 | #define __NR_shutdown 352 | ||
366 | #define __NR_setsockopt 353 | ||
367 | #define __NR_getsockopt 354 | ||
368 | #define __NR_sendmsg 355 | ||
369 | #define __NR_recvmsg 356 | ||
370 | #define __NR_recvmmsg 357 | ||
371 | #define __NR_accept4 358 | ||
372 | #define __NR_name_to_handle_at 359 | ||
373 | #define __NR_open_by_handle_at 360 | ||
374 | #define __NR_clock_adjtime 361 | ||
375 | #define __NR_syncfs 362 | ||
376 | #define __NR_sendmmsg 363 | ||
377 | #define __NR_setns 364 | ||
378 | |||
379 | #define NR_syscalls 365 | ||
380 | |||
381 | #ifdef __KERNEL__ | ||
382 | |||
383 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
384 | #define __ARCH_WANT_OLD_READDIR | ||
385 | #define __ARCH_WANT_OLD_STAT | ||
386 | #define __ARCH_WANT_STAT64 | ||
387 | #define __ARCH_WANT_SYS_ALARM | ||
388 | #define __ARCH_WANT_SYS_GETHOSTNAME | ||
389 | #define __ARCH_WANT_SYS_IPC | ||
390 | #define __ARCH_WANT_SYS_PAUSE | ||
391 | #define __ARCH_WANT_SYS_SGETMASK | ||
392 | #define __ARCH_WANT_SYS_SIGNAL | ||
393 | #define __ARCH_WANT_SYS_TIME | ||
394 | #define __ARCH_WANT_SYS_UTIME | ||
395 | #define __ARCH_WANT_SYS_WAITPID | ||
396 | #define __ARCH_WANT_SYS_SOCKETCALL | ||
397 | #define __ARCH_WANT_SYS_FADVISE64 | ||
398 | #define __ARCH_WANT_SYS_GETPGRP | ||
399 | #define __ARCH_WANT_SYS_LLSEEK | ||
400 | #define __ARCH_WANT_SYS_NICE | ||
401 | #define __ARCH_WANT_SYS_OLD_GETRLIMIT | ||
402 | #define __ARCH_WANT_SYS_OLD_UNAME | ||
403 | #define __ARCH_WANT_SYS_OLDUMOUNT | ||
404 | #define __ARCH_WANT_SYS_SIGPENDING | ||
405 | #define __ARCH_WANT_SYS_SIGPROCMASK | ||
406 | #define __ARCH_WANT_SYS_RT_SIGACTION | ||
407 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND | ||
408 | |||
409 | /* | ||
410 | * "Conditional" syscalls | ||
411 | * | ||
412 | * What we want is __attribute__((weak,alias("sys_ni_syscall"))), | ||
413 | * but it doesn't work on all toolchains, so we just do it by hand | ||
414 | */ | ||
415 | #ifndef cond_syscall | ||
416 | #define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") | ||
417 | #endif | ||
418 | |||
419 | #endif /* __KERNEL__ */ | ||
420 | #endif /* __ASM_SH_UNISTD_H */ | ||
diff --git a/arch/sh/include/asm/unistd_64.h b/arch/sh/include/asm/unistd_64.h new file mode 100644 index 00000000000..ec9898665f2 --- /dev/null +++ b/arch/sh/include/asm/unistd_64.h | |||
@@ -0,0 +1,440 @@ | |||
1 | #ifndef __ASM_SH_UNISTD_64_H | ||
2 | #define __ASM_SH_UNISTD_64_H | ||
3 | |||
4 | /* | ||
5 | * include/asm-sh/unistd_64.h | ||
6 | * | ||
7 | * This file contains the system call numbers. | ||
8 | * | ||
9 | * Copyright (C) 2000, 2001 Paolo Alberelli | ||
10 | * Copyright (C) 2003 - 2007 Paul Mundt | ||
11 | * Copyright (C) 2004 Sean McGoogan | ||
12 | * | ||
13 | * This file is subject to the terms and conditions of the GNU General Public | ||
14 | * License. See the file "COPYING" in the main directory of this archive | ||
15 | * for more details. | ||
16 | */ | ||
17 | #define __NR_restart_syscall 0 | ||
18 | #define __NR_exit 1 | ||
19 | #define __NR_fork 2 | ||
20 | #define __NR_read 3 | ||
21 | #define __NR_write 4 | ||
22 | #define __NR_open 5 | ||
23 | #define __NR_close 6 | ||
24 | #define __NR_waitpid 7 | ||
25 | #define __NR_creat 8 | ||
26 | #define __NR_link 9 | ||
27 | #define __NR_unlink 10 | ||
28 | #define __NR_execve 11 | ||
29 | #define __NR_chdir 12 | ||
30 | #define __NR_time 13 | ||
31 | #define __NR_mknod 14 | ||
32 | #define __NR_chmod 15 | ||
33 | #define __NR_lchown 16 | ||
34 | #define __NR_break 17 | ||
35 | #define __NR_oldstat 18 | ||
36 | #define __NR_lseek 19 | ||
37 | #define __NR_getpid 20 | ||
38 | #define __NR_mount 21 | ||
39 | #define __NR_umount 22 | ||
40 | #define __NR_setuid 23 | ||
41 | #define __NR_getuid 24 | ||
42 | #define __NR_stime 25 | ||
43 | #define __NR_ptrace 26 | ||
44 | #define __NR_alarm 27 | ||
45 | #define __NR_oldfstat 28 | ||
46 | #define __NR_pause 29 | ||
47 | #define __NR_utime 30 | ||
48 | #define __NR_stty 31 | ||
49 | #define __NR_gtty 32 | ||
50 | #define __NR_access 33 | ||
51 | #define __NR_nice 34 | ||
52 | #define __NR_ftime 35 | ||
53 | #define __NR_sync 36 | ||
54 | #define __NR_kill 37 | ||
55 | #define __NR_rename 38 | ||
56 | #define __NR_mkdir 39 | ||
57 | #define __NR_rmdir 40 | ||
58 | #define __NR_dup 41 | ||
59 | #define __NR_pipe 42 | ||
60 | #define __NR_times 43 | ||
61 | #define __NR_prof 44 | ||
62 | #define __NR_brk 45 | ||
63 | #define __NR_setgid 46 | ||
64 | #define __NR_getgid 47 | ||
65 | #define __NR_signal 48 | ||
66 | #define __NR_geteuid 49 | ||
67 | #define __NR_getegid 50 | ||
68 | #define __NR_acct 51 | ||
69 | #define __NR_umount2 52 | ||
70 | #define __NR_lock 53 | ||
71 | #define __NR_ioctl 54 | ||
72 | #define __NR_fcntl 55 | ||
73 | #define __NR_mpx 56 | ||
74 | #define __NR_setpgid 57 | ||
75 | #define __NR_ulimit 58 | ||
76 | #define __NR_oldolduname 59 | ||
77 | #define __NR_umask 60 | ||
78 | #define __NR_chroot 61 | ||
79 | #define __NR_ustat 62 | ||
80 | #define __NR_dup2 63 | ||
81 | #define __NR_getppid 64 | ||
82 | #define __NR_getpgrp 65 | ||
83 | #define __NR_setsid 66 | ||
84 | #define __NR_sigaction 67 | ||
85 | #define __NR_sgetmask 68 | ||
86 | #define __NR_ssetmask 69 | ||
87 | #define __NR_setreuid 70 | ||
88 | #define __NR_setregid 71 | ||
89 | #define __NR_sigsuspend 72 | ||
90 | #define __NR_sigpending 73 | ||
91 | #define __NR_sethostname 74 | ||
92 | #define __NR_setrlimit 75 | ||
93 | #define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ | ||
94 | #define __NR_getrusage 77 | ||
95 | #define __NR_gettimeofday 78 | ||
96 | #define __NR_settimeofday 79 | ||
97 | #define __NR_getgroups 80 | ||
98 | #define __NR_setgroups 81 | ||
99 | #define __NR_select 82 | ||
100 | #define __NR_symlink 83 | ||
101 | #define __NR_oldlstat 84 | ||
102 | #define __NR_readlink 85 | ||
103 | #define __NR_uselib 86 | ||
104 | #define __NR_swapon 87 | ||
105 | #define __NR_reboot 88 | ||
106 | #define __NR_readdir 89 | ||
107 | #define __NR_mmap 90 | ||
108 | #define __NR_munmap 91 | ||
109 | #define __NR_truncate 92 | ||
110 | #define __NR_ftruncate 93 | ||
111 | #define __NR_fchmod 94 | ||
112 | #define __NR_fchown 95 | ||
113 | #define __NR_getpriority 96 | ||
114 | #define __NR_setpriority 97 | ||
115 | #define __NR_profil 98 | ||
116 | #define __NR_statfs 99 | ||
117 | #define __NR_fstatfs 100 | ||
118 | #define __NR_ioperm 101 | ||
119 | #define __NR_socketcall 102 /* old implementation of socket systemcall */ | ||
120 | #define __NR_syslog 103 | ||
121 | #define __NR_setitimer 104 | ||
122 | #define __NR_getitimer 105 | ||
123 | #define __NR_stat 106 | ||
124 | #define __NR_lstat 107 | ||
125 | #define __NR_fstat 108 | ||
126 | #define __NR_olduname 109 | ||
127 | #define __NR_iopl 110 | ||
128 | #define __NR_vhangup 111 | ||
129 | #define __NR_idle 112 | ||
130 | #define __NR_vm86old 113 | ||
131 | #define __NR_wait4 114 | ||
132 | #define __NR_swapoff 115 | ||
133 | #define __NR_sysinfo 116 | ||
134 | #define __NR_ipc 117 | ||
135 | #define __NR_fsync 118 | ||
136 | #define __NR_sigreturn 119 | ||
137 | #define __NR_clone 120 | ||
138 | #define __NR_setdomainname 121 | ||
139 | #define __NR_uname 122 | ||
140 | #define __NR_cacheflush 123 | ||
141 | #define __NR_adjtimex 124 | ||
142 | #define __NR_mprotect 125 | ||
143 | #define __NR_sigprocmask 126 | ||
144 | #define __NR_create_module 127 | ||
145 | #define __NR_init_module 128 | ||
146 | #define __NR_delete_module 129 | ||
147 | #define __NR_get_kernel_syms 130 | ||
148 | #define __NR_quotactl 131 | ||
149 | #define __NR_getpgid 132 | ||
150 | #define __NR_fchdir 133 | ||
151 | #define __NR_bdflush 134 | ||
152 | #define __NR_sysfs 135 | ||
153 | #define __NR_personality 136 | ||
154 | #define __NR_afs_syscall 137 /* Syscall for Andrew File System */ | ||
155 | #define __NR_setfsuid 138 | ||
156 | #define __NR_setfsgid 139 | ||
157 | #define __NR__llseek 140 | ||
158 | #define __NR_getdents 141 | ||
159 | #define __NR__newselect 142 | ||
160 | #define __NR_flock 143 | ||
161 | #define __NR_msync 144 | ||
162 | #define __NR_readv 145 | ||
163 | #define __NR_writev 146 | ||
164 | #define __NR_getsid 147 | ||
165 | #define __NR_fdatasync 148 | ||
166 | #define __NR__sysctl 149 | ||
167 | #define __NR_mlock 150 | ||
168 | #define __NR_munlock 151 | ||
169 | #define __NR_mlockall 152 | ||
170 | #define __NR_munlockall 153 | ||
171 | #define __NR_sched_setparam 154 | ||
172 | #define __NR_sched_getparam 155 | ||
173 | #define __NR_sched_setscheduler 156 | ||
174 | #define __NR_sched_getscheduler 157 | ||
175 | #define __NR_sched_yield 158 | ||
176 | #define __NR_sched_get_priority_max 159 | ||
177 | #define __NR_sched_get_priority_min 160 | ||
178 | #define __NR_sched_rr_get_interval 161 | ||
179 | #define __NR_nanosleep 162 | ||
180 | #define __NR_mremap 163 | ||
181 | #define __NR_setresuid 164 | ||
182 | #define __NR_getresuid 165 | ||
183 | #define __NR_vm86 166 | ||
184 | #define __NR_query_module 167 | ||
185 | #define __NR_poll 168 | ||
186 | #define __NR_nfsservctl 169 | ||
187 | #define __NR_setresgid 170 | ||
188 | #define __NR_getresgid 171 | ||
189 | #define __NR_prctl 172 | ||
190 | #define __NR_rt_sigreturn 173 | ||
191 | #define __NR_rt_sigaction 174 | ||
192 | #define __NR_rt_sigprocmask 175 | ||
193 | #define __NR_rt_sigpending 176 | ||
194 | #define __NR_rt_sigtimedwait 177 | ||
195 | #define __NR_rt_sigqueueinfo 178 | ||
196 | #define __NR_rt_sigsuspend 179 | ||
197 | #define __NR_pread64 180 | ||
198 | #define __NR_pwrite64 181 | ||
199 | #define __NR_chown 182 | ||
200 | #define __NR_getcwd 183 | ||
201 | #define __NR_capget 184 | ||
202 | #define __NR_capset 185 | ||
203 | #define __NR_sigaltstack 186 | ||
204 | #define __NR_sendfile 187 | ||
205 | #define __NR_streams1 188 /* some people actually want it */ | ||
206 | #define __NR_streams2 189 /* some people actually want it */ | ||
207 | #define __NR_vfork 190 | ||
208 | #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ | ||
209 | #define __NR_mmap2 192 | ||
210 | #define __NR_truncate64 193 | ||
211 | #define __NR_ftruncate64 194 | ||
212 | #define __NR_stat64 195 | ||
213 | #define __NR_lstat64 196 | ||
214 | #define __NR_fstat64 197 | ||
215 | #define __NR_lchown32 198 | ||
216 | #define __NR_getuid32 199 | ||
217 | #define __NR_getgid32 200 | ||
218 | #define __NR_geteuid32 201 | ||
219 | #define __NR_getegid32 202 | ||
220 | #define __NR_setreuid32 203 | ||
221 | #define __NR_setregid32 204 | ||
222 | #define __NR_getgroups32 205 | ||
223 | #define __NR_setgroups32 206 | ||
224 | #define __NR_fchown32 207 | ||
225 | #define __NR_setresuid32 208 | ||
226 | #define __NR_getresuid32 209 | ||
227 | #define __NR_setresgid32 210 | ||
228 | #define __NR_getresgid32 211 | ||
229 | #define __NR_chown32 212 | ||
230 | #define __NR_setuid32 213 | ||
231 | #define __NR_setgid32 214 | ||
232 | #define __NR_setfsuid32 215 | ||
233 | #define __NR_setfsgid32 216 | ||
234 | #define __NR_pivot_root 217 | ||
235 | #define __NR_mincore 218 | ||
236 | #define __NR_madvise 219 | ||
237 | |||
238 | /* Non-multiplexed socket family */ | ||
239 | #define __NR_socket 220 | ||
240 | #define __NR_bind 221 | ||
241 | #define __NR_connect 222 | ||
242 | #define __NR_listen 223 | ||
243 | #define __NR_accept 224 | ||
244 | #define __NR_getsockname 225 | ||
245 | #define __NR_getpeername 226 | ||
246 | #define __NR_socketpair 227 | ||
247 | #define __NR_send 228 | ||
248 | #define __NR_sendto 229 | ||
249 | #define __NR_recv 230 | ||
250 | #define __NR_recvfrom 231 | ||
251 | #define __NR_shutdown 232 | ||
252 | #define __NR_setsockopt 233 | ||
253 | #define __NR_getsockopt 234 | ||
254 | #define __NR_sendmsg 235 | ||
255 | #define __NR_recvmsg 236 | ||
256 | |||
257 | /* Non-multiplexed IPC family */ | ||
258 | #define __NR_semop 237 | ||
259 | #define __NR_semget 238 | ||
260 | #define __NR_semctl 239 | ||
261 | #define __NR_msgsnd 240 | ||
262 | #define __NR_msgrcv 241 | ||
263 | #define __NR_msgget 242 | ||
264 | #define __NR_msgctl 243 | ||
265 | #if 0 | ||
266 | #define __NR_shmatcall 244 | ||
267 | #endif | ||
268 | #define __NR_shmdt 245 | ||
269 | #define __NR_shmget 246 | ||
270 | #define __NR_shmctl 247 | ||
271 | |||
272 | #define __NR_getdents64 248 | ||
273 | #define __NR_fcntl64 249 | ||
274 | /* 223 is unused */ | ||
275 | #define __NR_gettid 252 | ||
276 | #define __NR_readahead 253 | ||
277 | #define __NR_setxattr 254 | ||
278 | #define __NR_lsetxattr 255 | ||
279 | #define __NR_fsetxattr 256 | ||
280 | #define __NR_getxattr 257 | ||
281 | #define __NR_lgetxattr 258 | ||
282 | #define __NR_fgetxattr 269 | ||
283 | #define __NR_listxattr 260 | ||
284 | #define __NR_llistxattr 261 | ||
285 | #define __NR_flistxattr 262 | ||
286 | #define __NR_removexattr 263 | ||
287 | #define __NR_lremovexattr 264 | ||
288 | #define __NR_fremovexattr 265 | ||
289 | #define __NR_tkill 266 | ||
290 | #define __NR_sendfile64 267 | ||
291 | #define __NR_futex 268 | ||
292 | #define __NR_sched_setaffinity 269 | ||
293 | #define __NR_sched_getaffinity 270 | ||
294 | #define __NR_set_thread_area 271 | ||
295 | #define __NR_get_thread_area 272 | ||
296 | #define __NR_io_setup 273 | ||
297 | #define __NR_io_destroy 274 | ||
298 | #define __NR_io_getevents 275 | ||
299 | #define __NR_io_submit 276 | ||
300 | #define __NR_io_cancel 277 | ||
301 | #define __NR_fadvise64 278 | ||
302 | #define __NR_exit_group 280 | ||
303 | |||
304 | #define __NR_lookup_dcookie 281 | ||
305 | #define __NR_epoll_create 282 | ||
306 | #define __NR_epoll_ctl 283 | ||
307 | #define __NR_epoll_wait 284 | ||
308 | #define __NR_remap_file_pages 285 | ||
309 | #define __NR_set_tid_address 286 | ||
310 | #define __NR_timer_create 287 | ||
311 | #define __NR_timer_settime (__NR_timer_create+1) | ||
312 | #define __NR_timer_gettime (__NR_timer_create+2) | ||
313 | #define __NR_timer_getoverrun (__NR_timer_create+3) | ||
314 | #define __NR_timer_delete (__NR_timer_create+4) | ||
315 | #define __NR_clock_settime (__NR_timer_create+5) | ||
316 | #define __NR_clock_gettime (__NR_timer_create+6) | ||
317 | #define __NR_clock_getres (__NR_timer_create+7) | ||
318 | #define __NR_clock_nanosleep (__NR_timer_create+8) | ||
319 | #define __NR_statfs64 296 | ||
320 | #define __NR_fstatfs64 297 | ||
321 | #define __NR_tgkill 298 | ||
322 | #define __NR_utimes 299 | ||
323 | #define __NR_fadvise64_64 300 | ||
324 | #define __NR_vserver 301 | ||
325 | #define __NR_mbind 302 | ||
326 | #define __NR_get_mempolicy 303 | ||
327 | #define __NR_set_mempolicy 304 | ||
328 | #define __NR_mq_open 305 | ||
329 | #define __NR_mq_unlink (__NR_mq_open+1) | ||
330 | #define __NR_mq_timedsend (__NR_mq_open+2) | ||
331 | #define __NR_mq_timedreceive (__NR_mq_open+3) | ||
332 | #define __NR_mq_notify (__NR_mq_open+4) | ||
333 | #define __NR_mq_getsetattr (__NR_mq_open+5) | ||
334 | #define __NR_kexec_load 311 | ||
335 | #define __NR_waitid 312 | ||
336 | #define __NR_add_key 313 | ||
337 | #define __NR_request_key 314 | ||
338 | #define __NR_keyctl 315 | ||
339 | #define __NR_ioprio_set 316 | ||
340 | #define __NR_ioprio_get 317 | ||
341 | #define __NR_inotify_init 318 | ||
342 | #define __NR_inotify_add_watch 319 | ||
343 | #define __NR_inotify_rm_watch 320 | ||
344 | /* 321 is unused */ | ||
345 | #define __NR_migrate_pages 322 | ||
346 | #define __NR_openat 323 | ||
347 | #define __NR_mkdirat 324 | ||
348 | #define __NR_mknodat 325 | ||
349 | #define __NR_fchownat 326 | ||
350 | #define __NR_futimesat 327 | ||
351 | #define __NR_fstatat64 328 | ||
352 | #define __NR_unlinkat 329 | ||
353 | #define __NR_renameat 330 | ||
354 | #define __NR_linkat 331 | ||
355 | #define __NR_symlinkat 332 | ||
356 | #define __NR_readlinkat 333 | ||
357 | #define __NR_fchmodat 334 | ||
358 | #define __NR_faccessat 335 | ||
359 | #define __NR_pselect6 336 | ||
360 | #define __NR_ppoll 337 | ||
361 | #define __NR_unshare 338 | ||
362 | #define __NR_set_robust_list 339 | ||
363 | #define __NR_get_robust_list 340 | ||
364 | #define __NR_splice 341 | ||
365 | #define __NR_sync_file_range 342 | ||
366 | #define __NR_tee 343 | ||
367 | #define __NR_vmsplice 344 | ||
368 | #define __NR_move_pages 345 | ||
369 | #define __NR_getcpu 346 | ||
370 | #define __NR_epoll_pwait 347 | ||
371 | #define __NR_utimensat 348 | ||
372 | #define __NR_signalfd 349 | ||
373 | #define __NR_timerfd_create 350 | ||
374 | #define __NR_eventfd 351 | ||
375 | #define __NR_fallocate 352 | ||
376 | #define __NR_timerfd_settime 353 | ||
377 | #define __NR_timerfd_gettime 354 | ||
378 | #define __NR_signalfd4 355 | ||
379 | #define __NR_eventfd2 356 | ||
380 | #define __NR_epoll_create1 357 | ||
381 | #define __NR_dup3 358 | ||
382 | #define __NR_pipe2 359 | ||
383 | #define __NR_inotify_init1 360 | ||
384 | #define __NR_preadv 361 | ||
385 | #define __NR_pwritev 362 | ||
386 | #define __NR_rt_tgsigqueueinfo 363 | ||
387 | #define __NR_perf_event_open 364 | ||
388 | #define __NR_recvmmsg 365 | ||
389 | #define __NR_accept4 366 | ||
390 | #define __NR_fanotify_init 367 | ||
391 | #define __NR_fanotify_mark 368 | ||
392 | #define __NR_prlimit64 369 | ||
393 | #define __NR_name_to_handle_at 370 | ||
394 | #define __NR_open_by_handle_at 371 | ||
395 | #define __NR_clock_adjtime 372 | ||
396 | #define __NR_syncfs 373 | ||
397 | #define __NR_sendmmsg 374 | ||
398 | #define __NR_setns 375 | ||
399 | |||
400 | #ifdef __KERNEL__ | ||
401 | |||
402 | #define NR_syscalls 376 | ||
403 | |||
404 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
405 | #define __ARCH_WANT_OLD_READDIR | ||
406 | #define __ARCH_WANT_OLD_STAT | ||
407 | #define __ARCH_WANT_STAT64 | ||
408 | #define __ARCH_WANT_SYS_ALARM | ||
409 | #define __ARCH_WANT_SYS_GETHOSTNAME | ||
410 | #define __ARCH_WANT_SYS_IPC | ||
411 | #define __ARCH_WANT_SYS_PAUSE | ||
412 | #define __ARCH_WANT_SYS_SGETMASK | ||
413 | #define __ARCH_WANT_SYS_SIGNAL | ||
414 | #define __ARCH_WANT_SYS_TIME | ||
415 | #define __ARCH_WANT_SYS_UTIME | ||
416 | #define __ARCH_WANT_SYS_WAITPID | ||
417 | #define __ARCH_WANT_SYS_SOCKETCALL | ||
418 | #define __ARCH_WANT_SYS_FADVISE64 | ||
419 | #define __ARCH_WANT_SYS_GETPGRP | ||
420 | #define __ARCH_WANT_SYS_LLSEEK | ||
421 | #define __ARCH_WANT_SYS_NICE | ||
422 | #define __ARCH_WANT_SYS_OLD_GETRLIMIT | ||
423 | #define __ARCH_WANT_SYS_OLD_UNAME | ||
424 | #define __ARCH_WANT_SYS_OLDUMOUNT | ||
425 | #define __ARCH_WANT_SYS_SIGPENDING | ||
426 | #define __ARCH_WANT_SYS_SIGPROCMASK | ||
427 | #define __ARCH_WANT_SYS_RT_SIGACTION | ||
428 | |||
429 | /* | ||
430 | * "Conditional" syscalls | ||
431 | * | ||
432 | * What we want is __attribute__((weak,alias("sys_ni_syscall"))), | ||
433 | * but it doesn't work on all toolchains, so we just do it by hand | ||
434 | */ | ||
435 | #ifndef cond_syscall | ||
436 | #define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") | ||
437 | #endif | ||
438 | |||
439 | #endif /* __KERNEL__ */ | ||
440 | #endif /* __ASM_SH_UNISTD_64_H */ | ||
diff --git a/arch/sh/include/asm/xor.h b/arch/sh/include/asm/xor.h new file mode 100644 index 00000000000..c82eb12a5b1 --- /dev/null +++ b/arch/sh/include/asm/xor.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/xor.h> | |||
diff --git a/arch/sh/include/cpu-sh2/cpu/dma.h b/arch/sh/include/cpu-sh2/cpu/dma.h new file mode 100644 index 00000000000..d66b43cdc63 --- /dev/null +++ b/arch/sh/include/cpu-sh2/cpu/dma.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * Definitions for the SH-2 DMAC. | ||
3 | * | ||
4 | * Copyright (C) 2003 Paul Mundt | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | #ifndef __ASM_CPU_SH2_DMA_H | ||
11 | #define __ASM_CPU_SH2_DMA_H | ||
12 | |||
13 | #define SH_MAX_DMA_CHANNELS 2 | ||
14 | |||
15 | #define SAR ((unsigned long[]){ 0xffffff80, 0xffffff90 }) | ||
16 | #define DAR ((unsigned long[]){ 0xffffff84, 0xffffff94 }) | ||
17 | #define DMATCR ((unsigned long[]){ 0xffffff88, 0xffffff98 }) | ||
18 | #define CHCR ((unsigned long[]){ 0xfffffffc, 0xffffff9c }) | ||
19 | |||
20 | #define DMAOR 0xffffffb0 | ||
21 | |||
22 | #endif /* __ASM_CPU_SH2_DMA_H */ | ||
23 | |||
diff --git a/arch/sh/include/cpu-sh2a/cpu/dma.h b/arch/sh/include/cpu-sh2a/cpu/dma.h new file mode 100644 index 00000000000..27a13ef4fdf --- /dev/null +++ b/arch/sh/include/cpu-sh2a/cpu/dma.h | |||
@@ -0,0 +1 @@ | |||
#include <cpu-sh2/cpu/dma.h> | |||
diff --git a/arch/sh/include/cpu-sh2a/cpu/ubc.h b/arch/sh/include/cpu-sh2a/cpu/ubc.h new file mode 100644 index 00000000000..1192e1c761a --- /dev/null +++ b/arch/sh/include/cpu-sh2a/cpu/ubc.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * SH-2A UBC definitions | ||
3 | * | ||
4 | * Copyright (C) 2008 Kieran Bingham | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #ifndef __ASM_CPU_SH2A_UBC_H | ||
12 | #define __ASM_CPU_SH2A_UBC_H | ||
13 | |||
14 | #define UBC_BARA 0xfffc0400 | ||
15 | #define UBC_BAMRA 0xfffc0404 | ||
16 | #define UBC_BBRA 0xfffc04a0 /* 16 bit access */ | ||
17 | #define UBC_BDRA 0xfffc0408 | ||
18 | #define UBC_BDMRA 0xfffc040c | ||
19 | |||
20 | #define UBC_BARB 0xfffc0410 | ||
21 | #define UBC_BAMRB 0xfffc0414 | ||
22 | #define UBC_BBRB 0xfffc04b0 /* 16 bit access */ | ||
23 | #define UBC_BDRB 0xfffc0418 | ||
24 | #define UBC_BDMRB 0xfffc041c | ||
25 | |||
26 | #define UBC_BRCR 0xfffc04c0 | ||
27 | |||
28 | #endif /* __ASM_CPU_SH2A_UBC_H */ | ||
diff --git a/arch/sh/include/cpu-sh4/cpu/dma-sh4a.h b/arch/sh/include/cpu-sh4/cpu/dma-sh4a.h new file mode 100644 index 00000000000..9647e681fd2 --- /dev/null +++ b/arch/sh/include/cpu-sh4/cpu/dma-sh4a.h | |||
@@ -0,0 +1,83 @@ | |||
1 | #ifndef __ASM_SH_CPU_SH4_DMA_SH7780_H | ||
2 | #define __ASM_SH_CPU_SH4_DMA_SH7780_H | ||
3 | |||
4 | #if defined(CONFIG_CPU_SUBTYPE_SH7343) || \ | ||
5 | defined(CONFIG_CPU_SUBTYPE_SH7730) | ||
6 | #define DMTE0_IRQ 48 | ||
7 | #define DMTE4_IRQ 76 | ||
8 | #define DMAE0_IRQ 78 /* DMA Error IRQ*/ | ||
9 | #define SH_DMAC_BASE0 0xFE008020 | ||
10 | #define SH_DMARS_BASE0 0xFE009000 | ||
11 | #elif defined(CONFIG_CPU_SUBTYPE_SH7722) | ||
12 | #define DMTE0_IRQ 48 | ||
13 | #define DMTE4_IRQ 76 | ||
14 | #define DMAE0_IRQ 78 /* DMA Error IRQ*/ | ||
15 | #define SH_DMAC_BASE0 0xFE008020 | ||
16 | #define SH_DMARS_BASE0 0xFE009000 | ||
17 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ | ||
18 | defined(CONFIG_CPU_SUBTYPE_SH7764) | ||
19 | #define DMTE0_IRQ 34 | ||
20 | #define DMTE4_IRQ 44 | ||
21 | #define DMAE0_IRQ 38 | ||
22 | #define SH_DMAC_BASE0 0xFF608020 | ||
23 | #define SH_DMARS_BASE0 0xFF609000 | ||
24 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) | ||
25 | #define DMTE0_IRQ 48 /* DMAC0A*/ | ||
26 | #define DMTE4_IRQ 76 /* DMAC0B */ | ||
27 | #define DMTE6_IRQ 40 | ||
28 | #define DMTE8_IRQ 42 /* DMAC1A */ | ||
29 | #define DMTE9_IRQ 43 | ||
30 | #define DMTE10_IRQ 72 /* DMAC1B */ | ||
31 | #define DMTE11_IRQ 73 | ||
32 | #define DMAE0_IRQ 78 /* DMA Error IRQ*/ | ||
33 | #define DMAE1_IRQ 74 /* DMA Error IRQ*/ | ||
34 | #define SH_DMAC_BASE0 0xFE008020 | ||
35 | #define SH_DMAC_BASE1 0xFDC08020 | ||
36 | #define SH_DMARS_BASE0 0xFDC09000 | ||
37 | #elif defined(CONFIG_CPU_SUBTYPE_SH7724) | ||
38 | #define DMTE0_IRQ 48 /* DMAC0A*/ | ||
39 | #define DMTE4_IRQ 76 /* DMAC0B */ | ||
40 | #define DMTE6_IRQ 40 | ||
41 | #define DMTE8_IRQ 42 /* DMAC1A */ | ||
42 | #define DMTE9_IRQ 43 | ||
43 | #define DMTE10_IRQ 72 /* DMAC1B */ | ||
44 | #define DMTE11_IRQ 73 | ||
45 | #define DMAE0_IRQ 78 /* DMA Error IRQ*/ | ||
46 | #define DMAE1_IRQ 74 /* DMA Error IRQ*/ | ||
47 | #define SH_DMAC_BASE0 0xFE008020 | ||
48 | #define SH_DMAC_BASE1 0xFDC08020 | ||
49 | #define SH_DMARS_BASE0 0xFE009000 | ||
50 | #define SH_DMARS_BASE1 0xFDC09000 | ||
51 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
52 | #define DMTE0_IRQ 34 | ||
53 | #define DMTE4_IRQ 44 | ||
54 | #define DMTE6_IRQ 46 | ||
55 | #define DMTE8_IRQ 92 | ||
56 | #define DMTE9_IRQ 93 | ||
57 | #define DMTE10_IRQ 94 | ||
58 | #define DMTE11_IRQ 95 | ||
59 | #define DMAE0_IRQ 38 /* DMA Error IRQ */ | ||
60 | #define SH_DMAC_BASE0 0xFC808020 | ||
61 | #define SH_DMAC_BASE1 0xFC818020 | ||
62 | #define SH_DMARS_BASE0 0xFC809000 | ||
63 | #else /* SH7785 */ | ||
64 | #define DMTE0_IRQ 33 | ||
65 | #define DMTE4_IRQ 37 | ||
66 | #define DMTE6_IRQ 52 | ||
67 | #define DMTE8_IRQ 54 | ||
68 | #define DMTE9_IRQ 55 | ||
69 | #define DMTE10_IRQ 56 | ||
70 | #define DMTE11_IRQ 57 | ||
71 | #define DMAE0_IRQ 39 /* DMA Error IRQ0 */ | ||
72 | #define DMAE1_IRQ 58 /* DMA Error IRQ1 */ | ||
73 | #define SH_DMAC_BASE0 0xFC808020 | ||
74 | #define SH_DMAC_BASE1 0xFCC08020 | ||
75 | #define SH_DMARS_BASE0 0xFC809000 | ||
76 | #endif | ||
77 | |||
78 | #define REQ_HE 0x000000C0 | ||
79 | #define REQ_H 0x00000080 | ||
80 | #define REQ_LE 0x00000040 | ||
81 | #define TM_BURST 0x00000020 | ||
82 | |||
83 | #endif /* __ASM_SH_CPU_SH4_DMA_SH7780_H */ | ||
diff --git a/arch/sh/include/cpu-sh5/cpu/dma.h b/arch/sh/include/cpu-sh5/cpu/dma.h new file mode 100644 index 00000000000..7bf6bb3d35e --- /dev/null +++ b/arch/sh/include/cpu-sh5/cpu/dma.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_SH_CPU_SH5_DMA_H | ||
2 | #define __ASM_SH_CPU_SH5_DMA_H | ||
3 | |||
4 | /* Nothing yet */ | ||
5 | |||
6 | #endif /* __ASM_SH_CPU_SH5_DMA_H */ | ||
diff --git a/arch/sh/kernel/cpu/hwblk.c b/arch/sh/kernel/cpu/hwblk.c new file mode 100644 index 00000000000..3e985aae5d9 --- /dev/null +++ b/arch/sh/kernel/cpu/hwblk.c | |||
@@ -0,0 +1,159 @@ | |||
1 | #include <linux/clk.h> | ||
2 | #include <linux/compiler.h> | ||
3 | #include <linux/io.h> | ||
4 | #include <linux/spinlock.h> | ||
5 | #include <asm/suspend.h> | ||
6 | #include <asm/hwblk.h> | ||
7 | #include <asm/clock.h> | ||
8 | |||
9 | static DEFINE_SPINLOCK(hwblk_lock); | ||
10 | |||
11 | static void hwblk_area_mod_cnt(struct hwblk_info *info, | ||
12 | int area, int counter, int value, int goal) | ||
13 | { | ||
14 | struct hwblk_area *hap = info->areas + area; | ||
15 | |||
16 | hap->cnt[counter] += value; | ||
17 | |||
18 | if (hap->cnt[counter] != goal) | ||
19 | return; | ||
20 | |||
21 | if (hap->flags & HWBLK_AREA_FLAG_PARENT) | ||
22 | hwblk_area_mod_cnt(info, hap->parent, counter, value, goal); | ||
23 | } | ||
24 | |||
25 | |||
26 | static int __hwblk_mod_cnt(struct hwblk_info *info, int hwblk, | ||
27 | int counter, int value, int goal) | ||
28 | { | ||
29 | struct hwblk *hp = info->hwblks + hwblk; | ||
30 | |||
31 | hp->cnt[counter] += value; | ||
32 | if (hp->cnt[counter] == goal) | ||
33 | hwblk_area_mod_cnt(info, hp->area, counter, value, goal); | ||
34 | |||
35 | return hp->cnt[counter]; | ||
36 | } | ||
37 | |||
38 | static void hwblk_mod_cnt(struct hwblk_info *info, int hwblk, | ||
39 | int counter, int value, int goal) | ||
40 | { | ||
41 | unsigned long flags; | ||
42 | |||
43 | spin_lock_irqsave(&hwblk_lock, flags); | ||
44 | __hwblk_mod_cnt(info, hwblk, counter, value, goal); | ||
45 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
46 | } | ||
47 | |||
48 | void hwblk_cnt_inc(struct hwblk_info *info, int hwblk, int counter) | ||
49 | { | ||
50 | hwblk_mod_cnt(info, hwblk, counter, 1, 1); | ||
51 | } | ||
52 | |||
53 | void hwblk_cnt_dec(struct hwblk_info *info, int hwblk, int counter) | ||
54 | { | ||
55 | hwblk_mod_cnt(info, hwblk, counter, -1, 0); | ||
56 | } | ||
57 | |||
58 | void hwblk_enable(struct hwblk_info *info, int hwblk) | ||
59 | { | ||
60 | struct hwblk *hp = info->hwblks + hwblk; | ||
61 | unsigned long tmp; | ||
62 | unsigned long flags; | ||
63 | int ret; | ||
64 | |||
65 | spin_lock_irqsave(&hwblk_lock, flags); | ||
66 | |||
67 | ret = __hwblk_mod_cnt(info, hwblk, HWBLK_CNT_USAGE, 1, 1); | ||
68 | if (ret == 1) { | ||
69 | tmp = __raw_readl(hp->mstp); | ||
70 | tmp &= ~(1 << hp->bit); | ||
71 | __raw_writel(tmp, hp->mstp); | ||
72 | } | ||
73 | |||
74 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
75 | } | ||
76 | |||
77 | void hwblk_disable(struct hwblk_info *info, int hwblk) | ||
78 | { | ||
79 | struct hwblk *hp = info->hwblks + hwblk; | ||
80 | unsigned long tmp; | ||
81 | unsigned long flags; | ||
82 | int ret; | ||
83 | |||
84 | spin_lock_irqsave(&hwblk_lock, flags); | ||
85 | |||
86 | ret = __hwblk_mod_cnt(info, hwblk, HWBLK_CNT_USAGE, -1, 0); | ||
87 | if (ret == 0) { | ||
88 | tmp = __raw_readl(hp->mstp); | ||
89 | tmp |= 1 << hp->bit; | ||
90 | __raw_writel(tmp, hp->mstp); | ||
91 | } | ||
92 | |||
93 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
94 | } | ||
95 | |||
96 | struct hwblk_info *hwblk_info; | ||
97 | |||
98 | int __init hwblk_register(struct hwblk_info *info) | ||
99 | { | ||
100 | hwblk_info = info; | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | int __init __weak arch_hwblk_init(void) | ||
105 | { | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | int __weak arch_hwblk_sleep_mode(void) | ||
110 | { | ||
111 | return SUSP_SH_SLEEP; | ||
112 | } | ||
113 | |||
114 | int __init hwblk_init(void) | ||
115 | { | ||
116 | return arch_hwblk_init(); | ||
117 | } | ||
118 | |||
119 | /* allow clocks to enable and disable hardware blocks */ | ||
120 | static int sh_hwblk_clk_enable(struct clk *clk) | ||
121 | { | ||
122 | if (!hwblk_info) | ||
123 | return -ENOENT; | ||
124 | |||
125 | hwblk_enable(hwblk_info, clk->arch_flags); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static void sh_hwblk_clk_disable(struct clk *clk) | ||
130 | { | ||
131 | if (hwblk_info) | ||
132 | hwblk_disable(hwblk_info, clk->arch_flags); | ||
133 | } | ||
134 | |||
135 | static struct clk_ops sh_hwblk_clk_ops = { | ||
136 | .enable = sh_hwblk_clk_enable, | ||
137 | .disable = sh_hwblk_clk_disable, | ||
138 | .recalc = followparent_recalc, | ||
139 | }; | ||
140 | |||
141 | int __init sh_hwblk_clk_register(struct clk *clks, int nr) | ||
142 | { | ||
143 | struct clk *clkp; | ||
144 | int ret = 0; | ||
145 | int k; | ||
146 | |||
147 | for (k = 0; !ret && (k < nr); k++) { | ||
148 | clkp = clks + k; | ||
149 | |||
150 | /* skip over clocks using hwblk 0 (HWBLK_UNKNOWN) */ | ||
151 | if (!clkp->arch_flags) | ||
152 | continue; | ||
153 | |||
154 | clkp->ops = &sh_hwblk_clk_ops; | ||
155 | ret |= clk_register(clkp); | ||
156 | } | ||
157 | |||
158 | return ret; | ||
159 | } | ||
diff --git a/arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c b/arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c new file mode 100644 index 00000000000..a288b5d9234 --- /dev/null +++ b/arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh4a/hwblk-sh7722.c | ||
3 | * | ||
4 | * SH7722 hardware block support | ||
5 | * | ||
6 | * Copyright (C) 2009 Magnus Damm | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <asm/suspend.h> | ||
25 | #include <asm/hwblk.h> | ||
26 | #include <cpu/sh7722.h> | ||
27 | |||
28 | /* SH7722 registers */ | ||
29 | #define MSTPCR0 0xa4150030 | ||
30 | #define MSTPCR1 0xa4150034 | ||
31 | #define MSTPCR2 0xa4150038 | ||
32 | |||
33 | /* SH7722 Power Domains */ | ||
34 | enum { CORE_AREA, SUB_AREA, CORE_AREA_BM }; | ||
35 | static struct hwblk_area sh7722_hwblk_area[] = { | ||
36 | [CORE_AREA] = HWBLK_AREA(0, 0), | ||
37 | [CORE_AREA_BM] = HWBLK_AREA(HWBLK_AREA_FLAG_PARENT, CORE_AREA), | ||
38 | [SUB_AREA] = HWBLK_AREA(0, 0), | ||
39 | }; | ||
40 | |||
41 | /* Table mapping HWBLK to Module Stop Bit and Power Domain */ | ||
42 | static struct hwblk sh7722_hwblk[HWBLK_NR] = { | ||
43 | [HWBLK_TLB] = HWBLK(MSTPCR0, 31, CORE_AREA), | ||
44 | [HWBLK_IC] = HWBLK(MSTPCR0, 30, CORE_AREA), | ||
45 | [HWBLK_OC] = HWBLK(MSTPCR0, 29, CORE_AREA), | ||
46 | [HWBLK_URAM] = HWBLK(MSTPCR0, 28, CORE_AREA), | ||
47 | [HWBLK_XYMEM] = HWBLK(MSTPCR0, 26, CORE_AREA), | ||
48 | [HWBLK_INTC] = HWBLK(MSTPCR0, 22, CORE_AREA), | ||
49 | [HWBLK_DMAC] = HWBLK(MSTPCR0, 21, CORE_AREA_BM), | ||
50 | [HWBLK_SHYWAY] = HWBLK(MSTPCR0, 20, CORE_AREA), | ||
51 | [HWBLK_HUDI] = HWBLK(MSTPCR0, 19, CORE_AREA), | ||
52 | [HWBLK_UBC] = HWBLK(MSTPCR0, 17, CORE_AREA), | ||
53 | [HWBLK_TMU] = HWBLK(MSTPCR0, 15, CORE_AREA), | ||
54 | [HWBLK_CMT] = HWBLK(MSTPCR0, 14, SUB_AREA), | ||
55 | [HWBLK_RWDT] = HWBLK(MSTPCR0, 13, SUB_AREA), | ||
56 | [HWBLK_FLCTL] = HWBLK(MSTPCR0, 10, CORE_AREA), | ||
57 | [HWBLK_SCIF0] = HWBLK(MSTPCR0, 7, CORE_AREA), | ||
58 | [HWBLK_SCIF1] = HWBLK(MSTPCR0, 6, CORE_AREA), | ||
59 | [HWBLK_SCIF2] = HWBLK(MSTPCR0, 5, CORE_AREA), | ||
60 | [HWBLK_SIO] = HWBLK(MSTPCR0, 3, CORE_AREA), | ||
61 | [HWBLK_SIOF0] = HWBLK(MSTPCR0, 2, CORE_AREA), | ||
62 | [HWBLK_SIOF1] = HWBLK(MSTPCR0, 1, CORE_AREA), | ||
63 | |||
64 | [HWBLK_IIC] = HWBLK(MSTPCR1, 9, CORE_AREA), | ||
65 | [HWBLK_RTC] = HWBLK(MSTPCR1, 8, SUB_AREA), | ||
66 | |||
67 | [HWBLK_TPU] = HWBLK(MSTPCR2, 25, CORE_AREA), | ||
68 | [HWBLK_IRDA] = HWBLK(MSTPCR2, 24, CORE_AREA), | ||
69 | [HWBLK_SDHI] = HWBLK(MSTPCR2, 18, CORE_AREA), | ||
70 | [HWBLK_SIM] = HWBLK(MSTPCR2, 16, CORE_AREA), | ||
71 | [HWBLK_KEYSC] = HWBLK(MSTPCR2, 14, SUB_AREA), | ||
72 | [HWBLK_TSIF] = HWBLK(MSTPCR2, 13, SUB_AREA), | ||
73 | [HWBLK_USBF] = HWBLK(MSTPCR2, 11, CORE_AREA), | ||
74 | [HWBLK_2DG] = HWBLK(MSTPCR2, 9, CORE_AREA_BM), | ||
75 | [HWBLK_SIU] = HWBLK(MSTPCR2, 8, CORE_AREA), | ||
76 | [HWBLK_JPU] = HWBLK(MSTPCR2, 6, CORE_AREA_BM), | ||
77 | [HWBLK_VOU] = HWBLK(MSTPCR2, 5, CORE_AREA_BM), | ||
78 | [HWBLK_BEU] = HWBLK(MSTPCR2, 4, CORE_AREA_BM), | ||
79 | [HWBLK_CEU] = HWBLK(MSTPCR2, 3, CORE_AREA_BM), | ||
80 | [HWBLK_VEU] = HWBLK(MSTPCR2, 2, CORE_AREA_BM), | ||
81 | [HWBLK_VPU] = HWBLK(MSTPCR2, 1, CORE_AREA_BM), | ||
82 | [HWBLK_LCDC] = HWBLK(MSTPCR2, 0, CORE_AREA_BM), | ||
83 | }; | ||
84 | |||
85 | static struct hwblk_info sh7722_hwblk_info = { | ||
86 | .areas = sh7722_hwblk_area, | ||
87 | .nr_areas = ARRAY_SIZE(sh7722_hwblk_area), | ||
88 | .hwblks = sh7722_hwblk, | ||
89 | .nr_hwblks = ARRAY_SIZE(sh7722_hwblk), | ||
90 | }; | ||
91 | |||
92 | int arch_hwblk_sleep_mode(void) | ||
93 | { | ||
94 | if (!sh7722_hwblk_area[CORE_AREA].cnt[HWBLK_CNT_USAGE]) | ||
95 | return SUSP_SH_STANDBY | SUSP_SH_SF; | ||
96 | |||
97 | if (!sh7722_hwblk_area[CORE_AREA_BM].cnt[HWBLK_CNT_USAGE]) | ||
98 | return SUSP_SH_SLEEP | SUSP_SH_SF; | ||
99 | |||
100 | return SUSP_SH_SLEEP; | ||
101 | } | ||
102 | |||
103 | int __init arch_hwblk_init(void) | ||
104 | { | ||
105 | return hwblk_register(&sh7722_hwblk_info); | ||
106 | } | ||
diff --git a/arch/sh/kernel/cpu/sh4a/hwblk-sh7723.c b/arch/sh/kernel/cpu/sh4a/hwblk-sh7723.c new file mode 100644 index 00000000000..a7f4684d203 --- /dev/null +++ b/arch/sh/kernel/cpu/sh4a/hwblk-sh7723.c | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh4a/hwblk-sh7723.c | ||
3 | * | ||
4 | * SH7723 hardware block support | ||
5 | * | ||
6 | * Copyright (C) 2009 Magnus Damm | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <asm/suspend.h> | ||
25 | #include <asm/hwblk.h> | ||
26 | #include <cpu/sh7723.h> | ||
27 | |||
28 | /* SH7723 registers */ | ||
29 | #define MSTPCR0 0xa4150030 | ||
30 | #define MSTPCR1 0xa4150034 | ||
31 | #define MSTPCR2 0xa4150038 | ||
32 | |||
33 | /* SH7723 Power Domains */ | ||
34 | enum { CORE_AREA, SUB_AREA, CORE_AREA_BM }; | ||
35 | static struct hwblk_area sh7723_hwblk_area[] = { | ||
36 | [CORE_AREA] = HWBLK_AREA(0, 0), | ||
37 | [CORE_AREA_BM] = HWBLK_AREA(HWBLK_AREA_FLAG_PARENT, CORE_AREA), | ||
38 | [SUB_AREA] = HWBLK_AREA(0, 0), | ||
39 | }; | ||
40 | |||
41 | /* Table mapping HWBLK to Module Stop Bit and Power Domain */ | ||
42 | static struct hwblk sh7723_hwblk[HWBLK_NR] = { | ||
43 | [HWBLK_TLB] = HWBLK(MSTPCR0, 31, CORE_AREA), | ||
44 | [HWBLK_IC] = HWBLK(MSTPCR0, 30, CORE_AREA), | ||
45 | [HWBLK_OC] = HWBLK(MSTPCR0, 29, CORE_AREA), | ||
46 | [HWBLK_L2C] = HWBLK(MSTPCR0, 28, CORE_AREA), | ||
47 | [HWBLK_ILMEM] = HWBLK(MSTPCR0, 27, CORE_AREA), | ||
48 | [HWBLK_FPU] = HWBLK(MSTPCR0, 24, CORE_AREA), | ||
49 | [HWBLK_INTC] = HWBLK(MSTPCR0, 22, CORE_AREA), | ||
50 | [HWBLK_DMAC0] = HWBLK(MSTPCR0, 21, CORE_AREA_BM), | ||
51 | [HWBLK_SHYWAY] = HWBLK(MSTPCR0, 20, CORE_AREA), | ||
52 | [HWBLK_HUDI] = HWBLK(MSTPCR0, 19, CORE_AREA), | ||
53 | [HWBLK_DBG] = HWBLK(MSTPCR0, 18, CORE_AREA), | ||
54 | [HWBLK_UBC] = HWBLK(MSTPCR0, 17, CORE_AREA), | ||
55 | [HWBLK_SUBC] = HWBLK(MSTPCR0, 16, CORE_AREA), | ||
56 | [HWBLK_TMU0] = HWBLK(MSTPCR0, 15, CORE_AREA), | ||
57 | [HWBLK_CMT] = HWBLK(MSTPCR0, 14, SUB_AREA), | ||
58 | [HWBLK_RWDT] = HWBLK(MSTPCR0, 13, SUB_AREA), | ||
59 | [HWBLK_DMAC1] = HWBLK(MSTPCR0, 12, CORE_AREA_BM), | ||
60 | [HWBLK_TMU1] = HWBLK(MSTPCR0, 11, CORE_AREA), | ||
61 | [HWBLK_FLCTL] = HWBLK(MSTPCR0, 10, CORE_AREA), | ||
62 | [HWBLK_SCIF0] = HWBLK(MSTPCR0, 9, CORE_AREA), | ||
63 | [HWBLK_SCIF1] = HWBLK(MSTPCR0, 8, CORE_AREA), | ||
64 | [HWBLK_SCIF2] = HWBLK(MSTPCR0, 7, CORE_AREA), | ||
65 | [HWBLK_SCIF3] = HWBLK(MSTPCR0, 6, CORE_AREA), | ||
66 | [HWBLK_SCIF4] = HWBLK(MSTPCR0, 5, CORE_AREA), | ||
67 | [HWBLK_SCIF5] = HWBLK(MSTPCR0, 4, CORE_AREA), | ||
68 | [HWBLK_MSIOF0] = HWBLK(MSTPCR0, 2, CORE_AREA), | ||
69 | [HWBLK_MSIOF1] = HWBLK(MSTPCR0, 1, CORE_AREA), | ||
70 | [HWBLK_MERAM] = HWBLK(MSTPCR0, 0, CORE_AREA), | ||
71 | |||
72 | [HWBLK_IIC] = HWBLK(MSTPCR1, 9, CORE_AREA), | ||
73 | [HWBLK_RTC] = HWBLK(MSTPCR1, 8, SUB_AREA), | ||
74 | |||
75 | [HWBLK_ATAPI] = HWBLK(MSTPCR2, 28, CORE_AREA_BM), | ||
76 | [HWBLK_ADC] = HWBLK(MSTPCR2, 27, CORE_AREA), | ||
77 | [HWBLK_TPU] = HWBLK(MSTPCR2, 25, CORE_AREA), | ||
78 | [HWBLK_IRDA] = HWBLK(MSTPCR2, 24, CORE_AREA), | ||
79 | [HWBLK_TSIF] = HWBLK(MSTPCR2, 22, CORE_AREA), | ||
80 | [HWBLK_ICB] = HWBLK(MSTPCR2, 21, CORE_AREA_BM), | ||
81 | [HWBLK_SDHI0] = HWBLK(MSTPCR2, 18, CORE_AREA), | ||
82 | [HWBLK_SDHI1] = HWBLK(MSTPCR2, 17, CORE_AREA), | ||
83 | [HWBLK_KEYSC] = HWBLK(MSTPCR2, 14, SUB_AREA), | ||
84 | [HWBLK_USB] = HWBLK(MSTPCR2, 11, CORE_AREA), | ||
85 | [HWBLK_2DG] = HWBLK(MSTPCR2, 10, CORE_AREA_BM), | ||
86 | [HWBLK_SIU] = HWBLK(MSTPCR2, 8, CORE_AREA), | ||
87 | [HWBLK_VEU2H1] = HWBLK(MSTPCR2, 6, CORE_AREA_BM), | ||
88 | [HWBLK_VOU] = HWBLK(MSTPCR2, 5, CORE_AREA_BM), | ||
89 | [HWBLK_BEU] = HWBLK(MSTPCR2, 4, CORE_AREA_BM), | ||
90 | [HWBLK_CEU] = HWBLK(MSTPCR2, 3, CORE_AREA_BM), | ||
91 | [HWBLK_VEU2H0] = HWBLK(MSTPCR2, 2, CORE_AREA_BM), | ||
92 | [HWBLK_VPU] = HWBLK(MSTPCR2, 1, CORE_AREA_BM), | ||
93 | [HWBLK_LCDC] = HWBLK(MSTPCR2, 0, CORE_AREA_BM), | ||
94 | }; | ||
95 | |||
96 | static struct hwblk_info sh7723_hwblk_info = { | ||
97 | .areas = sh7723_hwblk_area, | ||
98 | .nr_areas = ARRAY_SIZE(sh7723_hwblk_area), | ||
99 | .hwblks = sh7723_hwblk, | ||
100 | .nr_hwblks = ARRAY_SIZE(sh7723_hwblk), | ||
101 | }; | ||
102 | |||
103 | int arch_hwblk_sleep_mode(void) | ||
104 | { | ||
105 | if (!sh7723_hwblk_area[CORE_AREA].cnt[HWBLK_CNT_USAGE]) | ||
106 | return SUSP_SH_STANDBY | SUSP_SH_SF; | ||
107 | |||
108 | if (!sh7723_hwblk_area[CORE_AREA_BM].cnt[HWBLK_CNT_USAGE]) | ||
109 | return SUSP_SH_SLEEP | SUSP_SH_SF; | ||
110 | |||
111 | return SUSP_SH_SLEEP; | ||
112 | } | ||
113 | |||
114 | int __init arch_hwblk_init(void) | ||
115 | { | ||
116 | return hwblk_register(&sh7723_hwblk_info); | ||
117 | } | ||
diff --git a/arch/sh/kernel/cpu/sh4a/hwblk-sh7724.c b/arch/sh/kernel/cpu/sh4a/hwblk-sh7724.c new file mode 100644 index 00000000000..1613ad6013c --- /dev/null +++ b/arch/sh/kernel/cpu/sh4a/hwblk-sh7724.c | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh4a/hwblk-sh7724.c | ||
3 | * | ||
4 | * SH7724 hardware block support | ||
5 | * | ||
6 | * Copyright (C) 2009 Magnus Damm | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <asm/suspend.h> | ||
25 | #include <asm/hwblk.h> | ||
26 | #include <cpu/sh7724.h> | ||
27 | |||
28 | /* SH7724 registers */ | ||
29 | #define MSTPCR0 0xa4150030 | ||
30 | #define MSTPCR1 0xa4150034 | ||
31 | #define MSTPCR2 0xa4150038 | ||
32 | |||
33 | /* SH7724 Power Domains */ | ||
34 | enum { CORE_AREA, SUB_AREA, CORE_AREA_BM }; | ||
35 | static struct hwblk_area sh7724_hwblk_area[] = { | ||
36 | [CORE_AREA] = HWBLK_AREA(0, 0), | ||
37 | [CORE_AREA_BM] = HWBLK_AREA(HWBLK_AREA_FLAG_PARENT, CORE_AREA), | ||
38 | [SUB_AREA] = HWBLK_AREA(0, 0), | ||
39 | }; | ||
40 | |||
41 | /* Table mapping HWBLK to Module Stop Bit and Power Domain */ | ||
42 | static struct hwblk sh7724_hwblk[HWBLK_NR] = { | ||
43 | [HWBLK_TLB] = HWBLK(MSTPCR0, 31, CORE_AREA), | ||
44 | [HWBLK_IC] = HWBLK(MSTPCR0, 30, CORE_AREA), | ||
45 | [HWBLK_OC] = HWBLK(MSTPCR0, 29, CORE_AREA), | ||
46 | [HWBLK_RSMEM] = HWBLK(MSTPCR0, 28, CORE_AREA), | ||
47 | [HWBLK_ILMEM] = HWBLK(MSTPCR0, 27, CORE_AREA), | ||
48 | [HWBLK_L2C] = HWBLK(MSTPCR0, 26, CORE_AREA), | ||
49 | [HWBLK_FPU] = HWBLK(MSTPCR0, 24, CORE_AREA), | ||
50 | [HWBLK_INTC] = HWBLK(MSTPCR0, 22, CORE_AREA), | ||
51 | [HWBLK_DMAC0] = HWBLK(MSTPCR0, 21, CORE_AREA_BM), | ||
52 | [HWBLK_SHYWAY] = HWBLK(MSTPCR0, 20, CORE_AREA), | ||
53 | [HWBLK_HUDI] = HWBLK(MSTPCR0, 19, CORE_AREA), | ||
54 | [HWBLK_DBG] = HWBLK(MSTPCR0, 18, CORE_AREA), | ||
55 | [HWBLK_UBC] = HWBLK(MSTPCR0, 17, CORE_AREA), | ||
56 | [HWBLK_TMU0] = HWBLK(MSTPCR0, 15, CORE_AREA), | ||
57 | [HWBLK_CMT] = HWBLK(MSTPCR0, 14, SUB_AREA), | ||
58 | [HWBLK_RWDT] = HWBLK(MSTPCR0, 13, SUB_AREA), | ||
59 | [HWBLK_DMAC1] = HWBLK(MSTPCR0, 12, CORE_AREA_BM), | ||
60 | [HWBLK_TMU1] = HWBLK(MSTPCR0, 10, CORE_AREA), | ||
61 | [HWBLK_SCIF0] = HWBLK(MSTPCR0, 9, CORE_AREA), | ||
62 | [HWBLK_SCIF1] = HWBLK(MSTPCR0, 8, CORE_AREA), | ||
63 | [HWBLK_SCIF2] = HWBLK(MSTPCR0, 7, CORE_AREA), | ||
64 | [HWBLK_SCIF3] = HWBLK(MSTPCR0, 6, CORE_AREA), | ||
65 | [HWBLK_SCIF4] = HWBLK(MSTPCR0, 5, CORE_AREA), | ||
66 | [HWBLK_SCIF5] = HWBLK(MSTPCR0, 4, CORE_AREA), | ||
67 | [HWBLK_MSIOF0] = HWBLK(MSTPCR0, 2, CORE_AREA), | ||
68 | [HWBLK_MSIOF1] = HWBLK(MSTPCR0, 1, CORE_AREA), | ||
69 | |||
70 | [HWBLK_KEYSC] = HWBLK(MSTPCR1, 12, SUB_AREA), | ||
71 | [HWBLK_RTC] = HWBLK(MSTPCR1, 11, SUB_AREA), | ||
72 | [HWBLK_IIC0] = HWBLK(MSTPCR1, 9, CORE_AREA), | ||
73 | [HWBLK_IIC1] = HWBLK(MSTPCR1, 8, CORE_AREA), | ||
74 | |||
75 | [HWBLK_MMC] = HWBLK(MSTPCR2, 29, CORE_AREA), | ||
76 | [HWBLK_ETHER] = HWBLK(MSTPCR2, 28, CORE_AREA_BM), | ||
77 | [HWBLK_ATAPI] = HWBLK(MSTPCR2, 26, CORE_AREA_BM), | ||
78 | [HWBLK_TPU] = HWBLK(MSTPCR2, 25, CORE_AREA), | ||
79 | [HWBLK_IRDA] = HWBLK(MSTPCR2, 24, CORE_AREA), | ||
80 | [HWBLK_TSIF] = HWBLK(MSTPCR2, 22, CORE_AREA), | ||
81 | [HWBLK_USB1] = HWBLK(MSTPCR2, 21, CORE_AREA), | ||
82 | [HWBLK_USB0] = HWBLK(MSTPCR2, 20, CORE_AREA), | ||
83 | [HWBLK_2DG] = HWBLK(MSTPCR2, 19, CORE_AREA_BM), | ||
84 | [HWBLK_SDHI0] = HWBLK(MSTPCR2, 18, CORE_AREA), | ||
85 | [HWBLK_SDHI1] = HWBLK(MSTPCR2, 17, CORE_AREA), | ||
86 | [HWBLK_VEU1] = HWBLK(MSTPCR2, 15, CORE_AREA_BM), | ||
87 | [HWBLK_CEU1] = HWBLK(MSTPCR2, 13, CORE_AREA_BM), | ||
88 | [HWBLK_BEU1] = HWBLK(MSTPCR2, 12, CORE_AREA_BM), | ||
89 | [HWBLK_2DDMAC] = HWBLK(MSTPCR2, 10, CORE_AREA_BM), | ||
90 | [HWBLK_SPU] = HWBLK(MSTPCR2, 9, CORE_AREA_BM), | ||
91 | [HWBLK_JPU] = HWBLK(MSTPCR2, 6, CORE_AREA_BM), | ||
92 | [HWBLK_VOU] = HWBLK(MSTPCR2, 5, CORE_AREA_BM), | ||
93 | [HWBLK_BEU0] = HWBLK(MSTPCR2, 4, CORE_AREA_BM), | ||
94 | [HWBLK_CEU0] = HWBLK(MSTPCR2, 3, CORE_AREA_BM), | ||
95 | [HWBLK_VEU0] = HWBLK(MSTPCR2, 2, CORE_AREA_BM), | ||
96 | [HWBLK_VPU] = HWBLK(MSTPCR2, 1, CORE_AREA_BM), | ||
97 | [HWBLK_LCDC] = HWBLK(MSTPCR2, 0, CORE_AREA_BM), | ||
98 | }; | ||
99 | |||
100 | static struct hwblk_info sh7724_hwblk_info = { | ||
101 | .areas = sh7724_hwblk_area, | ||
102 | .nr_areas = ARRAY_SIZE(sh7724_hwblk_area), | ||
103 | .hwblks = sh7724_hwblk, | ||
104 | .nr_hwblks = ARRAY_SIZE(sh7724_hwblk), | ||
105 | }; | ||
106 | |||
107 | int arch_hwblk_sleep_mode(void) | ||
108 | { | ||
109 | if (!sh7724_hwblk_area[CORE_AREA].cnt[HWBLK_CNT_USAGE]) | ||
110 | return SUSP_SH_STANDBY | SUSP_SH_SF; | ||
111 | |||
112 | if (!sh7724_hwblk_area[CORE_AREA_BM].cnt[HWBLK_CNT_USAGE]) | ||
113 | return SUSP_SH_SLEEP | SUSP_SH_SF; | ||
114 | |||
115 | return SUSP_SH_SLEEP; | ||
116 | } | ||
117 | |||
118 | int __init arch_hwblk_init(void) | ||
119 | { | ||
120 | return hwblk_register(&sh7724_hwblk_info); | ||
121 | } | ||
diff --git a/arch/sh/kernel/cpu/shmobile/pm_runtime.c b/arch/sh/kernel/cpu/shmobile/pm_runtime.c new file mode 100644 index 00000000000..bf280c812d2 --- /dev/null +++ b/arch/sh/kernel/cpu/shmobile/pm_runtime.c | |||
@@ -0,0 +1,319 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/shmobile/pm_runtime.c | ||
3 | * | ||
4 | * Runtime PM support code for SuperH Mobile | ||
5 | * | ||
6 | * Copyright (C) 2009 Magnus Damm | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file "COPYING" in the main directory of this archive | ||
10 | * for more details. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/pm_runtime.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/mutex.h> | ||
18 | #include <asm/hwblk.h> | ||
19 | |||
20 | static DEFINE_SPINLOCK(hwblk_lock); | ||
21 | static LIST_HEAD(hwblk_idle_list); | ||
22 | static struct work_struct hwblk_work; | ||
23 | |||
24 | extern struct hwblk_info *hwblk_info; | ||
25 | |||
26 | static void platform_pm_runtime_not_idle(struct platform_device *pdev) | ||
27 | { | ||
28 | unsigned long flags; | ||
29 | |||
30 | /* remove device from idle list */ | ||
31 | spin_lock_irqsave(&hwblk_lock, flags); | ||
32 | if (test_bit(PDEV_ARCHDATA_FLAG_IDLE, &pdev->archdata.flags)) { | ||
33 | list_del(&pdev->archdata.entry); | ||
34 | __clear_bit(PDEV_ARCHDATA_FLAG_IDLE, &pdev->archdata.flags); | ||
35 | } | ||
36 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
37 | } | ||
38 | |||
39 | static int __platform_pm_runtime_resume(struct platform_device *pdev) | ||
40 | { | ||
41 | struct device *d = &pdev->dev; | ||
42 | struct pdev_archdata *ad = &pdev->archdata; | ||
43 | int hwblk = ad->hwblk_id; | ||
44 | int ret = -ENOSYS; | ||
45 | |||
46 | dev_dbg(d, "__platform_pm_runtime_resume() [%d]\n", hwblk); | ||
47 | |||
48 | if (d->driver) { | ||
49 | hwblk_enable(hwblk_info, hwblk); | ||
50 | ret = 0; | ||
51 | |||
52 | if (test_bit(PDEV_ARCHDATA_FLAG_SUSP, &ad->flags)) { | ||
53 | if (d->driver->pm && d->driver->pm->runtime_resume) | ||
54 | ret = d->driver->pm->runtime_resume(d); | ||
55 | |||
56 | if (!ret) | ||
57 | clear_bit(PDEV_ARCHDATA_FLAG_SUSP, &ad->flags); | ||
58 | else | ||
59 | hwblk_disable(hwblk_info, hwblk); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | dev_dbg(d, "__platform_pm_runtime_resume() [%d] - returns %d\n", | ||
64 | hwblk, ret); | ||
65 | |||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | static int __platform_pm_runtime_suspend(struct platform_device *pdev) | ||
70 | { | ||
71 | struct device *d = &pdev->dev; | ||
72 | struct pdev_archdata *ad = &pdev->archdata; | ||
73 | int hwblk = ad->hwblk_id; | ||
74 | int ret = -ENOSYS; | ||
75 | |||
76 | dev_dbg(d, "__platform_pm_runtime_suspend() [%d]\n", hwblk); | ||
77 | |||
78 | if (d->driver) { | ||
79 | BUG_ON(!test_bit(PDEV_ARCHDATA_FLAG_IDLE, &ad->flags)); | ||
80 | ret = 0; | ||
81 | |||
82 | if (d->driver->pm && d->driver->pm->runtime_suspend) { | ||
83 | hwblk_enable(hwblk_info, hwblk); | ||
84 | ret = d->driver->pm->runtime_suspend(d); | ||
85 | hwblk_disable(hwblk_info, hwblk); | ||
86 | } | ||
87 | |||
88 | if (!ret) { | ||
89 | set_bit(PDEV_ARCHDATA_FLAG_SUSP, &ad->flags); | ||
90 | platform_pm_runtime_not_idle(pdev); | ||
91 | hwblk_cnt_dec(hwblk_info, hwblk, HWBLK_CNT_IDLE); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | dev_dbg(d, "__platform_pm_runtime_suspend() [%d] - returns %d\n", | ||
96 | hwblk, ret); | ||
97 | |||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | static void platform_pm_runtime_work(struct work_struct *work) | ||
102 | { | ||
103 | struct platform_device *pdev; | ||
104 | unsigned long flags; | ||
105 | int ret; | ||
106 | |||
107 | /* go through the idle list and suspend one device at a time */ | ||
108 | do { | ||
109 | spin_lock_irqsave(&hwblk_lock, flags); | ||
110 | if (list_empty(&hwblk_idle_list)) | ||
111 | pdev = NULL; | ||
112 | else | ||
113 | pdev = list_first_entry(&hwblk_idle_list, | ||
114 | struct platform_device, | ||
115 | archdata.entry); | ||
116 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
117 | |||
118 | if (pdev) { | ||
119 | mutex_lock(&pdev->archdata.mutex); | ||
120 | ret = __platform_pm_runtime_suspend(pdev); | ||
121 | |||
122 | /* at this point the platform device may be: | ||
123 | * suspended: ret = 0, FLAG_SUSP set, clock stopped | ||
124 | * failed: ret < 0, FLAG_IDLE set, clock stopped | ||
125 | */ | ||
126 | mutex_unlock(&pdev->archdata.mutex); | ||
127 | } else { | ||
128 | ret = -ENODEV; | ||
129 | } | ||
130 | } while (!ret); | ||
131 | } | ||
132 | |||
133 | /* this function gets called from cpuidle context when all devices in the | ||
134 | * main power domain are unused but some are counted as idle, ie the hwblk | ||
135 | * counter values are (HWBLK_CNT_USAGE == 0) && (HWBLK_CNT_IDLE != 0) | ||
136 | */ | ||
137 | void platform_pm_runtime_suspend_idle(void) | ||
138 | { | ||
139 | queue_work(pm_wq, &hwblk_work); | ||
140 | } | ||
141 | |||
142 | static int default_platform_runtime_suspend(struct device *dev) | ||
143 | { | ||
144 | struct platform_device *pdev = to_platform_device(dev); | ||
145 | struct pdev_archdata *ad = &pdev->archdata; | ||
146 | unsigned long flags; | ||
147 | int hwblk = ad->hwblk_id; | ||
148 | int ret = 0; | ||
149 | |||
150 | dev_dbg(dev, "%s() [%d]\n", __func__, hwblk); | ||
151 | |||
152 | /* ignore off-chip platform devices */ | ||
153 | if (!hwblk) | ||
154 | goto out; | ||
155 | |||
156 | /* interrupt context not allowed */ | ||
157 | might_sleep(); | ||
158 | |||
159 | /* catch misconfigured drivers not starting with resume */ | ||
160 | if (test_bit(PDEV_ARCHDATA_FLAG_INIT, &ad->flags)) { | ||
161 | ret = -EINVAL; | ||
162 | goto out; | ||
163 | } | ||
164 | |||
165 | /* serialize */ | ||
166 | mutex_lock(&ad->mutex); | ||
167 | |||
168 | /* disable clock */ | ||
169 | hwblk_disable(hwblk_info, hwblk); | ||
170 | |||
171 | /* put device on idle list */ | ||
172 | spin_lock_irqsave(&hwblk_lock, flags); | ||
173 | list_add_tail(&ad->entry, &hwblk_idle_list); | ||
174 | __set_bit(PDEV_ARCHDATA_FLAG_IDLE, &ad->flags); | ||
175 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
176 | |||
177 | /* increase idle count */ | ||
178 | hwblk_cnt_inc(hwblk_info, hwblk, HWBLK_CNT_IDLE); | ||
179 | |||
180 | /* at this point the platform device is: | ||
181 | * idle: ret = 0, FLAG_IDLE set, clock stopped | ||
182 | */ | ||
183 | mutex_unlock(&ad->mutex); | ||
184 | |||
185 | out: | ||
186 | dev_dbg(dev, "%s() [%d] returns %d\n", | ||
187 | __func__, hwblk, ret); | ||
188 | |||
189 | return ret; | ||
190 | } | ||
191 | |||
192 | static int default_platform_runtime_resume(struct device *dev) | ||
193 | { | ||
194 | struct platform_device *pdev = to_platform_device(dev); | ||
195 | struct pdev_archdata *ad = &pdev->archdata; | ||
196 | int hwblk = ad->hwblk_id; | ||
197 | int ret = 0; | ||
198 | |||
199 | dev_dbg(dev, "%s() [%d]\n", __func__, hwblk); | ||
200 | |||
201 | /* ignore off-chip platform devices */ | ||
202 | if (!hwblk) | ||
203 | goto out; | ||
204 | |||
205 | /* interrupt context not allowed */ | ||
206 | might_sleep(); | ||
207 | |||
208 | /* serialize */ | ||
209 | mutex_lock(&ad->mutex); | ||
210 | |||
211 | /* make sure device is removed from idle list */ | ||
212 | platform_pm_runtime_not_idle(pdev); | ||
213 | |||
214 | /* decrease idle count */ | ||
215 | if (!test_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags) && | ||
216 | !test_bit(PDEV_ARCHDATA_FLAG_SUSP, &pdev->archdata.flags)) | ||
217 | hwblk_cnt_dec(hwblk_info, hwblk, HWBLK_CNT_IDLE); | ||
218 | |||
219 | /* resume the device if needed */ | ||
220 | ret = __platform_pm_runtime_resume(pdev); | ||
221 | |||
222 | /* the driver has been initialized now, so clear the init flag */ | ||
223 | clear_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags); | ||
224 | |||
225 | /* at this point the platform device may be: | ||
226 | * resumed: ret = 0, flags = 0, clock started | ||
227 | * failed: ret < 0, FLAG_SUSP set, clock stopped | ||
228 | */ | ||
229 | mutex_unlock(&ad->mutex); | ||
230 | out: | ||
231 | dev_dbg(dev, "%s() [%d] returns %d\n", | ||
232 | __func__, hwblk, ret); | ||
233 | |||
234 | return ret; | ||
235 | } | ||
236 | |||
237 | static int default_platform_runtime_idle(struct device *dev) | ||
238 | { | ||
239 | struct platform_device *pdev = to_platform_device(dev); | ||
240 | int hwblk = pdev->archdata.hwblk_id; | ||
241 | int ret = 0; | ||
242 | |||
243 | dev_dbg(dev, "%s() [%d]\n", __func__, hwblk); | ||
244 | |||
245 | /* ignore off-chip platform devices */ | ||
246 | if (!hwblk) | ||
247 | goto out; | ||
248 | |||
249 | /* interrupt context not allowed, use pm_runtime_put()! */ | ||
250 | might_sleep(); | ||
251 | |||
252 | /* suspend synchronously to disable clocks immediately */ | ||
253 | ret = pm_runtime_suspend(dev); | ||
254 | out: | ||
255 | dev_dbg(dev, "%s() [%d] done!\n", __func__, hwblk); | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | static struct dev_pm_domain default_pm_domain = { | ||
260 | .ops = { | ||
261 | .runtime_suspend = default_platform_runtime_suspend, | ||
262 | .runtime_resume = default_platform_runtime_resume, | ||
263 | .runtime_idle = default_platform_runtime_idle, | ||
264 | USE_PLATFORM_PM_SLEEP_OPS | ||
265 | }, | ||
266 | }; | ||
267 | |||
268 | static int platform_bus_notify(struct notifier_block *nb, | ||
269 | unsigned long action, void *data) | ||
270 | { | ||
271 | struct device *dev = data; | ||
272 | struct platform_device *pdev = to_platform_device(dev); | ||
273 | int hwblk = pdev->archdata.hwblk_id; | ||
274 | |||
275 | /* ignore off-chip platform devices */ | ||
276 | if (!hwblk) | ||
277 | return 0; | ||
278 | |||
279 | switch (action) { | ||
280 | case BUS_NOTIFY_ADD_DEVICE: | ||
281 | INIT_LIST_HEAD(&pdev->archdata.entry); | ||
282 | mutex_init(&pdev->archdata.mutex); | ||
283 | /* platform devices without drivers should be disabled */ | ||
284 | hwblk_enable(hwblk_info, hwblk); | ||
285 | hwblk_disable(hwblk_info, hwblk); | ||
286 | /* make sure driver re-inits itself once */ | ||
287 | __set_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags); | ||
288 | dev->pm_domain = &default_pm_domain; | ||
289 | break; | ||
290 | /* TODO: add BUS_NOTIFY_BIND_DRIVER and increase idle count */ | ||
291 | case BUS_NOTIFY_BOUND_DRIVER: | ||
292 | /* keep track of number of devices in use per hwblk */ | ||
293 | hwblk_cnt_inc(hwblk_info, hwblk, HWBLK_CNT_DEVICES); | ||
294 | break; | ||
295 | case BUS_NOTIFY_UNBOUND_DRIVER: | ||
296 | /* keep track of number of devices in use per hwblk */ | ||
297 | hwblk_cnt_dec(hwblk_info, hwblk, HWBLK_CNT_DEVICES); | ||
298 | /* make sure driver re-inits itself once */ | ||
299 | __set_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags); | ||
300 | break; | ||
301 | case BUS_NOTIFY_DEL_DEVICE: | ||
302 | dev->pm_domain = NULL; | ||
303 | break; | ||
304 | } | ||
305 | return 0; | ||
306 | } | ||
307 | |||
308 | static struct notifier_block platform_bus_notifier = { | ||
309 | .notifier_call = platform_bus_notify | ||
310 | }; | ||
311 | |||
312 | static int __init sh_pm_runtime_init(void) | ||
313 | { | ||
314 | INIT_WORK(&hwblk_work, platform_pm_runtime_work); | ||
315 | |||
316 | bus_register_notifier(&platform_bus_type, &platform_bus_notifier); | ||
317 | return 0; | ||
318 | } | ||
319 | core_initcall(sh_pm_runtime_init); | ||
diff --git a/arch/sh/kernel/init_task.c b/arch/sh/kernel/init_task.c new file mode 100644 index 00000000000..11f2ea556a6 --- /dev/null +++ b/arch/sh/kernel/init_task.c | |||
@@ -0,0 +1,30 @@ | |||
1 | #include <linux/mm.h> | ||
2 | #include <linux/module.h> | ||
3 | #include <linux/sched.h> | ||
4 | #include <linux/init_task.h> | ||
5 | #include <linux/mqueue.h> | ||
6 | #include <linux/fs.h> | ||
7 | #include <asm/uaccess.h> | ||
8 | #include <asm/pgtable.h> | ||
9 | |||
10 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | ||
11 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | ||
12 | struct pt_regs fake_swapper_regs; | ||
13 | /* | ||
14 | * Initial thread structure. | ||
15 | * | ||
16 | * We need to make sure that this is 8192-byte aligned due to the | ||
17 | * way process stacks are handled. This is done by having a special | ||
18 | * "init_task" linker map entry.. | ||
19 | */ | ||
20 | union thread_union init_thread_union __init_task_data = | ||
21 | { INIT_THREAD_INFO(init_task) }; | ||
22 | |||
23 | /* | ||
24 | * Initial task structure. | ||
25 | * | ||
26 | * All other task structs will be allocated on slabs in fork.c | ||
27 | */ | ||
28 | struct task_struct init_task = INIT_TASK(init_task); | ||
29 | |||
30 | EXPORT_SYMBOL(init_task); | ||
diff --git a/arch/sh/kernel/sys_sh64.c b/arch/sh/kernel/sys_sh64.c new file mode 100644 index 00000000000..c5a38c4bf41 --- /dev/null +++ b/arch/sh/kernel/sys_sh64.c | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/sys_sh64.c | ||
3 | * | ||
4 | * Copyright (C) 2000, 2001 Paolo Alberelli | ||
5 | * | ||
6 | * This file contains various random system calls that | ||
7 | * have a non-standard calling sequence on the Linux/SH5 | ||
8 | * platform. | ||
9 | * | ||
10 | * This file is subject to the terms and conditions of the GNU General Public | ||
11 | * License. See the file "COPYING" in the main directory of this archive | ||
12 | * for more details. | ||
13 | */ | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/rwsem.h> | ||
16 | #include <linux/sched.h> | ||
17 | #include <linux/mm.h> | ||
18 | #include <linux/fs.h> | ||
19 | #include <linux/smp.h> | ||
20 | #include <linux/sem.h> | ||
21 | #include <linux/msg.h> | ||
22 | #include <linux/shm.h> | ||
23 | #include <linux/stat.h> | ||
24 | #include <linux/mman.h> | ||
25 | #include <linux/file.h> | ||
26 | #include <linux/syscalls.h> | ||
27 | #include <linux/ipc.h> | ||
28 | #include <asm/uaccess.h> | ||
29 | #include <asm/ptrace.h> | ||
30 | #include <asm/unistd.h> | ||
31 | |||
32 | /* | ||
33 | * Do a system call from kernel instead of calling sys_execve so we | ||
34 | * end up with proper pt_regs. | ||
35 | */ | ||
36 | int kernel_execve(const char *filename, | ||
37 | const char *const argv[], | ||
38 | const char *const envp[]) | ||
39 | { | ||
40 | register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve); | ||
41 | register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename; | ||
42 | register unsigned long __sc3 __asm__ ("r3") = (unsigned long) argv; | ||
43 | register unsigned long __sc4 __asm__ ("r4") = (unsigned long) envp; | ||
44 | __asm__ __volatile__ ("trapa %1 !\t\t\t execve(%2,%3,%4)" | ||
45 | : "=r" (__sc0) | ||
46 | : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) ); | ||
47 | __asm__ __volatile__ ("!dummy %0 %1 %2 %3" | ||
48 | : : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) : "memory"); | ||
49 | return __sc0; | ||
50 | } | ||
diff --git a/arch/sh/lib64/dbg.c b/arch/sh/lib64/dbg.c new file mode 100644 index 00000000000..6152a6a6d9c --- /dev/null +++ b/arch/sh/lib64/dbg.c | |||
@@ -0,0 +1,248 @@ | |||
1 | /*-------------------------------------------------------------------------- | ||
2 | -- | ||
3 | -- Identity : Linux50 Debug Funcions | ||
4 | -- | ||
5 | -- File : arch/sh/lib64/dbg.c | ||
6 | -- | ||
7 | -- Copyright 2000, 2001 STMicroelectronics Limited. | ||
8 | -- Copyright 2004 Richard Curnow (evt_debug etc) | ||
9 | -- | ||
10 | --------------------------------------------------------------------------*/ | ||
11 | #include <linux/types.h> | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/sched.h> | ||
14 | #include <linux/mm.h> | ||
15 | #include <linux/fs.h> | ||
16 | #include <asm/mmu_context.h> | ||
17 | |||
18 | typedef u64 regType_t; | ||
19 | |||
20 | static regType_t getConfigReg(u64 id) | ||
21 | { | ||
22 | register u64 reg __asm__("r2"); | ||
23 | asm volatile ("getcfg %1, 0, %0":"=r" (reg):"r"(id)); | ||
24 | return (reg); | ||
25 | } | ||
26 | |||
27 | /* ======================================================================= */ | ||
28 | |||
29 | static char *szTab[] = { "4k", "64k", "1M", "512M" }; | ||
30 | static char *protTab[] = { "----", | ||
31 | "---R", | ||
32 | "--X-", | ||
33 | "--XR", | ||
34 | "-W--", | ||
35 | "-W-R", | ||
36 | "-WX-", | ||
37 | "-WXR", | ||
38 | "U---", | ||
39 | "U--R", | ||
40 | "U-X-", | ||
41 | "U-XR", | ||
42 | "UW--", | ||
43 | "UW-R", | ||
44 | "UWX-", | ||
45 | "UWXR" | ||
46 | }; | ||
47 | #define ITLB_BASE 0x00000000 | ||
48 | #define DTLB_BASE 0x00800000 | ||
49 | #define MAX_TLBs 64 | ||
50 | /* PTE High */ | ||
51 | #define GET_VALID(pte) ((pte) & 0x1) | ||
52 | #define GET_SHARED(pte) ((pte) & 0x2) | ||
53 | #define GET_ASID(pte) ((pte >> 2) & 0x0ff) | ||
54 | #define GET_EPN(pte) ((pte) & 0xfffff000) | ||
55 | |||
56 | /* PTE Low */ | ||
57 | #define GET_CBEHAVIOR(pte) ((pte) & 0x3) | ||
58 | #define GET_PAGE_SIZE(pte) szTab[((pte >> 3) & 0x3)] | ||
59 | #define GET_PROTECTION(pte) protTab[((pte >> 6) & 0xf)] | ||
60 | #define GET_PPN(pte) ((pte) & 0xfffff000) | ||
61 | |||
62 | #define PAGE_1K_MASK 0x00000000 | ||
63 | #define PAGE_4K_MASK 0x00000010 | ||
64 | #define PAGE_64K_MASK 0x00000080 | ||
65 | #define MMU_PAGESIZE_MASK (PAGE_64K_MASK | PAGE_4K_MASK) | ||
66 | #define PAGE_1MB_MASK MMU_PAGESIZE_MASK | ||
67 | #define PAGE_1K (1024) | ||
68 | #define PAGE_4K (1024 * 4) | ||
69 | #define PAGE_64K (1024 * 64) | ||
70 | #define PAGE_1MB (1024 * 1024) | ||
71 | |||
72 | #define HOW_TO_READ_TLB_CONTENT \ | ||
73 | "[ ID] PPN EPN ASID Share CB P.Size PROT.\n" | ||
74 | |||
75 | void print_single_tlb(unsigned long tlb, int single_print) | ||
76 | { | ||
77 | regType_t pteH; | ||
78 | regType_t pteL; | ||
79 | unsigned int valid, shared, asid, epn, cb, ppn; | ||
80 | char *pSize; | ||
81 | char *pProt; | ||
82 | |||
83 | /* | ||
84 | ** in case of single print <single_print> is true, this implies: | ||
85 | ** 1) print the TLB in any case also if NOT VALID | ||
86 | ** 2) print out the header | ||
87 | */ | ||
88 | |||
89 | pteH = getConfigReg(tlb); | ||
90 | valid = GET_VALID(pteH); | ||
91 | if (single_print) | ||
92 | printk(HOW_TO_READ_TLB_CONTENT); | ||
93 | else if (!valid) | ||
94 | return; | ||
95 | |||
96 | pteL = getConfigReg(tlb + 1); | ||
97 | |||
98 | shared = GET_SHARED(pteH); | ||
99 | asid = GET_ASID(pteH); | ||
100 | epn = GET_EPN(pteH); | ||
101 | cb = GET_CBEHAVIOR(pteL); | ||
102 | pSize = GET_PAGE_SIZE(pteL); | ||
103 | pProt = GET_PROTECTION(pteL); | ||
104 | ppn = GET_PPN(pteL); | ||
105 | printk("[%c%2ld] 0x%08x 0x%08x %03d %02x %02x %4s %s\n", | ||
106 | ((valid) ? ' ' : 'u'), ((tlb & 0x0ffff) / TLB_STEP), | ||
107 | ppn, epn, asid, shared, cb, pSize, pProt); | ||
108 | } | ||
109 | |||
110 | void print_dtlb(void) | ||
111 | { | ||
112 | int count; | ||
113 | unsigned long tlb; | ||
114 | |||
115 | printk(" ================= SH-5 D-TLBs Status ===================\n"); | ||
116 | printk(HOW_TO_READ_TLB_CONTENT); | ||
117 | tlb = DTLB_BASE; | ||
118 | for (count = 0; count < MAX_TLBs; count++, tlb += TLB_STEP) | ||
119 | print_single_tlb(tlb, 0); | ||
120 | printk | ||
121 | (" =============================================================\n"); | ||
122 | } | ||
123 | |||
124 | void print_itlb(void) | ||
125 | { | ||
126 | int count; | ||
127 | unsigned long tlb; | ||
128 | |||
129 | printk(" ================= SH-5 I-TLBs Status ===================\n"); | ||
130 | printk(HOW_TO_READ_TLB_CONTENT); | ||
131 | tlb = ITLB_BASE; | ||
132 | for (count = 0; count < MAX_TLBs; count++, tlb += TLB_STEP) | ||
133 | print_single_tlb(tlb, 0); | ||
134 | printk | ||
135 | (" =============================================================\n"); | ||
136 | } | ||
137 | |||
138 | void show_excp_regs(char *from, int trapnr, int signr, struct pt_regs *regs) | ||
139 | { | ||
140 | |||
141 | unsigned long long ah, al, bh, bl, ch, cl; | ||
142 | |||
143 | printk("\n"); | ||
144 | printk("EXCEPTION - %s: task %d; Linux trap # %d; signal = %d\n", | ||
145 | ((from) ? from : "???"), current->pid, trapnr, signr); | ||
146 | |||
147 | asm volatile ("getcon " __EXPEVT ", %0":"=r"(ah)); | ||
148 | asm volatile ("getcon " __EXPEVT ", %0":"=r"(al)); | ||
149 | ah = (ah) >> 32; | ||
150 | al = (al) & 0xffffffff; | ||
151 | asm volatile ("getcon " __KCR1 ", %0":"=r"(bh)); | ||
152 | asm volatile ("getcon " __KCR1 ", %0":"=r"(bl)); | ||
153 | bh = (bh) >> 32; | ||
154 | bl = (bl) & 0xffffffff; | ||
155 | asm volatile ("getcon " __INTEVT ", %0":"=r"(ch)); | ||
156 | asm volatile ("getcon " __INTEVT ", %0":"=r"(cl)); | ||
157 | ch = (ch) >> 32; | ||
158 | cl = (cl) & 0xffffffff; | ||
159 | printk("EXPE: %08Lx%08Lx KCR1: %08Lx%08Lx INTE: %08Lx%08Lx\n", | ||
160 | ah, al, bh, bl, ch, cl); | ||
161 | |||
162 | asm volatile ("getcon " __PEXPEVT ", %0":"=r"(ah)); | ||
163 | asm volatile ("getcon " __PEXPEVT ", %0":"=r"(al)); | ||
164 | ah = (ah) >> 32; | ||
165 | al = (al) & 0xffffffff; | ||
166 | asm volatile ("getcon " __PSPC ", %0":"=r"(bh)); | ||
167 | asm volatile ("getcon " __PSPC ", %0":"=r"(bl)); | ||
168 | bh = (bh) >> 32; | ||
169 | bl = (bl) & 0xffffffff; | ||
170 | asm volatile ("getcon " __PSSR ", %0":"=r"(ch)); | ||
171 | asm volatile ("getcon " __PSSR ", %0":"=r"(cl)); | ||
172 | ch = (ch) >> 32; | ||
173 | cl = (cl) & 0xffffffff; | ||
174 | printk("PEXP: %08Lx%08Lx PSPC: %08Lx%08Lx PSSR: %08Lx%08Lx\n", | ||
175 | ah, al, bh, bl, ch, cl); | ||
176 | |||
177 | ah = (regs->pc) >> 32; | ||
178 | al = (regs->pc) & 0xffffffff; | ||
179 | bh = (regs->regs[18]) >> 32; | ||
180 | bl = (regs->regs[18]) & 0xffffffff; | ||
181 | ch = (regs->regs[15]) >> 32; | ||
182 | cl = (regs->regs[15]) & 0xffffffff; | ||
183 | printk("PC : %08Lx%08Lx LINK: %08Lx%08Lx SP : %08Lx%08Lx\n", | ||
184 | ah, al, bh, bl, ch, cl); | ||
185 | |||
186 | ah = (regs->sr) >> 32; | ||
187 | al = (regs->sr) & 0xffffffff; | ||
188 | asm volatile ("getcon " __TEA ", %0":"=r"(bh)); | ||
189 | asm volatile ("getcon " __TEA ", %0":"=r"(bl)); | ||
190 | bh = (bh) >> 32; | ||
191 | bl = (bl) & 0xffffffff; | ||
192 | asm volatile ("getcon " __KCR0 ", %0":"=r"(ch)); | ||
193 | asm volatile ("getcon " __KCR0 ", %0":"=r"(cl)); | ||
194 | ch = (ch) >> 32; | ||
195 | cl = (cl) & 0xffffffff; | ||
196 | printk("SR : %08Lx%08Lx TEA : %08Lx%08Lx KCR0: %08Lx%08Lx\n", | ||
197 | ah, al, bh, bl, ch, cl); | ||
198 | |||
199 | ah = (regs->regs[0]) >> 32; | ||
200 | al = (regs->regs[0]) & 0xffffffff; | ||
201 | bh = (regs->regs[1]) >> 32; | ||
202 | bl = (regs->regs[1]) & 0xffffffff; | ||
203 | ch = (regs->regs[2]) >> 32; | ||
204 | cl = (regs->regs[2]) & 0xffffffff; | ||
205 | printk("R0 : %08Lx%08Lx R1 : %08Lx%08Lx R2 : %08Lx%08Lx\n", | ||
206 | ah, al, bh, bl, ch, cl); | ||
207 | |||
208 | ah = (regs->regs[3]) >> 32; | ||
209 | al = (regs->regs[3]) & 0xffffffff; | ||
210 | bh = (regs->regs[4]) >> 32; | ||
211 | bl = (regs->regs[4]) & 0xffffffff; | ||
212 | ch = (regs->regs[5]) >> 32; | ||
213 | cl = (regs->regs[5]) & 0xffffffff; | ||
214 | printk("R3 : %08Lx%08Lx R4 : %08Lx%08Lx R5 : %08Lx%08Lx\n", | ||
215 | ah, al, bh, bl, ch, cl); | ||
216 | |||
217 | ah = (regs->regs[6]) >> 32; | ||
218 | al = (regs->regs[6]) & 0xffffffff; | ||
219 | bh = (regs->regs[7]) >> 32; | ||
220 | bl = (regs->regs[7]) & 0xffffffff; | ||
221 | ch = (regs->regs[8]) >> 32; | ||
222 | cl = (regs->regs[8]) & 0xffffffff; | ||
223 | printk("R6 : %08Lx%08Lx R7 : %08Lx%08Lx R8 : %08Lx%08Lx\n", | ||
224 | ah, al, bh, bl, ch, cl); | ||
225 | |||
226 | ah = (regs->regs[9]) >> 32; | ||
227 | al = (regs->regs[9]) & 0xffffffff; | ||
228 | bh = (regs->regs[10]) >> 32; | ||
229 | bl = (regs->regs[10]) & 0xffffffff; | ||
230 | ch = (regs->regs[11]) >> 32; | ||
231 | cl = (regs->regs[11]) & 0xffffffff; | ||
232 | printk("R9 : %08Lx%08Lx R10 : %08Lx%08Lx R11 : %08Lx%08Lx\n", | ||
233 | ah, al, bh, bl, ch, cl); | ||
234 | printk("....\n"); | ||
235 | |||
236 | ah = (regs->tregs[0]) >> 32; | ||
237 | al = (regs->tregs[0]) & 0xffffffff; | ||
238 | bh = (regs->tregs[1]) >> 32; | ||
239 | bl = (regs->tregs[1]) & 0xffffffff; | ||
240 | ch = (regs->tregs[2]) >> 32; | ||
241 | cl = (regs->tregs[2]) & 0xffffffff; | ||
242 | printk("T0 : %08Lx%08Lx T1 : %08Lx%08Lx T2 : %08Lx%08Lx\n", | ||
243 | ah, al, bh, bl, ch, cl); | ||
244 | printk("....\n"); | ||
245 | |||
246 | print_dtlb(); | ||
247 | print_itlb(); | ||
248 | } | ||
diff --git a/arch/sh/mm/fault_32.c b/arch/sh/mm/fault_32.c new file mode 100644 index 00000000000..7bebd044f2a --- /dev/null +++ b/arch/sh/mm/fault_32.c | |||
@@ -0,0 +1,374 @@ | |||
1 | /* | ||
2 | * Page fault handler for SH with an MMU. | ||
3 | * | ||
4 | * Copyright (C) 1999 Niibe Yutaka | ||
5 | * Copyright (C) 2003 - 2009 Paul Mundt | ||
6 | * | ||
7 | * Based on linux/arch/i386/mm/fault.c: | ||
8 | * Copyright (C) 1995 Linus Torvalds | ||
9 | * | ||
10 | * This file is subject to the terms and conditions of the GNU General Public | ||
11 | * License. See the file "COPYING" in the main directory of this archive | ||
12 | * for more details. | ||
13 | */ | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/mm.h> | ||
16 | #include <linux/hardirq.h> | ||
17 | #include <linux/kprobes.h> | ||
18 | #include <linux/perf_event.h> | ||
19 | #include <asm/io_trapped.h> | ||
20 | #include <asm/system.h> | ||
21 | #include <asm/mmu_context.h> | ||
22 | #include <asm/tlbflush.h> | ||
23 | |||
24 | static inline int notify_page_fault(struct pt_regs *regs, int trap) | ||
25 | { | ||
26 | int ret = 0; | ||
27 | |||
28 | if (kprobes_built_in() && !user_mode(regs)) { | ||
29 | preempt_disable(); | ||
30 | if (kprobe_running() && kprobe_fault_handler(regs, trap)) | ||
31 | ret = 1; | ||
32 | preempt_enable(); | ||
33 | } | ||
34 | |||
35 | return ret; | ||
36 | } | ||
37 | |||
38 | static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) | ||
39 | { | ||
40 | unsigned index = pgd_index(address); | ||
41 | pgd_t *pgd_k; | ||
42 | pud_t *pud, *pud_k; | ||
43 | pmd_t *pmd, *pmd_k; | ||
44 | |||
45 | pgd += index; | ||
46 | pgd_k = init_mm.pgd + index; | ||
47 | |||
48 | if (!pgd_present(*pgd_k)) | ||
49 | return NULL; | ||
50 | |||
51 | pud = pud_offset(pgd, address); | ||
52 | pud_k = pud_offset(pgd_k, address); | ||
53 | if (!pud_present(*pud_k)) | ||
54 | return NULL; | ||
55 | |||
56 | if (!pud_present(*pud)) | ||
57 | set_pud(pud, *pud_k); | ||
58 | |||
59 | pmd = pmd_offset(pud, address); | ||
60 | pmd_k = pmd_offset(pud_k, address); | ||
61 | if (!pmd_present(*pmd_k)) | ||
62 | return NULL; | ||
63 | |||
64 | if (!pmd_present(*pmd)) | ||
65 | set_pmd(pmd, *pmd_k); | ||
66 | else { | ||
67 | /* | ||
68 | * The page tables are fully synchronised so there must | ||
69 | * be another reason for the fault. Return NULL here to | ||
70 | * signal that we have not taken care of the fault. | ||
71 | */ | ||
72 | BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k)); | ||
73 | return NULL; | ||
74 | } | ||
75 | |||
76 | return pmd_k; | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * Handle a fault on the vmalloc or module mapping area | ||
81 | */ | ||
82 | static noinline int vmalloc_fault(unsigned long address) | ||
83 | { | ||
84 | pgd_t *pgd_k; | ||
85 | pmd_t *pmd_k; | ||
86 | pte_t *pte_k; | ||
87 | |||
88 | /* Make sure we are in vmalloc/module/P3 area: */ | ||
89 | if (!(address >= VMALLOC_START && address < P3_ADDR_MAX)) | ||
90 | return -1; | ||
91 | |||
92 | /* | ||
93 | * Synchronize this task's top level page-table | ||
94 | * with the 'reference' page table. | ||
95 | * | ||
96 | * Do _not_ use "current" here. We might be inside | ||
97 | * an interrupt in the middle of a task switch.. | ||
98 | */ | ||
99 | pgd_k = get_TTB(); | ||
100 | pmd_k = vmalloc_sync_one(pgd_k, address); | ||
101 | if (!pmd_k) | ||
102 | return -1; | ||
103 | |||
104 | pte_k = pte_offset_kernel(pmd_k, address); | ||
105 | if (!pte_present(*pte_k)) | ||
106 | return -1; | ||
107 | |||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static int fault_in_kernel_space(unsigned long address) | ||
112 | { | ||
113 | return address >= TASK_SIZE; | ||
114 | } | ||
115 | |||
116 | /* | ||
117 | * This routine handles page faults. It determines the address, | ||
118 | * and the problem, and then passes it off to one of the appropriate | ||
119 | * routines. | ||
120 | */ | ||
121 | asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, | ||
122 | unsigned long writeaccess, | ||
123 | unsigned long address) | ||
124 | { | ||
125 | unsigned long vec; | ||
126 | struct task_struct *tsk; | ||
127 | struct mm_struct *mm; | ||
128 | struct vm_area_struct * vma; | ||
129 | int si_code; | ||
130 | int fault; | ||
131 | siginfo_t info; | ||
132 | |||
133 | tsk = current; | ||
134 | mm = tsk->mm; | ||
135 | si_code = SEGV_MAPERR; | ||
136 | vec = lookup_exception_vector(); | ||
137 | |||
138 | /* | ||
139 | * We fault-in kernel-space virtual memory on-demand. The | ||
140 | * 'reference' page table is init_mm.pgd. | ||
141 | * | ||
142 | * NOTE! We MUST NOT take any locks for this case. We may | ||
143 | * be in an interrupt or a critical region, and should | ||
144 | * only copy the information from the master page table, | ||
145 | * nothing more. | ||
146 | */ | ||
147 | if (unlikely(fault_in_kernel_space(address))) { | ||
148 | if (vmalloc_fault(address) >= 0) | ||
149 | return; | ||
150 | if (notify_page_fault(regs, vec)) | ||
151 | return; | ||
152 | |||
153 | goto bad_area_nosemaphore; | ||
154 | } | ||
155 | |||
156 | if (unlikely(notify_page_fault(regs, vec))) | ||
157 | return; | ||
158 | |||
159 | /* Only enable interrupts if they were on before the fault */ | ||
160 | if ((regs->sr & SR_IMASK) != SR_IMASK) | ||
161 | local_irq_enable(); | ||
162 | |||
163 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); | ||
164 | |||
165 | /* | ||
166 | * If we're in an interrupt, have no user context or are running | ||
167 | * in an atomic region then we must not take the fault: | ||
168 | */ | ||
169 | if (in_atomic() || !mm) | ||
170 | goto no_context; | ||
171 | |||
172 | down_read(&mm->mmap_sem); | ||
173 | |||
174 | vma = find_vma(mm, address); | ||
175 | if (!vma) | ||
176 | goto bad_area; | ||
177 | if (vma->vm_start <= address) | ||
178 | goto good_area; | ||
179 | if (!(vma->vm_flags & VM_GROWSDOWN)) | ||
180 | goto bad_area; | ||
181 | if (expand_stack(vma, address)) | ||
182 | goto bad_area; | ||
183 | |||
184 | /* | ||
185 | * Ok, we have a good vm_area for this memory access, so | ||
186 | * we can handle it.. | ||
187 | */ | ||
188 | good_area: | ||
189 | si_code = SEGV_ACCERR; | ||
190 | if (writeaccess) { | ||
191 | if (!(vma->vm_flags & VM_WRITE)) | ||
192 | goto bad_area; | ||
193 | } else { | ||
194 | if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))) | ||
195 | goto bad_area; | ||
196 | } | ||
197 | |||
198 | /* | ||
199 | * If for any reason at all we couldn't handle the fault, | ||
200 | * make sure we exit gracefully rather than endlessly redo | ||
201 | * the fault. | ||
202 | */ | ||
203 | fault = handle_mm_fault(mm, vma, address, writeaccess ? FAULT_FLAG_WRITE : 0); | ||
204 | if (unlikely(fault & VM_FAULT_ERROR)) { | ||
205 | if (fault & VM_FAULT_OOM) | ||
206 | goto out_of_memory; | ||
207 | else if (fault & VM_FAULT_SIGBUS) | ||
208 | goto do_sigbus; | ||
209 | BUG(); | ||
210 | } | ||
211 | if (fault & VM_FAULT_MAJOR) { | ||
212 | tsk->maj_flt++; | ||
213 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, | ||
214 | regs, address); | ||
215 | } else { | ||
216 | tsk->min_flt++; | ||
217 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, | ||
218 | regs, address); | ||
219 | } | ||
220 | |||
221 | up_read(&mm->mmap_sem); | ||
222 | return; | ||
223 | |||
224 | /* | ||
225 | * Something tried to access memory that isn't in our memory map.. | ||
226 | * Fix it, but check if it's kernel or user first.. | ||
227 | */ | ||
228 | bad_area: | ||
229 | up_read(&mm->mmap_sem); | ||
230 | |||
231 | bad_area_nosemaphore: | ||
232 | if (user_mode(regs)) { | ||
233 | info.si_signo = SIGSEGV; | ||
234 | info.si_errno = 0; | ||
235 | info.si_code = si_code; | ||
236 | info.si_addr = (void *) address; | ||
237 | force_sig_info(SIGSEGV, &info, tsk); | ||
238 | return; | ||
239 | } | ||
240 | |||
241 | no_context: | ||
242 | /* Are we prepared to handle this kernel fault? */ | ||
243 | if (fixup_exception(regs)) | ||
244 | return; | ||
245 | |||
246 | if (handle_trapped_io(regs, address)) | ||
247 | return; | ||
248 | /* | ||
249 | * Oops. The kernel tried to access some bad page. We'll have to | ||
250 | * terminate things with extreme prejudice. | ||
251 | * | ||
252 | */ | ||
253 | |||
254 | bust_spinlocks(1); | ||
255 | |||
256 | if (oops_may_print()) { | ||
257 | unsigned long page; | ||
258 | |||
259 | if (address < PAGE_SIZE) | ||
260 | printk(KERN_ALERT "Unable to handle kernel NULL " | ||
261 | "pointer dereference"); | ||
262 | else | ||
263 | printk(KERN_ALERT "Unable to handle kernel paging " | ||
264 | "request"); | ||
265 | printk(" at virtual address %08lx\n", address); | ||
266 | printk(KERN_ALERT "pc = %08lx\n", regs->pc); | ||
267 | page = (unsigned long)get_TTB(); | ||
268 | if (page) { | ||
269 | page = ((__typeof__(page) *)page)[address >> PGDIR_SHIFT]; | ||
270 | printk(KERN_ALERT "*pde = %08lx\n", page); | ||
271 | if (page & _PAGE_PRESENT) { | ||
272 | page &= PAGE_MASK; | ||
273 | address &= 0x003ff000; | ||
274 | page = ((__typeof__(page) *) | ||
275 | __va(page))[address >> | ||
276 | PAGE_SHIFT]; | ||
277 | printk(KERN_ALERT "*pte = %08lx\n", page); | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | |||
282 | die("Oops", regs, writeaccess); | ||
283 | bust_spinlocks(0); | ||
284 | do_exit(SIGKILL); | ||
285 | |||
286 | /* | ||
287 | * We ran out of memory, or some other thing happened to us that made | ||
288 | * us unable to handle the page fault gracefully. | ||
289 | */ | ||
290 | out_of_memory: | ||
291 | up_read(&mm->mmap_sem); | ||
292 | if (!user_mode(regs)) | ||
293 | goto no_context; | ||
294 | pagefault_out_of_memory(); | ||
295 | return; | ||
296 | |||
297 | do_sigbus: | ||
298 | up_read(&mm->mmap_sem); | ||
299 | |||
300 | /* | ||
301 | * Send a sigbus, regardless of whether we were in kernel | ||
302 | * or user mode. | ||
303 | */ | ||
304 | info.si_signo = SIGBUS; | ||
305 | info.si_errno = 0; | ||
306 | info.si_code = BUS_ADRERR; | ||
307 | info.si_addr = (void *)address; | ||
308 | force_sig_info(SIGBUS, &info, tsk); | ||
309 | |||
310 | /* Kernel mode? Handle exceptions or die */ | ||
311 | if (!user_mode(regs)) | ||
312 | goto no_context; | ||
313 | } | ||
314 | |||
315 | /* | ||
316 | * Called with interrupts disabled. | ||
317 | */ | ||
318 | asmlinkage int __kprobes | ||
319 | handle_tlbmiss(struct pt_regs *regs, unsigned long writeaccess, | ||
320 | unsigned long address) | ||
321 | { | ||
322 | pgd_t *pgd; | ||
323 | pud_t *pud; | ||
324 | pmd_t *pmd; | ||
325 | pte_t *pte; | ||
326 | pte_t entry; | ||
327 | |||
328 | /* | ||
329 | * We don't take page faults for P1, P2, and parts of P4, these | ||
330 | * are always mapped, whether it be due to legacy behaviour in | ||
331 | * 29-bit mode, or due to PMB configuration in 32-bit mode. | ||
332 | */ | ||
333 | if (address >= P3SEG && address < P3_ADDR_MAX) { | ||
334 | pgd = pgd_offset_k(address); | ||
335 | } else { | ||
336 | if (unlikely(address >= TASK_SIZE || !current->mm)) | ||
337 | return 1; | ||
338 | |||
339 | pgd = pgd_offset(current->mm, address); | ||
340 | } | ||
341 | |||
342 | pud = pud_offset(pgd, address); | ||
343 | if (pud_none_or_clear_bad(pud)) | ||
344 | return 1; | ||
345 | pmd = pmd_offset(pud, address); | ||
346 | if (pmd_none_or_clear_bad(pmd)) | ||
347 | return 1; | ||
348 | pte = pte_offset_kernel(pmd, address); | ||
349 | entry = *pte; | ||
350 | if (unlikely(pte_none(entry) || pte_not_present(entry))) | ||
351 | return 1; | ||
352 | if (unlikely(writeaccess && !pte_write(entry))) | ||
353 | return 1; | ||
354 | |||
355 | if (writeaccess) | ||
356 | entry = pte_mkdirty(entry); | ||
357 | entry = pte_mkyoung(entry); | ||
358 | |||
359 | set_pte(pte, entry); | ||
360 | |||
361 | #if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SMP) | ||
362 | /* | ||
363 | * SH-4 does not set MMUCR.RC to the corresponding TLB entry in | ||
364 | * the case of an initial page write exception, so we need to | ||
365 | * flush it in order to avoid potential TLB entry duplication. | ||
366 | */ | ||
367 | if (writeaccess == 2) | ||
368 | local_flush_tlb_one(get_asid(), address & PAGE_MASK); | ||
369 | #endif | ||
370 | |||
371 | update_mmu_cache(NULL, address, pte); | ||
372 | |||
373 | return 0; | ||
374 | } | ||
diff --git a/arch/sh/mm/fault_64.c b/arch/sh/mm/fault_64.c new file mode 100644 index 00000000000..2b356cec248 --- /dev/null +++ b/arch/sh/mm/fault_64.c | |||
@@ -0,0 +1,266 @@ | |||
1 | /* | ||
2 | * The SH64 TLB miss. | ||
3 | * | ||
4 | * Original code from fault.c | ||
5 | * Copyright (C) 2000, 2001 Paolo Alberelli | ||
6 | * | ||
7 | * Fast PTE->TLB refill path | ||
8 | * Copyright (C) 2003 Richard.Curnow@superh.com | ||
9 | * | ||
10 | * IMPORTANT NOTES : | ||
11 | * The do_fast_page_fault function is called from a context in entry.S | ||
12 | * where very few registers have been saved. In particular, the code in | ||
13 | * this file must be compiled not to use ANY caller-save registers that | ||
14 | * are not part of the restricted save set. Also, it means that code in | ||
15 | * this file must not make calls to functions elsewhere in the kernel, or | ||
16 | * else the excepting context will see corruption in its caller-save | ||
17 | * registers. Plus, the entry.S save area is non-reentrant, so this code | ||
18 | * has to run with SR.BL==1, i.e. no interrupts taken inside it and panic | ||
19 | * on any exception. | ||
20 | * | ||
21 | * This file is subject to the terms and conditions of the GNU General Public | ||
22 | * License. See the file "COPYING" in the main directory of this archive | ||
23 | * for more details. | ||
24 | */ | ||
25 | #include <linux/signal.h> | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/errno.h> | ||
29 | #include <linux/string.h> | ||
30 | #include <linux/types.h> | ||
31 | #include <linux/ptrace.h> | ||
32 | #include <linux/mman.h> | ||
33 | #include <linux/mm.h> | ||
34 | #include <linux/smp.h> | ||
35 | #include <linux/interrupt.h> | ||
36 | #include <asm/system.h> | ||
37 | #include <asm/tlb.h> | ||
38 | #include <asm/io.h> | ||
39 | #include <asm/uaccess.h> | ||
40 | #include <asm/pgalloc.h> | ||
41 | #include <asm/mmu_context.h> | ||
42 | #include <cpu/registers.h> | ||
43 | |||
44 | /* Callable from fault.c, so not static */ | ||
45 | inline void __do_tlb_refill(unsigned long address, | ||
46 | unsigned long long is_text_not_data, pte_t *pte) | ||
47 | { | ||
48 | unsigned long long ptel; | ||
49 | unsigned long long pteh=0; | ||
50 | struct tlb_info *tlbp; | ||
51 | unsigned long long next; | ||
52 | |||
53 | /* Get PTEL first */ | ||
54 | ptel = pte_val(*pte); | ||
55 | |||
56 | /* | ||
57 | * Set PTEH register | ||
58 | */ | ||
59 | pteh = neff_sign_extend(address & MMU_VPN_MASK); | ||
60 | |||
61 | /* Set the ASID. */ | ||
62 | pteh |= get_asid() << PTEH_ASID_SHIFT; | ||
63 | pteh |= PTEH_VALID; | ||
64 | |||
65 | /* Set PTEL register, set_pte has performed the sign extension */ | ||
66 | ptel &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */ | ||
67 | |||
68 | tlbp = is_text_not_data ? &(cpu_data->itlb) : &(cpu_data->dtlb); | ||
69 | next = tlbp->next; | ||
70 | __flush_tlb_slot(next); | ||
71 | asm volatile ("putcfg %0,1,%2\n\n\t" | ||
72 | "putcfg %0,0,%1\n" | ||
73 | : : "r" (next), "r" (pteh), "r" (ptel) ); | ||
74 | |||
75 | next += TLB_STEP; | ||
76 | if (next > tlbp->last) next = tlbp->first; | ||
77 | tlbp->next = next; | ||
78 | |||
79 | } | ||
80 | |||
81 | static int handle_vmalloc_fault(struct mm_struct *mm, | ||
82 | unsigned long protection_flags, | ||
83 | unsigned long long textaccess, | ||
84 | unsigned long address) | ||
85 | { | ||
86 | pgd_t *dir; | ||
87 | pud_t *pud; | ||
88 | pmd_t *pmd; | ||
89 | static pte_t *pte; | ||
90 | pte_t entry; | ||
91 | |||
92 | dir = pgd_offset_k(address); | ||
93 | |||
94 | pud = pud_offset(dir, address); | ||
95 | if (pud_none_or_clear_bad(pud)) | ||
96 | return 0; | ||
97 | |||
98 | pmd = pmd_offset(pud, address); | ||
99 | if (pmd_none_or_clear_bad(pmd)) | ||
100 | return 0; | ||
101 | |||
102 | pte = pte_offset_kernel(pmd, address); | ||
103 | entry = *pte; | ||
104 | |||
105 | if (pte_none(entry) || !pte_present(entry)) | ||
106 | return 0; | ||
107 | if ((pte_val(entry) & protection_flags) != protection_flags) | ||
108 | return 0; | ||
109 | |||
110 | __do_tlb_refill(address, textaccess, pte); | ||
111 | |||
112 | return 1; | ||
113 | } | ||
114 | |||
115 | static int handle_tlbmiss(struct mm_struct *mm, | ||
116 | unsigned long long protection_flags, | ||
117 | unsigned long long textaccess, | ||
118 | unsigned long address) | ||
119 | { | ||
120 | pgd_t *dir; | ||
121 | pud_t *pud; | ||
122 | pmd_t *pmd; | ||
123 | pte_t *pte; | ||
124 | pte_t entry; | ||
125 | |||
126 | /* NB. The PGD currently only contains a single entry - there is no | ||
127 | page table tree stored for the top half of the address space since | ||
128 | virtual pages in that region should never be mapped in user mode. | ||
129 | (In kernel mode, the only things in that region are the 512Mb super | ||
130 | page (locked in), and vmalloc (modules) + I/O device pages (handled | ||
131 | by handle_vmalloc_fault), so no PGD for the upper half is required | ||
132 | by kernel mode either). | ||
133 | |||
134 | See how mm->pgd is allocated and initialised in pgd_alloc to see why | ||
135 | the next test is necessary. - RPC */ | ||
136 | if (address >= (unsigned long) TASK_SIZE) | ||
137 | /* upper half - never has page table entries. */ | ||
138 | return 0; | ||
139 | |||
140 | dir = pgd_offset(mm, address); | ||
141 | if (pgd_none(*dir) || !pgd_present(*dir)) | ||
142 | return 0; | ||
143 | if (!pgd_present(*dir)) | ||
144 | return 0; | ||
145 | |||
146 | pud = pud_offset(dir, address); | ||
147 | if (pud_none(*pud) || !pud_present(*pud)) | ||
148 | return 0; | ||
149 | |||
150 | pmd = pmd_offset(pud, address); | ||
151 | if (pmd_none(*pmd) || !pmd_present(*pmd)) | ||
152 | return 0; | ||
153 | |||
154 | pte = pte_offset_kernel(pmd, address); | ||
155 | entry = *pte; | ||
156 | |||
157 | if (pte_none(entry) || !pte_present(entry)) | ||
158 | return 0; | ||
159 | |||
160 | /* | ||
161 | * If the page doesn't have sufficient protection bits set to | ||
162 | * service the kind of fault being handled, there's not much | ||
163 | * point doing the TLB refill. Punt the fault to the general | ||
164 | * handler. | ||
165 | */ | ||
166 | if ((pte_val(entry) & protection_flags) != protection_flags) | ||
167 | return 0; | ||
168 | |||
169 | __do_tlb_refill(address, textaccess, pte); | ||
170 | |||
171 | return 1; | ||
172 | } | ||
173 | |||
174 | /* | ||
175 | * Put all this information into one structure so that everything is just | ||
176 | * arithmetic relative to a single base address. This reduces the number | ||
177 | * of movi/shori pairs needed just to load addresses of static data. | ||
178 | */ | ||
179 | struct expevt_lookup { | ||
180 | unsigned short protection_flags[8]; | ||
181 | unsigned char is_text_access[8]; | ||
182 | unsigned char is_write_access[8]; | ||
183 | }; | ||
184 | |||
185 | #define PRU (1<<9) | ||
186 | #define PRW (1<<8) | ||
187 | #define PRX (1<<7) | ||
188 | #define PRR (1<<6) | ||
189 | |||
190 | #define DIRTY (_PAGE_DIRTY | _PAGE_ACCESSED) | ||
191 | #define YOUNG (_PAGE_ACCESSED) | ||
192 | |||
193 | /* Sized as 8 rather than 4 to allow checking the PTE's PRU bit against whether | ||
194 | the fault happened in user mode or privileged mode. */ | ||
195 | static struct expevt_lookup expevt_lookup_table = { | ||
196 | .protection_flags = {PRX, PRX, 0, 0, PRR, PRR, PRW, PRW}, | ||
197 | .is_text_access = {1, 1, 0, 0, 0, 0, 0, 0} | ||
198 | }; | ||
199 | |||
200 | /* | ||
201 | This routine handles page faults that can be serviced just by refilling a | ||
202 | TLB entry from an existing page table entry. (This case represents a very | ||
203 | large majority of page faults.) Return 1 if the fault was successfully | ||
204 | handled. Return 0 if the fault could not be handled. (This leads into the | ||
205 | general fault handling in fault.c which deals with mapping file-backed | ||
206 | pages, stack growth, segmentation faults, swapping etc etc) | ||
207 | */ | ||
208 | asmlinkage int do_fast_page_fault(unsigned long long ssr_md, | ||
209 | unsigned long long expevt, | ||
210 | unsigned long address) | ||
211 | { | ||
212 | struct task_struct *tsk; | ||
213 | struct mm_struct *mm; | ||
214 | unsigned long long textaccess; | ||
215 | unsigned long long protection_flags; | ||
216 | unsigned long long index; | ||
217 | unsigned long long expevt4; | ||
218 | |||
219 | /* The next few lines implement a way of hashing EXPEVT into a | ||
220 | * small array index which can be used to lookup parameters | ||
221 | * specific to the type of TLBMISS being handled. | ||
222 | * | ||
223 | * Note: | ||
224 | * ITLBMISS has EXPEVT==0xa40 | ||
225 | * RTLBMISS has EXPEVT==0x040 | ||
226 | * WTLBMISS has EXPEVT==0x060 | ||
227 | */ | ||
228 | expevt4 = (expevt >> 4); | ||
229 | /* TODO : xor ssr_md into this expression too. Then we can check | ||
230 | * that PRU is set when it needs to be. */ | ||
231 | index = expevt4 ^ (expevt4 >> 5); | ||
232 | index &= 7; | ||
233 | protection_flags = expevt_lookup_table.protection_flags[index]; | ||
234 | textaccess = expevt_lookup_table.is_text_access[index]; | ||
235 | |||
236 | /* SIM | ||
237 | * Note this is now called with interrupts still disabled | ||
238 | * This is to cope with being called for a missing IO port | ||
239 | * address with interrupts disabled. This should be fixed as | ||
240 | * soon as we have a better 'fast path' miss handler. | ||
241 | * | ||
242 | * Plus take care how you try and debug this stuff. | ||
243 | * For example, writing debug data to a port which you | ||
244 | * have just faulted on is not going to work. | ||
245 | */ | ||
246 | |||
247 | tsk = current; | ||
248 | mm = tsk->mm; | ||
249 | |||
250 | if ((address >= VMALLOC_START && address < VMALLOC_END) || | ||
251 | (address >= IOBASE_VADDR && address < IOBASE_END)) { | ||
252 | if (ssr_md) | ||
253 | /* | ||
254 | * Process-contexts can never have this address | ||
255 | * range mapped | ||
256 | */ | ||
257 | if (handle_vmalloc_fault(mm, protection_flags, | ||
258 | textaccess, address)) | ||
259 | return 1; | ||
260 | } else if (!in_interrupt() && mm) { | ||
261 | if (handle_tlbmiss(mm, protection_flags, textaccess, address)) | ||
262 | return 1; | ||
263 | } | ||
264 | |||
265 | return 0; | ||
266 | } | ||