forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
asm-generic: add generic versions of common headers
These are all kernel internal interfaces that get copied around a lot. In most cases, architectures can provide their own optimized versions, but these generic versions can work as well. I have tried to use the most common contents of each header to allow existing architectures to migrate easily. Thanks to Remis for suggesting a number of cleanups. Signed-off-by: Remis Lima Baima <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
- Loading branch information
Showing
18 changed files
with
558 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef __ASM_GENERIC_BUGS_H | ||
#define __ASM_GENERIC_BUGS_H | ||
/* | ||
* This file is included by 'init/main.c' to check for | ||
* architecture-dependent bugs. | ||
*/ | ||
|
||
static inline void check_bugs(void) { } | ||
|
||
#endif /* __ASM_GENERIC_BUGS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef __ASM_GENERIC_CURRENT_H | ||
#define __ASM_GENERIC_CURRENT_H | ||
|
||
#include <linux/thread_info.h> | ||
|
||
#define get_current() (current_thread_info()->task) | ||
#define current get_current() | ||
|
||
#endif /* __ASM_GENERIC_CURRENT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef __ASM_GENERIC_DELAY_H | ||
#define __ASM_GENERIC_DELAY_H | ||
|
||
extern void __udelay(unsigned long usecs); | ||
extern void __delay(unsigned long loops); | ||
|
||
#define udelay(n) __udelay(n) | ||
|
||
#endif /* __ASM_GENERIC_DELAY_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef __ASM_GENERIC_FB_H_ | ||
#define __ASM_GENERIC_FB_H_ | ||
#include <linux/fb.h> | ||
|
||
#define fb_pgprotect(...) do {} while (0) | ||
|
||
static inline int fb_is_primary_device(struct fb_info *info) | ||
{ | ||
return 0; | ||
} | ||
|
||
#endif /* __ASM_GENERIC_FB_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef __ASM_GENERIC_HARDIRQ_H | ||
#define __ASM_GENERIC_HARDIRQ_H | ||
|
||
#include <linux/cache.h> | ||
#include <linux/threads.h> | ||
#include <linux/irq.h> | ||
|
||
typedef struct { | ||
unsigned long __softirq_pending; | ||
} ____cacheline_aligned irq_cpustat_t; | ||
|
||
#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ | ||
|
||
#ifndef HARDIRQ_BITS | ||
#define HARDIRQ_BITS 8 | ||
#endif | ||
|
||
/* | ||
* The hardirq mask has to be large enough to have | ||
* space for potentially all IRQ sources in the system | ||
* nesting on a single CPU: | ||
*/ | ||
#if (1 << HARDIRQ_BITS) < NR_IRQS | ||
# error HARDIRQ_BITS is too low! | ||
#endif | ||
|
||
#ifndef ack_bad_irq | ||
static inline void ack_bad_irq(unsigned int irq) | ||
{ | ||
printk(KERN_CRIT "unexpected IRQ trap at vector %02x\n", irq); | ||
} | ||
#endif | ||
|
||
#endif /* __ASM_GENERIC_HARDIRQ_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef __ASM_GENERIC_IRQ_H | ||
#define __ASM_GENERIC_IRQ_H | ||
|
||
/* | ||
* NR_IRQS is the upper bound of how many interrupts can be handled | ||
* in the platform. It is used to size the static irq_map array, | ||
* so don't make it too big. | ||
*/ | ||
#ifndef NR_IRQS | ||
#define NR_IRQS 64 | ||
#endif | ||
|
||
static inline int irq_canonicalize(int irq) | ||
{ | ||
return irq; | ||
} | ||
|
||
#endif /* __ASM_GENERIC_IRQ_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#ifndef __ASM_GENERIC_IRQFLAGS_H | ||
#define __ASM_GENERIC_IRQFLAGS_H | ||
|
||
/* | ||
* All architectures should implement at least the first two functions, | ||
* usually inline assembly will be the best way. | ||
*/ | ||
#ifndef RAW_IRQ_DISABLED | ||
#define RAW_IRQ_DISABLED 0 | ||
#define RAW_IRQ_ENABLED 1 | ||
#endif | ||
|
||
/* read interrupt enabled status */ | ||
#ifndef __raw_local_save_flags | ||
unsigned long __raw_local_save_flags(void); | ||
#endif | ||
|
||
/* set interrupt enabled status */ | ||
#ifndef raw_local_irq_restore | ||
void raw_local_irq_restore(unsigned long flags); | ||
#endif | ||
|
||
/* get status and disable interrupts */ | ||
#ifndef __raw_local_irq_save | ||
static inline unsigned long __raw_local_irq_save(void) | ||
{ | ||
unsigned long flags; | ||
flags = __raw_local_save_flags(); | ||
raw_local_irq_restore(RAW_IRQ_DISABLED); | ||
return flags; | ||
} | ||
#endif | ||
|
||
/* test flags */ | ||
#ifndef raw_irqs_disabled_flags | ||
static inline int raw_irqs_disabled_flags(unsigned long flags) | ||
{ | ||
return flags == RAW_IRQ_DISABLED; | ||
} | ||
#endif | ||
|
||
/* unconditionally enable interrupts */ | ||
#ifndef raw_local_irq_enable | ||
static inline void raw_local_irq_enable(void) | ||
{ | ||
raw_local_irq_restore(RAW_IRQ_ENABLED); | ||
} | ||
#endif | ||
|
||
/* unconditionally disable interrupts */ | ||
#ifndef raw_local_irq_disable | ||
static inline void raw_local_irq_disable(void) | ||
{ | ||
raw_local_irq_restore(RAW_IRQ_DISABLED); | ||
} | ||
#endif | ||
|
||
/* test hardware interrupt enable bit */ | ||
#ifndef raw_irqs_disabled | ||
static inline int raw_irqs_disabled(void) | ||
{ | ||
return raw_irqs_disabled_flags(__raw_local_save_flags()); | ||
} | ||
#endif | ||
|
||
#define raw_local_save_flags(flags) \ | ||
do { (flags) = __raw_local_save_flags(); } while (0) | ||
|
||
#define raw_local_irq_save(flags) \ | ||
do { (flags) = __raw_local_irq_save(); } while (0) | ||
|
||
#endif /* __ASM_GENERIC_IRQFLAGS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef _ASM_GENERIC_KMAP_TYPES_H | ||
#define _ASM_GENERIC_KMAP_TYPES_H | ||
|
||
#ifdef CONFIG_DEBUG_HIGHMEM | ||
# define D(n) __KM_FENCE_##n , | ||
#else | ||
# define D(n) | ||
#endif | ||
|
||
enum km_type { | ||
D(0) KM_BOUNCE_READ, | ||
D(1) KM_SKB_SUNRPC_DATA, | ||
D(2) KM_SKB_DATA_SOFTIRQ, | ||
D(3) KM_USER0, | ||
D(4) KM_USER1, | ||
D(5) KM_BIO_SRC_IRQ, | ||
D(6) KM_BIO_DST_IRQ, | ||
D(7) KM_PTE0, | ||
D(8) KM_PTE1, | ||
D(9) KM_IRQ0, | ||
D(10) KM_IRQ1, | ||
D(11) KM_SOFTIRQ0, | ||
D(12) KM_SOFTIRQ1, | ||
D(13) KM_SYNC_ICACHE, | ||
D(14) KM_SYNC_DCACHE, | ||
D(15) KM_UML_USERCOPY, /* UML specific, for copy_*_user - used in do_op_one_page */ | ||
D(16) KM_TYPE_NR | ||
}; | ||
|
||
#undef D | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef __ASM_GENERIC_LINKAGE_H | ||
#define __ASM_GENERIC_LINKAGE_H | ||
/* | ||
* linux/linkage.h provides reasonable defaults. | ||
* an architecture can override them by providing its own version. | ||
*/ | ||
|
||
#endif /* __ASM_GENERIC_LINKAGE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef __ASM_GENERIC_MODULE_H | ||
#define __ASM_GENERIC_MODULE_H | ||
|
||
/* | ||
* Many architectures just need a simple module | ||
* loader without arch specific data. | ||
*/ | ||
struct mod_arch_specific | ||
{ | ||
}; | ||
|
||
#ifdef CONFIG_64BIT | ||
#define Elf_Shdr Elf64_Shdr | ||
#define Elf_Sym Elf64_Sym | ||
#define Elf_Ehdr Elf64_Ehdr | ||
#else | ||
#define Elf_Shdr Elf32_Shdr | ||
#define Elf_Sym Elf32_Sym | ||
#define Elf_Ehdr Elf32_Ehdr | ||
#endif | ||
|
||
#endif /* __ASM_GENERIC_MODULE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef __ASM_GENERIC_MUTEX_H | ||
#define __ASM_GENERIC_MUTEX_H | ||
/* | ||
* Pull in the generic implementation for the mutex fastpath, | ||
* which is a reasonable default on many architectures. | ||
*/ | ||
|
||
#include <asm-generic/mutex-dec.h> | ||
#endif /* __ASM_GENERIC_MUTEX_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef __ASM_GENERIC_SCATTERLIST_H | ||
#define __ASM_GENERIC_SCATTERLIST_H | ||
|
||
#include <linux/types.h> | ||
|
||
struct scatterlist { | ||
#ifdef CONFIG_DEBUG_SG | ||
unsigned long sg_magic; | ||
#endif | ||
unsigned long page_link; | ||
unsigned int offset; | ||
unsigned int length; | ||
dma_addr_t dma_address; | ||
unsigned int dma_length; | ||
}; | ||
|
||
/* | ||
* These macros should be used after a dma_map_sg call has been done | ||
* to get bus addresses of each of the SG entries and their lengths. | ||
* You should only work with the number of sg entries pci_map_sg | ||
* returns, or alternatively stop on the first sg_dma_len(sg) which | ||
* is 0. | ||
*/ | ||
#define sg_dma_address(sg) ((sg)->dma_address) | ||
#ifndef sg_dma_len | ||
/* | ||
* Normally, you have an iommu on 64 bit machines, but not on 32 bit | ||
* machines. Architectures that are differnt should override this. | ||
*/ | ||
#if __BITS_PER_LONG == 64 | ||
#define sg_dma_len(sg) ((sg)->dma_length) | ||
#else | ||
#define sg_dma_len(sg) ((sg)->length) | ||
#endif /* 64 bit */ | ||
#endif /* sg_dma_len */ | ||
|
||
#ifndef ISA_DMA_THRESHOLD | ||
#define ISA_DMA_THRESHOLD (~0UL) | ||
#endif | ||
|
||
#define ARCH_HAS_SG_CHAIN | ||
|
||
#endif /* __ASM_GENERIC_SCATTERLIST_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef __ASM_GENERIC_SPINLOCK_H | ||
#define __ASM_GENERIC_SPINLOCK_H | ||
/* | ||
* You need to implement asm/spinlock.h for SMP support. The generic | ||
* version does not handle SMP. | ||
*/ | ||
#ifdef CONFIG_SMP | ||
#error need an architecture specific asm/spinlock.h | ||
#endif | ||
|
||
#endif /* __ASM_GENERIC_SPINLOCK_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef __ASM_GENERIC_STRING_H | ||
#define __ASM_GENERIC_STRING_H | ||
/* | ||
* The kernel provides all required functions in lib/string.c | ||
* | ||
* Architectures probably want to provide at least their own optimized | ||
* memcpy and memset functions though. | ||
*/ | ||
|
||
#endif /* __ASM_GENERIC_STRING_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#ifndef __ASM_GENERIC_SYSCALLS_H | ||
#define __ASM_GENERIC_SYSCALLS_H | ||
|
||
#include <linux/compiler.h> | ||
#include <linux/linkage.h> | ||
|
||
/* | ||
* Calling conventions for these system calls can differ, so | ||
* it's possible to override them. | ||
*/ | ||
#ifndef sys_clone | ||
asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp, | ||
void __user *parent_tid, void __user *child_tid, | ||
struct pt_regs *regs); | ||
#endif | ||
|
||
#ifndef sys_fork | ||
asmlinkage long sys_fork(struct pt_regs *regs); | ||
#endif | ||
|
||
#ifndef sys_vfork | ||
asmlinkage long sys_vfork(struct pt_regs *regs); | ||
#endif | ||
|
||
#ifndef sys_execve | ||
asmlinkage long sys_execve(char __user *filename, char __user * __user *argv, | ||
char __user * __user *envp, struct pt_regs *regs); | ||
#endif | ||
|
||
#ifndef sys_mmap2 | ||
asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | ||
unsigned long prot, unsigned long flags, | ||
unsigned long fd, unsigned long pgoff); | ||
#endif | ||
|
||
#ifndef sys_mmap | ||
asmlinkage long sys_mmap(unsigned long addr, unsigned long len, | ||
unsigned long prot, unsigned long flags, | ||
unsigned long fd, off_t pgoff); | ||
#endif | ||
|
||
#ifndef sys_sigaltstack | ||
asmlinkage long sys_sigaltstack(const stack_t __user *, stack_t __user *, | ||
struct pt_regs *); | ||
#endif | ||
|
||
#ifndef sys_rt_sigreturn | ||
asmlinkage long sys_rt_sigreturn(struct pt_regs *regs); | ||
#endif | ||
|
||
#ifndef sys_rt_sigsuspend | ||
asmlinkage long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize); | ||
#endif | ||
|
||
#ifndef sys_rt_sigaction | ||
asmlinkage long sys_rt_sigaction(int sig, const struct sigaction __user *act, | ||
struct sigaction __user *oact, size_t sigsetsize); | ||
#endif | ||
|
||
#endif /* __ASM_GENERIC_SYSCALLS_H */ |
Oops, something went wrong.