source: trunk/hal/tsar_mips32/core/hal_irqmask.c @ 457

Last change on this file since 457 was 457, checked in by alain, 6 years ago

This version modifies the exec syscall and fixes a large number of small bugs.
The version number has been updated (0.1)

File size: 2.0 KB
Line 
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_kernel_types.h>
26#include <hal_shared_types.h>
27
28//////////////////////////////////////////
29inline void hal_disable_irq( reg_t * old )
30{
31        register uint32_t sr;
32       
33        __asm__ volatile 
34                (".set noat                          \n"
35         "mfc0   $1,     $12                 \n"
36                 "or     %0,     $0,     $1          \n"
37                 "srl    $1,     $1,     1           \n"
38                 "sll    $1,     $1,     1           \n"
39                 "mtc0   $1,     $12                 \n"
40         ".set at                            \n"
41                 : "=&r" (sr) );
42
43        if( old ) *old = sr;
44}
45
46/////////////////////////////////////////
47inline void hal_enable_irq( reg_t * old )
48{
49        register uint32_t sr;
50 
51        __asm__ volatile 
52                (".set noat                          \n"
53                 "mfc0   $1,     $12                 \n"
54                 "or     %0,     $0,     $1          \n"
55                 "ori    $1,     $1,     0xFF01      \n"
56                 "mtc0   $1,     $12                 \n"
57         ".set at                            \n"
58                 : "=&r" (sr) );
59 
60        if( old ) *old = sr;
61}
62
63////////////////////////////////////////
64inline void hal_restore_irq( reg_t old )
65{
66        __asm__ volatile 
67                ( "mtc0    %0,    $12" : : "r" (old) );
68}
69
70
Note: See TracBrowser for help on using the repository browser.