source: rtems/bsps/arm/csb336/clock/clockdrv.c

Last change on this file was 7ee59313, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 1, 2018 at 5:11:12 AM

Remove Clock_driver_support_shutdown_hardware()

The aim of this clock driver hook was to stop clock tick interrupts at
some late point in the exit() procedure.

The use of atexit() pulls in malloc() which pulls in errno. It is
incompatible with the intention of the
CONFIGURE_DISABLE_NEWLIB_REENTRANCY configuration option.

The exit() function must be called from thread context, so accompanied
clock tick interrupts should cause no harm. On the contrary, someone
may assume a normal operating system operation, e.g. working timeouts.

Remove the Clock_driver_support_shutdown_hardware() clock driver hook.

Close #3436.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  MC9328MXL clock specific using the System Timer
3 */
4
5/*
6 *  Copyright (c) 2004 by Cogent Computer Systems
7 *  Written by Jay Monkman <jtm@lopingdog.com>
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.org/license/LICENSE.
12 */
13
14#include <rtems.h>
15#include <bsp.h>
16#include <bsp/irq.h>
17#include <mc9328mxl.h>
18#include <rtems/bspIo.h>  /* for printk */
19
20/* this is defined in ../../../shared/dev/clock/clockimpl.h */
21void Clock_isr(rtems_irq_hdl_param arg);
22static void clock_isr_on(const rtems_irq_connect_data *unused);
23static void clock_isr_off(const rtems_irq_connect_data *unused);
24static int clock_isr_is_on(const rtems_irq_connect_data *irq);
25
26/* Replace the first value with the clock's interrupt name. */
27rtems_irq_connect_data clock_isr_data = {
28  .name   = BSP_INT_TIMER1,
29  .hdl    = Clock_isr,
30  .handle = (void *)BSP_INT_TIMER1,
31  .on     = clock_isr_on,
32  .off    = clock_isr_off,
33  .isOn   = clock_isr_is_on,
34};
35
36/**
37 * When we get the clock interrupt
38 *    - clear the interrupt bit?
39 *    - restart the timer?
40 */
41#define Clock_driver_support_at_tick()               \
42  do {                                               \
43    uint32_t reg;                                    \
44                                                     \
45    reg = MC9328MXL_TMR1_TSTAT;                      \
46    (void) reg; /* avoid set but not used warning */ \
47    MC9328MXL_TMR1_TSTAT = 0;                        \
48  } while(0)
49
50/**
51 * Installs the clock ISR. You shouldn't need to change this.
52 */
53#define Clock_driver_support_install_isr( _new ) \
54  BSP_install_rtems_irq_handler(&clock_isr_data)
55
56/**
57 * Initialize the hardware for the clock
58 *   - Set the frequency
59 *   - enable it
60 *   - clear any pending interrupts
61 *
62 * Since you may want the clock always running, you can
63 * enable interrupts here. If you do so, the clock_isr_on(),
64 * clock_isr_off(), and clock_isr_is_on() functions can be
65 * NOPs.
66 */
67#define Clock_driver_support_initialize_hardware() \
68  do { \
69        int freq; \
70        int cnt; \
71        freq = get_perclk1_freq(); \
72        printk("perclk1 freq is %d\n", freq); \
73        cnt = ((long long)freq * rtems_configuration_get_microseconds_per_tick() + 500000) / 1000000;\
74        printk("cnt freq is %d\n", cnt); \
75        MC9328MXL_TMR1_TCMP = cnt; \
76        /* use PERCLK1 as input, enable timer */ \
77        MC9328MXL_TMR1_TCTL = (MC9328MXL_TMR_TCTL_CLKSRC_PCLK1 | \
78                               MC9328MXL_TMR_TCTL_TEN | \
79                               MC9328MXL_TMR_TCTL_IRQEN); \
80        /* set prescaler to 1 (register value + 1) */ \
81        MC9328MXL_TMR1_TPRER = 0; \
82     } while (0)
83
84/**
85 * Enables clock interrupt.
86 *
87 * If the interrupt is always on, this can be a NOP.
88 */
89static void clock_isr_on(const rtems_irq_connect_data *unused)
90{
91  MC9328MXL_TMR1_TCTL |= MC9328MXL_TMR_TCTL_IRQEN;
92  MC9328MXL_AITC_INTENNUM = MC9328MXL_INT_TIMER1;
93}
94
95/**
96 * Disables clock interrupts
97 *
98 * If the interrupt is always on, this can be a NOP.
99 */
100static void clock_isr_off(const rtems_irq_connect_data *unused)
101{
102  MC9328MXL_TMR1_TCTL &= ~MC9328MXL_TMR_TCTL_IRQEN;
103  MC9328MXL_AITC_INTDISNUM = MC9328MXL_INT_TIMER1;
104}
105
106/**
107 * Tests to see if clock interrupt is enabled, and returns 1 if so.
108 * If interrupt is not enabled, returns 0.
109 *
110 * If the interrupt is always on, this always returns 1.
111 */
112static int clock_isr_is_on(const rtems_irq_connect_data *irq)
113{
114  return MC9328MXL_TMR1_TCTL & MC9328MXL_TMR_TCTL_IRQEN;
115}
116
117#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
118
119/* Make sure to include this, and only at the end of the file */
120
121#include "../../../shared/dev/clock/clockimpl.h"
Note: See TracBrowser for help on using the repository browser.