source: rtems/c/src/lib/libbsp/shared/src/irq-legacy.c @ 780428f

4.104.114.95
Last change on this file since 780428f was 780428f, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/10/08 at 06:19:03

Extension of the RTEMS Interrupt Manager
(shared handler and handler with a handle).

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup bsp_interrupt
5 *
6 * @brief Source file for generic BSP interrupt support legacy code.
7 */
8
9/*
10 * Copyright (c) 2008
11 * Embedded Brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * rtems@embedded-brains.de
16 *
17 * The license and distribution terms for this file may be found in the file
18 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
19 */
20
21#include <stdlib.h>
22
23#include <rtems/irq.h>
24
25#include <bsp/irq-generic.h>
26
27typedef struct {
28        rtems_irq_hdl handler;
29        void *arg;
30} bsp_interrupt_legacy_entry;
31
32static void bsp_interrupt_legacy_dispatch( rtems_vector_number vector, void *arg)
33{
34        bsp_interrupt_legacy_entry *e = arg;
35        e->handler( e->arg);
36}
37
38/**
39 * @deprecated Obsolete.
40 */
41int BSP_get_current_rtems_irq_handler( rtems_irq_connect_data *cd)
42{
43        cd->hdl = NULL;
44        cd->handle = NULL;
45        cd->on = NULL;
46        cd->off = NULL;
47        cd->isOn = NULL;
48}
49
50/**
51 * @deprecated Use rtems_interrupt_handler_install() instead.
52 */
53int BSP_install_rtems_irq_handler( const rtems_irq_connect_data *cd)
54{
55        rtems_status_code sc = RTEMS_SUCCESSFUL;
56        bsp_interrupt_legacy_entry *e = malloc( sizeof( bsp_interrupt_legacy_entry));
57
58        if (e == NULL) {
59                return 0;
60        }
61
62        e->handler = cd->hdl;
63        e->arg = cd->handle;
64
65        sc = rtems_interrupt_handler_install(
66                cd->name,
67                "Unique interrupt handler (installed with obsolete BSP_install_rtems_irq_handler())",
68                RTEMS_INTERRUPT_UNIQUE,
69                bsp_interrupt_legacy_dispatch,
70                e
71        );
72        if (sc != RTEMS_SUCCESSFUL) {
73                free( e);
74                return 0;
75        }
76
77        if (cd->on) {
78                cd->on( cd);
79        }
80
81        return 1;
82}
83
84/**
85 * @deprecated Use rtems_interrupt_handler_install() instead.
86 */
87int BSP_install_rtems_shared_irq_handler( const rtems_irq_connect_data *cd)
88{
89        rtems_status_code sc = RTEMS_SUCCESSFUL;
90        bsp_interrupt_legacy_entry *e = malloc( sizeof( bsp_interrupt_legacy_entry));
91
92        if (e == NULL) {
93                return 0;
94        }
95
96        e->handler = cd->hdl;
97        e->arg = cd->handle;
98
99        sc = rtems_interrupt_handler_install(
100                cd->name,
101                "Shared interrupt handler (installed with obsolete BSP_install_rtems_shared_irq_handler())",
102                RTEMS_INTERRUPT_SHARED,
103                bsp_interrupt_legacy_dispatch,
104                e
105        );
106        if (sc != RTEMS_SUCCESSFUL) {
107                free( e);
108                return 0;
109        }
110
111        if (cd->on) {
112                cd->on( cd);
113        }
114
115        return 1;
116}
117
118/**
119 * @deprecated Use rtems_interrupt_handler_remove() instead.
120 */
121int BSP_remove_rtems_irq_handler( const rtems_irq_connect_data *cd)
122{
123        rtems_status_code sc = RTEMS_SUCCESSFUL;
124        bsp_interrupt_handler_entry *head = NULL;
125        bsp_interrupt_handler_entry *current = NULL;
126        bsp_interrupt_legacy_entry *e = NULL;
127
128        sc = bsp_interrupt_handler_query( cd->name, head);
129        if (sc != RTEMS_SUCCESSFUL) {
130                return 0;
131        }
132
133        current = head;
134        while (current != NULL) {
135                if (current->handler == bsp_interrupt_legacy_dispatch) {
136                        e = current->arg;
137                        if (e->arg == cd->handle) {
138                                break;
139                        } else {
140                                e = NULL;
141                        }
142                }
143                current = current->next;
144        }
145
146        sc = bsp_interrupt_handler_query_free( head);
147        if (sc != RTEMS_SUCCESSFUL) {
148                return 0;
149        }
150
151        if (e == NULL) {
152                return 0;
153        }
154
155        if (cd->off) {
156                cd->off( cd);
157        }
158        sc = rtems_interrupt_handler_remove( cd->name, bsp_interrupt_legacy_dispatch, e);
159        if (sc != RTEMS_SUCCESSFUL) {
160                return 0;
161        }
162        return 1;
163}
164
165/**
166 * @deprecated Use bsp_interrupt_initialize() instead.
167 */
168int BSP_rtems_irq_mngt_set( rtems_irq_global_settings *config)
169{
170        return 0;
171}
172
173/**
174 * @deprecated Obsolete.
175 */
176int BSP_rtems_irq_mngt_get( rtems_irq_global_settings **config)
177{
178        *config = NULL;
179        return 0;
180}
Note: See TracBrowser for help on using the repository browser.