Page 2 of 2

Posted: Sun Jul 15, 2007 2:13 am
by davidv1992
here it is

Code: Select all

Allocating common symbols
Common symbol       size              file

IDTPtr              0x10              obj\IDT.o
IDTList             0x800             obj\IDT.o

Memory Configuration

Name             Origin             Length             Attributes
*default*        0x00000000         0xffffffff

Linker script and memory map

Address of section .text set to 0x1000
LOAD obj\kentry.ao
LOAD obj\BSOD.o
LOAD obj\IDT.o
LOAD obj\LIDT.o
LOAD obj\cexception.o
LOAD obj\dummy.o
LOAD obj\exception.o
LOAD obj\iflag.o
LOAD obj\kmain.o
LOAD obj\pic.o
LOAD obj\port.o
LOAD obj\string.o

.text           0x00001000      0xa00
 *(.text)
 .text          0x00001000       0x10 obj\kentry.ao
                0x00001000                kentry
 .text          0x00001010      0x150 obj\BSOD.o
                0x0000101d                BSOD
 .text          0x00001160       0xe0 obj\IDT.o
                0x000011d6                activate_IDT
                0x00001160                init_IDT
                0x000011ee                register_ISR
 .text          0x00001240       0x10 obj\LIDT.o
                0x00001240                LIDT
 .text          0x00001250      0x3b0 obj\cexception.o
                0x00001250                init_exception
                0x000015d4                exception
 .text          0x00001600        0x1 obj\dummy.o
 *fill*         0x00001601        0xf 00
 .text          0x00001610      0x240 obj\exception.o
 .text          0x00001850       0x10 obj\iflag.o
                0x00001856                STI
                0x00001850                CLI
 .text          0x00001860       0x50 obj\kmain.o
                0x00001860                kmain
 .text          0x000018b0       0xa0 obj\pic.o
                0x000018b0                remap_pics
 .text          0x00001950       0x40 obj\port.o
                0x00001950                in
                0x0000196e                out
 .text          0x00001990       0x20 obj\string.o
                0x00001990                strlen
 *(.text.*)
 *(.gnu.linkonce.t*)
 *(.const*)
 *(.ro*)
 *(.gnu.linkonce.r*)
                0x000019b0                etext = .
                0x000019b0                PROVIDE (_etext, .)
                0x00001a00                . = ALIGN (0x200)
 *fill*         0x000019b0       0x50 00

.data           0x00001a00      0x200
                0x00001a00                djgpp_first_ctor = .
 *(SORT(.ctors.*))
 *(.ctor)
 *(.ctors)
                0x00001a00                djgpp_last_ctor = .
                0x00001a00                djgpp_first_dtor = .
 *(SORT(.dtors.*))
 *(.dtor)
 *(.dtors)
                0x00001a00                djgpp_last_dtor = .
                0x00001a00                __environ = .
                0x00001a00                PROVIDE (_environ, .)
                0x00001a00        0x4 LONG 0x0
 *(.data)
 *fill*         0x00001a04        0xc 00
 .data          0x00001a10        0x0 obj\kentry.ao
 .data          0x00001a10       0x10 obj\BSOD.o
                0x00001a10                lineError
 .data          0x00001a20       0x10 obj\IDT.o
                0x00001a20                dummy
 .data          0x00001a30        0x0 obj\LIDT.o
 .data          0x00001a30       0x80 obj\cexception.o
                0x00001a30                messages
 .data          0x00001ab0        0x0 obj\iflag.o
 .data          0x00001ab0        0x0 obj\kmain.o
 .data          0x00001ab0        0x0 obj\pic.o
 .data          0x00001ab0        0x0 obj\port.o
 .data          0x00001ab0        0x0 obj\string.o
 *(.data.*)
 *(.gcc_exc*)
                0x00001ab0                ___EH_FRAME_BEGIN__ = .
 *(.eh_fram*)
                0x00001ab0                ___EH_FRAME_END__ = .
                0x00001ab0        0x4 LONG 0x0
 *(.gnu.linkonce.d*)
                0x00001ab4                edata = .
                0x00001ab4                PROVIDE (_edata, .)
                0x00001c00                . = ALIGN (0x200)
 *fill*         0x00001ab4      0x14c 00

