Page 1 of 1

Wierd and Strange problem with GRUB

Posted: Mon Jan 09, 2012 5:41 am
by ammubhave
Hi, I am facing an unusual problem with GRUB.
I have a kernel having about 20 files (.o) which are linked by ld.
If I include one or two more files then GRUB stops loading. The following is displayed and GRUB freezes.
When I remove any other file (any unimportant one), then the kernel boots fine but on adding more files, it freezes.
I tried one more thing. I first of all included all files and then commented some portion of code from a file. It booted. And then I included that code, and again it began to freeze. Same I did with other files also I noticed the same behaviour. So the problem, as I understand it, is the size of the overall code. But IT should not be a problem. Should it be? After it is GRUB and there are more massive kernels than mine. Mine is just 70,628 bytes i.e. about 69 KB.

This is the screen displayed when freezing:

Booting AmolOS...

root(cd)
Filesystem type is iso9660, using whole disk
kernel /kernel
[Multiboot-kludge, loadaddr=0x100000, text-and-data=0xe000, bss=0x10b0, symtab=0xb8, strtab=0xfffffffc(bad), entry=0x100020]

And yeah the strtab might not be a problem because mine is not a ELF kernel. I use AOUT kludge.

Please help ...

Re: Wierd and Strange problem with GRUB

Posted: Mon Jan 09, 2012 6:11 am
by raghuk
Are you testing using an emulator like Bochs? If not you should. That will give you more info about what goes wrong.

Re: Wierd and Strange problem with GRUB

Posted: Mon Jan 09, 2012 7:01 am
by ammubhave
Nopes, I am using VirtualBox, will give it a shot and get some debug info.

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 3:04 am
by ammubhave
Hi, I get the following dump from Bochs just before the GPF:

