forked from Imagelibrary/rtems
clock: Simplify driver initialization
Use a system initialization handler instead of a legacy IO driver. Update #3834.
This commit is contained in:
@@ -53,16 +53,7 @@ static void Clock_exit(void)
|
||||
*(uint32_t volatile *) TCNTL = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock_initialize
|
||||
*
|
||||
* This routine initializes the clock driver.
|
||||
*/
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Clock_driver_ticks = 0;
|
||||
|
||||
@@ -75,6 +66,4 @@ rtems_device_driver Clock_initialize(
|
||||
*(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD | TCNTL_TMREN;
|
||||
|
||||
atexit(Clock_exit);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -112,14 +112,7 @@ Install_clock(rtems_isr_entry clock_isr)
|
||||
atexit(Clock_exit);
|
||||
}
|
||||
|
||||
rtems_device_driver
|
||||
Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock (Clock_isr);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -91,14 +91,7 @@ Install_clock (rtems_isr_entry clock_isr)
|
||||
atexit (Clock_exit);
|
||||
}
|
||||
|
||||
rtems_device_driver
|
||||
Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock (Clock_isr);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -102,12 +102,7 @@ Install_clock(rtems_isr_entry clock_isr)
|
||||
atexit(Clock_exit);
|
||||
}
|
||||
|
||||
rtems_device_driver
|
||||
Clock_initialize(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock (Clock_isr);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -63,13 +63,7 @@ void Clock_exit( void )
|
||||
/* do not restore old vector */
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -70,13 +70,7 @@ void Clock_exit( void )
|
||||
pcc->timer2_int_control = 0x00; /* Disable T2 Interr. */
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -77,13 +77,7 @@ void Clock_exit( void )
|
||||
/* Dummy for now. See other m68k BSP's for code examples */
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
/*
|
||||
* Implementation of the Clock_initialize() functions
|
||||
* prototyped in rtems/c/src/lib/include/clockdrv.h.
|
||||
*
|
||||
* This port does not allow the application to select which timer on the
|
||||
* MVME167 to use for the clock, nor does it allow the application to
|
||||
* configure the clock. The clock uses the VMEchip2 Tick Timer #2. This
|
||||
@@ -147,13 +144,7 @@ void clock_exit( void )
|
||||
set_vector( Old_ticker, CLOCK_VECTOR, 1 );
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
VMEchip2_T2_initialize();
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -198,20 +198,7 @@ void Clock_exit( void )
|
||||
mips_disable_in_interrupt_mask(~CLOCK_VECTOR_MASK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock_initialize
|
||||
*
|
||||
* Device driver entry point for clock tick driver initialization.
|
||||
*/
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,19 +109,7 @@ void Clock_exit( void )
|
||||
/* XXX: If necessary, restore the old vector */
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock_initialize
|
||||
*
|
||||
* Device driver entry point for clock tick driver initialization.
|
||||
*/
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,16 +197,7 @@ int clockIsOn(void* unused)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock_initialize
|
||||
*
|
||||
* This routine initializes the clock driver.
|
||||
*/
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
rtems_interrupt_level l,tcr;
|
||||
|
||||
|
||||
@@ -265,11 +265,7 @@ void Clock_exit(void)
|
||||
BSP_remove_rtems_irq_handler (&clockIrqConnData);
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_initialize(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -167,11 +167,7 @@ static int ppc_clock_exception_handler_ppc405(BSP_Exception_frame *frame, unsign
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
uint64_t frequency = bsp_time_base_frequency;
|
||||
uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
|
||||
@@ -233,6 +229,4 @@ rtems_device_driver Clock_initialize(
|
||||
ppc_tc.tc_frequency = frequency;
|
||||
ppc_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
|
||||
rtems_timecounter_install(&ppc_tc);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -130,13 +130,7 @@ static void Install_clock(rtems_isr_entry clock_isr)
|
||||
atexit(Clock_exit);
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -288,19 +288,7 @@ void Clock_exit( void )
|
||||
/* old vector shall not be installed */
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock_initialize
|
||||
*
|
||||
* Device driver entry point for clock tick driver initialization.
|
||||
*/
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -228,18 +228,7 @@ void Clock_exit( void )
|
||||
/* old vector shall not be installed */
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock_initialize
|
||||
*
|
||||
* Device driver entry point for clock tick driver initialization.
|
||||
*/
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -229,18 +229,7 @@ Clock_exit(void)
|
||||
/* old vector shall not be installed */
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock_initialize
|
||||
*
|
||||
* Device driver entry point for clock tick driver initialization.
|
||||
*/
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Install_clock( Clock_isr );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -194,22 +194,7 @@ rtems_isr Clock_isr(
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clock_initialize
|
||||
*
|
||||
* This routine initializes the clock driver.
|
||||
*
|
||||
* @param[in] major Clock device major number.
|
||||
* @param[in] minor Clock device minor number.
|
||||
* @param[in] parg Pointer to optional device driver arguments
|
||||
*
|
||||
* @retval rtems_device_driver status code
|
||||
*/
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
void _Clock_Initialize( void )
|
||||
{
|
||||
Clock_driver_ticks = 0;
|
||||
|
||||
@@ -240,6 +225,4 @@ rtems_device_driver Clock_initialize(
|
||||
#if CLOCK_DRIVER_ISRS_PER_TICK
|
||||
Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK_VALUE;
|
||||
#endif
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -163,8 +163,7 @@ static void tlib_clock_timecounter_tick(void)
|
||||
priv.ops->timecounter_tick();
|
||||
}
|
||||
|
||||
/* Return a value not equal to RTEMS_SUCCESFUL to make Clock_initialize fail. */
|
||||
static rtems_device_driver tlib_clock_install_isr(rtems_isr *isr)
|
||||
static void tlib_clock_install_isr(rtems_isr *isr)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
@@ -173,8 +172,6 @@ static rtems_device_driver tlib_clock_install_isr(rtems_isr *isr)
|
||||
flags = TLIB_FLAGS_BROADCAST;
|
||||
#endif
|
||||
tlib_irq_register(priv.tlib_tick, isr, NULL, flags);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
#ifndef RTEMS_SMP
|
||||
@@ -404,13 +401,7 @@ static const struct ops ops_irqamp = {
|
||||
} while (0)
|
||||
|
||||
#define Clock_driver_support_install_isr( isr ) \
|
||||
do { \
|
||||
rtems_device_driver ret; \
|
||||
ret = tlib_clock_install_isr( isr ); \
|
||||
if (RTEMS_SUCCESSFUL != ret) { \
|
||||
return ret; \
|
||||
} \
|
||||
} while (0)
|
||||
tlib_clock_install_isr( isr )
|
||||
|
||||
#define Clock_driver_support_set_interrupt_affinity(online_processors) \
|
||||
/* Done by tlib_clock_install_isr() */
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Clock Driver for all Boards
|
||||
* @ingroup RTEMSDriverClock
|
||||
*
|
||||
* This file describes the Clock Driver for all boards.
|
||||
* @brief Clock Driver API
|
||||
*
|
||||
* This file defines the Clock Driver API.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -18,26 +20,35 @@
|
||||
#ifndef _RTEMS_CLOCKDRV_H
|
||||
#define _RTEMS_CLOCKDRV_H
|
||||
|
||||
#include <rtems/io.h> /* rtems_device_driver */
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* variables */
|
||||
/**
|
||||
* @defgroup RTEMSDriverClock Clock Driver
|
||||
*
|
||||
* @ingroup RTEMSDeviceDrivers
|
||||
*
|
||||
* @brief The Clock Driver API.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern volatile uint32_t Clock_driver_ticks;
|
||||
/**
|
||||
* @brief Count of clock driver ticks since system boot or last overflow.
|
||||
*
|
||||
* This counter may overflow.
|
||||
*/
|
||||
extern volatile uint32_t Clock_driver_ticks;
|
||||
|
||||
/* default clock driver entry */
|
||||
/**
|
||||
* @brief Initialize the clock driver.
|
||||
*/
|
||||
void _Clock_Initialize( void );
|
||||
|
||||
#define CLOCK_DRIVER_TABLE_ENTRY \
|
||||
{ Clock_initialize, NULL, NULL, NULL, NULL, NULL }
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1558,6 +1558,14 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
|
||||
|
||||
#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#include <rtems/clockdrv.h>
|
||||
|
||||
#ifdef CONFIGURE_INIT
|
||||
RTEMS_SYSINIT_ITEM(
|
||||
_Clock_Initialize,
|
||||
RTEMS_SYSINIT_DEVICE_DRIVERS,
|
||||
RTEMS_SYSINIT_ORDER_THIRD
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
|
||||
@@ -1619,9 +1627,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
|
||||
#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
CONSOLE_DRIVER_TABLE_ENTRY,
|
||||
#endif
|
||||
#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
CLOCK_DRIVER_TABLE_ENTRY,
|
||||
#endif
|
||||
#ifdef CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
|
||||
RTC_DRIVER_TABLE_ENTRY,
|
||||
#endif
|
||||
@@ -1649,7 +1654,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
|
||||
#ifdef CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER
|
||||
NULL_DRIVER_TABLE_ENTRY
|
||||
#elif !defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) && \
|
||||
!defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \
|
||||
!defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) && \
|
||||
!defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) && \
|
||||
!defined(CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER) && \
|
||||
|
||||
@@ -26,9 +26,9 @@ void do_test_zero_driver(void);
|
||||
|
||||
#define PRIurtems_device_major_number PRIu32
|
||||
|
||||
#define STUB_DRIVER_MAJOR 0x2
|
||||
#define ZERO_DRIVER_MAJOR 0x3
|
||||
#define NO_DRIVER_MAJOR 0x4
|
||||
#define STUB_DRIVER_MAJOR 1
|
||||
#define ZERO_DRIVER_MAJOR 2
|
||||
#define NO_DRIVER_MAJOR 3
|
||||
#define INVALID_DRIVER_MAJOR UINT32_MAX
|
||||
|
||||
/* driver entries to use with io_register */
|
||||
|
||||
@@ -180,6 +180,7 @@ rtems_task Init(
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
|
||||
|
||||
/* more one more driver slot than are statically configured */
|
||||
#define CONFIGURE_MAXIMUM_DRIVERS 2
|
||||
|
||||
Reference in New Issue
Block a user