···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_BITOPS_H2020+#define __ASM_OPENRISC_BITOPS_H2121+2222+/*2323+ * Where we haven't written assembly versions yet, we fall back to the2424+ * generic implementations. Otherwise, we pull in our (hopefully)2525+ * optimized versions.2626+ */2727+2828+#include <linux/irqflags.h>2929+#include <linux/compiler.h>3030+3131+/*3232+ * clear_bit may not imply a memory barrier3333+ */3434+#ifndef smp_mb__before_clear_bit3535+#define smp_mb__before_clear_bit() smp_mb()3636+#define smp_mb__after_clear_bit() smp_mb()3737+#endif3838+3939+#include <asm/bitops/__ffs.h>4040+#include <asm-generic/bitops/ffz.h>4141+#include <asm/bitops/fls.h>4242+#include <asm/bitops/__fls.h>4343+#include <asm-generic/bitops/fls64.h>4444+#include <asm-generic/bitops/find.h>4545+4646+#ifndef _LINUX_BITOPS_H4747+#error only <linux/bitops.h> can be included directly4848+#endif4949+5050+#include <asm-generic/bitops/sched.h>5151+#include <asm/bitops/ffs.h>5252+#include <asm-generic/bitops/hweight.h>5353+#include <asm-generic/bitops/lock.h>5454+5555+#include <asm-generic/bitops/atomic.h>5656+#include <asm-generic/bitops/non-atomic.h>5757+#include <asm-generic/bitops/ext2-atomic.h>5858+5959+#endif /* __ASM_GENERIC_BITOPS_H */
+33
arch/openrisc/include/asm/bitops/__ffs.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License as published by88+ * the Free Software Foundation; either version 2 of the License, or99+ * (at your option) any later version.1010+ */1111+1212+#ifndef __ASM_OPENRISC___FFS_H1313+#define __ASM_OPENRISC___FFS_H1414+1515+1616+#ifdef CONFIG_OPENRISC_HAVE_INST_FF11717+1818+static inline unsigned long __ffs(unsigned long x)1919+{2020+ int ret;2121+2222+ __asm__ ("l.ff1 %0,%1"2323+ : "=r" (ret)2424+ : "r" (x));2525+2626+ return ret-1;2727+}2828+2929+#else3030+#include <asm-generic/bitops/__ffs.h>3131+#endif3232+3333+#endif /* __ASM_OPENRISC___FFS_H */
+33
arch/openrisc/include/asm/bitops/__fls.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License as published by88+ * the Free Software Foundation; either version 2 of the License, or99+ * (at your option) any later version.1010+ */1111+1212+#ifndef __ASM_OPENRISC___FLS_H1313+#define __ASM_OPENRISC___FLS_H1414+1515+1616+#ifdef CONFIG_OPENRISC_HAVE_INST_FL11717+1818+static inline unsigned long __fls(unsigned long x)1919+{2020+ int ret;2121+2222+ __asm__ ("l.fl1 %0,%1"2323+ : "=r" (ret)2424+ : "r" (x));2525+2626+ return ret-1;2727+}2828+2929+#else3030+#include <asm-generic/bitops/__fls.h>3131+#endif3232+3333+#endif /* __ASM_OPENRISC___FLS_H */
+32
arch/openrisc/include/asm/bitops/ffs.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License as published by88+ * the Free Software Foundation; either version 2 of the License, or99+ * (at your option) any later version.1010+ */1111+1212+#ifndef __ASM_OPENRISC_FFS_H1313+#define __ASM_OPENRISC_FFS_H1414+1515+#ifdef CONFIG_OPENRISC_HAVE_INST_FF11616+1717+static inline int ffs(int x)1818+{1919+ int ret;2020+2121+ __asm__ ("l.ff1 %0,%1"2222+ : "=r" (ret)2323+ : "r" (x));2424+2525+ return ret;2626+}2727+2828+#else2929+#include <asm-generic/bitops/ffs.h>3030+#endif3131+3232+#endif /* __ASM_OPENRISC_FFS_H */
+33
arch/openrisc/include/asm/bitops/fls.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License as published by88+ * the Free Software Foundation; either version 2 of the License, or99+ * (at your option) any later version.1010+ */1111+1212+#ifndef __ASM_OPENRISC_FLS_H1313+#define __ASM_OPENRISC_FLS_H1414+1515+1616+#ifdef CONFIG_OPENRISC_HAVE_INST_FL11717+1818+static inline int fls(int x)1919+{2020+ int ret;2121+2222+ __asm__ ("l.fl1 %0,%1"2323+ : "=r" (ret)2424+ : "r" (x));2525+2626+ return ret;2727+}2828+2929+#else3030+#include <asm-generic/bitops/fls.h>3131+#endif3232+3333+#endif /* __ASM_OPENRISC_FLS_H */
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_CPUINFO_H2020+#define __ASM_OPENRISC_CPUINFO_H2121+2222+struct cpuinfo {2323+ u32 clock_frequency;2424+2525+ u32 icache_size;2626+ u32 icache_block_size;2727+2828+ u32 dcache_size;2929+ u32 dcache_block_size;3030+};3131+3232+extern struct cpuinfo cpuinfo;3333+3434+#endif /* __ASM_OPENRISC_CPUINFO_H */
+24
arch/openrisc/include/asm/delay.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1010+ *1111+ * This program is free software; you can redistribute it and/or modify1212+ * it under the terms of the GNU General Public License as published by1313+ * the Free Software Foundation; either version 2 of the License, or1414+ * (at your option) any later version.1515+ */1616+1717+#ifndef __ASM_OPENRISC_DELAY_H1818+#define __ASM_OPENRISC_DELAY_H1919+2020+#include <asm-generic/delay.h>2121+2222+extern unsigned long loops_per_jiffy;2323+2424+#endif
+108
arch/openrisc/include/asm/elf.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_ELF_H2020+#define __ASM_OPENRISC_ELF_H2121+2222+/*2323+ * ELF register definitions..2424+ */2525+#include <linux/types.h>2626+#include <linux/ptrace.h>2727+2828+2929+/* The OR1K relocation types... not all relevant for module loader */3030+#define R_OR32_NONE 03131+#define R_OR32_32 13232+#define R_OR32_16 23333+#define R_OR32_8 33434+#define R_OR32_CONST 43535+#define R_OR32_CONSTH 53636+#define R_OR32_JUMPTARG 63737+#define R_OR32_VTINHERIT 73838+#define R_OR32_VTENTRY 83939+4040+typedef unsigned long elf_greg_t;4141+4242+/*4343+ * Note that NGREG is defined to ELF_NGREG in include/linux/elfcore.h, and is4444+ * thus exposed to user-space.4545+ */4646+#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))4747+typedef elf_greg_t elf_gregset_t[ELF_NGREG];4848+4949+/* A placeholder; OR32 does not have fp support yes, so no fp regs for now. */5050+typedef unsigned long elf_fpregset_t;5151+5252+/* This should be moved to include/linux/elf.h */5353+#define EM_OR32 0x84725454+#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */5555+5656+/*5757+ * These are used to set parameters in the core dumps.5858+ */5959+#define ELF_ARCH EM_OR326060+#define ELF_CLASS ELFCLASS326161+#define ELF_DATA ELFDATA2MSB6262+6363+#ifdef __KERNEL__6464+6565+/*6666+ * This is used to ensure we don't load something for the wrong architecture.6767+ */6868+6969+#define elf_check_arch(x) \7070+ (((x)->e_machine == EM_OR32) || ((x)->e_machine == EM_OPENRISC))7171+7272+/* This is the location that an ET_DYN program is loaded if exec'ed. Typical7373+ use of this is to invoke "./ld.so someprog" to test out a new version of7474+ the loader. We need to make sure that it is out of the way of the program7575+ that it will "exec", and that there is sufficient room for the brk. */7676+7777+#define ELF_ET_DYN_BASE (0x08000000)7878+7979+/*8080+ * Enable dump using regset.8181+ * This covers all of general/DSP/FPU regs.8282+ */8383+#define CORE_DUMP_USE_REGSET8484+8585+#define ELF_EXEC_PAGESIZE 81928686+8787+extern void dump_elf_thread(elf_greg_t *dest, struct pt_regs *pt);8888+#define ELF_CORE_COPY_REGS(dest, regs) dump_elf_thread(dest, regs);8989+9090+/* This yields a mask that user programs can use to figure out what9191+ instruction set this cpu supports. This could be done in userspace,9292+ but it's not easy, and we've already done it here. */9393+9494+#define ELF_HWCAP (0)9595+9696+/* This yields a string that ld.so will use to load implementation9797+ specific libraries for optimization. This is more specific in9898+ intent than poking at uname or /proc/cpuinfo.9999+100100+ For the moment, we have only optimizations for the Intel generations,101101+ but that could change... */102102+103103+#define ELF_PLATFORM (NULL)104104+105105+#define SET_PERSONALITY(ex) set_personality(PER_LINUX)106106+107107+#endif /* __KERNEL__ */108108+#endif
+51
arch/openrisc/include/asm/io.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1010+ * et al.1111+ *1212+ * This program is free software; you can redistribute it and/or modify1313+ * it under the terms of the GNU General Public License as published by1414+ * the Free Software Foundation; either version 2 of the License, or1515+ * (at your option) any later version.1616+ */1717+1818+#ifndef __ASM_OPENRISC_IO_H1919+#define __ASM_OPENRISC_IO_H2020+2121+/*2222+ * PCI: can we really do 0 here if we have no port IO?2323+ */2424+#define IO_SPACE_LIMIT 02525+2626+/* OpenRISC has no port IO */2727+#define HAVE_ARCH_PIO_SIZE 12828+#define PIO_RESERVED 0X0UL2929+#define PIO_OFFSET 03030+#define PIO_MASK 03131+3232+#include <asm-generic/io.h>3333+3434+extern void __iomem *__ioremap(phys_addr_t offset, unsigned long size,3535+ pgprot_t prot);3636+3737+static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size)3838+{3939+ return __ioremap(offset, size, PAGE_KERNEL);4040+}4141+4242+/* #define _PAGE_CI 0x002 */4343+static inline void __iomem *ioremap_nocache(phys_addr_t offset,4444+ unsigned long size)4545+{4646+ return __ioremap(offset, size,4747+ __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI));4848+}4949+5050+extern void iounmap(void *addr);5151+#endif
+25
arch/openrisc/include/asm/linkage.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_LINKAGE_H2020+#define __ASM_OPENRISC_LINKAGE_H2121+2222+#define __ALIGN .align 02323+#define __ALIGN_STR ".align 0"2424+2525+#endif /* __ASM_OPENRISC_LINKAGE_H */
+27
arch/openrisc/include/asm/mutex.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+/*2020+ * Pull in the generic implementation for the mutex fastpath.2121+ *2222+ * TODO: implement optimized primitives instead, or leave the generic2323+ * implementation in place, or pick the atomic_xchg() based generic2424+ * implementation. (see asm-generic/mutex-xchg.h for details)2525+ */2626+2727+#include <asm-generic/mutex-dec.h>
+26
arch/openrisc/include/asm/param.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_PARAM_H2020+#define __ASM_OPENRISC_PARAM_H2121+2222+#define EXEC_PAGESIZE 81922323+2424+#include <asm-generic/param.h>2525+2626+#endif /* __ASM_OPENRISC_PARAM_H */
+113
arch/openrisc/include/asm/processor.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_PROCESSOR_H2020+#define __ASM_OPENRISC_PROCESSOR_H2121+2222+#include <asm/spr_defs.h>2323+#include <asm/page.h>2424+#include <asm/ptrace.h>2525+2626+#define STACK_TOP TASK_SIZE2727+#define STACK_TOP_MAX STACK_TOP2828+/* Kernel and user SR register setting */2929+#define KERNEL_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \3030+ | SPR_SR_DCE | SPR_SR_SM)3131+#define USER_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \3232+ | SPR_SR_DCE | SPR_SR_IEE | SPR_SR_TEE)3333+/*3434+ * Default implementation of macro that returns current3535+ * instruction pointer ("program counter").3636+ */3737+#define current_text_addr() ({ __label__ _l; _l: &&_l; })3838+3939+/*4040+ * User space process size. This is hardcoded into a few places,4141+ * so don't change it unless you know what you are doing.4242+ */4343+4444+#define TASK_SIZE (0x80000000UL)4545+4646+/* This decides where the kernel will search for a free chunk of vm4747+ * space during mmap's.4848+ */4949+#define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)5050+5151+#ifndef __ASSEMBLY__5252+5353+struct task_struct;5454+5555+struct thread_struct {5656+};5757+5858+/*5959+ * At user->kernel entry, the pt_regs struct is stacked on the top of the6060+ * kernel-stack. This macro allows us to find those regs for a task.6161+ * Notice that subsequent pt_regs stackings, like recursive interrupts6262+ * occurring while we're in the kernel, won't affect this - only the first6363+ * user->kernel transition registers are reached by this (i.e. not regs6464+ * for running signal handler)6565+ */6666+#define user_regs(thread_info) (((struct pt_regs *)((unsigned long)(thread_info) + THREAD_SIZE - STACK_FRAME_OVERHEAD)) - 1)6767+6868+/*6969+ * Dito but for the currently running task7070+ */7171+7272+#define task_pt_regs(task) user_regs(task_thread_info(task))7373+#define current_regs() user_regs(current_thread_info())7474+7575+extern inline void prepare_to_copy(struct task_struct *tsk)7676+{7777+}7878+7979+#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)8080+8181+#define INIT_THREAD { }8282+8383+8484+#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc);8585+#define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp);8686+8787+8888+extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);8989+9090+void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);9191+void release_thread(struct task_struct *);9292+unsigned long get_wchan(struct task_struct *p);9393+9494+/*9595+ * Free current thread data structures etc..9696+ */9797+9898+extern inline void exit_thread(void)9999+{100100+ /* Nothing needs to be done. */101101+}102102+103103+/*104104+ * Return saved PC of a blocked thread. For now, this is the "user" PC105105+ */106106+extern unsigned long thread_saved_pc(struct task_struct *t);107107+108108+#define init_stack (init_thread_union.stack)109109+110110+#define cpu_relax() do { } while (0)111111+112112+#endif /* __ASSEMBLY__ */113113+#endif /* __ASM_OPENRISC_PROCESSOR_H */
+36
arch/openrisc/include/asm/serial.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_SERIAL_H2020+#define __ASM_OPENRISC_SERIAL_H2121+2222+#ifdef __KERNEL__2323+2424+#include <asm/cpuinfo.h>2525+2626+/* There's a generic version of this file, but it assumes a 1.8MHz UART clk...2727+ * this, on the other hand, assumes the UART clock is tied to the system2828+ * clock... 8250_early.c (early 8250 serial console) actually uses this, so2929+ * it needs to be correct to get the early console working.3030+ */3131+3232+#define BASE_BAUD (cpuinfo.clock_frequency/16)3333+3434+#endif /* __KERNEL__ */3535+3636+#endif /* __ASM_OPENRISC_SERIAL_H */
+24
arch/openrisc/include/asm/spinlock.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_SPINLOCK_H2020+#define __ASM_OPENRISC_SPINLOCK_H2121+2222+#error "or32 doesn't do SMP yet"2323+2424+#endif
+42
arch/openrisc/include/asm/spr.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1010+ *1111+ * This program is free software; you can redistribute it and/or modify1212+ * it under the terms of the GNU General Public License as published by1313+ * the Free Software Foundation; either version 2 of the License, or1414+ * (at your option) any later version.1515+ */1616+1717+#ifndef __ASM_OPENRISC_SPR_H1818+#define __ASM_OPENRISC_SPR_H1919+2020+#define mtspr(_spr, _val) __asm__ __volatile__ ( \2121+ "l.mtspr r0,%1,%0" \2222+ : : "K" (_spr), "r" (_val))2323+#define mtspr_off(_spr, _off, _val) __asm__ __volatile__ ( \2424+ "l.mtspr %0,%1,%2" \2525+ : : "r" (_off), "r" (_val), "K" (_spr))2626+2727+static inline unsigned long mfspr(unsigned long add)2828+{2929+ unsigned long ret;3030+ __asm__ __volatile__ ("l.mfspr %0,r0,%1" : "=r" (ret) : "K" (add));3131+ return ret;3232+}3333+3434+static inline unsigned long mfspr_off(unsigned long add, unsigned long offset)3535+{3636+ unsigned long ret;3737+ __asm__ __volatile__ ("l.mfspr %0,%1,%2" : "=r" (ret)3838+ : "r" (offset), "K" (add));3939+ return ret;4040+}4141+4242+#endif
+604
arch/openrisc/include/asm/spr_defs.h
···11+/*22+ * OpenRISC Linux33+ *44+ * SPR Definitions55+ *66+ * Copyright (C) 2000 Damjan Lampret77+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>88+ * Copyright (C) 2008, 2010 Embecosm Limited99+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1010+ * et al.1111+ *1212+ * This program is free software; you can redistribute it and/or modify1313+ * it under the terms of the GNU General Public License as published by1414+ * the Free Software Foundation; either version 2 of the License, or1515+ * (at your option) any later version.1616+ *1717+ * This file is part of OpenRISC 1000 Architectural Simulator.1818+ */1919+2020+#ifndef SPR_DEFS__H2121+#define SPR_DEFS__H2222+2323+/* Definition of special-purpose registers (SPRs). */2424+2525+#define MAX_GRPS (32)2626+#define MAX_SPRS_PER_GRP_BITS (11)2727+#define MAX_SPRS_PER_GRP (1 << MAX_SPRS_PER_GRP_BITS)2828+#define MAX_SPRS (0x10000)2929+3030+/* Base addresses for the groups */3131+#define SPRGROUP_SYS (0 << MAX_SPRS_PER_GRP_BITS)3232+#define SPRGROUP_DMMU (1 << MAX_SPRS_PER_GRP_BITS)3333+#define SPRGROUP_IMMU (2 << MAX_SPRS_PER_GRP_BITS)3434+#define SPRGROUP_DC (3 << MAX_SPRS_PER_GRP_BITS)3535+#define SPRGROUP_IC (4 << MAX_SPRS_PER_GRP_BITS)3636+#define SPRGROUP_MAC (5 << MAX_SPRS_PER_GRP_BITS)3737+#define SPRGROUP_D (6 << MAX_SPRS_PER_GRP_BITS)3838+#define SPRGROUP_PC (7 << MAX_SPRS_PER_GRP_BITS)3939+#define SPRGROUP_PM (8 << MAX_SPRS_PER_GRP_BITS)4040+#define SPRGROUP_PIC (9 << MAX_SPRS_PER_GRP_BITS)4141+#define SPRGROUP_TT (10 << MAX_SPRS_PER_GRP_BITS)4242+#define SPRGROUP_FP (11 << MAX_SPRS_PER_GRP_BITS)4343+4444+/* System control and status group */4545+#define SPR_VR (SPRGROUP_SYS + 0)4646+#define SPR_UPR (SPRGROUP_SYS + 1)4747+#define SPR_CPUCFGR (SPRGROUP_SYS + 2)4848+#define SPR_DMMUCFGR (SPRGROUP_SYS + 3)4949+#define SPR_IMMUCFGR (SPRGROUP_SYS + 4)5050+#define SPR_DCCFGR (SPRGROUP_SYS + 5)5151+#define SPR_ICCFGR (SPRGROUP_SYS + 6)5252+#define SPR_DCFGR (SPRGROUP_SYS + 7)5353+#define SPR_PCCFGR (SPRGROUP_SYS + 8)5454+#define SPR_NPC (SPRGROUP_SYS + 16) /* CZ 21/06/01 */5555+#define SPR_SR (SPRGROUP_SYS + 17) /* CZ 21/06/01 */5656+#define SPR_PPC (SPRGROUP_SYS + 18) /* CZ 21/06/01 */5757+#define SPR_FPCSR (SPRGROUP_SYS + 20) /* CZ 21/06/01 */5858+#define SPR_EPCR_BASE (SPRGROUP_SYS + 32) /* CZ 21/06/01 */5959+#define SPR_EPCR_LAST (SPRGROUP_SYS + 47) /* CZ 21/06/01 */6060+#define SPR_EEAR_BASE (SPRGROUP_SYS + 48)6161+#define SPR_EEAR_LAST (SPRGROUP_SYS + 63)6262+#define SPR_ESR_BASE (SPRGROUP_SYS + 64)6363+#define SPR_ESR_LAST (SPRGROUP_SYS + 79)6464+#define SPR_GPR_BASE (SPRGROUP_SYS + 1024)6565+6666+/* Data MMU group */6767+#define SPR_DMMUCR (SPRGROUP_DMMU + 0)6868+#define SPR_DTLBEIR (SPRGROUP_DMMU + 2)6969+#define SPR_DTLBMR_BASE(WAY) (SPRGROUP_DMMU + 0x200 + (WAY) * 0x100)7070+#define SPR_DTLBMR_LAST(WAY) (SPRGROUP_DMMU + 0x27f + (WAY) * 0x100)7171+#define SPR_DTLBTR_BASE(WAY) (SPRGROUP_DMMU + 0x280 + (WAY) * 0x100)7272+#define SPR_DTLBTR_LAST(WAY) (SPRGROUP_DMMU + 0x2ff + (WAY) * 0x100)7373+7474+/* Instruction MMU group */7575+#define SPR_IMMUCR (SPRGROUP_IMMU + 0)7676+#define SPR_ITLBEIR (SPRGROUP_IMMU + 2)7777+#define SPR_ITLBMR_BASE(WAY) (SPRGROUP_IMMU + 0x200 + (WAY) * 0x100)7878+#define SPR_ITLBMR_LAST(WAY) (SPRGROUP_IMMU + 0x27f + (WAY) * 0x100)7979+#define SPR_ITLBTR_BASE(WAY) (SPRGROUP_IMMU + 0x280 + (WAY) * 0x100)8080+#define SPR_ITLBTR_LAST(WAY) (SPRGROUP_IMMU + 0x2ff + (WAY) * 0x100)8181+8282+/* Data cache group */8383+#define SPR_DCCR (SPRGROUP_DC + 0)8484+#define SPR_DCBPR (SPRGROUP_DC + 1)8585+#define SPR_DCBFR (SPRGROUP_DC + 2)8686+#define SPR_DCBIR (SPRGROUP_DC + 3)8787+#define SPR_DCBWR (SPRGROUP_DC + 4)8888+#define SPR_DCBLR (SPRGROUP_DC + 5)8989+#define SPR_DCR_BASE(WAY) (SPRGROUP_DC + 0x200 + (WAY) * 0x200)9090+#define SPR_DCR_LAST(WAY) (SPRGROUP_DC + 0x3ff + (WAY) * 0x200)9191+9292+/* Instruction cache group */9393+#define SPR_ICCR (SPRGROUP_IC + 0)9494+#define SPR_ICBPR (SPRGROUP_IC + 1)9595+#define SPR_ICBIR (SPRGROUP_IC + 2)9696+#define SPR_ICBLR (SPRGROUP_IC + 3)9797+#define SPR_ICR_BASE(WAY) (SPRGROUP_IC + 0x200 + (WAY) * 0x200)9898+#define SPR_ICR_LAST(WAY) (SPRGROUP_IC + 0x3ff + (WAY) * 0x200)9999+100100+/* MAC group */101101+#define SPR_MACLO (SPRGROUP_MAC + 1)102102+#define SPR_MACHI (SPRGROUP_MAC + 2)103103+104104+/* Debug group */105105+#define SPR_DVR(N) (SPRGROUP_D + (N))106106+#define SPR_DCR(N) (SPRGROUP_D + 8 + (N))107107+#define SPR_DMR1 (SPRGROUP_D + 16)108108+#define SPR_DMR2 (SPRGROUP_D + 17)109109+#define SPR_DWCR0 (SPRGROUP_D + 18)110110+#define SPR_DWCR1 (SPRGROUP_D + 19)111111+#define SPR_DSR (SPRGROUP_D + 20)112112+#define SPR_DRR (SPRGROUP_D + 21)113113+114114+/* Performance counters group */115115+#define SPR_PCCR(N) (SPRGROUP_PC + (N))116116+#define SPR_PCMR(N) (SPRGROUP_PC + 8 + (N))117117+118118+/* Power management group */119119+#define SPR_PMR (SPRGROUP_PM + 0)120120+121121+/* PIC group */122122+#define SPR_PICMR (SPRGROUP_PIC + 0)123123+#define SPR_PICPR (SPRGROUP_PIC + 1)124124+#define SPR_PICSR (SPRGROUP_PIC + 2)125125+126126+/* Tick Timer group */127127+#define SPR_TTMR (SPRGROUP_TT + 0)128128+#define SPR_TTCR (SPRGROUP_TT + 1)129129+130130+/*131131+ * Bit definitions for the Version Register132132+ *133133+ */134134+#define SPR_VR_VER 0xff000000 /* Processor version */135135+#define SPR_VR_CFG 0x00ff0000 /* Processor configuration */136136+#define SPR_VR_RES 0x0000ffc0 /* Reserved */137137+#define SPR_VR_REV 0x0000003f /* Processor revision */138138+139139+#define SPR_VR_VER_OFF 24140140+#define SPR_VR_CFG_OFF 16141141+#define SPR_VR_REV_OFF 0142142+143143+/*144144+ * Bit definitions for the Unit Present Register145145+ *146146+ */147147+#define SPR_UPR_UP 0x00000001 /* UPR present */148148+#define SPR_UPR_DCP 0x00000002 /* Data cache present */149149+#define SPR_UPR_ICP 0x00000004 /* Instruction cache present */150150+#define SPR_UPR_DMP 0x00000008 /* Data MMU present */151151+#define SPR_UPR_IMP 0x00000010 /* Instruction MMU present */152152+#define SPR_UPR_MP 0x00000020 /* MAC present */153153+#define SPR_UPR_DUP 0x00000040 /* Debug unit present */154154+#define SPR_UPR_PCUP 0x00000080 /* Performance counters unit present */155155+#define SPR_UPR_PMP 0x00000100 /* Power management present */156156+#define SPR_UPR_PICP 0x00000200 /* PIC present */157157+#define SPR_UPR_TTP 0x00000400 /* Tick timer present */158158+#define SPR_UPR_RES 0x00fe0000 /* Reserved */159159+#define SPR_UPR_CUP 0xff000000 /* Context units present */160160+161161+/*162162+ * JPB: Bit definitions for the CPU configuration register163163+ *164164+ */165165+#define SPR_CPUCFGR_NSGF 0x0000000f /* Number of shadow GPR files */166166+#define SPR_CPUCFGR_CGF 0x00000010 /* Custom GPR file */167167+#define SPR_CPUCFGR_OB32S 0x00000020 /* ORBIS32 supported */168168+#define SPR_CPUCFGR_OB64S 0x00000040 /* ORBIS64 supported */169169+#define SPR_CPUCFGR_OF32S 0x00000080 /* ORFPX32 supported */170170+#define SPR_CPUCFGR_OF64S 0x00000100 /* ORFPX64 supported */171171+#define SPR_CPUCFGR_OV64S 0x00000200 /* ORVDX64 supported */172172+#define SPR_CPUCFGR_RES 0xfffffc00 /* Reserved */173173+174174+/*175175+ * JPB: Bit definitions for the Debug configuration register and other176176+ * constants.177177+ *178178+ */179179+180180+#define SPR_DCFGR_NDP 0x00000007 /* Number of matchpoints mask */181181+#define SPR_DCFGR_NDP1 0x00000000 /* One matchpoint supported */182182+#define SPR_DCFGR_NDP2 0x00000001 /* Two matchpoints supported */183183+#define SPR_DCFGR_NDP3 0x00000002 /* Three matchpoints supported */184184+#define SPR_DCFGR_NDP4 0x00000003 /* Four matchpoints supported */185185+#define SPR_DCFGR_NDP5 0x00000004 /* Five matchpoints supported */186186+#define SPR_DCFGR_NDP6 0x00000005 /* Six matchpoints supported */187187+#define SPR_DCFGR_NDP7 0x00000006 /* Seven matchpoints supported */188188+#define SPR_DCFGR_NDP8 0x00000007 /* Eight matchpoints supported */189189+#define SPR_DCFGR_WPCI 0x00000008 /* Watchpoint counters implemented */190190+191191+#define MATCHPOINTS_TO_NDP(n) (1 == n ? SPR_DCFGR_NDP1 : \192192+ 2 == n ? SPR_DCFGR_NDP2 : \193193+ 3 == n ? SPR_DCFGR_NDP3 : \194194+ 4 == n ? SPR_DCFGR_NDP4 : \195195+ 5 == n ? SPR_DCFGR_NDP5 : \196196+ 6 == n ? SPR_DCFGR_NDP6 : \197197+ 7 == n ? SPR_DCFGR_NDP7 : SPR_DCFGR_NDP8)198198+#define MAX_MATCHPOINTS 8199199+#define MAX_WATCHPOINTS (MAX_MATCHPOINTS + 2)200200+201201+/*202202+ * Bit definitions for the Supervision Register203203+ *204204+ */205205+#define SPR_SR_SM 0x00000001 /* Supervisor Mode */206206+#define SPR_SR_TEE 0x00000002 /* Tick timer Exception Enable */207207+#define SPR_SR_IEE 0x00000004 /* Interrupt Exception Enable */208208+#define SPR_SR_DCE 0x00000008 /* Data Cache Enable */209209+#define SPR_SR_ICE 0x00000010 /* Instruction Cache Enable */210210+#define SPR_SR_DME 0x00000020 /* Data MMU Enable */211211+#define SPR_SR_IME 0x00000040 /* Instruction MMU Enable */212212+#define SPR_SR_LEE 0x00000080 /* Little Endian Enable */213213+#define SPR_SR_CE 0x00000100 /* CID Enable */214214+#define SPR_SR_F 0x00000200 /* Condition Flag */215215+#define SPR_SR_CY 0x00000400 /* Carry flag */216216+#define SPR_SR_OV 0x00000800 /* Overflow flag */217217+#define SPR_SR_OVE 0x00001000 /* Overflow flag Exception */218218+#define SPR_SR_DSX 0x00002000 /* Delay Slot Exception */219219+#define SPR_SR_EPH 0x00004000 /* Exception Prefix High */220220+#define SPR_SR_FO 0x00008000 /* Fixed one */221221+#define SPR_SR_SUMRA 0x00010000 /* Supervisor SPR read access */222222+#define SPR_SR_RES 0x0ffe0000 /* Reserved */223223+#define SPR_SR_CID 0xf0000000 /* Context ID */224224+225225+/*226226+ * Bit definitions for the Data MMU Control Register227227+ *228228+ */229229+#define SPR_DMMUCR_P2S 0x0000003e /* Level 2 Page Size */230230+#define SPR_DMMUCR_P1S 0x000007c0 /* Level 1 Page Size */231231+#define SPR_DMMUCR_VADDR_WIDTH 0x0000f800 /* Virtual ADDR Width */232232+#define SPR_DMMUCR_PADDR_WIDTH 0x000f0000 /* Physical ADDR Width */233233+234234+/*235235+ * Bit definitions for the Instruction MMU Control Register236236+ *237237+ */238238+#define SPR_IMMUCR_P2S 0x0000003e /* Level 2 Page Size */239239+#define SPR_IMMUCR_P1S 0x000007c0 /* Level 1 Page Size */240240+#define SPR_IMMUCR_VADDR_WIDTH 0x0000f800 /* Virtual ADDR Width */241241+#define SPR_IMMUCR_PADDR_WIDTH 0x000f0000 /* Physical ADDR Width */242242+243243+/*244244+ * Bit definitions for the Data TLB Match Register245245+ *246246+ */247247+#define SPR_DTLBMR_V 0x00000001 /* Valid */248248+#define SPR_DTLBMR_PL1 0x00000002 /* Page Level 1 (if 0 then PL2) */249249+#define SPR_DTLBMR_CID 0x0000003c /* Context ID */250250+#define SPR_DTLBMR_LRU 0x000000c0 /* Least Recently Used */251251+#define SPR_DTLBMR_VPN 0xfffff000 /* Virtual Page Number */252252+253253+/*254254+ * Bit definitions for the Data TLB Translate Register255255+ *256256+ */257257+#define SPR_DTLBTR_CC 0x00000001 /* Cache Coherency */258258+#define SPR_DTLBTR_CI 0x00000002 /* Cache Inhibit */259259+#define SPR_DTLBTR_WBC 0x00000004 /* Write-Back Cache */260260+#define SPR_DTLBTR_WOM 0x00000008 /* Weakly-Ordered Memory */261261+#define SPR_DTLBTR_A 0x00000010 /* Accessed */262262+#define SPR_DTLBTR_D 0x00000020 /* Dirty */263263+#define SPR_DTLBTR_URE 0x00000040 /* User Read Enable */264264+#define SPR_DTLBTR_UWE 0x00000080 /* User Write Enable */265265+#define SPR_DTLBTR_SRE 0x00000100 /* Supervisor Read Enable */266266+#define SPR_DTLBTR_SWE 0x00000200 /* Supervisor Write Enable */267267+#define SPR_DTLBTR_PPN 0xfffff000 /* Physical Page Number */268268+269269+/*270270+ * Bit definitions for the Instruction TLB Match Register271271+ *272272+ */273273+#define SPR_ITLBMR_V 0x00000001 /* Valid */274274+#define SPR_ITLBMR_PL1 0x00000002 /* Page Level 1 (if 0 then PL2) */275275+#define SPR_ITLBMR_CID 0x0000003c /* Context ID */276276+#define SPR_ITLBMR_LRU 0x000000c0 /* Least Recently Used */277277+#define SPR_ITLBMR_VPN 0xfffff000 /* Virtual Page Number */278278+279279+/*280280+ * Bit definitions for the Instruction TLB Translate Register281281+ *282282+ */283283+#define SPR_ITLBTR_CC 0x00000001 /* Cache Coherency */284284+#define SPR_ITLBTR_CI 0x00000002 /* Cache Inhibit */285285+#define SPR_ITLBTR_WBC 0x00000004 /* Write-Back Cache */286286+#define SPR_ITLBTR_WOM 0x00000008 /* Weakly-Ordered Memory */287287+#define SPR_ITLBTR_A 0x00000010 /* Accessed */288288+#define SPR_ITLBTR_D 0x00000020 /* Dirty */289289+#define SPR_ITLBTR_SXE 0x00000040 /* User Read Enable */290290+#define SPR_ITLBTR_UXE 0x00000080 /* User Write Enable */291291+#define SPR_ITLBTR_PPN 0xfffff000 /* Physical Page Number */292292+293293+/*294294+ * Bit definitions for Data Cache Control register295295+ *296296+ */297297+#define SPR_DCCR_EW 0x000000ff /* Enable ways */298298+299299+/*300300+ * Bit definitions for Insn Cache Control register301301+ *302302+ */303303+#define SPR_ICCR_EW 0x000000ff /* Enable ways */304304+305305+/*306306+ * Bit definitions for Data Cache Configuration Register307307+ *308308+ */309309+310310+#define SPR_DCCFGR_NCW 0x00000007311311+#define SPR_DCCFGR_NCS 0x00000078312312+#define SPR_DCCFGR_CBS 0x00000080313313+#define SPR_DCCFGR_CWS 0x00000100314314+#define SPR_DCCFGR_CCRI 0x00000200315315+#define SPR_DCCFGR_CBIRI 0x00000400316316+#define SPR_DCCFGR_CBPRI 0x00000800317317+#define SPR_DCCFGR_CBLRI 0x00001000318318+#define SPR_DCCFGR_CBFRI 0x00002000319319+#define SPR_DCCFGR_CBWBRI 0x00004000320320+321321+#define SPR_DCCFGR_NCW_OFF 0322322+#define SPR_DCCFGR_NCS_OFF 3323323+#define SPR_DCCFGR_CBS_OFF 7324324+325325+/*326326+ * Bit definitions for Instruction Cache Configuration Register327327+ *328328+ */329329+#define SPR_ICCFGR_NCW 0x00000007330330+#define SPR_ICCFGR_NCS 0x00000078331331+#define SPR_ICCFGR_CBS 0x00000080332332+#define SPR_ICCFGR_CCRI 0x00000200333333+#define SPR_ICCFGR_CBIRI 0x00000400334334+#define SPR_ICCFGR_CBPRI 0x00000800335335+#define SPR_ICCFGR_CBLRI 0x00001000336336+337337+#define SPR_ICCFGR_NCW_OFF 0338338+#define SPR_ICCFGR_NCS_OFF 3339339+#define SPR_ICCFGR_CBS_OFF 7340340+341341+/*342342+ * Bit definitions for Data MMU Configuration Register343343+ *344344+ */345345+346346+#define SPR_DMMUCFGR_NTW 0x00000003347347+#define SPR_DMMUCFGR_NTS 0x0000001C348348+#define SPR_DMMUCFGR_NAE 0x000000E0349349+#define SPR_DMMUCFGR_CRI 0x00000100350350+#define SPR_DMMUCFGR_PRI 0x00000200351351+#define SPR_DMMUCFGR_TEIRI 0x00000400352352+#define SPR_DMMUCFGR_HTR 0x00000800353353+354354+#define SPR_DMMUCFGR_NTW_OFF 0355355+#define SPR_DMMUCFGR_NTS_OFF 2356356+357357+/*358358+ * Bit definitions for Instruction MMU Configuration Register359359+ *360360+ */361361+362362+#define SPR_IMMUCFGR_NTW 0x00000003363363+#define SPR_IMMUCFGR_NTS 0x0000001C364364+#define SPR_IMMUCFGR_NAE 0x000000E0365365+#define SPR_IMMUCFGR_CRI 0x00000100366366+#define SPR_IMMUCFGR_PRI 0x00000200367367+#define SPR_IMMUCFGR_TEIRI 0x00000400368368+#define SPR_IMMUCFGR_HTR 0x00000800369369+370370+#define SPR_IMMUCFGR_NTW_OFF 0371371+#define SPR_IMMUCFGR_NTS_OFF 2372372+373373+/*374374+ * Bit definitions for Debug Control registers375375+ *376376+ */377377+#define SPR_DCR_DP 0x00000001 /* DVR/DCR present */378378+#define SPR_DCR_CC 0x0000000e /* Compare condition */379379+#define SPR_DCR_SC 0x00000010 /* Signed compare */380380+#define SPR_DCR_CT 0x000000e0 /* Compare to */381381+382382+/* Bit results with SPR_DCR_CC mask */383383+#define SPR_DCR_CC_MASKED 0x00000000384384+#define SPR_DCR_CC_EQUAL 0x00000002385385+#define SPR_DCR_CC_LESS 0x00000004386386+#define SPR_DCR_CC_LESSE 0x00000006387387+#define SPR_DCR_CC_GREAT 0x00000008388388+#define SPR_DCR_CC_GREATE 0x0000000a389389+#define SPR_DCR_CC_NEQUAL 0x0000000c390390+391391+/* Bit results with SPR_DCR_CT mask */392392+#define SPR_DCR_CT_DISABLED 0x00000000393393+#define SPR_DCR_CT_IFEA 0x00000020394394+#define SPR_DCR_CT_LEA 0x00000040395395+#define SPR_DCR_CT_SEA 0x00000060396396+#define SPR_DCR_CT_LD 0x00000080397397+#define SPR_DCR_CT_SD 0x000000a0398398+#define SPR_DCR_CT_LSEA 0x000000c0399399+#define SPR_DCR_CT_LSD 0x000000e0400400+/* SPR_DCR_CT_LSD doesn't seem to be implemented anywhere in or1ksim. 2004-1-30 HP */401401+402402+/*403403+ * Bit definitions for Debug Mode 1 register404404+ *405405+ */406406+#define SPR_DMR1_CW 0x000fffff /* Chain register pair data */407407+#define SPR_DMR1_CW0_AND 0x00000001408408+#define SPR_DMR1_CW0_OR 0x00000002409409+#define SPR_DMR1_CW0 (SPR_DMR1_CW0_AND | SPR_DMR1_CW0_OR)410410+#define SPR_DMR1_CW1_AND 0x00000004411411+#define SPR_DMR1_CW1_OR 0x00000008412412+#define SPR_DMR1_CW1 (SPR_DMR1_CW1_AND | SPR_DMR1_CW1_OR)413413+#define SPR_DMR1_CW2_AND 0x00000010414414+#define SPR_DMR1_CW2_OR 0x00000020415415+#define SPR_DMR1_CW2 (SPR_DMR1_CW2_AND | SPR_DMR1_CW2_OR)416416+#define SPR_DMR1_CW3_AND 0x00000040417417+#define SPR_DMR1_CW3_OR 0x00000080418418+#define SPR_DMR1_CW3 (SPR_DMR1_CW3_AND | SPR_DMR1_CW3_OR)419419+#define SPR_DMR1_CW4_AND 0x00000100420420+#define SPR_DMR1_CW4_OR 0x00000200421421+#define SPR_DMR1_CW4 (SPR_DMR1_CW4_AND | SPR_DMR1_CW4_OR)422422+#define SPR_DMR1_CW5_AND 0x00000400423423+#define SPR_DMR1_CW5_OR 0x00000800424424+#define SPR_DMR1_CW5 (SPR_DMR1_CW5_AND | SPR_DMR1_CW5_OR)425425+#define SPR_DMR1_CW6_AND 0x00001000426426+#define SPR_DMR1_CW6_OR 0x00002000427427+#define SPR_DMR1_CW6 (SPR_DMR1_CW6_AND | SPR_DMR1_CW6_OR)428428+#define SPR_DMR1_CW7_AND 0x00004000429429+#define SPR_DMR1_CW7_OR 0x00008000430430+#define SPR_DMR1_CW7 (SPR_DMR1_CW7_AND | SPR_DMR1_CW7_OR)431431+#define SPR_DMR1_CW8_AND 0x00010000432432+#define SPR_DMR1_CW8_OR 0x00020000433433+#define SPR_DMR1_CW8 (SPR_DMR1_CW8_AND | SPR_DMR1_CW8_OR)434434+#define SPR_DMR1_CW9_AND 0x00040000435435+#define SPR_DMR1_CW9_OR 0x00080000436436+#define SPR_DMR1_CW9 (SPR_DMR1_CW9_AND | SPR_DMR1_CW9_OR)437437+#define SPR_DMR1_RES1 0x00300000 /* Reserved */438438+#define SPR_DMR1_ST 0x00400000 /* Single-step trace*/439439+#define SPR_DMR1_BT 0x00800000 /* Branch trace */440440+#define SPR_DMR1_RES2 0xff000000 /* Reserved */441441+442442+/*443443+ * Bit definitions for Debug Mode 2 register. AWTC and WGB corrected by JPB444444+ *445445+ */446446+#define SPR_DMR2_WCE0 0x00000001 /* Watchpoint counter 0 enable */447447+#define SPR_DMR2_WCE1 0x00000002 /* Watchpoint counter 0 enable */448448+#define SPR_DMR2_AWTC 0x00000ffc /* Assign watchpoints to counters */449449+#define SPR_DMR2_AWTC_OFF 2 /* Bit offset to AWTC field */450450+#define SPR_DMR2_WGB 0x003ff000 /* Watchpoints generating breakpoint */451451+#define SPR_DMR2_WGB_OFF 12 /* Bit offset to WGB field */452452+#define SPR_DMR2_WBS 0xffc00000 /* JPB: Watchpoint status */453453+#define SPR_DMR2_WBS_OFF 22 /* Bit offset to WBS field */454454+455455+/*456456+ * Bit definitions for Debug watchpoint counter registers457457+ *458458+ */459459+#define SPR_DWCR_COUNT 0x0000ffff /* Count */460460+#define SPR_DWCR_MATCH 0xffff0000 /* Match */461461+#define SPR_DWCR_MATCH_OFF 16 /* Match bit offset */462462+463463+/*464464+ * Bit definitions for Debug stop register465465+ *466466+ */467467+#define SPR_DSR_RSTE 0x00000001 /* Reset exception */468468+#define SPR_DSR_BUSEE 0x00000002 /* Bus error exception */469469+#define SPR_DSR_DPFE 0x00000004 /* Data Page Fault exception */470470+#define SPR_DSR_IPFE 0x00000008 /* Insn Page Fault exception */471471+#define SPR_DSR_TTE 0x00000010 /* Tick Timer exception */472472+#define SPR_DSR_AE 0x00000020 /* Alignment exception */473473+#define SPR_DSR_IIE 0x00000040 /* Illegal Instruction exception */474474+#define SPR_DSR_IE 0x00000080 /* Interrupt exception */475475+#define SPR_DSR_DME 0x00000100 /* DTLB miss exception */476476+#define SPR_DSR_IME 0x00000200 /* ITLB miss exception */477477+#define SPR_DSR_RE 0x00000400 /* Range exception */478478+#define SPR_DSR_SCE 0x00000800 /* System call exception */479479+#define SPR_DSR_FPE 0x00001000 /* Floating Point Exception */480480+#define SPR_DSR_TE 0x00002000 /* Trap exception */481481+482482+/*483483+ * Bit definitions for Debug reason register484484+ *485485+ */486486+#define SPR_DRR_RSTE 0x00000001 /* Reset exception */487487+#define SPR_DRR_BUSEE 0x00000002 /* Bus error exception */488488+#define SPR_DRR_DPFE 0x00000004 /* Data Page Fault exception */489489+#define SPR_DRR_IPFE 0x00000008 /* Insn Page Fault exception */490490+#define SPR_DRR_TTE 0x00000010 /* Tick Timer exception */491491+#define SPR_DRR_AE 0x00000020 /* Alignment exception */492492+#define SPR_DRR_IIE 0x00000040 /* Illegal Instruction exception */493493+#define SPR_DRR_IE 0x00000080 /* Interrupt exception */494494+#define SPR_DRR_DME 0x00000100 /* DTLB miss exception */495495+#define SPR_DRR_IME 0x00000200 /* ITLB miss exception */496496+#define SPR_DRR_RE 0x00000400 /* Range exception */497497+#define SPR_DRR_SCE 0x00000800 /* System call exception */498498+#define SPR_DRR_FPE 0x00001000 /* Floating Point Exception */499499+#define SPR_DRR_TE 0x00002000 /* Trap exception */500500+501501+/*502502+ * Bit definitions for Performance counters mode registers503503+ *504504+ */505505+#define SPR_PCMR_CP 0x00000001 /* Counter present */506506+#define SPR_PCMR_UMRA 0x00000002 /* User mode read access */507507+#define SPR_PCMR_CISM 0x00000004 /* Count in supervisor mode */508508+#define SPR_PCMR_CIUM 0x00000008 /* Count in user mode */509509+#define SPR_PCMR_LA 0x00000010 /* Load access event */510510+#define SPR_PCMR_SA 0x00000020 /* Store access event */511511+#define SPR_PCMR_IF 0x00000040 /* Instruction fetch event*/512512+#define SPR_PCMR_DCM 0x00000080 /* Data cache miss event */513513+#define SPR_PCMR_ICM 0x00000100 /* Insn cache miss event */514514+#define SPR_PCMR_IFS 0x00000200 /* Insn fetch stall event */515515+#define SPR_PCMR_LSUS 0x00000400 /* LSU stall event */516516+#define SPR_PCMR_BS 0x00000800 /* Branch stall event */517517+#define SPR_PCMR_DTLBM 0x00001000 /* DTLB miss event */518518+#define SPR_PCMR_ITLBM 0x00002000 /* ITLB miss event */519519+#define SPR_PCMR_DDS 0x00004000 /* Data dependency stall event */520520+#define SPR_PCMR_WPE 0x03ff8000 /* Watchpoint events */521521+522522+/*523523+ * Bit definitions for the Power management register524524+ *525525+ */526526+#define SPR_PMR_SDF 0x0000000f /* Slow down factor */527527+#define SPR_PMR_DME 0x00000010 /* Doze mode enable */528528+#define SPR_PMR_SME 0x00000020 /* Sleep mode enable */529529+#define SPR_PMR_DCGE 0x00000040 /* Dynamic clock gating enable */530530+#define SPR_PMR_SUME 0x00000080 /* Suspend mode enable */531531+532532+/*533533+ * Bit definitions for PICMR534534+ *535535+ */536536+#define SPR_PICMR_IUM 0xfffffffc /* Interrupt unmask */537537+538538+/*539539+ * Bit definitions for PICPR540540+ *541541+ */542542+#define SPR_PICPR_IPRIO 0xfffffffc /* Interrupt priority */543543+544544+/*545545+ * Bit definitions for PICSR546546+ *547547+ */548548+#define SPR_PICSR_IS 0xffffffff /* Interrupt status */549549+550550+/*551551+ * Bit definitions for Tick Timer Control Register552552+ *553553+ */554554+555555+#define SPR_TTCR_CNT 0xffffffff /* Count, time period */556556+#define SPR_TTMR_TP 0x0fffffff /* Time period */557557+#define SPR_TTMR_IP 0x10000000 /* Interrupt Pending */558558+#define SPR_TTMR_IE 0x20000000 /* Interrupt Enable */559559+#define SPR_TTMR_DI 0x00000000 /* Disabled */560560+#define SPR_TTMR_RT 0x40000000 /* Restart tick */561561+#define SPR_TTMR_SR 0x80000000 /* Single run */562562+#define SPR_TTMR_CR 0xc0000000 /* Continuous run */563563+#define SPR_TTMR_M 0xc0000000 /* Tick mode */564564+565565+/*566566+ * Bit definitions for the FP Control Status Register567567+ *568568+ */569569+#define SPR_FPCSR_FPEE 0x00000001 /* Floating Point Exception Enable */570570+#define SPR_FPCSR_RM 0x00000006 /* Rounding Mode */571571+#define SPR_FPCSR_OVF 0x00000008 /* Overflow Flag */572572+#define SPR_FPCSR_UNF 0x00000010 /* Underflow Flag */573573+#define SPR_FPCSR_SNF 0x00000020 /* SNAN Flag */574574+#define SPR_FPCSR_QNF 0x00000040 /* QNAN Flag */575575+#define SPR_FPCSR_ZF 0x00000080 /* Zero Flag */576576+#define SPR_FPCSR_IXF 0x00000100 /* Inexact Flag */577577+#define SPR_FPCSR_IVF 0x00000200 /* Invalid Flag */578578+#define SPR_FPCSR_INF 0x00000400 /* Infinity Flag */579579+#define SPR_FPCSR_DZF 0x00000800 /* Divide By Zero Flag */580580+#define SPR_FPCSR_ALLF (SPR_FPCSR_OVF | SPR_FPCSR_UNF | SPR_FPCSR_SNF | \581581+ SPR_FPCSR_QNF | SPR_FPCSR_ZF | SPR_FPCSR_IXF | \582582+ SPR_FPCSR_IVF | SPR_FPCSR_INF | SPR_FPCSR_DZF)583583+584584+#define FPCSR_RM_RN (0<<1)585585+#define FPCSR_RM_RZ (1<<1)586586+#define FPCSR_RM_RIP (2<<1)587587+#define FPCSR_RM_RIN (3<<1)588588+589589+/*590590+ * l.nop constants591591+ *592592+ */593593+#define NOP_NOP 0x0000 /* Normal nop instruction */594594+#define NOP_EXIT 0x0001 /* End of simulation */595595+#define NOP_REPORT 0x0002 /* Simple report */596596+/*#define NOP_PRINTF 0x0003 Simprintf instruction (obsolete)*/597597+#define NOP_PUTC 0x0004 /* JPB: Simputc instruction */598598+#define NOP_CNT_RESET 0x0005 /* Reset statistics counters */599599+#define NOP_GET_TICKS 0x0006 /* JPB: Get # ticks running */600600+#define NOP_GET_PS 0x0007 /* JPB: Get picosecs/cycle */601601+#define NOP_REPORT_FIRST 0x0400 /* Report with number */602602+#define NOP_REPORT_LAST 0x03ff /* Report with number */603603+604604+#endif /* SPR_DEFS__H */
+35
arch/openrisc/include/asm/system.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_SYSTEM_H2020+#define __ASM_OPENRISC_SYSTEM_H2121+2222+#ifdef __KERNEL__2323+#ifndef __ASSEMBLY__2424+2525+#include <asm/spr.h>2626+#include <asm-generic/system.h>2727+2828+/* We probably need this definition, but the generic system.h provides it2929+ * and it's not used on our arch anyway...3030+ */3131+/*#define nop() __asm__ __volatile__ ("l.nop"::)*/3232+3333+#endif /* __ASSEMBLY__ */3434+#endif /* __KERNEL__ */3535+#endif /* __ASM_OPENRISC_SYSTEM_H */
+51
arch/openrisc/include/asm/unaligned.h
···11+/*22+ * OpenRISC Linux33+ *44+ * Linux architectural port borrowing liberally from similar works of55+ * others. All original copyrights apply as per the original source66+ * declaration.77+ *88+ * OpenRISC implementation:99+ * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>1010+ * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>1111+ * et al.1212+ *1313+ * This program is free software; you can redistribute it and/or modify1414+ * it under the terms of the GNU General Public License as published by1515+ * the Free Software Foundation; either version 2 of the License, or1616+ * (at your option) any later version.1717+ */1818+1919+#ifndef __ASM_OPENRISC_UNALIGNED_H2020+#define __ASM_OPENRISC_UNALIGNED_H2121+2222+/*2323+ * This is copied from the generic implementation and the C-struct2424+ * variant replaced with the memmove variant. The GCC compiler2525+ * for the OR32 arch optimizes too aggressively for the C-struct2626+ * variant to work, so use the memmove variant instead.2727+ *2828+ * It may be worth considering implementing the unaligned access2929+ * exception handler and allowing unaligned accesses (access_ok.h)...3030+ * not sure if it would be much of a performance win without further3131+ * investigation.3232+ */3333+#include <asm/byteorder.h>3434+3535+#if defined(__LITTLE_ENDIAN)3636+# include <linux/unaligned/le_memmove.h>3737+# include <linux/unaligned/be_byteshift.h>3838+# include <linux/unaligned/generic.h>3939+# define get_unaligned __get_unaligned_le4040+# define put_unaligned __put_unaligned_le4141+#elif defined(__BIG_ENDIAN)4242+# include <linux/unaligned/be_memmove.h>4343+# include <linux/unaligned/le_byteshift.h>4444+# include <linux/unaligned/generic.h>4545+# define get_unaligned __get_unaligned_be4646+# define put_unaligned __put_unaligned_be4747+#else4848+# error need to define endianess4949+#endif5050+5151+#endif /* __ASM_OPENRISC_UNALIGNED_H */