DOC PREVIEW
USF CS 635 - Detecting PCI devices

This preview shows page 1-2-21-22 out of 22 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Detecting PCI devicesEarly PCsThe PC’s evolutionSlide 4Slide 5Three IA-32 address-spacesInterface to PCI Configuration SpaceReading PCI Configuration DataSlide 9Example: network interfaceVendor’s identitySlide 12Packet filtering capabilityYour NIC’s unique addressOur ‘tigon3.c demoHow we got the MAC-addressDriver’s authorsSlide 18Linux helper-functionsBig-Endian to Little-EndianIn-class exerciseSlide 22Detecting PCI devicesOn identifying the peripheral equipment installed in our PCEarly PCs •Peripheral devices in the early PCs used fixed i/o-ports and fixed memory-addresses, e.g.:–Video memory address-range: 0xA0000-0xBFFFF –Programmable timer i/o-ports: 0x40-0x43–Keyboard and mouse i/o-ports: 0x60-0x64–Real-Time Clock’s i/o-ports: 0x70-0x71–Hard Disk controller’s i/o-ports: 0x01F0-01F7–Graphics controller’s i/o-ports: 0x03C0-0x3CF–Serial-port controller’s i/o-ports: 0x03F8-0x03FF–Parallel-port controller’s i/o-ports: 0x0378-0x037AThe PC’s evolution•It became clear in the 1990s that there would be contention among equipment vendors for ‘fixed’ resource-addresses, which of course were in limited supply•Among the goals that motivated the PCI Specification was the creation of a more flexible scheme for allocating addresses that future peripheral devices could usePCI Configuration SpacePCI Configuration Space Body(48 doublewords – variable format) 64doublewordsPCI Configuration Space Header(16 doublewords – fixed format)A non-volatile parameter-storage area for each PCI device-functionPCI Configuration HeaderStatusRegisterCommandRegisterDeviceIDVendorIDBISTCacheLineSizeClass CodeClass/SubClass/ProgIFRevisionIDBase Address 0SubsystemDevice IDSubsystemVendor IDCardBus CIS PointerreservedcapabilitiespointerExpansion ROM Base AddressMinimumGrantInterruptPinreservedLatencyTimerHeaderTypeBase Address 1Base Address 2Base Address 3Base Address 4Base Address 5InterruptLineMaximumLatency 31 0 31 016 doublewordsDwords 1 - 0 3 - 2 5 - 4 7 - 6 9 - 811 - 1013 - 1215 - 14Three IA-32 address-spacesmemoryspace(4GB)i/o space(64KB)PCIconfigurationspace(16MB)accessed using a large variety of processor instructions (mov, add, or, shr, push, etc.) and virtual-to-physical address-translation accessed only by using the processor’s special ‘in’ and ‘out’ instructions (without any translation of port-addresses) i/o-ports 0x0CF8-0x0CFF dedicated to accessing PCI Configuration SpacereservedInterface to PCI Configuration SpaceCONFADD( 0x0CF8)CONFDAT( 0x0CFC)31 23 16 15 11 10 8 7 2 0ENbus(8-bits)device(5-bits)doubleword (6-bits) function(3-bits)00PCI Configuration Space Address Port (32-bits)PCI Configuration Space Data Port (32-bits)31 0 Enable Configuration Space Mapping (1=yes, 0=no)Reading PCI Configuration Data •Step one: Output the desired longword’s address (bus, device, function, and dword) with bit 31 set to 1 (to enable access) to the Configuration-Space Address-Port•Step two: Read the designated data from the Configuration-Space Data-Port:# read the PCI Header-Type field (byte 2 of dword 3) for bus=0, device=0, function=0movl $0x8000000C, %eax # setup address in EAXmovw $0x0CF8, %dx # setup port-number in DX outl %eax, %dx # output address to portmov $0x0CFC, %dx # setup port-number in DXinl %dx, %eax # input configuration longwordshr $16, %eax # shift word 2 into AL registermovb %al, header_type # store Header Type in variableDemo Program•We created a short Linux utility that searches for and reports all of your system’s PCI devices •It’s named “pciprobe.cpp” on our CS635 website•It uses some C++ macros that expand to Intel input/output instructions -- which normally are ‘privileged’ instructions that a Linux application-program is not allowed to execute (segfault!)•Our system administrator (Alex Fedosov) has created a utility (named “iopl3”) that will allow your command-shell to acquire I/O privilegesExample: network interface•We identify the network interface controller in our classroom PC’s by class-code 0x02•The subclass-code 0x00 is for ‘ethernet’•We can identify the NIC from its VENDOR and DEVICE identification-numbers:•VENDOR_ID = 0x14E4•DEVICE_ID = 0x1677•You can use the ‘grep’ command to search for these numbers in this header-file:</usr/src/linux/include/linux/pci_ids.h>Vendor’s identity•The VENDOR-ID 0x14E4 belongs to the Broadcom Corporation (headquarters in Irvine, California)•Information about this firm may be learned from the corporation’s website:<http://www.broadcom.com>•The DEVICE-ID 0x1677 is used to signify Broadcom’s BCM5751 ethernet productnicTypical NIC TX FIFORX FIFOtransceiver LANcableBUSmain memorypacketbufferCPUPacket filtering capability •Network Interface’s hardware needs to implement ‘filtering’ of network packets•Otherwise the PC’s memory-usage and processor-time will be wasted handling packets not meant for this PC to receive network packet’s layoutDestination-address (6-bytes) Source-address (6-bytes)Each data-packet begins with the 6-byte device-address of the network interface which is intended to receive itYour NIC’s unique address•You can see the Hardware Address of the ethernet controller on your PC by typing: $ /sbin/ifconfig •Look for it in the first line of screen-output that is labeled ‘eth0’, for example:•(The NIC’s filter-register stores this value)eth0 Link encap: Ethernet HWaddr 00:11:43:C9:50:3AOur ‘tigon3.c demo•We wrote a kernel module that lets users see certain register-values which pertain to the BCM5751 network interface in your classroom workstation:–(1) the PCI Configuration Space registers–(2) the Media Access Controller’s address •It also shows your machine’s node-name (in case you want to save the information)How we got the MAC-address•We do not have Broadcom’s programming datasheet -- but we do have Linux source code for the ‘tigon3’ device-driver, which includes a header-file ‘tg3.h’ found here: </usr/src/linux/drivers/net/> •If you scroll through the #define directives you will see the offset where the hardware address is stored in the memory-mapped register-space of the ‘tigon3’ interfaceDriver’s authors•The Linux kernel’s open-source driver for the Broadcom ‘tigon3’ network controller was


View Full Document

USF CS 635 - Detecting PCI devices

Download Detecting PCI devices
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Detecting PCI devices and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Detecting PCI devices 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?