1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSBSPsPowerPCQorIQ |
---|
5 | * |
---|
6 | * @brief Support file for Timer Test 27. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2010-2015 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef _RTEMS_TMTEST27 |
---|
18 | #error "This is an RTEMS internal file you must not include directly." |
---|
19 | #endif /* _RTEMS_TMTEST27 */ |
---|
20 | |
---|
21 | #ifndef TMTESTS_TM27_H |
---|
22 | #define TMTESTS_TM27_H |
---|
23 | |
---|
24 | #include <assert.h> |
---|
25 | |
---|
26 | #include <libcpu/powerpc-utility.h> |
---|
27 | |
---|
28 | #include <bsp/irq.h> |
---|
29 | #include <bsp/qoriq.h> |
---|
30 | |
---|
31 | #define MUST_WAIT_FOR_INTERRUPT 1 |
---|
32 | |
---|
33 | #define IPI_INDEX_LOW 1 |
---|
34 | |
---|
35 | #define IPI_INDEX_HIGH 2 |
---|
36 | |
---|
37 | RTEMS_INLINE_ROUTINE void Install_tm27_vector(void (*handler)(rtems_vector_number)) |
---|
38 | { |
---|
39 | rtems_status_code sc; |
---|
40 | rtems_vector_number low = QORIQ_IRQ_IPI_0 + IPI_INDEX_LOW; |
---|
41 | rtems_vector_number high = QORIQ_IRQ_IPI_0 + IPI_INDEX_HIGH; |
---|
42 | |
---|
43 | sc = rtems_interrupt_handler_install( |
---|
44 | low, |
---|
45 | "tm17 low", |
---|
46 | RTEMS_INTERRUPT_UNIQUE, |
---|
47 | (rtems_interrupt_handler) handler, |
---|
48 | NULL |
---|
49 | ); |
---|
50 | assert(sc == RTEMS_SUCCESSFUL); |
---|
51 | |
---|
52 | sc = qoriq_pic_set_priority(low, 1, NULL); |
---|
53 | assert(sc == RTEMS_SUCCESSFUL); |
---|
54 | |
---|
55 | sc = rtems_interrupt_handler_install( |
---|
56 | high, |
---|
57 | "tm17 high", |
---|
58 | RTEMS_INTERRUPT_UNIQUE, |
---|
59 | (rtems_interrupt_handler) handler, |
---|
60 | NULL |
---|
61 | ); |
---|
62 | assert(sc == RTEMS_SUCCESSFUL); |
---|
63 | |
---|
64 | sc = qoriq_pic_set_priority(high, 2, NULL); |
---|
65 | assert(sc == RTEMS_SUCCESSFUL); |
---|
66 | } |
---|
67 | |
---|
68 | RTEMS_INLINE_ROUTINE void qoriq_tm27_cause(uint32_t ipi_index) |
---|
69 | { |
---|
70 | uint32_t self = ppc_processor_id(); |
---|
71 | |
---|
72 | qoriq.pic.per_cpu[self].ipidr[ipi_index].reg = UINT32_C(1) << self; |
---|
73 | } |
---|
74 | |
---|
75 | RTEMS_INLINE_ROUTINE void Cause_tm27_intr(void) |
---|
76 | { |
---|
77 | qoriq_tm27_cause(IPI_INDEX_LOW); |
---|
78 | } |
---|
79 | |
---|
80 | RTEMS_INLINE_ROUTINE void Clear_tm27_intr(void) |
---|
81 | { |
---|
82 | /* Nothing to do */ |
---|
83 | } |
---|
84 | |
---|
85 | RTEMS_INLINE_ROUTINE inline void Lower_tm27_intr(void) |
---|
86 | { |
---|
87 | qoriq_tm27_cause(IPI_INDEX_HIGH); |
---|
88 | } |
---|
89 | |
---|
90 | #endif /* TMTESTS_TM27_H */ |
---|