Page 1 of 2
need some help with my screen of death
Posted: Tue Jun 26, 2007 3:01 am
by Pyrofan1
my screen of death is invoked by exceptions
my regs struct
Code: Select all
struct regs
{
unsigned int gs, fs, es, ds; /* pushed the segs last */
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
unsigned int int_no, err; /* our 'push byte #' and ecodes do this */
unsigned int eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
};
my isr_common
Code: Select all
.type isr_common,@function
isr_common:
pusha
push %ds
push %es
push %fs
push %gs
call RSOD
sti
iret
RSOD
Code: Select all
void RSOD(struct regs r)
{
text_color(WHITE,RED);
clrscr();
Puts("ChaoS has encounted a problem\n");
if(r.int_no<19)
{
Printf("%s, interrupt %d, error %d\n",messages[r.int_no],r.int_no,r.err);
}
Puts("Registers:\n");
Printf("eax: %d ebx: %d ecx: %d\n",r.eax,r.ebx,r.ecx);
Printf("edx: %d esi: %d edi: %d\n",r.edx,r.esi,r.edi);
Printf("ebp: %d esp: %d gs: %d\n",r.ebp,r.esp,r.gs);
Printf("fs: %d es: %d ds: %d\n\n",r.fs,r.es,r.ds);
Printf("EFLAGS: %d\neip: %d\ncs: %d\n",r.eflags,r.eip,r.cs);
Printf("ss: %d\n",r.ss);
asm("hlt");
}
this prints the contents of the rodata section of my executable.
Posted: Tue Jun 26, 2007 3:26 am
by Bughunter
Why do a 'sti' and 'iret' after 'call RSOD', it won't ever return.
As for the rest of your post, what exactly is your question? Where do you want help?
Posted: Tue Jun 26, 2007 3:34 am
by Pyrofan1
Why do a 'sti' and 'iret' after 'call RSOD', it won't ever return.
that was just left over code
Where do you want help?
well i'd like it to do what it's suppose to do instead of doing this
this prints the contents of the rodata section of my executable.
Posted: Tue Jun 26, 2007 3:41 am
by os64dev
well in your assembly you don't push the the struct r parameter of the c function. so that would be pointing anywhere producing the garbage you discribe.
insert a push %esp before the call. if this doesn't work then your c function should be void RSOD(struct regs * r)
Posted: Tue Jun 26, 2007 3:45 am
by AJ
I would also suggest that for debugging it would be a lot more useful to have hex numbers rather than decimal - it will tend to flag up bits that should be set but aren't in e.g. the EFLAGS register.
Cheers,
Adam
Posted: Tue Jun 26, 2007 4:14 am
by Pyrofan1
insert a push %esp before the call. if this doesn't work then your c function should be void RSOD(struct regs * r)
nope, didn't work
useful to have hex numbers
i know that
Posted: Tue Jun 26, 2007 6:54 am
by t0xic
@Pyrofan1
Try and use:
I found the same problem you did when regs wasn't a pointer
--t0xic
Posted: Tue Jun 26, 2007 6:59 am
by Pyrofan1
nope
Posted: Tue Jun 26, 2007 7:10 am
by AJ
It should work if you are correctly passing the pointer. Could we see your source files, please? Also, is the value of ESP in Bochs what you would expect?
Just one thought - if an exception has occurred, you should think about loading your segment registers with known "good values" in case they are scrapped.
Cheers,
Adam
Posted: Tue Jun 26, 2007 7:11 am
by t0xic
Here's my common stub... my gsod works perfectly so try this:
Try using an indirect push of esp, and load the segments like AJ said
Notice the following:
Code: Select all
_isrcommonstub:
pusha
push ds
push es
push fs
push gs
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp
push eax
mov eax, _fault_handler
call eax
pop eax
pop gs
pop fs
pop es
pop ds
popa
add esp, 8
iret
--t0xic
Posted: Tue Jun 26, 2007 7:18 am
by Pyrofan1
Also, is the value of ESP in Bochs what you would expect?
I don't use bochs or qemu. also i'm not triggering any exceptions (purposfully)
RSOD
Code: Select all
void RSOD(struct regs *r)
{
text_color(WHITE,RED);
clrscr();
Puts("ChaoS has encounted a problem\n");
if(r->int_no<19)
{
Printf("%s, interrupt %d, error %d\n",messages[r->int_no],r->int_no,r->err);
}
else
{
Printf("Reserved, interrupt %d, error %d\n",r->int_no,r->err);
}
Puts("Registers:\n");
Printf("eax: %x ebx: %x ecx: %x\n",r->eax,r->ebx,r->ecx);
Printf("edx: %x esi: %x edi: %x\n",r->edx,r->esi,r->edi);
Printf("ebp: %x esp: %x gs: %x\n",r->ebp,r->esp,r->gs);
Printf("fs: %x es: %x ds: %x\n",r->fs,r->es,r->ds);
Printf("EFLAGS: %x\neip: %x\ncs: %x\n",r->eflags,r->eip,r->cs);
Printf("ss: %x\n",r->ss);
asm("hlt");
}
Posted: Tue Jun 26, 2007 7:38 am
by AJ
Pyrofan1 wrote:
I don't use bochs or qemu.
Please do. It will make debugging this much easier.
I can't see any glaringly obvious mistakes in your code, although the syntax is not one I'm familiar with - I assume it's AT&T.
You might still try to put known good segments in to the segment registers. Out of interest, if you aren't causing any exceptions, how do you know that your exception handlers aren't working
Cheers,
Adam
Posted: Tue Jun 26, 2007 7:45 am
by Pyrofan1
Please do. It will make debugging this much easier.
I tried to, but qemu wouldn't run it
You might still try to put known good segments in to the segment registers.
i tried that, didn't work
Out of interest, if you aren't causing any exceptions, how do you know that your exception handlers aren't working
because when i boot, i get a red screen
Posted: Tue Jun 26, 2007 8:16 am
by os64dev
so it could be your Puts that fails in case of an exeption handler. or do you see white text also.
edit: hmm you told this already. can we see the linker script?
Posted: Tue Jun 26, 2007 8:18 am
by Pyrofan1
I do see white text.