SMM: enter
EAX=00000001 EBX=07fe02d0 ECX=00000000 EDX=00000cfc
ESI=000f102d EDI=0003802d EBP=07fe01e0 ESP=00006ebc
EIP=000f2346 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000fcd30 00000037
IDT= 000fdb30 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=000f1000 CCD=00000001 CCO=LOGICB
EFER=0000000000000000
SMM: after RSM
EAX=00000001 EBX=07fe02d0 ECX=00000000 EDX=00000cfc
ESI=000f102d EDI=0003802d EBP=07fe01e0 ESP=00006ebc
EIP=000f2346 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000fcd30 00000037
IDT= 000fdb30 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
0: v=08 e=0000 i=0 cpl=0 IP=0008:00000000002001a0 pc=00000000002001a0 SP=0000:00000000001fffdc EAX=0000000000201000
EAX=00201000 EBX=0000001e ECX=00000000 EDX=00080206
ESI=000110c6 EDI=00210000 EBP=001ffff4 ESP=001fffdc
EIP=002001a0 EFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
SS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
DS =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
FS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
GS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 00001066 0000000f
IDT= 00001020 000007ff
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=00000004 CCD=00080206 CCO=EFLAGS
EFER=0000000000000000
check_exception old: 0xffffffff new 0xd
1: v=0d e=0042 i=0 cpl=0 IP=0008:00000000002001a0 pc=00000000002001a0 SP=0000:00000000001fffdc EAX=0000000000201000
EAX=00201000 EBX=0000001e ECX=00000000 EDX=00080206
ESI=000110c6 EDI=00210000 EBP=001ffff4 ESP=001fffdc
EIP=002001a0 EFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
SS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
DS =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
FS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
GS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 00001066 0000000f
IDT= 00001020 000007ff
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=00000004 CCD=00080206 CCO=EFLAGS
EFER=0000000000000000
check_exception old: 0xd new 0xb
2: v=08 e=0000 i=0 cpl=0 IP=0008:00000000002001a0 pc=00000000002001a0 SP=0000:00000000001fffdc EAX=0000000000201000
EAX=00201000 EBX=0000001e ECX=00000000 EDX=00080206
ESI=000110c6 EDI=00210000 EBP=001ffff4 ESP=001fffdc
EIP=002001a0 EFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
SS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
DS =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
FS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
GS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 00001066 0000000f
IDT= 00001020 000007ff
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=00000004 CCD=00080206 CCO=EFLAGS
EFER=0000000000000000
check_exception old: 0x8 new 0xd
kernel.c:
#define DESC 1
#define IT 0x000000//Адресс IDT
#define IR 0x000800
#define rm 0xB8000
#define SCS 0x8
#define IRQ_HANDLER(func) void func (void)\
{asm(#func ": pusha \n call _" #func " \n movb $0x20, %al \n outb %al, $0x20 \n popa \n iret \n");}\
void _ ## func(void)
//Устанавливает прервывание в IDT
struct desc_ptr {
short size;
short address;
} __attribute__((packed));
struct gate_desc {
unsigned int a;
unsigned int b;
} __attribute__((packed));
struct desc_ptr idt_descr;
struct gate_desc idt_table[256];
struct desc_ptr gdt_descr;
void initalize_idt_entry(int vector, void (*func)(void))
{
unsigned long addr = (unsigned long)func;
int high_address = addr & 0xFFFF0000;
int low_address = addr & 0x0000FFFF;
int DPL = 0;/*descriptor privilege level*/
int P = 1;/*selector present flag*/
int Selector = 1<<3;/*segment selector for destination code segment.*/
int D = 1;/*size of gate: 1=32bit; 0=16bit*/
int type=14;
idt_table[vector].b=high_address;
idt_table[vector].b|=P<<15;
idt_table[vector].b|=DPL<<13;
idt_table[vector].b|=D<<11;
idt_table[vector].b|=type<<8;
idt_table[vector].a=low_address;
idt_table[vector].a|=Selector<<16;
}
void load_idt(const struct desc_ptr *dtr)
{
asm volatile("lidt %0"::"m" (*dtr));
}
void initalize_interrupts()
{
initalize_idt();
idt_descr.size=(256*8)-1;
idt_descr.address=(unsigned int)idt_table;
load_idt(&idt_descr);
int_e();
}
// Разрешаем прерывания
void int_e()
{
asm("sti");
}
// Запрещаем прерывания
void int_d()
{
asm("cli");
}
#define RAM 0xB8000
void opw(unsigned short value,unsigned int port){
asm("outw %w0,%w1":: "a"(value), "d"(port));
}
void opb(unsigned char value,unsigned int port){
asm("outb %b0,%w1":: "a"(value), "d"(port));
}
int ipb(unsigned int port){
unsigned char value;
asm("inb %w1, %b0": "=a"(value): "d"(port));
return value;
}
void k_main(){
char *vid=RAM;
int key;initalize_interrupts();
for(;;){
}
}
//---------
extern void interrupt_wrapper_0(){}
extern void interrupt_wrapper_1(){}
extern void interrupt_wrapper_2(){}
extern void interrupt_wrapper_3(){}
extern void interrupt_wrapper_4(){}
extern void interrupt_wrapper_5(){}
extern void interrupt_wrapper_6(){}
extern void interrupt_wrapper_7(){}
extern void interrupt_wrapper_8(){}
extern void interrupt_wrapper_9(){}
extern void interrupt_wrapper_10(){}
extern void interrupt_wrapper_11(){}
extern void interrupt_wrapper_12(){}
extern void interrupt_wrapper_13(){}
extern void interrupt_wrapper_14(){}
extern void interrupt_wrapper_15(){}
extern void interrupt_wrapper_16(){}
extern void interrupt_wrapper_17(){}
extern void interrupt_wrapper_18(){}
extern void interrupt_wrapper_19(){}
extern void interrupt_wrapper_20(){}
void initalize_idt(){
initalize_idt_entry(0,interrupt_wrapper_0);
initalize_idt_entry(1,interrupt_wrapper_1);
initalize_idt_entry(2,interrupt_wrapper_2);
initalize_idt_entry(3,interrupt_wrapper_3);
initalize_idt_entry(4,interrupt_wrapper_4);
initalize_idt_entry(5,interrupt_wrapper_5);
initalize_idt_entry(6,interrupt_wrapper_6);
initalize_idt_entry(7,interrupt_wrapper_7);
initalize_idt_entry(8,interrupt_wrapper_8);
initalize_idt_entry(9,interrupt_wrapper_9);
initalize_idt_entry(10,interrupt_wrapper_10);
initalize_idt_entry(11,interrupt_wrapper_11);
initalize_idt_entry(12,interrupt_wrapper_12);
initalize_idt_entry(13,interrupt_wrapper_13);
initalize_idt_entry(14,interrupt_wrapper_14);
initalize_idt_entry(15,interrupt_wrapper_15);
initalize_idt_entry(16,interrupt_wrapper_16);
initalize_idt_entry(17,interrupt_wrapper_17);
initalize_idt_entry(18,interrupt_wrapper_18);
initalize_idt_entry(19,interrupt_wrapper_19);
initalize_idt_entry(20,interrupt_wrapper_20);
}
runs init_e()
then it crashed
Crash
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: Crash
May I direct you to the forum rules? (Specifically the section on asking smart questions)
At the risk of encouraging this behaviour... what happens is your code "Triple Faults" because you loaded a bad value into a segment register and didn't have a working IDT for it to use to handle the error. It's hard to know more with the code as it is.
At the risk of encouraging this behaviour... what happens is your code "Triple Faults" because you loaded a bad value into a segment register and didn't have a working IDT for it to use to handle the error. It's hard to know more with the code as it is.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc