1 /******************************************************************************/
2 /* src/kernel/ProcMng/ProcMngTss.c */
4 /* Copyright (C) 2017 Mochi. */
5 /******************************************************************************/
6 /******************************************************************************/
8 /******************************************************************************/
12 #include <hardware/IA32/IA32.h>
13 #include <hardware/IA32/IA32Descriptor.h>
14 #include <hardware/IA32/IA32Instruction.h>
15 #include <hardware/IA32/IA32Tss.h>
25 /******************************************************************************/
27 /******************************************************************************/
29 #ifdef DEBUG_LOG_ENABLE
30 #define DEBUG_LOG( ... ) \
31 DebugLogOutput( CMN_MODULE_PROCMNG_TSS, \
35 #define DEBUG_LOG( ... )
39 /******************************************************************************/
41 /******************************************************************************/
43 static IA32Tss_t gTss;
46 /******************************************************************************/
48 /******************************************************************************/
49 /******************************************************************************/
52 * @details TSS管理サブモジュールの初期化を行う。
54 /******************************************************************************/
55 void ProcMngTssInit( void )
57 uint16_t index; /* GDTエントリ番号 */
58 uint16_t selector; /* セグメントセレクタ */
61 DEBUG_LOG( "%s() start.", __func__ );
64 memset( &gTss, 0, sizeof ( IA32Tss_t ) );
69 sizeof ( IA32Tss_t ) - 1, /* セグメントサイズ */
70 IA32_DESCRIPTOR_G_BYTE, /* リミット粒度 */
71 IA32_DESCRIPTOR_S_SYSTEM, /* システムフラグ */
72 IA32_DESCRIPTOR_TYPE_TSS32, /* セグメントタイプ */
73 IA32_DESCRIPTOR_DPL_0, /* セグメント特権レベル */
74 IA32_DESCRIPTOR_DB_UNUSED ); /* オペレーションサイズ */
77 selector = IA32_SEGMENT_SELECTOR( index, /* インデックス */
79 IA32_RPL_0 ); /* RPL */
82 IA32InstructionLtr( selector );
85 DEBUG_LOG( "%s() end.", __func__ );
91 /******************************************************************************/
94 * @details TSSのESP0フィールドを設定する。
96 * @param[in] esp0 ESP0設定値
98 /******************************************************************************/
99 void ProcMngTssSetEsp0( uint32_t esp0 )
108 /******************************************************************************/