Path: blob/master/arch/unicore32/include/asm/system.h
10818 views
/*1* linux/arch/unicore32/include/asm/system.h2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*/11#ifndef __UNICORE_SYSTEM_H__12#define __UNICORE_SYSTEM_H__1314#ifdef __KERNEL__1516/*17* CR1 bits (CP#0 CR1)18*/19#define CR_M (1 << 0) /* MMU enable */20#define CR_A (1 << 1) /* Alignment abort enable */21#define CR_D (1 << 2) /* Dcache enable */22#define CR_I (1 << 3) /* Icache enable */23#define CR_B (1 << 4) /* Dcache write mechanism: write back */24#define CR_T (1 << 5) /* Burst enable */25#define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */2627#ifndef __ASSEMBLY__2829#include <linux/linkage.h>30#include <linux/irqflags.h>3132struct thread_info;33struct task_struct;3435struct pt_regs;3637void die(const char *msg, struct pt_regs *regs, int err);3839struct siginfo;40void uc32_notify_die(const char *str, struct pt_regs *regs,41struct siginfo *info, unsigned long err, unsigned long trap);4243void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,44struct pt_regs *),45int sig, int code, const char *name);4647#define xchg(ptr, x) \48((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))4950extern asmlinkage void __backtrace(void);51extern asmlinkage void c_backtrace(unsigned long fp, int pmode);5253struct mm_struct;54extern void show_pte(struct mm_struct *mm, unsigned long addr);55extern void __show_regs(struct pt_regs *);5657extern int cpu_architecture(void);58extern void cpu_init(void);5960#define vectors_high() (cr_alignment & CR_V)6162#define isb() __asm__ __volatile__ ("" : : : "memory")63#define dsb() __asm__ __volatile__ ("" : : : "memory")64#define dmb() __asm__ __volatile__ ("" : : : "memory")6566#define mb() barrier()67#define rmb() barrier()68#define wmb() barrier()69#define smp_mb() barrier()70#define smp_rmb() barrier()71#define smp_wmb() barrier()72#define read_barrier_depends() do { } while (0)73#define smp_read_barrier_depends() do { } while (0)7475#define set_mb(var, value) do { var = value; smp_mb(); } while (0)76#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");7778extern unsigned long cr_no_alignment; /* defined in entry-unicore.S */79extern unsigned long cr_alignment; /* defined in entry-unicore.S */8081static inline unsigned int get_cr(void)82{83unsigned int val;84asm("movc %0, p0.c1, #0" : "=r" (val) : : "cc");85return val;86}8788static inline void set_cr(unsigned int val)89{90asm volatile("movc p0.c1, %0, #0 @set CR"91: : "r" (val) : "cc");92isb();93}9495extern void adjust_cr(unsigned long mask, unsigned long set);9697/*98* switch_to(prev, next) should switch from task `prev' to `next'99* `prev' will never be the same as `next'. schedule() itself100* contains the memory barrier to tell GCC not to cache `current'.101*/102extern struct task_struct *__switch_to(struct task_struct *,103struct thread_info *, struct thread_info *);104extern void panic(const char *fmt, ...);105106#define switch_to(prev, next, last) \107do { \108last = __switch_to(prev, \109task_thread_info(prev), task_thread_info(next)); \110} while (0)111112static inline unsigned long113__xchg(unsigned long x, volatile void *ptr, int size)114{115unsigned long ret;116117switch (size) {118case 1:119asm volatile("@ __xchg1\n"120" swapb %0, %1, [%2]"121: "=&r" (ret)122: "r" (x), "r" (ptr)123: "memory", "cc");124break;125case 4:126asm volatile("@ __xchg4\n"127" swapw %0, %1, [%2]"128: "=&r" (ret)129: "r" (x), "r" (ptr)130: "memory", "cc");131break;132default:133panic("xchg: bad data size: ptr 0x%p, size %d\n",134ptr, size);135}136137return ret;138}139140#include <asm-generic/cmpxchg-local.h>141142/*143* cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make144* them available.145*/146#define cmpxchg_local(ptr, o, n) \147((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \148(unsigned long)(o), (unsigned long)(n), sizeof(*(ptr))))149#define cmpxchg64_local(ptr, o, n) \150__cmpxchg64_local_generic((ptr), (o), (n))151152#include <asm-generic/cmpxchg.h>153154#endif /* __ASSEMBLY__ */155156#define arch_align_stack(x) (x)157158#endif /* __KERNEL__ */159160#endif161162163