aboutsummaryrefslogtreecommitdiffstats
path: root/arch/unicore32
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /arch/unicore32
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'arch/unicore32')
-rw-r--r--arch/unicore32/Kconfig34
-rw-r--r--arch/unicore32/Kconfig.debug14
-rw-r--r--arch/unicore32/Makefile1
-rw-r--r--arch/unicore32/boot/Makefile12
-rw-r--r--arch/unicore32/boot/compressed/Makefile4
-rw-r--r--arch/unicore32/include/asm/Kbuild5
-rw-r--r--arch/unicore32/include/asm/barrier.h28
-rw-r--r--arch/unicore32/include/asm/bitops.h12
-rw-r--r--arch/unicore32/include/asm/bug.h22
-rw-r--r--arch/unicore32/include/asm/cmpxchg.h61
-rw-r--r--arch/unicore32/include/asm/dma-mapping.h18
-rw-r--r--arch/unicore32/include/asm/hwdef-copro.h48
-rw-r--r--arch/unicore32/include/asm/io.h11
-rw-r--r--arch/unicore32/include/asm/pci.h6
-rw-r--r--arch/unicore32/include/asm/processor.h9
-rw-r--r--arch/unicore32/include/asm/ptrace.h77
-rw-r--r--arch/unicore32/include/asm/switch_to.h30
-rw-r--r--arch/unicore32/include/asm/thread_info.h6
-rw-r--r--arch/unicore32/include/asm/uaccess.h1
-rw-r--r--arch/unicore32/include/mach/PKUnity.h36
-rw-r--r--arch/unicore32/include/mach/hardware.h2
-rw-r--r--arch/unicore32/include/mach/regs-ost.h18
-rw-r--r--arch/unicore32/include/mach/uncompress.h4
-rw-r--r--arch/unicore32/include/uapi/asm/Kbuild10
-rw-r--r--arch/unicore32/include/uapi/asm/byteorder.h24
-rw-r--r--arch/unicore32/include/uapi/asm/ptrace.h90
-rw-r--r--arch/unicore32/include/uapi/asm/sigcontext.h29
-rw-r--r--arch/unicore32/include/uapi/asm/unistd.h15
-rw-r--r--arch/unicore32/kernel/Makefile3
-rw-r--r--arch/unicore32/kernel/dma.c1
-rw-r--r--arch/unicore32/kernel/entry.S28
-rw-r--r--arch/unicore32/kernel/head.S2
-rw-r--r--arch/unicore32/kernel/hibernate.c1
-rw-r--r--arch/unicore32/kernel/irq.c1
-rw-r--r--arch/unicore32/kernel/ksyms.c5
-rw-r--r--arch/unicore32/kernel/module.c3
-rw-r--r--arch/unicore32/kernel/pci.c24
-rw-r--r--arch/unicore32/kernel/process.c72
-rw-r--r--arch/unicore32/kernel/puv3-core.c1
-rw-r--r--arch/unicore32/kernel/puv3-nb0916.c5
-rw-r--r--arch/unicore32/kernel/setup.c3
-rw-r--r--arch/unicore32/kernel/setup.h9
-rw-r--r--arch/unicore32/kernel/signal.c69
-rw-r--r--arch/unicore32/kernel/sys.c78
-rw-r--r--arch/unicore32/kernel/time.c2
-rw-r--r--arch/unicore32/kernel/traps.c1
-rw-r--r--arch/unicore32/lib/findbit.S14
-rw-r--r--arch/unicore32/mm/alignment.c2
-rw-r--r--arch/unicore32/mm/dma-swiotlb.c18
-rw-r--r--arch/unicore32/mm/fault.c38
-rw-r--r--arch/unicore32/mm/flush.c1
-rw-r--r--arch/unicore32/mm/init.c5
-rw-r--r--arch/unicore32/mm/mm.h5
-rw-r--r--arch/unicore32/mm/mmu.c1
54 files changed, 459 insertions, 560 deletions
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index 60651df5f95..e57dcce9bfd 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -6,28 +6,33 @@ config UNICORE32
6 select HAVE_DMA_ATTRS 6 select HAVE_DMA_ATTRS
7 select HAVE_KERNEL_GZIP 7 select HAVE_KERNEL_GZIP
8 select HAVE_KERNEL_BZIP2 8 select HAVE_KERNEL_BZIP2
9 select GENERIC_ATOMIC64
10 select HAVE_KERNEL_LZO 9 select HAVE_KERNEL_LZO
11 select HAVE_KERNEL_LZMA 10 select HAVE_KERNEL_LZMA
12 select ARCH_HAVE_CUSTOM_GPIO_H
13 select GENERIC_FIND_FIRST_BIT 11 select GENERIC_FIND_FIRST_BIT
14 select GENERIC_IRQ_PROBE 12 select GENERIC_IRQ_PROBE
15 select GENERIC_IRQ_SHOW 13 select GENERIC_IRQ_SHOW
16 select ARCH_WANT_FRAME_POINTERS 14 select ARCH_WANT_FRAME_POINTERS
17 select GENERIC_IOMAP
18 select MODULES_USE_ELF_REL
19 help 15 help
20 UniCore-32 is 32-bit Instruction Set Architecture, 16 UniCore-32 is 32-bit Instruction Set Architecture,
21 including a series of low-power-consumption RISC chip 17 including a series of low-power-consumption RISC chip
22 designs licensed by PKUnity Ltd. 18 designs licensed by PKUnity Ltd.
23 Please see web page at <http://www.pkunity.com/>. 19 Please see web page at <http://www.pkunity.com/>.
24 20
21config HAVE_PWM
22 bool
23
25config GENERIC_GPIO 24config GENERIC_GPIO
26 def_bool y 25 def_bool y
27 26
27config GENERIC_CLOCKEVENTS
28 bool
29
28config GENERIC_CSUM 30config GENERIC_CSUM
29 def_bool y 31 def_bool y
30 32
33config GENERIC_IOMAP
34 def_bool y
35
31config NO_IOPORT 36config NO_IOPORT
32 bool 37 bool
33 38
@@ -64,9 +69,6 @@ config GENERIC_CALIBRATE_DELAY
64config ARCH_MAY_HAVE_PC_FDC 69config ARCH_MAY_HAVE_PC_FDC
65 bool 70 bool
66 71
67config ZONE_DMA
68 def_bool y
69
70config NEED_DMA_MAP_STATE 72config NEED_DMA_MAP_STATE
71 def_bool y 73 def_bool y
72 74
@@ -107,8 +109,7 @@ config PUV3_DB0913
107 109
108config PUV3_NB0916 110config PUV3_NB0916
109 bool "NetBook board (0916)" 111 bool "NetBook board (0916)"
110 select PWM 112 select HAVE_PWM
111 select PWM_PUV3
112 113
113config PUV3_SMW0919 114config PUV3_SMW0919
114 bool "Security Mini-Workstation board (0919)" 115 bool "Security Mini-Workstation board (0919)"
@@ -147,6 +148,8 @@ endmenu
147 148
148menu "Kernel Features" 149menu "Kernel Features"
149 150
151source "kernel/time/Kconfig"
152
150source "kernel/Kconfig.preempt" 153source "kernel/Kconfig.preempt"
151 154
152source "kernel/Kconfig.hz" 155source "kernel/Kconfig.hz"
@@ -219,22 +222,29 @@ config PUV3_GPIO
219 bool 222 bool
220 depends on !ARCH_FPGA 223 depends on !ARCH_FPGA
221 select GENERIC_GPIO 224 select GENERIC_GPIO
222 select GPIO_SYSFS 225 select GPIO_SYSFS if EXPERIMENTAL
223 default y 226 default y
224 227
228config PUV3_PWM
229 tristate
230 default BACKLIGHT_PWM
231 help
232 Enable support for NB0916 PWM controllers
233
225if PUV3_NB0916 234if PUV3_NB0916
226 235
227menu "PKUnity NetBook-0916 Features" 236menu "PKUnity NetBook-0916 Features"
228 237
229config I2C_BATTERY_BQ27200 238config I2C_BATTERY_BQ27200
230 tristate "I2C Battery BQ27200 Support" 239 tristate "I2C Battery BQ27200 Support"
231 select I2C_PUV3 240 select PUV3_I2C
232 select POWER_SUPPLY 241 select POWER_SUPPLY
233 select BATTERY_BQ27x00 242 select BATTERY_BQ27x00
234 243
235config I2C_EEPROM_AT24 244config I2C_EEPROM_AT24
236 tristate "I2C EEPROMs AT24 support" 245 tristate "I2C EEPROMs AT24 support"
237 select I2C_PUV3 246 select PUV3_I2C
247 select MISC_DEVICES
238 select EEPROM_AT24 248 select EEPROM_AT24
239 249
240config LCD_BACKLIGHT 250config LCD_BACKLIGHT
diff --git a/arch/unicore32/Kconfig.debug b/arch/unicore32/Kconfig.debug
index 1a362623984..ae2ec334c3c 100644
--- a/arch/unicore32/Kconfig.debug
+++ b/arch/unicore32/Kconfig.debug
@@ -44,4 +44,18 @@ config DEBUG_OCD
44 Say Y here if you want the debug print routines to direct their 44 Say Y here if you want the debug print routines to direct their
45 output to the UniCore On-Chip-Debugger channel using CP #1. 45 output to the UniCore On-Chip-Debugger channel using CP #1.
46 46
47config DEBUG_OCD_BREAKPOINT
48 bool "Breakpoint support via On-Chip-Debugger"
49 depends on DEBUG_OCD
50
51config DEBUG_UART
52 int "Kernel low-level debugging messages via serial port"
53 depends on DEBUG_LL
54 range 0 1
55 default "0"
56 help
57 Choice for UART for kernel low-level using PKUnity UARTS,
58 should be between zero and one. The port must have been
59 initialised by the boot-loader before use.
60
47endmenu 61endmenu
diff --git a/arch/unicore32/Makefile b/arch/unicore32/Makefile
index b6f5c4c1eaf..6af4bc415f2 100644
--- a/arch/unicore32/Makefile
+++ b/arch/unicore32/Makefile
@@ -33,6 +33,7 @@ endif
33CHECKFLAGS += -D__unicore32__ 33CHECKFLAGS += -D__unicore32__
34 34
35head-y := arch/unicore32/kernel/head.o 35head-y := arch/unicore32/kernel/head.o
36head-y += arch/unicore32/kernel/init_task.o
36 37
37core-y += arch/unicore32/kernel/ 38core-y += arch/unicore32/kernel/
38core-y += arch/unicore32/mm/ 39core-y += arch/unicore32/mm/
diff --git a/arch/unicore32/boot/Makefile b/arch/unicore32/boot/Makefile
index ec7fb70b412..79e5f88845d 100644
--- a/arch/unicore32/boot/Makefile
+++ b/arch/unicore32/boot/Makefile
@@ -11,6 +11,8 @@
11# Copyright (C) 2001~2010 GUAN Xue-tao 11# Copyright (C) 2001~2010 GUAN Xue-tao
12# 12#
13 13
14MKIMAGE := $(srctree)/scripts/mkuboot.sh
15
14targets := Image zImage uImage 16targets := Image zImage uImage
15 17
16$(obj)/Image: vmlinux FORCE 18$(obj)/Image: vmlinux FORCE
@@ -24,8 +26,14 @@ $(obj)/zImage: $(obj)/compressed/vmlinux FORCE
24 $(call if_changed,objcopy) 26 $(call if_changed,objcopy)
25 @echo ' Kernel: $@ is ready' 27 @echo ' Kernel: $@ is ready'
26 28
27UIMAGE_ARCH = unicore 29quiet_cmd_uimage = UIMAGE $@
28UIMAGE_LOADADDR = 0x0 30 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A unicore -O linux -T kernel \
31 -C none -a $(LOADADDR) -e $(STARTADDR) \
32 -n 'Linux-$(KERNELRELEASE)' -d $< $@
33
34$(obj)/uImage: LOADADDR=0x0
35
36$(obj)/uImage: STARTADDR=$(LOADADDR)
29 37
30$(obj)/uImage: $(obj)/zImage FORCE 38$(obj)/uImage: $(obj)/zImage FORCE
31 $(call if_changed,uimage) 39 $(call if_changed,uimage)
diff --git a/arch/unicore32/boot/compressed/Makefile b/arch/unicore32/boot/compressed/Makefile
index 950a9afa38f..b0954a2d23c 100644
--- a/arch/unicore32/boot/compressed/Makefile
+++ b/arch/unicore32/boot/compressed/Makefile
@@ -10,8 +10,8 @@
10# Copyright (C) 2001~2010 GUAN Xue-tao 10# Copyright (C) 2001~2010 GUAN Xue-tao
11# 11#
12 12
13ccflags-y := -fpic -fno-builtin 13EXTRA_CFLAGS := -fpic -fno-builtin
14asflags-y := -Wa,-march=all 14EXTRA_AFLAGS := -Wa,-march=all
15 15
16OBJS := misc.o 16OBJS := misc.o
17 17
diff --git a/arch/unicore32/include/asm/Kbuild b/arch/unicore32/include/asm/Kbuild
index 89d8b6c4e39..ca113d6999c 100644
--- a/arch/unicore32/include/asm/Kbuild
+++ b/arch/unicore32/include/asm/Kbuild
@@ -1,16 +1,16 @@
1include include/asm-generic/Kbuild.asm
1 2
2generic-y += atomic.h 3generic-y += atomic.h
3generic-y += auxvec.h 4generic-y += auxvec.h
4generic-y += bitsperlong.h 5generic-y += bitsperlong.h
6generic-y += bug.h
5generic-y += bugs.h 7generic-y += bugs.h
6generic-y += clkdev.h
7generic-y += cputime.h 8generic-y += cputime.h
8generic-y += current.h 9generic-y += current.h
9generic-y += device.h 10generic-y += device.h
10generic-y += div64.h 11generic-y += div64.h
11generic-y += emergency-restart.h 12generic-y += emergency-restart.h
12generic-y += errno.h 13generic-y += errno.h
13generic-y += exec.h
14generic-y += fb.h 14generic-y += fb.h
15generic-y += fcntl.h 15generic-y += fcntl.h
16generic-y += ftrace.h 16generic-y += ftrace.h
@@ -53,7 +53,6 @@ generic-y += syscalls.h
53generic-y += termbits.h 53generic-y += termbits.h
54generic-y += termios.h 54generic-y += termios.h
55generic-y += topology.h 55generic-y += topology.h
56generic-y += trace_clock.h
57generic-y += types.h 56generic-y += types.h
58generic-y += ucontext.h 57generic-y += ucontext.h
59generic-y += unaligned.h 58generic-y += unaligned.h
diff --git a/arch/unicore32/include/asm/barrier.h b/arch/unicore32/include/asm/barrier.h
deleted file mode 100644
index a6620e5336b..00000000000
--- a/arch/unicore32/include/asm/barrier.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * Memory barrier implementations for PKUnity SoC and UniCore ISA
3 *
4 * Copyright (C) 2001-2012 GUAN Xue-tao
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __UNICORE_BARRIER_H__
11#define __UNICORE_BARRIER_H__
12
13#define isb() __asm__ __volatile__ ("" : : : "memory")
14#define dsb() __asm__ __volatile__ ("" : : : "memory")
15#define dmb() __asm__ __volatile__ ("" : : : "memory")
16
17#define mb() barrier()
18#define rmb() barrier()
19#define wmb() barrier()
20#define smp_mb() barrier()
21#define smp_rmb() barrier()
22#define smp_wmb() barrier()
23#define read_barrier_depends() do { } while (0)
24#define smp_read_barrier_depends() do { } while (0)
25
26#define set_mb(var, value) do { var = value; smp_mb(); } while (0)
27
28#endif /* __UNICORE_BARRIER_H__ */
diff --git a/arch/unicore32/include/asm/bitops.h b/arch/unicore32/include/asm/bitops.h
index 401f597bc38..1628a632899 100644
--- a/arch/unicore32/include/asm/bitops.h
+++ b/arch/unicore32/include/asm/bitops.h
@@ -13,6 +13,12 @@
13#ifndef __UNICORE_BITOPS_H__ 13#ifndef __UNICORE_BITOPS_H__
14#define __UNICORE_BITOPS_H__ 14#define __UNICORE_BITOPS_H__
15 15
16#define find_next_bit __uc32_find_next_bit
17#define find_next_zero_bit __uc32_find_next_zero_bit
18
19#define find_first_bit __uc32_find_first_bit
20#define find_first_zero_bit __uc32_find_first_zero_bit
21
16#define _ASM_GENERIC_BITOPS_FLS_H_ 22#define _ASM_GENERIC_BITOPS_FLS_H_
17#define _ASM_GENERIC_BITOPS___FLS_H_ 23#define _ASM_GENERIC_BITOPS___FLS_H_
18#define _ASM_GENERIC_BITOPS_FFS_H_ 24#define _ASM_GENERIC_BITOPS_FFS_H_
@@ -38,10 +44,4 @@ static inline int fls(int x)
38 44
39#include <asm-generic/bitops.h> 45#include <asm-generic/bitops.h>
40 46
41/* following definitions: to avoid using codes in lib/find_*.c */
42#define find_next_bit find_next_bit
43#define find_next_zero_bit find_next_zero_bit
44#define find_first_bit find_first_bit
45#define find_first_zero_bit find_first_zero_bit
46
47#endif /* __UNICORE_BITOPS_H__ */ 47#endif /* __UNICORE_BITOPS_H__ */
diff --git a/arch/unicore32/include/asm/bug.h b/arch/unicore32/include/asm/bug.h
deleted file mode 100644
index 93a56f3e234..00000000000
--- a/arch/unicore32/include/asm/bug.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Bug handling for PKUnity SoC and UniCore ISA
3 *
4 * Copyright (C) 2001-2012 GUAN Xue-tao
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __UNICORE_BUG_H__
11#define __UNICORE_BUG_H__
12
13#include <asm-generic/bug.h>
14
15struct pt_regs;
16struct siginfo;
17
18extern void die(const char *msg, struct pt_regs *regs, int err);
19extern void uc32_notify_die(const char *str, struct pt_regs *regs,
20 struct siginfo *info, unsigned long err, unsigned long trap);
21
22#endif /* __UNICORE_BUG_H__ */
diff --git a/arch/unicore32/include/asm/cmpxchg.h b/arch/unicore32/include/asm/cmpxchg.h
deleted file mode 100644
index 8e797ad4fa2..00000000000
--- a/arch/unicore32/include/asm/cmpxchg.h
+++ /dev/null
@@ -1,61 +0,0 @@
1/*
2 * Atomics xchg/cmpxchg for PKUnity SoC and UniCore ISA
3 *
4 * Copyright (C) 2001-2012 GUAN Xue-tao
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __UNICORE_CMPXCHG_H__
11#define __UNICORE_CMPXCHG_H__
12
13/*
14 * Generate a link failure on undefined symbol if the pointer points to a value
15 * of unsupported size.
16 */
17extern void __xchg_bad_pointer(void);
18
19static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
20 int size)
21{
22 unsigned long ret;
23
24 switch (size) {
25 case 1:
26 asm volatile("swapb %0, %1, [%2]"
27 : "=&r" (ret)
28 : "r" (x), "r" (ptr)
29 : "memory", "cc");
30 break;
31 case 4:
32 asm volatile("swapw %0, %1, [%2]"
33 : "=&r" (ret)
34 : "r" (x), "r" (ptr)
35 : "memory", "cc");
36 break;
37 default:
38 __xchg_bad_pointer();
39 }
40
41 return ret;
42}
43
44#define xchg(ptr, x) \
45 ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
46
47#include <asm-generic/cmpxchg-local.h>
48
49/*
50 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
51 * them available.
52 */
53#define cmpxchg_local(ptr, o, n) \
54 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
55 (unsigned long)(o), (unsigned long)(n), sizeof(*(ptr))))
56#define cmpxchg64_local(ptr, o, n) \
57 __cmpxchg64_local_generic((ptr), (o), (n))
58
59#include <asm-generic/cmpxchg.h>
60
61#endif /* __UNICORE_CMPXCHG_H__ */
diff --git a/arch/unicore32/include/asm/dma-mapping.h b/arch/unicore32/include/asm/dma-mapping.h
index 366460a8179..9258e592f41 100644
--- a/arch/unicore32/include/asm/dma-mapping.h
+++ b/arch/unicore32/include/asm/dma-mapping.h
@@ -82,26 +82,20 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
82 return 0; 82 return 0;
83} 83}
84 84
85#define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL) 85static inline void *dma_alloc_coherent(struct device *dev, size_t size,
86 86 dma_addr_t *dma_handle, gfp_t flag)
87static inline void *dma_alloc_attrs(struct device *dev, size_t size,
88 dma_addr_t *dma_handle, gfp_t flag,
89 struct dma_attrs *attrs)
90{ 87{
91 struct dma_map_ops *dma_ops = get_dma_ops(dev); 88 struct dma_map_ops *dma_ops = get_dma_ops(dev);
92 89
93 return dma_ops->alloc(dev, size, dma_handle, flag, attrs); 90 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
94} 91}
95 92
96#define dma_free_coherent(d,s,c,h) dma_free_attrs(d,s,c,h,NULL) 93static inline void dma_free_coherent(struct device *dev, size_t size,
97 94 void *cpu_addr, dma_addr_t dma_handle)
98static inline void dma_free_attrs(struct device *dev, size_t size,
99 void *cpu_addr, dma_addr_t dma_handle,
100 struct dma_attrs *attrs)
101{ 95{
102 struct dma_map_ops *dma_ops = get_dma_ops(dev); 96 struct dma_map_ops *dma_ops = get_dma_ops(dev);
103 97
104 dma_ops->free(dev, size, cpu_addr, dma_handle, attrs); 98 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
105} 99}
106 100
107#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 101#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
diff --git a/arch/unicore32/include/asm/hwdef-copro.h b/arch/unicore32/include/asm/hwdef-copro.h
deleted file mode 100644
index a3292f039a6..00000000000
--- a/arch/unicore32/include/asm/hwdef-copro.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 * Co-processor register definitions for PKUnity SoC and UniCore ISA
3 *
4 * Copyright (C) 2001-2012 GUAN Xue-tao
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __UNICORE_HWDEF_COPRO_H__
11#define __UNICORE_HWDEF_COPRO_H__
12
13/*
14 * Control Register bits (CP#0 CR1)
15 */
16#define CR_M (1 << 0) /* MMU enable */
17#define CR_A (1 << 1) /* Alignment abort enable */
18#define CR_D (1 << 2) /* Dcache enable */
19#define CR_I (1 << 3) /* Icache enable */
20#define CR_B (1 << 4) /* Dcache write mechanism: write back */
21#define CR_T (1 << 5) /* Burst enable */
22#define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */
23
24#ifndef __ASSEMBLY__
25
26#define vectors_high() (cr_alignment & CR_V)
27
28extern unsigned long cr_no_alignment; /* defined in entry.S */
29extern unsigned long cr_alignment; /* defined in entry.S */
30
31static inline unsigned int get_cr(void)
32{
33 unsigned int val;
34 asm("movc %0, p0.c1, #0" : "=r" (val) : : "cc");
35 return val;
36}
37
38static inline void set_cr(unsigned int val)
39{
40 asm volatile("movc p0.c1, %0, #0" : : "r" (val) : "cc");
41 isb();
42}
43
44extern void adjust_cr(unsigned long mask, unsigned long set);
45
46#endif /* __ASSEMBLY__ */
47
48#endif /* __UNICORE_HWDEF_COPRO_H__ */
diff --git a/arch/unicore32/include/asm/io.h b/arch/unicore32/include/asm/io.h
index 39decb6e6f5..4bd87f3d13d 100644
--- a/arch/unicore32/include/asm/io.h
+++ b/arch/unicore32/include/asm/io.h
@@ -16,6 +16,7 @@
16 16
17#include <asm/byteorder.h> 17#include <asm/byteorder.h>
18#include <asm/memory.h> 18#include <asm/memory.h>
19#include <asm/system.h>
19 20
20#define PCI_IOBASE PKUNITY_PCILIO_BASE 21#define PCI_IOBASE PKUNITY_PCILIO_BASE
21#include <asm-generic/io.h> 22#include <asm-generic/io.h>
@@ -31,14 +32,20 @@ extern void __uc32_iounmap(volatile void __iomem *addr);
31 * ioremap and friends. 32 * ioremap and friends.
32 * 33 *
33 * ioremap takes a PCI memory address, as specified in 34 * ioremap takes a PCI memory address, as specified in
34 * Documentation/io-mapping.txt. 35 * Documentation/IO-mapping.txt.
35 * 36 *
36 */ 37 */
37#define ioremap(cookie, size) __uc32_ioremap(cookie, size) 38#define ioremap(cookie, size) __uc32_ioremap(cookie, size)
38#define ioremap_cached(cookie, size) __uc32_ioremap_cached(cookie, size) 39#define ioremap_cached(cookie, size) __uc32_ioremap_cached(cookie, size)
39#define ioremap_nocache(cookie, size) __uc32_ioremap(cookie, size)
40#define iounmap(cookie) __uc32_iounmap(cookie) 40#define iounmap(cookie) __uc32_iounmap(cookie)
41 41
42/*
43 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
44 * access
45 */
46#undef xlate_dev_mem_ptr
47#define xlate_dev_mem_ptr(p) __va(p)
48
42#define HAVE_ARCH_PIO_SIZE 49#define HAVE_ARCH_PIO_SIZE
43#define PIO_OFFSET (unsigned int)(PCI_IOBASE) 50#define PIO_OFFSET (unsigned int)(PCI_IOBASE)
44#define PIO_MASK (unsigned int)(IO_SPACE_LIMIT) 51#define PIO_MASK (unsigned int)(IO_SPACE_LIMIT)
diff --git a/arch/unicore32/include/asm/pci.h b/arch/unicore32/include/asm/pci.h
index f5e108f4a15..c5b28b45953 100644
--- a/arch/unicore32/include/asm/pci.h
+++ b/arch/unicore32/include/asm/pci.h
@@ -14,10 +14,14 @@
14 14
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16#include <asm-generic/pci-dma-compat.h> 16#include <asm-generic/pci-dma-compat.h>
17#include <asm-generic/pci-bridge.h>
18#include <asm-generic/pci.h> 17#include <asm-generic/pci.h>
19#include <mach/hardware.h> /* for PCIBIOS_MIN_* */ 18#include <mach/hardware.h> /* for PCIBIOS_MIN_* */
20 19
20static inline void pcibios_set_master(struct pci_dev *dev)
21{
22 /* No special bus mastering setup handling */
23}
24
21static inline void pcibios_penalize_isa_irq(int irq, int active) 25static inline void pcibios_penalize_isa_irq(int irq, int active)
22{ 26{
23 /* We don't do dynamic PCI IRQ allocation */ 27 /* We don't do dynamic PCI IRQ allocation */
diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h
index 4eaa4216766..e11cb078657 100644
--- a/arch/unicore32/include/asm/processor.h
+++ b/arch/unicore32/include/asm/processor.h
@@ -53,6 +53,7 @@ struct thread_struct {
53#define start_thread(regs, pc, sp) \ 53#define start_thread(regs, pc, sp) \
54({ \ 54({ \
55 unsigned long *stack = (unsigned long *)sp; \ 55 unsigned long *stack = (unsigned long *)sp; \
56 set_fs(USER_DS); \
56 memset(regs->uregs, 0, sizeof(regs->uregs)); \ 57 memset(regs->uregs, 0, sizeof(regs->uregs)); \
57 regs->UCreg_asr = USER_MODE; \ 58 regs->UCreg_asr = USER_MODE; \
58 regs->UCreg_pc = pc & ~1; /* pc */ \ 59 regs->UCreg_pc = pc & ~1; /* pc */ \
@@ -68,10 +69,18 @@ struct task_struct;
68/* Free all resources held by a thread. */ 69/* Free all resources held by a thread. */
69extern void release_thread(struct task_struct *); 70extern void release_thread(struct task_struct *);
70 71
72/* Prepare to copy thread state - unlazy all lazy status */
73#define prepare_to_copy(tsk) do { } while (0)
74
71unsigned long get_wchan(struct task_struct *p); 75unsigned long get_wchan(struct task_struct *p);
72 76
73#define cpu_relax() barrier() 77#define cpu_relax() barrier()
74 78
79/*
80 * Create a new kernel thread
81 */
82extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
83
75#define task_pt_regs(p) \ 84#define task_pt_regs(p) \
76 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1) 85 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
77 86
diff --git a/arch/unicore32/include/asm/ptrace.h b/arch/unicore32/include/asm/ptrace.h
index 9df53d991c7..b9caf9b0997 100644
--- a/arch/unicore32/include/asm/ptrace.h
+++ b/arch/unicore32/include/asm/ptrace.h
@@ -12,10 +12,80 @@
12#ifndef __UNICORE_PTRACE_H__ 12#ifndef __UNICORE_PTRACE_H__
13#define __UNICORE_PTRACE_H__ 13#define __UNICORE_PTRACE_H__
14 14
15#include <uapi/asm/ptrace.h> 15#define PTRACE_GET_THREAD_AREA 22
16
17/*
18 * PSR bits
19 */
20#define USER_MODE 0x00000010
21#define REAL_MODE 0x00000011
22#define INTR_MODE 0x00000012
23#define PRIV_MODE 0x00000013
24#define ABRT_MODE 0x00000017
25#define EXTN_MODE 0x0000001b
26#define SUSR_MODE 0x0000001f
27#define MODE_MASK 0x0000001f
28#define PSR_R_BIT 0x00000040
29#define PSR_I_BIT 0x00000080
30#define PSR_V_BIT 0x10000000
31#define PSR_C_BIT 0x20000000
32#define PSR_Z_BIT 0x40000000
33#define PSR_S_BIT 0x80000000
34
35/*
36 * Groups of PSR bits
37 */
38#define PSR_f 0xff000000 /* Flags */
39#define PSR_c 0x000000ff /* Control */
16 40
17#ifndef __ASSEMBLY__ 41#ifndef __ASSEMBLY__
18 42
43/*
44 * This struct defines the way the registers are stored on the
45 * stack during a system call. Note that sizeof(struct pt_regs)
46 * has to be a multiple of 8.
47 */
48struct pt_regs {
49 unsigned long uregs[34];
50};
51
52#define UCreg_asr uregs[32]
53#define UCreg_pc uregs[31]
54#define UCreg_lr uregs[30]
55#define UCreg_sp uregs[29]
56#define UCreg_ip uregs[28]
57#define UCreg_fp uregs[27]
58#define UCreg_26 uregs[26]
59#define UCreg_25 uregs[25]
60#define UCreg_24 uregs[24]
61#define UCreg_23 uregs[23]
62#define UCreg_22 uregs[22]
63#define UCreg_21 uregs[21]
64#define UCreg_20 uregs[20]
65#define UCreg_19 uregs[19]
66#define UCreg_18 uregs[18]
67#define UCreg_17 uregs[17]
68#define UCreg_16 uregs[16]
69#define UCreg_15 uregs[15]
70#define UCreg_14 uregs[14]
71#define UCreg_13 uregs[13]
72#define UCreg_12 uregs[12]
73#define UCreg_11 uregs[11]
74#define UCreg_10 uregs[10]
75#define UCreg_09 uregs[9]
76#define UCreg_08 uregs[8]
77#define UCreg_07 uregs[7]
78#define UCreg_06 uregs[6]
79#define UCreg_05 uregs[5]
80#define UCreg_04 uregs[4]
81#define UCreg_03 uregs[3]
82#define UCreg_02 uregs[2]
83#define UCreg_01 uregs[1]
84#define UCreg_00 uregs[0]
85#define UCreg_ORIG_00 uregs[33]
86
87#ifdef __KERNEL__
88
19#define user_mode(regs) \ 89#define user_mode(regs) \
20 (processor_mode(regs) == USER_MODE) 90 (processor_mode(regs) == USER_MODE)
21 91
@@ -54,7 +124,10 @@ static inline int valid_user_regs(struct pt_regs *regs)
54} 124}
55 125
56#define instruction_pointer(regs) ((regs)->UCreg_pc) 126#define instruction_pointer(regs) ((regs)->UCreg_pc)
57#define user_stack_pointer(regs) ((regs)->UCreg_sp) 127
128#endif /* __KERNEL__ */
58 129
59#endif /* __ASSEMBLY__ */ 130#endif /* __ASSEMBLY__ */
131
60#endif 132#endif
133
diff --git a/arch/unicore32/include/asm/switch_to.h b/arch/unicore32/include/asm/switch_to.h
deleted file mode 100644
index 39572d2bd69..00000000000
--- a/arch/unicore32/include/asm/switch_to.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*
2 * Task switching for PKUnity SoC and UniCore ISA
3 *
4 * Copyright (C) 2001-2012 GUAN Xue-tao
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __UNICORE_SWITCH_TO_H__
11#define __UNICORE_SWITCH_TO_H__
12
13struct task_struct;
14struct thread_info;
15
16/*
17 * switch_to(prev, next) should switch from task `prev' to `next'
18 * `prev' will never be the same as `next'. schedule() itself
19 * contains the memory barrier to tell GCC not to cache `current'.
20 */
21extern struct task_struct *__switch_to(struct task_struct *,
22 struct thread_info *, struct thread_info *);
23
24#define switch_to(prev, next, last) \
25 do { \
26 last = __switch_to(prev, task_thread_info(prev), \
27 task_thread_info(next)); \
28 } while (0)
29
30#endif /* __UNICORE_SWITCH_TO_H__ */
diff --git a/arch/unicore32/include/asm/thread_info.h b/arch/unicore32/include/asm/thread_info.h
index 818b4a1edb5..c270e9e0486 100644
--- a/arch/unicore32/include/asm/thread_info.h
+++ b/arch/unicore32/include/asm/thread_info.h
@@ -135,18 +135,20 @@ static inline struct thread_info *current_thread_info(void)
135#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ 135#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
136#define TIF_SYSCALL_TRACE 8 136#define TIF_SYSCALL_TRACE 8
137#define TIF_MEMDIE 18 137#define TIF_MEMDIE 18
138#define TIF_FREEZE 19
138#define TIF_RESTORE_SIGMASK 20 139#define TIF_RESTORE_SIGMASK 20
139 140
140#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 141#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
141#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 142#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
142#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 143#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
143#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 144#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
145#define _TIF_FREEZE (1 << TIF_FREEZE)
146#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
144 147
145/* 148/*
146 * Change these and you break ASM code in entry-common.S 149 * Change these and you break ASM code in entry-common.S
147 */ 150 */
148#define _TIF_WORK_MASK \ 151#define _TIF_WORK_MASK 0x000000ff
149 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
150 152
151#endif /* __KERNEL__ */ 153#endif /* __KERNEL__ */
152#endif /* __UNICORE_THREAD_INFO_H__ */ 154#endif /* __UNICORE_THREAD_INFO_H__ */
diff --git a/arch/unicore32/include/asm/uaccess.h b/arch/unicore32/include/asm/uaccess.h
index 897e11ad812..2acda503a6d 100644
--- a/arch/unicore32/include/asm/uaccess.h
+++ b/arch/unicore32/include/asm/uaccess.h
@@ -16,6 +16,7 @@
16#include <linux/errno.h> 16#include <linux/errno.h>
17 17
18#include <asm/memory.h> 18#include <asm/memory.h>
19#include <asm/system.h>
19 20
20#define __copy_from_user __copy_from_user 21#define __copy_from_user __copy_from_user
21#define __copy_to_user __copy_to_user 22#define __copy_to_user __copy_to_user
diff --git a/arch/unicore32/include/mach/PKUnity.h b/arch/unicore32/include/mach/PKUnity.h
index 46705afcbf5..8040d575ddd 100644
--- a/arch/unicore32/include/mach/PKUnity.h
+++ b/arch/unicore32/include/mach/PKUnity.h
@@ -15,7 +15,7 @@
15#error You must include hardware.h not PKUnity.h 15#error You must include hardware.h not PKUnity.h
16#endif 16#endif
17 17
18#include <mach/bitfield.h> 18#include "bitfield.h"
19 19
20/* 20/*
21 * Memory Definitions 21 * Memory Definitions
@@ -32,7 +32,7 @@
32 * 0x98000000 - 0x9FFFFFFF 128MB PCI PCI-AHB MEM-mapping 32 * 0x98000000 - 0x9FFFFFFF 128MB PCI PCI-AHB MEM-mapping
33 */ 33 */
34#define PKUNITY_PCI_BASE io_p2v(0x80000000) /* 0x80000000 - 0xBFFFFFFF 1GB */ 34#define PKUNITY_PCI_BASE io_p2v(0x80000000) /* 0x80000000 - 0xBFFFFFFF 1GB */
35#include <mach/regs-pci.h> 35#include "regs-pci.h"
36 36
37#define PKUNITY_PCICFG_BASE (PKUNITY_PCI_BASE + 0x0) 37#define PKUNITY_PCICFG_BASE (PKUNITY_PCI_BASE + 0x0)
38#define PKUNITY_PCIBRI_BASE (PKUNITY_PCI_BASE + 0x00010000) 38#define PKUNITY_PCIBRI_BASE (PKUNITY_PCI_BASE + 0x00010000)
@@ -50,18 +50,18 @@
50#define PKUNITY_ARBITER_BASE (PKUNITY_AHB_BASE + 0x000000) /* AHB-2 */ 50#define PKUNITY_ARBITER_BASE (PKUNITY_AHB_BASE + 0x000000) /* AHB-2 */
51#define PKUNITY_DDR2CTRL_BASE (PKUNITY_AHB_BASE + 0x100000) /* AHB-3 */ 51#define PKUNITY_DDR2CTRL_BASE (PKUNITY_AHB_BASE + 0x100000) /* AHB-3 */
52#define PKUNITY_DMAC_BASE (PKUNITY_AHB_BASE + 0x200000) /* AHB-4 */ 52#define PKUNITY_DMAC_BASE (PKUNITY_AHB_BASE + 0x200000) /* AHB-4 */
53#include <mach/regs-dmac.h> 53#include "regs-dmac.h"
54#define PKUNITY_UMAL_BASE (PKUNITY_AHB_BASE + 0x300000) /* AHB-5 */ 54#define PKUNITY_UMAL_BASE (PKUNITY_AHB_BASE + 0x300000) /* AHB-5 */
55#include <mach/regs-umal.h> 55#include "regs-umal.h"
56#define PKUNITY_USB_BASE (PKUNITY_AHB_BASE + 0x400000) /* AHB-6 */ 56#define PKUNITY_USB_BASE (PKUNITY_AHB_BASE + 0x400000) /* AHB-6 */
57#define PKUNITY_SATA_BASE (PKUNITY_AHB_BASE + 0x500000) /* AHB-7 */ 57#define PKUNITY_SATA_BASE (PKUNITY_AHB_BASE + 0x500000) /* AHB-7 */
58#define PKUNITY_SMC_BASE (PKUNITY_AHB_BASE + 0x600000) /* AHB-8 */ 58#define PKUNITY_SMC_BASE (PKUNITY_AHB_BASE + 0x600000) /* AHB-8 */
59/* AHB-9 is for APB bridge */ 59/* AHB-9 is for APB bridge */
60#define PKUNITY_MME_BASE (PKUNITY_AHB_BASE + 0x700000) /* AHB-10 */ 60#define PKUNITY_MME_BASE (PKUNITY_AHB_BASE + 0x700000) /* AHB-10 */
61#define PKUNITY_UNIGFX_BASE (PKUNITY_AHB_BASE + 0x800000) /* AHB-11 */ 61#define PKUNITY_UNIGFX_BASE (PKUNITY_AHB_BASE + 0x800000) /* AHB-11 */
62#include <mach/regs-unigfx.h> 62#include "regs-unigfx.h"
63#define PKUNITY_NAND_BASE (PKUNITY_AHB_BASE + 0x900000) /* AHB-12 */ 63#define PKUNITY_NAND_BASE (PKUNITY_AHB_BASE + 0x900000) /* AHB-12 */
64#include <mach/regs-nand.h> 64#include "regs-nand.h"
65#define PKUNITY_H264D_BASE (PKUNITY_AHB_BASE + 0xA00000) /* AHB-13 */ 65#define PKUNITY_H264D_BASE (PKUNITY_AHB_BASE + 0xA00000) /* AHB-13 */
66#define PKUNITY_H264E_BASE (PKUNITY_AHB_BASE + 0xB00000) /* AHB-14 */ 66#define PKUNITY_H264E_BASE (PKUNITY_AHB_BASE + 0xB00000) /* AHB-14 */
67 67
@@ -72,27 +72,27 @@
72 72
73#define PKUNITY_UART0_BASE (PKUNITY_APB_BASE + 0x000000) /* APB-0 */ 73#define PKUNITY_UART0_BASE (PKUNITY_APB_BASE + 0x000000) /* APB-0 */
74#define PKUNITY_UART1_BASE (PKUNITY_APB_BASE + 0x100000) /* APB-1 */ 74#define PKUNITY_UART1_BASE (PKUNITY_APB_BASE + 0x100000) /* APB-1 */
75#include <mach/regs-uart.h> 75#include "regs-uart.h"
76#define PKUNITY_I2C_BASE (PKUNITY_APB_BASE + 0x200000) /* APB-2 */ 76#define PKUNITY_I2C_BASE (PKUNITY_APB_BASE + 0x200000) /* APB-2 */
77#include <mach/regs-i2c.h> 77#include "regs-i2c.h"
78#define PKUNITY_SPI_BASE (PKUNITY_APB_BASE + 0x300000) /* APB-3 */ 78#define PKUNITY_SPI_BASE (PKUNITY_APB_BASE + 0x300000) /* APB-3 */
79#include <mach/regs-spi.h> 79#include "regs-spi.h"
80#define PKUNITY_AC97_BASE (PKUNITY_APB_BASE + 0x400000) /* APB-4 */ 80#define PKUNITY_AC97_BASE (PKUNITY_APB_BASE + 0x400000) /* APB-4 */
81#include <mach/regs-ac97.h> 81#include "regs-ac97.h"
82#define PKUNITY_GPIO_BASE (PKUNITY_APB_BASE + 0x500000) /* APB-5 */ 82#define PKUNITY_GPIO_BASE (PKUNITY_APB_BASE + 0x500000) /* APB-5 */
83#include <mach/regs-gpio.h> 83#include "regs-gpio.h"
84#define PKUNITY_INTC_BASE (PKUNITY_APB_BASE + 0x600000) /* APB-6 */ 84#define PKUNITY_INTC_BASE (PKUNITY_APB_BASE + 0x600000) /* APB-6 */
85#include <mach/regs-intc.h> 85#include "regs-intc.h"
86#define PKUNITY_RTC_BASE (PKUNITY_APB_BASE + 0x700000) /* APB-7 */ 86#define PKUNITY_RTC_BASE (PKUNITY_APB_BASE + 0x700000) /* APB-7 */
87#include <mach/regs-rtc.h> 87#include "regs-rtc.h"
88#define PKUNITY_OST_BASE (PKUNITY_APB_BASE + 0x800000) /* APB-8 */ 88#define PKUNITY_OST_BASE (PKUNITY_APB_BASE + 0x800000) /* APB-8 */
89#include <mach/regs-ost.h> 89#include "regs-ost.h"
90#define PKUNITY_RESETC_BASE (PKUNITY_APB_BASE + 0x900000) /* APB-9 */ 90#define PKUNITY_RESETC_BASE (PKUNITY_APB_BASE + 0x900000) /* APB-9 */
91#include <mach/regs-resetc.h> 91#include "regs-resetc.h"
92#define PKUNITY_PM_BASE (PKUNITY_APB_BASE + 0xA00000) /* APB-10 */ 92#define PKUNITY_PM_BASE (PKUNITY_APB_BASE + 0xA00000) /* APB-10 */
93#include <mach/regs-pm.h> 93#include "regs-pm.h"
94#define PKUNITY_PS2_BASE (PKUNITY_APB_BASE + 0xB00000) /* APB-11 */ 94#define PKUNITY_PS2_BASE (PKUNITY_APB_BASE + 0xB00000) /* APB-11 */
95#include <mach/regs-ps2.h> 95#include "regs-ps2.h"
96#define PKUNITY_SDC_BASE (PKUNITY_APB_BASE + 0xC00000) /* APB-12 */ 96#define PKUNITY_SDC_BASE (PKUNITY_APB_BASE + 0xC00000) /* APB-12 */
97#include <mach/regs-sdc.h> 97#include "regs-sdc.h"
98 98
diff --git a/arch/unicore32/include/mach/hardware.h b/arch/unicore32/include/mach/hardware.h
index 9e20b5d9ed5..930bea6e129 100644
--- a/arch/unicore32/include/mach/hardware.h
+++ b/arch/unicore32/include/mach/hardware.h
@@ -15,7 +15,7 @@
15#ifndef __MACH_PUV3_HARDWARE_H__ 15#ifndef __MACH_PUV3_HARDWARE_H__
16#define __MACH_PUV3_HARDWARE_H__ 16#define __MACH_PUV3_HARDWARE_H__
17 17
18#include <mach/PKUnity.h> 18#include "PKUnity.h"
19 19
20#ifndef __ASSEMBLY__ 20#ifndef __ASSEMBLY__
21#define io_p2v(x) (void __iomem *)((x) - PKUNITY_MMIO_BASE) 21#define io_p2v(x) (void __iomem *)((x) - PKUNITY_MMIO_BASE)
diff --git a/arch/unicore32/include/mach/regs-ost.h b/arch/unicore32/include/mach/regs-ost.h
index 4a85fb46384..7b91fe698ee 100644
--- a/arch/unicore32/include/mach/regs-ost.h
+++ b/arch/unicore32/include/mach/regs-ost.h
@@ -33,16 +33,18 @@
33 * Interrupt Enable Reg OST_OIER 33 * Interrupt Enable Reg OST_OIER
34 */ 34 */
35#define OST_OIER (PKUNITY_OST_BASE + 0x001C) 35#define OST_OIER (PKUNITY_OST_BASE + 0x001C)
36
37/* 36/*
38 * PWM Registers: IO base address: PKUNITY_OST_BASE + 0x80 37 * PWM Pulse Width Control Reg OST_PWMPWCR
39 * PWCR: Pulse Width Control Reg 38 */
40 * DCCR: Duty Cycle Control Reg 39#define OST_PWMPWCR (PKUNITY_OST_BASE + 0x0080)
41 * PCR: Period Control Reg 40/*
41 * PWM Duty Cycle Control Reg OST_PWMDCCR
42 */
43#define OST_PWMDCCR (PKUNITY_OST_BASE + 0x0084)
44/*
45 * PWM Period Control Reg OST_PWMPCR
42 */ 46 */
43#define OST_PWM_PWCR (0x00) 47#define OST_PWMPCR (PKUNITY_OST_BASE + 0x0088)
44#define OST_PWM_DCCR (0x04)
45#define OST_PWM_PCR (0x08)
46 48
47/* 49/*
48 * Match detected 0 OST_OSSR_M0 50 * Match detected 0 OST_OSSR_M0
diff --git a/arch/unicore32/include/mach/uncompress.h b/arch/unicore32/include/mach/uncompress.h
index 9be67c9d3b5..142d3e7958a 100644
--- a/arch/unicore32/include/mach/uncompress.h
+++ b/arch/unicore32/include/mach/uncompress.h
@@ -13,8 +13,8 @@
13#ifndef __MACH_PUV3_UNCOMPRESS_H__ 13#ifndef __MACH_PUV3_UNCOMPRESS_H__
14#define __MACH_PUV3_UNCOMPRESS_H__ 14#define __MACH_PUV3_UNCOMPRESS_H__
15 15
16#include <mach/hardware.h> 16#include "hardware.h"
17#include <mach/ocd.h> 17#include "ocd.h"
18 18
19extern char input_data[]; 19extern char input_data[];
20extern char input_data_end[]; 20extern char input_data_end[];
diff --git a/arch/unicore32/include/uapi/asm/Kbuild b/arch/unicore32/include/uapi/asm/Kbuild
deleted file mode 100644
index 0514d7ad685..00000000000
--- a/arch/unicore32/include/uapi/asm/Kbuild
+++ /dev/null
@@ -1,10 +0,0 @@
1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm
3
4header-y += byteorder.h
5header-y += kvm_para.h
6header-y += ptrace.h
7header-y += sigcontext.h
8header-y += unistd.h
9
10generic-y += kvm_para.h
diff --git a/arch/unicore32/include/uapi/asm/byteorder.h b/arch/unicore32/include/uapi/asm/byteorder.h
deleted file mode 100644
index ebe1b3fef3e..00000000000
--- a/arch/unicore32/include/uapi/asm/byteorder.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * linux/arch/unicore32/include/asm/byteorder.h
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
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 version 2 as
10 * published by the Free Software Foundation.
11 *
12 * UniCore ONLY support Little Endian mode, the data bus is connected such
13 * that byte accesses appear as:
14 * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
15 * and word accesses (data or instruction) appear as:
16 * d0...d31
17 */
18#ifndef __UNICORE_BYTEORDER_H__
19#define __UNICORE_BYTEORDER_H__
20
21#include <linux/byteorder/little_endian.h>
22
23#endif
24
diff --git a/arch/unicore32/include/uapi/asm/ptrace.h b/arch/unicore32/include/uapi/asm/ptrace.h
deleted file mode 100644
index 187aa2e98a5..00000000000
--- a/arch/unicore32/include/uapi/asm/ptrace.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * linux/arch/unicore32/include/asm/ptrace.h
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
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 version 2 as
10 * published by the Free Software Foundation.
11 */
12#ifndef _UAPI__UNICORE_PTRACE_H__
13#define _UAPI__UNICORE_PTRACE_H__
14
15#define PTRACE_GET_THREAD_AREA 22
16
17/*
18 * PSR bits
19 */
20#define USER_MODE 0x00000010
21#define REAL_MODE 0x00000011
22#define INTR_MODE 0x00000012
23#define PRIV_MODE 0x00000013
24#define ABRT_MODE 0x00000017
25#define EXTN_MODE 0x0000001b
26#define SUSR_MODE 0x0000001f
27#define MODE_MASK 0x0000001f
28#define PSR_R_BIT 0x00000040
29#define PSR_I_BIT 0x00000080
30#define PSR_V_BIT 0x10000000
31#define PSR_C_BIT 0x20000000
32#define PSR_Z_BIT 0x40000000
33#define PSR_S_BIT 0x80000000
34
35/*
36 * Groups of PSR bits
37 */
38#define PSR_f 0xff000000 /* Flags */
39#define PSR_c 0x000000ff /* Control */
40
41#ifndef __ASSEMBLY__
42
43/*
44 * This struct defines the way the registers are stored on the
45 * stack during a system call. Note that sizeof(struct pt_regs)
46 * has to be a multiple of 8.
47 */
48struct pt_regs {
49 unsigned long uregs[34];
50};
51
52#define UCreg_asr uregs[32]
53#define UCreg_pc uregs[31]
54#define UCreg_lr uregs[30]
55#define UCreg_sp uregs[29]
56#define UCreg_ip uregs[28]
57#define UCreg_fp uregs[27]
58#define UCreg_26 uregs[26]
59#define UCreg_25 uregs[25]
60#define UCreg_24 uregs[24]
61#define UCreg_23 uregs[23]
62#define UCreg_22 uregs[22]
63#define UCreg_21 uregs[21]
64#define UCreg_20 uregs[20]
65#define UCreg_19 uregs[19]
66#define UCreg_18 uregs[18]
67#define UCreg_17 uregs[17]
68#define UCreg_16 uregs[16]
69#define UCreg_15 uregs[15]
70#define UCreg_14 uregs[14]
71#define UCreg_13 uregs[13]
72#define UCreg_12 uregs[12]
73#define UCreg_11 uregs[11]
74#define UCreg_10 uregs[10]
75#define UCreg_09 uregs[9]
76#define UCreg_08 uregs[8]
77#define UCreg_07 uregs[7]
78#define UCreg_06 uregs[6]
79#define UCreg_05 uregs[5]
80#define UCreg_04 uregs[4]
81#define UCreg_03 uregs[3]
82#define UCreg_02 uregs[2]
83#define UCreg_01 uregs[1]
84#define UCreg_00 uregs[0]
85#define UCreg_ORIG_00 uregs[33]
86
87
88#endif /* __ASSEMBLY__ */
89
90#endif /* _UAPI__UNICORE_PTRACE_H__ */
diff --git a/arch/unicore32/include/uapi/asm/sigcontext.h b/arch/unicore32/include/uapi/asm/sigcontext.h
deleted file mode 100644
index 6a2d7671c05..00000000000
--- a/arch/unicore32/include/uapi/asm/sigcontext.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * linux/arch/unicore32/include/asm/sigcontext.h
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
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 version 2 as
10 * published by the Free Software Foundation.
11 */
12#ifndef __UNICORE_SIGCONTEXT_H__
13#define __UNICORE_SIGCONTEXT_H__
14
15#include <asm/ptrace.h>
16/*
17 * Signal context structure - contains all info to do with the state
18 * before the signal handler was invoked. Note: only add new entries
19 * to the end of the structure.
20 */
21struct sigcontext {
22 unsigned long trap_no;
23 unsigned long error_code;
24 unsigned long oldmask;
25 unsigned long fault_address;
26 struct pt_regs regs;
27};
28
29#endif
diff --git a/arch/unicore32/include/uapi/asm/unistd.h b/arch/unicore32/include/uapi/asm/unistd.h
deleted file mode 100644
index d4cc4559d84..00000000000
--- a/arch/unicore32/include/uapi/asm/unistd.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * linux/arch/unicore32/include/asm/unistd.h
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
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 version 2 as
10 * published by the Free Software Foundation.
11 */
12
13/* Use the standard ABI for syscalls. */
14#include <asm-generic/unistd.h>
15#define __ARCH_WANT_SYS_CLONE
diff --git a/arch/unicore32/kernel/Makefile b/arch/unicore32/kernel/Makefile
index fa497e0efe5..aeb0f181568 100644
--- a/arch/unicore32/kernel/Makefile
+++ b/arch/unicore32/kernel/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_UNICORE_FPU_F64) += fpu-ucf64.o
16obj-$(CONFIG_ARCH_PUV3) += clock.o irq.o time.o 16obj-$(CONFIG_ARCH_PUV3) += clock.o irq.o time.o
17 17
18obj-$(CONFIG_PUV3_GPIO) += gpio.o 18obj-$(CONFIG_PUV3_GPIO) += gpio.o
19obj-$(CONFIG_PUV3_PWM) += pwm.o
19obj-$(CONFIG_PUV3_PM) += pm.o sleep.o 20obj-$(CONFIG_PUV3_PM) += pm.o sleep.o
20obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate_asm.o 21obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate_asm.o
21 22
@@ -28,4 +29,4 @@ obj-$(CONFIG_PUV3_NB0916) += puv3-nb0916.o
28head-y := head.o 29head-y := head.o
29obj-$(CONFIG_DEBUG_LL) += debug.o 30obj-$(CONFIG_DEBUG_LL) += debug.o
30 31
31extra-y := $(head-y) vmlinux.lds 32extra-y := $(head-y) init_task.o vmlinux.lds
diff --git a/arch/unicore32/kernel/dma.c b/arch/unicore32/kernel/dma.c
index ed2d4d78d9c..ae441bc3122 100644
--- a/arch/unicore32/kernel/dma.c
+++ b/arch/unicore32/kernel/dma.c
@@ -18,6 +18,7 @@
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/io.h> 19#include <linux/io.h>
20 20
21#include <asm/system.h>
21#include <asm/irq.h> 22#include <asm/irq.h>
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <mach/dma.h> 24#include <mach/dma.h>
diff --git a/arch/unicore32/kernel/entry.S b/arch/unicore32/kernel/entry.S
index 581630d9144..00a259f9819 100644
--- a/arch/unicore32/kernel/entry.S
+++ b/arch/unicore32/kernel/entry.S
@@ -544,6 +544,8 @@ fast_work_pending:
544work_pending: 544work_pending:
545 cand.a r1, #_TIF_NEED_RESCHED 545 cand.a r1, #_TIF_NEED_RESCHED
546 bne work_resched 546 bne work_resched
547 cand.a r1, #_TIF_SIGPENDING|_TIF_NOTIFY_RESUME
548 beq no_work_pending
547 mov r0, sp @ 'regs' 549 mov r0, sp @ 'regs'
548 mov r2, why @ 'syscall' 550 mov r2, why @ 'syscall'
549 cand.a r1, #_TIF_SIGPENDING @ delivering a signal? 551 cand.a r1, #_TIF_SIGPENDING @ delivering a signal?
@@ -573,16 +575,17 @@ ENDPROC(ret_to_user)
573 */ 575 */
574ENTRY(ret_from_fork) 576ENTRY(ret_from_fork)
575 b.l schedule_tail 577 b.l schedule_tail
578 get_thread_info tsk
579 ldw r1, [tsk+], #TI_FLAGS @ check for syscall tracing
580 mov why, #1
581 cand.a r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
582 beq ret_slow_syscall
583 mov r1, sp
584 mov r0, #1 @ trace exit [IP = 1]
585 b.l syscall_trace
576 b ret_slow_syscall 586 b ret_slow_syscall
577ENDPROC(ret_from_fork) 587ENDPROC(ret_from_fork)
578 588
579ENTRY(ret_from_kernel_thread)
580 b.l schedule_tail
581 mov r0, r5
582 adr lr, ret_slow_syscall
583 mov pc, r4
584ENDPROC(ret_from_kernel_thread)
585
586/*============================================================================= 589/*=============================================================================
587 * SWI handler 590 * SWI handler
588 *----------------------------------------------------------------------------- 591 *-----------------------------------------------------------------------------
@@ -668,6 +671,17 @@ __cr_alignment:
668#endif 671#endif
669 .ltorg 672 .ltorg
670 673
674ENTRY(sys_execve)
675 add r3, sp, #S_OFF
676 b __sys_execve
677ENDPROC(sys_execve)
678
679ENTRY(sys_clone)
680 add ip, sp, #S_OFF
681 stw ip, [sp+], #4
682 b __sys_clone
683ENDPROC(sys_clone)
684
671ENTRY(sys_rt_sigreturn) 685ENTRY(sys_rt_sigreturn)
672 add r0, sp, #S_OFF 686 add r0, sp, #S_OFF
673 mov why, #0 @ prevent syscall restart handling 687 mov why, #0 @ prevent syscall restart handling
diff --git a/arch/unicore32/kernel/head.S b/arch/unicore32/kernel/head.S
index e8f0b98c02e..8caf322e110 100644
--- a/arch/unicore32/kernel/head.S
+++ b/arch/unicore32/kernel/head.S
@@ -17,7 +17,7 @@
17#include <generated/asm-offsets.h> 17#include <generated/asm-offsets.h>
18#include <asm/memory.h> 18#include <asm/memory.h>
19#include <asm/thread_info.h> 19#include <asm/thread_info.h>
20#include <asm/hwdef-copro.h> 20#include <asm/system.h>
21#include <asm/pgtable-hwdef.h> 21#include <asm/pgtable-hwdef.h>
22 22
23#if (PHYS_OFFSET & 0x003fffff) 23#if (PHYS_OFFSET & 0x003fffff)
diff --git a/arch/unicore32/kernel/hibernate.c b/arch/unicore32/kernel/hibernate.c
index d75ef8b6cb5..7d0f0b7983a 100644
--- a/arch/unicore32/kernel/hibernate.c
+++ b/arch/unicore32/kernel/hibernate.c
@@ -15,6 +15,7 @@
15#include <linux/suspend.h> 15#include <linux/suspend.h>
16#include <linux/bootmem.h> 16#include <linux/bootmem.h>
17 17
18#include <asm/system.h>
18#include <asm/page.h> 19#include <asm/page.h>
19#include <asm/pgtable.h> 20#include <asm/pgtable.h>
20#include <asm/pgalloc.h> 21#include <asm/pgalloc.h>
diff --git a/arch/unicore32/kernel/irq.c b/arch/unicore32/kernel/irq.c
index 0be5ccd7ccd..d4efa7d679f 100644
--- a/arch/unicore32/kernel/irq.c
+++ b/arch/unicore32/kernel/irq.c
@@ -26,6 +26,7 @@
26#include <linux/syscore_ops.h> 26#include <linux/syscore_ops.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28 28
29#include <asm/system.h>
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30 31
31#include "setup.h" 32#include "setup.h"
diff --git a/arch/unicore32/kernel/ksyms.c b/arch/unicore32/kernel/ksyms.c
index d285d71cbe3..a8970809428 100644
--- a/arch/unicore32/kernel/ksyms.c
+++ b/arch/unicore32/kernel/ksyms.c
@@ -20,11 +20,12 @@
20#include <linux/io.h> 20#include <linux/io.h>
21 21
22#include <asm/checksum.h> 22#include <asm/checksum.h>
23#include <asm/system.h>
23 24
24#include "ksyms.h" 25#include "ksyms.h"
25 26
26EXPORT_SYMBOL(find_next_zero_bit); 27EXPORT_SYMBOL(__uc32_find_next_zero_bit);
27EXPORT_SYMBOL(find_next_bit); 28EXPORT_SYMBOL(__uc32_find_next_bit);
28 29
29EXPORT_SYMBOL(__backtrace); 30EXPORT_SYMBOL(__backtrace);
30 31
diff --git a/arch/unicore32/kernel/module.c b/arch/unicore32/kernel/module.c
index 16bd1495b93..8fbe8577f5e 100644
--- a/arch/unicore32/kernel/module.c
+++ b/arch/unicore32/kernel/module.c
@@ -27,6 +27,9 @@ void *module_alloc(unsigned long size)
27 struct vm_struct *area; 27 struct vm_struct *area;
28 28
29 size = PAGE_ALIGN(size); 29 size = PAGE_ALIGN(size);
30 if (!size)
31 return NULL;
32
30 area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END); 33 area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END);
31 if (!area) 34 if (!area)
32 return NULL; 35 return NULL;
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index ef69c0c8282..4892fbb54eb 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -21,6 +21,7 @@
21#include <linux/io.h> 21#include <linux/io.h>
22 22
23static int debug_pci; 23static int debug_pci;
24static int use_firmware;
24 25
25#define CONFIG_CMD(bus, devfn, where) \ 26#define CONFIG_CMD(bus, devfn, where) \
26 (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3)) 27 (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
@@ -154,6 +155,14 @@ void __init puv3_pci_adjust_zones(unsigned long *zone_size,
154 zhole_size[0] = 0; 155 zhole_size[0] = 0;
155} 156}
156 157
158void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
159{
160 if (debug_pci)
161 printk(KERN_DEBUG "PCI: Assigning IRQ %02d to %s\n",
162 irq, pci_name(dev));
163 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
164}
165
157/* 166/*
158 * If the bus contains any of these devices, then we must not turn on 167 * If the bus contains any of these devices, then we must not turn on
159 * parity checking of any kind. 168 * parity checking of any kind.
@@ -167,7 +176,7 @@ static inline int pdev_bad_for_parity(struct pci_dev *dev)
167 * pcibios_fixup_bus - Called after each bus is probed, 176 * pcibios_fixup_bus - Called after each bus is probed,
168 * but before its children are examined. 177 * but before its children are examined.
169 */ 178 */
170void pcibios_fixup_bus(struct pci_bus *bus) 179void __devinit pcibios_fixup_bus(struct pci_bus *bus)
171{ 180{
172 struct pci_dev *dev; 181 struct pci_dev *dev;
173 u16 features = PCI_COMMAND_SERR 182 u16 features = PCI_COMMAND_SERR
@@ -250,7 +259,9 @@ void pcibios_fixup_bus(struct pci_bus *bus)
250 printk(KERN_INFO "PCI: bus%d: Fast back to back transfers %sabled\n", 259 printk(KERN_INFO "PCI: bus%d: Fast back to back transfers %sabled\n",
251 bus->number, (features & PCI_COMMAND_FAST_BACK) ? "en" : "dis"); 260 bus->number, (features & PCI_COMMAND_FAST_BACK) ? "en" : "dis");
252} 261}
262#ifdef CONFIG_HOTPLUG
253EXPORT_SYMBOL(pcibios_fixup_bus); 263EXPORT_SYMBOL(pcibios_fixup_bus);
264#endif
254 265
255static int __init pci_common_init(void) 266static int __init pci_common_init(void)
256{ 267{
@@ -265,7 +276,7 @@ static int __init pci_common_init(void)
265 276
266 pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq); 277 pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
267 278
268 if (!pci_has_flag(PCI_PROBE_ONLY)) { 279 if (!use_firmware) {
269 /* 280 /*
270 * Size the bridge windows. 281 * Size the bridge windows.
271 */ 282 */
@@ -286,23 +297,18 @@ static int __init pci_common_init(void)
286} 297}
287subsys_initcall(pci_common_init); 298subsys_initcall(pci_common_init);
288 299
289char * __init pcibios_setup(char *str) 300char * __devinit pcibios_setup(char *str)
290{ 301{
291 if (!strcmp(str, "debug")) { 302 if (!strcmp(str, "debug")) {
292 debug_pci = 1; 303 debug_pci = 1;
293 return NULL; 304 return NULL;
294 } else if (!strcmp(str, "firmware")) { 305 } else if (!strcmp(str, "firmware")) {
295 pci_add_flags(PCI_PROBE_ONLY); 306 use_firmware = 1;
296 return NULL; 307 return NULL;
297 } 308 }
298 return str; 309 return str;
299} 310}
300 311
301void pcibios_set_master(struct pci_dev *dev)
302{
303 /* No special bus mastering setup handling */
304}
305
306/* 312/*
307 * From arch/i386/kernel/pci-i386.c: 313 * From arch/i386/kernel/pci-i386.c:
308 * 314 *
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index 62bad9fed03..ba401df971e 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -34,6 +34,7 @@
34 34
35#include <asm/cacheflush.h> 35#include <asm/cacheflush.h>
36#include <asm/processor.h> 36#include <asm/processor.h>
37#include <asm/system.h>
37#include <asm/stacktrace.h> 38#include <asm/stacktrace.h>
38 39
39#include "setup.h" 40#include "setup.h"
@@ -54,8 +55,7 @@ void cpu_idle(void)
54{ 55{
55 /* endless idle loop with no priority at all */ 56 /* endless idle loop with no priority at all */
56 while (1) { 57 while (1) {
57 tick_nohz_idle_enter(); 58 tick_nohz_stop_sched_tick(1);
58 rcu_idle_enter();
59 while (!need_resched()) { 59 while (!need_resched()) {
60 local_irq_disable(); 60 local_irq_disable();
61 stop_critical_timings(); 61 stop_critical_timings();
@@ -63,8 +63,7 @@ void cpu_idle(void)
63 local_irq_enable(); 63 local_irq_enable();
64 start_critical_timings(); 64 start_critical_timings();
65 } 65 }
66 rcu_idle_exit(); 66 tick_nohz_restart_sched_tick();
67 tick_nohz_idle_exit();
68 preempt_enable_no_resched(); 67 preempt_enable_no_resched();
69 schedule(); 68 schedule();
70 preempt_disable(); 69 preempt_disable();
@@ -258,32 +257,25 @@ void release_thread(struct task_struct *dead_task)
258} 257}
259 258
260asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); 259asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
261asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
262 260
263int 261int
264copy_thread(unsigned long clone_flags, unsigned long stack_start, 262copy_thread(unsigned long clone_flags, unsigned long stack_start,
265 unsigned long stk_sz, struct task_struct *p) 263 unsigned long stk_sz, struct task_struct *p, struct pt_regs *regs)
266{ 264{
267 struct thread_info *thread = task_thread_info(p); 265 struct thread_info *thread = task_thread_info(p);
268 struct pt_regs *childregs = task_pt_regs(p); 266 struct pt_regs *childregs = task_pt_regs(p);
269 267
268 *childregs = *regs;
269 childregs->UCreg_00 = 0;
270 childregs->UCreg_sp = stack_start;
271
270 memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save)); 272 memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save));
271 thread->cpu_context.sp = (unsigned long)childregs; 273 thread->cpu_context.sp = (unsigned long)childregs;
272 if (unlikely(p->flags & PF_KTHREAD)) { 274 thread->cpu_context.pc = (unsigned long)ret_from_fork;
273 thread->cpu_context.pc = (unsigned long)ret_from_kernel_thread; 275
274 thread->cpu_context.r4 = stack_start; 276 if (clone_flags & CLONE_SETTLS)
275 thread->cpu_context.r5 = stk_sz; 277 childregs->UCreg_16 = regs->UCreg_03;
276 memset(childregs, 0, sizeof(struct pt_regs)); 278
277 } else {
278 thread->cpu_context.pc = (unsigned long)ret_from_fork;
279 *childregs = *current_pt_regs();
280 childregs->UCreg_00 = 0;
281 if (stack_start)
282 childregs->UCreg_sp = stack_start;
283
284 if (clone_flags & CLONE_SETTLS)
285 childregs->UCreg_16 = childregs->UCreg_03;
286 }
287 return 0; 279 return 0;
288} 280}
289 281
@@ -312,6 +304,42 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fp)
312} 304}
313EXPORT_SYMBOL(dump_fpu); 305EXPORT_SYMBOL(dump_fpu);
314 306
307/*
308 * Shuffle the argument into the correct register before calling the
309 * thread function. r1 is the thread argument, r2 is the pointer to
310 * the thread function, and r3 points to the exit function.
311 */
312asm(".pushsection .text\n"
313" .align\n"
314" .type kernel_thread_helper, #function\n"
315"kernel_thread_helper:\n"
316" mov.a asr, r7\n"
317" mov r0, r4\n"
318" mov lr, r6\n"
319" mov pc, r5\n"
320" .size kernel_thread_helper, . - kernel_thread_helper\n"
321" .popsection");
322
323/*
324 * Create a kernel thread.
325 */
326pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
327{
328 struct pt_regs regs;
329
330 memset(&regs, 0, sizeof(regs));
331
332 regs.UCreg_04 = (unsigned long)arg;
333 regs.UCreg_05 = (unsigned long)fn;
334 regs.UCreg_06 = (unsigned long)do_exit;
335 regs.UCreg_07 = PRIV_MODE;
336 regs.UCreg_pc = (unsigned long)kernel_thread_helper;
337 regs.UCreg_asr = regs.UCreg_07 | PSR_I_BIT;
338
339 return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
340}
341EXPORT_SYMBOL(kernel_thread);
342
315unsigned long get_wchan(struct task_struct *p) 343unsigned long get_wchan(struct task_struct *p)
316{ 344{
317 struct stackframe frame; 345 struct stackframe frame;
@@ -351,7 +379,7 @@ int vectors_user_mapping(void)
351 return install_special_mapping(mm, 0xffff0000, PAGE_SIZE, 379 return install_special_mapping(mm, 0xffff0000, PAGE_SIZE,
352 VM_READ | VM_EXEC | 380 VM_READ | VM_EXEC |
353 VM_MAYREAD | VM_MAYEXEC | 381 VM_MAYREAD | VM_MAYEXEC |
354 VM_DONTEXPAND | VM_DONTDUMP, 382 VM_ALWAYSDUMP | VM_RESERVED,
355 NULL); 383 NULL);
356} 384}
357 385
diff --git a/arch/unicore32/kernel/puv3-core.c b/arch/unicore32/kernel/puv3-core.c
index 254adeecc61..1a505a78776 100644
--- a/arch/unicore32/kernel/puv3-core.c
+++ b/arch/unicore32/kernel/puv3-core.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/sysdev.h>
16#include <linux/amba/bus.h> 17#include <linux/amba/bus.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/io.h> 19#include <linux/io.h>
diff --git a/arch/unicore32/kernel/puv3-nb0916.c b/arch/unicore32/kernel/puv3-nb0916.c
index 181108b8ecc..e731c561ed4 100644
--- a/arch/unicore32/kernel/puv3-nb0916.c
+++ b/arch/unicore32/kernel/puv3-nb0916.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/sysdev.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/mtd/physmap.h> 18#include <linux/mtd/physmap.h>
18#include <linux/io.h> 19#include <linux/io.h>
@@ -123,7 +124,7 @@ int __init mach_nb0916_init(void)
123 124
124 if (request_irq(gpio_to_irq(GPI_LCD_CASE_OFF), 125 if (request_irq(gpio_to_irq(GPI_LCD_CASE_OFF),
125 &nb0916_lcdcaseoff_handler, 126 &nb0916_lcdcaseoff_handler,
126 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 127 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
127 "NB0916 lcd case off", NULL) < 0) { 128 "NB0916 lcd case off", NULL) < 0) {
128 129
129 printk(KERN_DEBUG "LCD-Case-OFF IRQ %d not available\n", 130 printk(KERN_DEBUG "LCD-Case-OFF IRQ %d not available\n",
@@ -131,7 +132,7 @@ int __init mach_nb0916_init(void)
131 } 132 }
132 133
133 if (request_irq(gpio_to_irq(GPI_OTP_INT), &nb0916_overheat_handler, 134 if (request_irq(gpio_to_irq(GPI_OTP_INT), &nb0916_overheat_handler,
134 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 135 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
135 "NB0916 overheating protection", NULL) < 0) { 136 "NB0916 overheating protection", NULL) < 0) {
136 137
137 printk(KERN_DEBUG "Overheating Protection IRQ %d not available\n", 138 printk(KERN_DEBUG "Overheating Protection IRQ %d not available\n",
diff --git a/arch/unicore32/kernel/setup.c b/arch/unicore32/kernel/setup.c
index 87adbf5ebfe..471b6bca8da 100644
--- a/arch/unicore32/kernel/setup.c
+++ b/arch/unicore32/kernel/setup.c
@@ -37,7 +37,6 @@
37#include <asm/cacheflush.h> 37#include <asm/cacheflush.h>
38#include <asm/tlbflush.h> 38#include <asm/tlbflush.h>
39#include <asm/traps.h> 39#include <asm/traps.h>
40#include <asm/memblock.h>
41 40
42#include "setup.h" 41#include "setup.h"
43 42
@@ -65,7 +64,7 @@ static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
65 */ 64 */
66static struct resource mem_res[] = { 65static struct resource mem_res[] = {
67 { 66 {
68 .name = "Kernel code", 67 .name = "Kernel text",
69 .start = 0, 68 .start = 0,
70 .end = 0, 69 .end = 0,
71 .flags = IORESOURCE_MEM 70 .flags = IORESOURCE_MEM
diff --git a/arch/unicore32/kernel/setup.h b/arch/unicore32/kernel/setup.h
index 30f749da8f7..dcd1306eb5c 100644
--- a/arch/unicore32/kernel/setup.h
+++ b/arch/unicore32/kernel/setup.h
@@ -12,11 +12,8 @@
12#ifndef __UNICORE_KERNEL_SETUP_H__ 12#ifndef __UNICORE_KERNEL_SETUP_H__
13#define __UNICORE_KERNEL_SETUP_H__ 13#define __UNICORE_KERNEL_SETUP_H__
14 14
15#include <asm/hwdef-copro.h>
16
17extern void paging_init(void); 15extern void paging_init(void);
18extern void puv3_core_init(void); 16extern void puv3_core_init(void);
19extern void cpu_init(void);
20 17
21extern void puv3_ps2_init(void); 18extern void puv3_ps2_init(void);
22extern void pci_puv3_preinit(void); 19extern void pci_puv3_preinit(void);
@@ -30,10 +27,4 @@ extern char __vectors_start[], __vectors_end[];
30extern void kernel_thread_helper(void); 27extern void kernel_thread_helper(void);
31 28
32extern void __init early_signal_init(void); 29extern void __init early_signal_init(void);
33
34extern asmlinkage void __backtrace(void);
35extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
36
37extern void __show_regs(struct pt_regs *);
38
39#endif 30#endif
diff --git a/arch/unicore32/kernel/signal.c b/arch/unicore32/kernel/signal.c
index b8b2ffd774d..b163fca5678 100644
--- a/arch/unicore32/kernel/signal.c
+++ b/arch/unicore32/kernel/signal.c
@@ -12,6 +12,7 @@
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/signal.h> 13#include <linux/signal.h>
14#include <linux/personality.h> 14#include <linux/personality.h>
15#include <linux/freezer.h>
15#include <linux/uaccess.h> 16#include <linux/uaccess.h>
16#include <linux/tracehook.h> 17#include <linux/tracehook.h>
17#include <linux/elf.h> 18#include <linux/elf.h>
@@ -20,6 +21,8 @@
20#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
21#include <asm/ucontext.h> 22#include <asm/ucontext.h>
22 23
24#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
25
23/* 26/*
24 * For UniCore syscalls, we encode the syscall number into the instruction. 27 * For UniCore syscalls, we encode the syscall number into the instruction.
25 */ 28 */
@@ -58,8 +61,13 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
58 int err; 61 int err;
59 62
60 err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); 63 err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
61 if (err == 0) 64 if (err == 0) {
62 set_current_blocked(&set); 65 sigdelsetmask(&set, ~_BLOCKABLE);
66 spin_lock_irq(&current->sighand->siglock);
67 current->blocked = set;
68 recalc_sigpending();
69 spin_unlock_irq(&current->sighand->siglock);
70 }
63 71
64 err |= __get_user(regs->UCreg_00, &sf->uc.uc_mcontext.regs.UCreg_00); 72 err |= __get_user(regs->UCreg_00, &sf->uc.uc_mcontext.regs.UCreg_00);
65 err |= __get_user(regs->UCreg_01, &sf->uc.uc_mcontext.regs.UCreg_01); 73 err |= __get_user(regs->UCreg_01, &sf->uc.uc_mcontext.regs.UCreg_01);
@@ -307,12 +315,12 @@ static inline void setup_syscall_restart(struct pt_regs *regs)
307/* 315/*
308 * OK, we're invoking a handler 316 * OK, we're invoking a handler
309 */ 317 */
310static void handle_signal(unsigned long sig, struct k_sigaction *ka, 318static int handle_signal(unsigned long sig, struct k_sigaction *ka,
311 siginfo_t *info, struct pt_regs *regs, int syscall) 319 siginfo_t *info, sigset_t *oldset,
320 struct pt_regs *regs, int syscall)
312{ 321{
313 struct thread_info *thread = current_thread_info(); 322 struct thread_info *thread = current_thread_info();
314 struct task_struct *tsk = current; 323 struct task_struct *tsk = current;
315 sigset_t *oldset = sigmask_to_save();
316 int usig = sig; 324 int usig = sig;
317 int ret; 325 int ret;
318 326
@@ -358,10 +366,21 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
358 366
359 if (ret != 0) { 367 if (ret != 0) {
360 force_sigsegv(sig, tsk); 368 force_sigsegv(sig, tsk);
361 return; 369 return ret;
362 } 370 }
363 371
364 signal_delivered(sig, info, ka, regs, 0); 372 /*
373 * Block the signal if we were successful.
374 */
375 spin_lock_irq(&tsk->sighand->siglock);
376 sigorsets(&tsk->blocked, &tsk->blocked,
377 &ka->sa.sa_mask);
378 if (!(ka->sa.sa_flags & SA_NODEFER))
379 sigaddset(&tsk->blocked, sig);
380 recalc_sigpending();
381 spin_unlock_irq(&tsk->sighand->siglock);
382
383 return 0;
365} 384}
366 385
367/* 386/*
@@ -388,12 +407,32 @@ static void do_signal(struct pt_regs *regs, int syscall)
388 if (!user_mode(regs)) 407 if (!user_mode(regs))
389 return; 408 return;
390 409
410 if (try_to_freeze())
411 goto no_signal;
412
391 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 413 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
392 if (signr > 0) { 414 if (signr > 0) {
393 handle_signal(signr, &ka, &info, regs, syscall); 415 sigset_t *oldset;
416
417 if (test_thread_flag(TIF_RESTORE_SIGMASK))
418 oldset = &current->saved_sigmask;
419 else
420 oldset = &current->blocked;
421 if (handle_signal(signr, &ka, &info, oldset, regs, syscall)
422 == 0) {
423 /*
424 * A signal was successfully delivered; the saved
425 * sigmask will have been stored in the signal frame,
426 * and will be restored by sigreturn, so we can simply
427 * clear the TIF_RESTORE_SIGMASK flag.
428 */
429 if (test_thread_flag(TIF_RESTORE_SIGMASK))
430 clear_thread_flag(TIF_RESTORE_SIGMASK);
431 }
394 return; 432 return;
395 } 433 }
396 434
435 no_signal:
397 /* 436 /*
398 * No signal to deliver to the process - restart the syscall. 437 * No signal to deliver to the process - restart the syscall.
399 */ 438 */
@@ -416,11 +455,15 @@ static void do_signal(struct pt_regs *regs, int syscall)
416 regs->UCreg_00 == -ERESTARTNOINTR) { 455 regs->UCreg_00 == -ERESTARTNOINTR) {
417 setup_syscall_restart(regs); 456 setup_syscall_restart(regs);
418 } 457 }
458
459 /* If there's no signal to deliver, we just put the saved
460 * sigmask back.
461 */
462 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
463 clear_thread_flag(TIF_RESTORE_SIGMASK);
464 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
465 }
419 } 466 }
420 /* If there's no signal to deliver, we just put the saved
421 * sigmask back.
422 */
423 restore_saved_sigmask();
424} 467}
425 468
426asmlinkage void do_notify_resume(struct pt_regs *regs, 469asmlinkage void do_notify_resume(struct pt_regs *regs,
@@ -432,6 +475,8 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
432 if (thread_flags & _TIF_NOTIFY_RESUME) { 475 if (thread_flags & _TIF_NOTIFY_RESUME) {
433 clear_thread_flag(TIF_NOTIFY_RESUME); 476 clear_thread_flag(TIF_NOTIFY_RESUME);
434 tracehook_notify_resume(regs); 477 tracehook_notify_resume(regs);
478 if (current->replacement_session_keyring)
479 key_replace_session_keyring();
435 } 480 }
436} 481}
437 482
diff --git a/arch/unicore32/kernel/sys.c b/arch/unicore32/kernel/sys.c
index cfe79c9529b..3afe60a39ac 100644
--- a/arch/unicore32/kernel/sys.c
+++ b/arch/unicore32/kernel/sys.c
@@ -28,6 +28,84 @@
28#include <asm/syscalls.h> 28#include <asm/syscalls.h>
29#include <asm/cacheflush.h> 29#include <asm/cacheflush.h>
30 30
31/* Clone a task - this clones the calling program thread.
32 * This is called indirectly via a small wrapper
33 */
34asmlinkage long __sys_clone(unsigned long clone_flags, unsigned long newsp,
35 void __user *parent_tid, void __user *child_tid,
36 struct pt_regs *regs)
37{
38 if (!newsp)
39 newsp = regs->UCreg_sp;
40
41 return do_fork(clone_flags, newsp, regs, 0,
42 parent_tid, child_tid);
43}
44
45/* sys_execve() executes a new program.
46 * This is called indirectly via a small wrapper
47 */
48asmlinkage long __sys_execve(const char __user *filename,
49 const char __user *const __user *argv,
50 const char __user *const __user *envp,
51 struct pt_regs *regs)
52{
53 int error;
54 char *fn;
55
56 fn = getname(filename);
57 error = PTR_ERR(fn);
58 if (IS_ERR(fn))
59 goto out;
60 error = do_execve(fn, argv, envp, regs);
61 putname(fn);
62out:
63 return error;
64}
65
66int kernel_execve(const char *filename,
67 const char *const argv[],
68 const char *const envp[])
69{
70 struct pt_regs regs;
71 int ret;
72
73 memset(&regs, 0, sizeof(struct pt_regs));
74 ret = do_execve(filename,
75 (const char __user *const __user *)argv,
76 (const char __user *const __user *)envp, &regs);
77 if (ret < 0)
78 goto out;
79
80 /*
81 * Save argc to the register structure for userspace.
82 */
83 regs.UCreg_00 = ret;
84
85 /*
86 * We were successful. We won't be returning to our caller, but
87 * instead to user space by manipulating the kernel stack.
88 */
89 asm("add r0, %0, %1\n\t"
90 "mov r1, %2\n\t"
91 "mov r2, %3\n\t"
92 "mov r22, #0\n\t" /* not a syscall */
93 "mov r23, %0\n\t" /* thread structure */
94 "b.l memmove\n\t" /* copy regs to top of stack */
95 "mov sp, r0\n\t" /* reposition stack pointer */
96 "b ret_to_user"
97 :
98 : "r" (current_thread_info()),
99 "Ir" (THREAD_START_SP - sizeof(regs)),
100 "r" (&regs),
101 "Ir" (sizeof(regs))
102 : "r0", "r1", "r2", "r3", "ip", "lr", "memory");
103
104 out:
105 return ret;
106}
107EXPORT_SYMBOL(kernel_execve);
108
31/* Note: used by the compat code even in 64-bit Linux. */ 109/* Note: used by the compat code even in 64-bit Linux. */
32SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, 110SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
33 unsigned long, prot, unsigned long, flags, 111 unsigned long, prot, unsigned long, flags,
diff --git a/arch/unicore32/kernel/time.c b/arch/unicore32/kernel/time.c
index d3824b2ff64..080710c0924 100644
--- a/arch/unicore32/kernel/time.c
+++ b/arch/unicore32/kernel/time.c
@@ -86,7 +86,7 @@ static struct clocksource cksrc_puv3_oscr = {
86 86
87static struct irqaction puv3_timer_irq = { 87static struct irqaction puv3_timer_irq = {
88 .name = "ost0", 88 .name = "ost0",
89 .flags = IRQF_TIMER | IRQF_IRQPOLL, 89 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
90 .handler = puv3_ost0_interrupt, 90 .handler = puv3_ost0_interrupt,
91 .dev_id = &ckevt_puv3_osmr0, 91 .dev_id = &ckevt_puv3_osmr0,
92}; 92};
diff --git a/arch/unicore32/kernel/traps.c b/arch/unicore32/kernel/traps.c
index 2054f0d4db1..b9a26465e72 100644
--- a/arch/unicore32/kernel/traps.c
+++ b/arch/unicore32/kernel/traps.c
@@ -26,6 +26,7 @@
26#include <linux/unistd.h> 26#include <linux/unistd.h>
27 27
28#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
29#include <asm/system.h>
29#include <asm/traps.h> 30#include <asm/traps.h>
30 31
31#include "setup.h" 32#include "setup.h"
diff --git a/arch/unicore32/lib/findbit.S b/arch/unicore32/lib/findbit.S
index c77746247d3..c360ce905d8 100644
--- a/arch/unicore32/lib/findbit.S
+++ b/arch/unicore32/lib/findbit.S
@@ -17,7 +17,7 @@
17 * Purpose : Find a 'zero' bit 17 * Purpose : Find a 'zero' bit
18 * Prototype: int find_first_zero_bit(void *addr, unsigned int maxbit); 18 * Prototype: int find_first_zero_bit(void *addr, unsigned int maxbit);
19 */ 19 */
20ENTRY(find_first_zero_bit) 20__uc32_find_first_zero_bit:
21 cxor.a r1, #0 21 cxor.a r1, #0
22 beq 3f 22 beq 3f
23 mov r2, #0 23 mov r2, #0
@@ -29,14 +29,13 @@ ENTRY(find_first_zero_bit)
29 bub 1b 29 bub 1b
303: mov r0, r1 @ no free bits 303: mov r0, r1 @ no free bits
31 mov pc, lr 31 mov pc, lr
32ENDPROC(find_first_zero_bit)
33 32
34/* 33/*
35 * Purpose : Find next 'zero' bit 34 * Purpose : Find next 'zero' bit
36 * Prototype: int find_next_zero_bit 35 * Prototype: int find_next_zero_bit
37 * (void *addr, unsigned int maxbit, int offset) 36 * (void *addr, unsigned int maxbit, int offset)
38 */ 37 */
39ENTRY(find_next_zero_bit) 38ENTRY(__uc32_find_next_zero_bit)
40 cxor.a r1, #0 39 cxor.a r1, #0
41 beq 3b 40 beq 3b
42 and.a ip, r2, #7 41 and.a ip, r2, #7
@@ -48,14 +47,14 @@ ENTRY(find_next_zero_bit)
48 or r2, r2, #7 @ if zero, then no bits here 47 or r2, r2, #7 @ if zero, then no bits here
49 add r2, r2, #1 @ align bit pointer 48 add r2, r2, #1 @ align bit pointer
50 b 2b @ loop for next bit 49 b 2b @ loop for next bit
51ENDPROC(find_next_zero_bit) 50ENDPROC(__uc32_find_next_zero_bit)
52 51
53/* 52/*
54 * Purpose : Find a 'one' bit 53 * Purpose : Find a 'one' bit
55 * Prototype: int find_first_bit 54 * Prototype: int find_first_bit
56 * (const unsigned long *addr, unsigned int maxbit); 55 * (const unsigned long *addr, unsigned int maxbit);
57 */ 56 */
58ENTRY(find_first_bit) 57__uc32_find_first_bit:
59 cxor.a r1, #0 58 cxor.a r1, #0
60 beq 3f 59 beq 3f
61 mov r2, #0 60 mov r2, #0
@@ -67,14 +66,13 @@ ENTRY(find_first_bit)
67 bub 1b 66 bub 1b
683: mov r0, r1 @ no free bits 673: mov r0, r1 @ no free bits
69 mov pc, lr 68 mov pc, lr
70ENDPROC(find_first_bit)
71 69
72/* 70/*
73 * Purpose : Find next 'one' bit 71 * Purpose : Find next 'one' bit
74 * Prototype: int find_next_zero_bit 72 * Prototype: int find_next_zero_bit
75 * (void *addr, unsigned int maxbit, int offset) 73 * (void *addr, unsigned int maxbit, int offset)
76 */ 74 */
77ENTRY(find_next_bit) 75ENTRY(__uc32_find_next_bit)
78 cxor.a r1, #0 76 cxor.a r1, #0
79 beq 3b 77 beq 3b
80 and.a ip, r2, #7 78 and.a ip, r2, #7
@@ -85,7 +83,7 @@ ENTRY(find_next_bit)
85 or r2, r2, #7 @ if zero, then no bits here 83 or r2, r2, #7 @ if zero, then no bits here
86 add r2, r2, #1 @ align bit pointer 84 add r2, r2, #1 @ align bit pointer
87 b 2b @ loop for next bit 85 b 2b @ loop for next bit
88ENDPROC(find_next_bit) 86ENDPROC(__uc32_find_next_bit)
89 87
90/* 88/*
91 * One or more bits in the LSB of r3 are assumed to be set. 89 * One or more bits in the LSB of r3 are assumed to be set.
diff --git a/arch/unicore32/mm/alignment.c b/arch/unicore32/mm/alignment.c
index de7dc5fdd58..28f576d733e 100644
--- a/arch/unicore32/mm/alignment.c
+++ b/arch/unicore32/mm/alignment.c
@@ -24,8 +24,6 @@
24#include <asm/tlbflush.h> 24#include <asm/tlbflush.h>
25#include <asm/unaligned.h> 25#include <asm/unaligned.h>
26 26
27#include "mm.h"
28
29#define CODING_BITS(i) (i & 0xe0000120) 27#define CODING_BITS(i) (i & 0xe0000120)
30 28
31#define LDST_P_BIT(i) (i & (1 << 28)) /* Preindex */ 29#define LDST_P_BIT(i) (i & (1 << 28)) /* Preindex */
diff --git a/arch/unicore32/mm/dma-swiotlb.c b/arch/unicore32/mm/dma-swiotlb.c
index 16c08b2143a..bfa9fbb2bbb 100644
--- a/arch/unicore32/mm/dma-swiotlb.c
+++ b/arch/unicore32/mm/dma-swiotlb.c
@@ -17,23 +17,9 @@
17 17
18#include <asm/dma.h> 18#include <asm/dma.h>
19 19
20static void *unicore_swiotlb_alloc_coherent(struct device *dev, size_t size,
21 dma_addr_t *dma_handle, gfp_t flags,
22 struct dma_attrs *attrs)
23{
24 return swiotlb_alloc_coherent(dev, size, dma_handle, flags);
25}
26
27static void unicore_swiotlb_free_coherent(struct device *dev, size_t size,
28 void *vaddr, dma_addr_t dma_addr,
29 struct dma_attrs *attrs)
30{
31 swiotlb_free_coherent(dev, size, vaddr, dma_addr);
32}
33
34struct dma_map_ops swiotlb_dma_map_ops = { 20struct dma_map_ops swiotlb_dma_map_ops = {
35 .alloc = unicore_swiotlb_alloc_coherent, 21 .alloc_coherent = swiotlb_alloc_coherent,
36 .free = unicore_swiotlb_free_coherent, 22 .free_coherent = swiotlb_free_coherent,
37 .map_sg = swiotlb_map_sg_attrs, 23 .map_sg = swiotlb_map_sg_attrs,
38 .unmap_sg = swiotlb_unmap_sg_attrs, 24 .unmap_sg = swiotlb_unmap_sg_attrs,
39 .dma_supported = swiotlb_dma_supported, 25 .dma_supported = swiotlb_dma_supported,
diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
index f9b5c10bcce..283aa4b50b7 100644
--- a/arch/unicore32/mm/fault.c
+++ b/arch/unicore32/mm/fault.c
@@ -20,6 +20,7 @@
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/io.h> 21#include <linux/io.h>
22 22
23#include <asm/system.h>
23#include <asm/pgtable.h> 24#include <asm/pgtable.h>
24#include <asm/tlbflush.h> 25#include <asm/tlbflush.h>
25 26
@@ -168,7 +169,7 @@ static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
168} 169}
169 170
170static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr, 171static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
171 unsigned int flags, struct task_struct *tsk) 172 struct task_struct *tsk)
172{ 173{
173 struct vm_area_struct *vma; 174 struct vm_area_struct *vma;
174 int fault; 175 int fault;
@@ -194,7 +195,14 @@ good_area:
194 * If for any reason at all we couldn't handle the fault, make 195 * If for any reason at all we couldn't handle the fault, make
195 * sure we exit gracefully rather than endlessly redo the fault. 196 * sure we exit gracefully rather than endlessly redo the fault.
196 */ 197 */
197 fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, flags); 198 fault = handle_mm_fault(mm, vma, addr & PAGE_MASK,
199 (!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
200 if (unlikely(fault & VM_FAULT_ERROR))
201 return fault;
202 if (fault & VM_FAULT_MAJOR)
203 tsk->maj_flt++;
204 else
205 tsk->min_flt++;
198 return fault; 206 return fault;
199 207
200check_stack: 208check_stack:
@@ -209,8 +217,6 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
209 struct task_struct *tsk; 217 struct task_struct *tsk;
210 struct mm_struct *mm; 218 struct mm_struct *mm;
211 int fault, sig, code; 219 int fault, sig, code;
212 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
213 ((!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
214 220
215 tsk = current; 221 tsk = current;
216 mm = tsk->mm; 222 mm = tsk->mm;
@@ -231,7 +237,6 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
231 if (!user_mode(regs) 237 if (!user_mode(regs)
232 && !search_exception_tables(regs->UCreg_pc)) 238 && !search_exception_tables(regs->UCreg_pc))
233 goto no_context; 239 goto no_context;
234retry:
235 down_read(&mm->mmap_sem); 240 down_read(&mm->mmap_sem);
236 } else { 241 } else {
237 /* 242 /*
@@ -247,28 +252,7 @@ retry:
247#endif 252#endif
248 } 253 }
249 254
250 fault = __do_pf(mm, addr, fsr, flags, tsk); 255 fault = __do_pf(mm, addr, fsr, tsk);
251
252 /* If we need to retry but a fatal signal is pending, handle the
253 * signal first. We do not need to release the mmap_sem because
254 * it would already be released in __lock_page_or_retry in
255 * mm/filemap.c. */
256 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
257 return 0;
258
259 if (!(fault & VM_FAULT_ERROR) && (flags & FAULT_FLAG_ALLOW_RETRY)) {
260 if (fault & VM_FAULT_MAJOR)
261 tsk->maj_flt++;
262 else
263 tsk->min_flt++;
264 if (fault & VM_FAULT_RETRY) {
265 /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
266 * of starvation. */
267 flags &= ~FAULT_FLAG_ALLOW_RETRY;
268 goto retry;
269 }
270 }
271
272 up_read(&mm->mmap_sem); 256 up_read(&mm->mmap_sem);
273 257
274 /* 258 /*
diff --git a/arch/unicore32/mm/flush.c b/arch/unicore32/mm/flush.c
index 6d4c096ffa2..93478cc8b26 100644
--- a/arch/unicore32/mm/flush.c
+++ b/arch/unicore32/mm/flush.c
@@ -14,6 +14,7 @@
14#include <linux/pagemap.h> 14#include <linux/pagemap.h>
15 15
16#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
17#include <asm/system.h>
17#include <asm/tlbflush.h> 18#include <asm/tlbflush.h>
18 19
19void flush_cache_mm(struct mm_struct *mm) 20void flush_cache_mm(struct mm_struct *mm)
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index de186bde897..2d3e7112d2a 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -20,13 +20,11 @@
20#include <linux/memblock.h> 20#include <linux/memblock.h>
21#include <linux/sort.h> 21#include <linux/sort.h>
22#include <linux/dma-mapping.h> 22#include <linux/dma-mapping.h>
23#include <linux/export.h>
24 23
25#include <asm/sections.h> 24#include <asm/sections.h>
26#include <asm/setup.h> 25#include <asm/setup.h>
27#include <asm/sizes.h> 26#include <asm/sizes.h>
28#include <asm/tlb.h> 27#include <asm/tlb.h>
29#include <asm/memblock.h>
30#include <mach/map.h> 28#include <mach/map.h>
31 29
32#include "mm.h" 30#include "mm.h"
@@ -246,6 +244,7 @@ void __init uc32_memblock_init(struct meminfo *mi)
246 sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), 244 sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]),
247 meminfo_cmp, NULL); 245 meminfo_cmp, NULL);
248 246
247 memblock_init();
249 for (i = 0; i < mi->nr_banks; i++) 248 for (i = 0; i < mi->nr_banks; i++)
250 memblock_add(mi->bank[i].start, mi->bank[i].size); 249 memblock_add(mi->bank[i].start, mi->bank[i].size);
251 250
@@ -264,7 +263,7 @@ void __init uc32_memblock_init(struct meminfo *mi)
264 263
265 uc32_mm_memblock_reserve(); 264 uc32_mm_memblock_reserve();
266 265
267 memblock_allow_resize(); 266 memblock_analyze();
268 memblock_dump_all(); 267 memblock_dump_all();
269} 268}
270 269
diff --git a/arch/unicore32/mm/mm.h b/arch/unicore32/mm/mm.h
index 05c7f532eee..3296bca0f1f 100644
--- a/arch/unicore32/mm/mm.h
+++ b/arch/unicore32/mm/mm.h
@@ -9,8 +9,6 @@
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12#include <asm/hwdef-copro.h>
13
14/* the upper-most page table pointer */ 12/* the upper-most page table pointer */
15extern pmd_t *top_pmd; 13extern pmd_t *top_pmd;
16extern int sysctl_overcommit_memory; 14extern int sysctl_overcommit_memory;
@@ -36,9 +34,6 @@ struct mem_type {
36const struct mem_type *get_mem_type(unsigned int type); 34const struct mem_type *get_mem_type(unsigned int type);
37 35
38extern void __flush_dcache_page(struct address_space *, struct page *); 36extern void __flush_dcache_page(struct address_space *, struct page *);
39extern void hook_fault_code(int nr, int (*fn)
40 (unsigned long, unsigned int, struct pt_regs *),
41 int sig, int code, const char *name);
42 37
43void __init bootmem_init(void); 38void __init bootmem_init(void);
44void uc32_mm_memblock_reserve(void); 39void uc32_mm_memblock_reserve(void);
diff --git a/arch/unicore32/mm/mmu.c b/arch/unicore32/mm/mmu.c
index 43c20b40e44..3e5c3e5a0b4 100644
--- a/arch/unicore32/mm/mmu.c
+++ b/arch/unicore32/mm/mmu.c
@@ -25,7 +25,6 @@
25#include <asm/setup.h> 25#include <asm/setup.h>
26#include <asm/sizes.h> 26#include <asm/sizes.h>
27#include <asm/tlb.h> 27#include <asm/tlb.h>
28#include <asm/memblock.h>
29 28
30#include <mach/map.h> 29#include <mach/map.h>
31 30