1 /******************************************************************************/
2 /* src/kernel/TimerMng/TimerMngPit.c */
4 /* Copyright (C) 2016-2018 Mochi. */
5 /******************************************************************************/
6 /******************************************************************************/
8 /******************************************************************************/
12 #include <kernel/config.h>
13 #include <hardware/I8254/I8254.h>
14 #include <hardware/I8259A/I8259A.h>
15 #include <hardware/IA32/IA32Instruction.h>
25 #include "TimerMngCtrl.h"
28 /******************************************************************************/
30 /******************************************************************************/
32 #ifdef DEBUG_LOG_ENABLE
33 #define DEBUG_LOG( ... ) \
34 DebugLogOutput( CMN_MODULE_TIMERMNG_PIT, \
38 #define DEBUG_LOG( ... )
41 /** PIT(カウンタ0)カウンタ設定値 */
42 #define PIT_CYCLE ( I8254_CLOCK / MK_CONFIG_TICK_HZ )
45 /******************************************************************************/
47 /******************************************************************************/
48 /******************************************************************************/
51 * @details PITからの割込み処理を行う。
53 * @param[in] intNo 割込み番号
54 * @param[in] context 割込み発生時コンテキスト情報(未使用)
56 /******************************************************************************/
57 void TimerMngPitHdlInt( uint32_t intNo,
58 IntMngContext_t context )
61 DEBUG_LOG( "%s() start. intNo=%#x", __func__, intNo );*/
64 IntMngPicEoi( I8259A_IRQ0 );
73 DEBUG_LOG( "%s() end.", __func__ );*/
79 /******************************************************************************/
82 * @details PIT管理サブモジュールの初期化を行う。
84 /******************************************************************************/
85 void TimerMngPitInit( void )
88 DEBUG_LOG( "%s() start.", __func__ );
91 IA32InstructionOutByte( I8254_PORT_CTRLW,
92 ( I8254_CTRLW_SC_CNTR0 |
95 I8254_CTRLW_BCD_BIN ) );
96 IA32InstructionOutByte( I8254_PORT_CNTR0, I8254_CNTR_LOW( PIT_CYCLE ) );
97 IA32InstructionOutByte( I8254_PORT_CNTR0, I8254_CNTR_HIGH( PIT_CYCLE ) );
100 IntMngHdlSet( INTMNG_PIC_VCTR_BASE + I8259A_IRQ0, /* 割込み番号 */
101 TimerMngPitHdlInt, /* 割込みハンドラ */
102 IA32_DESCRIPTOR_DPL_0 ); /* 特権レベル */
105 IntMngPicAllowIrq( I8259A_IRQ0 );
108 DEBUG_LOG( "%s() end.", __func__ );
114 /******************************************************************************/