PCI (Linux)

Identity

Each device is identified by a
  • domain (0000 each domain can have 256 buses)
  • bus number (00)
  • device number (00)
  • function (0)

# update-pciids      #update pci ids

# lspci
 00:00.0 Host bridge: Intel ...

# lspci -tv
-[0000:00]-+-00.0  Intel Corporation ...
           +-01.0-[0000:01-06]----00.0  Intel Corporation 82574L Gigabit Network Connection

Address Spaces

  1. Configuration
  2. I/O
  3. Memory

SYSFS

The address spaces (config, io, memory) can be seen from the sysfs tree.

config

# lspci -s 00:1f.3 -x
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
00: 86 80 22 1c 03 00 80 02 04 00 05 0c 00 00 00 00
10: 04 60 52 c2 00 00 00 00 00 00 00 00 00 00 00 00
20: 41 40 00 00 00 00 00 00 00 00 00 00 86 80 22 1c
30: 00 00 00 00 00 00 00 00 00 00 00 00 0a 03 00 00

# od -x /sys/devices/pci0000:00/0000:00:1f.3/config
0000000 8086 1c22 0003 0280 0004 0c05 0000 0000
0000020 6004 c252 0000 0000 0000 0000 0000 0000
0000040 4041 0000 0000 0000 0000 0000 8086 1c22
0000060 0000 0000 0000 0000 0000 0000 030a 0000
0000100 0001 0000 0000 0000 0000 0000 0000 0000
0000120 0000 0000 0000 0000 0000 0000 0000 0000
0000140 0403 0004 0000 0808 0000 0000 0000 0000
0000160 0000 0000 0000 0000 0000 0000 0000 0000
0000200 0004 0000 0000 0000 0000 0000 0000 0000
0000220 0000 0000 0000 0000 0000 0000 0000 0000
*
0000360 0000 0000 0000 0000 0f87 0806 0000 0000

I/O and Memory

These can be mmap'ed

# ll /sys/devices/pci0000:00/0000:00:1f.3/resource*
-r--r--r-- 1 root root 4096 Jul  5 17:46 /sys/devices/pci0000:00/0000:00:1f.3/resource
-rw------- 1 root root  256 Jul  5 17:46 /sys/devices/pci0000:00/0000:00:1f.3/resource0
-rw------- 1 root root   32 Jul  5 17:46 /sys/devices/pci0000:00/0000:00:1f.3/resource4

# lspci -v
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
        Subsystem: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller
        Flags: medium devsel, IRQ 201
        Memory at c2526000 (64-bit, non-prefetchable) [size=256]
        I/O ports at 4040 [size=32]

resource0 (BAR0) is the memory
resource4 (BAR4) is IO ports

Other Useful

Below is how you can find the driver used for the device

# lspci |grep Ether
00:19.0 Ethernet controller: Intel Corporation 82579LM 

# lspci -s 00:19.0 -n
00:19.0 0200: 8086:1502 (rev 04)

# grep 1502 /lib/modules/2.*/modules.pcimap
e1000e               0x00008086 0x00001502 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0

Java Basics

Primitive Types

byte
char - 16 bit
short
int
long - 64 bit
boolean
float
double

Variables

  • variable of primitive types holds value.
  • variable of non-primitive types holds reference.

Variable Storage

  • Static - static class variables
  • Local  - primitives
  • Dynamic - non-primitives

Parameters

  • All the parameters are pass-by-value (since the variables can only be value or reference; for reference it is a copy of the reference). 
  • There is no direct way change content of a primitive type with parameter (can wrap with array or object).

Class

Accessibility

public
private
protected - subclass and class from the same package.
package - member without any leading keyword get default package access.

  • no C++ const method
  • no ";" after class {}

Inheritance

  • no C++ multiple inheritance
  • Object is default base class if no base class is specified. Which is the root base class for all classes.
  • super is used to initialize superclass.

import Person;
public class Student extends Person
{
   private String major;
   public Student(String name, String major)
   {
      super(name);
      this.major=major;
   }
} 

Static and Dynamic Binding

  • virtual by default

 void a();  //C++==>  virtual void a();


Abstract Methods


abstract a();  //C++==> virtual void a()=0;

Call Superclass Version


super.a();     //C++==> baseName::a();

Final Methods

  • Cannot be overriden in a subclass

final void a();
 

Exceptions

  • Java exception class must be a subclass of the java.lang.Exception class (which is a subclass of java.lang.Throwable).
  • C++ exception can be of any class.

Features of C++ does not exist in Java

  • Preprocessor
  • Enumeration Types
  • Templates
  • Operator Overloading
  • Named types (typedef)
  • Structs and unions
  • const class function member.