* Makefile.am, configure.ac, preinstall.am, s3c2400/include/s3c2400.h:
	Add CPU type s3c2410. Add a new s3c24xx common file shared between
	s3c2400 and s3c2410. Most content is moved from s3c2400 now. Some
	were changed to include <s3c24xx.h> instead of <s3c2400.h>.
	* s3c2410/include/s3c2410.h, s3c2410/irq/bsp_irq_asm.S,
	s3c2410/irq/irq.h, s3c24xx/clock/clockdrv.c, s3c24xx/clock/support.c,
	s3c24xx/include/s3c24xx.h, s3c24xx/irq/bsp_irq_init.c,
	s3c24xx/irq/irq.c, s3c24xx/irq/irq.h, s3c24xx/timer/timer.c: New files.
This commit is contained in:
Joel Sherrill
2008-05-06 20:58:05 +00:00
parent 0542a23b3f
commit dbdb025548
15 changed files with 1618 additions and 3 deletions
+11
View File
@@ -1,3 +1,14 @@
2008-05-06 Ray Xu <rayx.cn@gmail.com>
* Makefile.am, configure.ac, preinstall.am, s3c2400/include/s3c2400.h:
Add CPU type s3c2410. Add a new s3c24xx common file shared between
s3c2400 and s3c2410. Most content is moved from s3c2400 now. Some
were changed to include <s3c24xx.h> instead of <s3c2400.h>.
* s3c2410/include/s3c2410.h, s3c2410/irq/bsp_irq_asm.S,
s3c2410/irq/irq.h, s3c24xx/clock/clockdrv.c, s3c24xx/clock/support.c,
s3c24xx/include/s3c24xx.h, s3c24xx/irq/bsp_irq_init.c,
s3c24xx/irq/irq.c, s3c24xx/irq/irq.h, s3c24xx/timer/timer.c: New files.
2007-12-11 Joel Sherrill <joel.sherrill@OARcorp.com>
* at91rm9200/clock/clock.c, lpc22xx/clock/clockdrv.c,
+28 -2
View File
@@ -90,7 +90,7 @@ mc9328mxl_irq_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
endif
if s3c2400
include_HEADERS = s3c2400/include/s3c2400.h
include_HEADERS = s3c24xx/include/s3c24xx.h s3c2400/include/s3c2400.h
## s3c2400/clock
noinst_PROGRAMS += s3c2400/clock.rel
@@ -108,13 +108,39 @@ s3c2400_timer_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
include_HEADERS += s3c2400/irq/irq.h
noinst_PROGRAMS += s3c2400/irq.rel
s3c2400_irq_rel_SOURCES = s3c2400/irq/irq.c s3c2400/irq/bsp_irq_init.c \
s3c2400_irq_rel_SOURCES = s3c24xx/irq/irq.c s3c24xx/irq/bsp_irq_init.c \
../../libbsp/arm/shared/irq/irq_init.c s3c2400/irq/bsp_irq_asm.S \
../../libbsp/arm/shared/irq/irq_asm.S s3c2400/irq/irq.h
s3c2400_irq_rel_CPPFLAGS = $(AM_CPPFLAGS)
s3c2400_irq_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
endif
if s3c2410
include_HEADERS = s3c24xx/include/s3c24xx.h s3c2410/include/s3c2410.h
## s3c2410/clock
noinst_PROGRAMS += s3c2410/clock.rel
s3c2410_clock_rel_SOURCES = s3c24xx/clock/clockdrv.c s3c24xx/clock/support.c
s3c2410_clock_rel_CPPFLAGS = $(AM_CPPFLAGS)
s3c2410_clock_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
## s3c2410/timer
noinst_PROGRAMS += s3c2410/timer.rel
s3c2410_timer_rel_SOURCES = s3c24xx/timer/timer.c
s3c2410_timer_rel_CPPFLAGS = $(AM_CPPFLAGS)
s3c2410_timer_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
## s3c2410/interrupt
include_HEADERS += s3c2410/irq/irq.h
noinst_PROGRAMS += s3c2410/irq.rel
s3c2410_irq_rel_SOURCES = s3c24xx/irq/irq.c s3c24xx/irq/bsp_irq_init.c \
../../libbsp/arm/shared/irq/irq_init.c s3c2410/irq/bsp_irq_asm.S \
../../libbsp/arm/shared/irq/irq_asm.S s3c2410/irq/irq.h
s3c2410_irq_rel_CPPFLAGS = $(AM_CPPFLAGS)
s3c2410_irq_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
endif
if lpc22xx
include_HEADERS = lpc22xx/include/lpc22xx.h
+2
View File
@@ -23,10 +23,12 @@ RTEMS_PROG_CCAS
AM_CONDITIONAL(shared, test "$RTEMS_CPU_MODEL" = "at91rm9200" || \
test "$RTEMS_CPU_MODEL" = "mc9328mxl" || \
test "$RTEMS_CPU_MODEL" = "s3c2410" || \
test "$RTEMS_CPU_MODEL" = "s3c2400")
AM_CONDITIONAL(at91rm9200, test "$RTEMS_CPU_MODEL" = "at91rm9200")
AM_CONDITIONAL(mc9328mxl, test "$RTEMS_CPU_MODEL" = "mc9328mxl")
AM_CONDITIONAL(s3c2400, test "$RTEMS_CPU_MODEL" = "s3c2400")
AM_CONDITIONAL(s3c2410, test "$RTEMS_CPU_MODEL" = "s3c2410")
AM_CONDITIONAL(lpc22xx, test "$RTEMS_CPU_MODEL" = "lpc22xx")
RTEMS_AMPOLISH3
+17
View File
@@ -71,6 +71,10 @@ $(PROJECT_INCLUDE)/irq.h: mc9328mxl/irq/irq.h $(PROJECT_INCLUDE)/$(dirstamp)
PREINSTALL_FILES += $(PROJECT_INCLUDE)/irq.h
endif
if s3c2400
$(PROJECT_INCLUDE)/s3c24xx.h: s3c24xx/include/s3c24xx.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/s3c24xx.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/s3c24xx.h
$(PROJECT_INCLUDE)/s3c2400.h: s3c2400/include/s3c2400.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/s3c2400.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/s3c2400.h
@@ -79,6 +83,19 @@ $(PROJECT_INCLUDE)/irq.h: s3c2400/irq/irq.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/irq.h
endif
if s3c2410
$(PROJECT_INCLUDE)/s3c24xx.h: s3c24xx/include/s3c24xx.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/s3c24xx.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/s3c24xx.h
$(PROJECT_INCLUDE)/s3c2410.h: s3c2410/include/s3c2410.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/s3c2410.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/s3c2410.h
$(PROJECT_INCLUDE)/irq.h: s3c2410/irq/irq.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/irq.h
endif
if lpc22xx
$(PROJECT_INCLUDE)/lpc22xx.h: lpc22xx/include/lpc22xx.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/lpc22xx.h
@@ -427,6 +427,7 @@
}
/* Wait until rINTPND is changed for the case that the ISR is very short. */
#ifndef __asm__
/* Typedefs */
typedef union {
struct _reg {
@@ -653,7 +654,7 @@ typedef union {
} reg;
unsigned long all;
} IISSFIF;
#endif //__asm__
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,40 @@
/* bsp_irq_asm.S
*
* This file contains the implementation of the IRQ handler
* for a specific BSP
*
* CopyRight (C) 2000 Canon Research France SA.
* Emmanuel Raguet, mailto:raguet@crf.canon.fr
*
* The license and distribution terms for this file may be
* found in found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#define __asm__
/*
* Function to obtain, execute an IT handler and acknowledge the IT
*/
.globl ExecuteITHandler
ExecuteITHandler :
ldr r0, =0x4A000014 /* Read rINTOFFSET */
ldr r1, [r0]
ldr r0, =bsp_vector_table
ldr r0, [r0, r1, LSL #2] /* Read the address */
stmdb sp!,{lr}
ldr lr, =IRQ_return /* prepare the return from handler */
mov pc, r0
IRQ_return:
ldmia sp!,{lr}
mov pc, lr
+202
View File
@@ -0,0 +1,202 @@
/* irq.h
*
* This include file describe the data structure and the functions implemented
* by rtems to write interrupt handlers.
*
* Copyright (c) 2000 Canon Research Centre France SA.
* Emmanuel Raguet, mailto:raguet@crf.canon.fr
*
* The license and distribution terms for this file may be
* found in found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#ifndef _IRQ_H_
#define _IRQ_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* Include some preprocessor value also used by assember code
*/
#include <rtems.h>
#include <s3c2410.h>
extern void default_int_handler();
/*-------------------------------------------------------------------------+
| Constants
+--------------------------------------------------------------------------*/
/* possible interrupt sources */
#define BSP_EINT0 0
#define BSP_EINT1 1
#define BSP_EINT2 2
#define BSP_EINT3 3
#define BSP_EINT4_7 4
#define BSP_EINT8_23 5
#define BSP_nBATT_FLT 7
#define BSP_INT_TICK 8
#define BSP_INT_WDT 9
#define BSP_INT_TIMER0 10
#define BSP_INT_TIMER1 11
#define BSP_INT_TIMER2 12
#define BSP_INT_TIMER3 13
#define BSP_INT_TIMER4 14
#define BSP_INT_UART2 15
#define BSP_INT_LCD 16
#define BSP_INT_DMA0 17
#define BSP_INT_DMA1 18
#define BSP_INT_DMA2 19
#define BSP_INT_DMA3 20
#define BSP_INT_SDI 21
#define BSP_INT_SPI0 22
#define BSP_INT_UART1 23
#define BSP_INT_USBD 25
#define BSP_INT_USBH 26
#define BSP_INT_IIC 27
#define BSP_INT_UART0 28
#define BSP_INT_SPI1 29
#define BSP_INT_RTC 30
#define BSP_INT_ADC 31
#define BSP_MAX_INT 32
extern void *bsp_vector_table;
#define VECTOR_TABLE &bsp_vector_table
/*
* Type definition for RTEMS managed interrupts
*/
typedef unsigned char rtems_irq_level;
typedef unsigned char rtems_irq_trigger;
struct __rtems_irq_connect_data__; /* forward declaratiuon */
typedef unsigned int rtems_irq_number;
typedef void (*rtems_irq_hdl) (void);
typedef void (*rtems_irq_enable) (const struct __rtems_irq_connect_data__*);
typedef void (*rtems_irq_disable) (const struct __rtems_irq_connect_data__*);
typedef int (*rtems_irq_is_enabled) (const struct __rtems_irq_connect_data__*);
typedef struct __rtems_irq_connect_data__ {
/*
* IRQ line
*/
rtems_irq_number name;
/*
* handler. See comment on handler properties below in function prototype.
*/
rtems_irq_hdl hdl;
/*
* function for enabling interrupts at device level (ONLY!).
* The BSP code will automatically enable it at i8259s level.
* RATIONALE : anyway such code has to exist in current driver code.
* It is usually called immediately AFTER connecting the interrupt handler.
* RTEMS may well need such a function when restoring normal interrupt
* processing after a debug session.
*
*/
rtems_irq_enable on;
/*
* function for disabling interrupts at device level (ONLY!).
* The code will disable it at i8259s level. RATIONALE : anyway
* such code has to exist for clean shutdown. It is usually called
* BEFORE disconnecting the interrupt. RTEMS may well need such
* a function when disabling normal interrupt processing for
* a debug session. May well be a NOP function.
*/
rtems_irq_disable off;
/*
* function enabling to know what interrupt may currently occur
* if someone manipulates the i8259s interrupt mask without care...
*/
rtems_irq_is_enabled isOn;
/*
* priority level at the vplus level
*/
rtems_irq_level irqLevel;
/*
* Trigger way : Rising or falling edge or High or low level
*/
rtems_irq_trigger irqTrigger;
} rtems_irq_connect_data;
/*-------------------------------------------------------------------------+
| Function Prototypes.
+--------------------------------------------------------------------------*/
/*
* ------------------ RTEMS Single Irq Handler Mngt Routines ----------------
*/
/*
* function to initialize the interrupt for a specific BSP
*/
void BSP_rtems_irq_mngt_init();
/*
* function to connect a particular irq handler. This hanlder will NOT be called
* directly as the result of the corresponding interrupt. Instead, a RTEMS
* irq prologue will be called that will :
*
* 1) save the C scratch registers,
* 2) switch to a interrupt stack if the interrupt is not nested,
* 3) store the current i8259s' interrupt masks
* 4) modify them to disable the current interrupt at 8259 level (and may
* be others depending on software priorities)
* 5) aknowledge the i8259s',
* 6) demask the processor,
* 7) call the application handler
*
* As a result the hdl function provided
*
* a) can perfectly be written is C,
* b) may also well directly call the part of the RTEMS API that can be used
* from interrupt level,
* c) It only responsible for handling the jobs that need to be done at
* the device level including (aknowledging/re-enabling the interrupt at device,
* level, getting the data,...)
*
* When returning from the function, the following will be performed by
* the RTEMS irq epilogue :
*
* 1) masks the interrupts again,
* 2) restore the original i8259s' interrupt masks
* 3) switch back on the orinal stack if needed,
* 4) perform rescheduling when necessary,
* 5) restore the C scratch registers...
* 6) restore initial execution flow
*
*/
int BSP_install_rtems_irq_handler (const rtems_irq_connect_data*);
/*
* function to get the current RTEMS irq handler for ptr->name. It enables to
* define hanlder chain...
*/
int BSP_get_current_rtems_irq_handler (rtems_irq_connect_data* ptr);
/*
* function to get disconnect the RTEMS irq handler for ptr->name.
* This function checks that the value given is the current one for safety reason.
* The user can use the previous function to get it.
*/
int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data*);
#ifdef __cplusplus
}
#endif
#endif /* _IRQ_H_ */
/* end of include file */
@@ -0,0 +1,137 @@
/*
* S3C2400 clock specific using the System Timer
*
* This is hardware specific part of the clock driver. At the end of this
* file, the generic part of the driver is #included.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE.
*
*
* $Id$
*/
#include <rtems.h>
#include <irq.h>
#include <bsp.h>
#include <s3c24xx.h>
/* this is defined in ../../../shared/clockdrv_shell.c */
rtems_isr Clock_isr(rtems_vector_number vector);
static void clock_isr_on(const rtems_irq_connect_data *unused);
static void clock_isr_off(const rtems_irq_connect_data *unused);
static int clock_isr_is_on(const rtems_irq_connect_data *irq);
/* Replace the first value with the clock's interrupt name. */
rtems_irq_connect_data clock_isr_data = {BSP_INT_TIMER4,
(rtems_irq_hdl)Clock_isr,
clock_isr_on,
clock_isr_off,
clock_isr_is_on,
3, /* unused for ARM cpus */
0 }; /* unused for ARM cpus */
/* If you follow the code, this is never used, so any value
* should work
*/
#define CLOCK_VECTOR 0
/**
* When we get the clock interrupt
* - clear the interrupt bit?
* - restart the timer?
*/
#define Clock_driver_support_at_tick() \
do { \
ClearPending(BIT_TIMER4); \
} while(0)
/**
* Installs the clock ISR. You shouldn't need to change this.
*/
#define Clock_driver_support_install_isr( _new, _old ) \
do { \
_old = NULL; \
BSP_install_rtems_irq_handler(&clock_isr_data); \
} while(0)
/**
* Initialize the hardware for the clock
* - Set the frequency
* - enable it
* - clear any pending interrupts
*
* Since you may want the clock always running, you can
* enable interrupts here. If you do so, the clock_isr_on(),
* clock_isr_off(), and clock_isr_is_on() functions can be
* NOPs.
*/
#define Clock_driver_support_initialize_hardware() \
do { \
uint32_t cr; \
uint32_t freq,m,p,s; \
/* set MUX for Timer4 to 1/16 */ \
cr=rTCFG1 & 0xFFF0FFFF; \
rTCFG1=(cr | (3<<16)); \
freq = get_PCLK(); \
/* set TIMER4 counter, input freq=PLCK/16/16Mhz*/ \
freq = (freq /16)/16; \
rTCNTB4 = ((freq / 1000) * BSP_Configuration.microseconds_per_tick) / 1000; \
/*unmask TIMER4 irq*/ \
rINTMSK&=~BIT_TIMER4; \
/* start TIMER4 with autoreload */ \
cr=rTCON & 0xFF8FFFFF; \
rTCON=(cr|(0x6<<20)); \
rTCON=(cr|(0x5<<20)); \
} while (0)
/**
* Do whatever you need to shut the clock down and remove the
* interrupt handler. Since this normally only gets called on
* RTEMS shutdown, you may not need to do anything other than
* remove the ISR.
*/
#define Clock_driver_support_shutdown_hardware() \
do { \
/* Disable timer */ \
BSP_remove_rtems_irq_handler(&clock_isr_data); \
} while (0)
/**
* Enables clock interrupt.
*
* If the interrupt is always on, this can be a NOP.
*/
static void clock_isr_on(const rtems_irq_connect_data *unused)
{
return;
}
/**
* Disables clock interrupts
*
* If the interrupt is always on, this can be a NOP.
*/
static void clock_isr_off(const rtems_irq_connect_data *unused)
{
return;
}
/**
* Tests to see if clock interrupt is enabled, and returns 1 if so.
* If interrupt is not enabled, returns 0.
*
* If the interrupt is always on, this always returns 1.
*/
static int clock_isr_is_on(const rtems_irq_connect_data *irq)
{
return 1;
}
/* Make sure to include this, and only at the end of the file */
#include "../../../../libbsp/shared/clockdrv_shell.c"
@@ -0,0 +1,57 @@
#include <rtems.h>
#include <bsp.h>
#include <s3c24xx.h>
/* ------------------------------------------------------------------------- */
/* NOTE: This describes the proper use of this file.
*
* BSP_OSC_FREQ should be defined as the input frequency of the PLL.
*
* get_FCLK(), get_HCLK(), get_PCLK() and get_UCLK() return the clock of
* the specified bus in HZ.
*/
/* ------------------------------------------------------------------------- */
/* return FCLK frequency */
uint32_t get_FCLK(void)
{
uint32_t r, m, p, s;
r = rMPLLCON;
m = ((r & 0xFF000) >> 12) + 8;
p = ((r & 0x003F0) >> 4) + 2;
s = r & 0x3;
return((BSP_OSC_FREQ * m) / (p << s));
}
/* return UCLK frequency */
uint32_t get_UCLK(void)
{
uint32_t r, m, p, s;
r = rUPLLCON;
m = ((r & 0xFF000) >> 12) + 8;
p = ((r & 0x003F0) >> 4) + 2;
s = r & 0x3;
return((BSP_OSC_FREQ * m) / (p << s));
}
/* return HCLK frequency */
uint32_t get_HCLK(void)
{
if (rCLKDIVN & 0x2)
return get_FCLK()/2;
else
return get_FCLK();
}
/* return PCLK frequency */
uint32_t get_PCLK(void)
{
if (rCLKDIVN & 0x1)
return get_HCLK()/2;
else
return get_HCLK();
}
@@ -0,0 +1,17 @@
/************************************************
* NAME : s3c2400.h
* Version : 4.18.2008
*
* share code for different Samsung CPU
************************************************/
#ifndef S3C24XX_H_
#define S3C24XX_H_
#ifdef CPU_S3C2400
#include<s3c2400.h>
#elif defined CPU_S3C2410
#include<s3c2410.h>
#endif
#endif /*S3C24XX_H_*/
@@ -0,0 +1,37 @@
/* irq_init.c
*
* This file contains the implementation of rtems initialization
* related to interrupt handling.
*
* CopyRight (C) 2000 Canon Research Centre France SA.
* Emmanuel Raguet, mailto:raguet@crf.canon.fr
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#include <irq.h>
#include <bsp.h>
#include <s3c24xx.h>
extern void default_int_handler();
void BSP_rtems_irq_mngt_init()
{
long *vectorTable;
int i;
vectorTable = (long *) VECTOR_TABLE;
/* Initialize the vector table contents with default handler */
for (i=0; i<BSP_MAX_INT; i++) {
*(vectorTable + i) = (long)(default_int_handler);
}
/*
* Here is the code to initialize the INT for
* the specified BSP
*/
}
+110
View File
@@ -0,0 +1,110 @@
/* irq.c
*
* This file contains the implementation of the function described in irq.h
*
* CopyRight (C) 2000 Canon Research France SA.
* Emmanuel Raguet, mailto:raguet@crf.canon.fr
*
* The license and distribution terms for this file may be
* found in found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#include <bsp.h>
#include <irq.h>
#include <rtems/score/thread.h>
#include <rtems/score/apiext.h>
#include <s3c24xx.h>
/*
* This function check that the value given for the irq line
* is valid.
*/
static int isValidInterrupt(int irq)
{
if ( (irq < 0) || (irq > BSP_MAX_INT)) {
return 0;
}
return 1;
}
/*
* ------------------- RTEMS Single Irq Handler Mngt Routines ----------------
*/
int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq)
{
rtems_irq_hdl *HdlTable;
rtems_interrupt_level level;
if (!isValidInterrupt(irq->name)) {
return 0;
}
/*
* Check if default handler is actually connected. If not issue an error.
*/
HdlTable = (rtems_irq_hdl *)VECTOR_TABLE;
if (*(HdlTable + irq->name) != default_int_handler) {
return 0;
}
_CPU_ISR_Disable(level);
/*
* store the new handler
*/
*(HdlTable + irq->name) = irq->hdl;
/*
* Enable interrupt on device
*/
if(irq->on)
{
irq->on(irq);
}
_CPU_ISR_Enable(level);
return 1;
}
int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq)
{
rtems_irq_hdl *HdlTable;
rtems_interrupt_level level;
if (!isValidInterrupt(irq->name)) {
return 0;
}
/*
* Check if the handler is actually connected. If not issue an error.
*/
HdlTable = (rtems_irq_hdl *)VECTOR_TABLE;
if (*(HdlTable + irq->name) != irq->hdl) {
return 0;
}
_CPU_ISR_Disable(level);
/*
* Disable interrupt on device
*/
if(irq->off) {
irq->off(irq);
}
/*
* restore the default irq value
*/
*(HdlTable + irq->name) = default_int_handler;
_CPU_ISR_Enable(level);
return 1;
}
+16
View File
@@ -0,0 +1,16 @@
/* irq.h
*
* Note: This file will not be compiled, it just a place holder by now
*/
#ifndef _IRQ_H_
#define _IRQ_H_
// This file is a place holder
// The real irq.h preinstalled is s3c2410/irq/irq.h and s3c2410/irq/irq.h
// change/refer to this files
// TODO: clean irq.h in ARM BSP. there is lots of duplicated codes in cpu_name/irq/irq.h with cpukit/include/rtems/irq.h
//
#endif /* _IRQ_H_ */
/* end of include file */
+120
View File
@@ -0,0 +1,120 @@
/*
* S3C2400 Timer driver
*
* This uses timer 1 for timing measurments.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE.
*
* Notes:
* This file manages the benchmark timer used by the RTEMS Timing Test
* Suite. Each measured time period is demarcated by calls to
* Timer_initialize() and Read_timer(). Read_timer() usually returns
* the number of microseconds since Timer_initialize() exitted.
*
* It is important that the timer start/stop overhead be determined
* when porting or modifying this code.
*
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <s3c24xx.h>
uint32_t g_start;
uint32_t g_freq;
rtems_boolean Timer_driver_Find_average_overhead;
/*
* Set up Timer 1
*/
void Timer_initialize( void )
{
uint32_t cr;
/* stop TIMER1*/
cr=rTCON & 0xFFFFF0FF;
rTCON=(cr | (0x0 << 8));
/* set MUX for Timer1 to 1/2 */
cr=rTCFG1 & 0xFFFFFF0F;
rTCFG1=(cr | (0<<4));
/* input freq=PLCK/2 Mhz*/
g_freq = get_PCLK() / 2000;
rTCNTB1 = 0xFFFF;
/* start TIMER1 with manual reload */
cr=rTCON & 0xFFFFF0FF;
rTCON=(cr | (0x1 << 9));
rTCON=(cr | (0x1 << 8));
g_start = rTCNTO1;
}
/*
* The following controls the behavior of Read_timer().
*
* AVG_OVEREHAD is the overhead for starting and stopping the timer. It
* is usually deducted from the number returned.
*
* LEAST_VALID is the lowest number this routine should trust. Numbers
* below this are "noise" and zero is returned.
*/
#define AVG_OVERHEAD 0 /* It typically takes X.X microseconds */
/* (Y countdowns) to start/stop the timer. */
/* This value is in microseconds. */
#define LEAST_VALID 1 /* Don't trust a clicks value lower than this */
int Read_timer( void )
{
uint32_t t;
unsigned long long total;
t = rTCNTO1;
/*
* Total is calculated by taking into account the number of timer overflow
* interrupts since the timer was initialized and clicks since the last
* interrupts.
*/
total = (g_start - t);
/* convert to microseconds */
total = (total*1000) / g_freq;
if ( Timer_driver_Find_average_overhead == 1 ) {
return (int) total;
} else if ( total < LEAST_VALID ) {
return 0;
}
/*
* Somehow convert total into microseconds
*/
return (total - AVG_OVERHEAD);
}
/*
* Empty function call used in loops to measure basic cost of looping
* in Timing Test Suite.
*/
rtems_status_code Empty_function( void )
{
return RTEMS_SUCCESSFUL;
}
void Set_find_average_overhead(
rtems_boolean find_flag
)
{
Timer_driver_Find_average_overhead = find_flag;
}