How to check that a device is attached on a port

Q1: can anyone tell me how cfgadm keeps track of the device even if the device is disconnected ,

when we disconnect a device using cfgadm
cfgadm -ys disconnect <ap_id>

then the device disappears from the lshal o/p. HAL uses libdevinfo for the device list. if the device is not there in the /dev i think the system resources assigned to that device are freed. it means we can't keep track of that device. cfgadm does so. we can reconnect it from there... how it is done ?

cfgadm -c configure pci_ap_id

Example: The logical Ap_Id for a SCSI device usually looks like this:

HBA-logical-apid::device-identifier

thanks incredible:b: but this is not what i am asking. i am saying that when we disconnect the device using cfgadm. it disappears from the HAL output . check in lshal it will not be there. but we can connect it using the ap_id. what i am asking is how any device which is disconnected , ie resources are freed , and not having an entry in /dev can be connected using ap_id.

and if there is a way of doing so. can i do it for other than pci devices.??

i am not looking for a command , i am looking for the mechanism.