.bss            0x00001c00      0xa00
 *(.bss .bss.* .gnu.linkonce.b.*)
 .bss           0x00001c00        0x0 obj\kentry.ao
 .bss           0x00001c00        0x0 obj\BSOD.o
 .bss           0x00001c00        0x0 obj\IDT.o
 .bss           0x00001c00        0x0 obj\LIDT.o
 .bss           0x00001c00        0x0 obj\cexception.o
 .bss           0x00001c00        0x0 obj\iflag.o
 .bss           0x00001c00        0x0 obj\kmain.o
 .bss           0x00001c00        0x0 obj\pic.o
 .bss           0x00001c00        0x0 obj\port.o
 .bss           0x00001c00        0x0 obj\string.o
 *(COMMON)
 COMMON         0x00001c00      0x810 obj\IDT.o
                0x00001c00                IDTPtr
                0x00001c10                IDTList
                0x00002410                end = .
                0x00002410                PROVIDE (_end, .)
                0x00002600                . = ALIGN (0x200)
 *fill*         0x00002410      0x1f0 00

.stab
 *(.stab)

.stabstr
 *(.stabstr)

.debug_aranges
 *(.debug_aranges)

.debug_pubnames
 *(.debug_pubnames)

.debug_info
 *(.debug_info)
 *(.gnu.linkonce.wi.*)

.debug_abbrev
 *(.debug_abbrev)

.debug_line
 *(.debug_line)

.debug_frame
 *(.debug_frame)

.debug_str
 *(.debug_str)

.debug_loc
 *(.debug_loc)

.debug_macinfo
 *(.debug_macinfo)
OUTPUT(kernel.o coff-go32-exe)

.comment        0x00002600       0xc8
 .comment       0x00002600       0x14 obj\kentry.ao
 .comment       0x00002614       0x14 obj\BSOD.o
 .comment       0x00002628       0x14 obj\IDT.o
 .comment       0x0000263c       0x14 obj\LIDT.o
 .comment       0x00002650       0x14 obj\cexception.o
 .comment       0x00002664       0x14 obj\iflag.o
 .comment       0x00002678       0x14 obj\kmain.o
 .comment       0x0000268c       0x14 obj\pic.o
 .comment       0x000026a0       0x14 obj\port.o
 .comment       0x000026b4       0x14 obj\string.o

Posted: Mon Jul 16, 2007 2:39 am
by JamesM
@frank:

Hmm, it seems djgpp is more forgiving about syntax in asm than gcc/g++ - I always get errors when I put two percent signs in front of a register when there are no inputs/outputs. It seems to want only one percent sign in that case.

To clarify (before you flame me ;) )

Code: Select all

asm volatile("mov $0x1, %%eax"); // DOESN'T normally work for me
asm volatile("mov $0x1, %eax"); // DOES normally work
asm volatile("mov %0, %%eax" :: "r"(tmp)); // DOES work.

Posted: Mon Jul 16, 2007 2:57 am
by davidv1992
well

dgjpp only want's to compile this

Code: Select all

__asm__ ("lidt %%eax" : : "a"(desc));
and for the linking process im still at a complete loss. Nasm just seems to not export any label.

Posted: Mon Jul 16, 2007 4:34 am
by os64dev
do you use 'SECTION .text' ? and did you try declaring the function without the underscore?

Posted: Mon Jul 16, 2007 6:08 am
by davidv1992
i've tried it both with and without the leading underscore in the assembly file. What do you mean with SECTION .text????

EDIT:

tried adding SECTION .text at the beginning of the file, and it worked. THNX so much.

