Exce 13 in 1 meg....

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
jrfritz

Exce 13 in 1 meg....

Post by jrfritz »

[attachment deleted by admin]
jrfritz

Re:Exce 13 in 1 meg....

Post by jrfritz »

Maybe i'm overwriting some important data or something?

Am I even copying the data to the 1 meg mark and loading the kernel correctly?
Curufir

Re:Exce 13 in 1 meg....

Post by Curufir »

Forget the CHS scheme and think in terms of LBA since the translation between the two makes the CHS organisation very easy to understand.

A 1.44mb 3.5 inch floppy has 2 heads/80 cylinders/18 sectors per cylinder. Because there is only one platter one cylinder represents a single track (See Schol-R-Lea's very good explanation here http://www.mega-tokyo.com/forum/index.php?board=1;action=display;threadid=2494 if you don't get that).

Now that gives you a total of 2*80*18 sectors on the disk, ie 2880 sectors. In LBA scheme you start at sector 0. So the range for a 1.44mb 3.5 floppy is 0-2779.

To convert to CHS scheme from LBA you use these formulae.

Sector = ((LBA Sector) mod (Sectors per track)) + 1
Head = floor((LBA Sector) / (Sectors per track)) mod (Heads per cylinder)
Cylinder = floor(((LBA Sector) / (Sectors per track)) / (Heads per cylinder))

Some examples on 1.44mb 3.5inch floppy:
Sectors per track = 18
Heads per cylinder = 2

LBA sector=0 (Ie the 1st sector on the disk)
Sector = 1
Head = 0
Cylinder = 0

LBA sector=18 (Ie the 19th sector on the disk)
Sector=1
Head=1
Cylinder=0

Now the important thing to take from these examples is that in CHS scheme THE SECTOR VALUE STARTS AT 1 NOT 0. Bios 13h uses CHS.

Here's the details of BIOS Int 13h, 0x02
AH=0x02 - Indicates that you are using the read sectors function
AL=Number of contiguous sectors to read
CH=Start Cylinder
CL=Start Sector
DH=Start Head
DL=Drive number

This interrupt function returns this information:
AH=Status of operation
AL=Number of sectors read (Not always what you expect)
CF=Set on error, cleared otherwise

Now AL acts as a counter. So when load al with 0x11 it will read 17 sectors, that 17 sectors includes the sector you instruct Int 13h, 0x02 to start the read at.

BIOS will not change the head/cylinder for you. Ie all the sectors you want to read in a single Int 13, 0x02 call must be on the same track.

To load a full track you set up CHS to be the first sector on the track and AL to be 0x12, ie 18 sectors including the start sector.

Hopefully that clarifies a few things. Sorry it's not more use Tom, but I reached the point of seeing you incrementing the heads value 3 times on a floppy and figured these might be worth pointing out seeing as from recent posts a few people are having problems with int 13h, 0x02. I'll look again sometime tomorrow.

**

I think C uses % for mod, can't be sure though.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Exce 13 in 1 meg....

Post by df »

[attachment deleted by admin]
-- Stu --
jrfritz

Re:Exce 13 in 1 meg....

Post by jrfritz »

Doesn't work :-\
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Exce 13 in 1 meg....

Post by df »

i didnt say i tested it, all i said it compiled :)
your disk loading is totally bogus.

write a chs lba routine and just loop it to read X sectors.
personally i'd dump it and use grub. your boot sector aint loading anything anytime soon without a majour overhaul.
-- Stu --
jrfritz

Re:Exce 13 in 1 meg....

Post by jrfritz »

Ok...i'll try compiling grub for the 4th time...
jrfritz

Re:Exce 13 in 1 meg....

Post by jrfritz »

Could someone compile grub for me?

Or is there a better way?
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Exce 13 in 1 meg....

Post by df »

i uploaded a grub disk image to my ftp its in operating-systems/grub_boot.zip

all you have to do is copy your kernel as bootp.bin to a:\ (either as a real floppy disk, or with mtools or winimage).

your kernel needs to be an ELF file or have a multiboot hack on it for a flat binary.
-- Stu --
jrfritz

Re:Exce 13 in 1 meg....

Post by jrfritz »

How do I compile to elf?
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Exce 13 in 1 meg....

Post by df »

if you had cygwin, you could use the ld-all.exe thats also in the FTP to output elf files ;)

there are also DJGPP elf tools (eaisest for you).

check out http://elfbinutils.narod.ru/
-- Stu --
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Exce 13 in 1 meg....

Post by df »

i should also add, you dont NEED elf to boot from grub,
http://my.execpc.com/~geezer/osd/boot/grub-how.txt
-- Stu --
jrfritz

Re:Exce 13 in 1 meg....

Post by jrfritz »

I don't care about DGJPP...i'm using linux's LD...but I will have to care about DGJPP now since I ported the installer to windows :-[
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Exce 13 in 1 meg....

Post by df »

if your in linux, no probs. your ld already does elf nativly :D
djgpp's LD does COFF only, unless you download the djgpp elf binutils and add the LD switch -m elf_i386 your set.
-- Stu --
Post Reply