LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-30-2013, 04:42 PM   #1
sevs
Member
 
Registered: Jul 2008
Location: Russia, Saratov
Distribution: debian, knoppix, mandriva, asplinux, altlinux
Posts: 110

Rep: Reputation: 20
Question Write to port 0cf8h fails with segfault


I have an AMD processor of e2-2000 model. THis is family 0fh. According to family 0fh BKDG I have this code to read device and vendor ID:

Code:
ReadPCIConfiguration:
movq    $0x80000100, %rax
movq    $0x0cf8, %rdx
outl    %eax, %dx          # sigsegv caught here
movq    $0x0cfc, %rdx
inl     %dx, %eax
ret
As far as I know the algorithm to read/write PCI configuration is as follows:
  1. write target bus number, device number function number and offset or register number to configuration address port
  2. perform 1-, 2- or 4-byte r/w operation from/to configuration data port

Ports 0xcf8..0xcfb - configuration address port (doubleword)

Bits meaning:
  • 31 - EnReg - enable the transaction (R/W)
  • 24..31 - reserved (R/O)
  • 16..23 - BusNum (R/W)
  • 11..15 - DevNum (R/W)
  • 8..10 - FuncNum (R/W)
  • 2..7 - RegNum (R/W)
  • 0..1 - Reserved (R/O)
So, I write to bus - 0, dev - 0, func - 1, reg - 00

Am I doing something wrong?

(I run the compiled and linked application from userspace, GNU/Debian "Wheezy" Linux 3.11.6)

Sorry for my broken English
Thanks in advance
 
Old 12-01-2013, 11:26 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Are you using any operating system (Windows, Linux, MacOs, etc)?
 
  


Reply

Tags
assembly, linux, pci



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
read/write,write/write lock with smbclient fails swatidas11 Linux - Networking 1 03-10-2010 12:27 PM
[SOLVED] Write to SD card fails Niraj Kulkarni Linux - Newbie 2 02-18-2010 02:22 AM
CD and DVD write fails SaintDanBert Linux - Hardware 2 11-01-2009 10:52 PM
C under Linux -Trying to write two port server and 2 port client application NancyT Linux - Server 3 04-17-2009 02:05 AM
k3b fails to write dvd Fahiem Linux - Software 2 07-28-2004 03:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration