how to get /dev/hd0 ioport address?

I need to identify the physical location of /dev/hd0.

Basically, I want to find whether my /dev/hd1 device is Primary Slave or Secondary Master through program?

How can i do it ?

Thanks,

Someone else will have to comment on whether or not there is a driver call that will provide this information. That would be the best/easiest method. Without such a call, the following might work.

Put something identifiable in the first sector of each drive. Write your own driver code to try to read all four possible first sectors, Primary Master, Primary Slave, Secondary Master, and Secondary Slave. When finished you will know where the identifiers are. This program should be run before the real driver is started to prevent interference. Then after the system is booted, you can read the first sector of /dev/hd0 and /dev/hd1 and compare with the previous results.

A reasonable question might be, why do you need this information?

Thanks for your quick response.

My system has 3 IDE devices, and the devices on primary master and alsove are optional. So, i want to provide a user choice(1,2,3), where 1=Primary Master, 2=Promary slave and 3=secondary master.
So, based on his input i want to mount that device on /.

To achieve this, i need to the identify /dev/hd1 as primary slave or secondary master.

Are there any devctl commands which can get me the ioport address of the device?