Page 1 of 1

Exce 13 in 1 meg....

Posted: Sun Jan 05, 2003 7:08 pm
by jrfritz
[attachment deleted by admin]

Re:Exce 13 in 1 meg....

Posted: Sun Jan 05, 2003 8:43 pm
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?

Re:Exce 13 in 1 meg....

Posted: Sun Jan 05, 2003 9:56 pm
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.

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 11:24 am
by df
[attachment deleted by admin]

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 12:01 pm
by jrfritz
Doesn't work :-\

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:01 pm
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.

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:04 pm
by jrfritz
Ok...i'll try compiling grub for the 4th time...

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:09 pm
by jrfritz
Could someone compile grub for me?

Or is there a better way?

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:19 pm
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.

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:21 pm
by jrfritz
How do I compile to elf?

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:24 pm
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/

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:25 pm
by df
i should also add, you dont NEED elf to boot from grub,
http://my.execpc.com/~geezer/osd/boot/grub-how.txt

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:38 pm
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 :-[

Re:Exce 13 in 1 meg....

Posted: Mon Jan 06, 2003 1:44 pm
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.