source: rtems/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c @ 8fbe2e6

4.115
Last change on this file since 8fbe2e6 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup raspberrypi_interrupt
5 *
6 * @brief Interrupt support.
7 */
8
9/*
10 * Copyright (c) 2009
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
18 * found in the file LICENSE in this distribution or at
19 * http://www.rtems.org/license/LICENSE.
20 */
21
22#include <rtems/score/armv4.h>
23
24#include <bsp.h>
25#include <bsp/irq.h>
26#include <bsp/irq-generic.h>
27#include <bsp/raspberrypi.h>
28#include <bsp/linker-symbols.h>
29#include <bsp/mmu.h>
30
31/*
32** This sets the main exception vectors
33*/
34void raspberrypi_set_exception_handler(
35                        Arm_symbolic_exception_name exception,
36                        void (*handler)(void)
37                                       )
38{
39    if ((unsigned) exception < MAX_EXCEPTIONS)
40    {
41        uint32_t *table = (uint32_t *) bsp_section_vector_begin + MAX_EXCEPTIONS;
42        table [exception] = (uint32_t) handler;
43
44    }
45}
46
47/*
48** Determine the source of the interrupt and dispatch the correct handler.
49*/
50void bsp_interrupt_dispatch(void)
51{
52  rtems_vector_number vector = 255;
53
54  /* ARM timer */
55  if (BCM2835_REG(BCM2835_IRQ_BASIC) && 0x1)
56  {
57      vector = BCM2835_IRQ_ID_TIMER_0;
58
59  }
60  /* UART 0 */
61  else if ( BCM2835_REG(BCM2835_IRQ_BASIC) && BCM2835_BIT(19))
62  {
63      vector = BCM2835_IRQ_ID_UART;
64  }
65
66  if ( vector < 255 )
67  {
68      bsp_interrupt_handler_dispatch(vector);
69  }
70
71}
72
73rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
74{
75  rtems_interrupt_level  level;
76
77  rtems_interrupt_disable(level);
78
79   /* ARM Timer */
80  if ( vector == BCM2835_IRQ_ID_TIMER_0 )
81  {
82      BCM2835_REG(BCM2835_IRQ_ENABLE_BASIC) = 0x1;
83  }
84  /* UART 0 */
85  else if ( vector == BCM2835_IRQ_ID_UART )
86  {
87      BCM2835_REG(BCM2835_IRQ_ENABLE2) =  BCM2835_BIT(25);
88
89  }
90  rtems_interrupt_enable(level);
91
92  return RTEMS_SUCCESSFUL;
93}
94
95rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
96{
97  rtems_interrupt_level level;
98
99  rtems_interrupt_disable(level);
100
101  if ( vector == BCM2835_IRQ_ID_TIMER_0 )
102  {
103      BCM2835_REG(BCM2835_IRQ_DISABLE_BASIC) = 0x1;
104  }
105  else if ( vector == BCM2835_IRQ_ID_UART )
106  {
107      BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(25);
108  }
109  rtems_interrupt_enable(level);
110
111  return RTEMS_SUCCESSFUL;
112}
113
114
115void bsp_interrupt_handler_default(rtems_vector_number vector)
116{
117    printk("spurious interrupt: %u\n", vector);
118}
119
120rtems_status_code bsp_interrupt_facility_initialize(void)
121{
122   raspberrypi_set_exception_handler(ARM_EXCEPTION_IRQ, _ARMV4_Exception_interrupt);
123   return RTEMS_SUCCESSFUL;
124}
Note: See TracBrowser for help on using the repository browser.