Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Michal Simek | 6455ac0 | 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 | 6455ac0 | 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 | ee1aced | 2007-05-08 14:39:11 +0200 | [diff] [blame] | 11 | |
Michal Simek | 6455ac0 | 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 | ee1aced | 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 | 6455ac0 | 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 | ee1aced | 2007-05-08 14:39:11 +0200 | [diff] [blame] | 23 | |
Michal Simek | 6455ac0 | 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 | 603aa74 | 2007-05-07 17:11:09 +0200 | [diff] [blame] | 26 | |
Michal Simek | ee1aced | 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 | 6455ac0 | 2007-05-05 18:27:16 +0200 | [diff] [blame] | 33 | /* CPU dependent */ |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 34 | /* machine status register */ |
Michal Simek | ebf7b23 | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 35 | #define MFS(val, reg) \ |
| 36 | __asm__ __volatile__ ("mfs %0," #reg :"=r" (val)); |
Michal Simek | 603aa74 | 2007-05-07 17:11:09 +0200 | [diff] [blame] | 37 | |
Michal Simek | ebf7b23 | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 38 | #define MTS(val, reg) \ |
| 39 | __asm__ __volatile__ ("mts " #reg ", %0"::"r" (val)); |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 40 | |
Michal Simek | 98c1979 | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 41 | /* get return address from interrupt */ |
Michal Simek | 603aa74 | 2007-05-07 17:11:09 +0200 | [diff] [blame] | 42 | #define R14(val) \ |
| 43 | __asm__ __volatile__ ("addi %0, r14, 0":"=r" (val)); |
Michal Simek | 98c1979 | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 44 | |
Michal Simek | 924819c | 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 | ebf7b23 | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 49 | #define NOP __asm__ __volatile__ ("nop"); |
| 50 | |
Michal Simek | 98c1979 | 2007-05-07 23:58:31 +0200 | [diff] [blame] | 51 | /* use machine status registe USE_MSR_REG */ |
Michal Simek | 731e0f9 | 2016-05-24 11:45:11 +0200 | [diff] [blame] | 52 | #if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 1 |
Michal Simek | 98c1979 | 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 | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 64 | mfs %0, rmsr; \ |
Michal Simek | 98c1979 | 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 | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 77 | mfs %0, rmsr; \ |
Michal Simek | 98c1979 | 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 |