Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2007 Michal Simek |
| 4 | * |
| 5 | * Michal SIMEK <monstr@monstr.eu> |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* FSL macros */ |
| 9 | #define NGET(val, fslnum) \ |
| 10 | __asm__ __volatile__ ("nget %0, rfsl" #fslnum :"=r" (val)); |
Michal Simek | ab874d5 | 2007-05-08 14:39:11 +0200 | [diff] [blame] | 11 | |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 12 | #define GET(val, fslnum) \ |
| 13 | __asm__ __volatile__ ("get %0, rfsl" #fslnum :"=r" (val)); |
Michal Simek | ab874d5 | 2007-05-08 14:39:11 +0200 | [diff] [blame] | 14 | |
| 15 | #define NCGET(val, fslnum) \ |
| 16 | __asm__ __volatile__ ("ncget %0, rfsl" #fslnum :"=r" (val)); |
| 17 | |
| 18 | #define CGET(val, fslnum) \ |
| 19 | __asm__ __volatile__ ("cget %0, rfsl" #fslnum :"=r" (val)); |
| 20 | |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 21 | #define NPUT(val, fslnum) \ |
| 22 | __asm__ __volatile__ ("nput %0, rfsl" #fslnum ::"r" (val)); |
Michal Simek | ab874d5 | 2007-05-08 14:39:11 +0200 | [diff] [blame] | 23 | |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 24 | #define PUT(val, fslnum) \ |
| 25 | __asm__ __volatile__ ("put %0, rfsl" #fslnum ::"r" (val)); |
Michal Simek | 48fbd3a | 2007-05-07 17:11:09 +0200 | [diff] [blame] | 26 | |
Michal Simek | ab874d5 | 2007-05-08 14:39:11 +0200 | [diff] [blame] | 27 | #define NCPUT(val, fslnum) \ |
| 28 | __asm__ __volatile__ ("ncput %0, rfsl" #fslnum ::"r" (val)); |
| 29 | |
| 30 | #define CPUT(val, fslnum) \ |
| 31 | __asm__ __volatile__ ("cput %0, rfsl" #fslnum ::"r" (val)); |
| 32 | |
Michal Simek | f7e2e0e | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 33 | /* CPU dependent */ |
Michal Simek | 1a50f164 | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 34 | /* machine status register */ |
Michal Simek | e69f66c | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 35 | #define MFS(val, reg) \ |
| 36 | __asm__ __volatile__ ("mfs %0," #reg :"=r" (val)); |
Michal Simek | 48fbd3a | 2007-05-07 17:11:09 +0200 | [diff] [blame] | 37 | |
Michal Simek | e69f66c | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 38 | #define MTS(val, reg) \ |
| 39 | __asm__ __volatile__ ("mts " #reg ", %0"::"r" (val)); |
Michal Simek | 1a50f164 | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 40 | |
Michal Simek | fb05f6d | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 41 | /* get return address from interrupt */ |
Michal Simek | 48fbd3a | 2007-05-07 17:11:09 +0200 | [diff] [blame] | 42 | #define R14(val) \ |
| 43 | __asm__ __volatile__ ("addi %0, r14, 0":"=r" (val)); |
Michal Simek | fb05f6d | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 44 | |
Michal Simek | 1c424d2 | 2015-01-26 14:32:23 +0100 | [diff] [blame] | 45 | /* get return address from interrupt */ |
| 46 | #define R17(val) \ |
| 47 | __asm__ __volatile__ ("addi %0, r17, 0" : "=r" (val)); |
| 48 | |
Michal Simek | e69f66c | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 49 | #define NOP __asm__ __volatile__ ("nop"); |
| 50 | |
Michal Simek | fb05f6d | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 51 | /* use machine status registe USE_MSR_REG */ |
Michal Simek | ac551e3 | 2016-05-24 11:45:11 +0200 | [diff] [blame] | 52 | #if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 1 |
Michal Simek | fb05f6d | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 53 | #define MSRSET(val) \ |
| 54 | __asm__ __volatile__ ("msrset r0," #val ); |
| 55 | |
| 56 | #define MSRCLR(val) \ |
| 57 | __asm__ __volatile__ ("msrclr r0," #val ); |
| 58 | |
| 59 | #else |
| 60 | #define MSRSET(val) \ |
| 61 | { \ |
| 62 | register unsigned tmp; \ |
| 63 | __asm__ __volatile__ (" \ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 64 | mfs %0, rmsr; \ |
Michal Simek | fb05f6d | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 65 | ori %0, %0, "#val"; \ |
| 66 | mts rmsr, %0; \ |
| 67 | nop;" \ |
| 68 | : "=r" (tmp) \ |
| 69 | : "d" (val) \ |
| 70 | : "memory"); \ |
| 71 | } |
| 72 | |
| 73 | #define MSRCLR(val) \ |
| 74 | { \ |
| 75 | register unsigned tmp; \ |
| 76 | __asm__ __volatile__ (" \ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 77 | mfs %0, rmsr; \ |
Michal Simek | fb05f6d | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 78 | andi %0, %0, ~"#val"; \ |
| 79 | mts rmsr, %0; \ |
| 80 | nop;" \ |
| 81 | : "=r" (tmp) \ |
| 82 | : "d" (val) \ |
| 83 | : "memory"); \ |
| 84 | } |
| 85 | #endif |