OS compiles fine but wont run

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Jimferd

OS compiles fine but wont run

Post by Jimferd »

Hello there fellow OS Developers. I have recently revamped my desire to work on my os, and went back to coding some of the basics. But I'm having a particularly awful time getting it working! At the bottom of this post I link to my kernel, if anyone would like to take a look at it and try to guess what i did wrong. Here is the error at hand:
Everything compiles great, seems to be working fine. I use
the makeos.bat in the zip posted below. It compiles, assembles, links, and cats without problem. Then I rawwrite it to a floppy, which also goes fine. I boot it in my other box, and no dice whatsoever. Anyone who can help has my greatfulness forever.
If you need more information, email me:
[email protected]

ossrc: http://asbestos.freeservers.com/asbestos.zip
(the file is also attached to the post)

[attachment deleted by admin]
Slasher

Re:OS compiles fine but wont run

Post by Slasher »

Hi,
in your linker script you have
.text 0x10000
but in your boot.asm file you are jumping to
jmp CODESEL:0x100000
you are jumping to an address with 5 ZEROs in stead of 4.
also add
*(.common*) to the .data section of your linker script.
hope that helps
Jimferd

Re:OS compiles fine but wont run

Post by Jimferd »

nope - it now spits out a load of gibberish to the second half of the first line and the first half of the second line of the screen. I changed the 10000 in link.ld to 100000 and added under .data the *(.common*) thing. we're getting closer - i know it. Thanks again, Jimferd.
Slasher

Re:OS compiles fine but wont run

Post by Slasher »

hi,
the problem it seems(i think) is in the c code i.e kernel.bin
I just used it in my own os as the kernel and also got about 3 lines of gibberish. You need to look at you printing function. I'm examinging it...
I think you should change in stdio.c
i=(line*25*2);
to
i=(line*160); /* 80x25 so a line is 160bytes long*/
also try replacing '\n' with 0x0a, sometimes '\n' is not recognised properly. happened to me.
Jimferd

Re:OS compiles fine but wont run

Post by Jimferd »

ergg still gibberish!
also, change '\n' to '0x0a' or just 0x0a ? I changed it to just 0x0a .
Jimferd
thanks a lot
not working still tho :-[
Slasher

Re:OS compiles fine but wont run

Post by Slasher »

Okay,
in your boot code try removing
sti ; re-enable interrupts for BIOS fdd read
its not needed.
also
mov ax,0xffff
mov es,ax ; Data buffer for file
mov bx,0x10 ; Start of segment
is not a good idea. Bochs returns
[FDD ] read() on floppy image returns 0
continuously.
That eb:bx combo ends up as 0x10000 (1mb). I don't think bios can handle addresses above 1mb even though you have enabled the A20 line.
Try reading the kernel to memory below 1mb (also linking in to that address) until you are sure the kernel is bug free(affter dev) then you can copy it to memory above 1mb.
Slasher

Re:OS compiles fine but wont run

Post by Slasher »

just looked over the boot code again and
you are reading 17 sectors from track 0 in the first read,
and then 18 sectors from track 0 in the second read
Don't you mean, read 18 sectors from track 1 in the second read?
mov ax,0xffff
mov es,ax ; Data buffer for file
mov bx,0x10 ; Start of segment
mov ah,2 ; Function to read disk
mov al,17 ; Total sectors to read
mov ch,0 ; Track <---------------------this is what i mean
mov cl,2 ; Sector
mov dh,0 ; Head | Drive is already loaded
int 0x13 ; Call BIOS read disk function
jc read

mov ax,0xffff
mov es,ax
mov bx, 0x2210
mov ah,2 ; Function to read disk
mov al,18 ; Total sectors to read
mov ch,0 ; Track <-------------------here is the other one
mov cl,1 ; Sector
mov dh,1 ; Head | Drive is already loaded
int 0x13 ; Call BIOS read disk function
Jimferd

Re:OS compiles fine but wont run

Post by Jimferd »

I changed all of the aforementioned, (loading os at 0x1000) but not the thing just boots, reboots, boots, reboots, etc.
Ergg
Thanks for your help!
:'(
bkilgore

Re:OS compiles fine but wont run

Post by bkilgore »

why don't you try running it with bochs? It might give you a better idea of what's going on. A regular computer will just reset if there is a big enough problem, and bochs will crash too, but it will give you more information why.
Peter_Vigren

Re:OS compiles fine but wont run

Post by Peter_Vigren »

Code: Select all

; -[move GDT to 0x500]- ;
xor ax,ax
mov ds,ax
mov es,ax
mov si,GDT                    ; Move From [DS:SI]
mov di,[GDTbase]              ; Move to [ES:DI]
mov cx,[GDTsize]              ; size of GDT
cld                           ; Clear the Direction Flag
rep movsb                     ; Move it
Maybe it is better that you push Cs and pop it into Ds instead... but I dunno... The reset may come from a triple fault... and that can be because the CODESEL is wrong...
bkilgore

Re:OS compiles fine but wont run

Post by bkilgore »

Code: Select all

; -[move GDT to 0x500]- ;
xor ax,ax
mov ds,ax
mov es,ax
why are you moving 0 into the ds and es segment selectors? isn't segment 0 the null segment and reserved? could this be causing problems?
Peter_Vigren

Re:OS compiles fine but wont run

Post by Peter_Vigren »

bkilgore wrote:

Code: Select all

; -[move GDT to 0x500]- ;
xor ax,ax
mov ds,ax
mov es,ax
why are you moving 0 into the ds and es segment selectors? isn't segment 0 the null segment and reserved? could this be causing problems?
The null selector (the first segment selector descriptor in the GDT) is reserved in protected mode only. In real mode, it behaves as a normal segment... 16 bytes wide etc...
bkilgore

Re:OS compiles fine but wont run

Post by bkilgore »

ah, right. I keep forgetting there is a world beyond protected mode...
Peter_Vigren

Re:OS compiles fine but wont run

Post by Peter_Vigren »

bkilgore wrote: ah, right. I keep forgetting there is a world beyond protected mode...
Hehe... Well, it's rather _before_ protected mode... :)
beyond infinity lazy

Re:OS compiles fine but wont run

Post by beyond infinity lazy »

Ha! fine word games these are *g*

ere long everyone will go hither and tither spreading word about peters stress on 'BEFORE p_mode' :P

but doesnt fit beyond in both directions? In german there is no real aequivalent for this word. Maybe "jenseits" fits best for it but with this odd feeling that it doesn't really express what one means...

and no, don't prick my butt with bits, i'm just in a queer mood.
Post Reply