Solved

PCI interrupt programming

Posted on 1998-06-28
8
739 Views
Last Modified: 2008-02-01
I want to get infomation for PCI interrupt programming.
I tested INT 1Ah AX=B10E and scanned PCI IRQ routing table.
But It happen fault and
scan only signature with table size 0.
I found IRQ table is supported by windows osr2 only.
so I must use INT 1A AX=B10E
 with DPMI real-mode int
or PCI BIOS32 directory service with int386 1ah AX=B18E.
but first makes general protection fault.
I can't find my mistake for this.
Second requires selector for PCI BIOS32 data.
so I tried to use PCI BIOS32.
I refered Interrupt list of ralf brown.
I got BSD entry point. and tried get PCI BIOS32 entry point.
but makes general protection fault.
so I used watcom debugger.
I found get PCI BIOS32 service return with 'retf'
and general protection fault indicate this 'retf'.
So I tried to call with 'callf'
but it makes invalid-opcode fault.
I use watcom C compiler and PMODE/W dos extender
with DPMI service(get dos memory,simulate realmode int).
Can you help me about getting PCI IRQ route table
 and set IRQ?
0
Comment
Question by:commania
  • 5
  • 3
8 Comments
 
LVL 4

Expert Comment

by:nils pipenbrinck
Comment Utility
I did something like that some month ago.. I tried to intercept the interrupt of pci-vga cards.

I scanned all pci devices, checked the class-code for a display adapter and if I found one I used the pcibios interrupt calls to get the interrupt-line.

I'm not sure if this is what you need. if so I can give you some code for watcom to scan the pci-bus and extract the irq-lines.
0
 

Author Comment

by:commania
Comment Utility
Edited text of question
0
 

Author Comment

by:commania
Comment Utility
Edited text of question
0
 

Author Comment

by:commania
Comment Utility
Thanks nils pipenbrinck.
I edited my question to describe problem.
If your source is about IRQ get and set with watcom compiler,
your source muse be best reference for me.
If you can, send your code to me.

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 4

Expert Comment

by:nils pipenbrinck
Comment Utility
Ok, commania.

This code reads out some informations about all installed pci-devices. it works with watcom c under dos4g, pmodew and also with win95 in background.

You shouldn't have any problems to throw away all the stuff that you don't need.

Cheers,
  Nils

BTW. remember, that if you want to hook an interrupt you don't have to use the irq-line returned by the pci-bios. the actual hardware-irq's are mapped. (ralph browns list will tell you where.. I forgot that).

Have a nice day,

  Nils



         /* ********************* CUT HERE ******************* */

#include <i86.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

static union  REGS  regs;
static struct SREGS sregs;

static struct rminfo
{
  unsigned long  EDI;
  unsigned long  ESI;
  unsigned long  EBP;
  unsigned long  reserved_by_system;
  unsigned long  EBX;
  unsigned long  EDX;
  unsigned long  ECX;
  unsigned long  EAX;
  unsigned short flags;
  unsigned short ES,DS,FS,GS,IP,CS,SP,SS;
} RMI;

int PCI_Detect (void)
{
  memset  (&RMI,0,sizeof(RMI));
  memset  (&sregs,0,sizeof(sregs));
  memset  (&regs,0,sizeof(regs));
  RMI.EAX=0x0000b101;
  regs.w.ax  = 0x0300;
  regs.h.bl  = 0x1a;
  sregs.es   = FP_SEG(&RMI);
  regs.x.edi = FP_OFF(&RMI);
  int386x  (0x31, &regs, &regs, &sregs );
  return   ((RMI.EDX == 0x20494350) && ((RMI.flags &1 )==0));
}

long PCI_ReadDword (unsigned char id, short offset)
{
  memset(&RMI,0,sizeof(RMI));
  memset(&sregs,0,sizeof(sregs));
  memset(&regs,0,sizeof(regs));
  RMI.EAX=0x0000b10a;
  RMI.EBX=id<<3;
  RMI.EDI=offset;
  regs.w.ax  = 0x0300;
  regs.h.bl  = 0x1a;
  sregs.es   = FP_SEG(&RMI);
  regs.x.edi = FP_OFF(&RMI);
  int386x(0x31, &regs, &regs, &sregs );
  return  RMI.ECX;
}


void main (void)
{
  int i;
  long Vendor;
  long ClassCode;

  if ( !PCI_Detect())
  {
   printf ("No PCI Bios Detected.. Abort\n\n");
   return;
  }
  printf ("PCI Bios Detected.. Dumping PCI-Devices\n\n");
  for ( i=0; i<32; i++ )
  {
    Vendor    = PCI_ReadDword (i,0);
    ClassCode = PCI_ReadDword (i,0x08) >> 8;
    if ( Vendor != -1)
    {
      printf ("PCI ID %02i:  Vendor:Device  : %04x:%04x\n", i, Vendor &
0xffff, Vendor >> 16);
      printf ("            Class Code     : 0x%06x\n", ClassCode);

      // write out some pci information
      if (PCI_ReadDword (i,0x10)) printf ("            Base Memory #0 :
0x%08x\n", PCI_ReadDword (i,0x10));
      if (PCI_ReadDword (i,0x14)) printf ("            Base Memory #1 :
0x%08x\n", PCI_ReadDword (i,0x14));
      if (PCI_ReadDword (i,0x18)) printf ("            Base Memory #2 :
0x%08x\n", PCI_ReadDword (i,0x18));
      if (PCI_ReadDword (i,0x1c)) printf ("            Base Memory #3 :
0x%08x\n", PCI_ReadDword (i,0x1c));
      if (PCI_ReadDword (i,0x20)) printf ("            Base Memory #4 :
0x%08x\n", PCI_ReadDword (i,0x20));
      if (PCI_ReadDword (i,0x24)) printf ("            Base Memory #5 :
0x%08x\n", PCI_ReadDword (i,0x24));
      if (PCI_ReadDword (i,0x30)) printf ("            Base ROM       :
0x%08x\n", PCI_ReadDword (i,0x30));
      if (PCI_ReadDword (i,0x3c)&0xff) printf ("            IRQ-LINE
: %02i\n", PCI_ReadDword (i,0x3c) & 0xff);

      // identify some class codes
      switch ( ClassCode )
      {
        case 0x38000: printf ("            Non-Super VGA Display
Controller\n"); break;
        case 0x30000: printf ("            Super VGA Display
Controller\n");     break;
        default:      printf ("            Unknown Class Code\n"); break;
      }
      printf ("---------------------------------------------------\n");
    }
  }
}

        /* ********************* CUT HERE ******************* */


0
 

Author Comment

by:commania
Comment Utility
Thanks nils pipenbrinck for your answer.
But your source read only PCI config.
So I can't get IRQ route info and set IRQ.
Your source can't help me regardless of your favor.
But I succeeded with my source last night.
I used Int 1Ah AX=B10E with PMODE/W
I didn't find my fault.
But my source works well now.
0
 

Author Comment

by:commania
Comment Utility
Oh! my mistake.
Nils pipenbrinck's answer is very good for me.
But I missed your answer saying no need to set IRQ.
I want to give my point to you.
PLZ give me an answer with no content.

0
 
LVL 4

Accepted Solution

by:
nils pipenbrinck earned 300 total points
Comment Utility
allright. here it is.. the answer.




0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now