hardware interaction in c

This is a discussion on hardware interaction in c within the C Programming forums, part of the General Programming Boards category; hi there, this is vineet.i am in MCA fourth sem.planning to submit "system manager for dos" as a minor project,which ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    1

    hardware interaction in c

    hi there,
    this is vineet.i am in MCA fourth sem.planning to submit "system manager for dos" as a minor project,which would provide a GUI for formatting(A drive),scanning and many other utilities.but i am facing a lot of problems.it would be really nice of u if u could help me with the following..

    1-->how can i provide information about all the partition's on the sytem i.e. it's free and used space.

    2-->How can i show exat RAM size used(it's 192 in mine).

    3-->it would be really nice of u if u could provide me information about media discreptor of floppy(1.44MB).

    vineet..

  2. #2
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Lightbulb

    At first you should write what compiler do you use and in which operating system are you writing your code.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >system manager for dos

    I assume you're using DOS. You could use the info in the BIOS.

  4. #4
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    How can i use the info in the BIOS? DOn't u need assembly stuff do access the partition table and things like that?

  5. #5
    Im a Capricorn vsriharsha's Avatar
    Join Date
    Feb 2002
    Posts
    192

    Thumbs up

    > How can i use the info in the BIOS? DOn't u need assembly stuff do access the partition table and things like that?

    In the first case, No assembly is required to access partition table information and any of the Hardware resource information for that matter. C (I use Turbo C) provides u a rich set of functions to do the same for some and for the others u always have memory under ur spell, so get the values from various memory locations. U can also have information from CMOS using the system CMOS ports 70h & 71h.
    For partition table...

    The hard disk is partitioned using utilities like DOS's FDISK. While partitioning the hard disk, FDISK stores the details like where one partition ends and the next begins, which is the bootable partition etc in the first physical sector (side 0, track 0 sector 1). It also stores a program called Master Boot Program in the PT (partition table). Thus a PT consists of a data part and the code part. This is how the PT is logically divided...

    Code Part Data Data 55
    (master boot program) data data AA
    -------------- ----------------------- -----------
    446 bytes 64 bytes 2 bytes
    totally : 512 bytes

    The data part begins at the 447th byte. the last 2 bytes in the PT are always 0x55, 0xAA. The data part is 64 bytes long and is further divided into 4 16-bit chunks. Each chunk consists of info abt a partition on the HDD. Hence there can be maximum four partitions on the HDD. (dont confuse with logical drives which can by any number). The break up for those 16-byte chunks are ...

    Byte Meaning
    ----- -----------
    0 Boot Indicator. Contains 0x80 for active partition and 0
    otherwise.Only 1 partition can be active at a time
    1 Side where partition begins
    2 Low-six bits are the sector where partition begins
    Two-high bits are the two high bits of the track where
    partition begins
    3 Low order 8 bits of the track where partition begins
    4 Partition type indicator. The following values may exist...
    0 - Unused partition
    1 - DOS partition using 12-bit FAT
    2 - Unix Partition
    4 - DOS partition using 16-bit FAT
    5 - Extended partition
    6 - Huge Partition
    5 Side where partition ends
    6 Low-six bits are the sector where partition ends
    Two-high bits are the two high bits of the track where
    partition ends
    7 Low order 8 bits of the track where partition ends
    8-11 Double word containing the number of sectors preceding
    the partition. Low order word is stored first
    12-15 Double word containing the number of sectors in
    the partition. Low order word is stored first


    So, with these details, go ahead and try a program off ur brains... But remember (There is no mention for 32-bit FAT or Linux native / swap partitions. So, this is a premitive stuff (not suited for the latest partitions), so just be careful)


    Best regards,
    Sriharsha.

    *Note: Dont play with ur PT or else U have to reset the whole disk.
    Help everyone you can

  6. #6
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    What are the functions that can access the partition table?

  7. #7
    Im a Capricorn vsriharsha's Avatar
    Join Date
    Feb 2002
    Posts
    192
    I never remember using any Off-the shelf functions. I always wrote it on my own.
    I guess u can do it with the info i provided above.
    Help everyone you can

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hardware interaction through USB port with C
    By mariano_donati in forum C Programming
    Replies: 3
    Last Post: 11-15-2007, 06:31 PM
  2. How does hardware interpret data?
    By Silvercord in forum Tech Board
    Replies: 3
    Last Post: 01-29-2003, 12:46 PM
  3. Linux Hardware Handbook
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 04-02-2002, 05:06 AM
  4. C++ Hardware Interaction
    By William in forum C Programming
    Replies: 1
    Last Post: 03-28-2002, 02:52 AM
  5. support 256 colors...
    By jackie_islam in forum C Programming
    Replies: 4
    Last Post: 03-12-2002, 12:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21