How to access HBA_PORT PxCLB from User Space?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
raydenvm
Posts: 3
Joined: Fri Nov 22, 2013 3:26 am

How to access HBA_PORT PxCLB from User Space?

Post by raydenvm »

Hi all,

I do need your help because of being totally stuck on the following issue. I have been writing Linux software that runs in User Space mode under root user. It works with AHCI controller and 4 SATA drives attached to it. I use Intel SATA AHCI Specification (http://www.intel.com/content/www/us/en/ ... ev1_3.html) and hints from http://wiki.osdev.org/AHCI.

I managed to map successfully physical address ABAR5 via mmap command. Now I have all 4 SATA ports and their live values of registers working well. For instance, PxTFD shows changes of status and error registers per each drive correctly.

PROBLEM:

Can't understand how I can map physical memory address from PxCLB. It's needed for sending Register FISes containing ATA Commands to HDD. I just can't access that memory anyhow. Tried to use mmap but all my mapping attemts were failed with MAP_FAILED (-1).

Any hints?
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: How to access HBA_PORT PxCLB from User Space?

Post by thepowersgang »

May I ask why you are writing an AHCI driver in the linux userland? When linux has a working SATA driver already.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
raydenvm
Posts: 3
Joined: Fri Nov 22, 2013 3:26 am

Re: How to access HBA_PORT PxCLB from User Space?

Post by raydenvm »

thepowersgang wrote:May I ask why you are writing an AHCI driver in the linux userland? When linux has a working SATA driver already.
It's a part of my company's product that should work with HDDs in very native way via AHCI ports. We support damaged drives, and have somewhat patched kernel for that.

By the way, I am trying now to recompile linux kernel (2.6.32) with disabled CONFIG_STRICT_DEVMEM options. It seems it may help.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: How to access HBA_PORT PxCLB from User Space?

Post by thepowersgang »

I would instead make a kernel module that does the driver actions, and have a userland process send it command sets.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
raydenvm
Posts: 3
Joined: Fri Nov 22, 2013 3:26 am

Re: How to access HBA_PORT PxCLB from User Space?

Post by raydenvm »

thepowersgang wrote:I would instead make a kernel module that does the driver actions, and have a userland process send it command sets.
Thanks a lot! Could you hint any kind of short guide that could help to do that?

I know I am able to google that by myself but suppose your experience can direct me at the best way.
Post Reply