========================================================================
Bochs x86 Emulator 2.5.1
Built from SVN snapshot on January 6, 2012
Compiled on Jan 6 2012 at 21:28:14
========================================================================
00000000000i[ ] reading configuration from K:\Root\CppOs\VCOS\VCOS\bochsrc.b
xrc
00000000000i[ ] installing win32 module as the Bochs GUI
00000000000i[ ] Bochs x86 Emulator 2.5.1
00000000000i[ ] Built from SVN snapshot on January 6, 2012
00000000000i[ ] Compiled on Jan 6 2012 at 21:28:14
00000000000i[ ] System configuration
00000000000i[ ] processors: 1 (cores=1, HT threads=1)
00000000000i[ ] A20 line support: yes
00000000000i[ ] IPS is set to 4000000
00000000000i[ ] CPU configuration
00000000000i[ ] level: 6
00000000000i[ ] SMP support: no
00000000000i[ ] APIC support: xapic
00000000000i[ ] FPU support: yes
00000000000i[ ] MMX support: yes
00000000000i[ ] 3dnow! support: no
00000000000i[ ] SEP support: yes
00000000000i[ ] SSE support: sse2
00000000000i[ ] XSAVE support: no
00000000000i[ ] AES support: no
00000000000i[ ] MOVBE support: no
00000000000i[ ] x86-64 support: yes
00000000000i[ ] 1G paging support: no
00000000000i[ ] MWAIT support: yes
00000000000i[ ] Optimization configuration
00000000000i[ ] RepeatSpeedups support: yes
00000000000i[ ] Fast function calls: yes
00000000000i[ ] Handlers Chaining speedups: yes
00000000000i[ ] Devices configuration
00000000000i[ ] NE2000 support: yes
00000000000i[ ] PCI support: yes, enabled=yes
00000000000i[ ] SB16 support: yes
00000000000i[ ] USB support: yes
00000000000i[ ] VGA extension support: vbe cirrus
00000000000i[MEM0 ] allocated memory at 03230020. after alignment, vector=032310
00
00000000000i[MEM0 ] 32.00MB
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('C:\Program Files (x86)\Bochs-2.5.
1/BIOS-bochs-latest')
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Tue Jan 10 14:31:35 2012 (time0=13
26186095)
00000000000i[DMA ] channel 4 used by cascade
00000000000i[DMA ] channel 2 used by Floppy Drive
00000000000i[PCI ] 440FX Host bridge present at device 0, function 0
00000000000i[PCI ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
00000000000i[MEM0 ] Register memory access handlers: 0x00000000000a0000 - 0x0000
0000000bffff
00000000000i[WGUI ] Desktop Window dimensions: 1280 x 960
00000000000i[WGUI ] Number of Mouse Buttons = 3
00000000000i[WGUI ] IME disabled
00000000000i[VGA ] interval=200000
00000000000i[MEM0 ] Register memory access handlers: 0x00000000e0000000 - 0x0000
0000e0ffffff
00000000000i[BXVGA] VBE Bochs Display Extension Enabled
00000000000i[MEM0 ] rom at 0xc0000/41472 ('C:\Program Files (x86)\Bochs-2.5.1/VG
ABIOS-lgpl-latest')
00000000000i[ ] init_dev of 'acpi' plugin device by virtual method
00000000000i[PCI ] ACPI Controller present at device 1, function 3
00000000000i[ ] init_dev of 'unmapped' plugin device by virtual method
00000000000i[ ] init_dev of 'biosdev' plugin device by virtual method
00000000000i[ ] init_dev of 'speaker' plugin device by virtual method
00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[ ] init_dev of 'gameport' plugin device by virtual method
00000000000i[ ] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAP ] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0x00000000fec00000 - 0x0000
0000fec00fff
00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD ] CD on ata0-0: 'K:\Root\CppOs\VCOS\VCOS\amolos.iso'
00000000000i[CD1 ] load cdrom with path=K:\Root\CppOs\VCOS\VCOS\amolos.iso
00000000000i[CD1 ] Opening image file as a cd
00000000000i[HD ] Media present in CD-ROM drive
00000000000i[HD ] Capacity is 474 sectors (0.93 MB)
00000000000i[HD ] Using boot sequence cdrom, none, none
00000000000i[HD ] Floppy boot signature check is enabled
00000000000i[ ] init_dev of 'pci_ide' plugin device by virtual method
00000000000i[PCI ] PIIX3 PCI IDE controller present at device 1, function 1
00000000000i[ ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x03f8 irq 4
00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
00000000000i[ ] register state of 'acpi' plugin device by virtual method
00000000000i[ ] register state of 'unmapped' plugin device by virtual method

00000000000i[ ] register state of 'biosdev' plugin device by virtual method
00000000000i[ ] register state of 'speaker' plugin device by virtual method
00000000000i[ ] register state of 'extfpuirq' plugin device by virtual metho
d
00000000000i[ ] register state of 'gameport' plugin device by virtual method

00000000000i[ ] register state of 'ioapic' plugin device by virtual method
00000000000i[ ] register state of 'keyboard' plugin device by virtual method

00000000000i[ ] register state of 'harddrv' plugin device by virtual method
00000000000i[ ] register state of 'pci_ide' plugin device by virtual method
00000000000i[ ] register state of 'serial' plugin device by virtual method
00000000000i[ ] register state of 'parallel' plugin device by virtual method

00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
00000000000i[CPU0 ] CPUID[0x00000000]: 00000005 756e6547 6c65746e 49656e69
00000000000i[CPU0 ] CPUID[0x00000001]: 00000633 00010800 00002008 0fcbfbff
00000000000i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000005]: 00000040 00000040 00000003 00000020
00000000000i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000101 2a100000
00000000000i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00000000000i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00000000000i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00000000000i[CPU0 ] CPUID[0x80000005]: 01ff01ff 01ff01ff 40020140 40020140
00000000000i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00000000000i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
00000000000i[ ] reset of 'acpi' plugin device by virtual method
00000000000i[ ] reset of 'unmapped' plugin device by virtual method
00000000000i[ ] reset of 'biosdev' plugin device by virtual method
00000000000i[ ] reset of 'speaker' plugin device by virtual method
00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method
00000000000i[ ] reset of 'gameport' plugin device by virtual method
00000000000i[ ] reset of 'ioapic' plugin device by virtual method
00000000000i[ ] reset of 'keyboard' plugin device by virtual method
00000000000i[ ] reset of 'harddrv' plugin device by virtual method
00000000000i[ ] reset of 'pci_ide' plugin device by virtual method
00000000000i[ ] reset of 'serial' plugin device by virtual method
00000000000i[ ] reset of 'parallel' plugin device by virtual method
00000004849i[BIOS ] $Revision: 10789 $ $Date: 2011-11-24 17:03:51 +0100 (Do, 24.
Nov 2011) $
00000319056i[KBD ] reset-disable command received
00000321844i[BIOS ] Starting rombios32
00000322291i[BIOS ] Shutdown flag 0
00000322901i[BIOS ] ram_size=0x02000000
00000323336i[BIOS ] ram_end=32MB
00000364102i[BIOS ] Found 1 cpu(s)
00000380356i[BIOS ] bios_table_addr: 0x000fbde8 end=0x000fcc00
00000380439i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00000708139i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00000800002i[WGUI ] dimension update x=720 y=400 fontheight=16 fontwidth=9 bpp=8

00001036061i[P2I ] PCI IRQ routing: PIRQA# set to 0x0b
00001036089i[P2I ] PCI IRQ routing: PIRQB# set to 0x09
00001036110i[P2I ] PCI IRQ routing: PIRQC# set to 0x0b
00001036131i[P2I ] PCI IRQ routing: PIRQD# set to 0x09
00001036131i[P2I ] write: ELCR2 = 0x0a
00001036940i[BIOS ] PIIX3/PIIX4 init: elcr=00 0a
00001044647i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 cla
ss=0x0600
00001046962i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 cla
ss=0x0601
00001049116i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 cla
ss=0x0101
00001049322i[PIDE ] new BM-DMA address: 0xc000
00001049985i[BIOS ] region 4: 0x0000c000
00001052050i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 cla
ss=0x0680
00001052275i[ACPI ] new irq line = 11
00001052297i[ACPI ] new irq line = 9
00001052318i[ACPI ] new PM base address: 0xb000
00001052350i[ACPI ] new SM base address: 0xb100
00001052350i[PCI ] setting SMRAM control register to 0x4a
00001216470i[CPU0 ] Enter to System Management Mode
00001216474i[CPU0 ] RSM: Resuming from System Management Mode
00001380493i[PCI ] setting SMRAM control register to 0x0a
00001389257i[BIOS ] MP table addr=0x000fbec0 MPC table addr=0x000fbdf0 size=0xd0

00001391110i[BIOS ] SMBIOS table addr=0x000fbed0
00001393336i[BIOS ] ACPI tables: RSDP addr=0x000fbff0 ACPI DATA addr=0x01ff0000
size=0x988
00001396600i[BIOS ] Firmware waking vector 0x1ff00cc
00001397931i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001398690i[BIOS ] bios_table_cur_addr: 0x000fc014
00001526304i[VBIOS] VGABios $Id: vgabios.c,v 1.75 2011/10/15 14:07:21 vruppert E
xp $
00001526374i[BXVGA] VBE known Display Interface b0c0
00001526406i[BXVGA] VBE known Display Interface b0c5
00001529332i[VBIOS] VBE Bios $Id: vbe.c,v 1.64 2011/07/19 18:25:05 vruppert Exp
$
00005744630i[BIOS ] IDE time out
00017846951i[BIOS ] Booting from 07c0:0000
00018109111i[BIOS ] int13_harddisk: function 41, unmapped device for ELDL=80
00018113888i[BIOS ] int13_harddisk: function 08, unmapped device for ELDL=80
00018118541i[BIOS ] *** int 15h function AX=00c0, BX=0000 not yet supported!
00036495463i[CPU0 ] LOCK prefix unallowed (op1=0x53, modrm=0x00)
00036495463e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
06)
00036495463e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
0d)
00036495463e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
08)
00036495463i[CPU0 ] CPU is in protected mode (active)
00036495463i[CPU0 ] CS.mode = 32 bit
00036495463i[CPU0 ] SS.mode = 32 bit
00036495463i[CPU0 ] | EAX=2badb002 EBX=0010d09c ECX=00000001 EDX=00000001
00036495463i[CPU0 ] | ESP=00104050 EBP=00067ee0 ESI=00053bad EDI=00053bae
00036495463i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF AF PF CF
00036495463i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00036495463i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
00036495463i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00036495463i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00036495463i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00036495463i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00036495463i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00036495463i[CPU0 ] | EIP=00000003 (00000003)
00036495463i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
00036495463i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00036495463i[CPU0 ] 0x0000000000000003>> lock push ebx : F053
00036495463p[CPU0 ] >>PANIC<< exception(): 3rd (13) exception with no resolution

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 3:37 am
by Graham
Is the multiboot header within the first 8 kilobytes of the OS image? Maybe the linker is putting too much stuff before it when you add more code - Multiboot loaders only have to search the first 8k for it (see: http://www.gnu.org/software/grub/manual ... age-format).

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 4:21 am
by Solar
I'd like to see:
  • ...how you write the kernel binary to disk (e.g. relevant parts of your Makefile or whatever),
  • ...the output of mbchk run against your kernel binary (both the working and the non-working version),
  • ...the output of "ls -l" run against your kernel binary (both versions),
  • ...the output of "nm" run against your kernel binary, grepped for mboot (which you kindly made global via "global mboot" in your ASM file.)

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 4:42 am
by ammubhave
The problem with my code is I think that the some parts of my code aren't being linked properly or something like this. My present linker script is below:

Code: Select all

ENTRY(start)
SECTIONS
{
	. = 0x100000;

    .text ALIGN (0x1000) : 
    {
        code = .; _code = .; __code = .;
        *(.text)
		*(.gnu.linkonce.t*)
		. = ALIGN(4096);
    }
    .data ALIGN (4096) : 
    {
        data = .; _data = .; __data = .;
        *(.data)
					
		start_ctors = .;
        *(.ctor*)
        end_ctors = .;

        start_dtors = .;
        *(.dtor*)
        end_dtors = .;

        *(.rdata)
        *(.rodata*)
		*(.gnu.linkonce.r*)
		*(.gnu.linkonce.d*)
        . = ALIGN(4096);
dataend=.;
    }
    .bss ALIGN (4096) :
    {
        bss = .; _bss = .; __bss = .;
		*(.COMMON*)
        *(.bss)
		*(.gnu.linkonce.b*)
    }

    end = .; _end = .; __end = .;
}
Now, if I shift the content of the data section in the content of the text section, it works perfectly. But now when I keep it inside the data section, it doesnt work.
By boot.s file i.e. where multiboot spec is there is:

Code: Select all

[BITS 32]

section .text
; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
STACKSIZE equ 0x4000
mboot:
    ; Multiboot macros to make a few lines later more readable
	MULTIBOOT_PAGE_ALIGN   equ 1<<0
	MULTIBOOT_MEMORY_INFO  equ 1<<1
	MULTIBOOT_AOUT_KLUDGE  equ 1<<16
    MULTIBOOT_HEADER_MAGIC	equ 0x1BADB002
    MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO |  MULTIBOOT_AOUT_KLUDGE
	MULTIBOOT_CHECKSUM  equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

    EXTERN code, bss, end, dataend

    ; This is the GRUB Multiboot header. A boot signature
    dd MULTIBOOT_HEADER_MAGIC
    dd MULTIBOOT_HEADER_FLAGS
    dd MULTIBOOT_CHECKSUM
    
    ; AOUT kludge - must be physical addresses. Make a note of these:
    ; The linker script fills in the data for these ones!
   dd mboot ; these are PHYSICAL addresses
   dd code  ; start of kernel .text (code) section
   dd dataend	; end of kernel .data section
   dd end   ; end of kernel BSS
   dd start ; kernel entry point (initial EIP)


; This is an endless loop here. Make a note of this: Later on, we
; will insert an 'extern _main', followed by 'call _main', right
; before the 'jmp $'.
extern _main
extern start_ctors                      
extern end_ctors                        
extern start_dtors
extern end_dtors 
global start

start:
    mov  esp, stack + STACKSIZE         ; set up the stack
    mov  ebx, start_ctors               ; call the constructors
    jmp  .ctors_until_end
.call_constructor:
    call [ebx]
    add  ebx,4
.ctors_until_end:
    cmp  ebx, end_ctors
    jb   .call_constructor
	push esp
    call _main                          ; call kernel proper
 
    mov  ebx, end_dtors
    jmp  .hang
.call_destructor:
    sub  ebx, 4
    call [ebx]
.dtors_until_end:
    cmp  ebx, start_dtors
    jb   .call_destructor
 
    cli
.hang:
    hlt                                 ; halt machine should kernel return
    jmp  .hang

align 4
stack:
    resb STACKSIZE
Relevant part of my Makefile:

Code: Select all

CPPFLAGS=-nostdlib -nostdinc -fno-builtin -nostartfiles -fno-rtti -fno-exceptions -I include
LDFLAGS=-Tlink.ld
ASFLAGS=-f elf

OUT_DIR=\obj
OUT_OBJS=$(addprefix $(OUT_DIR)/,$(KSRC) $(KLIB) $(SOURCES))

all: $(KSRC) link

clean:
	del *.o kernel src\*.o

link:
	ld $(LDFLAGS) -o ..\ISO\kernel $(KSRC)

.s.o:
	nasm $(ASFLAGS) $<

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 5:09 am
by Combuster
It would be helpful if you actually answered the question (and use code tags, please)

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 5:36 am
by ammubhave
Here is the briefed output of nm:

Code: Select all

0010e000 B bss
00100000 T code
0010c000 D data
0010d3d4 D dataend
0010f0b0 A end
0010d034 D end_ctors
0010d034 D end_dtors
00100000 T mboot
00100020 T start
0010d000 D start_ctors
0010d034 D start_dtors
I build my code using:

Code: Select all

PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;E:\Program Files (x86)\nasm\;K:\MinGW\bin\
cd VCOS
mingw32-make %1
cd..
mkisofs.exe -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o amolos.iso ISO
I am on a Windows machine (no I don't intend to use linux) and use MinGW's gcc to compile.

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 6:55 am
by Solar
ammubhave wrote:Here is the briefed output of nm:
Is that the working, or the non-working binary?

And the output for the other binary looks like...?

What does mbchk have to say about your kernel binaries? (Uh, wait, I don't think there's a Windows version of that one...)

What does "ls -l" (in your case, "dir") have to say about your kernel binaries?
I am on a Windows machine (no I don't intend to use linux) and use MinGW's gcc to compile.
We usually recommend using Cygwin and building a cross-compiler (as it gives you a more able environment and rules out a couple of common problems, as well as making things more reproducable for Linux users), but I'm willing to let that subject rest for the time being.

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 7:34 am
by ammubhave
That one was for non working. Here is the one for

working binary (i.e. shifting the data sections' parts to text section)

Code: Select all

0010e000 B bss
00100000 T code
0010e000 T data
0010e000 T dataend
0010f0b0 A end
0010d034 T end_ctors
0010d034 T end_dtors
00100000 T mboot
00100020 T start
0010d000 T start_ctors
0010d034 T start_dtors
Here is the one where I have excluded one file and data sections is in its correct position:

Code: Select all

0010c000 B bss
00100000 T code
0010a000 D data
0010c000 D dataend
0010cdf0 A end
0010b030 D end_ctors
0010b030 D end_dtors
00100000 T mboot
00100020 T start
0010b000 D start_ctors
0010b030 D start_dtors
I only compile the whole code into single binary file: kernel
Here are the files included:

Code: Select all

KSRC=	boot\boot.o src\kernel_entry.o src\main.o src\common.o src\console.o  \
		src\ide.o src\string.o src\descriptor_tables.o src\gdt.o src\interrupt.o src\isr.o \
		src\pit.o src\mmu.o src\paging.o src\ordered_array.o src\graphics.o \
		src\process.o src\task.o src\rtc.o src\syscall.o src\bios_interrupt.o

Re: Wierd and Strange problem with GRUB

Posted: Tue Jan 10, 2012 9:08 am
by raghuk
ammubhave wrote: 00036495463i[CPU0 ] LOCK prefix unallowed (op1=0x53, modrm=0x00)
00036495463e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
06)
00036495463e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
0d)
00036495463e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
08)
How did you set up the IDT and interrupt handlers? Did you notice that your EIP is 0x00000003?

Re: Wierd and Strange problem with GRUB

Posted: Wed Jan 11, 2012 4:00 am
by AJ
Hi,

As stated above, you seem to be jumping to address 0x00000000. The real mode IVT which you are then executing is causing exceptions and you do not have an IDT correctly set up to handle them. Some points to check:
  • Running all those constructors in your assembly stub looks a bit suspect to me. Do you know exactly what code is being run when you do that?
  • Have you tried putting "cli", "hlt" at the top of your stub? If you do, is EIP where you would expect it to be when you halt Bochs?
  • If that's all OK, where do you have to move the "cli", "hlt" instructions to before everything goes wrong?
  • All that _main, __main, main business makes me think that the code for this has been copied straight out of a tutorial rather than tailored by you for your toolchain. Are you using the Cross-Compiler in the Wiki, or are you using DJGPP?
  • Does the name of the new file that you have just tried to add have a higher alphabetical precedence than "entry.o" or whatever your stub is called? If that's causing things to break, then something is flawed in the linker script and relies on your objects being linked in a specific order.
Cheers,
Adam