problem loading kernel

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.
Post Reply
shaz

problem loading kernel

Post by shaz »

my kernel consists of almost 36k.
but it's not loading properly.
here is my code to load kernel.

Code: Select all

mov ax,0x0 
mov es,ax
mov bx, 0xB800          
mov ah,2                      
mov al,18                     
mov ch,7                      
mov cl,1                      
mov dh,0                      
int 0x13                      
jc error

mov ax,0x0 
mov es,ax
mov bx, 0xDC00          
mov ah,2                      
mov al,18                  
mov ch,8                      
mov cl,1                      
mov dh,0                      
int 0x13                      
jc error

mov ax,0x1000
mov es,ax
mov bx, 0x0          
mov ah,2                      
mov al,18                     
mov ch,9                      
mov cl,1                      
mov dh,0                      
int 0x13                      
jc error


mov ax,0x1000
mov es,ax
mov bx, 0x2400          
mov ah,2                      
mov al,18                     
mov ch,10                      
mov cl,1                      
mov dh,0                      
int 0x13                      
jc error



[\code]

the probelm occurs when i load 4th track.all tracks are loaded
properly cuz carry flag is not set.but i think something is wrong with loading addresses.
please tell me the problem and how to correct it. 



User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:problem loading kernel

Post by Candy »

some (read, lots) floppy controllers (bioses?) don't support >7 tracks per read. Split it up in 6-track reads. (guess of mine, happened to me too once)
Curufir

Re:problem loading kernel

Post by Curufir »

Well I took a look at the addresses and they seem fine.

The thing that gets me curious is that all of these reads take place on the same head. Unless you've got your own utility for writing the file out to disk that seems a very unusual way for it to be arranged.
shaz

Re:problem loading kernel

Post by shaz »

another strange thing happend when i limited the size of my kernel to less than 3 tracks.
now if i still read the 4th track (although it contains nothing) to above mentioned address .pc just halts.but if i change the loading address to something else,everything works fine.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:problem loading kernel

Post by Neo »

if anyone knows of a good site having pics of a floppys layout of tracks sectors etc with numbering as well as a good explanation it would be helpful for me to include in my docs.
Only Human
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:problem loading kernel

Post by Pype.Clicker »

keep in mind that the DMA transfers may not cross a 64KB boundary. This means that a transfer that starts with X = N*65536+M can only go up to N*65536+65535 ...

I don't know if the BIOS can split the transfer in two DMA request or not, but i wouldn't count on it. The BIOS doesn't allows more than 64KB to be transferred at once, iirc that makes about 7 tracks of 18 sectors
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:problem loading kernel

Post by Neo »

Ive seen that most of you use the default values for sectors/track, heads, bytes/sector etc... what i want to know is how can this work if i change the floppy or drive etc..?
How can we obtain the actual values of these parameters? Should we get it from the bootloader? if so what happens when we boot from a hard-disk? wont the bootloader just give us the same defaults we use?
Suppose during run-time we use a differently formatted(diff params) floppy? (or is this a dumb question?)
Yeah thats a lot of questions. Any answers?
Only Human
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:problem loading kernel

Post by Candy »

Neo wrote: Ive seen that most of you use the default values for sectors/track, heads, bytes/sector etc... what i want to know is how can this work if i change the floppy or drive etc..?
Not.
How can we obtain the actual values of these parameters?
The Bios Data Area has some info, and the floppy itself (with FAT12) has some.
Should we get it from the bootloader?
Don't you make the bootloader? Or at least, decide?
if so what happens when we boot from a hard-disk? wont the bootloader just give us the same defaults we use?
N/A, and the BDA is adjusted.
Suppose during run-time we use a differently formatted(diff params) floppy? (or is this a dumb question?)
There are no dumb questions :P

You code a different bootloader for the floppies that are different. Or, you probe the sectorcount.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:problem loading kernel

Post by Neo »

Candy wrote: You code a different bootloader for the floppies that are different. Or, you probe the sectorcount.
do you mean keep testing the sectors until we fault??
Only Human
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:problem loading kernel

Post by Candy »

Neo wrote:
Candy wrote: You code a different bootloader for the floppies that are different. Or, you probe the sectorcount.
do you mean keep testing the sectors until we fault??
Try to read sector 36, if it doesn't exist the floppy has less than 36 sectors. Try to read sector 18, if it doesn't exist .... sector 9, if it doesn't exist ... sector 6 ... ?

get the point?
Post Reply