summaryrefslogtreecommitdiffstats
path: root/pmint.c
diff options
context:
space:
mode:
authorlantw44 <lantw44@gmail.com>2013-01-21 02:16:51 +0800
committerlantw44 <lantw44@gmail.com>2013-01-21 02:16:51 +0800
commite80b7d7b9ceabc86154715d3332aebce3a60f1fe (patch)
tree5d15230e2594494a797b9c2da6d560a26d6d219d /pmint.c
parent21f4b645319848112fd62b0bb5019d98f8e4a741 (diff)
downloadyotos-e80b7d7b9ceabc86154715d3332aebce3a60f1fe.tar
yotos-e80b7d7b9ceabc86154715d3332aebce3a60f1fe.tar.gz
yotos-e80b7d7b9ceabc86154715d3332aebce3a60f1fe.tar.bz2
yotos-e80b7d7b9ceabc86154715d3332aebce3a60f1fe.tar.lz
yotos-e80b7d7b9ceabc86154715d3332aebce3a60f1fe.tar.xz
yotos-e80b7d7b9ceabc86154715d3332aebce3a60f1fe.tar.zst
yotos-e80b7d7b9ceabc86154715d3332aebce3a60f1fe.zip
加入尚未完成的保護模式切換功能
Diffstat (limited to 'pmint.c')
-rw-r--r--pmint.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/pmint.c b/pmint.c
new file mode 100644
index 0000000..752cec1
--- /dev/null
+++ b/pmint.c
@@ -0,0 +1,46 @@
+#include <yotk32.h>
+
+typedef struct registers
+{
+ long ds;
+ long edi, esi, ebp, esp, ebx, edx, ecx, eax;
+ long int_no, err_code;
+ long eip, cs, eflags, useresp, ss;
+} registers_t;
+
+
+void int_isr_handler(registers_t regs){
+ chv_putchar(regs.int_no);
+ chv_sync_cursor();
+}
+
+void timer_sleep_msg(void){
+ static int count = 0;
+ count++;
+ if(count % 100 == 0){
+ putstr("...");
+ putint(count / 100);
+ chv_sync_cursor();
+ }
+}
+
+void int_irq_handler(registers_t regs){
+ asm(".intel_syntax noprefix\n");
+
+ if(regs.int_no > 31 + 8){ /* Send reset signal to slave PIC (PIC2) */
+ asm volatile(
+ "mov dx, 0xA0\n"
+ "mov al, 0x20\n"
+ "out dx, al");
+ }
+
+ /* Send reset signal to master PIC (PIC1) */
+ asm volatile(
+ "mov dx, 0x20\n"
+ "mov al, 0x20\n"
+ "out dx, al");
+
+ if(regs.int_no == 32){ /* IRQ0 == Timer */
+ timer_sleep_msg();
+ }
+}