Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 549665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:12:28+00:00 2026-05-13T11:12:28+00:00

I am trying to communicate with a disk drive using inb(), inw(), outb() and

  • 0

I am trying to communicate with a disk drive using inb(), inw(), outb() and outw() commands so I can find specific information about the drive. However, to use these commands, I need the correct I/O ports for the device. When I have the correct I/O ports, I can find the information I am looking for very easily, however, I do not know a way to find the base address of a device’s I/O ports in Linux.

In DOS, I am able to use Hdat2 to find the device’s base address, however, I am trying to find the address in Linux. Is there a way to find which device maps to which I/O port in Linux?

There is a file in /proc called ioports that contains some information but I don’t how to associate this information with specific devices.

Any help would be greatly appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:12:28+00:00Added an answer on May 13, 2026 at 11:12 am

    So I did find something, although it isn’t the most elegant solution and it definitely doesn’t work everywhere, it has worked on my hardware so I figured I would share.

    First, you have to get the address of the SATA Controller from the lspci command like Nikolai showed (the -D just shows the full domain numbers):

    # lspci -D
    ...
    0000:00:1f.2 SATA controller: Intel Corporation 82801IR 6 port SATA AHCI Controller
    ...
    

    Now with this address (0000:00:1f.2) you can go into /sys.

    In /sys/bus/pci/devices, your device should be listed:

    # ls -l /sys/bus/pci/devices
    ...
    lrwxrwxrwx 1 root root 0 Jan 14 12:35 0000:00:1f.2 -> ../../../devices/pci0000:00/0000:00:1f.2
    

    Now in this directory there will be several hostX directories.

    # ls -l /sys/bus/pci/devices/0000\:00\:1f.2/
    ...
    drwxr-xr-x 4 root root    0 Jan 13 12:40 host0
    drwxr-xr-x 4 root root    0 Jan 13 12:40 host1
    drwxr-xr-x 3 root root    0 Jan 13 12:40 host2
    drwxr-xr-x 3 root root    0 Jan 13 12:40 host3
    drwxr-xr-x 3 root root    0 Jan 13 12:40 host4
    drwxr-xr-x 4 root root    0 Jan 14 08:21 host5
    ...
    

    In one of these hostX directories, there will be a targetX:X:X directory. This targetX:X:X directory will then have a directory called X:X:X:X (the X’s are numbers that can vary).

    # ls -R /sys/bus/pci/devices/0000\:00\:1f.2/host0
    /sys/bus/pci/devices/0000:00:1f.2/host0:
    power  scsi_host:host0  target0:0:0  uevent
    
    /sys/bus/pci/devices/0000:00:1f.2/host0/target0:0:0:
    0:0:0:0  power  uevent
    ...
    

    In the X:X:X:X directory, there is a link named “block:sdX” (where X is a letter). This sdX is the name of the drive that this directory corresponds to.

    # ls -l /sys/bus/pci/devices/0000\:00\:1f.2/host0/target0\:0\:0/0\:0\:0\:0/
    lrwxrwxrwx 1 root root    0 Jan 14 15:01 block:sda -> ../../../../../../block/sda
    

    So /dev/sda corresponds to host 0 on the SATA Controller at 0000:00:1f.2. Now to find the address that we can use to talk to /dev/sda through inb() and outb() commands, we look in the file named “resource” in /sys/bus/pci/devices/0000:00:1f.2/.

    # cat /sys/bus/pci/devices/0000\:00\:1f.2/resource
    0x000000000000fe00 0x000000000000fe07 0x0000000000000101
    0x000000000000fe10 0x000000000000fe13 0x0000000000000101
    0x000000000000fe20 0x000000000000fe27 0x0000000000000101
    0x000000000000fe30 0x000000000000fe33 0x0000000000000101
    0x000000000000fec0 0x000000000000fedf 0x0000000000000101
    0x00000000ff970000 0x00000000ff9707ff 0x0000000000000200
    0x0000000000000000 0x0000000000000000 0x0000000000000000
    

    The address we are looking for is fe00, which is on the first line. We want the first line because it is host 0, if it were host 1, we would look on the second line, and host 2 the third line, and so on. The host number was given by the hostX directory that we found earlier. Each line in the resource file is separated into 3 columns:

    Column 1 = beginning address
    Column 2 = end address
    Column 3 = flags

    So this is how I get from /dev/sda to 0xfe00 in order to send commands to the device.

    If anybody know any better way to do this, I am all ears…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.