I am a os lover. But recently, I am not happy about it.
I think I faced a very weird problem that is my os kernel can run on the qemu, but it can't run on VMware.
It look like a PIC problem. Because if I turn off the all the PICs, then I found it can run on the VMware.
I guess it's problem may assicated with IDT_Gate_Descriptor. possibly, I set the incorrect IDT descriptor. So I copy the others funtions that can set IDT descriptor. But I found the problem still exist.
I use the I/O instruction to prohibit the others IRQs except the IRQ1 that is keyborad interruption in 8259A so that make you easyly find the problem localtion. the instruction is io_out8_ASM(PIC0_IMR, 0xfd ); /*(this instruction in pic.c) 0xfd = 11111101. all of PIC's interupt is prohibited except IRQ1. The PICO_IMR=0x21*/.
as long as you enter any character on my os running on VMware,It will breakdown.
Code: Select all
This is my idt.c that includes "set idt gate descriptor function" :
#include "../com/types.h"
#include "idt.h"
#include "handler_ASM.h"
#include "io_ASM.h"
void init_idt(){
IDT_Gate_Descriptor *idt=(IDT_Gate_Descriptor*)IDT_ADDR; // The IDT_ADDR = 0x00090000, Is this address invaild?
for (int i = 0; i <= IDT_LIMIT / 8; i++) {
set_idt_gatedesc(idt + i, 0, 0, 0);
}
load_idtr(IDT_LIMIT, IDT_ADDR);
set_idt_gatedesc(idt + 0x21, (int)_asm_inthandler21_keyboard, 8, AR_INTGATE32);
set_idt_gatedesc(idt + 0x20, (int)_asm_inthandler20_timer, 8, AR_INTGATE32);
}
void set_idt_gatedesc(IDT_Gate_Descriptor *gd, int offset, int selector, int ar) {
gd->offset_low = offset & 0xffff;
gd->selector = selector;
gd->dw_count = (ar >> 8) & 0xff;
gd->access_right = ar & 0xff;
gd->offset_high = (offset >> 16) & 0xffff;
return;
}
I use win10 64bit to compiler the os code. a month ago, I use the ubuntu 32bit to compile the os code. If I use ubuntu to compile code, the os can run on the VMware!!! very weird!!!
without compile, You can run my os with DolphinOS.img directly.
then, this is all of my os code in rar.