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