so, if isn't IDT, isn't GDT, what is my problem....chase wrote:The BIOS provides a real mode IDT. In PMode you have to provide everything such as an IDT and the interrupt handling code. But if you do a cli before you start PMode and don't do a sti then your current problem shouldn't be related to the IDT stuff.
kernel, when i pass a string, pc reboot [c++] *SOLVED*
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Well, disabling interrupts only disables external hardware interrupts. It won't prevent a triple fault caused by a processor-raised exception. If a handler were in place, it may be much easier to figure out what is happening. Of course, getting useful information out of the debugger is likely to require working video IO. I would still start with the IDT, even if there is a good indication that the current problem is elsewhere, because it is so useful for debugging problems like this.chase wrote:The BIOS provides a real mode IDT. In PMode you have to provide everything such as an IDT and the interrupt handling code. But if you do a cli before you start PMode and don't do a sti then your current problem shouldn't be related to the IDT stuff.
so....i should try what ??rexlunae wrote:Well, disabling interrupts only disables external hardware interrupts. It won't prevent a triple fault caused by a processor-raised exception. If a handler were in place, it may be much easier to figure out what is happening. Of course, getting useful information out of the debugger is likely to require working video IO. I would still start with the IDT, even if there is a good indication that the current problem is elsewhere, because it is so useful for debugging problems like this.chase wrote:The BIOS provides a real mode IDT. In PMode you have to provide everything such as an IDT and the interrupt handling code. But if you do a cli before you start PMode and don't do a sti then your current problem shouldn't be related to the IDT stuff.
debugging ?
i try debug with bochs, and with qemu + gdb...this is what i get :
<bochs> n
Next at t=19980401
(0) [0x0007e9c4] 0008:0007e9c4 (unk. ctxt): add byte ptr ds:[eax], al ; 0000
<bochs> n
Next at t=19980402
(0) [0x0007e9c6] 0008:0007e9c6 (unk. ctxt): add byte ptr ds:[eax], al ; 0000
<bochs> nn
bochs:657: syntax error at 'nn'
<bochs> c
Next at t=20048417
(0) [0x0009fd24] 0008:9fd24 (unk. ctxt): lock add eax, esi ; f001f0
<bochs>
mmm...boh
if you want to look the project http://www.upload2.net/page/download/zL ... s.zip.html
- chase
- Site Admin
- Posts: 710
- Joined: Wed Oct 20, 2004 10:46 pm
- Libera.chat IRC: chase_osdev
- Location: Texas
- Discord: chase/matt.heimer
- Contact:
Yes, you'll need to debug. Personally I don't debug with bochs or other virtual machines. My debugging method for this stage is to print data to the screen(which you can't do) and in the case of triple faults I see where the last place I can put I "jmp $" is without causing a reboot. Since the problem is in C/C++ code you might have to generate assembly, modify the assembly source code, assemble(with as) and then link everything together. I'd say that once you get PMode and basic printing to the screen working that you really want to add the IDT & debugging handler code. Maybe someone else can provide some better debugging techniques for virtual machines and C/C++ code.
i know where is the problem...but i don't know how resolve it...chase wrote:Yes, you'll need to debug. Personally I don't debug with bochs or other virtual machines. My debugging method for this stage is to print data to the screen(which you can't do) and in the case of triple faults I see where the last place I can put I "jmp $" is without causing a reboot. Since the problem is in C/C++ code you might have to generate assembly, modify the assembly source code, assemble(with as) and then link everything together. I'd say that once you get PMode and basic printing to the screen working that you really want to add the IDT & debugging handler code. Maybe someone else can provide some better debugging techniques for virtual machines and C/C++ code.
i can print to the video, but only one character...
how can i generate assembly by c++... ??
- chase
- Site Admin
- Posts: 710
- Joined: Wed Oct 20, 2004 10:46 pm
- Libera.chat IRC: chase_osdev
- Location: Texas
- Discord: chase/matt.heimer
- Contact:
Does the computer reboot when data is being pushed to the stack before the write call? Is it during the "call" instruction? The "ret" instruction? Is the compiler adding extra stuff that is causing the problem? I'd say the problem is in the code, if we knew where it was we would have fixed it by noworigin of wrote:i know where is the problem...
It still could be a GDT/segment descriptor problem, a compiler issue, a bug in your code, etc. Once you find the exact instruction that is causing the problem then you start to figure out why.origin of wrote: but i don't know how resolve it...
i can print to the video, but only one character...
By using the -S option that I keep talking about. Use all the options that you run when you compile but also add these.origin of wrote: how can i generate assembly by c++... ??
Code: Select all
g++ -S -masm=intel -finhibit-size-directive -fverbose-asm -o video..asm video.cpp
g++ -S -masm=intel -finhibit-size-directive -fverbose-asm -o kernel.asm kernel.cpp
thanks for the help, thanks to all....but....i find the solution...i don't understand because fix my problem, but fix my problem....can you give me an explanetion about how fix my problem ?
i change those files :
kernel.cpp
link.ld
OT : why, italian isn't the international language
i change those files :
kernel.cpp
Code: Select all
//Kernel.cpp
#include "video.h"
void __do_global_ctors (void);
int main(void)
{
__do_global_ctors ();
Video vid ; //local, (global variables need some Run-Time support code)
vid.write("ciao");
while(1);
}
void __do_global_ctors (void)
{
//la lista dei costruttori è definita nello scrpt di ld
extern void (*__CTOR_LIST__)();
void (**constructor)() = &__CTOR_LIST__;
//il primo intero è il numero di costruttori
int total = *(int *)constructor;
constructor++;
// eseguo i costruttori uno alla volta
while(total--)
{
(*constructor)();
constructor++;
}
}
Code: Select all
/* LINK.ld*/
OUTPUT_FORMAT("binary")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
. = 0x10000;
.text : { *(.text .stub .text.* .gnu.linkonce.t.*) }
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
. = DATA_SEGMENT_ALIGN(0x1000, 0x1000);
. = ALIGN(32 / 8);
.data :
{
/*costruttori del c++*/
__CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__ = .;
__DTOR_LIST__ = .; LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ = .;
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.ctors :
{
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.bss : {
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
_end = .;
PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
}
- chase
- Site Admin
- Posts: 710
- Joined: Wed Oct 20, 2004 10:46 pm
- Libera.chat IRC: chase_osdev
- Location: Texas
- Discord: chase/matt.heimer
- Contact:
So it is something the compiler is doing somewhere. From what I can tell it has some thing to do with global object contructors but I'm not a C++ expert. This is one of the reasons why most people just use assembly and C for OSDev.origin of wrote:thanks for the help, thanks to all....but....i find the solution...i don't understand because fix my problem, but fix my problem....can you give me an explanetion about how fix my problem ?
The only information I could find at all was http://groups.google.com/group/alt.os.d ... 76f75afbac
Because everyone knows english should be the international languageorigin of wrote: OT : why, italian isn't the international language
ok, thanks, thank you very much...BUT now i want to do this...
@rexlunae wrote:
THANKS TO ALL
bye
@rexlunae wrote:
i'll search in google, if i nedd some help...post another thread.....heheheYou would know if you had created an IDT. It isn't something the compiler is likely to do for you. I think the first step is to create one. There may still be other problems with your code, but not having an IDT will cause problems like this one. You should always have an IDT before interrupts are enable, otherwise, the first interrupt will cause a tripple fault and the computer will reboot. If you define an IDT, and put in a handler which can report unexpected exceptions, it may give you much better information to work from.
THANKS TO ALL
bye
the first place you should look for IDT information (which will greatly help solving problems like this), is in the intel manuals -- do you have them?
i'll search in google, if i nedd some help...post another thread.....hehehe
if not, check the link in my signature -- it links to the download, and from that page, you can get order information for ordering hard-copies (highly recommended)
everything you could ever want to know about the CPU is told in these books (particularly important is volume 3a -- chapter 5 talks about the IDT)
these books are completely free (including shipping) anywhere in the world, and are availible in other languages as well -- prob including italian
dont print them -- order the hard-copies, they are free, and it will be easier (and nicer) than printing -- and cheaper too since they are completely free (and if you print, it will take lots of paper and ink -- not free) including shipping (and get all 5 books they are all useful, though 3a is most important)
did you call the ordering number and ask if they had it in italian? because i know they have it in several other languages (but i havent found downloads other than english)
did you call the ordering number and ask if they had it in italian? because i know they have it in several other languages (but i havent found downloads other than english)