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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [common/] [v2_0/] [include/] [drv_api.h] - Blame information for rev 665

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

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_DRV_API_H
2
#define CYGONCE_HAL_DRV_API_H
3
 
4
/*==========================================================================
5
//
6
//      drv_api.h
7
//
8
//      Native API for Kernel
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 Red Hat, 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 version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//==========================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):   nickg
47
// Date:        1999-02-24
48
// Purpose:     Driver API
49
// Description: This file defines the API used by device drivers to access
50
//              system services. When the kernel is present it maps directly
51
//              to the Kernel C API. When the kernel is absent, it is provided
52
//              by a set of HAL functions.
53
//
54
// Usage:       #include <cyg/kernel/kapi.h>
55
//
56
//####DESCRIPTIONEND####
57
//
58
//========================================================================*/
59
 
60
#include <pkgconf/hal.h>
61
#include <cyg/infra/cyg_type.h>
62
 
63
#ifdef CYGPKG_KERNEL
64
 
65
/*------------------------------------------------------------------------*/
66
/* Kernel co-resident version of API                                      */
67
 
68
#include <pkgconf/kernel.h>
69
 
70
#ifndef CYGFUN_KERNEL_API_C
71
#error Driver API requres Kernel API to be present
72
#endif
73
 
74
#include <cyg/kernel/kapi.h>
75
 
76
#define cyg_drv_isr_lock                    cyg_interrupt_disable
77
#define cyg_drv_isr_unlock                  cyg_interrupt_enable
78
 
79
#define cyg_drv_dsr_lock                    cyg_scheduler_lock
80
#define cyg_drv_dsr_unlock                  cyg_scheduler_unlock
81
 
82
#define cyg_drv_mutex_t                     cyg_mutex_t
83
#define cyg_drv_mutex_init                  cyg_mutex_init
84
#define cyg_drv_mutex_destroy               cyg_mutex_destroy
85
#define cyg_drv_mutex_lock                  cyg_mutex_lock
86
#define cyg_drv_mutex_trylock               cyg_mutex_trylock
87
#define cyg_drv_mutex_unlock                cyg_mutex_unlock
88
#define cyg_drv_mutex_release               cyg_mutex_release
89
 
90
#define cyg_drv_cond_t                      cyg_cond_t
91
#define cyg_drv_cond_init                   cyg_cond_init
92
#define cyg_drv_cond_destroy                cyg_cond_destroy
93
#define cyg_drv_cond_wait                   cyg_cond_wait
94
#define cyg_drv_cond_signal                 cyg_cond_signal
95
#define cyg_drv_cond_broadcast              cyg_cond_broadcast
96
 
97
#define cyg_drv_interrupt_create            cyg_interrupt_create
98
#define cyg_drv_interrupt_delete            cyg_interrupt_delete
99
#define cyg_drv_interrupt_attach            cyg_interrupt_attach
100
#define cyg_drv_interrupt_detach            cyg_interrupt_detach
101
#define cyg_drv_interrupt_mask              cyg_interrupt_mask
102
#define cyg_drv_interrupt_unmask            cyg_interrupt_unmask
103
#define cyg_drv_interrupt_mask_intunsafe    cyg_interrupt_mask_intunsafe
104
#define cyg_drv_interrupt_unmask_intunsafe  cyg_interrupt_unmask_intunsafe
105
#define cyg_drv_interrupt_acknowledge       cyg_interrupt_acknowledge
106
#define cyg_drv_interrupt_configure         cyg_interrupt_configure
107
#define cyg_drv_interrupt_level             cyg_interrupt_level
108
#define cyg_drv_interrupt_set_cpu           cyg_interrupt_set_cpu
109
#define cyg_drv_interrupt_get_cpu           cyg_interrupt_get_cpu
110
 
111
#define cyg_drv_spinlock_t                  cyg_spinlock_t
112
#define cyg_drv_spinlock_init               cyg_spinlock_init
113
#define cyg_drv_spinlock_spin               cyg_spinlock_spin
114
#define cyg_drv_spinlock_clear              cyg_spinlock_clear
115
#define cyg_drv_spinlock_try                cyg_spinlock_try
116
#define cyg_drv_spinlock_test               cyg_spinlock_test
117
#define cyg_drv_spinlock_spin_intsave       cyg_spinlock_spin_intsave
118
#define cyg_drv_spinlock_clear_intsave      cyg_spinlock_clear_intsave
119
 
120
#else /* CYGPKG_KERNEL */
121
 
122
/*------------------------------------------------------------------------*/
123
/* Non-kernel version of API                                              */
124
 
125
typedef CYG_ADDRWORD cyg_addrword_t;        /* May hold pointer or word   */
126
typedef cyg_addrword_t cyg_handle_t;        /* Object handle              */
127
typedef cyg_uint32   cyg_priority_t;        /* type for priorities        */
128
typedef cyg_uint32   cyg_vector_t;          /* Interrupt vector id        */
129
typedef cyg_uint32   cyg_cpu_t;             /* CPU id                     */
130
typedef int          cyg_bool_t;
131
typedef cyg_int32    cyg_code_t;            /* type for various codes     */
132
 
133
typedef cyg_uint32 cyg_ISR_t( cyg_vector_t vector, cyg_addrword_t data);
134
typedef void cyg_DSR_t(cyg_vector_t vector,
135
                       cyg_ucount32 count,
136
                       cyg_addrword_t data);
137
 
138
 
