diff options
Diffstat (limited to 'arch/nds32/include')
50 files changed, 3875 insertions, 0 deletions
diff --git a/arch/nds32/include/asm/Kbuild b/arch/nds32/include/asm/Kbuild new file mode 100644 index 000000000000..06bdf8167f5a --- /dev/null +++ b/arch/nds32/include/asm/Kbuild | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | generic-y += asm-offsets.h | ||
| 2 | generic-y += atomic.h | ||
| 3 | generic-y += bitops.h | ||
| 4 | generic-y += bitsperlong.h | ||
| 5 | generic-y += bpf_perf_event.h | ||
| 6 | generic-y += bug.h | ||
| 7 | generic-y += bugs.h | ||
| 8 | generic-y += checksum.h | ||
| 9 | generic-y += clkdev.h | ||
| 10 | generic-y += cmpxchg.h | ||
| 11 | generic-y += cmpxchg-local.h | ||
| 12 | generic-y += cputime.h | ||
| 13 | generic-y += device.h | ||
| 14 | generic-y += div64.h | ||
| 15 | generic-y += dma.h | ||
| 16 | generic-y += emergency-restart.h | ||
| 17 | generic-y += errno.h | ||
| 18 | generic-y += exec.h | ||
| 19 | generic-y += fb.h | ||
| 20 | generic-y += fcntl.h | ||
| 21 | generic-y += ftrace.h | ||
| 22 | generic-y += gpio.h | ||
| 23 | generic-y += hardirq.h | ||
| 24 | generic-y += hw_irq.h | ||
| 25 | generic-y += ioctl.h | ||
| 26 | generic-y += ioctls.h | ||
| 27 | generic-y += irq.h | ||
| 28 | generic-y += irq_regs.h | ||
| 29 | generic-y += irq_work.h | ||
| 30 | generic-y += kdebug.h | ||
| 31 | generic-y += kmap_types.h | ||
| 32 | generic-y += kprobes.h | ||
| 33 | generic-y += kvm_para.h | ||
| 34 | generic-y += limits.h | ||
| 35 | generic-y += local.h | ||
| 36 | generic-y += mm-arch-hooks.h | ||
| 37 | generic-y += mman.h | ||
| 38 | generic-y += parport.h | ||
| 39 | generic-y += pci.h | ||
| 40 | generic-y += percpu.h | ||
| 41 | generic-y += preempt.h | ||
| 42 | generic-y += sections.h | ||
| 43 | generic-y += segment.h | ||
| 44 | generic-y += serial.h | ||
| 45 | generic-y += shmbuf.h | ||
| 46 | generic-y += sizes.h | ||
| 47 | generic-y += stat.h | ||
| 48 | generic-y += switch_to.h | ||
| 49 | generic-y += timex.h | ||
| 50 | generic-y += topology.h | ||
| 51 | generic-y += trace_clock.h | ||
| 52 | generic-y += unaligned.h | ||
| 53 | generic-y += user.h | ||
| 54 | generic-y += vga.h | ||
| 55 | generic-y += word-at-a-time.h | ||
diff --git a/arch/nds32/include/asm/assembler.h b/arch/nds32/include/asm/assembler.h new file mode 100644 index 000000000000..c3855782a541 --- /dev/null +++ b/arch/nds32/include/asm/assembler.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_ASSEMBLER_H__ | ||
| 5 | #define __NDS32_ASSEMBLER_H__ | ||
| 6 | |||
| 7 | .macro gie_disable | ||
| 8 | setgie.d | ||
| 9 | dsb | ||
| 10 | .endm | ||
| 11 | |||
| 12 | .macro gie_enable | ||
| 13 | setgie.e | ||
| 14 | dsb | ||
| 15 | .endm | ||
| 16 | |||
| 17 | .macro gie_save oldpsw | ||
| 18 | mfsr \oldpsw, $ir0 | ||
| 19 | setgie.d | ||
| 20 | dsb | ||
| 21 | .endm | ||
| 22 | |||
| 23 | .macro gie_restore oldpsw | ||
| 24 | andi \oldpsw, \oldpsw, #0x1 | ||
| 25 | beqz \oldpsw, 7001f | ||
| 26 | setgie.e | ||
| 27 | dsb | ||
| 28 | 7001: | ||
| 29 | .endm | ||
| 30 | |||
| 31 | |||
| 32 | #define USER(insn, reg, addr, opr) \ | ||
| 33 | 9999: insn reg, addr, opr; \ | ||
| 34 | .section __ex_table,"a"; \ | ||
| 35 | .align 3; \ | ||
| 36 | .long 9999b, 9001f; \ | ||
| 37 | .previous | ||
| 38 | |||
| 39 | #endif /* __NDS32_ASSEMBLER_H__ */ | ||
diff --git a/arch/nds32/include/asm/barrier.h b/arch/nds32/include/asm/barrier.h new file mode 100644 index 000000000000..faafc373ea6c --- /dev/null +++ b/arch/nds32/include/asm/barrier.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_ASM_BARRIER_H | ||
| 5 | #define __NDS32_ASM_BARRIER_H | ||
| 6 | |||
| 7 | #ifndef __ASSEMBLY__ | ||
| 8 | #define mb() asm volatile("msync all":::"memory") | ||
| 9 | #define rmb() asm volatile("msync all":::"memory") | ||
| 10 | #define wmb() asm volatile("msync store":::"memory") | ||
| 11 | #include <asm-generic/barrier.h> | ||
| 12 | |||
| 13 | #endif /* __ASSEMBLY__ */ | ||
| 14 | |||
| 15 | #endif /* __NDS32_ASM_BARRIER_H */ | ||
diff --git a/arch/nds32/include/asm/bitfield.h b/arch/nds32/include/asm/bitfield.h new file mode 100644 index 000000000000..c73f71d67744 --- /dev/null +++ b/arch/nds32/include/asm/bitfield.h | |||
| @@ -0,0 +1,963 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_BITFIELD_H__ | ||
| 5 | #define __NDS32_BITFIELD_H__ | ||
| 6 | /****************************************************************************** | ||
| 7 | * cr0: CPU_VER (CPU Version Register) | ||
| 8 | *****************************************************************************/ | ||
| 9 | #define CPU_VER_offCFGID 0 /* Minor configuration */ | ||
| 10 | #define CPU_VER_offREV 16 /* Revision of the CPU version */ | ||
| 11 | #define CPU_VER_offCPUID 24 /* Major CPU versions */ | ||
| 12 | |||
| 13 | #define CPU_VER_mskCFGID ( 0xFFFF << CPU_VER_offCFGID ) | ||
| 14 | #define CPU_VER_mskREV ( 0xFF << CPU_VER_offREV ) | ||
| 15 | #define CPU_VER_mskCPUID ( 0xFF << CPU_VER_offCPUID ) | ||
| 16 | |||
| 17 | /****************************************************************************** | ||
| 18 | * cr1: ICM_CFG (Instruction Cache/Memory Configuration Register) | ||
| 19 | *****************************************************************************/ | ||
| 20 | #define ICM_CFG_offISET 0 /* I-cache sets (# of cache lines) per way */ | ||
| 21 | #define ICM_CFG_offIWAY 3 /* I-cache ways */ | ||
| 22 | #define ICM_CFG_offISZ 6 /* I-cache line size */ | ||
| 23 | #define ICM_CFG_offILCK 9 /* I-cache locking support */ | ||
| 24 | #define ICM_CFG_offILMB 10 /* On-chip ILM banks */ | ||
| 25 | #define ICM_CFG_offBSAV 13 /* ILM base register alignment version */ | ||
| 26 | /* bit 15:31 reserved */ | ||
| 27 | |||
| 28 | #define ICM_CFG_mskISET ( 0x7 << ICM_CFG_offISET ) | ||
| 29 | #define ICM_CFG_mskIWAY ( 0x7 << ICM_CFG_offIWAY ) | ||
| 30 | #define ICM_CFG_mskISZ ( 0x7 << ICM_CFG_offISZ ) | ||
| 31 | #define ICM_CFG_mskILCK ( 0x1 << ICM_CFG_offILCK ) | ||
| 32 | #define ICM_CFG_mskILMB ( 0x7 << ICM_CFG_offILMB ) | ||
| 33 | #define ICM_CFG_mskBSAV ( 0x3 << ICM_CFG_offBSAV ) | ||
| 34 | |||
| 35 | /****************************************************************************** | ||
| 36 | * cr2: DCM_CFG (Data Cache/Memory Configuration Register) | ||
| 37 | *****************************************************************************/ | ||
| 38 | #define DCM_CFG_offDSET 0 /* D-cache sets (# of cache lines) per way */ | ||
| 39 | #define DCM_CFG_offDWAY 3 /* D-cache ways */ | ||
| 40 | #define DCM_CFG_offDSZ 6 /* D-cache line size */ | ||
| 41 | #define DCM_CFG_offDLCK 9 /* D-cache locking support */ | ||
| 42 | #define DCM_CFG_offDLMB 10 /* On-chip DLM banks */ | ||
| 43 | #define DCM_CFG_offBSAV 13 /* DLM base register alignment version */ | ||
| 44 | /* bit 15:31 reserved */ | ||
| 45 | |||
| 46 | #define DCM_CFG_mskDSET ( 0x7 << DCM_CFG_offDSET ) | ||
| 47 | #define DCM_CFG_mskDWAY ( 0x7 << DCM_CFG_offDWAY ) | ||
| 48 | #define DCM_CFG_mskDSZ ( 0x7 << DCM_CFG_offDSZ ) | ||
| 49 | #define DCM_CFG_mskDLCK ( 0x1 << DCM_CFG_offDLCK ) | ||
| 50 | #define DCM_CFG_mskDLMB ( 0x7 << DCM_CFG_offDLMB ) | ||
| 51 | #define DCM_CFG_mskBSAV ( 0x3 << DCM_CFG_offBSAV ) | ||
| 52 | |||
| 53 | /****************************************************************************** | ||
| 54 | * cr3: MMU_CFG (MMU Configuration Register) | ||
| 55 | *****************************************************************************/ | ||
| 56 | #define MMU_CFG_offMMPS 0 /* Memory management protection scheme */ | ||
| 57 | #define MMU_CFG_offMMPV 2 /* Memory management protection version number */ | ||
| 58 | #define MMU_CFG_offFATB 7 /* Fully-associative or non-fully-associative TLB */ | ||
| 59 | |||
| 60 | #define MMU_CFG_offTBW 8 /* TLB ways(non-associative) TBS */ | ||
| 61 | #define MMU_CFG_offTBS 11 /* TLB sets per way(non-associative) TBS */ | ||
| 62 | /* bit 14:14 reserved */ | ||
| 63 | |||
| 64 | #define MMU_CFG_offEP8MIN4 15 /* 8KB page supported while minimum page is 4KB */ | ||
| 65 | #define MMU_CFG_offfEPSZ 16 /* Extra page size supported */ | ||
| 66 | #define MMU_CFG_offTLBLCK 24 /* TLB locking support */ | ||
| 67 | #define MMU_CFG_offHPTWK 25 /* Hardware Page Table Walker implemented */ | ||
| 68 | #define MMU_CFG_offDE 26 /* Default endian */ | ||
| 69 | #define MMU_CFG_offNTPT 27 /* Partitions for non-translated attributes */ | ||
| 70 | #define MMU_CFG_offIVTB 28 /* Invisible TLB */ | ||
| 71 | #define MMU_CFG_offVLPT 29 /* VLPT for fast TLB fill handling implemented */ | ||
| 72 | #define MMU_CFG_offNTME 30 /* Non-translated VA to PA mapping */ | ||
| 73 | /* bit 31 reserved */ | ||
| 74 | |||
| 75 | #define MMU_CFG_mskMMPS ( 0x3 << MMU_CFG_offMMPS ) | ||
| 76 | #define MMU_CFG_mskMMPV ( 0x1F << MMU_CFG_offMMPV ) | ||
| 77 | #define MMU_CFG_mskFATB ( 0x1 << MMU_CFG_offFATB ) | ||
| 78 | #define MMU_CFG_mskTBW ( 0x7 << MMU_CFG_offTBW ) | ||
| 79 | #define MMU_CFG_mskTBS ( 0x7 << MMU_CFG_offTBS ) | ||
| 80 | #define MMU_CFG_mskEP8MIN4 ( 0x1 << MMU_CFG_offEP8MIN4 ) | ||
| 81 | #define MMU_CFG_mskfEPSZ ( 0xFF << MMU_CFG_offfEPSZ ) | ||
| 82 | #define MMU_CFG_mskTLBLCK ( 0x1 << MMU_CFG_offTLBLCK ) | ||
| 83 | #define MMU_CFG_mskHPTWK ( 0x1 << MMU_CFG_offHPTWK ) | ||
| 84 | #define MMU_CFG_mskDE ( 0x1 << MMU_CFG_offDE ) | ||
| 85 | #define MMU_CFG_mskNTPT ( 0x1 << MMU_CFG_offNTPT ) | ||
| 86 | #define MMU_CFG_mskIVTB ( 0x1 << MMU_CFG_offIVTB ) | ||
| 87 | #define MMU_CFG_mskVLPT ( 0x1 << MMU_CFG_offVLPT ) | ||
| 88 | #define MMU_CFG_mskNTME ( 0x1 << MMU_CFG_offNTME ) | ||
| 89 | |||
| 90 | /****************************************************************************** | ||
| 91 | * cr4: MSC_CFG (Misc Configuration Register) | ||
| 92 | *****************************************************************************/ | ||
| 93 | #define MSC_CFG_offEDM 0 | ||
| 94 | #define MSC_CFG_offLMDMA 1 | ||
| 95 | #define MSC_CFG_offPFM 2 | ||
| 96 | #define MSC_CFG_offHSMP 3 | ||
| 97 | #define MSC_CFG_offTRACE 4 | ||
| 98 | #define MSC_CFG_offDIV 5 | ||
| 99 | #define MSC_CFG_offMAC 6 | ||
| 100 | #define MSC_CFG_offAUDIO 7 | ||
| 101 | #define MSC_CFG_offL2C 9 | ||
| 102 | #define MSC_CFG_offRDREG 10 | ||
| 103 | #define MSC_CFG_offADR24 11 | ||
| 104 | #define MSC_CFG_offINTLC 12 | ||
| 105 | #define MSC_CFG_offBASEV 13 | ||
| 106 | #define MSC_CFG_offNOD 16 | ||
| 107 | /* bit 13:31 reserved */ | ||
| 108 | |||
| 109 | #define MSC_CFG_mskEDM ( 0x1 << MSC_CFG_offEDM ) | ||
| 110 | #define MSC_CFG_mskLMDMA ( 0x1 << MSC_CFG_offLMDMA ) | ||
| 111 | #define MSC_CFG_mskPFM ( 0x1 << MSC_CFG_offPFM ) | ||
| 112 | #define MSC_CFG_mskHSMP ( 0x1 << MSC_CFG_offHSMP ) | ||
| 113 | #define MSC_CFG_mskTRACE ( 0x1 << MSC_CFG_offTRACE ) | ||
| 114 | #define MSC_CFG_mskDIV ( 0x1 << MSC_CFG_offDIV ) | ||
| 115 | #define MSC_CFG_mskMAC ( 0x1 << MSC_CFG_offMAC ) | ||
| 116 | #define MSC_CFG_mskAUDIO ( 0x3 << MSC_CFG_offAUDIO ) | ||
| 117 | #define MSC_CFG_mskL2C ( 0x1 << MSC_CFG_offL2C ) | ||
| 118 | #define MSC_CFG_mskRDREG ( 0x1 << MSC_CFG_offRDREG ) | ||
| 119 | #define MSC_CFG_mskADR24 ( 0x1 << MSC_CFG_offADR24 ) | ||
| 120 | #define MSC_CFG_mskINTLC ( 0x1 << MSC_CFG_offINTLC ) | ||
| 121 | #define MSC_CFG_mskBASEV ( 0x7 << MSC_CFG_offBASEV ) | ||
| 122 | #define MSC_CFG_mskNOD ( 0x1 << MSC_CFG_offNOD ) | ||
| 123 | |||
| 124 | /****************************************************************************** | ||
| 125 | * cr5: CORE_CFG (Core Identification Register) | ||
| 126 | *****************************************************************************/ | ||
| 127 | #define CORE_ID_offCOREID 0 | ||
| 128 | /* bit 4:31 reserved */ | ||
| 129 | |||
| 130 | #define CORE_ID_mskCOREID ( 0xF << CORE_ID_offCOREID ) | ||
| 131 | |||
| 132 | /****************************************************************************** | ||
| 133 | * cr6: FUCOP_EXIST (FPU and Coprocessor Existence Configuration Register) | ||
| 134 | *****************************************************************************/ | ||
| 135 | #define FUCOP_EXIST_offCP0EX 0 | ||
| 136 | #define FUCOP_EXIST_offCP1EX 1 | ||
| 137 | #define FUCOP_EXIST_offCP2EX 2 | ||
| 138 | #define FUCOP_EXIST_offCP3EX 3 | ||
| 139 | #define FUCOP_EXIST_offCP0ISFPU 31 | ||
| 140 | |||
| 141 | #define FUCOP_EXIST_mskCP0EX ( 0x1 << FUCOP_EXIST_offCP0EX ) | ||
| 142 | #define FUCOP_EXIST_mskCP1EX ( 0x1 << FUCOP_EXIST_offCP1EX ) | ||
| 143 | #define FUCOP_EXIST_mskCP2EX ( 0x1 << FUCOP_EXIST_offCP2EX ) | ||
| 144 | #define FUCOP_EXIST_mskCP3EX ( 0x1 << FUCOP_EXIST_offCP3EX ) | ||
| 145 | #define FUCOP_EXIST_mskCP0ISFPU ( 0x1 << FUCOP_EXIST_offCP0ISFPU ) | ||
| 146 | |||
| 147 | /****************************************************************************** | ||
| 148 | * ir0: PSW (Processor Status Word Register) | ||
| 149 | * ir1: IPSW (Interruption PSW Register) | ||
| 150 | * ir2: P_IPSW (Previous IPSW Register) | ||
| 151 | *****************************************************************************/ | ||
| 152 | #define PSW_offGIE 0 /* Global Interrupt Enable */ | ||
| 153 | #define PSW_offINTL 1 /* Interruption Stack Level */ | ||
| 154 | #define PSW_offPOM 3 /* Processor Operation Mode, User/Superuser */ | ||
| 155 | #define PSW_offBE 5 /* Endianness for data memory access, 1:MSB, 0:LSB */ | ||
| 156 | #define PSW_offIT 6 /* Enable instruction address translation */ | ||
| 157 | #define PSW_offDT 7 /* Enable data address translation */ | ||
| 158 | #define PSW_offIME 8 /* Instruction Machine Error flag */ | ||
| 159 | #define PSW_offDME 9 /* Data Machine Error flag */ | ||
| 160 | #define PSW_offDEX 10 /* Debug Exception */ | ||
| 161 | #define PSW_offHSS 11 /* Hardware Single Stepping */ | ||
| 162 | #define PSW_offDRBE 12 /* Device Register Endian Mode */ | ||
| 163 | #define PSW_offAEN 13 /* Audio ISA special feature */ | ||
| 164 | #define PSW_offWBNA 14 /* Write Back Non-Allocate */ | ||
| 165 | #define PSW_offIFCON 15 /* IFC On */ | ||
| 166 | #define PSW_offCPL 16 /* Current Priority Level */ | ||
| 167 | /* bit 19:31 reserved */ | ||
| 168 | |||
| 169 | #define PSW_mskGIE ( 0x1 << PSW_offGIE ) | ||
| 170 | #define PSW_mskINTL ( 0x3 << PSW_offINTL ) | ||
| 171 | #define PSW_mskPOM ( 0x3 << PSW_offPOM ) | ||
| 172 | #define PSW_mskBE ( 0x1 << PSW_offBE ) | ||
| 173 | #define PSW_mskIT ( 0x1 << PSW_offIT ) | ||
| 174 | #define PSW_mskDT ( 0x1 << PSW_offDT ) | ||
| 175 | #define PSW_mskIME ( 0x1 << PSW_offIME ) | ||
| 176 | #define PSW_mskDME ( 0x1 << PSW_offDME ) | ||
| 177 | #define PSW_mskDEX ( 0x1 << PSW_offDEX ) | ||
| 178 | #define PSW_mskHSS ( 0x1 << PSW_offHSS ) | ||
| 179 | #define PSW_mskDRBE ( 0x1 << PSW_offDRBE ) | ||
| 180 | #define PSW_mskAEN ( 0x1 << PSW_offAEN ) | ||
| 181 | #define PSW_mskWBNA ( 0x1 << PSW_offWBNA ) | ||
| 182 | #define PSW_mskIFCON ( 0x1 << PSW_offIFCON ) | ||
| 183 | #define PSW_mskCPL ( 0x7 << PSW_offCPL ) | ||
| 184 | |||
| 185 | #define PSW_SYSTEM ( 1 << PSW_offPOM ) | ||
| 186 | #define PSW_INTL_1 ( 1 << PSW_offINTL ) | ||
| 187 | #define PSW_CPL_NO ( 0 << PSW_offCPL ) | ||
| 188 | #define PSW_CPL_ANY ( 7 << PSW_offCPL ) | ||
| 189 | |||
| 190 | #define PSW_clr (PSW_mskGIE|PSW_mskINTL|PSW_mskPOM|PSW_mskIT|PSW_mskDT|PSW_mskIME|PSW_mskWBNA) | ||
| 191 | #ifdef __NDS32_EB__ | ||
| 192 | #ifdef CONFIG_WBNA | ||
| 193 | #define PSW_init (PSW_mskWBNA|(1<<PSW_offINTL)|(1<<PSW_offPOM)|PSW_mskIT|PSW_mskDT|PSW_mskBE) | ||
| 194 | #else | ||
| 195 | #define PSW_init ((1<<PSW_offINTL)|(1<<PSW_offPOM)|PSW_mskIT|PSW_mskDT|PSW_mskBE) | ||
| 196 | #endif | ||
| 197 | #else | ||
| 198 | #ifdef CONFIG_WBNA | ||
| 199 | #define PSW_init (PSW_mskWBNA|(1<<PSW_offINTL)|(1<<PSW_offPOM)|PSW_mskIT|PSW_mskDT) | ||
| 200 | #else | ||
| 201 | #define PSW_init ((1<<PSW_offINTL)|(1<<PSW_offPOM)|PSW_mskIT|PSW_mskDT) | ||
| 202 | #endif | ||
| 203 | #endif | ||
| 204 | /****************************************************************************** | ||
| 205 | * ir3: IVB (Interruption Vector Base Register) | ||
| 206 | *****************************************************************************/ | ||
| 207 | /* bit 0:12 reserved */ | ||
| 208 | #define IVB_offNIVIC 1 /* Number of input for IVIC Controller */ | ||
| 209 | #define IVB_offIVIC_VER 11 /* IVIC Version */ | ||
| 210 | #define IVB_offEVIC 13 /* External Vector Interrupt Controller mode */ | ||
| 211 | #define IVB_offESZ 14 /* Size of each vector entry */ | ||
| 212 | #define IVB_offIVBASE 16 /* BasePA of interrupt vector table */ | ||
| 213 | |||
| 214 | #define IVB_mskNIVIC ( 0x7 << IVB_offNIVIC ) | ||
| 215 | #define IVB_mskIVIC_VER ( 0x3 << IVB_offIVIC_VER ) | ||
| 216 | #define IVB_mskEVIC ( 0x1 << IVB_offEVIC ) | ||
| 217 | #define IVB_mskESZ ( 0x3 << IVB_offESZ ) | ||
| 218 | #define IVB_mskIVBASE ( 0xFFFF << IVB_offIVBASE ) | ||
| 219 | |||
| 220 | #define IVB_valESZ4 0 | ||
| 221 | #define IVB_valESZ16 1 | ||
| 222 | #define IVB_valESZ64 2 | ||
| 223 | #define IVB_valESZ256 3 | ||
| 224 | /****************************************************************************** | ||
| 225 | * ir4: EVA (Exception Virtual Address Register) | ||
| 226 | * ir5: P_EVA (Previous EVA Register) | ||
| 227 | *****************************************************************************/ | ||
| 228 | |||
| 229 | /* This register contains the VA that causes the exception */ | ||
| 230 | |||
| 231 | /****************************************************************************** | ||
| 232 | * ir6: ITYPE (Interruption Type Register) | ||
| 233 | * ir7: P_ITYPE (Previous ITYPE Register) | ||
| 234 | *****************************************************************************/ | ||
| 235 | #define ITYPE_offETYPE 0 /* Exception Type */ | ||
| 236 | #define ITYPE_offINST 4 /* Exception caused by insn fetch or data access */ | ||
| 237 | /* bit 5:15 reserved */ | ||
| 238 | #define ITYPE_offVECTOR 5 /* Vector */ | ||
| 239 | #define ITYPE_offSWID 16 /* SWID of debugging exception */ | ||
| 240 | /* bit 31:31 reserved */ | ||
| 241 | |||
| 242 | #define ITYPE_mskETYPE ( 0xF << ITYPE_offETYPE ) | ||
| 243 | #define ITYPE_mskINST ( 0x1 << ITYPE_offINST ) | ||
| 244 | #define ITYPE_mskVECTOR ( 0x7F << ITYPE_offVECTOR ) | ||
| 245 | #define ITYPE_mskSWID ( 0x7FFF << ITYPE_offSWID ) | ||
| 246 | |||
| 247 | /* Additional definitions for ITYPE register */ | ||
| 248 | #define ITYPE_offSTYPE 16 /* Arithmetic Sub Type */ | ||
| 249 | #define ITYPE_offCPID 20 /* Co-Processor ID which generate the exception */ | ||
| 250 | |||
| 251 | #define ITYPE_mskSTYPE ( 0xF << ITYPE_offSTYPE ) | ||
| 252 | #define ITYPE_mskCPID ( 0x3 << ITYPE_offCPID ) | ||
| 253 | |||
| 254 | #define NDS32_VECTOR_mskNONEXCEPTION 0x78 | ||
| 255 | #define NDS32_VECTOR_offEXCEPTION 8 | ||
| 256 | #define NDS32_VECTOR_offINTERRUPT 9 | ||
| 257 | |||
| 258 | /* Interrupt vector entry */ | ||
| 259 | #define ENTRY_RESET_NMI 0 | ||
| 260 | #define ENTRY_TLB_FILL 1 | ||
| 261 | #define ENTRY_PTE_NOT_PRESENT 2 | ||
| 262 | #define ENTRY_TLB_MISC 3 | ||
| 263 | #define ENTRY_TLB_VLPT_MISS 4 | ||
| 264 | #define ENTRY_MACHINE_ERROR 5 | ||
| 265 | #define ENTRY_DEBUG_RELATED 6 | ||
| 266 | #define ENTRY_GENERAL_EXCPETION 7 | ||
| 267 | #define ENTRY_SYSCALL 8 | ||
| 268 | |||
| 269 | /* PTE not present exception definition */ | ||
| 270 | #define ETYPE_NON_LEAF_PTE_NOT_PRESENT 0 | ||
| 271 | #define ETYPE_LEAF_PTE_NOT_PRESENT 1 | ||
| 272 | |||
| 273 | /* General exception ETYPE definition */ | ||
| 274 | #define ETYPE_ALIGNMENT_CHECK 0 | ||
| 275 | #define ETYPE_RESERVED_INSTRUCTION 1 | ||
| 276 | #define ETYPE_TRAP 2 | ||
| 277 | #define ETYPE_ARITHMETIC 3 | ||
| 278 | #define ETYPE_PRECISE_BUS_ERROR 4 | ||
| 279 | #define ETYPE_IMPRECISE_BUS_ERROR 5 | ||
| 280 | #define ETYPE_COPROCESSOR 6 | ||
| 281 | #define ETYPE_RESERVED_VALUE 7 | ||
| 282 | #define ETYPE_NONEXISTENT_MEM_ADDRESS 8 | ||
| 283 | #define ETYPE_MPZIU_CONTROL 9 | ||
| 284 | #define ETYPE_NEXT_PRECISE_STACK_OFL 10 | ||
| 285 | |||
| 286 | /* Kerenl reserves software ID */ | ||
| 287 | #define SWID_RAISE_INTERRUPT_LEVEL 0x1a /* SWID_RAISE_INTERRUPT_LEVEL is used to | ||
| 288 | * raise interrupt level for debug exception | ||
| 289 | */ | ||
| 290 | |||
| 291 | /****************************************************************************** | ||
| 292 | * ir8: MERR (Machine Error Log Register) | ||
| 293 | *****************************************************************************/ | ||
| 294 | /* bit 0:30 reserved */ | ||
| 295 | #define MERR_offBUSERR 31 /* Bus error caused by a load insn */ | ||
| 296 | |||
| 297 | #define MERR_mskBUSERR ( 0x1 << MERR_offBUSERR ) | ||
| 298 | |||
| 299 | /****************************************************************************** | ||
| 300 | * ir9: IPC (Interruption Program Counter Register) | ||
| 301 | * ir10: P_IPC (Previous IPC Register) | ||
| 302 | * ir11: OIPC (Overflow Interruption Program Counter Register) | ||
| 303 | *****************************************************************************/ | ||
| 304 | |||
| 305 | /* This is the shadow stack register of the Program Counter */ | ||
| 306 | |||
| 307 | /****************************************************************************** | ||
| 308 | * ir12: P_P0 (Previous P0 Register) | ||
| 309 | * ir13: P_P1 (Previous P1 Register) | ||
| 310 | *****************************************************************************/ | ||
| 311 | |||
| 312 | /* These are shadow registers of $p0 and $p1 */ | ||
| 313 | |||
| 314 | /****************************************************************************** | ||
| 315 | * ir14: INT_MASK (Interruption Masking Register) | ||
| 316 | *****************************************************************************/ | ||
| 317 | #define INT_MASK_offH0IM 0 /* Hardware Interrupt 0 Mask bit */ | ||
| 318 | #define INT_MASK_offH1IM 1 /* Hardware Interrupt 1 Mask bit */ | ||
| 319 | #define INT_MASK_offH2IM 2 /* Hardware Interrupt 2 Mask bit */ | ||
| 320 | #define INT_MASK_offH3IM 3 /* Hardware Interrupt 3 Mask bit */ | ||
| 321 | #define INT_MASK_offH4IM 4 /* Hardware Interrupt 4 Mask bit */ | ||
| 322 | #define INT_MASK_offH5IM 5 /* Hardware Interrupt 5 Mask bit */ | ||
| 323 | /* bit 6:15 reserved */ | ||
| 324 | #define INT_MASK_offSIM 16 /* Software Interrupt Mask bit */ | ||
| 325 | /* bit 17:29 reserved */ | ||
| 326 | #define INT_MASK_offIDIVZE 30 /* Enable detection for Divide-By-Zero */ | ||
| 327 | #define INT_MASK_offDSSIM 31 /* Default Single Stepping Interruption Mask */ | ||
| 328 | |||
| 329 | #define INT_MASK_mskH0IM ( 0x1 << INT_MASK_offH0IM ) | ||
| 330 | #define INT_MASK_mskH1IM ( 0x1 << INT_MASK_offH1IM ) | ||
| 331 | #define INT_MASK_mskH2IM ( 0x1 << INT_MASK_offH2IM ) | ||
| 332 | #define INT_MASK_mskH3IM ( 0x1 << INT_MASK_offH3IM ) | ||
| 333 | #define INT_MASK_mskH4IM ( 0x1 << INT_MASK_offH4IM ) | ||
| 334 | #define INT_MASK_mskH5IM ( 0x1 << INT_MASK_offH5IM ) | ||
| 335 | #define INT_MASK_mskSIM ( 0x1 << INT_MASK_offSIM ) | ||
| 336 | #define INT_MASK_mskIDIVZE ( 0x1 << INT_MASK_offIDIVZE ) | ||
| 337 | #define INT_MASK_mskDSSIM ( 0x1 << INT_MASK_offDSSIM ) | ||
| 338 | |||
| 339 | #define INT_MASK_INITAIAL_VAL 0x10003 | ||
| 340 | |||
| 341 | /****************************************************************************** | ||
| 342 | * ir15: INT_PEND (Interrupt Pending Register) | ||
| 343 | *****************************************************************************/ | ||
| 344 | #define INT_PEND_offH0I 0 /* Hardware Interrupt 0 pending bit */ | ||
| 345 | #define INT_PEND_offH1I 1 /* Hardware Interrupt 1 pending bit */ | ||
| 346 | #define INT_PEND_offH2I 2 /* Hardware Interrupt 2 pending bit */ | ||
| 347 | #define INT_PEND_offH3I 3 /* Hardware Interrupt 3 pending bit */ | ||
| 348 | #define INT_PEND_offH4I 4 /* Hardware Interrupt 4 pending bit */ | ||
| 349 | #define INT_PEND_offH5I 5 /* Hardware Interrupt 5 pending bit */ | ||
| 350 | |||
| 351 | #define INT_PEND_offCIPL 0 /* Current Interrupt Priority Level */ | ||
| 352 | |||
| 353 | /* bit 6:15 reserved */ | ||
| 354 | #define INT_PEND_offSWI 16 /* Software Interrupt pending bit */ | ||
| 355 | /* bit 17:31 reserved */ | ||
| 356 | |||
| 357 | #define INT_PEND_mskH0I ( 0x1 << INT_PEND_offH0I ) | ||
| 358 | #define INT_PEND_mskH1I ( 0x1 << INT_PEND_offH1I ) | ||
| 359 | #define INT_PEND_mskH2I ( 0x1 << INT_PEND_offH2I ) | ||
| 360 | #define INT_PEND_mskH3I ( 0x1 << INT_PEND_offH3I ) | ||
| 361 | #define INT_PEND_mskH4I ( 0x1 << INT_PEND_offH4I ) | ||
| 362 | #define INT_PEND_mskH5I ( 0x1 << INT_PEND_offH5I ) | ||
| 363 | #define INT_PEND_mskCIPL ( 0x1 << INT_PEND_offCIPL ) | ||
| 364 | #define INT_PEND_mskSWI ( 0x1 << INT_PEND_offSWI ) | ||
| 365 | |||
| 366 | /****************************************************************************** | ||
| 367 | * mr0: MMU_CTL (MMU Control Register) | ||
| 368 | *****************************************************************************/ | ||
| 369 | #define MMU_CTL_offD 0 /* Default minimum page size */ | ||
| 370 | #define MMU_CTL_offNTC0 1 /* Non-Translated Cachebility of partition 0 */ | ||
| 371 | #define MMU_CTL_offNTC1 3 /* Non-Translated Cachebility of partition 1 */ | ||
| 372 | #define MMU_CTL_offNTC2 5 /* Non-Translated Cachebility of partition 2 */ | ||
| 373 | #define MMU_CTL_offNTC3 7 /* Non-Translated Cachebility of partition 3 */ | ||
| 374 | #define MMU_CTL_offTBALCK 9 /* TLB all-lock resolution scheme */ | ||
| 375 | #define MMU_CTL_offMPZIU 10 /* Multiple Page Size In Use bit */ | ||
| 376 | #define MMU_CTL_offNTM0 11 /* Non-Translated VA to PA of partition 0 */ | ||
| 377 | #define MMU_CTL_offNTM1 13 /* Non-Translated VA to PA of partition 1 */ | ||
| 378 | #define MMU_CTL_offNTM2 15 /* Non-Translated VA to PA of partition 2 */ | ||
| 379 | #define MMU_CTL_offNTM3 17 /* Non-Translated VA to PA of partition 3 */ | ||
| 380 | #define MMU_CTL_offUNA 23 /* Unaligned access */ | ||
| 381 | /* bit 24:31 reserved */ | ||
| 382 | |||
| 383 | #define MMU_CTL_mskD ( 0x1 << MMU_CTL_offD ) | ||
| 384 | #define MMU_CTL_mskNTC0 ( 0x3 << MMU_CTL_offNTC0 ) | ||
| 385 | #define MMU_CTL_mskNTC1 ( 0x3 << MMU_CTL_offNTC1 ) | ||
| 386 | #define MMU_CTL_mskNTC2 ( 0x3 << MMU_CTL_offNTC2 ) | ||
| 387 | #define MMU_CTL_mskNTC3 ( 0x3 << MMU_CTL_offNTC3 ) | ||
| 388 | #define MMU_CTL_mskTBALCK ( 0x1 << MMU_CTL_offTBALCK ) | ||
| 389 | #define MMU_CTL_mskMPZIU ( 0x1 << MMU_CTL_offMPZIU ) | ||
| 390 | #define MMU_CTL_mskNTM0 ( 0x3 << MMU_CTL_offNTM0 ) | ||
| 391 | #define MMU_CTL_mskNTM1 ( 0x3 << MMU_CTL_offNTM1 ) | ||
| 392 | #define MMU_CTL_mskNTM2 ( 0x3 << MMU_CTL_offNTM2 ) | ||
| 393 | #define MMU_CTL_mskNTM3 ( 0x3 << MMU_CTL_offNTM3 ) | ||
| 394 | |||
| 395 | #define MMU_CTL_D4KB 0 | ||
| 396 | #define MMU_CTL_D8KB 1 | ||
| 397 | #define MMU_CTL_UNA ( 0x1 << MMU_CTL_offUNA ) | ||
| 398 | |||
| 399 | #define MMU_CTL_CACHEABLE_WB 2 | ||
| 400 | #define MMU_CTL_CACHEABLE_WT 3 | ||
| 401 | |||
| 402 | /****************************************************************************** | ||
| 403 | * mr1: L1_PPTB (L1 Physical Page Table Base Register) | ||
| 404 | *****************************************************************************/ | ||
| 405 | #define L1_PPTB_offNV 0 /* Enable Hardware Page Table Walker (HPTWK) */ | ||
| 406 | /* bit 1:11 reserved */ | ||
| 407 | #define L1_PPTB_offBASE 12 /* First level physical page table base address */ | ||
| 408 | |||
| 409 | #define L1_PPTB_mskNV ( 0x1 << L1_PPTB_offNV ) | ||
| 410 | #define L1_PPTB_mskBASE ( 0xFFFFF << L1_PPTB_offBASE ) | ||
| 411 | |||
| 412 | /****************************************************************************** | ||
| 413 | * mr2: TLB_VPN (TLB Access VPN Register) | ||
| 414 | *****************************************************************************/ | ||
| 415 | /* bit 0:11 reserved */ | ||
| 416 | #define TLB_VPN_offVPN 12 /* Virtual Page Number */ | ||
| 417 | |||
| 418 | #define TLB_VPN_mskVPN ( 0xFFFFF << TLB_VPN_offVPN ) | ||
| 419 | |||
| 420 | /****************************************************************************** | ||
| 421 | * mr3: TLB_DATA (TLB Access Data Register) | ||
| 422 | *****************************************************************************/ | ||
| 423 | #define TLB_DATA_offV 0 /* PTE is valid and present */ | ||
| 424 | #define TLB_DATA_offM 1 /* Page read/write access privilege */ | ||
| 425 | #define TLB_DATA_offD 4 /* Dirty bit */ | ||
| 426 | #define TLB_DATA_offX 5 /* Executable bit */ | ||
| 427 | #define TLB_DATA_offA 6 /* Access bit */ | ||
| 428 | #define TLB_DATA_offG 7 /* Global page (shared across contexts) */ | ||
| 429 | #define TLB_DATA_offC 8 /* Cacheability atribute */ | ||
| 430 | /* bit 11:11 reserved */ | ||
| 431 | #define TLB_DATA_offPPN 12 /* Phisical Page Number */ | ||
| 432 | |||
| 433 | #define TLB_DATA_mskV ( 0x1 << TLB_DATA_offV ) | ||
| 434 | #define TLB_DATA_mskM ( 0x7 << TLB_DATA_offM ) | ||
| 435 | #define TLB_DATA_mskD ( 0x1 << TLB_DATA_offD ) | ||
| 436 | #define TLB_DATA_mskX ( 0x1 << TLB_DATA_offX ) | ||
| 437 | #define TLB_DATA_mskA ( 0x1 << TLB_DATA_offA ) | ||
| 438 | #define TLB_DATA_mskG ( 0x1 << TLB_DATA_offG ) | ||
| 439 | #define TLB_DATA_mskC ( 0x7 << TLB_DATA_offC ) | ||
| 440 | #define TLB_DATA_mskPPN ( 0xFFFFF << TLB_DATA_offPPN ) | ||
| 441 | |||
| 442 | #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH | ||
| 443 | #define TLB_DATA_kernel_text_attr (TLB_DATA_mskV|TLB_DATA_mskM|TLB_DATA_mskD|TLB_DATA_mskX|TLB_DATA_mskG|TLB_DATA_mskC) | ||
| 444 | #else | ||
| 445 | #define TLB_DATA_kernel_text_attr (TLB_DATA_mskV|TLB_DATA_mskM|TLB_DATA_mskD|TLB_DATA_mskX|TLB_DATA_mskG|(0x6 << TLB_DATA_offC)) | ||
| 446 | #endif | ||
| 447 | |||
| 448 | /****************************************************************************** | ||
| 449 | * mr4: TLB_MISC (TLB Access Misc Register) | ||
| 450 | *****************************************************************************/ | ||
| 451 | #define TLB_MISC_offACC_PSZ 0 /* Page size of a PTE entry */ | ||
| 452 | #define TLB_MISC_offCID 4 /* Context id */ | ||
| 453 | /* bit 13:31 reserved */ | ||
| 454 | |||
| 455 | #define TLB_MISC_mskACC_PSZ ( 0xF << TLB_MISC_offACC_PSZ ) | ||
| 456 | #define TLB_MISC_mskCID ( 0x1FF << TLB_MISC_offCID ) | ||
| 457 | |||
| 458 | /****************************************************************************** | ||
| 459 | * mr5: VLPT_IDX (Virtual Linear Page Table Index Register) | ||
| 460 | *****************************************************************************/ | ||
| 461 | #define VLPT_IDX_offZERO 0 /* Always 0 */ | ||
| 462 | #define VLPT_IDX_offEVPN 2 /* Exception Virtual Page Number */ | ||
| 463 | #define VLPT_IDX_offVLPTB 22 /* Base VA of VLPT */ | ||
| 464 | |||
| 465 | #define VLPT_IDX_mskZERO ( 0x3 << VLPT_IDX_offZERO ) | ||
| 466 | #define VLPT_IDX_mskEVPN ( 0xFFFFF << VLPT_IDX_offEVPN ) | ||
| 467 | #define VLPT_IDX_mskVLPTB ( 0x3FF << VLPT_IDX_offVLPTB ) | ||
| 468 | |||
| 469 | /****************************************************************************** | ||
| 470 | * mr6: ILMB (Instruction Local Memory Base Register) | ||
| 471 | *****************************************************************************/ | ||
| 472 | #define ILMB_offIEN 0 /* Enable ILM */ | ||
| 473 | #define ILMB_offILMSZ 1 /* Size of ILM */ | ||
| 474 | /* bit 5:19 reserved */ | ||
| 475 | #define ILMB_offIBPA 20 /* Base PA of ILM */ | ||
| 476 | |||
| 477 | #define ILMB_mskIEN ( 0x1 << ILMB_offIEN ) | ||
| 478 | #define ILMB_mskILMSZ ( 0xF << ILMB_offILMSZ ) | ||
| 479 | #define ILMB_mskIBPA ( 0xFFF << ILMB_offIBPA ) | ||
| 480 | |||
| 481 | /****************************************************************************** | ||
| 482 | * mr7: DLMB (Data Local Memory Base Register) | ||
| 483 | *****************************************************************************/ | ||
| 484 | #define DLMB_offDEN 0 /* Enable DLM */ | ||
| 485 | #define DLMB_offDLMSZ 1 /* Size of DLM */ | ||
| 486 | #define DLMB_offDBM 5 /* Enable Double-Buffer Mode for DLM */ | ||
| 487 | #define DLMB_offDBB 6 /* Double-buffer bank which can be accessed by the processor */ | ||
| 488 | /* bit 7:19 reserved */ | ||
| 489 | #define DLMB_offDBPA 20 /* Base PA of DLM */ | ||
| 490 | |||
| 491 | #define DLMB_mskDEN ( 0x1 << DLMB_offDEN ) | ||
| 492 | #define DLMB_mskDLMSZ ( 0xF << DLMB_offDLMSZ ) | ||
| 493 | #define DLMB_mskDBM ( 0x1 << DLMB_offDBM ) | ||
| 494 | #define DLMB_mskDBB ( 0x1 << DLMB_offDBB ) | ||
| 495 | #define DLMB_mskDBPA ( 0xFFF << DLMB_offDBPA ) | ||
| 496 | |||
| 497 | /****************************************************************************** | ||
| 498 | * mr8: CACHE_CTL (Cache Control Register) | ||
| 499 | *****************************************************************************/ | ||
| 500 | #define CACHE_CTL_offIC_EN 0 /* Enable I-cache */ | ||
| 501 | #define CACHE_CTL_offDC_EN 1 /* Enable D-cache */ | ||
| 502 | #define CACHE_CTL_offICALCK 2 /* I-cache all-lock resolution scheme */ | ||
| 503 | #define CACHE_CTL_offDCALCK 3 /* D-cache all-lock resolution scheme */ | ||
| 504 | #define CACHE_CTL_offDCCWF 4 /* Enable D-cache Critical Word Forwarding */ | ||
| 505 | #define CACHE_CTL_offDCPMW 5 /* Enable D-cache concurrent miss and write-back processing */ | ||
| 506 | /* bit 6:31 reserved */ | ||
| 507 | |||
| 508 | #define CACHE_CTL_mskIC_EN ( 0x1 << CACHE_CTL_offIC_EN ) | ||
| 509 | #define CACHE_CTL_mskDC_EN ( 0x1 << CACHE_CTL_offDC_EN ) | ||
| 510 | #define CACHE_CTL_mskICALCK ( 0x1 << CACHE_CTL_offICALCK ) | ||
| 511 | #define CACHE_CTL_mskDCALCK ( 0x1 << CACHE_CTL_offDCALCK ) | ||
| 512 | #define CACHE_CTL_mskDCCWF ( 0x1 << CACHE_CTL_offDCCWF ) | ||
| 513 | #define CACHE_CTL_mskDCPMW ( 0x1 << CACHE_CTL_offDCPMW ) | ||
| 514 | |||
| 515 | /****************************************************************************** | ||
| 516 | * mr9: HSMP_SADDR (High Speed Memory Port Starting Address) | ||
| 517 | *****************************************************************************/ | ||
| 518 | #define HSMP_SADDR_offEN 0 /* Enable control bit for the High Speed Memory port */ | ||
| 519 | /* bit 1:19 reserved */ | ||
| 520 | |||
| 521 | #define HSMP_SADDR_offRANGE 1 /* Denote the address range (only defined in HSMP v2 ) */ | ||
| 522 | #define HSMP_SADDR_offSADDR 20 /* Starting base PA of the High Speed Memory Port region */ | ||
| 523 | |||
| 524 | #define HSMP_SADDR_mskEN ( 0x1 << HSMP_SADDR_offEN ) | ||
| 525 | #define HSMP_SADDR_mskRANGE ( 0xFFF << HSMP_SADDR_offRANGE ) | ||
| 526 | #define HSMP_SADDR_mskSADDR ( 0xFFF << HSMP_SADDR_offSADDR ) | ||
| 527 | |||
| 528 | /****************************************************************************** | ||
| 529 | * mr10: HSMP_EADDR (High Speed Memory Port Ending Address) | ||
| 530 | *****************************************************************************/ | ||
| 531 | /* bit 0:19 reserved */ | ||
| 532 | #define HSMP_EADDR_offEADDR 20 | ||
| 533 | |||
| 534 | #define HSMP_EADDR_mskEADDR ( 0xFFF << HSMP_EADDR_offEADDR ) | ||
| 535 | |||
| 536 | /****************************************************************************** | ||
| 537 | * dr0+(n*5): BPCn (n=0-7) (Breakpoint Control Register) | ||
| 538 | *****************************************************************************/ | ||
| 539 | #define BPC_offWP 0 /* Configuration of BPAn */ | ||
| 540 | #define BPC_offEL 1 /* Enable BPAn */ | ||
| 541 | #define BPC_offS 2 /* Data address comparison for a store instruction */ | ||
| 542 | #define BPC_offP 3 /* Compared data address is PA */ | ||
| 543 | #define BPC_offC 4 /* CID value is compared with the BPCIDn register */ | ||
| 544 | #define BPC_offBE0 5 /* Enable byte mask for the comparison with register */ | ||
| 545 | #define BPC_offBE1 6 /* Enable byte mask for the comparison with register */ | ||
| 546 | #define BPC_offBE2 7 /* Enable byte mask for the comparison with register */ | ||
| 547 | #define BPC_offBE3 8 /* Enable byte mask for the comparison with register */ | ||
| 548 | #define BPC_offT 9 /* Enable breakpoint Embedded Tracer triggering operation */ | ||
| 549 | |||
| 550 | #define BPC_mskWP ( 0x1 << BPC_offWP ) | ||
| 551 | #define BPC_mskEL ( 0x1 << BPC_offEL ) | ||
| 552 | #define BPC_mskS ( 0x1 << BPC_offS ) | ||
| 553 | #define BPC_mskP ( 0x1 << BPC_offP ) | ||
| 554 | #define BPC_mskC ( 0x1 << BPC_offC ) | ||
| 555 | #define BPC_mskBE0 ( 0x1 << BPC_offBE0 ) | ||
| 556 | #define BPC_mskBE1 ( 0x1 << BPC_offBE1 ) | ||
| 557 | #define BPC_mskBE2 ( 0x1 << BPC_offBE2 ) | ||
| 558 | #define BPC_mskBE3 ( 0x1 << BPC_offBE3 ) | ||
| 559 | #define BPC_mskT ( 0x1 << BPC_offT ) | ||
| 560 | |||
| 561 | /****************************************************************************** | ||
| 562 | * dr1+(n*5): BPAn (n=0-7) (Breakpoint Address Register) | ||
| 563 | *****************************************************************************/ | ||
| 564 | |||
| 565 | /* These registers contain break point address */ | ||
| 566 | |||
| 567 | /****************************************************************************** | ||
| 568 | * dr2+(n*5): BPAMn (n=0-7) (Breakpoint Address Mask Register) | ||
| 569 | *****************************************************************************/ | ||
| 570 | |||
| 571 | /* These registerd contain the address comparison mask for the BPAn register */ | ||
| 572 | |||
| 573 | /****************************************************************************** | ||
| 574 | * dr3+(n*5): BPVn (n=0-7) Breakpoint Data Value Register | ||
| 575 | *****************************************************************************/ | ||
| 576 | |||
| 577 | /* The BPVn register contains the data value that will be compared with the | ||
| 578 | * incoming load/store data value */ | ||
| 579 | |||
| 580 | /****************************************************************************** | ||
| 581 | * dr4+(n*5): BPCIDn (n=0-7) (Breakpoint Context ID Register) | ||
| 582 | *****************************************************************************/ | ||
| 583 | #define BPCID_offCID 0 /* CID that will be compared with a process's CID */ | ||
| 584 | /* bit 9:31 reserved */ | ||
| 585 | |||
| 586 | #define BPCID_mskCID ( 0x1FF << BPCID_offCID ) | ||
| 587 | |||
| 588 | /****************************************************************************** | ||
| 589 | * dr40: EDM_CFG (EDM Configuration Register) | ||
| 590 | *****************************************************************************/ | ||
| 591 | #define EDM_CFG_offBC 0 /* Number of hardware breakpoint sets implemented */ | ||
| 592 | #define EDM_CFG_offDIMU 3 /* Debug Instruction Memory Unit exists */ | ||
| 593 | /* bit 4:15 reserved */ | ||
| 594 | #define EDM_CFG_offVER 16 /* EDM version */ | ||
| 595 | |||
| 596 | #define EDM_CFG_mskBC ( 0x7 << EDM_CFG_offBC ) | ||
| 597 | #define EDM_CFG_mskDIMU ( 0x1 << EDM_CFG_offDIMU ) | ||
| 598 | #define EDM_CFG_mskVER ( 0xFFFF << EDM_CFG_offVER ) | ||
| 599 | |||
| 600 | /****************************************************************************** | ||
| 601 | * dr41: EDMSW (EDM Status Word) | ||
| 602 | *****************************************************************************/ | ||
| 603 | #define EDMSW_offWV 0 /* Write Valid */ | ||
| 604 | #define EDMSW_offRV 1 /* Read Valid */ | ||
| 605 | #define EDMSW_offDE 2 /* Debug exception has occurred for this core */ | ||
| 606 | /* bit 3:31 reserved */ | ||
| 607 | |||
| 608 | #define EDMSW_mskWV ( 0x1 << EDMSW_offWV ) | ||
| 609 | #define EDMSW_mskRV ( 0x1 << EDMSW_offRV ) | ||
| 610 | #define EDMSW_mskDE ( 0x1 << EDMSW_offDE ) | ||
| 611 | |||
| 612 | /****************************************************************************** | ||
| 613 | * dr42: EDM_CTL (EDM Control Register) | ||
| 614 | *****************************************************************************/ | ||
| 615 | /* bit 0:30 reserved */ | ||
| 616 | #define EDM_CTL_offV3_EDM_MODE 6 /* EDM compatibility control bit */ | ||
| 617 | #define EDM_CTL_offDEH_SEL 31 /* Controls where debug exception is directed to */ | ||
| 618 | |||
| 619 | #define EDM_CTL_mskV3_EDM_MODE ( 0x1 << EDM_CTL_offV3_EDM_MODE ) | ||
| 620 | #define EDM_CTL_mskDEH_SEL ( 0x1 << EDM_CTL_offDEH_SEL ) | ||
| 621 | |||
| 622 | /****************************************************************************** | ||
| 623 | * dr43: EDM_DTR (EDM Data Transfer Register) | ||
| 624 | *****************************************************************************/ | ||
| 625 | |||
| 626 | /* This is used to exchange data between the embedded EDM logic | ||
| 627 | * and the processor core */ | ||
| 628 | |||
| 629 | /****************************************************************************** | ||
| 630 | * dr44: BPMTC (Breakpoint Match Trigger Counter Register) | ||
| 631 | *****************************************************************************/ | ||
| 632 | #define BPMTC_offBPMTC 0 /* Breakpoint match trigger counter value */ | ||
| 633 | /* bit 16:31 reserved */ | ||
| 634 | |||
| 635 | #define BPMTC_mskBPMTC ( 0xFFFF << BPMTC_offBPMTC ) | ||
| 636 | |||
| 637 | /****************************************************************************** | ||
| 638 | * dr45: DIMBR (Debug Instruction Memory Base Register) | ||
| 639 | *****************************************************************************/ | ||
| 640 | /* bit 0:11 reserved */ | ||
| 641 | #define DIMBR_offDIMB 12 /* Base address of the Debug Instruction Memory (DIM) */ | ||
| 642 | #define DIMBR_mskDIMB ( 0xFFFFF << DIMBR_offDIMB ) | ||
| 643 | |||
| 644 | /****************************************************************************** | ||
| 645 | * dr46: TECR0(Trigger Event Control register 0) | ||
| 646 | * dr47: TECR1 (Trigger Event Control register 1) | ||
| 647 | *****************************************************************************/ | ||
| 648 | #define TECR_offBP 0 /* Controld which BP is used as a trigger source */ | ||
| 649 | #define TECR_offNMI 8 /* Use NMI as a trigger source */ | ||
| 650 | #define TECR_offHWINT 9 /* Corresponding interrupt is used as a trigger source */ | ||
| 651 | #define TECR_offEVIC 15 /* Enable HWINT as a trigger source in EVIC mode */ | ||
| 652 | #define TECR_offSYS 16 /* Enable SYSCALL instruction as a trigger source */ | ||
| 653 | #define TECR_offDBG 17 /* Enable debug exception as a trigger source */ | ||
| 654 | #define TECR_offMRE 18 /* Enable MMU related exception as a trigger source */ | ||
| 655 | #define TECR_offE 19 /* An exception is used as a trigger source */ | ||
| 656 | /* bit 20:30 reserved */ | ||
| 657 | #define TECR_offL 31 /* Link/Cascade TECR0 trigger event to TECR1 trigger event */ | ||
| 658 | |||
| 659 | #define TECR_mskBP ( 0xFF << TECR_offBP ) | ||
| 660 | #define TECR_mskNMI ( 0x1 << TECR_offBNMI ) | ||
| 661 | #define TECR_mskHWINT ( 0x3F << TECR_offBHWINT ) | ||
| 662 | #define TECR_mskEVIC ( 0x1 << TECR_offBEVIC ) | ||
| 663 | #define TECR_mskSYS ( 0x1 << TECR_offBSYS ) | ||
| 664 | #define TECR_mskDBG ( 0x1 << TECR_offBDBG ) | ||
| 665 | #define TECR_mskMRE ( 0x1 << TECR_offBMRE ) | ||
| 666 | #define TECR_mskE ( 0x1 << TECR_offE ) | ||
| 667 | #define TECR_mskL ( 0x1 << TECR_offL ) | ||
| 668 | |||
| 669 | /****************************************************************************** | ||
| 670 | * pfr0-2: PFMC0-2 (Performance Counter Register 0-2) | ||
| 671 | *****************************************************************************/ | ||
| 672 | |||
| 673 | /* These registers contains performance event count */ | ||
| 674 | |||
| 675 | /****************************************************************************** | ||
| 676 | * pfr3: PFM_CTL (Performance Counter Control Register) | ||
| 677 | *****************************************************************************/ | ||
| 678 | #define PFM_CTL_offEN0 0 /* Enable PFMC0 */ | ||
| 679 | #define PFM_CTL_offEN1 1 /* Enable PFMC1 */ | ||
| 680 | #define PFM_CTL_offEN2 2 /* Enable PFMC2 */ | ||
| 681 | #define PFM_CTL_offIE0 3 /* Enable interrupt for PFMC0 */ | ||
| 682 | #define PFM_CTL_offIE1 4 /* Enable interrupt for PFMC1 */ | ||
| 683 | #define PFM_CTL_offIE2 5 /* Enable interrupt for PFMC2 */ | ||
| 684 | #define PFM_CTL_offOVF0 6 /* Overflow bit of PFMC0 */ | ||
| 685 | #define PFM_CTL_offOVF1 7 /* Overflow bit of PFMC1 */ | ||
| 686 | #define PFM_CTL_offOVF2 8 /* Overflow bit of PFMC2 */ | ||
| 687 | #define PFM_CTL_offKS0 9 /* Enable superuser mode event counting for PFMC0 */ | ||
| 688 | #define PFM_CTL_offKS1 10 /* Enable superuser mode event counting for PFMC1 */ | ||
| 689 | #define PFM_CTL_offKS2 11 /* Enable superuser mode event counting for PFMC2 */ | ||
| 690 | #define PFM_CTL_offKU0 12 /* Enable user mode event counting for PFMC0 */ | ||
| 691 | #define PFM_CTL_offKU1 13 /* Enable user mode event counting for PFMC1 */ | ||
| 692 | #define PFM_CTL_offKU2 14 /* Enable user mode event counting for PFMC2 */ | ||
| 693 | #define PFM_CTL_offSEL0 15 /* The event selection for PFMC0 */ | ||
| 694 | #define PFM_CTL_offSEL1 21 /* The event selection for PFMC1 */ | ||
| 695 | #define PFM_CTL_offSEL2 27 /* The event selection for PFMC2 */ | ||
| 696 | /* bit 28:31 reserved */ | ||
| 697 | |||
| 698 | #define PFM_CTL_mskEN0 ( 0x01 << PFM_CTL_offEN0 ) | ||
| 699 | #define PFM_CTL_mskEN1 ( 0x01 << PFM_CTL_offEN1 ) | ||
| 700 | #define PFM_CTL_mskEN2 ( 0x01 << PFM_CTL_offEN2 ) | ||
| 701 | #define PFM_CTL_mskIE0 ( 0x01 << PFM_CTL_offIE0 ) | ||
| 702 | #define PFM_CTL_mskIE1 ( 0x01 << PFM_CTL_offIE1 ) | ||
| 703 | #define PFM_CTL_mskIE2 ( 0x01 << PFM_CTL_offIE2 ) | ||
| 704 | #define PFM_CTL_mskOVF0 ( 0x01 << PFM_CTL_offOVF0 ) | ||
| 705 | #define PFM_CTL_mskOVF1 ( 0x01 << PFM_CTL_offOVF1 ) | ||
| 706 | #define PFM_CTL_mskOVF2 ( 0x01 << PFM_CTL_offOVF2 ) | ||
| 707 | #define PFM_CTL_mskKS0 ( 0x01 << PFM_CTL_offKS0 ) | ||
| 708 | #define PFM_CTL_mskKS1 ( 0x01 << PFM_CTL_offKS1 ) | ||
| 709 | #define PFM_CTL_mskKS2 ( 0x01 << PFM_CTL_offKS2 ) | ||
| 710 | #define PFM_CTL_mskKU0 ( 0x01 << PFM_CTL_offKU0 ) | ||
| 711 | #define PFM_CTL_mskKU1 ( 0x01 << PFM_CTL_offKU1 ) | ||
| 712 | #define PFM_CTL_mskKU2 ( 0x01 << PFM_CTL_offKU2 ) | ||
| 713 | #define PFM_CTL_mskSEL0 ( 0x01 << PFM_CTL_offSEL0 ) | ||
| 714 | #define PFM_CTL_mskSEL1 ( 0x3F << PFM_CTL_offSEL1 ) | ||
| 715 | #define PFM_CTL_mskSEL2 ( 0x3F << PFM_CTL_offSEL2 ) | ||
| 716 | |||
| 717 | /****************************************************************************** | ||
| 718 | * SDZ_CTL (Structure Downsizing Control Register) | ||
| 719 | *****************************************************************************/ | ||
| 720 | #define SDZ_CTL_offICDZ 0 /* I-cache downsizing control */ | ||
| 721 | #define SDZ_CTL_offDCDZ 3 /* D-cache downsizing control */ | ||
| 722 | #define SDZ_CTL_offMTBDZ 6 /* MTLB downsizing control */ | ||
| 723 | #define SDZ_CTL_offBTBDZ 9 /* Branch Target Table downsizing control */ | ||
| 724 | /* bit 12:31 reserved */ | ||
| 725 | #define SDZ_CTL_mskICDZ ( 0x07 << SDZ_CTL_offICDZ ) | ||
| 726 | #define SDZ_CTL_mskDCDZ ( 0x07 << SDZ_CTL_offDCDZ ) | ||
| 727 | #define SDZ_CTL_mskMTBDZ ( 0x07 << SDZ_CTL_offMTBDZ ) | ||
| 728 | #define SDZ_CTL_mskBTBDZ ( 0x07 << SDZ_CTL_offBTBDZ ) | ||
| 729 | |||
| 730 | /****************************************************************************** | ||
| 731 | * N13MISC_CTL (N13 Miscellaneous Control Register) | ||
| 732 | *****************************************************************************/ | ||
| 733 | #define N13MISC_CTL_offBTB 0 /* Disable Branch Target Buffer */ | ||
| 734 | #define N13MISC_CTL_offRTP 1 /* Disable Return Target Predictor */ | ||
| 735 | #define N13MISC_CTL_offPTEPF 2 /* Disable HPTWK L2 PTE pefetch */ | ||
| 736 | #define N13MISC_CTL_offSP_SHADOW_EN 4 /* Enable shadow stack pointers */ | ||
| 737 | /* bit 6, 9:31 reserved */ | ||
| 738 | |||
| 739 | #define N13MISC_CTL_makBTB ( 0x1 << N13MISC_CTL_offBTB ) | ||
| 740 | #define N13MISC_CTL_makRTP ( 0x1 << N13MISC_CTL_offRTP ) | ||
| 741 | #define N13MISC_CTL_makPTEPF ( 0x1 << N13MISC_CTL_offPTEPF ) | ||
| 742 | #define N13MISC_CTL_makSP_SHADOW_EN ( 0x1 << N13MISC_CTL_offSP_SHADOW_EN ) | ||
| 743 | |||
| 744 | #define MISC_init (N13MISC_CTL_makBTB|N13MISC_CTL_makRTP|N13MISC_CTL_makSP_SHADOW_EN) | ||
| 745 | |||
| 746 | /****************************************************************************** | ||
| 747 | * PRUSR_ACC_CTL (Privileged Resource User Access Control Registers) | ||
| 748 | *****************************************************************************/ | ||
| 749 | #define PRUSR_ACC_CTL_offDMA_EN 0 /* Allow user mode access of DMA registers */ | ||
| 750 | #define PRUSR_ACC_CTL_offPFM_EN 1 /* Allow user mode access of PFM registers */ | ||
| 751 | |||
| 752 | #define PRUSR_ACC_CTL_mskDMA_EN ( 0x1 << PRUSR_ACC_CTL_offDMA_EN ) | ||
| 753 | #define PRUSR_ACC_CTL_mskPFM_EN ( 0x1 << PRUSR_ACC_CTL_offPFM_EN ) | ||
| 754 | |||
| 755 | /****************************************************************************** | ||
| 756 | * dmar0: DMA_CFG (DMA Configuration Register) | ||
| 757 | *****************************************************************************/ | ||
| 758 | #define DMA_CFG_offNCHN 0 /* The number of DMA channels implemented */ | ||
| 759 | #define DMA_CFG_offUNEA 2 /* Un-aligned External Address transfer feature */ | ||
| 760 | #define DMA_CFG_off2DET 3 /* 2-D Element Transfer feature */ | ||
| 761 | /* bit 4:15 reserved */ | ||
| 762 | #define DMA_CFG_offVER 16 /* DMA architecture and implementation version */ | ||
| 763 | |||
| 764 | #define DMA_CFG_mskNCHN ( 0x3 << DMA_CFG_offNCHN ) | ||
| 765 | #define DMA_CFG_mskUNEA ( 0x1 << DMA_CFG_offUNEA ) | ||
| 766 | #define DMA_CFG_msk2DET ( 0x1 << DMA_CFG_off2DET ) | ||
| 767 | #define DMA_CFG_mskVER ( 0xFFFF << DMA_CFG_offVER ) | ||
| 768 | |||
| 769 | /****************************************************************************** | ||
| 770 | * dmar1: DMA_GCSW (DMA Global Control and Status Word Register) | ||
| 771 | *****************************************************************************/ | ||
| 772 | #define DMA_GCSW_offC0STAT 0 /* DMA channel 0 state */ | ||
| 773 | #define DMA_GCSW_offC1STAT 3 /* DMA channel 1 state */ | ||
| 774 | /* bit 6:11 reserved */ | ||
| 775 | #define DMA_GCSW_offC0INT 12 /* DMA channel 0 generate interrupt */ | ||
| 776 | #define DMA_GCSW_offC1INT 13 /* DMA channel 1 generate interrupt */ | ||
| 777 | /* bit 14:30 reserved */ | ||
| 778 | #define DMA_GCSW_offEN 31 /* Enable DMA engine */ | ||
| 779 | |||
| 780 | #define DMA_GCSW_mskC0STAT ( 0x7 << DMA_GCSW_offC0STAT ) | ||
| 781 | #define DMA_GCSW_mskC1STAT ( 0x7 << DMA_GCSW_offC1STAT ) | ||
| 782 | #define DMA_GCSW_mskC0INT ( 0x1 << DMA_GCSW_offC0INT ) | ||
| 783 | #define DMA_GCSW_mskC1INT ( 0x1 << DMA_GCSW_offC1INT ) | ||
| 784 | #define DMA_GCSW_mskEN ( 0x1 << DMA_GCSW_offEN ) | ||
| 785 | |||
| 786 | /****************************************************************************** | ||
| 787 | * dmar2: DMA_CHNSEL (DMA Channel Selection Register) | ||
| 788 | *****************************************************************************/ | ||
| 789 | #define DMA_CHNSEL_offCHAN 0 /* Selected channel number */ | ||
| 790 | /* bit 2:31 reserved */ | ||
| 791 | |||
| 792 | #define DMA_CHNSEL_mskCHAN ( 0x3 << DMA_CHNSEL_offCHAN ) | ||
| 793 | |||
| 794 | /****************************************************************************** | ||
| 795 | * dmar3: DMA_ACT (DMA Action Register) | ||
| 796 | *****************************************************************************/ | ||
| 797 | #define DMA_ACT_offACMD 0 /* DMA Action Command */ | ||
| 798 | /* bit 2:31 reserved */ | ||
| 799 | #define DMA_ACT_mskACMD ( 0x3 << DMA_ACT_offACMD ) | ||
| 800 | |||
| 801 | /****************************************************************************** | ||
| 802 | * dmar4: DMA_SETUP (DMA Setup Register) | ||
| 803 | *****************************************************************************/ | ||
| 804 | #define DMA_SETUP_offLM 0 /* Local Memory Selection */ | ||
| 805 | #define DMA_SETUP_offTDIR 1 /* Transfer Direction */ | ||
| 806 | #define DMA_SETUP_offTES 2 /* Transfer Element Size */ | ||
| 807 | #define DMA_SETUP_offESTR 4 /* External memory transfer Stride */ | ||
| 808 | #define DMA_SETUP_offCIE 16 /* Interrupt Enable on Completion */ | ||
| 809 | #define DMA_SETUP_offSIE 17 /* Interrupt Enable on explicit Stop */ | ||
| 810 | #define DMA_SETUP_offEIE 18 /* Interrupt Enable on Error */ | ||
| 811 | #define DMA_SETUP_offUE 19 /* Enable the Un-aligned External Address */ | ||
| 812 | #define DMA_SETUP_off2DE 20 /* Enable the 2-D External Transfer */ | ||
| 813 | #define DMA_SETUP_offCOA 21 /* Transfer Coalescable */ | ||
| 814 | /* bit 22:31 reserved */ | ||
| 815 | |||
| 816 | #define DMA_SETUP_mskLM ( 0x1 << DMA_SETUP_offLM ) | ||
| 817 | #define DMA_SETUP_mskTDIR ( 0x1 << DMA_SETUP_offTDIR ) | ||
| 818 | #define DMA_SETUP_mskTES ( 0x3 << DMA_SETUP_offTES ) | ||
| 819 | #define DMA_SETUP_mskESTR ( 0xFFF << DMA_SETUP_offESTR ) | ||
| 820 | #define DMA_SETUP_mskCIE ( 0x1 << DMA_SETUP_offCIE ) | ||
| 821 | #define DMA_SETUP_mskSIE ( 0x1 << DMA_SETUP_offSIE ) | ||
| 822 | #define DMA_SETUP_mskEIE ( 0x1 << DMA_SETUP_offEIE ) | ||
| 823 | #define DMA_SETUP_mskUE ( 0x1 << DMA_SETUP_offUE ) | ||
| 824 | #define DMA_SETUP_msk2DE ( 0x1 << DMA_SETUP_off2DE ) | ||
| 825 | #define DMA_SETUP_mskCOA ( 0x1 << DMA_SETUP_offCOA ) | ||
| 826 | |||
| 827 | /****************************************************************************** | ||
| 828 | * dmar5: DMA_ISADDR (DMA Internal Start Address Register) | ||
| 829 | *****************************************************************************/ | ||
| 830 | #define DMA_ISADDR_offISADDR 0 /* Internal Start Address */ | ||
| 831 | /* bit 20:31 reserved */ | ||
| 832 | #define DMA_ISADDR_mskISADDR ( 0xFFFFF << DMA_ISADDR_offISADDR ) | ||
| 833 | |||
| 834 | /****************************************************************************** | ||
| 835 | * dmar6: DMA_ESADDR (DMA External Start Address Register) | ||
| 836 | *****************************************************************************/ | ||
| 837 | /* This register holds External Start Address */ | ||
| 838 | |||
| 839 | /****************************************************************************** | ||
| 840 | * dmar7: DMA_TCNT (DMA Transfer Element Count Register) | ||
| 841 | *****************************************************************************/ | ||
| 842 | #define DMA_TCNT_offTCNT 0 /* DMA transfer element count */ | ||
| 843 | /* bit 18:31 reserved */ | ||
| 844 | #define DMA_TCNT_mskTCNT ( 0x3FFFF << DMA_TCNT_offTCNT ) | ||
| 845 | |||
| 846 | /****************************************************************************** | ||
| 847 | * dmar8: DMA_STATUS (DMA Status Register) | ||
| 848 | *****************************************************************************/ | ||
| 849 | #define DMA_STATUS_offSTAT 0 /* DMA channel state */ | ||
| 850 | #define DMA_STATUS_offSTUNA 3 /* Un-aligned error on External Stride value */ | ||
| 851 | #define DMA_STATUS_offDERR 4 /* DMA Transfer Disruption Error */ | ||
| 852 | #define DMA_STATUS_offEUNA 5 /* Un-aligned error on the External address */ | ||
| 853 | #define DMA_STATUS_offIUNA 6 /* Un-aligned error on the Internal address */ | ||
| 854 | #define DMA_STATUS_offIOOR 7 /* Out-Of-Range error on the Internal address */ | ||
| 855 | #define DMA_STATUS_offEBUS 8 /* Bus Error on an External DMA transfer */ | ||
| 856 | #define DMA_STATUS_offESUP 9 /* DMA setup error */ | ||
| 857 | /* bit 10:31 reserved */ | ||
| 858 | |||
| 859 | #define DMA_STATUS_mskSTAT ( 0x7 << DMA_STATUS_offSTAT ) | ||
| 860 | #define DMA_STATUS_mskSTUNA ( 0x1 << DMDMA_STATUS_offSTUNA ) | ||
| 861 | #define DMA_STATUS_mskDERR ( 0x1 << DMDMA_STATUS_offDERR ) | ||
| 862 | #define DMA_STATUS_mskEUNA ( 0x1 << DMDMA_STATUS_offEUNA ) | ||
| 863 | #define DMA_STATUS_mskIUNA ( 0x1 << DMDMA_STATUS_offIUNA ) | ||
| 864 | #define DMA_STATUS_mskIOOR ( 0x1 << DMDMA_STATUS_offIOOR ) | ||
| 865 | #define DMA_STATUS_mskEBUS ( 0x1 << DMDMA_STATUS_offEBUS ) | ||
| 866 | #define DMA_STATUS_mskESUP ( 0x1 << DMDMA_STATUS_offESUP ) | ||
| 867 | |||
| 868 | /****************************************************************************** | ||
| 869 | * dmar9: DMA_2DSET (DMA 2D Setup Register) | ||
| 870 | *****************************************************************************/ | ||
| 871 | #define DMA_2DSET_offWECNT 0 /* The Width Element Count for a 2-D region */ | ||
| 872 | #define DMA_2DSET_offHTSTR 16 /* The Height Stride for a 2-D region */ | ||
| 873 | |||
| 874 | #define DMA_2DSET_mskHTSTR ( 0xFFFF << DMA_2DSET_offHTSTR ) | ||
| 875 | #define DMA_2DSET_mskWECNT ( 0xFFFF << DMA_2DSET_offWECNT ) | ||
| 876 | |||
| 877 | /****************************************************************************** | ||
| 878 | * dmar10: DMA_2DSCTL (DMA 2D Startup Control Register) | ||
| 879 | *****************************************************************************/ | ||
| 880 | #define DMA_2DSCTL_offSTWECNT 0 /* Startup Width Element Count for a 2-D region */ | ||
| 881 | /* bit 16:31 reserved */ | ||
| 882 | |||
| 883 | #define DMA_2DSCTL_mskSTWECNT ( 0xFFFF << DMA_2DSCTL_offSTWECNT ) | ||
| 884 | |||
| 885 | /****************************************************************************** | ||
| 886 | * fpcsr: FPCSR (Floating-Point Control Status Register) | ||
| 887 | *****************************************************************************/ | ||
| 888 | #define FPCSR_offRM 0 | ||
| 889 | #define FPCSR_offIVO 2 | ||
| 890 | #define FPCSR_offDBZ 3 | ||
| 891 | #define FPCSR_offOVF 4 | ||
| 892 | #define FPCSR_offUDF 5 | ||
| 893 | #define FPCSR_offIEX 6 | ||
| 894 | #define FPCSR_offIVOE 7 | ||
| 895 | #define FPCSR_offDBZE 8 | ||
| 896 | #define FPCSR_offOVFE 9 | ||
| 897 | #define FPCSR_offUDFE 10 | ||
| 898 | #define FPCSR_offIEXE 11 | ||
| 899 | #define FPCSR_offDNZ 12 | ||
| 900 | #define FPCSR_offIVOT 13 | ||
| 901 | #define FPCSR_offDBZT 14 | ||
| 902 | #define FPCSR_offOVFT 15 | ||
| 903 | #define FPCSR_offUDFT 16 | ||
| 904 | #define FPCSR_offIEXT 17 | ||
| 905 | #define FPCSR_offDNIT 18 | ||
| 906 | #define FPCSR_offRIT 19 | ||
| 907 | |||
| 908 | #define FPCSR_mskRM ( 0x3 << FPCSR_offRM ) | ||
| 909 | #define FPCSR_mskIVO ( 0x1 << FPCSR_offIVO ) | ||
| 910 | #define FPCSR_mskDBZ ( 0x1 << FPCSR_offDBZ ) | ||
| 911 | #define FPCSR_mskOVF ( 0x1 << FPCSR_offOVF ) | ||
| 912 | #define FPCSR_mskUDF ( 0x1 << FPCSR_offUDF ) | ||
| 913 | #define FPCSR_mskIEX ( 0x1 << FPCSR_offIEX ) | ||
| 914 | #define FPCSR_mskIVOE ( 0x1 << FPCSR_offIVOE ) | ||
| 915 | #define FPCSR_mskDBZE ( 0x1 << FPCSR_offDBZE ) | ||
| 916 | #define FPCSR_mskOVFE ( 0x1 << FPCSR_offOVFE ) | ||
| 917 | #define FPCSR_mskUDFE ( 0x1 << FPCSR_offUDFE ) | ||
| 918 | #define FPCSR_mskIEXE ( 0x1 << FPCSR_offIEXE ) | ||
| 919 | #define FPCSR_mskDNZ ( 0x1 << FPCSR_offDNZ ) | ||
| 920 | #define FPCSR_mskIVOT ( 0x1 << FPCSR_offIVOT ) | ||
| 921 | #define FPCSR_mskDBZT ( 0x1 << FPCSR_offDBZT ) | ||
| 922 | #define FPCSR_mskOVFT ( 0x1 << FPCSR_offOVFT ) | ||
| 923 | #define FPCSR_mskUDFT ( 0x1 << FPCSR_offUDFT ) | ||
| 924 | #define FPCSR_mskIEXT ( 0x1 << FPCSR_offIEXT ) | ||
| 925 | #define FPCSR_mskDNIT ( 0x1 << FPCSR_offDNIT ) | ||
| 926 | #define FPCSR_mskRIT ( 0x1 << FPCSR_offRIT ) | ||
| 927 | #define FPCSR_mskALL (FPCSR_mskIVO | FPCSR_mskDBZ | FPCSR_mskOVF | FPCSR_mskUDF | FPCSR_mskIEX) | ||
| 928 | #define FPCSR_mskALLE (FPCSR_mskIVOE | FPCSR_mskDBZE | FPCSR_mskOVFE | FPCSR_mskUDFE | FPCSR_mskIEXE) | ||
| 929 | #define FPCSR_mskALLT (FPCSR_mskIVOT | FPCSR_mskDBZT | FPCSR_mskOVFT | FPCSR_mskUDFT | FPCSR_mskIEXT |FPCSR_mskDNIT | FPCSR_mskRIT) | ||
| 930 | |||
| 931 | /****************************************************************************** | ||
| 932 | * fpcfg: FPCFG (Floating-Point Configuration Register) | ||
| 933 | *****************************************************************************/ | ||
| 934 | #define FPCFG_offSP 0 | ||
| 935 | #define FPCFG_offDP 1 | ||
| 936 | #define FPCFG_offFREG 2 | ||
| 937 | #define FPCFG_offFMA 4 | ||
| 938 | #define FPCFG_offIMVER 22 | ||
| 939 | #define FPCFG_offAVER 27 | ||
| 940 | |||
| 941 | #define FPCFG_mskSP ( 0x1 << FPCFG_offSP ) | ||
| 942 | #define FPCFG_mskDP ( 0x1 << FPCFG_offDP ) | ||
| 943 | #define FPCFG_mskFREG ( 0x3 << FPCFG_offFREG ) | ||
| 944 | #define FPCFG_mskFMA ( 0x1 << FPCFG_offFMA ) | ||
| 945 | #define FPCFG_mskIMVER ( 0x1F << FPCFG_offIMVER ) | ||
| 946 | #define FPCFG_mskAVER ( 0x1F << FPCFG_offAVER ) | ||
| 947 | |||
| 948 | /****************************************************************************** | ||
| 949 | * fucpr: FUCOP_CTL (FPU and Coprocessor Enable Control Register) | ||
| 950 | *****************************************************************************/ | ||
| 951 | #define FUCOP_CTL_offCP0EN 0 | ||
| 952 | #define FUCOP_CTL_offCP1EN 1 | ||
| 953 | #define FUCOP_CTL_offCP2EN 2 | ||
| 954 | #define FUCOP_CTL_offCP3EN 3 | ||
| 955 | #define FUCOP_CTL_offAUEN 31 | ||
| 956 | |||
| 957 | #define FUCOP_CTL_mskCP0EN ( 0x1 << FUCOP_CTL_offCP0EN ) | ||
| 958 | #define FUCOP_CTL_mskCP1EN ( 0x1 << FUCOP_CTL_offCP1EN ) | ||
| 959 | #define FUCOP_CTL_mskCP2EN ( 0x1 << FUCOP_CTL_offCP2EN ) | ||
| 960 | #define FUCOP_CTL_mskCP3EN ( 0x1 << FUCOP_CTL_offCP3EN ) | ||
| 961 | #define FUCOP_CTL_mskAUEN ( 0x1 << FUCOP_CTL_offAUEN ) | ||
| 962 | |||
| 963 | #endif /* __NDS32_BITFIELD_H__ */ | ||
diff --git a/arch/nds32/include/asm/cache.h b/arch/nds32/include/asm/cache.h new file mode 100644 index 000000000000..347db4881c5f --- /dev/null +++ b/arch/nds32/include/asm/cache.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_CACHE_H__ | ||
| 5 | #define __NDS32_CACHE_H__ | ||
| 6 | |||
| 7 | #define L1_CACHE_BYTES 32 | ||
| 8 | #define L1_CACHE_SHIFT 5 | ||
| 9 | |||
| 10 | #define ARCH_DMA_MINALIGN L1_CACHE_BYTES | ||
| 11 | |||
| 12 | #endif /* __NDS32_CACHE_H__ */ | ||
diff --git a/arch/nds32/include/asm/cache_info.h b/arch/nds32/include/asm/cache_info.h new file mode 100644 index 000000000000..38ec458ba543 --- /dev/null +++ b/arch/nds32/include/asm/cache_info.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | struct cache_info { | ||
| 5 | unsigned char ways; | ||
| 6 | unsigned char line_size; | ||
| 7 | unsigned short sets; | ||
| 8 | unsigned short size; | ||
| 9 | #if defined(CONFIG_CPU_CACHE_ALIASING) | ||
| 10 | unsigned short aliasing_num; | ||
| 11 | unsigned int aliasing_mask; | ||
| 12 | #endif | ||
| 13 | }; | ||
diff --git a/arch/nds32/include/asm/cacheflush.h b/arch/nds32/include/asm/cacheflush.h new file mode 100644 index 000000000000..7b9b20a381cb --- /dev/null +++ b/arch/nds32/include/asm/cacheflush.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_CACHEFLUSH_H__ | ||
| 5 | #define __NDS32_CACHEFLUSH_H__ | ||
| 6 | |||
| 7 | #include <linux/mm.h> | ||
| 8 | |||
| 9 | #define PG_dcache_dirty PG_arch_1 | ||
| 10 | |||
| 11 | #ifdef CONFIG_CPU_CACHE_ALIASING | ||
| 12 | void flush_cache_mm(struct mm_struct *mm); | ||
| 13 | void flush_cache_dup_mm(struct mm_struct *mm); | ||
| 14 | void flush_cache_range(struct vm_area_struct *vma, | ||
| 15 | unsigned long start, unsigned long end); | ||
| 16 | void flush_cache_page(struct vm_area_struct *vma, | ||
| 17 | unsigned long addr, unsigned long pfn); | ||
| 18 | void flush_cache_kmaps(void); | ||
| 19 | void flush_cache_vmap(unsigned long start, unsigned long end); | ||
| 20 | void flush_cache_vunmap(unsigned long start, unsigned long end); | ||
| 21 | |||
| 22 | #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 | ||
| 23 | void flush_dcache_page(struct page *page); | ||
| 24 | void copy_to_user_page(struct vm_area_struct *vma, struct page *page, | ||
| 25 | unsigned long vaddr, void *dst, void *src, int len); | ||
| 26 | void copy_from_user_page(struct vm_area_struct *vma, struct page *page, | ||
| 27 | unsigned long vaddr, void *dst, void *src, int len); | ||
| 28 | |||
| 29 | #define ARCH_HAS_FLUSH_ANON_PAGE | ||
| 30 | void flush_anon_page(struct vm_area_struct *vma, | ||
| 31 | struct page *page, unsigned long vaddr); | ||
| 32 | |||
| 33 | #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE | ||
| 34 | void flush_kernel_dcache_page(struct page *page); | ||
| 35 | void flush_icache_range(unsigned long start, unsigned long end); | ||
| 36 | void flush_icache_page(struct vm_area_struct *vma, struct page *page); | ||
| 37 | #define flush_dcache_mmap_lock(mapping) spin_lock_irq(&(mapping)->tree_lock) | ||
| 38 | #define flush_dcache_mmap_unlock(mapping) spin_unlock_irq(&(mapping)->tree_lock) | ||
| 39 | |||
| 40 | #else | ||
| 41 | #include <asm-generic/cacheflush.h> | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #endif /* __NDS32_CACHEFLUSH_H__ */ | ||
diff --git a/arch/nds32/include/asm/current.h b/arch/nds32/include/asm/current.h new file mode 100644 index 000000000000..b4dcd22b7bcb --- /dev/null +++ b/arch/nds32/include/asm/current.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASM_NDS32_CURRENT_H | ||
| 5 | #define _ASM_NDS32_CURRENT_H | ||
| 6 | |||
| 7 | #ifndef __ASSEMBLY__ | ||
| 8 | register struct task_struct *current asm("$r25"); | ||
| 9 | #endif /* __ASSEMBLY__ */ | ||
| 10 | #define tsk $r25 | ||
| 11 | |||
| 12 | #endif /* _ASM_NDS32_CURRENT_H */ | ||
diff --git a/arch/nds32/include/asm/delay.h b/arch/nds32/include/asm/delay.h new file mode 100644 index 000000000000..519ba97acb6e --- /dev/null +++ b/arch/nds32/include/asm/delay.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_DELAY_H__ | ||
| 5 | #define __NDS32_DELAY_H__ | ||
| 6 | |||
| 7 | #include <asm/param.h> | ||
| 8 | |||
| 9 | /* There is no clocksource cycle counter in the CPU. */ | ||
| 10 | static inline void __delay(unsigned long loops) | ||
| 11 | { | ||
| 12 | __asm__ __volatile__(".align 2\n" | ||
| 13 | "1:\n" | ||
| 14 | "\taddi\t%0, %0, -1\n" | ||
| 15 | "\tbgtz\t%0, 1b\n" | ||
| 16 | :"=r"(loops) | ||
| 17 | :"0"(loops)); | ||
| 18 | } | ||
| 19 | |||
| 20 | static inline void __udelay(unsigned long usecs, unsigned long lpj) | ||
| 21 | { | ||
| 22 | usecs *= (unsigned long)(((0x8000000000000000ULL / (500000 / HZ)) + | ||
| 23 | 0x80000000ULL) >> 32); | ||
| 24 | usecs = (unsigned long)(((unsigned long long)usecs * lpj) >> 32); | ||
| 25 | __delay(usecs); | ||
| 26 | } | ||
| 27 | |||
| 28 | #define udelay(usecs) __udelay((usecs), loops_per_jiffy) | ||
| 29 | |||
| 30 | /* make sure "usecs *= ..." in udelay do not overflow. */ | ||
| 31 | #if HZ >= 1000 | ||
| 32 | #define MAX_UDELAY_MS 1 | ||
| 33 | #elif HZ <= 200 | ||
| 34 | #define MAX_UDELAY_MS 5 | ||
| 35 | #else | ||
| 36 | #define MAX_UDELAY_MS (1000 / HZ) | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #endif | ||
diff --git a/arch/nds32/include/asm/dma-mapping.h b/arch/nds32/include/asm/dma-mapping.h new file mode 100644 index 000000000000..2dd47d245c25 --- /dev/null +++ b/arch/nds32/include/asm/dma-mapping.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef ASMNDS32_DMA_MAPPING_H | ||
| 5 | #define ASMNDS32_DMA_MAPPING_H | ||
| 6 | |||
| 7 | extern struct dma_map_ops nds32_dma_ops; | ||
| 8 | |||
| 9 | static inline struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) | ||
| 10 | { | ||
| 11 | return &nds32_dma_ops; | ||
| 12 | } | ||
| 13 | |||
| 14 | #endif | ||
diff --git a/arch/nds32/include/asm/elf.h b/arch/nds32/include/asm/elf.h new file mode 100644 index 000000000000..56c479058802 --- /dev/null +++ b/arch/nds32/include/asm/elf.h | |||
| @@ -0,0 +1,171 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASMNDS32_ELF_H | ||
| 5 | #define __ASMNDS32_ELF_H | ||
| 6 | |||
| 7 | /* | ||
| 8 | * ELF register definitions.. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #include <asm/ptrace.h> | ||
| 12 | |||
| 13 | typedef unsigned long elf_greg_t; | ||
| 14 | typedef unsigned long elf_freg_t[3]; | ||
| 15 | |||
| 16 | extern unsigned int elf_hwcap; | ||
| 17 | |||
| 18 | #define EM_NDS32 167 | ||
| 19 | |||
| 20 | #define R_NDS32_NONE 0 | ||
| 21 | #define R_NDS32_16_RELA 19 | ||
| 22 | #define R_NDS32_32_RELA 20 | ||
| 23 | #define R_NDS32_9_PCREL_RELA 22 | ||
| 24 | #define R_NDS32_15_PCREL_RELA 23 | ||
| 25 | #define R_NDS32_17_PCREL_RELA 24 | ||
| 26 | #define R_NDS32_25_PCREL_RELA 25 | ||
| 27 | #define R_NDS32_HI20_RELA 26 | ||
| 28 | #define R_NDS32_LO12S3_RELA 27 | ||
| 29 | #define R_NDS32_LO12S2_RELA 28 | ||
| 30 | #define R_NDS32_LO12S1_RELA 29 | ||
| 31 | #define R_NDS32_LO12S0_RELA 30 | ||
| 32 | #define R_NDS32_SDA15S3_RELA 31 | ||
| 33 | #define R_NDS32_SDA15S2_RELA 32 | ||
| 34 | #define R_NDS32_SDA15S1_RELA 33 | ||
| 35 | #define R_NDS32_SDA15S0_RELA 34 | ||
| 36 | #define R_NDS32_GOT20 37 | ||
| 37 | #define R_NDS32_25_PLTREL 38 | ||
| 38 | #define R_NDS32_COPY 39 | ||
| 39 | #define R_NDS32_GLOB_DAT 40 | ||
| 40 | #define R_NDS32_JMP_SLOT 41 | ||
| 41 | #define R_NDS32_RELATIVE 42 | ||
| 42 | #define R_NDS32_GOTOFF 43 | ||
| 43 | #define R_NDS32_GOTPC20 44 | ||
| 44 | #define R_NDS32_GOT_HI20 45 | ||
| 45 | #define R_NDS32_GOT_LO12 46 | ||
| 46 | #define R_NDS32_GOTPC_HI20 47 | ||
| 47 | #define R_NDS32_GOTPC_LO12 48 | ||
| 48 | #define R_NDS32_GOTOFF_HI20 49 | ||
| 49 | #define R_NDS32_GOTOFF_LO12 50 | ||
| 50 | #define R_NDS32_INSN16 51 | ||
| 51 | #define R_NDS32_LABEL 52 | ||
| 52 | #define R_NDS32_LONGCALL1 53 | ||
| 53 | #define R_NDS32_LONGCALL2 54 | ||
| 54 | #define R_NDS32_LONGCALL3 55 | ||
| 55 | #define R_NDS32_LONGJUMP1 56 | ||
| 56 | #define R_NDS32_LONGJUMP2 57 | ||
| 57 | #define R_NDS32_LONGJUMP3 58 | ||
| 58 | #define R_NDS32_LOADSTORE 59 | ||
| 59 | #define R_NDS32_9_FIXED_RELA 60 | ||
| 60 | #define R_NDS32_15_FIXED_RELA 61 | ||
| 61 | #define R_NDS32_17_FIXED_RELA 62 | ||
| 62 | #define R_NDS32_25_FIXED_RELA 63 | ||
| 63 | #define R_NDS32_PLTREL_HI20 64 | ||
| 64 | #define R_NDS32_PLTREL_LO12 65 | ||
| 65 | #define R_NDS32_PLT_GOTREL_HI20 66 | ||
| 66 | #define R_NDS32_PLT_GOTREL_LO12 67 | ||
| 67 | #define R_NDS32_LO12S0_ORI_RELA 72 | ||
| 68 | #define R_NDS32_DWARF2_OP1_RELA 77 | ||
| 69 | #define R_NDS32_DWARF2_OP2_RELA 78 | ||
| 70 | #define R_NDS32_DWARF2_LEB_RELA 79 | ||
| 71 | #define R_NDS32_WORD_9_PCREL_RELA 94 | ||
| 72 | #define R_NDS32_LONGCALL4 107 | ||
| 73 | #define R_NDS32_RELA_NOP_MIX 192 | ||
| 74 | #define R_NDS32_RELA_NOP_MAX 255 | ||
| 75 | |||
| 76 | #define ELF_NGREG (sizeof (struct user_pt_regs) / sizeof(elf_greg_t)) | ||
| 77 | #define ELF_CORE_COPY_REGS(dest, regs) \ | ||
| 78 | *(struct user_pt_regs *)&(dest) = (regs)->user_regs; | ||
| 79 | |||
| 80 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | ||
| 81 | |||
| 82 | /* Core file format: The core file is written in such a way that gdb | ||
| 83 | can understand it and provide useful information to the user (under | ||
| 84 | linux we use the 'trad-core' bfd). There are quite a number of | ||
| 85 | obstacles to being able to view the contents of the floating point | ||
| 86 | registers, and until these are solved you will not be able to view the | ||
| 87 | contents of them. Actually, you can read in the core file and look at | ||
| 88 | the contents of the user struct to find out what the floating point | ||
| 89 | registers contain. | ||
| 90 | The actual file contents are as follows: | ||
| 91 | UPAGE: 1 page consisting of a user struct that tells gdb what is present | ||
| 92 | in the file. Directly after this is a copy of the task_struct, which | ||
| 93 | is currently not used by gdb, but it may come in useful at some point. | ||
| 94 | All of the registers are stored as part of the upage. The upage should | ||
| 95 | always be only one page. | ||
| 96 | DATA: The data area is stored. We use current->end_text to | ||
| 97 | current->brk to pick up all of the user variables, plus any memory | ||
| 98 | that may have been malloced. No attempt is made to determine if a page | ||
| 99 | is demand-zero or if a page is totally unused, we just cover the entire | ||
| 100 | range. All of the addresses are rounded in such a way that an integral | ||
| 101 | number of pages is written. | ||
| 102 | STACK: We need the stack information in order to get a meaningful | ||
| 103 | backtrace. We need to write the data from (esp) to | ||
| 104 | current->start_stack, so we round each of these off in order to be able | ||
| 105 | to write an integer number of pages. | ||
| 106 | The minimum core file size is 3 pages, or 12288 bytes. | ||
| 107 | */ | ||
| 108 | |||
| 109 | struct user_fp { | ||
| 110 | unsigned long long fd_regs[32]; | ||
| 111 | unsigned long fpcsr; | ||
| 112 | }; | ||
| 113 | |||
| 114 | typedef struct user_fp elf_fpregset_t; | ||
| 115 | |||
| 116 | struct elf32_hdr; | ||
| 117 | #define elf_check_arch(x) ((x)->e_machine == EM_NDS32) | ||
| 118 | |||
| 119 | /* | ||
| 120 | * These are used to set parameters in the core dumps. | ||
| 121 | */ | ||
| 122 | #define ELF_CLASS ELFCLASS32 | ||
| 123 | #ifdef __NDS32_EB__ | ||
| 124 | #define ELF_DATA ELFDATA2MSB; | ||
| 125 | #else | ||
| 126 | #define ELF_DATA ELFDATA2LSB; | ||
| 127 | #endif | ||
| 128 | #define ELF_ARCH EM_NDS32 | ||
| 129 | #define USE_ELF_CORE_DUMP | ||
| 130 | #define ELF_EXEC_PAGESIZE PAGE_SIZE | ||
| 131 | |||
| 132 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical | ||
| 133 | use of this is to invoke "./ld.so someprog" to test out a new version of | ||
| 134 | the loader. We need to make sure that it is out of the way of the program | ||
| 135 | that it will "exec", and that there is sufficient room for the brk. */ | ||
| 136 | |||
| 137 | #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) | ||
| 138 | |||
| 139 | /* When the program starts, a1 contains a pointer to a function to be | ||
| 140 | registered with atexit, as per the SVR4 ABI. A value of 0 means we | ||
| 141 | have no such handler. */ | ||
| 142 | #define ELF_PLAT_INIT(_r, load_addr) (_r)->uregs[0] = 0 | ||
| 143 | |||
| 144 | /* This yields a mask that user programs can use to figure out what | ||
| 145 | instruction set this cpu supports. */ | ||
| 146 | |||
| 147 | #define ELF_HWCAP (elf_hwcap) | ||
| 148 | |||
| 149 | #ifdef __KERNEL__ | ||
| 150 | |||
| 151 | #define ELF_PLATFORM (NULL) | ||
| 152 | |||
| 153 | /* Old NetWinder binaries were compiled in such a way that the iBCS | ||
| 154 | heuristic always trips on them. Until these binaries become uncommon | ||
| 155 | enough not to care, don't trust the `ibcs' flag here. In any case | ||
| 156 | there is no other ELF system currently supported by iBCS. | ||
| 157 | @@ Could print a warning message to encourage users to upgrade. */ | ||
| 158 | #define SET_PERSONALITY(ex) set_personality(PER_LINUX) | ||
| 159 | |||
| 160 | #endif | ||
| 161 | |||
| 162 | #define ARCH_DLINFO \ | ||
| 163 | do { \ | ||
| 164 | NEW_AUX_ENT(AT_SYSINFO_EHDR, \ | ||
| 165 | (elf_addr_t)current->mm->context.vdso); \ | ||
| 166 | } while (0) | ||
| 167 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 | ||
| 168 | struct linux_binprm; | ||
| 169 | int arch_setup_additional_pages(struct linux_binprm *, int); | ||
| 170 | |||
| 171 | #endif | ||
diff --git a/arch/nds32/include/asm/fixmap.h b/arch/nds32/include/asm/fixmap.h new file mode 100644 index 000000000000..0e60e153a71a --- /dev/null +++ b/arch/nds32/include/asm/fixmap.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_FIXMAP_H | ||
| 5 | #define __ASM_NDS32_FIXMAP_H | ||
| 6 | |||
| 7 | #ifdef CONFIG_HIGHMEM | ||
| 8 | #include <linux/threads.h> | ||
| 9 | #include <asm/kmap_types.h> | ||
| 10 | #endif | ||
| 11 | |||
| 12 | enum fixed_addresses { | ||
| 13 | FIX_HOLE, | ||
| 14 | FIX_KMAP_RESERVED, | ||
| 15 | FIX_KMAP_BEGIN, | ||
| 16 | #ifdef CONFIG_HIGHMEM | ||
| 17 | FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS), | ||
| 18 | #endif | ||
| 19 | FIX_EARLYCON_MEM_BASE, | ||
| 20 | __end_of_fixed_addresses | ||
| 21 | }; | ||
| 22 | #define FIXADDR_TOP ((unsigned long) (-(16 * PAGE_SIZE))) | ||
| 23 | #define FIXADDR_SIZE ((__end_of_fixed_addresses) << PAGE_SHIFT) | ||
| 24 | #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) | ||
| 25 | #define FIXMAP_PAGE_IO __pgprot(PAGE_DEVICE) | ||
| 26 | void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); | ||
| 27 | |||
| 28 | #include <asm-generic/fixmap.h> | ||
| 29 | #endif /* __ASM_NDS32_FIXMAP_H */ | ||
diff --git a/arch/nds32/include/asm/futex.h b/arch/nds32/include/asm/futex.h new file mode 100644 index 000000000000..eab5e84bd991 --- /dev/null +++ b/arch/nds32/include/asm/futex.h | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_FUTEX_H__ | ||
| 5 | #define __NDS32_FUTEX_H__ | ||
| 6 | |||
| 7 | #include <linux/futex.h> | ||
| 8 | #include <linux/uaccess.h> | ||
| 9 | #include <asm/errno.h> | ||
| 10 | |||
| 11 | #define __futex_atomic_ex_table(err_reg) \ | ||
| 12 | " .pushsection __ex_table,\"a\"\n" \ | ||
| 13 | " .align 3\n" \ | ||
| 14 | " .long 1b, 4f\n" \ | ||
| 15 | " .long 2b, 4f\n" \ | ||
| 16 | " .popsection\n" \ | ||
| 17 | " .pushsection .fixup,\"ax\"\n" \ | ||
| 18 | "4: move %0, " err_reg "\n" \ | ||
| 19 | " j 3b\n" \ | ||
| 20 | " .popsection" | ||
| 21 | |||
| 22 | #define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \ | ||
| 23 | smp_mb(); \ | ||
| 24 | asm volatile( \ | ||
| 25 | " movi $ta, #0\n" \ | ||
| 26 | "1: llw %1, [%2+$ta]\n" \ | ||
| 27 | " " insn "\n" \ | ||
| 28 | "2: scw %0, [%2+$ta]\n" \ | ||
| 29 | " beqz %0, 1b\n" \ | ||
| 30 | " movi %0, #0\n" \ | ||
| 31 | "3:\n" \ | ||
| 32 | __futex_atomic_ex_table("%4") \ | ||
| 33 | : "=&r" (ret), "=&r" (oldval) \ | ||
| 34 | : "r" (uaddr), "r" (oparg), "i" (-EFAULT) \ | ||
| 35 | : "cc", "memory") | ||
| 36 | static inline int | ||
| 37 | futex_atomic_cmpxchg_inatomic(u32 * uval, u32 __user * uaddr, | ||
| 38 | u32 oldval, u32 newval) | ||
| 39 | { | ||
| 40 | int ret = 0; | ||
| 41 | u32 val, tmp, flags; | ||
| 42 | |||
| 43 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) | ||
| 44 | return -EFAULT; | ||
| 45 | |||
| 46 | smp_mb(); | ||
| 47 | asm volatile (" movi $ta, #0\n" | ||
| 48 | "1: llw %1, [%6 + $ta]\n" | ||
| 49 | " sub %3, %1, %4\n" | ||
| 50 | " cmovz %2, %5, %3\n" | ||
| 51 | " cmovn %2, %1, %3\n" | ||
| 52 | "2: scw %2, [%6 + $ta]\n" | ||
| 53 | " beqz %2, 1b\n" | ||
| 54 | "3:\n " __futex_atomic_ex_table("%7") | ||
| 55 | :"+&r"(ret), "=&r"(val), "=&r"(tmp), "=&r"(flags) | ||
| 56 | :"r"(oldval), "r"(newval), "r"(uaddr), "i"(-EFAULT) | ||
| 57 | :"$ta", "memory"); | ||
| 58 | smp_mb(); | ||
| 59 | |||
| 60 | *uval = val; | ||
| 61 | return ret; | ||
| 62 | } | ||
| 63 | |||
| 64 | static inline int | ||
| 65 | arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) | ||
| 66 | { | ||
| 67 | int oldval = 0, ret; | ||
| 68 | |||
| 69 | |||
| 70 | pagefault_disable(); | ||
| 71 | switch (op) { | ||
| 72 | case FUTEX_OP_SET: | ||
| 73 | __futex_atomic_op("move %0, %3", ret, oldval, tmp, uaddr, | ||
| 74 | oparg); | ||
| 75 | break; | ||
| 76 | case FUTEX_OP_ADD: | ||
| 77 | __futex_atomic_op("add %0, %1, %3", ret, oldval, tmp, uaddr, | ||
| 78 | oparg); | ||
| 79 | break; | ||
| 80 | case FUTEX_OP_OR: | ||
| 81 | __futex_atomic_op("or %0, %1, %3", ret, oldval, tmp, uaddr, | ||
| 82 | oparg); | ||
| 83 | break; | ||
| 84 | case FUTEX_OP_ANDN: | ||
| 85 | __futex_atomic_op("and %0, %1, %3", ret, oldval, tmp, uaddr, | ||
| 86 | ~oparg); | ||
| 87 | break; | ||
| 88 | case FUTEX_OP_XOR: | ||
| 89 | __futex_atomic_op("xor %0, %1, %3", ret, oldval, tmp, uaddr, | ||
| 90 | oparg); | ||
| 91 | break; | ||
| 92 | default: | ||
| 93 | ret = -ENOSYS; | ||
| 94 | } | ||
| 95 | |||
| 96 | pagefault_enable(); | ||
| 97 | |||
| 98 | if (!ret) | ||
| 99 | *oval = oldval; | ||
| 100 | |||
| 101 | return ret; | ||
| 102 | } | ||
| 103 | #endif /* __NDS32_FUTEX_H__ */ | ||
diff --git a/arch/nds32/include/asm/highmem.h b/arch/nds32/include/asm/highmem.h new file mode 100644 index 000000000000..425d546cb059 --- /dev/null +++ b/arch/nds32/include/asm/highmem.h | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASM_HIGHMEM_H | ||
| 5 | #define _ASM_HIGHMEM_H | ||
| 6 | |||
| 7 | #include <asm/proc-fns.h> | ||
| 8 | #include <asm/kmap_types.h> | ||
| 9 | #include <asm/fixmap.h> | ||
| 10 | #include <asm/pgtable.h> | ||
| 11 | |||
| 12 | /* | ||
| 13 | * Right now we initialize only a single pte table. It can be extended | ||
| 14 | * easily, subsequent pte tables have to be allocated in one physical | ||
| 15 | * chunk of RAM. | ||
| 16 | */ | ||
| 17 | /* | ||
| 18 | * Ordering is (from lower to higher memory addresses): | ||
| 19 | * | ||
| 20 | * high_memory | ||
| 21 | * Persistent kmap area | ||
| 22 | * PKMAP_BASE | ||
| 23 | * fixed_addresses | ||
| 24 | * FIXADDR_START | ||
| 25 | * FIXADDR_TOP | ||
| 26 | * Vmalloc area | ||
| 27 | * VMALLOC_START | ||
| 28 | * VMALLOC_END | ||
| 29 | */ | ||
| 30 | #define PKMAP_BASE ((FIXADDR_START - PGDIR_SIZE) & (PGDIR_MASK)) | ||
| 31 | #define LAST_PKMAP PTRS_PER_PTE | ||
| 32 | #define LAST_PKMAP_MASK (LAST_PKMAP - 1) | ||
| 33 | #define PKMAP_NR(virt) (((virt) - (PKMAP_BASE)) >> PAGE_SHIFT) | ||
| 34 | #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) | ||
| 35 | #define kmap_prot PAGE_KERNEL | ||
| 36 | |||
| 37 | static inline void flush_cache_kmaps(void) | ||
| 38 | { | ||
| 39 | cpu_dcache_wbinval_all(); | ||
| 40 | } | ||
| 41 | |||
| 42 | /* declarations for highmem.c */ | ||
| 43 | extern unsigned long highstart_pfn, highend_pfn; | ||
| 44 | |||
| 45 | extern pte_t *pkmap_page_table; | ||
| 46 | |||
| 47 | extern void *kmap_high(struct page *page); | ||
| 48 | extern void kunmap_high(struct page *page); | ||
| 49 | |||
| 50 | extern void kmap_init(void); | ||
| 51 | |||
| 52 | /* | ||
| 53 | * The following functions are already defined by <linux/highmem.h> | ||
| 54 | * when CONFIG_HIGHMEM is not set. | ||
| 55 | */ | ||
| 56 | #ifdef CONFIG_HIGHMEM | ||
| 57 | extern void *kmap(struct page *page); | ||
| 58 | extern void kunmap(struct page *page); | ||
| 59 | extern void *kmap_atomic(struct page *page); | ||
| 60 | extern void __kunmap_atomic(void *kvaddr); | ||
| 61 | extern void *kmap_atomic_pfn(unsigned long pfn); | ||
| 62 | extern struct page *kmap_atomic_to_page(void *ptr); | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #endif | ||
diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h new file mode 100644 index 000000000000..966e71b3c960 --- /dev/null +++ b/arch/nds32/include/asm/io.h | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_IO_H | ||
| 5 | #define __ASM_NDS32_IO_H | ||
| 6 | |||
| 7 | extern void iounmap(volatile void __iomem *addr); | ||
| 8 | #define __raw_writeb __raw_writeb | ||
| 9 | static inline void __raw_writeb(u8 val, volatile void __iomem *addr) | ||
| 10 | { | ||
| 11 | asm volatile("sbi %0, [%1]" : : "r" (val), "r" (addr)); | ||
| 12 | } | ||
| 13 | |||
| 14 | #define __raw_writew __raw_writew | ||
| 15 | static inline void __raw_writew(u16 val, volatile void __iomem *addr) | ||
| 16 | { | ||
| 17 | asm volatile("shi %0, [%1]" : : "r" (val), "r" (addr)); | ||
| 18 | } | ||
| 19 | |||
| 20 | #define __raw_writel __raw_writel | ||
| 21 | static inline void __raw_writel(u32 val, volatile void __iomem *addr) | ||
| 22 | { | ||
| 23 | asm volatile("swi %0, [%1]" : : "r" (val), "r" (addr)); | ||
| 24 | } | ||
| 25 | |||
| 26 | #define __raw_readb __raw_readb | ||
| 27 | static inline u8 __raw_readb(const volatile void __iomem *addr) | ||
| 28 | { | ||
| 29 | u8 val; | ||
| 30 | |||
| 31 | asm volatile("lbi %0, [%1]" : "=r" (val) : "r" (addr)); | ||
| 32 | return val; | ||
| 33 | } | ||
| 34 | |||
| 35 | #define __raw_readw __raw_readw | ||
| 36 | static inline u16 __raw_readw(const volatile void __iomem *addr) | ||
| 37 | { | ||
| 38 | u16 val; | ||
| 39 | |||
| 40 | asm volatile("lhi %0, [%1]" : "=r" (val) : "r" (addr)); | ||
| 41 | return val; | ||
| 42 | } | ||
| 43 | |||
| 44 | #define __raw_readl __raw_readl | ||
| 45 | static inline u32 __raw_readl(const volatile void __iomem *addr) | ||
| 46 | { | ||
| 47 | u32 val; | ||
| 48 | |||
| 49 | asm volatile("lwi %0, [%1]" : "=r" (val) : "r" (addr)); | ||
| 50 | return val; | ||
| 51 | } | ||
| 52 | |||
| 53 | #define __iormb() rmb() | ||
| 54 | #define __iowmb() wmb() | ||
| 55 | |||
| 56 | #define mmiowb() __asm__ __volatile__ ("msync all" : : : "memory"); | ||
| 57 | |||
| 58 | /* | ||
| 59 | * {read,write}{b,w,l,q}_relaxed() are like the regular version, but | ||
| 60 | * are not guaranteed to provide ordering against spinlocks or memory | ||
| 61 | * accesses. | ||
| 62 | */ | ||
| 63 | |||
| 64 | #define readb_relaxed(c) ({ u8 __v = __raw_readb(c); __v; }) | ||
| 65 | #define readw_relaxed(c) ({ u16 __v = le16_to_cpu((__force __le16)__raw_readw(c)); __v; }) | ||
| 66 | #define readl_relaxed(c) ({ u32 __v = le32_to_cpu((__force __le32)__raw_readl(c)); __v; }) | ||
| 67 | #define writeb_relaxed(v,c) ((void)__raw_writeb((v),(c))) | ||
| 68 | #define writew_relaxed(v,c) ((void)__raw_writew((__force u16)cpu_to_le16(v),(c))) | ||
| 69 | #define writel_relaxed(v,c) ((void)__raw_writel((__force u32)cpu_to_le32(v),(c))) | ||
| 70 | |||
| 71 | /* | ||
| 72 | * {read,write}{b,w,l,q}() access little endian memory and return result in | ||
| 73 | * native endianness. | ||
| 74 | */ | ||
| 75 | #define readb(c) ({ u8 __v = readb_relaxed(c); __iormb(); __v; }) | ||
| 76 | #define readw(c) ({ u16 __v = readw_relaxed(c); __iormb(); __v; }) | ||
| 77 | #define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(); __v; }) | ||
| 78 | |||
| 79 | #define writeb(v,c) ({ __iowmb(); writeb_relaxed((v),(c)); }) | ||
| 80 | #define writew(v,c) ({ __iowmb(); writew_relaxed((v),(c)); }) | ||
| 81 | #define writel(v,c) ({ __iowmb(); writel_relaxed((v),(c)); }) | ||
| 82 | #include <asm-generic/io.h> | ||
| 83 | #endif /* __ASM_NDS32_IO_H */ | ||
diff --git a/arch/nds32/include/asm/irqflags.h b/arch/nds32/include/asm/irqflags.h new file mode 100644 index 000000000000..2bfd00f8bc48 --- /dev/null +++ b/arch/nds32/include/asm/irqflags.h | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #include <asm/nds32.h> | ||
| 5 | #include <nds32_intrinsic.h> | ||
| 6 | |||
| 7 | #define arch_local_irq_disable() \ | ||
| 8 | GIE_DISABLE(); | ||
| 9 | |||
| 10 | #define arch_local_irq_enable() \ | ||
| 11 | GIE_ENABLE(); | ||
| 12 | static inline unsigned long arch_local_irq_save(void) | ||
| 13 | { | ||
| 14 | unsigned long flags; | ||
| 15 | flags = __nds32__mfsr(NDS32_SR_PSW) & PSW_mskGIE; | ||
| 16 | GIE_DISABLE(); | ||
| 17 | return flags; | ||
| 18 | } | ||
| 19 | |||
| 20 | static inline unsigned long arch_local_save_flags(void) | ||
| 21 | { | ||
| 22 | unsigned long flags; | ||
| 23 | flags = __nds32__mfsr(NDS32_SR_PSW) & PSW_mskGIE; | ||
| 24 | return flags; | ||
| 25 | } | ||
| 26 | |||
| 27 | static inline void arch_local_irq_restore(unsigned long flags) | ||
| 28 | { | ||
| 29 | if(flags) | ||
| 30 | GIE_ENABLE(); | ||
| 31 | } | ||
| 32 | |||
| 33 | static inline int arch_irqs_disabled_flags(unsigned long flags) | ||
| 34 | { | ||
| 35 | return !flags; | ||
| 36 | } | ||
diff --git a/arch/nds32/include/asm/l2_cache.h b/arch/nds32/include/asm/l2_cache.h new file mode 100644 index 000000000000..37dd5ef61de8 --- /dev/null +++ b/arch/nds32/include/asm/l2_cache.h | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef L2_CACHE_H | ||
| 5 | #define L2_CACHE_H | ||
| 6 | |||
| 7 | /* CCTL_CMD_OP */ | ||
| 8 | #define L2_CA_CONF_OFF 0x0 | ||
| 9 | #define L2_IF_CONF_OFF 0x4 | ||
| 10 | #define L2CC_SETUP_OFF 0x8 | ||
| 11 | #define L2CC_PROT_OFF 0xC | ||
| 12 | #define L2CC_CTRL_OFF 0x10 | ||
| 13 | #define L2_INT_EN_OFF 0x20 | ||
| 14 | #define L2_STA_OFF 0x24 | ||
| 15 | #define RDERR_ADDR_OFF 0x28 | ||
| 16 | #define WRERR_ADDR_OFF 0x2c | ||
| 17 | #define EVDPTERR_ADDR_OFF 0x30 | ||
| 18 | #define IMPL3ERR_ADDR_OFF 0x34 | ||
| 19 | #define L2_CNT0_CTRL_OFF 0x40 | ||
| 20 | #define L2_EVNT_CNT0_OFF 0x44 | ||
| 21 | #define L2_CNT1_CTRL_OFF 0x48 | ||
| 22 | #define L2_EVNT_CNT1_OFF 0x4c | ||
| 23 | #define L2_CCTL_CMD_OFF 0x60 | ||
| 24 | #define L2_CCTL_STATUS_OFF 0x64 | ||
| 25 | #define L2_LINE_TAG_OFF 0x68 | ||
| 26 | #define L2_LINE_DPT_OFF 0x70 | ||
| 27 | |||
| 28 | #define CCTL_CMD_L2_IX_INVAL 0x0 | ||
| 29 | #define CCTL_CMD_L2_PA_INVAL 0x1 | ||
| 30 | #define CCTL_CMD_L2_IX_WB 0x2 | ||
| 31 | #define CCTL_CMD_L2_PA_WB 0x3 | ||
| 32 | #define CCTL_CMD_L2_PA_WBINVAL 0x5 | ||
| 33 | #define CCTL_CMD_L2_SYNC 0xa | ||
| 34 | |||
| 35 | /* CCTL_CMD_TYPE */ | ||
| 36 | #define CCTL_SINGLE_CMD 0 | ||
| 37 | #define CCTL_BLOCK_CMD 0x10 | ||
| 38 | #define CCTL_ALL_CMD 0x10 | ||
| 39 | |||
| 40 | /****************************************************************************** | ||
| 41 | * L2_CA_CONF (Cache architecture configuration) | ||
| 42 | *****************************************************************************/ | ||
| 43 | #define L2_CA_CONF_offL2SET 0 | ||
| 44 | #define L2_CA_CONF_offL2WAY 4 | ||
| 45 | #define L2_CA_CONF_offL2CLSZ 8 | ||
| 46 | #define L2_CA_CONF_offL2DW 11 | ||
| 47 | #define L2_CA_CONF_offL2PT 14 | ||
| 48 | #define L2_CA_CONF_offL2VER 16 | ||
| 49 | |||
| 50 | #define L2_CA_CONF_mskL2SET (0xFUL << L2_CA_CONF_offL2SET) | ||
| 51 | #define L2_CA_CONF_mskL2WAY (0xFUL << L2_CA_CONF_offL2WAY) | ||
| 52 | #define L2_CA_CONF_mskL2CLSZ (0x7UL << L2_CA_CONF_offL2CLSZ) | ||
| 53 | #define L2_CA_CONF_mskL2DW (0x7UL << L2_CA_CONF_offL2DW) | ||
| 54 | #define L2_CA_CONF_mskL2PT (0x3UL << L2_CA_CONF_offL2PT) | ||
| 55 | #define L2_CA_CONF_mskL2VER (0xFFFFUL << L2_CA_CONF_offL2VER) | ||
| 56 | |||
| 57 | /****************************************************************************** | ||
| 58 | * L2CC_SETUP (L2CC Setup register) | ||
| 59 | *****************************************************************************/ | ||
| 60 | #define L2CC_SETUP_offPART 0 | ||
| 61 | #define L2CC_SETUP_mskPART (0x3UL << L2CC_SETUP_offPART) | ||
| 62 | #define L2CC_SETUP_offDDLATC 4 | ||
| 63 | #define L2CC_SETUP_mskDDLATC (0x3UL << L2CC_SETUP_offDDLATC) | ||
| 64 | #define L2CC_SETUP_offTDLATC 8 | ||
| 65 | #define L2CC_SETUP_mskTDLATC (0x3UL << L2CC_SETUP_offTDLATC) | ||
| 66 | |||
| 67 | /****************************************************************************** | ||
| 68 | * L2CC_PROT (L2CC Protect register) | ||
| 69 | *****************************************************************************/ | ||
| 70 | #define L2CC_PROT_offMRWEN 31 | ||
| 71 | #define L2CC_PROT_mskMRWEN (0x1UL << L2CC_PROT_offMRWEN) | ||
| 72 | |||
| 73 | /****************************************************************************** | ||
| 74 | * L2_CCTL_STATUS_Mn (The L2CCTL command working status for Master n) | ||
| 75 | *****************************************************************************/ | ||
| 76 | #define L2CC_CTRL_offEN 31 | ||
| 77 | #define L2CC_CTRL_mskEN (0x1UL << L2CC_CTRL_offEN) | ||
| 78 | |||
| 79 | /****************************************************************************** | ||
| 80 | * L2_CCTL_STATUS_Mn (The L2CCTL command working status for Master n) | ||
| 81 | *****************************************************************************/ | ||
| 82 | #define L2_CCTL_STATUS_offCMD_COMP 31 | ||
| 83 | #define L2_CCTL_STATUS_mskCMD_COMP (0x1 << L2_CCTL_STATUS_offCMD_COMP) | ||
| 84 | |||
| 85 | extern void __iomem *atl2c_base; | ||
| 86 | #include <linux/smp.h> | ||
| 87 | #include <asm/io.h> | ||
| 88 | #include <asm/bitfield.h> | ||
| 89 | |||
| 90 | #define L2C_R_REG(offset) readl(atl2c_base + offset) | ||
| 91 | #define L2C_W_REG(offset, value) writel(value, atl2c_base + offset) | ||
| 92 | |||
| 93 | #define L2_CMD_RDY() \ | ||
| 94 | do{;}while((L2C_R_REG(L2_CCTL_STATUS_OFF) & L2_CCTL_STATUS_mskCMD_COMP) == 0) | ||
| 95 | |||
| 96 | static inline unsigned long L2_CACHE_SET(void) | ||
| 97 | { | ||
| 98 | return 64 << ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2SET) >> | ||
| 99 | L2_CA_CONF_offL2SET); | ||
| 100 | } | ||
| 101 | |||
| 102 | static inline unsigned long L2_CACHE_WAY(void) | ||
| 103 | { | ||
| 104 | return 1 + | ||
| 105 | ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2WAY) >> | ||
| 106 | L2_CA_CONF_offL2WAY); | ||
| 107 | } | ||
| 108 | |||
| 109 | static inline unsigned long L2_CACHE_LINE_SIZE(void) | ||
| 110 | { | ||
| 111 | |||
| 112 | return 4 << ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2CLSZ) >> | ||
| 113 | L2_CA_CONF_offL2CLSZ); | ||
| 114 | } | ||
| 115 | |||
| 116 | static inline unsigned long GET_L2CC_CTRL_CPU(unsigned long cpu) | ||
| 117 | { | ||
| 118 | if (cpu == smp_processor_id()) | ||
| 119 | return L2C_R_REG(L2CC_CTRL_OFF); | ||
| 120 | return L2C_R_REG(L2CC_CTRL_OFF + (cpu << 8)); | ||
| 121 | } | ||
| 122 | |||
| 123 | static inline void SET_L2CC_CTRL_CPU(unsigned long cpu, unsigned long val) | ||
| 124 | { | ||
| 125 | if (cpu == smp_processor_id()) | ||
| 126 | L2C_W_REG(L2CC_CTRL_OFF, val); | ||
| 127 | else | ||
| 128 | L2C_W_REG(L2CC_CTRL_OFF + (cpu << 8), val); | ||
| 129 | } | ||
| 130 | |||
| 131 | static inline unsigned long GET_L2CC_STATUS_CPU(unsigned long cpu) | ||
| 132 | { | ||
| 133 | if (cpu == smp_processor_id()) | ||
| 134 | return L2C_R_REG(L2_CCTL_STATUS_OFF); | ||
| 135 | return L2C_R_REG(L2_CCTL_STATUS_OFF + (cpu << 8)); | ||
| 136 | } | ||
| 137 | #endif | ||
diff --git a/arch/nds32/include/asm/linkage.h b/arch/nds32/include/asm/linkage.h new file mode 100644 index 000000000000..e708c8bdb926 --- /dev/null +++ b/arch/nds32/include/asm/linkage.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_LINKAGE_H | ||
| 5 | #define __ASM_LINKAGE_H | ||
| 6 | |||
| 7 | /* This file is required by include/linux/linkage.h */ | ||
| 8 | #define __ALIGN .align 2 | ||
| 9 | #define __ALIGN_STR ".align 2" | ||
| 10 | |||
| 11 | #endif | ||
diff --git a/arch/nds32/include/asm/memory.h b/arch/nds32/include/asm/memory.h new file mode 100644 index 000000000000..60efc726b56e --- /dev/null +++ b/arch/nds32/include/asm/memory.h | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_MEMORY_H | ||
| 5 | #define __ASM_NDS32_MEMORY_H | ||
| 6 | |||
| 7 | #include <linux/compiler.h> | ||
| 8 | #include <linux/sizes.h> | ||
| 9 | |||
| 10 | #ifndef __ASSEMBLY__ | ||
| 11 | #include <asm/page.h> | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #ifndef PHYS_OFFSET | ||
| 15 | #define PHYS_OFFSET (0x0) | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #ifndef __virt_to_bus | ||
| 19 | #define __virt_to_bus __virt_to_phys | ||
| 20 | #endif | ||
| 21 | |||
| 22 | #ifndef __bus_to_virt | ||
| 23 | #define __bus_to_virt __phys_to_virt | ||
| 24 | #endif | ||
| 25 | |||
| 26 | /* | ||
| 27 | * TASK_SIZE - the maximum size of a user space task. | ||
| 28 | * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area | ||
| 29 | */ | ||
| 30 | #define TASK_SIZE ((CONFIG_PAGE_OFFSET) - (SZ_32M)) | ||
| 31 | #define TASK_UNMAPPED_BASE ALIGN(TASK_SIZE / 3, SZ_32M) | ||
| 32 | #define PAGE_OFFSET (CONFIG_PAGE_OFFSET) | ||
| 33 | |||
| 34 | /* | ||
| 35 | * Physical vs virtual RAM address space conversion. These are | ||
| 36 | * private definitions which should NOT be used outside memory.h | ||
| 37 | * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. | ||
| 38 | */ | ||
| 39 | #ifndef __virt_to_phys | ||
| 40 | #define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET) | ||
| 41 | #define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET) | ||
| 42 | #endif | ||
| 43 | |||
| 44 | /* | ||
| 45 | * The module space lives between the addresses given by TASK_SIZE | ||
| 46 | * and PAGE_OFFSET - it must be within 32MB of the kernel text. | ||
| 47 | */ | ||
| 48 | #define MODULES_END (PAGE_OFFSET) | ||
| 49 | #define MODULES_VADDR (MODULES_END - SZ_32M) | ||
| 50 | |||
| 51 | #if TASK_SIZE > MODULES_VADDR | ||
| 52 | #error Top of user space clashes with start of module space | ||
| 53 | #endif | ||
| 54 | |||
| 55 | #ifndef __ASSEMBLY__ | ||
| 56 | |||
| 57 | /* | ||
| 58 | * PFNs are used to describe any physical page; this means | ||
| 59 | * PFN 0 == physical address 0. | ||
| 60 | * | ||
| 61 | * This is the PFN of the first RAM page in the kernel | ||
| 62 | * direct-mapped view. We assume this is the first page | ||
| 63 | * of RAM in the mem_map as well. | ||
| 64 | */ | ||
| 65 | #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) | ||
| 66 | |||
| 67 | /* | ||
| 68 | * Drivers should NOT use these either. | ||
| 69 | */ | ||
| 70 | #define __pa(x) __virt_to_phys((unsigned long)(x)) | ||
| 71 | #define __va(x) ((void *)__phys_to_virt((unsigned long)(x))) | ||
| 72 | |||
| 73 | /* | ||
| 74 | * Conversion between a struct page and a physical address. | ||
| 75 | * | ||
| 76 | * Note: when converting an unknown physical address to a | ||
| 77 | * struct page, the resulting pointer must be validated | ||
| 78 | * using VALID_PAGE(). It must return an invalid struct page | ||
| 79 | * for any physical address not corresponding to a system | ||
| 80 | * RAM address. | ||
| 81 | * | ||
| 82 | * pfn_valid(pfn) indicates whether a PFN number is valid | ||
| 83 | * | ||
| 84 | * virt_to_page(k) convert a _valid_ virtual address to struct page * | ||
| 85 | * virt_addr_valid(k) indicates whether a virtual address is valid | ||
| 86 | */ | ||
| 87 | #ifndef CONFIG_DISCONTIGMEM | ||
| 88 | |||
| 89 | #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET | ||
| 90 | #define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) | ||
| 91 | |||
| 92 | #define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)) | ||
| 93 | #define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) | ||
| 94 | |||
| 95 | #else /* CONFIG_DISCONTIGMEM */ | ||
| 96 | #error CONFIG_DISCONTIGMEM is not supported yet. | ||
| 97 | #endif /* !CONFIG_DISCONTIGMEM */ | ||
| 98 | |||
| 99 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | ||
| 100 | |||
| 101 | #endif | ||
| 102 | |||
| 103 | #include <asm-generic/memory_model.h> | ||
| 104 | |||
| 105 | #endif | ||
diff --git a/arch/nds32/include/asm/mmu.h b/arch/nds32/include/asm/mmu.h new file mode 100644 index 000000000000..88b9ee8c1064 --- /dev/null +++ b/arch/nds32/include/asm/mmu.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_MMU_H | ||
| 5 | #define __NDS32_MMU_H | ||
| 6 | |||
| 7 | typedef struct { | ||
| 8 | unsigned int id; | ||
| 9 | void *vdso; | ||
| 10 | } mm_context_t; | ||
| 11 | |||
| 12 | #endif | ||
diff --git a/arch/nds32/include/asm/mmu_context.h b/arch/nds32/include/asm/mmu_context.h new file mode 100644 index 000000000000..fd7d13cefccc --- /dev/null +++ b/arch/nds32/include/asm/mmu_context.h | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_MMU_CONTEXT_H | ||
| 5 | #define __ASM_NDS32_MMU_CONTEXT_H | ||
| 6 | |||
| 7 | #include <linux/spinlock.h> | ||
| 8 | #include <asm/tlbflush.h> | ||
| 9 | #include <asm/proc-fns.h> | ||
| 10 | #include <asm-generic/mm_hooks.h> | ||
| 11 | |||
| 12 | static inline int | ||
| 13 | init_new_context(struct task_struct *tsk, struct mm_struct *mm) | ||
| 14 | { | ||
| 15 | mm->context.id = 0; | ||
| 16 | return 0; | ||
| 17 | } | ||
| 18 | |||
| 19 | #define destroy_context(mm) do { } while(0) | ||
| 20 | |||
| 21 | #define CID_BITS 9 | ||
| 22 | extern spinlock_t cid_lock; | ||
| 23 | extern unsigned int cpu_last_cid; | ||
| 24 | |||
| 25 | static inline void __new_context(struct mm_struct *mm) | ||
| 26 | { | ||
| 27 | unsigned int cid; | ||
| 28 | unsigned long flags; | ||
| 29 | |||
| 30 | spin_lock_irqsave(&cid_lock, flags); | ||
| 31 | cid = cpu_last_cid; | ||
| 32 | cpu_last_cid += 1 << TLB_MISC_offCID; | ||
| 33 | if (cpu_last_cid == 0) | ||
| 34 | cpu_last_cid = 1 << TLB_MISC_offCID << CID_BITS; | ||
| 35 | |||
| 36 | if ((cid & TLB_MISC_mskCID) == 0) | ||
| 37 | flush_tlb_all(); | ||
| 38 | spin_unlock_irqrestore(&cid_lock, flags); | ||
| 39 | |||
| 40 | mm->context.id = cid; | ||
| 41 | } | ||
| 42 | |||
| 43 | static inline void check_context(struct mm_struct *mm) | ||
| 44 | { | ||
| 45 | if (unlikely | ||
| 46 | ((mm->context.id ^ cpu_last_cid) >> TLB_MISC_offCID >> CID_BITS)) | ||
| 47 | __new_context(mm); | ||
| 48 | } | ||
| 49 | |||
| 50 | static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) | ||
| 51 | { | ||
| 52 | } | ||
| 53 | |||
| 54 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | ||
| 55 | struct task_struct *tsk) | ||
| 56 | { | ||
| 57 | unsigned int cpu = smp_processor_id(); | ||
| 58 | |||
| 59 | if (!cpumask_test_and_set_cpu(cpu, mm_cpumask(next)) || prev != next) { | ||
| 60 | check_context(next); | ||
| 61 | cpu_switch_mm(next); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | #define deactivate_mm(tsk,mm) do { } while (0) | ||
| 66 | #define activate_mm(prev,next) switch_mm(prev, next, NULL) | ||
| 67 | |||
| 68 | #endif | ||
diff --git a/arch/nds32/include/asm/module.h b/arch/nds32/include/asm/module.h new file mode 100644 index 000000000000..16cf9c7237ad --- /dev/null +++ b/arch/nds32/include/asm/module.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASM_NDS32_MODULE_H | ||
| 5 | #define _ASM_NDS32_MODULE_H | ||
| 6 | |||
| 7 | #include <asm-generic/module.h> | ||
| 8 | |||
| 9 | #define MODULE_ARCH_VERMAGIC "NDS32v3" | ||
| 10 | |||
| 11 | #endif /* _ASM_NDS32_MODULE_H */ | ||
diff --git a/arch/nds32/include/asm/nds32.h b/arch/nds32/include/asm/nds32.h new file mode 100644 index 000000000000..19b19394a936 --- /dev/null +++ b/arch/nds32/include/asm/nds32.h | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASM_NDS32_NDS32_H_ | ||
| 5 | #define _ASM_NDS32_NDS32_H_ | ||
| 6 | |||
| 7 | #include <asm/bitfield.h> | ||
| 8 | #include <asm/cachectl.h> | ||
| 9 | |||
| 10 | #ifndef __ASSEMBLY__ | ||
| 11 | #include <linux/init.h> | ||
| 12 | #include <asm/barrier.h> | ||
| 13 | #include <nds32_intrinsic.h> | ||
| 14 | |||
| 15 | #ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE | ||
| 16 | #define FP_OFFSET (-3) | ||
| 17 | #else | ||
| 18 | #define FP_OFFSET (-2) | ||
| 19 | #endif | ||
| 20 | |||
| 21 | extern void __init early_trap_init(void); | ||
| 22 | static inline void GIE_ENABLE(void) | ||
| 23 | { | ||
| 24 | mb(); | ||
| 25 | __nds32__gie_en(); | ||
| 26 | } | ||
| 27 | |||
| 28 | static inline void GIE_DISABLE(void) | ||
| 29 | { | ||
| 30 | mb(); | ||
| 31 | __nds32__gie_dis(); | ||
| 32 | } | ||
| 33 | |||
| 34 | static inline unsigned long CACHE_SET(unsigned char cache) | ||
| 35 | { | ||
| 36 | |||
| 37 | if (cache == ICACHE) | ||
| 38 | return 64 << ((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskISET) >> | ||
| 39 | ICM_CFG_offISET); | ||
| 40 | else | ||
| 41 | return 64 << ((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDSET) >> | ||
| 42 | DCM_CFG_offDSET); | ||
| 43 | } | ||
| 44 | |||
| 45 | static inline unsigned long CACHE_WAY(unsigned char cache) | ||
| 46 | { | ||
| 47 | |||
| 48 | if (cache == ICACHE) | ||
| 49 | return 1 + | ||
| 50 | ((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskIWAY) >> ICM_CFG_offIWAY); | ||
| 51 | else | ||
| 52 | return 1 + | ||
| 53 | ((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDWAY) >> DCM_CFG_offDWAY); | ||
| 54 | } | ||
| 55 | |||
| 56 | static inline unsigned long CACHE_LINE_SIZE(unsigned char cache) | ||
| 57 | { | ||
| 58 | |||
| 59 | if (cache == ICACHE) | ||
| 60 | return 8 << | ||
| 61 | (((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskISZ) >> ICM_CFG_offISZ) - 1); | ||
| 62 | else | ||
| 63 | return 8 << | ||
| 64 | (((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDSZ) >> DCM_CFG_offDSZ) - 1); | ||
| 65 | } | ||
| 66 | |||
| 67 | #endif /* __ASSEMBLY__ */ | ||
| 68 | |||
| 69 | #define IVB_BASE PHYS_OFFSET /* in user space for intr/exc/trap/break table base, 64KB aligned | ||
| 70 | * We defined at the start of the physical memory */ | ||
| 71 | |||
| 72 | /* dispatched sub-entry exception handler numbering */ | ||
| 73 | #define RD_PROT 0 /* read protrection */ | ||
| 74 | #define WRT_PROT 1 /* write protection */ | ||
| 75 | #define NOEXEC 2 /* non executable */ | ||
| 76 | #define PAGE_MODIFY 3 /* page modified */ | ||
| 77 | #define ACC_BIT 4 /* access bit */ | ||
| 78 | #define RESVED_PTE 5 /* reserved PTE attribute */ | ||
| 79 | /* reserved 6 ~ 16 */ | ||
| 80 | |||
| 81 | #endif /* _ASM_NDS32_NDS32_H_ */ | ||
diff --git a/arch/nds32/include/asm/page.h b/arch/nds32/include/asm/page.h new file mode 100644 index 000000000000..e27365c097b6 --- /dev/null +++ b/arch/nds32/include/asm/page.h | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | /* | ||
| 2 | * SPDX-License-Identifier: GPL-2.0 | ||
| 3 | * Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef _ASMNDS32_PAGE_H | ||
| 7 | #define _ASMNDS32_PAGE_H | ||
| 8 | |||
| 9 | #ifdef CONFIG_ANDES_PAGE_SIZE_4KB | ||
| 10 | #define PAGE_SHIFT 12 | ||
| 11 | #endif | ||
| 12 | #ifdef CONFIG_ANDES_PAGE_SIZE_8KB | ||
| 13 | #define PAGE_SHIFT 13 | ||
| 14 | #endif | ||
| 15 | #include <linux/const.h> | ||
| 16 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) | ||
| 17 | #define PAGE_MASK (~(PAGE_SIZE-1)) | ||
| 18 | |||
| 19 | #ifdef __KERNEL__ | ||
| 20 | |||
| 21 | #ifndef __ASSEMBLY__ | ||
| 22 | |||
| 23 | struct page; | ||
| 24 | struct vm_area_struct; | ||
| 25 | #ifdef CONFIG_CPU_CACHE_ALIASING | ||
| 26 | extern void copy_user_highpage(struct page *to, struct page *from, | ||
| 27 | unsigned long vaddr, struct vm_area_struct *vma); | ||
| 28 | extern void clear_user_highpage(struct page *page, unsigned long vaddr); | ||
| 29 | |||
| 30 | #define __HAVE_ARCH_COPY_USER_HIGHPAGE | ||
| 31 | #define clear_user_highpage clear_user_highpage | ||
| 32 | #else | ||
| 33 | #define clear_user_page(page, vaddr, pg) clear_page(page) | ||
| 34 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) | ||
| 35 | #endif | ||
| 36 | |||
| 37 | void clear_page(void *page); | ||
| 38 | void copy_page(void *to, void *from); | ||
| 39 | |||
| 40 | typedef unsigned long pte_t; | ||
| 41 | typedef unsigned long pmd_t; | ||
| 42 | typedef unsigned long pgd_t; | ||
| 43 | typedef unsigned long pgprot_t; | ||
| 44 | |||
| 45 | #define pte_val(x) (x) | ||
| 46 | #define pmd_val(x) (x) | ||
| 47 | #define pgd_val(x) (x) | ||
| 48 | #define pgprot_val(x) (x) | ||
| 49 | |||
| 50 | #define __pte(x) (x) | ||
| 51 | #define __pmd(x) (x) | ||
| 52 | #define __pgd(x) (x) | ||
| 53 | #define __pgprot(x) (x) | ||
| 54 | |||
| 55 | typedef struct page *pgtable_t; | ||
| 56 | |||
| 57 | #include <asm/memory.h> | ||
| 58 | #include <asm-generic/getorder.h> | ||
| 59 | |||
| 60 | #endif /* !__ASSEMBLY__ */ | ||
| 61 | |||
| 62 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ | ||
| 63 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
| 64 | |||
| 65 | #endif /* __KERNEL__ */ | ||
| 66 | |||
| 67 | #endif | ||
diff --git a/arch/nds32/include/asm/pgalloc.h b/arch/nds32/include/asm/pgalloc.h new file mode 100644 index 000000000000..27448869131a --- /dev/null +++ b/arch/nds32/include/asm/pgalloc.h | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASMNDS32_PGALLOC_H | ||
| 5 | #define _ASMNDS32_PGALLOC_H | ||
| 6 | |||
| 7 | #include <asm/processor.h> | ||
| 8 | #include <asm/cacheflush.h> | ||
| 9 | #include <asm/tlbflush.h> | ||
| 10 | #include <asm/proc-fns.h> | ||
| 11 | |||
| 12 | /* | ||
| 13 | * Since we have only two-level page tables, these are trivial | ||
| 14 | */ | ||
| 15 | #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); }) | ||
| 16 | #define pmd_free(mm, pmd) do { } while (0) | ||
| 17 | #define pgd_populate(mm, pmd, pte) BUG() | ||
| 18 | #define pmd_pgtable(pmd) pmd_page(pmd) | ||
| 19 | |||
| 20 | extern pgd_t *pgd_alloc(struct mm_struct *mm); | ||
| 21 | extern void pgd_free(struct mm_struct *mm, pgd_t * pgd); | ||
| 22 | |||
| 23 | #define check_pgt_cache() do { } while (0) | ||
| 24 | |||
| 25 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, | ||
| 26 | unsigned long addr) | ||
| 27 | { | ||
| 28 | pte_t *pte; | ||
| 29 | |||
| 30 | pte = | ||
| 31 | (pte_t *) __get_free_page(GFP_KERNEL | __GFP_RETRY_MAYFAIL | | ||
| 32 | __GFP_ZERO); | ||
| 33 | |||
| 34 | return pte; | ||
| 35 | } | ||
| 36 | |||
| 37 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr) | ||
| 38 | { | ||
| 39 | pgtable_t pte; | ||
| 40 | |||
| 41 | pte = alloc_pages(GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_ZERO, 0); | ||
| 42 | if (pte) | ||
| 43 | cpu_dcache_wb_page((unsigned long)page_address(pte)); | ||
| 44 | |||
| 45 | return pte; | ||
| 46 | } | ||
| 47 | |||
| 48 | /* | ||
| 49 | * Free one PTE table. | ||
| 50 | */ | ||
| 51 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t * pte) | ||
| 52 | { | ||
| 53 | if (pte) { | ||
| 54 | free_page((unsigned long)pte); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | static inline void pte_free(struct mm_struct *mm, pgtable_t pte) | ||
| 59 | { | ||
| 60 | __free_page(pte); | ||
| 61 | } | ||
| 62 | |||
| 63 | /* | ||
| 64 | * Populate the pmdp entry with a pointer to the pte. This pmd is part | ||
| 65 | * of the mm address space. | ||
| 66 | * | ||
| 67 | * Ensure that we always set both PMD entries. | ||
| 68 | */ | ||
| 69 | static inline void | ||
| 70 | pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmdp, pte_t * ptep) | ||
| 71 | { | ||
| 72 | unsigned long pte_ptr = (unsigned long)ptep; | ||
| 73 | unsigned long pmdval; | ||
| 74 | |||
| 75 | BUG_ON(mm != &init_mm); | ||
| 76 | |||
| 77 | /* | ||
| 78 | * The pmd must be loaded with the physical | ||
| 79 | * address of the PTE table | ||
| 80 | */ | ||
| 81 | pmdval = __pa(pte_ptr) | _PAGE_KERNEL_TABLE; | ||
| 82 | set_pmd(pmdp, __pmd(pmdval)); | ||
| 83 | } | ||
| 84 | |||
| 85 | static inline void | ||
| 86 | pmd_populate(struct mm_struct *mm, pmd_t * pmdp, pgtable_t ptep) | ||
| 87 | { | ||
| 88 | unsigned long pmdval; | ||
| 89 | |||
| 90 | BUG_ON(mm == &init_mm); | ||
| 91 | |||
| 92 | pmdval = page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE; | ||
| 93 | set_pmd(pmdp, __pmd(pmdval)); | ||
| 94 | } | ||
| 95 | |||
| 96 | #endif | ||
diff --git a/arch/nds32/include/asm/pgtable.h b/arch/nds32/include/asm/pgtable.h new file mode 100644 index 000000000000..6783937edbeb --- /dev/null +++ b/arch/nds32/include/asm/pgtable.h | |||
| @@ -0,0 +1,409 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASMNDS32_PGTABLE_H | ||
| 5 | #define _ASMNDS32_PGTABLE_H | ||
| 6 | |||
| 7 | #define __PAGETABLE_PMD_FOLDED | ||
| 8 | #include <asm-generic/4level-fixup.h> | ||
| 9 | #include <asm-generic/sizes.h> | ||
| 10 | |||
| 11 | #include <asm/memory.h> | ||
| 12 | #include <asm/nds32.h> | ||
| 13 | #ifndef __ASSEMBLY__ | ||
| 14 | #include <asm/fixmap.h> | ||
| 15 | #include <asm/io.h> | ||
| 16 | #include <nds32_intrinsic.h> | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #ifdef CONFIG_ANDES_PAGE_SIZE_4KB | ||
| 20 | #define PGDIR_SHIFT 22 | ||
| 21 | #define PTRS_PER_PGD 1024 | ||
| 22 | #define PMD_SHIFT 22 | ||
| 23 | #define PTRS_PER_PMD 1 | ||
| 24 | #define PTRS_PER_PTE 1024 | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #ifdef CONFIG_ANDES_PAGE_SIZE_8KB | ||
| 28 | #define PGDIR_SHIFT 24 | ||
| 29 | #define PTRS_PER_PGD 256 | ||
| 30 | #define PMD_SHIFT 24 | ||
| 31 | #define PTRS_PER_PMD 1 | ||
| 32 | #define PTRS_PER_PTE 2048 | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #ifndef __ASSEMBLY__ | ||
| 36 | extern void __pte_error(const char *file, int line, unsigned long val); | ||
| 37 | extern void __pmd_error(const char *file, int line, unsigned long val); | ||
| 38 | extern void __pgd_error(const char *file, int line, unsigned long val); | ||
| 39 | |||
| 40 | #define pte_ERROR(pte) __pte_error(__FILE__, __LINE__, pte_val(pte)) | ||
| 41 | #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd_val(pmd)) | ||
| 42 | #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd)) | ||
| 43 | #endif /* !__ASSEMBLY__ */ | ||
| 44 | |||
| 45 | #define PMD_SIZE (1UL << PMD_SHIFT) | ||
| 46 | #define PMD_MASK (~(PMD_SIZE-1)) | ||
| 47 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) | ||
| 48 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) | ||
| 49 | |||
| 50 | /* | ||
| 51 | * This is the lowest virtual address we can permit any user space | ||
| 52 | * mapping to be mapped at. This is particularly important for | ||
| 53 | * non-high vector CPUs. | ||
| 54 | */ | ||
| 55 | #define FIRST_USER_ADDRESS 0x8000 | ||
| 56 | |||
| 57 | #ifdef CONFIG_HIGHMEM | ||
| 58 | #define CONSISTENT_BASE ((PKMAP_BASE) - (SZ_2M)) | ||
| 59 | #define CONSISTENT_END (PKMAP_BASE) | ||
| 60 | #else | ||
| 61 | #define CONSISTENT_BASE (FIXADDR_START - SZ_2M) | ||
| 62 | #define CONSISTENT_END (FIXADDR_START) | ||
| 63 | #endif | ||
| 64 | #define CONSISTENT_OFFSET(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT) | ||
| 65 | |||
| 66 | #ifdef CONFIG_HIGHMEM | ||
| 67 | #ifndef __ASSEMBLY__ | ||
| 68 | #include <asm/highmem.h> | ||
| 69 | #endif | ||
| 70 | #endif | ||
| 71 | |||
| 72 | #define VMALLOC_RESERVE SZ_128M | ||
| 73 | #define VMALLOC_END (CONSISTENT_BASE - PAGE_SIZE) | ||
| 74 | #define VMALLOC_START ((VMALLOC_END) - VMALLOC_RESERVE) | ||
| 75 | #define VMALLOC_VMADDR(x) ((unsigned long)(x)) | ||
| 76 | #define MAXMEM __pa(VMALLOC_START) | ||
| 77 | #define MAXMEM_PFN PFN_DOWN(MAXMEM) | ||
| 78 | |||
| 79 | #define FIRST_USER_PGD_NR 0 | ||
| 80 | #define USER_PTRS_PER_PGD ((TASK_SIZE/PGDIR_SIZE) + FIRST_USER_PGD_NR) | ||
| 81 | |||
| 82 | /* L2 PTE */ | ||
| 83 | #define _PAGE_V (1UL << 0) | ||
| 84 | |||
| 85 | #define _PAGE_M_XKRW (0UL << 1) | ||
| 86 | #define _PAGE_M_UR_KR (1UL << 1) | ||
| 87 | #define _PAGE_M_UR_KRW (2UL << 1) | ||
| 88 | #define _PAGE_M_URW_KRW (3UL << 1) | ||
| 89 | #define _PAGE_M_KR (5UL << 1) | ||
| 90 | #define _PAGE_M_KRW (7UL << 1) | ||
| 91 | |||
| 92 | #define _PAGE_D (1UL << 4) | ||
| 93 | #define _PAGE_E (1UL << 5) | ||
| 94 | #define _PAGE_A (1UL << 6) | ||
| 95 | #define _PAGE_G (1UL << 7) | ||
| 96 | |||
| 97 | #define _PAGE_C_DEV (0UL << 8) | ||
| 98 | #define _PAGE_C_DEV_WB (1UL << 8) | ||
| 99 | #define _PAGE_C_MEM (2UL << 8) | ||
| 100 | #define _PAGE_C_MEM_SHRD_WB (4UL << 8) | ||
| 101 | #define _PAGE_C_MEM_SHRD_WT (5UL << 8) | ||
| 102 | #define _PAGE_C_MEM_WB (6UL << 8) | ||
| 103 | #define _PAGE_C_MEM_WT (7UL << 8) | ||
| 104 | |||
| 105 | #define _PAGE_L (1UL << 11) | ||
| 106 | |||
| 107 | #define _HAVE_PAGE_L (_PAGE_L) | ||
| 108 | #define _PAGE_FILE (1UL << 1) | ||
| 109 | #define _PAGE_YOUNG 0 | ||
| 110 | #define _PAGE_M_MASK _PAGE_M_KRW | ||
| 111 | #define _PAGE_C_MASK _PAGE_C_MEM_WT | ||
| 112 | |||
| 113 | #ifdef CONFIG_SMP | ||
| 114 | #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH | ||
| 115 | #define _PAGE_CACHE_SHRD _PAGE_C_MEM_SHRD_WT | ||
| 116 | #else | ||
| 117 | #define _PAGE_CACHE_SHRD _PAGE_C_MEM_SHRD_WB | ||
| 118 | #endif | ||
| 119 | #else | ||
| 120 | #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH | ||
| 121 | #define _PAGE_CACHE_SHRD _PAGE_C_MEM_WT | ||
| 122 | #else | ||
| 123 | #define _PAGE_CACHE_SHRD _PAGE_C_MEM_WB | ||
| 124 | #endif | ||
| 125 | #endif | ||
| 126 | |||
| 127 | #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH | ||
| 128 | #define _PAGE_CACHE _PAGE_C_MEM_WT | ||
| 129 | #else | ||
| 130 | #define _PAGE_CACHE _PAGE_C_MEM_WB | ||
| 131 | #endif | ||
| 132 | |||
| 133 | /* | ||
| 134 | * + Level 1 descriptor (PMD) | ||
| 135 | */ | ||
| 136 | #define PMD_TYPE_TABLE 0 | ||
| 137 | |||
| 138 | #ifndef __ASSEMBLY__ | ||
| 139 | |||
| 140 | #define _PAGE_USER_TABLE PMD_TYPE_TABLE | ||
| 141 | #define _PAGE_KERNEL_TABLE PMD_TYPE_TABLE | ||
| 142 | |||
| 143 | #define PAGE_EXEC __pgprot(_PAGE_V | _PAGE_M_XKRW | _PAGE_E) | ||
| 144 | #define PAGE_NONE __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_A) | ||
| 145 | #define PAGE_READ __pgprot(_PAGE_V | _PAGE_M_UR_KR) | ||
| 146 | #define PAGE_RDWR __pgprot(_PAGE_V | _PAGE_M_URW_KRW | _PAGE_D) | ||
| 147 | #define PAGE_COPY __pgprot(_PAGE_V | _PAGE_M_UR_KR) | ||
| 148 | |||
| 149 | #define PAGE_UXKRWX_V1 __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD) | ||
| 150 | #define PAGE_UXKRWX_V2 __pgprot(_PAGE_V | _PAGE_M_XKRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD) | ||
| 151 | #define PAGE_URXKRWX_V2 __pgprot(_PAGE_V | _PAGE_M_UR_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD) | ||
| 152 | #define PAGE_CACHE_L1 __pgprot(_HAVE_PAGE_L | _PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE) | ||
| 153 | #define PAGE_MEMORY __pgprot(_HAVE_PAGE_L | _PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD) | ||
| 154 | #define PAGE_KERNEL __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD) | ||
| 155 | #define PAGE_DEVICE __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_G | _PAGE_C_DEV) | ||
| 156 | #endif /* __ASSEMBLY__ */ | ||
| 157 | |||
| 158 | /* xwr */ | ||
| 159 | #define __P000 (PAGE_NONE | _PAGE_CACHE_SHRD) | ||
| 160 | #define __P001 (PAGE_READ | _PAGE_CACHE_SHRD) | ||
| 161 | #define __P010 (PAGE_COPY | _PAGE_CACHE_SHRD) | ||
| 162 | #define __P011 (PAGE_COPY | _PAGE_CACHE_SHRD) | ||
| 163 | #define __P100 (PAGE_EXEC | _PAGE_CACHE_SHRD) | ||
| 164 | #define __P101 (PAGE_READ | _PAGE_E | _PAGE_CACHE_SHRD) | ||
| 165 | #define __P110 (PAGE_COPY | _PAGE_E | _PAGE_CACHE_SHRD) | ||
| 166 | #define __P111 (PAGE_COPY | _PAGE_E | _PAGE_CACHE_SHRD) | ||
| 167 | |||
| 168 | #define __S000 (PAGE_NONE | _PAGE_CACHE_SHRD) | ||
| 169 | #define __S001 (PAGE_READ | _PAGE_CACHE_SHRD) | ||
| 170 | #define __S010 (PAGE_RDWR | _PAGE_CACHE_SHRD) | ||
| 171 | #define __S011 (PAGE_RDWR | _PAGE_CACHE_SHRD) | ||
| 172 | #define __S100 (PAGE_EXEC | _PAGE_CACHE_SHRD) | ||
| 173 | #define __S101 (PAGE_READ | _PAGE_E | _PAGE_CACHE_SHRD) | ||
| 174 | #define __S110 (PAGE_RDWR | _PAGE_E | _PAGE_CACHE_SHRD) | ||
| 175 | #define __S111 (PAGE_RDWR | _PAGE_E | _PAGE_CACHE_SHRD) | ||
| 176 | |||
| 177 | #ifndef __ASSEMBLY__ | ||
| 178 | /* | ||
| 179 | * ZERO_PAGE is a global shared page that is always zero: used | ||
| 180 | * for zero-mapped memory areas etc.. | ||
| 181 | */ | ||
| 182 | extern struct page *empty_zero_page; | ||
| 183 | extern void paging_init(void); | ||
| 184 | #define ZERO_PAGE(vaddr) (empty_zero_page) | ||
| 185 | |||
| 186 | #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) | ||
| 187 | #define pfn_pte(pfn,prot) (__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))) | ||
| 188 | |||
| 189 | #define pte_none(pte) !(pte_val(pte)) | ||
| 190 | #define pte_clear(mm,addr,ptep) set_pte_at((mm),(addr),(ptep), __pte(0)) | ||
| 191 | #define pte_page(pte) (pfn_to_page(pte_pfn(pte))) | ||
| 192 | |||
| 193 | #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) | ||
| 194 | #define pte_offset_kernel(dir, address) ((pte_t *)pmd_page_kernel(*(dir)) + pte_index(address)) | ||
| 195 | #define pte_offset_map(dir, address) ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) | ||
| 196 | #define pte_offset_map_nested(dir, address) pte_offset_map(dir, address) | ||
| 197 | #define pmd_page_kernel(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) | ||
| 198 | |||
| 199 | #define pte_unmap(pte) do { } while (0) | ||
| 200 | #define pte_unmap_nested(pte) do { } while (0) | ||
| 201 | |||
| 202 | #define pmd_off_k(address) pmd_offset(pgd_offset_k(address), address) | ||
| 203 | |||
| 204 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) | ||
| 205 | /* | ||
| 206 | * Set a level 1 translation table entry, and clean it out of | ||
| 207 | * any caches such that the MMUs can load it correctly. | ||
| 208 | */ | ||
| 209 | static inline void set_pmd(pmd_t * pmdp, pmd_t pmd) | ||
| 210 | { | ||
| 211 | |||
| 212 | *pmdp = pmd; | ||
| 213 | #if !defined(CONFIG_CPU_DCACHE_DISABLE) && !defined(CONFIG_CPU_DCACHE_WRITETHROUGH) | ||
| 214 | __asm__ volatile ("\n\tcctl %0, L1D_VA_WB"::"r" (pmdp):"memory"); | ||
| 215 | __nds32__msync_all(); | ||
| 216 | __nds32__dsb(); | ||
| 217 | #endif | ||
| 218 | } | ||
| 219 | |||
| 220 | /* | ||
| 221 | * Set a PTE and flush it out | ||
| 222 | */ | ||
| 223 | static inline void set_pte(pte_t * ptep, pte_t pte) | ||
| 224 | { | ||
| 225 | |||
| 226 | *ptep = pte; | ||
| 227 | #if !defined(CONFIG_CPU_DCACHE_DISABLE) && !defined(CONFIG_CPU_DCACHE_WRITETHROUGH) | ||
| 228 | __asm__ volatile ("\n\tcctl %0, L1D_VA_WB"::"r" (ptep):"memory"); | ||
| 229 | __nds32__msync_all(); | ||
| 230 | __nds32__dsb(); | ||
| 231 | #endif | ||
| 232 | } | ||
| 233 | |||
| 234 | /* | ||
| 235 | * The following only work if pte_present() is true. | ||
| 236 | * Undefined behaviour if not.. | ||
| 237 | */ | ||
| 238 | |||
| 239 | /* | ||
| 240 | * pte_write: this page is writeable for user mode | ||
| 241 | * pte_read: this page is readable for user mode | ||
| 242 | * pte_kernel_write: this page is writeable for kernel mode | ||
| 243 | * | ||
| 244 | * We don't have pte_kernel_read because kernel always can read. | ||
| 245 | * | ||
| 246 | * */ | ||
| 247 | |||
| 248 | #define pte_present(pte) (pte_val(pte) & _PAGE_V) | ||
| 249 | #define pte_write(pte) ((pte_val(pte) & _PAGE_M_MASK) == _PAGE_M_URW_KRW) | ||
| 250 | #define pte_read(pte) (((pte_val(pte) & _PAGE_M_MASK) == _PAGE_M_UR_KR) || \ | ||
| 251 | ((pte_val(pte) & _PAGE_M_MASK) == _PAGE_M_UR_KRW) || \ | ||
| 252 | ((pte_val(pte) & _PAGE_M_MASK) == _PAGE_M_URW_KRW)) | ||
| 253 | #define pte_kernel_write(pte) (((pte_val(pte) & _PAGE_M_MASK) == _PAGE_M_URW_KRW) || \ | ||
| 254 | ((pte_val(pte) & _PAGE_M_MASK) == _PAGE_M_UR_KRW) || \ | ||
| 255 | ((pte_val(pte) & _PAGE_M_MASK) == _PAGE_M_KRW) || \ | ||
| 256 | (((pte_val(pte) & _PAGE_M_MASK) == _PAGE_M_XKRW) && pte_exec(pte))) | ||
| 257 | #define pte_exec(pte) (pte_val(pte) & _PAGE_E) | ||
| 258 | #define pte_dirty(pte) (pte_val(pte) & _PAGE_D) | ||
| 259 | #define pte_young(pte) (pte_val(pte) & _PAGE_YOUNG) | ||
| 260 | |||
| 261 | /* | ||
| 262 | * The following only works if pte_present() is not true. | ||
| 263 | */ | ||
| 264 | #define pte_file(pte) (pte_val(pte) & _PAGE_FILE) | ||
| 265 | #define pte_to_pgoff(x) (pte_val(x) >> 2) | ||
| 266 | #define pgoff_to_pte(x) __pte(((x) << 2) | _PAGE_FILE) | ||
| 267 | |||
| 268 | #define PTE_FILE_MAX_BITS 29 | ||
| 269 | |||
| 270 | #define PTE_BIT_FUNC(fn,op) \ | ||
| 271 | static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; } | ||
| 272 | |||
| 273 | static inline pte_t pte_wrprotect(pte_t pte) | ||
| 274 | { | ||
| 275 | pte_val(pte) = pte_val(pte) & ~_PAGE_M_MASK; | ||
| 276 | pte_val(pte) = pte_val(pte) | _PAGE_M_UR_KR; | ||
| 277 | return pte; | ||
| 278 | } | ||
| 279 | |||
| 280 | static inline pte_t pte_mkwrite(pte_t pte) | ||
| 281 | { | ||
| 282 | pte_val(pte) = pte_val(pte) & ~_PAGE_M_MASK; | ||
| 283 | pte_val(pte) = pte_val(pte) | _PAGE_M_URW_KRW; | ||
| 284 | return pte; | ||
| 285 | } | ||
| 286 | |||
| 287 | PTE_BIT_FUNC(exprotect, &=~_PAGE_E); | ||
| 288 | PTE_BIT_FUNC(mkexec, |=_PAGE_E); | ||
| 289 | PTE_BIT_FUNC(mkclean, &=~_PAGE_D); | ||
| 290 | PTE_BIT_FUNC(mkdirty, |=_PAGE_D); | ||
| 291 | PTE_BIT_FUNC(mkold, &=~_PAGE_YOUNG); | ||
| 292 | PTE_BIT_FUNC(mkyoung, |=_PAGE_YOUNG); | ||
| 293 | static inline int pte_special(pte_t pte) | ||
| 294 | { | ||
| 295 | return 0; | ||
| 296 | } | ||
| 297 | |||
| 298 | static inline pte_t pte_mkspecial(pte_t pte) | ||
| 299 | { | ||
| 300 | return pte; | ||
| 301 | } | ||
| 302 | |||
| 303 | /* | ||
| 304 | * Mark the prot value as uncacheable and unbufferable. | ||
| 305 | */ | ||
| 306 | #define pgprot_noncached(prot) __pgprot((pgprot_val(prot)&~_PAGE_C_MASK) | _PAGE_C_DEV) | ||
| 307 | #define pgprot_writecombine(prot) __pgprot((pgprot_val(prot)&~_PAGE_C_MASK) | _PAGE_C_DEV_WB) | ||
| 308 | |||
| 309 | #define pmd_none(pmd) (pmd_val(pmd)&0x1) | ||
| 310 | #define pmd_present(pmd) (!pmd_none(pmd)) | ||
| 311 | #define pmd_bad(pmd) pmd_none(pmd) | ||
| 312 | |||
| 313 | #define copy_pmd(pmdpd,pmdps) set_pmd((pmdpd), *(pmdps)) | ||
| 314 | #define pmd_clear(pmdp) set_pmd((pmdp), __pmd(1)) | ||
| 315 | |||
| 316 | static inline pmd_t __mk_pmd(pte_t * ptep, unsigned long prot) | ||
| 317 | { | ||
| 318 | unsigned long ptr = (unsigned long)ptep; | ||
| 319 | pmd_t pmd; | ||
| 320 | |||
| 321 | /* | ||
| 322 | * The pmd must be loaded with the physical | ||
| 323 | * address of the PTE table | ||
| 324 | */ | ||
| 325 | |||
| 326 | pmd_val(pmd) = __virt_to_phys(ptr) | prot; | ||
| 327 | return pmd; | ||
| 328 | } | ||
| 329 | |||
| 330 | #define pmd_page(pmd) virt_to_page(__va(pmd_val(pmd))) | ||
| 331 | |||
| 332 | /* | ||
| 333 | * Permanent address of a page. We never have highmem, so this is trivial. | ||
| 334 | */ | ||
| 335 | #define pages_to_mb(x) ((x) >> (20 - PAGE_SHIFT)) | ||
| 336 | |||
| 337 | /* | ||
| 338 | * Conversion functions: convert a page and protection to a page entry, | ||
| 339 | * and a page entry and page directory to the page they refer to. | ||
| 340 | */ | ||
| 341 | #define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot) | ||
| 342 | |||
| 343 | /* | ||
| 344 | * The "pgd_xxx()" functions here are trivial for a folded two-level | ||
| 345 | * setup: the pgd is never bad, and a pmd always exists (as it's folded | ||
| 346 | * into the pgd entry) | ||
| 347 | */ | ||
| 348 | #define pgd_none(pgd) (0) | ||
| 349 | #define pgd_bad(pgd) (0) | ||
| 350 | #define pgd_present(pgd) (1) | ||
| 351 | #define pgd_clear(pgdp) do { } while (0) | ||
| 352 | |||
| 353 | #define page_pte_prot(page,prot) mk_pte(page, prot) | ||
| 354 | #define page_pte(page) mk_pte(page, __pgprot(0)) | ||
| 355 | /* | ||
| 356 | * L1PTE = $mr1 + ((virt >> PMD_SHIFT) << 2); | ||
| 357 | * L2PTE = (((virt >> PAGE_SHIFT) & (PTRS_PER_PTE -1 )) << 2); | ||
| 358 | * PPN = (phys & 0xfffff000); | ||
| 359 | * | ||
| 360 | */ | ||
| 361 | |||
| 362 | /* to find an entry in a page-table-directory */ | ||
| 363 | #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) | ||
| 364 | #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address)) | ||
| 365 | /* to find an entry in a kernel page-table-directory */ | ||
| 366 | #define pgd_offset_k(addr) pgd_offset(&init_mm, addr) | ||
| 367 | |||
| 368 | /* Find an entry in the second-level page table.. */ | ||
| 369 | #define pmd_offset(dir, addr) ((pmd_t *)(dir)) | ||
| 370 | |||
| 371 | static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) | ||
| 372 | { | ||
| 373 | const unsigned long mask = 0xfff; | ||
| 374 | pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); | ||
| 375 | return pte; | ||
| 376 | } | ||
| 377 | |||
| 378 | extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; | ||
| 379 | |||
| 380 | /* Encode and decode a swap entry. | ||
| 381 | * | ||
| 382 | * We support up to 32GB of swap on 4k machines | ||
| 383 | */ | ||
| 384 | #define __swp_type(x) (((x).val >> 2) & 0x7f) | ||
| 385 | #define __swp_offset(x) ((x).val >> 9) | ||
| 386 | #define __swp_entry(type,offset) ((swp_entry_t) { ((type) << 2) | ((offset) << 9) }) | ||
| 387 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) | ||
| 388 | #define __swp_entry_to_pte(swp) ((pte_t) { (swp).val }) | ||
| 389 | |||
| 390 | /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */ | ||
| 391 | #define kern_addr_valid(addr) (1) | ||
| 392 | |||
| 393 | #include <asm-generic/pgtable.h> | ||
| 394 | |||
| 395 | /* | ||
| 396 | * We provide our own arch_get_unmapped_area to cope with VIPT caches. | ||
| 397 | */ | ||
| 398 | #define HAVE_ARCH_UNMAPPED_AREA | ||
| 399 | |||
| 400 | /* | ||
| 401 | * remap a physical address `phys' of size `size' with page protection `prot' | ||
| 402 | * into virtual address `from' | ||
| 403 | */ | ||
| 404 | |||
| 405 | #define pgtable_cache_init() do { } while (0) | ||
| 406 | |||
| 407 | #endif /* !__ASSEMBLY__ */ | ||
| 408 | |||
| 409 | #endif /* _ASMNDS32_PGTABLE_H */ | ||
diff --git a/arch/nds32/include/asm/proc-fns.h b/arch/nds32/include/asm/proc-fns.h new file mode 100644 index 000000000000..bedc4f59e064 --- /dev/null +++ b/arch/nds32/include/asm/proc-fns.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_PROCFNS_H__ | ||
| 5 | #define __NDS32_PROCFNS_H__ | ||
| 6 | |||
| 7 | #ifdef __KERNEL__ | ||
| 8 | #include <asm/page.h> | ||
| 9 | |||
| 10 | struct mm_struct; | ||
| 11 | struct vm_area_struct; | ||
| 12 | extern void cpu_proc_init(void); | ||
| 13 | extern void cpu_proc_fin(void); | ||
| 14 | extern void cpu_do_idle(void); | ||
| 15 | extern void cpu_reset(unsigned long reset); | ||
| 16 | extern void cpu_switch_mm(struct mm_struct *mm); | ||
| 17 | |||
| 18 | extern void cpu_dcache_inval_all(void); | ||
| 19 | extern void cpu_dcache_wbinval_all(void); | ||
| 20 | extern void cpu_dcache_inval_page(unsigned long page); | ||
| 21 | extern void cpu_dcache_wb_page(unsigned long page); | ||
| 22 | extern void cpu_dcache_wbinval_page(unsigned long page); | ||
| 23 | extern void cpu_dcache_inval_range(unsigned long start, unsigned long end); | ||
| 24 | extern void cpu_dcache_wb_range(unsigned long start, unsigned long end); | ||
| 25 | extern void cpu_dcache_wbinval_range(unsigned long start, unsigned long end); | ||
| 26 | |||
| 27 | extern void cpu_icache_inval_all(void); | ||
| 28 | extern void cpu_icache_inval_page(unsigned long page); | ||
| 29 | extern void cpu_icache_inval_range(unsigned long start, unsigned long end); | ||
| 30 | |||
| 31 | extern void cpu_cache_wbinval_page(unsigned long page, int flushi); | ||
| 32 | extern void cpu_cache_wbinval_range(unsigned long start, | ||
| 33 | unsigned long end, int flushi); | ||
| 34 | extern void cpu_cache_wbinval_range_check(struct vm_area_struct *vma, | ||
| 35 | unsigned long start, | ||
| 36 | unsigned long end, bool flushi, | ||
| 37 | bool wbd); | ||
| 38 | |||
| 39 | extern void cpu_dma_wb_range(unsigned long start, unsigned long end); | ||
| 40 | extern void cpu_dma_inval_range(unsigned long start, unsigned long end); | ||
| 41 | extern void cpu_dma_wbinval_range(unsigned long start, unsigned long end); | ||
| 42 | |||
| 43 | #endif /* __KERNEL__ */ | ||
| 44 | #endif /* __NDS32_PROCFNS_H__ */ | ||
diff --git a/arch/nds32/include/asm/processor.h b/arch/nds32/include/asm/processor.h new file mode 100644 index 000000000000..9c83caf4269f --- /dev/null +++ b/arch/nds32/include/asm/processor.h | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_PROCESSOR_H | ||
| 5 | #define __ASM_NDS32_PROCESSOR_H | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Default implementation of macro that returns current | ||
| 9 | * instruction pointer ("program counter"). | ||
| 10 | */ | ||
| 11 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
| 12 | |||
| 13 | #ifdef __KERNEL__ | ||
| 14 | |||
| 15 | #include <asm/ptrace.h> | ||
| 16 | #include <asm/types.h> | ||
| 17 | #include <asm/sigcontext.h> | ||
| 18 | |||
| 19 | #define KERNEL_STACK_SIZE PAGE_SIZE | ||
| 20 | #define STACK_TOP TASK_SIZE | ||
| 21 | #define STACK_TOP_MAX TASK_SIZE | ||
| 22 | |||
| 23 | struct cpu_context { | ||
| 24 | unsigned long r6; | ||
| 25 | unsigned long r7; | ||
| 26 | unsigned long r8; | ||
| 27 | unsigned long r9; | ||
| 28 | unsigned long r10; | ||
| 29 | unsigned long r11; | ||
| 30 | unsigned long r12; | ||
| 31 | unsigned long r13; | ||
| 32 | unsigned long r14; | ||
| 33 | unsigned long fp; | ||
| 34 | unsigned long pc; | ||
| 35 | unsigned long sp; | ||
| 36 | }; | ||
| 37 | |||
| 38 | struct thread_struct { | ||
| 39 | struct cpu_context cpu_context; /* cpu context */ | ||
| 40 | /* fault info */ | ||
| 41 | unsigned long address; | ||
| 42 | unsigned long trap_no; | ||
| 43 | unsigned long error_code; | ||
| 44 | }; | ||
| 45 | |||
| 46 | #define INIT_THREAD { } | ||
| 47 | |||
| 48 | #ifdef __NDS32_EB__ | ||
| 49 | #define PSW_DE PSW_mskBE | ||
| 50 | #else | ||
| 51 | #define PSW_DE 0x0 | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #ifdef CONFIG_WBNA | ||
| 55 | #define PSW_valWBNA PSW_mskWBNA | ||
| 56 | #else | ||
| 57 | #define PSW_valWBNA 0x0 | ||
| 58 | #endif | ||
| 59 | |||
| 60 | #ifdef CONFIG_HWZOL | ||
| 61 | #define PSW_valINIT (PSW_CPL_ANY | PSW_mskAEN | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE) | ||
| 62 | #else | ||
| 63 | #define PSW_valINIT (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE) | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #define start_thread(regs,pc,stack) \ | ||
| 67 | ({ \ | ||
| 68 | memzero(regs, sizeof(struct pt_regs)); \ | ||
| 69 | forget_syscall(regs); \ | ||
| 70 | regs->ipsw = PSW_valINIT; \ | ||
| 71 | regs->ir0 = (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_SYSTEM | PSW_INTL_1); \ | ||
| 72 | regs->ipc = pc; \ | ||
| 73 | regs->sp = stack; \ | ||
| 74 | }) | ||
| 75 | |||
| 76 | /* Forward declaration, a strange C thing */ | ||
| 77 | struct task_struct; | ||
| 78 | |||
| 79 | /* Free all resources held by a thread. */ | ||
| 80 | #define release_thread(thread) do { } while(0) | ||
| 81 | |||
| 82 | /* Prepare to copy thread state - unlazy all lazy status */ | ||
| 83 | #define prepare_to_copy(tsk) do { } while (0) | ||
| 84 | |||
| 85 | unsigned long get_wchan(struct task_struct *p); | ||
| 86 | |||
| 87 | #define cpu_relax() barrier() | ||
| 88 | |||
| 89 | #define task_pt_regs(task) \ | ||
| 90 | ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \ | ||
| 91 | - 8) - 1) | ||
| 92 | |||
| 93 | /* | ||
| 94 | * Create a new kernel thread | ||
| 95 | */ | ||
| 96 | extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags); | ||
| 97 | |||
| 98 | #define KSTK_EIP(tsk) instruction_pointer(task_pt_regs(tsk)) | ||
| 99 | #define KSTK_ESP(tsk) user_stack_pointer(task_pt_regs(tsk)) | ||
| 100 | |||
| 101 | #endif | ||
| 102 | |||
| 103 | #endif /* __ASM_NDS32_PROCESSOR_H */ | ||
diff --git a/arch/nds32/include/asm/ptrace.h b/arch/nds32/include/asm/ptrace.h new file mode 100644 index 000000000000..c4538839055c --- /dev/null +++ b/arch/nds32/include/asm/ptrace.h | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_PTRACE_H | ||
| 5 | #define __ASM_NDS32_PTRACE_H | ||
| 6 | |||
| 7 | #include <uapi/asm/ptrace.h> | ||
| 8 | |||
| 9 | /* | ||
| 10 | * If pt_regs.syscallno == NO_SYSCALL, then the thread is not executing | ||
| 11 | * a syscall -- i.e., its most recent entry into the kernel from | ||
| 12 | * userspace was not via syscall, or otherwise a tracer cancelled the | ||
| 13 | * syscall. | ||
| 14 | * | ||
| 15 | * This must have the value -1, for ABI compatibility with ptrace etc. | ||
| 16 | */ | ||
| 17 | #define NO_SYSCALL (-1) | ||
| 18 | #ifndef __ASSEMBLY__ | ||
| 19 | #include <linux/types.h> | ||
| 20 | |||
| 21 | struct pt_regs { | ||
| 22 | union { | ||
| 23 | struct user_pt_regs user_regs; | ||
| 24 | struct { | ||
| 25 | long uregs[26]; | ||
| 26 | long fp; | ||
| 27 | long gp; | ||
| 28 | long lp; | ||
| 29 | long sp; | ||
| 30 | long ipc; | ||
| 31 | #if defined(CONFIG_HWZOL) | ||
| 32 | long lb; | ||
| 33 | long le; | ||
| 34 | long lc; | ||
| 35 | #else | ||
| 36 | long dummy[3]; | ||
| 37 | #endif | ||
| 38 | long syscallno; | ||
| 39 | }; | ||
| 40 | }; | ||
| 41 | long orig_r0; | ||
| 42 | long ir0; | ||
| 43 | long ipsw; | ||
| 44 | long pipsw; | ||
| 45 | long pipc; | ||
| 46 | long pp0; | ||
| 47 | long pp1; | ||
| 48 | long fucop_ctl; | ||
| 49 | long osp; | ||
| 50 | }; | ||
| 51 | |||
| 52 | static inline bool in_syscall(struct pt_regs const *regs) | ||
| 53 | { | ||
| 54 | return regs->syscallno != NO_SYSCALL; | ||
| 55 | } | ||
| 56 | |||
| 57 | static inline void forget_syscall(struct pt_regs *regs) | ||
| 58 | { | ||
| 59 | regs->syscallno = NO_SYSCALL; | ||
| 60 | } | ||
| 61 | static inline unsigned long regs_return_value(struct pt_regs *regs) | ||
| 62 | { | ||
| 63 | return regs->uregs[0]; | ||
| 64 | } | ||
| 65 | extern void show_regs(struct pt_regs *); | ||
| 66 | /* Avoid circular header include via sched.h */ | ||
| 67 | struct task_struct; | ||
| 68 | |||
| 69 | #define arch_has_single_step() (1) | ||
| 70 | #define user_mode(regs) (((regs)->ipsw & PSW_mskPOM) == 0) | ||
| 71 | #define interrupts_enabled(regs) (!!((regs)->ipsw & PSW_mskGIE)) | ||
| 72 | #define user_stack_pointer(regs) ((regs)->sp) | ||
| 73 | #define instruction_pointer(regs) ((regs)->ipc) | ||
| 74 | #define profile_pc(regs) instruction_pointer(regs) | ||
| 75 | |||
| 76 | #endif /* __ASSEMBLY__ */ | ||
| 77 | #endif | ||
diff --git a/arch/nds32/include/asm/shmparam.h b/arch/nds32/include/asm/shmparam.h new file mode 100644 index 000000000000..fd1cff64b68e --- /dev/null +++ b/arch/nds32/include/asm/shmparam.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASMNDS32_SHMPARAM_H | ||
| 5 | #define _ASMNDS32_SHMPARAM_H | ||
| 6 | |||
| 7 | /* | ||
| 8 | * This should be the size of the virtually indexed cache/ways, | ||
| 9 | * whichever is greater since the cache aliases every size/ways | ||
| 10 | * bytes. | ||
| 11 | */ | ||
| 12 | #define SHMLBA (4 * SZ_8K) /* attach addr a multiple of this */ | ||
| 13 | |||
| 14 | /* | ||
| 15 | * Enforce SHMLBA in shmat | ||
| 16 | */ | ||
| 17 | #define __ARCH_FORCE_SHMLBA | ||
| 18 | |||
| 19 | #endif /* _ASMNDS32_SHMPARAM_H */ | ||
diff --git a/arch/nds32/include/asm/string.h b/arch/nds32/include/asm/string.h new file mode 100644 index 000000000000..179272caa540 --- /dev/null +++ b/arch/nds32/include/asm/string.h | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_STRING_H | ||
| 5 | #define __ASM_NDS32_STRING_H | ||
| 6 | |||
| 7 | #define __HAVE_ARCH_MEMCPY | ||
| 8 | extern void *memcpy(void *, const void *, __kernel_size_t); | ||
| 9 | |||
| 10 | #define __HAVE_ARCH_MEMMOVE | ||
| 11 | extern void *memmove(void *, const void *, __kernel_size_t); | ||
| 12 | |||
| 13 | #define __HAVE_ARCH_MEMSET | ||
| 14 | extern void *memset(void *, int, __kernel_size_t); | ||
| 15 | |||
| 16 | extern void *memzero(void *ptr, __kernel_size_t n); | ||
| 17 | #endif | ||
diff --git a/arch/nds32/include/asm/swab.h b/arch/nds32/include/asm/swab.h new file mode 100644 index 000000000000..e01a755a37d2 --- /dev/null +++ b/arch/nds32/include/asm/swab.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_SWAB_H__ | ||
| 5 | #define __NDS32_SWAB_H__ | ||
| 6 | |||
| 7 | #include <linux/types.h> | ||
| 8 | #include <linux/compiler.h> | ||
| 9 | |||
| 10 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) | ||
| 11 | { | ||
| 12 | __asm__("wsbh %0, %0\n\t" /* word swap byte within halfword */ | ||
| 13 | "rotri %0, %0, #16\n" | ||
| 14 | :"=r"(x) | ||
| 15 | :"0"(x)); | ||
| 16 | return x; | ||
| 17 | } | ||
| 18 | |||
| 19 | static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x) | ||
| 20 | { | ||
| 21 | __asm__("wsbh %0, %0\n" /* word swap byte within halfword */ | ||
| 22 | :"=r"(x) | ||
| 23 | :"0"(x)); | ||
| 24 | return x; | ||
| 25 | } | ||
| 26 | |||
| 27 | #define __arch_swab32(x) ___arch__swab32(x) | ||
| 28 | #define __arch_swab16(x) ___arch__swab16(x) | ||
| 29 | |||
| 30 | #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) | ||
| 31 | #define __BYTEORDER_HAS_U64__ | ||
| 32 | #define __SWAB_64_THRU_32__ | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #endif /* __NDS32_SWAB_H__ */ | ||
diff --git a/arch/nds32/include/asm/syscall.h b/arch/nds32/include/asm/syscall.h new file mode 100644 index 000000000000..f7e5e86765fe --- /dev/null +++ b/arch/nds32/include/asm/syscall.h | |||
| @@ -0,0 +1,188 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved. | ||
| 3 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 4 | |||
| 5 | #ifndef _ASM_NDS32_SYSCALL_H | ||
| 6 | #define _ASM_NDS32_SYSCALL_H 1 | ||
| 7 | |||
| 8 | #include <linux/err.h> | ||
| 9 | struct task_struct; | ||
| 10 | struct pt_regs; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * syscall_get_nr - find what system call a task is executing | ||
| 14 | * @task: task of interest, must be blocked | ||
| 15 | * @regs: task_pt_regs() of @task | ||
| 16 | * | ||
| 17 | * If @task is executing a system call or is at system call | ||
| 18 | * tracing about to attempt one, returns the system call number. | ||
| 19 | * If @task is not executing a system call, i.e. it's blocked | ||
| 20 | * inside the kernel for a fault or signal, returns -1. | ||
| 21 | * | ||
| 22 | * Note this returns int even on 64-bit machines. Only 32 bits of | ||
| 23 | * system call number can be meaningful. If the actual arch value | ||
| 24 | * is 64 bits, this truncates to 32 bits so 0xffffffff means -1. | ||
| 25 | * | ||
| 26 | * It's only valid to call this when @task is known to be blocked. | ||
| 27 | */ | ||
| 28 | int syscall_get_nr(struct task_struct *task, struct pt_regs *regs) | ||
| 29 | { | ||
| 30 | return regs->syscallno; | ||
| 31 | } | ||
| 32 | |||
| 33 | /** | ||
| 34 | * syscall_rollback - roll back registers after an aborted system call | ||
| 35 | * @task: task of interest, must be in system call exit tracing | ||
| 36 | * @regs: task_pt_regs() of @task | ||
| 37 | * | ||
| 38 | * It's only valid to call this when @task is stopped for system | ||
| 39 | * call exit tracing (due to TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT), | ||
| 40 | * after tracehook_report_syscall_entry() returned nonzero to prevent | ||
| 41 | * the system call from taking place. | ||
| 42 | * | ||
| 43 | * This rolls back the register state in @regs so it's as if the | ||
| 44 | * system call instruction was a no-op. The registers containing | ||
| 45 | * the system call number and arguments are as they were before the | ||
| 46 | * system call instruction. This may not be the same as what the | ||
| 47 | * register state looked like at system call entry tracing. | ||
| 48 | */ | ||
| 49 | void syscall_rollback(struct task_struct *task, struct pt_regs *regs) | ||
| 50 | { | ||
| 51 | regs->uregs[0] = regs->orig_r0; | ||
| 52 | } | ||
| 53 | |||
| 54 | /** | ||
| 55 | * syscall_get_error - check result of traced system call | ||
| 56 | * @task: task of interest, must be blocked | ||
| 57 | * @regs: task_pt_regs() of @task | ||
| 58 | * | ||
| 59 | * Returns 0 if the system call succeeded, or -ERRORCODE if it failed. | ||
| 60 | * | ||
| 61 | * It's only valid to call this when @task is stopped for tracing on exit | ||
| 62 | * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. | ||
| 63 | */ | ||
| 64 | long syscall_get_error(struct task_struct *task, struct pt_regs *regs) | ||
| 65 | { | ||
| 66 | unsigned long error = regs->uregs[0]; | ||
| 67 | return IS_ERR_VALUE(error) ? error : 0; | ||
| 68 | } | ||
| 69 | |||
| 70 | /** | ||
| 71 | * syscall_get_return_value - get the return value of a traced system call | ||
| 72 | * @task: task of interest, must be blocked | ||
| 73 | * @regs: task_pt_regs() of @task | ||
| 74 | * | ||
| 75 | * Returns the return value of the successful system call. | ||
| 76 | * This value is meaningless if syscall_get_error() returned nonzero. | ||
| 77 | * | ||
| 78 | * It's only valid to call this when @task is stopped for tracing on exit | ||
| 79 | * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. | ||
| 80 | */ | ||
| 81 | long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) | ||
| 82 | { | ||
| 83 | return regs->uregs[0]; | ||
| 84 | } | ||
| 85 | |||
| 86 | /** | ||
| 87 | * syscall_set_return_value - change the return value of a traced system call | ||
| 88 | * @task: task of interest, must be blocked | ||
| 89 | * @regs: task_pt_regs() of @task | ||
| 90 | * @error: negative error code, or zero to indicate success | ||
| 91 | * @val: user return value if @error is zero | ||
| 92 | * | ||
| 93 | * This changes the results of the system call that user mode will see. | ||
| 94 | * If @error is zero, the user sees a successful system call with a | ||
| 95 | * return value of @val. If @error is nonzero, it's a negated errno | ||
| 96 | * code; the user sees a failed system call with this errno code. | ||
| 97 | * | ||
| 98 | * It's only valid to call this when @task is stopped for tracing on exit | ||
| 99 | * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. | ||
| 100 | */ | ||
| 101 | void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, | ||
| 102 | int error, long val) | ||
| 103 | { | ||
| 104 | regs->uregs[0] = (long)error ? error : val; | ||
| 105 | } | ||
| 106 | |||
| 107 | /** | ||
| 108 | * syscall_get_arguments - extract system call parameter values | ||
| 109 | * @task: task of interest, must be blocked | ||
| 110 | * @regs: task_pt_regs() of @task | ||
| 111 | * @i: argument index [0,5] | ||
| 112 | * @n: number of arguments; n+i must be [1,6]. | ||
| 113 | * @args: array filled with argument values | ||
| 114 | * | ||
| 115 | * Fetches @n arguments to the system call starting with the @i'th argument | ||
| 116 | * (from 0 through 5). Argument @i is stored in @args[0], and so on. | ||
| 117 | * An arch inline version is probably optimal when @i and @n are constants. | ||
| 118 | * | ||
| 119 | * It's only valid to call this when @task is stopped for tracing on | ||
| 120 | * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. | ||
| 121 | * It's invalid to call this with @i + @n > 6; we only support system calls | ||
| 122 | * taking up to 6 arguments. | ||
| 123 | */ | ||
| 124 | #define SYSCALL_MAX_ARGS 6 | ||
| 125 | void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, | ||
| 126 | unsigned int i, unsigned int n, unsigned long *args) | ||
| 127 | { | ||
| 128 | if (n == 0) | ||
| 129 | return; | ||
| 130 | if (i + n > SYSCALL_MAX_ARGS) { | ||
| 131 | unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i; | ||
| 132 | unsigned int n_bad = n + i - SYSCALL_MAX_ARGS; | ||
| 133 | pr_warning("%s called with max args %d, handling only %d\n", | ||
| 134 | __func__, i + n, SYSCALL_MAX_ARGS); | ||
| 135 | memset(args_bad, 0, n_bad * sizeof(args[0])); | ||
| 136 | memset(args_bad, 0, n_bad * sizeof(args[0])); | ||
| 137 | } | ||
| 138 | |||
| 139 | if (i == 0) { | ||
| 140 | args[0] = regs->orig_r0; | ||
| 141 | args++; | ||
| 142 | i++; | ||
| 143 | n--; | ||
| 144 | } | ||
| 145 | |||
| 146 | memcpy(args, ®s->uregs[0] + i, n * sizeof(args[0])); | ||
| 147 | } | ||
| 148 | |||
| 149 | /** | ||
| 150 | * syscall_set_arguments - change system call parameter value | ||
| 151 | * @task: task of interest, must be in system call entry tracing | ||
| 152 | * @regs: task_pt_regs() of @task | ||
| 153 | * @i: argument index [0,5] | ||
| 154 | * @n: number of arguments; n+i must be [1,6]. | ||
| 155 | * @args: array of argument values to store | ||
| 156 | * | ||
| 157 | * Changes @n arguments to the system call starting with the @i'th argument. | ||
| 158 | * Argument @i gets value @args[0], and so on. | ||
| 159 | * An arch inline version is probably optimal when @i and @n are constants. | ||
| 160 | * | ||
| 161 | * It's only valid to call this when @task is stopped for tracing on | ||
| 162 | * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. | ||
| 163 | * It's invalid to call this with @i + @n > 6; we only support system calls | ||
| 164 | * taking up to 6 arguments. | ||
| 165 | */ | ||
| 166 | void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, | ||
| 167 | unsigned int i, unsigned int n, | ||
| 168 | const unsigned long *args) | ||
| 169 | { | ||
| 170 | if (n == 0) | ||
| 171 | return; | ||
| 172 | |||
| 173 | if (i + n > SYSCALL_MAX_ARGS) { | ||
| 174 | pr_warn("%s called with max args %d, handling only %d\n", | ||
| 175 | __func__, i + n, SYSCALL_MAX_ARGS); | ||
| 176 | n = SYSCALL_MAX_ARGS - i; | ||
| 177 | } | ||
| 178 | |||
| 179 | if (i == 0) { | ||
| 180 | regs->orig_r0 = args[0]; | ||
| 181 | args++; | ||
| 182 | i++; | ||
| 183 | n--; | ||
| 184 | } | ||
| 185 | |||
| 186 | memcpy(®s->uregs[0] + i, args, n * sizeof(args[0])); | ||
| 187 | } | ||
| 188 | #endif /* _ASM_NDS32_SYSCALL_H */ | ||
diff --git a/arch/nds32/include/asm/syscalls.h b/arch/nds32/include/asm/syscalls.h new file mode 100644 index 000000000000..78778ecff60c --- /dev/null +++ b/arch/nds32/include/asm/syscalls.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_SYSCALLS_H | ||
| 5 | #define __ASM_NDS32_SYSCALLS_H | ||
| 6 | |||
| 7 | asmlinkage long sys_cacheflush(unsigned long addr, unsigned long len, unsigned int op); | ||
| 8 | asmlinkage long sys_fadvise64_64_wrapper(int fd, int advice, loff_t offset, loff_t len); | ||
| 9 | asmlinkage long sys_rt_sigreturn_wrapper(void); | ||
| 10 | |||
| 11 | #include <asm-generic/syscalls.h> | ||
| 12 | |||
| 13 | #endif /* __ASM_NDS32_SYSCALLS_H */ | ||
diff --git a/arch/nds32/include/asm/thread_info.h b/arch/nds32/include/asm/thread_info.h new file mode 100644 index 000000000000..bff741ff337b --- /dev/null +++ b/arch/nds32/include/asm/thread_info.h | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_THREAD_INFO_H | ||
| 5 | #define __ASM_NDS32_THREAD_INFO_H | ||
| 6 | |||
| 7 | #ifdef __KERNEL__ | ||
| 8 | |||
| 9 | #define THREAD_SIZE_ORDER (1) | ||
| 10 | #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) | ||
| 11 | |||
| 12 | #ifndef __ASSEMBLY__ | ||
| 13 | |||
| 14 | struct task_struct; | ||
| 15 | |||
| 16 | #include <asm/ptrace.h> | ||
| 17 | #include <asm/types.h> | ||
| 18 | |||
| 19 | typedef unsigned long mm_segment_t; | ||
| 20 | |||
| 21 | /* | ||
| 22 | * low level task data that entry.S needs immediate access to. | ||
| 23 | * __switch_to() assumes cpu_context follows immediately after cpu_domain. | ||
| 24 | */ | ||
| 25 | struct thread_info { | ||
| 26 | unsigned long flags; /* low level flags */ | ||
| 27 | __s32 preempt_count; /* 0 => preemptable, <0 => bug */ | ||
| 28 | mm_segment_t addr_limit; /* address limit */ | ||
| 29 | }; | ||
| 30 | #define INIT_THREAD_INFO(tsk) \ | ||
| 31 | { \ | ||
| 32 | .preempt_count = INIT_PREEMPT_COUNT, \ | ||
| 33 | .addr_limit = KERNEL_DS, \ | ||
| 34 | } | ||
| 35 | #define thread_saved_pc(tsk) ((unsigned long)(tsk->thread.cpu_context.pc)) | ||
| 36 | #define thread_saved_fp(tsk) ((unsigned long)(tsk->thread.cpu_context.fp)) | ||
| 37 | #endif | ||
| 38 | |||
| 39 | /* | ||
| 40 | * thread information flags: | ||
| 41 | * TIF_SYSCALL_TRACE - syscall trace active | ||
| 42 | * TIF_SIGPENDING - signal pending | ||
| 43 | * TIF_NEED_RESCHED - rescheduling necessary | ||
| 44 | * TIF_NOTIFY_RESUME - callback before returning to user | ||
| 45 | * TIF_USEDFPU - FPU was used by this task this quantum (SMP) | ||
| 46 | * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED | ||
| 47 | */ | ||
| 48 | #define TIF_SIGPENDING 1 | ||
| 49 | #define TIF_NEED_RESCHED 2 | ||
| 50 | #define TIF_SINGLESTEP 3 | ||
| 51 | #define TIF_NOTIFY_RESUME 4 /* callback before returning to user */ | ||
| 52 | #define TIF_SYSCALL_TRACE 8 | ||
| 53 | #define TIF_USEDFPU 16 | ||
| 54 | #define TIF_POLLING_NRFLAG 17 | ||
| 55 | #define TIF_MEMDIE 18 | ||
| 56 | #define TIF_FREEZE 19 | ||
| 57 | #define TIF_RESTORE_SIGMASK 20 | ||
| 58 | |||
| 59 | #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) | ||
| 60 | #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) | ||
| 61 | #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) | ||
| 62 | #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) | ||
| 63 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) | ||
| 64 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) | ||
| 65 | #define _TIF_FREEZE (1 << TIF_FREEZE) | ||
| 66 | #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) | ||
| 67 | |||
| 68 | /* | ||
| 69 | * Change these and you break ASM code in entry-common.S | ||
| 70 | */ | ||
| 71 | #define _TIF_WORK_MASK 0x000000ff | ||
| 72 | #define _TIF_WORK_SYSCALL_ENTRY (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP) | ||
| 73 | #define _TIF_WORK_SYSCALL_LEAVE (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP) | ||
| 74 | |||
| 75 | #endif /* __KERNEL__ */ | ||
| 76 | #endif /* __ASM_NDS32_THREAD_INFO_H */ | ||
diff --git a/arch/nds32/include/asm/tlb.h b/arch/nds32/include/asm/tlb.h new file mode 100644 index 000000000000..b35ae5eae3ab --- /dev/null +++ b/arch/nds32/include/asm/tlb.h | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASMNDS32_TLB_H | ||
| 5 | #define __ASMNDS32_TLB_H | ||
| 6 | |||
| 7 | #define tlb_start_vma(tlb,vma) \ | ||
| 8 | do { \ | ||
| 9 | if (!tlb->fullmm) \ | ||
| 10 | flush_cache_range(vma, vma->vm_start, vma->vm_end); \ | ||
| 11 | } while (0) | ||
| 12 | |||
| 13 | #define tlb_end_vma(tlb,vma) \ | ||
| 14 | do { \ | ||
| 15 | if(!tlb->fullmm) \ | ||
| 16 | flush_tlb_range(vma, vma->vm_start, vma->vm_end); \ | ||
| 17 | } while (0) | ||
| 18 | |||
| 19 | #define __tlb_remove_tlb_entry(tlb, pte, addr) do { } while (0) | ||
| 20 | |||
| 21 | #define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) | ||
| 22 | |||
| 23 | #include <asm-generic/tlb.h> | ||
| 24 | |||
| 25 | #define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte) | ||
| 26 | #define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tln)->mm, pmd) | ||
| 27 | |||
| 28 | #endif | ||
diff --git a/arch/nds32/include/asm/tlbflush.h b/arch/nds32/include/asm/tlbflush.h new file mode 100644 index 000000000000..9b411f401903 --- /dev/null +++ b/arch/nds32/include/asm/tlbflush.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASMNDS32_TLBFLUSH_H | ||
| 5 | #define _ASMNDS32_TLBFLUSH_H | ||
| 6 | |||
| 7 | #include <linux/spinlock.h> | ||
| 8 | #include <linux/mm.h> | ||
| 9 | #include <nds32_intrinsic.h> | ||
| 10 | |||
| 11 | static inline void local_flush_tlb_all(void) | ||
| 12 | { | ||
| 13 | __nds32__tlbop_flua(); | ||
| 14 | __nds32__isb(); | ||
| 15 | } | ||
| 16 | |||
| 17 | static inline void local_flush_tlb_mm(struct mm_struct *mm) | ||
| 18 | { | ||
| 19 | __nds32__tlbop_flua(); | ||
| 20 | __nds32__isb(); | ||
| 21 | } | ||
| 22 | |||
| 23 | static inline void local_flush_tlb_kernel_range(unsigned long start, | ||
| 24 | unsigned long end) | ||
| 25 | { | ||
| 26 | while (start < end) { | ||
| 27 | __nds32__tlbop_inv(start); | ||
| 28 | __nds32__isb(); | ||
| 29 | start += PAGE_SIZE; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | void local_flush_tlb_range(struct vm_area_struct *vma, | ||
| 34 | unsigned long start, unsigned long end); | ||
| 35 | void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long addr); | ||
| 36 | |||
| 37 | #define flush_tlb_all local_flush_tlb_all | ||
| 38 | #define flush_tlb_mm local_flush_tlb_mm | ||
| 39 | #define flush_tlb_range local_flush_tlb_range | ||
| 40 | #define flush_tlb_page local_flush_tlb_page | ||
| 41 | #define flush_tlb_kernel_range local_flush_tlb_kernel_range | ||
| 42 | |||
| 43 | void update_mmu_cache(struct vm_area_struct *vma, | ||
| 44 | unsigned long address, pte_t * pte); | ||
| 45 | void tlb_migrate_finish(struct mm_struct *mm); | ||
| 46 | |||
| 47 | #endif | ||
diff --git a/arch/nds32/include/asm/uaccess.h b/arch/nds32/include/asm/uaccess.h new file mode 100644 index 000000000000..18a009f3804d --- /dev/null +++ b/arch/nds32/include/asm/uaccess.h | |||
| @@ -0,0 +1,283 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASMANDES_UACCESS_H | ||
| 5 | #define _ASMANDES_UACCESS_H | ||
| 6 | |||
| 7 | /* | ||
| 8 | * User space memory access functions | ||
| 9 | */ | ||
| 10 | #include <linux/sched.h> | ||
| 11 | #include <asm/errno.h> | ||
| 12 | #include <asm/memory.h> | ||
| 13 | #include <asm/types.h> | ||
| 14 | #include <linux/mm.h> | ||
| 15 | |||
| 16 | #define VERIFY_READ 0 | ||
| 17 | #define VERIFY_WRITE 1 | ||
| 18 | |||
| 19 | #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t" | ||
| 20 | |||
| 21 | /* | ||
| 22 | * The exception table consists of pairs of addresses: the first is the | ||
| 23 | * address of an instruction that is allowed to fault, and the second is | ||
| 24 | * the address at which the program should continue. No registers are | ||
| 25 | * modified, so it is entirely up to the continuation code to figure out | ||
| 26 | * what to do. | ||
| 27 | * | ||
| 28 | * All the routines below use bits of fixup code that are out of line | ||
| 29 | * with the main instruction path. This means when everything is well, | ||
| 30 | * we don't even have to jump over them. Further, they do not intrude | ||
| 31 | * on our cache or tlb entries. | ||
| 32 | */ | ||
| 33 | |||
| 34 | struct exception_table_entry { | ||
| 35 | unsigned long insn, fixup; | ||
| 36 | }; | ||
| 37 | |||
| 38 | extern int fixup_exception(struct pt_regs *regs); | ||
| 39 | |||
| 40 | #define KERNEL_DS ((mm_segment_t) { ~0UL }) | ||
| 41 | #define USER_DS ((mm_segment_t) {TASK_SIZE - 1}) | ||
| 42 | |||
| 43 | #define get_ds() (KERNEL_DS) | ||
| 44 | #define get_fs() (current_thread_info()->addr_limit) | ||
| 45 | #define user_addr_max get_fs | ||
| 46 | |||
| 47 | static inline void set_fs(mm_segment_t fs) | ||
| 48 | { | ||
| 49 | current_thread_info()->addr_limit = fs; | ||
| 50 | } | ||
| 51 | |||
| 52 | #define segment_eq(a, b) ((a) == (b)) | ||
| 53 | |||
| 54 | #define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs() -size)) | ||
| 55 | |||
| 56 | #define access_ok(type, addr, size) \ | ||
| 57 | __range_ok((unsigned long)addr, (unsigned long)size) | ||
| 58 | /* | ||
| 59 | * Single-value transfer routines. They automatically use the right | ||
| 60 | * size if we just have the right pointer type. Note that the functions | ||
| 61 | * which read from user space (*get_*) need to take care not to leak | ||
| 62 | * kernel data even if the calling code is buggy and fails to check | ||
| 63 | * the return value. This means zeroing out the destination variable | ||
| 64 | * or buffer on error. Normally this is done out of line by the | ||
| 65 | * fixup code, but there are a few places where it intrudes on the | ||
| 66 | * main code path. When we only write to user space, there is no | ||
| 67 | * problem. | ||
| 68 | * | ||
| 69 | * The "__xxx" versions of the user access functions do not verify the | ||
| 70 | * address space - it must have been done previously with a separate | ||
| 71 | * "access_ok()" call. | ||
| 72 | * | ||
| 73 | * The "xxx_error" versions set the third argument to EFAULT if an | ||
| 74 | * error occurs, and leave it unchanged on success. Note that these | ||
| 75 | * versions are void (ie, don't return a value as such). | ||
| 76 | */ | ||
| 77 | |||
| 78 | #define get_user(x,p) \ | ||
| 79 | ({ \ | ||
| 80 | long __e = -EFAULT; \ | ||
| 81 | if(likely(access_ok(VERIFY_READ, p, sizeof(*p)))) { \ | ||
| 82 | __e = __get_user(x,p); \ | ||
| 83 | } else \ | ||
| 84 | x = 0; \ | ||
| 85 | __e; \ | ||
| 86 | }) | ||
| 87 | #define __get_user(x,ptr) \ | ||
| 88 | ({ \ | ||
| 89 | long __gu_err = 0; \ | ||
| 90 | __get_user_err((x),(ptr),__gu_err); \ | ||
| 91 | __gu_err; \ | ||
| 92 | }) | ||
| 93 | |||
| 94 | #define __get_user_error(x,ptr,err) \ | ||
| 95 | ({ \ | ||
| 96 | __get_user_err((x),(ptr),err); \ | ||
| 97 | (void) 0; \ | ||
| 98 | }) | ||
| 99 | |||
| 100 | #define __get_user_err(x,ptr,err) \ | ||
| 101 | do { \ | ||
| 102 | unsigned long __gu_addr = (unsigned long)(ptr); \ | ||
| 103 | unsigned long __gu_val; \ | ||
| 104 | __chk_user_ptr(ptr); \ | ||
| 105 | switch (sizeof(*(ptr))) { \ | ||
| 106 | case 1: \ | ||
| 107 | __get_user_asm("lbi",__gu_val,__gu_addr,err); \ | ||
| 108 | break; \ | ||
| 109 | case 2: \ | ||
| 110 | __get_user_asm("lhi",__gu_val,__gu_addr,err); \ | ||
| 111 | break; \ | ||
| 112 | case 4: \ | ||
| 113 | __get_user_asm("lwi",__gu_val,__gu_addr,err); \ | ||
| 114 | break; \ | ||
| 115 | case 8: \ | ||
| 116 | __get_user_asm_dword(__gu_val,__gu_addr,err); \ | ||
| 117 | break; \ | ||
| 118 | default: \ | ||
| 119 | BUILD_BUG(); \ | ||
| 120 | break; \ | ||
| 121 | } \ | ||
| 122 | (x) = (__typeof__(*(ptr)))__gu_val; \ | ||
| 123 | } while (0) | ||
| 124 | |||
| 125 | #define __get_user_asm(inst,x,addr,err) \ | ||
| 126 | asm volatile( \ | ||
| 127 | "1: "inst" %1,[%2]\n" \ | ||
| 128 | "2:\n" \ | ||
| 129 | " .section .fixup,\"ax\"\n" \ | ||
| 130 | " .align 2\n" \ | ||
| 131 | "3: move %0, %3\n" \ | ||
| 132 | " move %1, #0\n" \ | ||
| 133 | " b 2b\n" \ | ||
| 134 | " .previous\n" \ | ||
| 135 | " .section __ex_table,\"a\"\n" \ | ||
| 136 | " .align 3\n" \ | ||
| 137 | " .long 1b, 3b\n" \ | ||
| 138 | " .previous" \ | ||
| 139 | : "+r" (err), "=&r" (x) \ | ||
| 140 | : "r" (addr), "i" (-EFAULT) \ | ||
| 141 | : "cc") | ||
| 142 | |||
| 143 | #ifdef __NDS32_EB__ | ||
| 144 | #define __gu_reg_oper0 "%H1" | ||
| 145 | #define __gu_reg_oper1 "%L1" | ||
| 146 | #else | ||
| 147 | #define __gu_reg_oper0 "%L1" | ||
| 148 | #define __gu_reg_oper1 "%H1" | ||
| 149 | #endif | ||
| 150 | |||
| 151 | #define __get_user_asm_dword(x, addr, err) \ | ||
| 152 | asm volatile( \ | ||
| 153 | "\n1:\tlwi " __gu_reg_oper0 ",[%2]\n" \ | ||
| 154 | "\n2:\tlwi " __gu_reg_oper1 ",[%2+4]\n" \ | ||
| 155 | "3:\n" \ | ||
| 156 | " .section .fixup,\"ax\"\n" \ | ||
| 157 | " .align 2\n" \ | ||
| 158 | "4: move %0, %3\n" \ | ||
| 159 | " b 3b\n" \ | ||
| 160 | " .previous\n" \ | ||
| 161 | " .section __ex_table,\"a\"\n" \ | ||
| 162 | " .align 3\n" \ | ||
| 163 | " .long 1b, 4b\n" \ | ||
| 164 | " .long 2b, 4b\n" \ | ||
| 165 | " .previous" \ | ||
| 166 | : "+r"(err), "=&r"(x) \ | ||
| 167 | : "r"(addr), "i"(-EFAULT) \ | ||
| 168 | : "cc") | ||
| 169 | #define put_user(x,p) \ | ||
| 170 | ({ \ | ||
| 171 | long __e = -EFAULT; \ | ||
| 172 | if(likely(access_ok(VERIFY_WRITE, p, sizeof(*p)))) { \ | ||
| 173 | __e = __put_user(x,p); \ | ||
| 174 | } \ | ||
| 175 | __e; \ | ||
| 176 | }) | ||
| 177 | #define __put_user(x,ptr) \ | ||
| 178 | ({ \ | ||
| 179 | long __pu_err = 0; \ | ||
| 180 | __put_user_err((x),(ptr),__pu_err); \ | ||
| 181 | __pu_err; \ | ||
| 182 | }) | ||
| 183 | |||
| 184 | #define __put_user_error(x,ptr,err) \ | ||
| 185 | ({ \ | ||
| 186 | __put_user_err((x),(ptr),err); \ | ||
| 187 | (void) 0; \ | ||
| 188 | }) | ||
| 189 | |||
| 190 | #define __put_user_err(x,ptr,err) \ | ||
| 191 | do { \ | ||
| 192 | unsigned long __pu_addr = (unsigned long)(ptr); \ | ||
| 193 | __typeof__(*(ptr)) __pu_val = (x); \ | ||
| 194 | __chk_user_ptr(ptr); \ | ||
| 195 | switch (sizeof(*(ptr))) { \ | ||
| 196 | case 1: \ | ||
| 197 | __put_user_asm("sbi",__pu_val,__pu_addr,err); \ | ||
| 198 | break; \ | ||
| 199 | case 2: \ | ||
| 200 | __put_user_asm("shi",__pu_val,__pu_addr,err); \ | ||
| 201 | break; \ | ||
| 202 | case 4: \ | ||
| 203 | __put_user_asm("swi",__pu_val,__pu_addr,err); \ | ||
| 204 | break; \ | ||
| 205 | case 8: \ | ||
| 206 | __put_user_asm_dword(__pu_val,__pu_addr,err); \ | ||
| 207 | break; \ | ||
| 208 | default: \ | ||
| 209 | BUILD_BUG(); \ | ||
| 210 | break; \ | ||
| 211 | } \ | ||
| 212 | } while (0) | ||
| 213 | |||
| 214 | #define __put_user_asm(inst,x,addr,err) \ | ||
| 215 | asm volatile( \ | ||
| 216 | "1: "inst" %1,[%2]\n" \ | ||
| 217 | "2:\n" \ | ||
| 218 | " .section .fixup,\"ax\"\n" \ | ||
| 219 | " .align 2\n" \ | ||
| 220 | "3: move %0, %3\n" \ | ||
| 221 | " b 2b\n" \ | ||
| 222 | " .previous\n" \ | ||
| 223 | " .section __ex_table,\"a\"\n" \ | ||
| 224 | " .align 3\n" \ | ||
| 225 | " .long 1b, 3b\n" \ | ||
| 226 | " .previous" \ | ||
| 227 | : "+r" (err) \ | ||
| 228 | : "r" (x), "r" (addr), "i" (-EFAULT) \ | ||
| 229 | : "cc") | ||
| 230 | |||
| 231 | #ifdef __NDS32_EB__ | ||
| 232 | #define __pu_reg_oper0 "%H2" | ||
| 233 | #define __pu_reg_oper1 "%L2" | ||
| 234 | #else | ||
| 235 | #define __pu_reg_oper0 "%L2" | ||
| 236 | #define __pu_reg_oper1 "%H2" | ||
| 237 | #endif | ||
| 238 | |||
| 239 | #define __put_user_asm_dword(x, addr, err) \ | ||
| 240 | asm volatile( \ | ||
| 241 | "\n1:\tswi " __pu_reg_oper0 ",[%1]\n" \ | ||
| 242 | "\n2:\tswi " __pu_reg_oper1 ",[%1+4]\n" \ | ||
| 243 | "3:\n" \ | ||
| 244 | " .section .fixup,\"ax\"\n" \ | ||
| 245 | " .align 2\n" \ | ||
| 246 | "4: move %0, %3\n" \ | ||
| 247 | " b 3b\n" \ | ||
| 248 | " .previous\n" \ | ||
| 249 | " .section __ex_table,\"a\"\n" \ | ||
| 250 | " .align 3\n" \ | ||
| 251 | " .long 1b, 4b\n" \ | ||
| 252 | " .long 2b, 4b\n" \ | ||
| 253 | " .previous" \ | ||
| 254 | : "+r"(err) \ | ||
| 255 | : "r"(addr), "r"(x), "i"(-EFAULT) \ | ||
| 256 | : "cc") | ||
| 257 | extern unsigned long __arch_clear_user(void __user * addr, unsigned long n); | ||
| 258 | extern long strncpy_from_user(char *dest, const char __user * src, long count); | ||
| 259 | extern __must_check long strlen_user(const char __user * str); | ||
| 260 | extern __must_check long strnlen_user(const char __user * str, long n); | ||
| 261 | extern unsigned long __arch_copy_from_user(void *to, const void __user * from, | ||
| 262 | unsigned long n); | ||
| 263 | extern unsigned long __arch_copy_to_user(void __user * to, const void *from, | ||
| 264 | unsigned long n); | ||
| 265 | |||
| 266 | #define raw_copy_from_user __arch_copy_from_user | ||
| 267 | #define raw_copy_to_user __arch_copy_to_user | ||
| 268 | |||
| 269 | #define INLINE_COPY_FROM_USER | ||
| 270 | #define INLINE_COPY_TO_USER | ||
| 271 | static inline unsigned long clear_user(void __user * to, unsigned long n) | ||
| 272 | { | ||
| 273 | if (access_ok(VERIFY_WRITE, to, n)) | ||
| 274 | n = __arch_clear_user(to, n); | ||
| 275 | return n; | ||
| 276 | } | ||
| 277 | |||
| 278 | static inline unsigned long __clear_user(void __user * to, unsigned long n) | ||
| 279 | { | ||
| 280 | return __arch_clear_user(to, n); | ||
| 281 | } | ||
| 282 | |||
| 283 | #endif /* _ASMNDS32_UACCESS_H */ | ||
diff --git a/arch/nds32/include/asm/unistd.h b/arch/nds32/include/asm/unistd.h new file mode 100644 index 000000000000..b586a2862beb --- /dev/null +++ b/arch/nds32/include/asm/unistd.h | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #define __ARCH_WANT_SYS_CLONE | ||
| 5 | |||
| 6 | #include <uapi/asm/unistd.h> | ||
diff --git a/arch/nds32/include/asm/vdso.h b/arch/nds32/include/asm/vdso.h new file mode 100644 index 000000000000..af2c6afc2469 --- /dev/null +++ b/arch/nds32/include/asm/vdso.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* | ||
| 2 | * SPDX-License-Identifier: GPL-2.0 | ||
| 3 | * Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef __ASM_VDSO_H | ||
| 7 | #define __ASM_VDSO_H | ||
| 8 | |||
| 9 | #ifdef __KERNEL__ | ||
| 10 | |||
| 11 | #ifndef __ASSEMBLY__ | ||
| 12 | |||
| 13 | #include <generated/vdso-offsets.h> | ||
| 14 | |||
| 15 | #define VDSO_SYMBOL(base, name) \ | ||
| 16 | ({ \ | ||
| 17 | (unsigned long)(vdso_offset_##name + (unsigned long)(base)); \ | ||
| 18 | }) | ||
| 19 | |||
| 20 | #endif /* !__ASSEMBLY__ */ | ||
| 21 | |||
| 22 | #endif /* __KERNEL__ */ | ||
| 23 | |||
| 24 | #endif /* __ASM_VDSO_H */ | ||
diff --git a/arch/nds32/include/asm/vdso_datapage.h b/arch/nds32/include/asm/vdso_datapage.h new file mode 100644 index 000000000000..79db5a12ca5e --- /dev/null +++ b/arch/nds32/include/asm/vdso_datapage.h | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2012 ARM Limited | ||
| 3 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 4 | #ifndef __ASM_VDSO_DATAPAGE_H | ||
| 5 | #define __ASM_VDSO_DATAPAGE_H | ||
| 6 | |||
| 7 | #ifdef __KERNEL__ | ||
| 8 | |||
| 9 | #ifndef __ASSEMBLY__ | ||
| 10 | |||
| 11 | struct vdso_data { | ||
| 12 | bool cycle_count_down; /* timer cyclye counter is decrease with time */ | ||
| 13 | u32 cycle_count_offset; /* offset of timer cycle counter register */ | ||
| 14 | u32 seq_count; /* sequence count - odd during updates */ | ||
| 15 | u32 xtime_coarse_sec; /* coarse time */ | ||
| 16 | u32 xtime_coarse_nsec; | ||
| 17 | |||
| 18 | u32 wtm_clock_sec; /* wall to monotonic offset */ | ||
| 19 | u32 wtm_clock_nsec; | ||
| 20 | u32 xtime_clock_sec; /* CLOCK_REALTIME - seconds */ | ||
| 21 | u32 cs_mult; /* clocksource multiplier */ | ||
| 22 | u32 cs_shift; /* Cycle to nanosecond divisor (power of two) */ | ||
| 23 | |||
| 24 | u64 cs_cycle_last; /* last cycle value */ | ||
| 25 | u64 cs_mask; /* clocksource mask */ | ||
| 26 | |||
| 27 | u64 xtime_clock_nsec; /* CLOCK_REALTIME sub-ns base */ | ||
| 28 | u32 tz_minuteswest; /* timezone info for gettimeofday(2) */ | ||
| 29 | u32 tz_dsttime; | ||
| 30 | }; | ||
| 31 | |||
| 32 | #endif /* !__ASSEMBLY__ */ | ||
| 33 | |||
| 34 | #endif /* __KERNEL__ */ | ||
| 35 | |||
| 36 | #endif /* __ASM_VDSO_DATAPAGE_H */ | ||
diff --git a/arch/nds32/include/asm/vdso_timer_info.h b/arch/nds32/include/asm/vdso_timer_info.h new file mode 100644 index 000000000000..50ba117cff12 --- /dev/null +++ b/arch/nds32/include/asm/vdso_timer_info.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | extern struct timer_info_t timer_info; | ||
| 5 | #define EMPTY_VALUE ~(0UL) | ||
| 6 | #define EMPTY_TIMER_MAPPING EMPTY_VALUE | ||
| 7 | #define EMPTY_REG_OFFSET EMPTY_VALUE | ||
| 8 | |||
| 9 | struct timer_info_t | ||
| 10 | { | ||
| 11 | bool cycle_count_down; | ||
| 12 | unsigned long mapping_base; | ||
| 13 | unsigned long cycle_count_reg_offset; | ||
| 14 | }; | ||
diff --git a/arch/nds32/include/uapi/asm/Kbuild b/arch/nds32/include/uapi/asm/Kbuild new file mode 100644 index 000000000000..40be972faf9e --- /dev/null +++ b/arch/nds32/include/uapi/asm/Kbuild | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | # UAPI Header export list | ||
| 2 | include include/uapi/asm-generic/Kbuild.asm | ||
| 3 | |||
| 4 | generic-y += bpf_perf_event.h | ||
| 5 | generic-y += errno.h | ||
| 6 | generic-y += ioctl.h | ||
| 7 | generic-y += ioctls.h | ||
| 8 | generic-y += ipcbuf.h | ||
| 9 | generic-y += shmbuf.h | ||
| 10 | generic-y += bitsperlong.h | ||
| 11 | generic-y += fcntl.h | ||
| 12 | generic-y += stat.h | ||
| 13 | generic-y += mman.h | ||
| 14 | generic-y += msgbuf.h | ||
| 15 | generic-y += poll.h | ||
| 16 | generic-y += posix_types.h | ||
| 17 | generic-y += resource.h | ||
| 18 | generic-y += sembuf.h | ||
| 19 | generic-y += setup.h | ||
| 20 | generic-y += siginfo.h | ||
| 21 | generic-y += signal.h | ||
| 22 | generic-y += socket.h | ||
| 23 | generic-y += sockios.h | ||
| 24 | generic-y += swab.h | ||
| 25 | generic-y += statfs.h | ||
| 26 | generic-y += termbits.h | ||
| 27 | generic-y += termios.h | ||
| 28 | generic-y += types.h | ||
| 29 | generic-y += ucontext.h | ||
diff --git a/arch/nds32/include/uapi/asm/auxvec.h b/arch/nds32/include/uapi/asm/auxvec.h new file mode 100644 index 000000000000..56043ce4972f --- /dev/null +++ b/arch/nds32/include/uapi/asm/auxvec.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_AUXVEC_H | ||
| 5 | #define __ASM_AUXVEC_H | ||
| 6 | |||
| 7 | /* VDSO location */ | ||
| 8 | #define AT_SYSINFO_EHDR 33 | ||
| 9 | |||
| 10 | #define AT_VECTOR_SIZE_ARCH 1 | ||
| 11 | |||
| 12 | #endif | ||
diff --git a/arch/nds32/include/uapi/asm/byteorder.h b/arch/nds32/include/uapi/asm/byteorder.h new file mode 100644 index 000000000000..a23f6f3a2468 --- /dev/null +++ b/arch/nds32/include/uapi/asm/byteorder.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __NDS32_BYTEORDER_H__ | ||
| 5 | #define __NDS32_BYTEORDER_H__ | ||
| 6 | |||
| 7 | #ifdef __NDS32_EB__ | ||
| 8 | #include <linux/byteorder/big_endian.h> | ||
| 9 | #else | ||
| 10 | #include <linux/byteorder/little_endian.h> | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #endif /* __NDS32_BYTEORDER_H__ */ | ||
diff --git a/arch/nds32/include/uapi/asm/cachectl.h b/arch/nds32/include/uapi/asm/cachectl.h new file mode 100644 index 000000000000..4cdca9b23974 --- /dev/null +++ b/arch/nds32/include/uapi/asm/cachectl.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 1994, 1995, 1996 by Ralf Baechle | ||
| 3 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 4 | #ifndef _ASM_CACHECTL | ||
| 5 | #define _ASM_CACHECTL | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Options for cacheflush system call | ||
| 9 | */ | ||
| 10 | #define ICACHE 0 /* flush instruction cache */ | ||
| 11 | #define DCACHE 1 /* writeback and flush data cache */ | ||
| 12 | #define BCACHE 2 /* flush instruction cache + writeback and flush data cache */ | ||
| 13 | |||
| 14 | #endif /* _ASM_CACHECTL */ | ||
diff --git a/arch/nds32/include/uapi/asm/param.h b/arch/nds32/include/uapi/asm/param.h new file mode 100644 index 000000000000..e3fb723ee362 --- /dev/null +++ b/arch/nds32/include/uapi/asm/param.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __ASM_NDS32_PARAM_H | ||
| 5 | #define __ASM_NDS32_PARAM_H | ||
| 6 | |||
| 7 | #define EXEC_PAGESIZE 8192 | ||
| 8 | |||
| 9 | #include <asm-generic/param.h> | ||
| 10 | |||
| 11 | #endif /* __ASM_NDS32_PARAM_H */ | ||
diff --git a/arch/nds32/include/uapi/asm/ptrace.h b/arch/nds32/include/uapi/asm/ptrace.h new file mode 100644 index 000000000000..358c99e399d0 --- /dev/null +++ b/arch/nds32/include/uapi/asm/ptrace.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef __UAPI_ASM_NDS32_PTRACE_H | ||
| 5 | #define __UAPI_ASM_NDS32_PTRACE_H | ||
| 6 | |||
| 7 | #ifndef __ASSEMBLY__ | ||
| 8 | |||
| 9 | /* | ||
| 10 | * User structures for general purpose register. | ||
| 11 | */ | ||
| 12 | struct user_pt_regs { | ||
| 13 | long uregs[26]; | ||
| 14 | long fp; | ||
| 15 | long gp; | ||
| 16 | long lp; | ||
| 17 | long sp; | ||
| 18 | long ipc; | ||
| 19 | long lb; | ||
| 20 | long le; | ||
| 21 | long lc; | ||
| 22 | long syscallno; | ||
| 23 | }; | ||
| 24 | #endif | ||
| 25 | #endif | ||
diff --git a/arch/nds32/include/uapi/asm/sigcontext.h b/arch/nds32/include/uapi/asm/sigcontext.h new file mode 100644 index 000000000000..00567b237b0c --- /dev/null +++ b/arch/nds32/include/uapi/asm/sigcontext.h | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #ifndef _ASMNDS32_SIGCONTEXT_H | ||
| 5 | #define _ASMNDS32_SIGCONTEXT_H | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Signal context structure - contains all info to do with the state | ||
| 9 | * before the signal handler was invoked. Note: only add new entries | ||
| 10 | * to the end of the structure. | ||
| 11 | */ | ||
| 12 | |||
| 13 | struct zol_struct { | ||
| 14 | unsigned long nds32_lc; /* $LC */ | ||
| 15 | unsigned long nds32_le; /* $LE */ | ||
| 16 | unsigned long nds32_lb; /* $LB */ | ||
| 17 | }; | ||
| 18 | |||
| 19 | struct sigcontext { | ||
| 20 | unsigned long trap_no; | ||
| 21 | unsigned long error_code; | ||
| 22 | unsigned long oldmask; | ||
| 23 | unsigned long nds32_r0; | ||
| 24 | unsigned long nds32_r1; | ||
| 25 | unsigned long nds32_r2; | ||
| 26 | unsigned long nds32_r3; | ||
| 27 | unsigned long nds32_r4; | ||
| 28 | unsigned long nds32_r5; | ||
| 29 | unsigned long nds32_r6; | ||
| 30 | unsigned long nds32_r7; | ||
| 31 | unsigned long nds32_r8; | ||
| 32 | unsigned long nds32_r9; | ||
| 33 | unsigned long nds32_r10; | ||
| 34 | unsigned long nds32_r11; | ||
| 35 | unsigned long nds32_r12; | ||
| 36 | unsigned long nds32_r13; | ||
| 37 | unsigned long nds32_r14; | ||
| 38 | unsigned long nds32_r15; | ||
| 39 | unsigned long nds32_r16; | ||
| 40 | unsigned long nds32_r17; | ||
| 41 | unsigned long nds32_r18; | ||
| 42 | unsigned long nds32_r19; | ||
| 43 | unsigned long nds32_r20; | ||
| 44 | unsigned long nds32_r21; | ||
| 45 | unsigned long nds32_r22; | ||
| 46 | unsigned long nds32_r23; | ||
| 47 | unsigned long nds32_r24; | ||
| 48 | unsigned long nds32_r25; | ||
| 49 | unsigned long nds32_fp; /* $r28 */ | ||
| 50 | unsigned long nds32_gp; /* $r29 */ | ||
| 51 | unsigned long nds32_lp; /* $r30 */ | ||
| 52 | unsigned long nds32_sp; /* $r31 */ | ||
| 53 | unsigned long nds32_ipc; | ||
| 54 | unsigned long fault_address; | ||
| 55 | unsigned long used_math_flag; | ||
| 56 | /* FPU Registers */ | ||
| 57 | struct zol_struct zol; | ||
| 58 | }; | ||
| 59 | |||
| 60 | #endif | ||
diff --git a/arch/nds32/include/uapi/asm/unistd.h b/arch/nds32/include/uapi/asm/unistd.h new file mode 100644 index 000000000000..6e95901cabe3 --- /dev/null +++ b/arch/nds32/include/uapi/asm/unistd.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2005-2017 Andes Technology Corporation | ||
| 3 | |||
| 4 | #define __ARCH_WANT_SYNC_FILE_RANGE2 | ||
| 5 | |||
| 6 | /* Use the standard ABI for syscalls */ | ||
| 7 | #include <asm-generic/unistd.h> | ||
| 8 | |||
| 9 | /* Additional NDS32 specific syscalls. */ | ||
| 10 | #define __NR_cacheflush (__NR_arch_specific_syscall) | ||
| 11 | __SYSCALL(__NR_cacheflush, sys_cacheflush) | ||
