flat assembler
Message board for the users of flat assembler.

Index > OS Construction > How can I get the size of the HD?

Author
Thread Post new topic Reply to topic
Goat6



Joined: 06 Jan 2006
Posts: 8
Goat6
Dose anyone know how to aquire the size of a hard disk
Maby an interrupt or something?

Dose anyone know where I can posably find some source code.

Cool Cool Cool

_________________
Death is not the opposite of life but rather the absence of it.
Post 06 Jan 2006, 17:12
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
Goat6,

Try:

GetDiskFreeSpaceEx
Code:
        bud      db     "C:\", 0

DISKSIZE        struct
        dwLowSize               dd      ?
        dwHighSize              dd      ?
DISKSIZE        ends

        avail_bytes             DISKSIZE
        total_bytes             DISKSIZE
        free_bytes              DISKSIZE

        invoke  GetDiskFreeSpaceEx, bud, avail_bytes, total_bytes, free_bytes
    


This will give you info for the C:\ drive available to the user.

hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 06 Jan 2006, 20:35
View user's profile Send private message Reply with quote
Goat6



Joined: 06 Jan 2006
Posts: 8
Goat6
Thanks for the suggestion but I cant use that Im writting Kernel code and it must have no dependencies on other OSes.

_________________
Death is not the opposite of life but rather the absence of it.
Post 06 Jan 2006, 22:32
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
You need to send the ATA_IDENTIFY command to the drive, wait for the BSY flag to clear, then read in 256 words.

1. Send 0x3c (ATA_IDENTIFY) to port 0x1f7. I send this as a single byte.
2. Read a byte in from port 0x1f7; when the value is equal to 88 (decimal), the busy flag is clear.
3. Repeat step 2 until the busy flag is cleared
4. Read in 256 words from port 0x1f0
5. Look through these words to find what you want to know.

Words number 100-103 store the total number of 512-byte sectors that can be addressed via 48-bit LBA. This will be the actual disk size. If you use CHS addressing; you won't get the full size on large hard drives.

http://www.tldp.org/HOWTO/Large-Disk-HOWTO-10.html has some nice details, including a good chart of what ATA_IDENTIFY returns. It was one of my main resources when I started improving the hard disk drivers in my OS.

_________________
Charles Childers, Programmer
Post 06 Jan 2006, 22:41
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
easier is to call the int 13h,8
ah=8
with dl=drive number
(0 for fd1,1 for fd2,80h for hd0,81h for hd1)

return=>
cx=cylinder,sector in ata chs form

cx:
bits 0-5=>sectors count
bits 6-7=>high order cylinders count
bits 8-15=>low cylinders byte

dl=heads/sides

it works
Post 30 Mar 2006, 10:51
View user's profile Send private message Visit poster's website Reply with quote
jdawg



Joined: 26 Jun 2005
Posts: 39
jdawg
edfed wrote
Quote:
easier is to call the int 13h,8
Where can a person find information about what values to send to ISR's. I haven't found anything about it except various bits and pieces here and there.

I have a couple of copies of the interrupt vector table, but none of them cover anything about the values you send to the ISR.
Post 06 May 2006, 17:31
View user's profile Send private message Reply with quote
Mota



Joined: 29 Dec 2004
Posts: 22
Mota
Oh um, while we're here, is there anywhere that'll give me good info on how to program an ATA driver? It doesn't need to tell me what to do exactly, but it would help if someone knew somewhere that tells us about the interrupts triggered, hardware registers, and pseudo-procedures that an ATA driver programmer would need to know.

Erm... thanks in advance? Surprised
Post 06 May 2006, 22:39
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Check http://ata-atapi.com/ for some good, solid documentation on the ATA specs and free code to review/use.
Post 07 May 2006, 00:56
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Post 07 May 2006, 10:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.