From 7dc59bdde7063323b6a70c2f0fadb399ede8038d Mon Sep 17 00:00:00 2001 From: GuanXuetao Date: Tue, 22 Feb 2011 19:06:43 +0800 Subject: asm-generic: fix inX/outX functions for architectures that have PCI The definitions for the PC-style PIO functions in asm-generic/io.h were meant as dummies so you could compile code on architectures without ISA and PCI buses. However, unicore32 actually wants to use them with a real PCI bus, so they need to be defined to actually address the register window holding the I/O ports. Signed-off-by: Arnd Bergmann --- include/asm-generic/io.h | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'include/asm-generic') diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 4644c9a7f72..e0ffa3ddb02 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -94,6 +94,10 @@ static inline void __raw_writeq(u64 b, volatile void __iomem *addr) #define writeq(b,addr) __raw_writeq(__cpu_to_le64(b),addr) #endif +#ifndef PCI_IOBASE +#define PCI_IOBASE ((void __iomem *) 0) +#endif + /*****************************************************************************/ /* * traditional input/output functions @@ -101,32 +105,32 @@ static inline void __raw_writeq(u64 b, volatile void __iomem *addr) static inline u8 inb(unsigned long addr) { - return readb((volatile void __iomem *) addr); + return readb(addr + PCI_IOBASE); } static inline u16 inw(unsigned long addr) { - return readw((volatile void __iomem *) addr); + return readw(addr + PCI_IOBASE); } static inline u32 inl(unsigned long addr) { - return readl((volatile void __iomem *) addr); + return readl(addr + PCI_IOBASE); } static inline void outb(u8 b, unsigned long addr) { - writeb(b, (volatile void __iomem *) addr); + writeb(b, addr + PCI_IOBASE); } static inline void outw(u16 b, unsigned long addr) { - writew(b, (volatile void __iomem *) addr); + writew(b, addr + PCI_IOBASE); } static inline void outl(u32 b, unsigned long addr) { - writel(b, (volatile void __iomem *) addr); + writel(b, addr + PCI_IOBASE); } #define inb_p(addr) inb(addr) @@ -213,32 +217,32 @@ static inline void outsl(unsigned long addr, const void *buffer, int count) static inline void readsl(const void __iomem *addr, void *buf, int len) { - insl((unsigned long)addr, buf, len); + insl(addr - PCI_IOBASE, buf, len); } static inline void readsw(const void __iomem *addr, void *buf, int len) { - insw((unsigned long)addr, buf, len); + insw(addr - PCI_IOBASE, buf, len); } static inline void readsb(const void __iomem *addr, void *buf, int len) { - insb((unsigned long)addr, buf, len); + insb(addr - PCI_IOBASE, buf, len); } static inline void writesl(const void __iomem *addr, const void *buf, int len) { - outsl((unsigned long)addr, buf, len); + outsl(addr - PCI_IOBASE, buf, len); } static inline void writesw(const void __iomem *addr, const void *buf, int len) { - outsw((unsigned long)addr, buf, len); + outsw(addr - PCI_IOBASE, buf, len); } static inline void writesb(const void __iomem *addr, const void *buf, int len) { - outsb((unsigned long)addr, buf, len); + outsb(addr - PCI_IOBASE, buf, len); } #ifndef CONFIG_GENERIC_IOMAP @@ -269,8 +273,9 @@ static inline void writesb(const void __iomem *addr, const void *buf, int len) outsl((unsigned long) (p), (src), (count)) #endif /* CONFIG_GENERIC_IOMAP */ - -#define IO_SPACE_LIMIT 0xffffffff +#ifndef IO_SPACE_LIMIT +#define IO_SPACE_LIMIT 0xffff +#endif #ifdef __KERNEL__ -- cgit v1.2.3 From d232b128e28f54cd8811dd4f6d8b72ffb12cc0a1 Mon Sep 17 00:00:00 2001 From: GuanXuetao Date: Sat, 15 Jan 2011 18:06:44 +0800 Subject: asm-generic headers: add sizes.h This patch adds sizes.h into asm-generic headers. Only 32-bit version supported. Signed-off-by: Guan Xuetao Acked-by: Arnd Bergmann --- include/asm-generic/sizes.h | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 include/asm-generic/sizes.h (limited to 'include/asm-generic') diff --git a/include/asm-generic/sizes.h b/include/asm-generic/sizes.h new file mode 100644 index 00000000000..ea5d4ef8106 --- /dev/null +++ b/include/asm-generic/sizes.h @@ -0,0 +1,47 @@ +/* + * linux/include/asm-generic/sizes.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_GENERIC_SIZES_H__ +#define __ASM_GENERIC_SIZES_H__ + +#define SZ_1 0x00000001 +#define SZ_2 0x00000002 +#define SZ_4 0x00000004 +#define SZ_8 0x00000008 +#define SZ_16 0x00000010 +#define SZ_32 0x00000020 +#define SZ_64 0x00000040 +#define SZ_128 0x00000080 +#define SZ_256 0x00000100 +#define SZ_512 0x00000200 + +#define SZ_1K 0x00000400 +#define SZ_2K 0x00000800 +#define SZ_4K 0x00001000 +#define SZ_8K 0x00002000 +#define SZ_16K 0x00004000 +#define SZ_32K 0x00008000 +#define SZ_64K 0x00010000 +#define SZ_128K 0x00020000 +#define SZ_256K 0x00040000 +#define SZ_512K 0x00080000 + +#define SZ_1M 0x00100000 +#define SZ_2M 0x00200000 +#define SZ_4M 0x00400000 +#define SZ_8M 0x00800000 +#define SZ_16M 0x01000000 +#define SZ_32M 0x02000000 +#define SZ_64M 0x04000000 +#define SZ_128M 0x08000000 +#define SZ_256M 0x10000000 +#define SZ_512M 0x20000000 + +#define SZ_1G 0x40000000 +#define SZ_2G 0x80000000 + +#endif /* __ASM_GENERIC_SIZES_H__ */ -- cgit v1.2.3 From 38f5bf84bd588a82890f5ab32cba3317555a73e1 Mon Sep 17 00:00:00 2001 From: GuanXuetao Date: Sat, 15 Jan 2011 18:07:08 +0800 Subject: asm-generic headers: add ftrace.h This patch adds ftrace.h into asm-generic headers. The file content could be empty in most architectures. Signed-off-by: Guan Xuetao Acked-by: Arnd Bergmann --- include/asm-generic/ftrace.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 include/asm-generic/ftrace.h (limited to 'include/asm-generic') diff --git a/include/asm-generic/ftrace.h b/include/asm-generic/ftrace.h new file mode 100644 index 00000000000..51abba9ea7a --- /dev/null +++ b/include/asm-generic/ftrace.h @@ -0,0 +1,16 @@ +/* + * linux/include/asm-generic/ftrace.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_GENERIC_FTRACE_H__ +#define __ASM_GENERIC_FTRACE_H__ + +/* + * Not all architectures need their own ftrace.h, the most + * common definitions are already in linux/ftrace.h. + */ + +#endif /* __ASM_GENERIC_FTRACE_H__ */ -- cgit v1.2.3 From 7f509a9ef7af0d6ac852d49eb87ed2b9857821cc Mon Sep 17 00:00:00 2001 From: GuanXuetao Date: Sat, 15 Jan 2011 18:08:09 +0800 Subject: asm-generic headers: add arch-specific __strnlen_user calling in uaccess.h This patch changes the implementation of strnlen_user in include/asm-generic/uaccess.h. Originally, it calls strlen() function directly, which may not correctly handle the access of user space in most mmu-enabled architectures. New __strnlen_user is added for using as an architecture specific function. Signed-off-by: Guan Xuetao Reviewed-by: Arnd Bergmann --- include/asm-generic/uaccess.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include/asm-generic') diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index b218b8513d0..ac68c999b6c 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -288,14 +288,16 @@ strncpy_from_user(char *dst, const char __user *src, long count) * * Return 0 on exception, a value greater than N if too long */ -#ifndef strnlen_user +#ifndef __strnlen_user +#define __strnlen_user strnlen +#endif + static inline long strnlen_user(const char __user *src, long n) { if (!access_ok(VERIFY_READ, src, 1)) return 0; - return strlen((void * __force)src) + 1; + return __strnlen_user(src, n); } -#endif static inline long strlen_user(const char __user *src) { -- cgit v1.2.3