Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

low-level os-independent disk access 2

Status
Not open for further replies.

recluse

Programmer
Apr 3, 2001
3
0
0
CA
Hi. To understand my situation:

I'm making an OS-type-thingy that loads from a floppy, and then basically reads the contents of any part(maybe one sector, maybe more) of the hard drive, or partition for further processing (kinda like a sector-editor). This hard drive might be 500MB or 100GB, and might contain winNT or Linux or some obscure OS nobody's heard of - but the OS on the drive shouldn't matter, I just want to read the sectors. So I understand that I must use int13h when reading my OS-type-thingy from the floppy into memory, but to access the HD I'll have to use something else because of the inherent size limits.

Have searched the web for many moons, and found little information. I am going to spout off some stuff, and maybe someone can tell me if I'm on the nail's head or on my thumb.

1. The difference between int13h and int25/26 is that int13 is a BIOS interrupt, int25/26 is a DOS interrupt using BIOS. And then there's int21 7305h, which I think is for fat32. Could someone elaborate on this for me?

2. int13 extensions must be used to access large drives >8GB partitions. And does anyone have any links to detailed info on these extensions. I know that the 4xh functions mirror 0xh functions... what addressing must you use: CHS or LBA. Elaboration on this would be super, too.

I've seen a lot of references to Ralf Brown's interrupt list, but I find it a little cryptic.

Basically I believe that if I want to load my own OS-type-thingy into memory from the boot sector, I'll have to use int13h, and then to access further down the disk, I'll have to use int13h extensions? I'm so confused.

Please shed some light...


 
Hey,
Can't INT 13h be used to read Hard disks ?
I think u can specify INT 13h, where from to read,
whether floppy or hard Disk.,
u specify this in the "DL" register. 80h in DL stands
for hard drive. I think so.
i dont understand why u have problems reading hard drive
U can reach any disk area via CHS addressing..Disk size
doesn't matter.
this is my understanding.
Let me know if i m wrong.

regards,s
sarnath
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Thanks for the response, Sarnath.

I know that int13 can be used to read hard drives, but only up to 8GB. I want to know the standard, os-independent way of accessing sectors on a drive >8GB. I think you have to use int13h extensions, but am not sure of the details.

How would CHS work for greater than 8GB? I thought one might have to use LBA or something.
 
Oh ! sorry, I have misunderstood the qn.

The following is your line of reasoning. (see below)

I/P to BIOS INT 13h function -

sectors = 6 bits = 64 Sectors
Tracks = 12 bits = 4096 Tracks
Head = 6 bits = 64 heads
Sector size = 512.
Multiplying 2^6 * 2^12 * 2^6 * 2^9 = 2^33 = 8Gb

Am i right ?

Just wait yaar. I'd hunt for the answer. This seems to be
a very interesting question.

Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Hi,
Check out this site
" or
search INT 13h in google, u'll land up in this site.
Hope this site helps u recluse.
BTB, whats that OS-Type-thingy stuff. Tell me more.
I can be reached at "intel386@usa.net". of course, if u
feel like sharing it.


Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Checkout this site also ->
Good one! Talks about repsonsiblities of OS which
has to co-exist with other OSes. Probably, this is what
u r looking for
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Hey recluse,
Here's one of my senior's answer for your question.

"Ya LBA is answer. Basically, 8G is the largest possible using 3D co-ordinates (whats called CHS), to access the disk.

If you look at the partition table, there is space in each
entry to store the partition start and size in terms of the
LBA. This is a 4 byte value and is in units of sectors.

Most modern drives are ATAPI compliant. What this means
in a nutshell is "SCSI interface for IDE devices".
SCSI uses linear addressing throughout and ATAPI uses LBA.

ATAPI stands for "ATA Packet Interface". "ATA" stands for "AT Attachment". ATA is historical.

In the old days of the IBM PC/AT, the hard drive was an
extension of the PCs AT bus lines. There was no IDE controller on the system that spoke to the
disk controller.

Instead the disk controller was programmed directly via the AT Bus. To simplify glue logic, the bus to the IDE drives disk controller was merely an extension of the AT bus - using the same line voltages and signaling lines.

This came to be called the AT Attachment. The ATA commands
were actually commands to the disk controller. Hence the
reason users had to program in CHS.

Contrast this with SCSI which used a dedicated "SCSI
controller" which could be programmed by its device driver to perform I/O from or to disks sitting behind it. These disks had their own *disk controllers". These SCSI controllers are also called HBAs - Host Bus Adapters - because they interface the PC (Host) with the Bus (SCSI Bus). And tehy usually come as add on adapters - hence the name.

Now as PCs moved away from the AT bus, the simplicty of ATA
became a hindrance. And so did their weird CHS limitation.

To get around this, they substituted the disk controller with an IDE controller which s/w now programmed. Further, the ATA commands were extended to include some new commands - called the "Packet Interface" commands.

This is like saying they extended system calls to include
ioctls. Once the PI commands became available, these PI
commands were used to implement a SCSI like user model
(i.e.to device drivers).

Hope this clears things up. I am not sure if the AT bus
that reached up to the disk controller was the same as the ISA bus. The AT expansion bus was the ISA I believe. But this may not be the bus that ATA is based on.
"

Also visit " You might get more
information.

regards,
sarnath.k
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Thanks, Sarnath. This second article was great. I had read some of it before, but maybe missed the meaty part. That's super. I'm so excited now. I've been searching Google for days, finding page after page of disappointment.

You da man.
 
Great that it helped you,
The credit goes to my technical manager.
he is a real fundoooooooooooooo..
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Hey recluse,

I was in a similar situation a couple months ago while
I was creating my own OS... I learned some stuff in the
process. First of all, you may want to consider what
you want out of this. Do you want an actual useful
Operating System or is it just a small project you're
doing?

I had gotten a large portion of an operating
system done when i realized that i would need to use
protected mode.. i'm not sure if you realize it but
currently your os is only in real mode and this limits
memory usage to 1mb because it is using 16-bit
segment shifted 4 places to the left and 16-bit offset
for a total of 20 bits aka 1mb.

Anyways, I'd like to warn you that if you decide to
switch to protected mode you will have to start from
scratch because it is more complicated and bios
interrupts aren't available without massive work.

Hope some of this helps - i wrote some drivers and
such of my own to replace the use of bios calls so
just tell me if you need anything i might be able to
help with.

brian
oconnellb@hotmail.com
 
A great resource for Interrupts in general is Ralph Brown's Interrupt List. I don't have a specific link but I do know that there are several sites where it can be found. A Web search at yahoo or aol will pick it up, and it is well worth the time and effort. Talk about comprehensive. It does contain all the necessary info on INT 13H expanded functions to access large drives.
 
Hi, I wanna write my own OS too. Just as a little project. What I want to do is to make some kind of boot disk and the program on the boot sector should load some sectors to mem and jmp over there.
Now, I have a prog called bootw and I can write sectors with it. but i dont know how to open and load a file with out int 21h. i want some code or examples if possible.

thanks...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top