Page 2 of 2

Re:Bugs on bootloader

Posted: Wed Jun 30, 2004 9:54 am
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 ...

Re:Bugs on bootloader

Posted: Wed Jun 30, 2004 10:37 am
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?

Re:Bugs on bootloader

Posted: Wed Jun 30, 2004 10:42 am
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>

Re:Bugs on bootloader

Posted: Wed Jun 30, 2004 12:53 pm
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

Re:Bugs on bootloader

Posted: Wed Jun 30, 2004 1:17 pm
by Vladaz
It still restarts me the PC when i try it on Real PC. Bochs too restarts and runs again that. :(

Re:Bugs on bootloader

Posted: Wed Jun 30, 2004 2:28 pm
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.

Re:Bugs on bootloader

Posted: Wed Jun 30, 2004 2:30 pm
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.

Re:Bugs on bootloader

Posted: Wed Jun 30, 2004 4:00 pm
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?

Re:Bugs on bootloader

Posted: Thu Jul 01, 2004 1:38 am
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

Re:Bugs on bootloader

Posted: Thu Jul 01, 2004 8:19 am
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.

Re:Bugs on bootloader

Posted: Thu Jul 01, 2004 11:01 pm
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

Re:Bugs on bootloader

Posted: Fri Jul 02, 2004 8:38 am
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

Re:Bugs on bootloader

Posted: Fri Jul 02, 2004 8:47 am
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.

Re:Bugs on bootloader

Posted: Fri Jul 02, 2004 10:03 am
by Vladaz
OK :) Now bootloader really works. Thanks everybody for help!!!