1 | /* |
---|
2 | * hal_irqmask.c - implementation of Generic IRQ Masking API for TSAR-MIPS32 |
---|
3 | * |
---|
4 | * Author Ghassan Almaless (2008,2009,2010,2011,2012) |
---|
5 | * Alain Greiner (2016) |
---|
6 | * |
---|
7 | * Copyright (c) UPMC Sorbonne Universites |
---|
8 | * |
---|
9 | * This file is part of ALMOS-MKH.. |
---|
10 | * |
---|
11 | * ALMOS-MKH. is free software; you can redistribute it and/or modify it |
---|
12 | * under the terms of the GNU General Public License as published by |
---|
13 | * the Free Software Foundation; version 2.0 of the License. |
---|
14 | * |
---|
15 | * ALMOS-MKH. is distributed in the hope that it will be useful, but |
---|
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | * General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU General Public License |
---|
21 | * along with ALMOS-MKH.; if not, write to the Free Software Foundation, |
---|
22 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
23 | */ |
---|
24 | |
---|
25 | #include <hal_types.h> |
---|
26 | |
---|
27 | ///////////////////////////////////////////// |
---|
28 | inline void hal_disable_irq( uint32_t * old ) |
---|
29 | { |
---|
30 | register unsigned int sr; |
---|
31 | |
---|
32 | __asm__ volatile |
---|
33 | (".set noat \n" |
---|
34 | ".set noreorder \n" |
---|
35 | "mfc0 $1, $12 \n" |
---|
36 | "nop \n" |
---|
37 | ".set reorder \n" |
---|
38 | "or %0, $0, $1 \n" |
---|
39 | "srl $1, $1, 1 \n" |
---|
40 | "sll $1, $1, 1 \n" |
---|
41 | "mtc0 $1, $12 \n" |
---|
42 | ".set at \n" |
---|
43 | : "=&r" (sr)); |
---|
44 | |
---|
45 | if( old ) *old = sr; |
---|
46 | } |
---|
47 | |
---|
48 | //////////////////////////////////////////// |
---|
49 | inline void hal_enable_irq( uint32_t * old ) |
---|
50 | { |
---|
51 | register unsigned int sr; |
---|
52 | |
---|
53 | __asm__ volatile |
---|
54 | (".set noat \n" |
---|
55 | ".set noreorder \n" |
---|
56 | "mfc0 $1, $12 \n" |
---|
57 | "nop \n" |
---|
58 | "or %0, $0, $1 \n" |
---|
59 | "ori $1, $1, 0x1 \n" |
---|
60 | "mtc0 $1, $12 \n" |
---|
61 | "nop \n" |
---|
62 | ".set reorder \n" |
---|
63 | ".set at \n" |
---|
64 | : "=&r" (sr)); |
---|
65 | |
---|
66 | if( old ) *old = sr; |
---|
67 | } |
---|
68 | |
---|
69 | /////////////////////////////////////////// |
---|
70 | inline void hal_restore_irq( uint32_t old ) |
---|
71 | { |
---|
72 | __asm__ volatile |
---|
73 | (".set noat \n" |
---|
74 | ".set noreorder \n" |
---|
75 | "mfc0 $1, $12 \n" |
---|
76 | "ori $2, $0, 0xFF \n" |
---|
77 | "and $2, $2, %0 \n" |
---|
78 | "or $1, $1, $2 \n" |
---|
79 | "mtc0 $1, $12 \n" |
---|
80 | ".set reorder \n" |
---|
81 | ".set at \n" |
---|
82 | : : "r" (old) : "$2"); |
---|
83 | } |
---|
84 | |
---|