139
externC void cyg_drv_isr_lock(void);
140
externC void cyg_drv_isr_unlock(void);
141
 
142
externC void cyg_drv_dsr_lock(void);
143
externC void cyg_drv_dsr_unlock(void);
144
 
145
typedef struct
146
{
147
    cyg_atomic          lock;
148
} cyg_drv_mutex_t;
149
 
150
externC void cyg_drv_mutex_init( cyg_drv_mutex_t *mutex );
151
externC void cyg_drv_mutex_destroy( cyg_drv_mutex_t *mutex );
152
externC cyg_bool_t cyg_drv_mutex_lock( cyg_drv_mutex_t *mutex );
153
externC cyg_bool_t cyg_drv_mutex_trylock( cyg_drv_mutex_t *mutex );
154
externC void cyg_drv_mutex_unlock( cyg_drv_mutex_t *mutex );
155
externC void cyg_drv_mutex_release( cyg_drv_mutex_t *mutex );
156
 
157
typedef struct
158
{
159
    cyg_atomic          wait;
160
    cyg_drv_mutex_t       *mutex;
161
} cyg_drv_cond_t;
162
 
163
externC void cyg_drv_cond_init( cyg_drv_cond_t  *cond, cyg_drv_mutex_t *mutex );
164
externC void cyg_drv_cond_destroy( cyg_drv_cond_t  *cond );
165
externC cyg_bool_t cyg_drv_cond_wait( cyg_drv_cond_t *cond );
166
externC void cyg_drv_cond_signal( cyg_drv_cond_t *cond );
167
externC void cyg_drv_cond_broadcast( cyg_drv_cond_t *cond );
168
 
169
typedef struct cyg_interrupt
170
{
171
    cyg_vector_t        vector;
172
    cyg_priority_t      priority;
173
    cyg_ISR_t           *isr;
174
    cyg_DSR_t           *dsr;
175
    CYG_ADDRWORD        data;
176
 
177
    struct cyg_interrupt* volatile next_dsr;
178
    volatile cyg_int32             dsr_count;
179
 
180
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
181
    struct cyg_interrupt *next;
182
#endif
183
 
184
} cyg_interrupt;
185
 
186
externC void cyg_drv_interrupt_create(
187
                     cyg_vector_t        vector,
188
                     cyg_priority_t      priority,
189
                     cyg_addrword_t      data,
190
                     cyg_ISR_t           *isr,
191
                     cyg_DSR_t           *dsr,
192
                     cyg_handle_t        *handle,
193
                     cyg_interrupt       *intr
194
                     );
195
externC void cyg_drv_interrupt_delete( cyg_handle_t interrupt );
196
externC void cyg_drv_interrupt_attach( cyg_handle_t interrupt );
197
externC void cyg_drv_interrupt_detach( cyg_handle_t interrupt );
198
 
199
externC void cyg_drv_interrupt_mask( cyg_vector_t vector );
200
externC void cyg_drv_interrupt_mask_intunsafe( cyg_vector_t vector );
201
externC void cyg_drv_interrupt_unmask( cyg_vector_t vector );
202
externC void cyg_drv_interrupt_unmask_intunsafe( cyg_vector_t vector );
203
externC void cyg_drv_interrupt_acknowledge( cyg_vector_t vector );
204
externC void cyg_drv_interrupt_configure(
205
                     cyg_vector_t        vector,
206
                     cyg_bool_t          level,
207
                     cyg_bool_t          up
208
                     );
209
externC void cyg_drv_interrupt_level( cyg_vector_t vector, cyg_priority_t level );
210
externC void cyg_drv_interrupt_set_cpu( cyg_vector_t vector, cyg_cpu_t cpu );
211
externC cyg_cpu_t cyg_drv_interrupt_get_cpu( cyg_vector_t vector );
212
 
213
 
214
enum cyg_ISR_results
215
{
216
    CYG_ISR_HANDLED  = 1,               /* Interrupt was handled             */
217
    CYG_ISR_CALL_DSR = 2                /* Schedule DSR                      */
218
};
219
 
220
 
221
typedef struct
222
{
223
    cyg_atomic          lock;
224
} cyg_drv_spinlock_t;
225
 
226
void cyg_drv_spinlock_init(
227
    cyg_drv_spinlock_t  *lock,          /* spinlock to initialize            */
228
    cyg_bool_t          locked          /* init locked or unlocked           */
229
);
230
 
231
void cyg_drv_spinlock_destroy( cyg_drv_spinlock_t *lock );
232
 
233
void cyg_drv_spinlock_spin( cyg_drv_spinlock_t *lock );
234
 
235
void cyg_drv_spinlock_clear( cyg_drv_spinlock_t *lock );
236
 
237
cyg_bool_t cyg_drv_spinlock_try( cyg_drv_spinlock_t *lock );
238
 
239
cyg_bool_t cyg_drv_spinlock_test( cyg_drv_spinlock_t *lock );
240
 
241
void cyg_drv_spinlock_spin_intsave( cyg_drv_spinlock_t *lock,
242
                                    cyg_addrword_t *istate );
243
 
244
void cyg_drv_spinlock_clear_intsave( cyg_drv_spinlock_t *lock,
245
                                     cyg_addrword_t istate );
246
 
247
#endif /* CYGPKG_KERNEL */
248
 
249
/*------------------------------------------------------------------------*/
250
/* EOF drv_api.h                                                          */
251
#endif // CYGONCE_HAL_DRV_API_H

powered by: WebSVN 2.1.0

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