This repository was archived by the owner on Jan 14, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,5 +5,7 @@ void _write(const char *string);
55int printk (const char * string , ...);
66void clear_screen ();
77void new_line ();
8+ void cpu_halt ();
9+ void timer_handler (uint32_t payload , void * ctx );
810
911#endif /* _IO_H */
Original file line number Diff line number Diff line change @@ -147,6 +147,8 @@ static void kbd_process(uint32_t sc_payload, void *ctx) {
147147 buffer_put (out );
148148 // 画面には表示しない(シェルが表示する)
149149 } else {
150+ // 未知のスキャンコードは無視(ログ出力しない)
151+ // 特定のキー(PgUp、PgDnなど)が必要な場合はここで処理
150152 /*
151153 if (sc == 0x49) { // PGUP
152154 console_scroll_page_up();
@@ -157,8 +159,6 @@ static void kbd_process(uint32_t sc_payload, void *ctx) {
157159 return;
158160 }
159161 */
160-
161- printk ("[0x%x]" , (unsigned )sc );
162162 }
163163}
164164
Original file line number Diff line number Diff line change 66#include <interrupt/idt.h>
77#include <util/shell.h>
88#include <util/shell_integration.h>
9+ #include <util/io.h>
910#include <mem/map.h>
1011#include <mem/manager.h>
1112#include <mem/segment.h>
1617void kloop ();
1718static int shell_started = 0 ;
1819
20+
1921/**
2022 * @fn kmain
2123 * @brief LiteCoreのメイン関数(kernel_entryより)
@@ -40,11 +42,18 @@ void kmain() {
4042 idt_init ();
4143 interrupt_init ();
4244 printk ("ok\n" );
45+
46+ // タイマー割り込み(IRQ 0)を登録
47+ interrupt_register (0 , timer_handler , NULL );
4348
4449 new_line ();
4550 printk ("> DEVICE INIT\n" );
4651 keyboard_init ();
4752 printk ("ok\n" );
53+
54+ // 割り込みを有効化
55+ __asm__ volatile ("sti" );
56+ printk ("> Interrupts enabled\n" );
4857
4958#ifdef TEST_TRUE
5059 new_line ();
@@ -68,19 +77,38 @@ void kmain() {
6877 * @brief kmainの処理が終了した後常に動き続ける処理
6978 */
7079void kloop () {
80+ int activity = 0 ; // このループで何か処理したかフラグ
81+
7182 /* ポーリングによるフォールバック: キーボードのscancodeを回収 */
7283 keyboard_poll ();
84+
7385 /* FIFOに入ったイベントを処理 */
74- interrupt_dispatch_all ();
86+ int event_count = 0 ;
87+ while (interrupt_dispatch_one ()) {
88+ activity = 1 ;
89+ event_count ++ ;
90+ }
7591
92+ /* シェルが開始されていない場合は、キー入力待ち */
7693 if (!shell_started ) {
7794 char c = keyboard_getchar_poll ();
7895 if (c != 0 ) {
96+ /* 何かキーが押されたらシェルを開始 */
7997 shell_started = 1 ;
8098 printk ("\n" );
8199 init_full_shell ();
100+ activity = 1 ;
82101 }
83102 } else {
84- shell_readline_and_execute ();
103+ /* シェル実行中 */
104+ int processed = shell_readline_and_execute ();
105+ if (processed != 0 ) {
106+ activity = 1 ;
107+ }
108+ }
109+
110+ /* 何も処理しなかった場合はCPUを休止(次の割り込みまで) */
111+ if (!activity ) {
112+ cpu_halt ();
85113 }
86114}
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ static int cmd_ver(int argc, char **argv) {
5858 (void )argv ;
5959
6060 printk ("LiteCore Operating System\n" );
61- printk ("Version: 0.1.0 (Development) \n" );
61+ printk ("Version: %s \n" , VERSION );
6262 printk ("Build: %s %s\n" , __DATE__ , __TIME__ );
6363
6464 return 0 ;
Original file line number Diff line number Diff line change 11#include <config.h>
2+ #include <util/io.h>
23
34/**
45 * @fn _write
@@ -27,4 +28,22 @@ void clear_screen() {
2728 * video ++ = ' ' ; // スペース
2829 * video ++ = attr ; // 色属性の書き込み
2930 }
31+ }
32+
33+
34+ /**
35+ * @brief CPUを休止状態にする(次の割り込みまで)
36+ */
37+ void cpu_halt (void ) {
38+ // STI命令で割り込みを有効にしてからHLT
39+ __asm__ volatile ("sti; hlt" );
40+ }
41+
42+ /**
43+ * @brief タイマー割り込みハンドラ(IRQ 0)
44+ * システムタイマーの割り込みを静かに処理(何もしないサボり関数)
45+ */
46+ void timer_handler (uint32_t payload , void * ctx ) {
47+ (void )payload ;
48+ (void )ctx ;
3049}
You can’t perform that action at this time.
0 commit comments