OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [common/] [current/] [include/] [hal_arbiter.h] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_HAL_ARBITER_H
2
#define CYGONCE_HAL_HAL_ARBITER_H
3
 
4
//=============================================================================
5
//
6
//      hal_arbiter.h
7
//
8
//      Functionality used by ISR arbiters
9
//
10
//=============================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
12
// -------------------------------------------                              
13
// This file is part of eCos, the Embedded Configurable Operating System.   
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under    
17
// the terms of the GNU General Public License as published by the Free     
18
// Software Foundation; either version 2 or (at your option) any later      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
24
// for more details.                                                        
25
//
26
// You should have received a copy of the GNU General Public License        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):   jskov
46
// Contributors:jskov
47
// Date:        2001-06-29
48
// Purpose:     Functionality used by ISR arbiters
49
// Usage:       #include <cyg/hal/hal_arbiter.h>
50
//                           
51
//####DESCRIPTIONEND####
52
//
53
//=============================================================================
54
 
55
#include <cyg/hal/hal_intr.h>           // hal_interrupt_x tables
56
#include <cyg/hal/drv_api.h>            // CYG_ISR_HANDLED
57
 
58
//=============================================================================
59
// Function used to call ISRs from ISR arbiters
60
// An arbiter is hooked on the shared interrupt vector and looks like this:
61
//
62
//  cyg_uint32 _arbitration_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
63
//  {
64
//     cyg_uint32 isr_ret;
65
//     // decode interrupt source and for each active source call the ISR
66
//     if (source_A_active) {
67
//         isr_ret = hal_call_isr (CYGNUM_HAL_INTERRUPT_SOURCE_A);
68
//  #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
69
//         if (isr_ret & CYG_ISR_HANDLED)
70
//  #endif
71
//             return isr_ret;
72
//     }
73
//     if (source_B_active) {
74
//         isr_ret = hal_call_isr (CYGNUM_HAL_INTERRUPT_SOURCE_B);
75
//  #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
76
//         if (isr_ret & CYG_ISR_HANDLED)
77
//  #endif
78
//             return isr_ret;
79
//     }
80
//  ...
81
//     return 0;
82
//  }
83
//
84
// Remember to attach and enable the arbiter source:
85
//    HAL_INTERRUPT_ATTACH(CYGNUM_HAL_INTERRUPT_ARBITER, &_arbitration_isr, 0, 0);
86
//    HAL_INTERRUPT_SET_LEVEL(CYGNUM_HAL_INTERRUPT_ARBITER, 1);
87
//    HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_ARBITER);
88
//
89
 
90
typedef cyg_uint32 cyg_ISR(cyg_uint32 vector, CYG_ADDRWORD data);
91
 
92
extern void cyg_interrupt_post_dsr( CYG_ADDRWORD intr_obj );
93
 
94
#ifndef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
95
 
96
static inline cyg_uint32
97
hal_call_isr (cyg_uint32 vector)
98
{
99
    cyg_ISR *isr;
100
    CYG_ADDRWORD data;
101
    cyg_uint32 isr_ret;
102
 
103
    isr = (cyg_ISR*) hal_interrupt_handlers[vector];
104
    data = hal_interrupt_data[vector];
105
 
106
    isr_ret = (*isr) (vector, data);
107
 
108
    if (isr_ret & CYG_ISR_CALL_DSR) {
109
        cyg_interrupt_post_dsr (hal_interrupt_objects[vector]);
110
    }
111
 
112
    return isr_ret & ~CYG_ISR_CALL_DSR;
113
}
114
 
115
#else
116
 
117
// In chained mode, assume vector 0 points to the chain
118
// handler. Simply call it with the vector number and let it find the
119
// ISR to call - it will also post DSRs as required.
120
static inline cyg_uint32
121
hal_call_isr (cyg_uint32 vector)
122
{
123
    cyg_ISR *isr;
124
    CYG_ADDRWORD data;
125
    cyg_uint32 isr_ret;
126
 
127
    isr = (cyg_ISR*) hal_interrupt_handlers[0];
128
    data = hal_interrupt_data[0];
129
 
130
    isr_ret = (*isr) (vector, data);
131
 
132
    return isr_ret;
133
}
134
 
135
#endif
136
 
137
//-----------------------------------------------------------------------------
138
#endif // CYGONCE_HAL_HAL_ARBITER_H
139
// End of hal_arbiter.h

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.