Bugs on bootloader

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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bugs on bootloader

Post by Pype.Clicker »

* A20: the code looks correct.
* LoadSectors: i can envision a problem if 'jc .error' is taken: since you don't reset AX to a value, you'll be actually re-using the "error status" that comes out of INT13 as command in the next iteration. beware!

Can you be more precise than "it doesn't work" like
- it at least goes until step XXX because i see NN dots on screen
- if XXX had worked, i should see YYY but it doesn't.

If possible, run your code in Bochs, with debug enabled and show us what BOCHS tells you ...
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

Hmm. Maybe i don't understand something.
I changed the source to this

Code: Select all

<...>
SectorLoader:
   mov ah, 0x02
   mov al, 0x02
   mov ch, 0x00
   mov cl, 0x02
   mov dh, 0x00
   mov dl, [bootDrive]
   
   mov bx, 60000
   mov es, bx
   mov bx, 00000
   
   jmp .readsector
.error
   mov si, msgErrorSector
   call Print
.readsector
   int 13h
   jc .error

   mov si, msgDot
   call Print
.end
   ret
<...>
msgInit db "Initializing",0
msgDot db ".",0
msgErrorSector db "Can't read sector",0
bootDrive db 0
<...>
But When it writes me initializing, it restarts my pc.
How to enable debuging mode in bochs, because im new to it?
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

I found how to run bochs with debug(bochsdbg.exe).
It writes me that:
Next at t=0
(0) context not implemented because BX_HAVE_HASH_MAP=0
[0x000ffff0] f000:fff0 (unk. ctxt): jmp f000:e05b ; ea5be000f0
<bochs:1>
pkd

Re:Bugs on bootloader

Post by pkd »

One thing that may be causing problems is the null GDT entry


gdt_null:
dd 0

should be change to

gdt_null:
dd 0
dd 0

each entry must be eight bytes

hope this helps
pkd
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

It still restarts me the PC when i try it on Real PC. Bochs too restarts and runs again that. :(
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

Now is fixed some problems and it doesn't restart my PC. It writes now just "Initializing." with one dot. That means that A20 is enabled, I think. So maybe there is a problem with SectorLoader. But if there would be a problem, it would write an error that is programmed to do if it can't load sectors. It doesn't write that error. So I think that the bug is earlier than that the .error . My kernel.bin that is in second sector size is 784 bytes. Maybe there is a problem that it loads too much sectors. Please help me with these problems.
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

BTW: I uploaded my bootloader source to the internet - http://avnet.sytes.net/~vladas/boot.asm .
I think it would be needed fixing that problem.
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

Yes, I found one bug, and now it writes me "Can't read sector".
I uploaded new source.
Bad that it still doesn't work good. Do someone knows a bug here?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Bugs on bootloader

Post by Brendan »

Hi,
Vladaz wrote: Yes, I found one bug, and now it writes me "Can't read sector".
I uploaded new source.
Bad that it still doesn't work good. Do someone knows a bug here?
Comments are good! For example:

Code: Select all

   mov ah, 0x02   ;ah = function 0x02, read sectors
   mov al, 0x14   ;al = number of sectors to read
   mov ch, 0x00   ;ch = cylinder (low 8 bits)
   mov cl, 0x02   ;cl = starting sector number
   mov dh, 0x00   ;dh = head number
Now, how many sectors do you have per track? A standard 1440 Kb floppy has 18, but you're trying to read from sector 2 to sector 21...

BTW it is possible to have 21 sectors per track (a 1680 Kb floppy), but it's not standard or as reliable..

Also you should try it 3 times before giving an error - from Ralph Brown's Interrupt List:

"errors on a floppy may be due to the motor failing to spin up quickly enough; the read should be retried at least three times, resetting the disk with AH=00h between attempts"


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

When it was mov al, 0x14 it flooded me with "Can't read sector" messages. When i changes to mov al, 0x08 it didn't wrote me that messege, but it restarted when second dot appeared. I am using a standard 1440 Kb floppy, my kernel size is 784 bytes if this info is needed. I am using now Bochs. Now I think that it maybe can't load PMode or something.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Bugs on bootloader

Post by Brendan »

Hi,

I took another look - this code:

Code: Select all

gdt_desc:
   db gdt_end - gdt
   dw gdt
.should be replaced with:

Code: Select all

gdt_desc:
   dw gdt_end - gdt
   dd gdt
Apart from that it worked properly for me using Bochs, although I did comment out the final "jmp 60000" because I didn't have a kernel.

Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

I have replaced these lines. If i comment jmp 60000 then it doesn't restarts. I've put the code that would work in PMode. That code must write "a" to the screen, but it won't do that.
The Bootloader source - http://avnet.sytes.net/~vladas/boot.asm
Kernel source if needed - http://avnet.sytes.net/~vladas/kernel.zip
I uploaded to net kernel source, because in kernel can be a problem, so if someone can and have some time, please take a look at it. Thanks
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

Sorry:) The "a" is wrote in the corner top left. Just I didn't saw. So there I think will be problems with kernel or SectorLoader.
Vladaz

Re:Bugs on bootloader

Post by Vladaz »

OK :) Now bootloader really works. Thanks everybody for help!!!
Post Reply