Posted: Mon Jul 16, 2007 6:45 am
by frank
Wow I love it when it is something simple like that. About the % signs I was just guessing, I haven't used dgjpp in a couple of months.

Posted: Mon Jul 16, 2007 7:32 am
by os64dev
davidv1992 wrote:i've tried it both with and without the leading underscore in the assembly file. What do you mean with SECTION .text????

EDIT:

tried adding SECTION .text at the beginning of the file, and it worked. THNX so much.
welcome :wink:

Posted: Mon Jul 16, 2007 2:42 pm
by davidv1992
well bounced unfortunately into the next error i do not get (yet)

could somebody explain the following error description from BOCH to me?

Code: Select all

0026649892i[CPU0 ] >> idiv eax, ecx : F7F9
0026649892e[CPU0 ] Exception(): 3d exception with no resuolution shutdown

Posted: Mon Jul 16, 2007 8:08 pm
by frank
The idiv instruction can sometimes produce exceptions. Here is what the intel manual says about the division exception:
Indicates the divisor operand for a DIV or IDIV instruction is 0 or that the result
cannot be represented in the number of bits specified for the destination operand.
So for some reason the idiv instruction is causing the processor to issue and exception. But since you do not have a valid IDT loaded the processor issues a double fault. Well when the processor looks for the interrupt handler for the double fault it finds that finds that it is also missing. Upon encountering these three errors the processor would normally 'triple' fault and reboot. That is the 3rd exception thing you are reading about.

I would advise you to stay away from the idiv instruction until after you have a working IDT loaded.

Posted: Tue Jul 17, 2007 3:47 am
by pcmattman
I know it's late, but don't forget about

Code: Select all

.global <symbol> # AT&T
global <symbol> ; intel
Otherwise the linker can't find the symbols.

I agree with frank, get an IDT then you can divide all you want :D

Posted: Tue Jul 17, 2007 3:49 am
by davidv1992
well that idiv was there on purpose, it should even generate an exception, just as a test case for my IDT. seems i have some problems with that one.

after reexaminating the output bochs gives on the error, i met another line that could indicate the problem:

Code: Select all

interrupt(): gate descriptor is not a valid system seg

Posted: Tue Jul 17, 2007 3:30 pm
by pcmattman
Make sure that your GDT is setup properly and that the IDT entries are valid. Maybe you could print out all the entries as they get put into the IDT then loop forever afterwards, so you can see what's in it?

Posted: Tue Jul 17, 2007 11:35 pm
by davidv1992
okay, another closely related question

wat is the difference between a trap gate and an interrupt gate, and what is the use of the System segment bit?

Posted: Wed Jul 18, 2007 8:40 am
by frank
davidv1992 wrote:okay, another closely related question

wat is the difference between a trap gate and an interrupt gate, and what is the use of the System segment bit?
Interrupt gates disable interrupts, Trap gates do not.

Posted: Wed Jul 18, 2007 2:57 pm
by davidv1992
Okay i totaly have the idea i missed some crucial bit of information about my GDT.

This is its content

Code: Select all

gdt:                    ; Address for the GDT

gdt_null:               ; Null Segment
        dd 0
        dd 0

gdt_code:               ; Code segment, read/execute, nonconforming
        dw 0FFFFh
        dw 0
        db 0
        db 10011010b
        db 11001111b
        db 0

gdt_data:               ; Data segment, read/write, expand down
        dw 0FFFFh
        dw 0
        db 0
        db 10010010b
        db 11001111b
        db 0

gdt_end:                ; Used to calculate the size of the GDT
and this is how i fill my IDT

Code: Select all

	IDTList[INTCode].offset_1 = isrAddr & 0x0000FFFF;
	IDTList[INTCode].selector = 0x08;
	IDTList[INTCode].zero = 0;
	IDTList[INTCode].type_attr = 0x8E;
	IDTList[INTCode].offset_2 = (isrAddr >> 16) & 0x0000FFFF;
the GDT works when just doing some basic print code.