PCI Drivers 491530025 陳俐如 (greener). Bus architecture  The higher-level bus architectures  Consist of programming interface and electrical interface.

Slides:



Advertisements
Similar presentations
Provide data pathways that connect various system components.
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
International Test Instruments Corporation
Introduction Computer Hardware Jess 2006 EXPANSION CARDS BUS ARCHITECTURE AND CONNECTORS.
University College Cork IRELAND Hardware Concepts An understanding of computer hardware is a vital prerequisite for the study of operating systems.
CH15 Overview Of Peripheral Buses ANT 鄭伊騏 (JOE)
Chapter 10 Supporting I/O Devices. You Will Learn…  How to install peripheral I/O devices  How to use ports and expansion slots for add- on devices.
1 Introduction to Computers Day 6. 2 Main Circuit Board of a PC The main circuit board (motherboard or system board) is the central nervous system of.
PHY 201 (Blum) Buses Warning: some of the terminology is used inconsistently within the field.
Computer Organization CSC 405 Bus Structure. System Bus Functions and Features A bus is a common pathway across which data can travel within a computer.
Chapter 8 Input/Output. Busses l Group of electrical conductors suitable for carrying computer signals from one location to another l Each conductor in.
Introduction to Computer Networks Introduction to Computer Networks.
Interconnection Structures
How Hardware and Software Work Together
9/28: Buses & Communication Buses: highways of the motherboard –system buses –local buses: PCI, ISA, EISA –expansion slots plug & play laptops: PCMCIA.
1 Chapter Overview Understanding Expansion Buses Configuring Expansion Cards Cables and Connectors.
PCI Drivers Ted Baker  Andy Wang CIS 4930 / COP 5641.
Bus structures Unit objectives Describe the primary types of buses, and define interrupt, IRQ, I/O address, DMA, and base memory address Describe the features.
CSC 370 (Blum)1 Communicating with Devices: Buses, Bridges, etc.
E0001 Computers in Engineering1 The System Unit & Memory.
LOGO BUS SYSTEM Members: Bui Thi Diep Nguyen Thi Ngoc Mai Vu Thi Thuy Class: 1c06.
The PCI Bus is typically measured in Megabytes per second (MBps). The USB and FireWire Bus is typically measured in Megabits per second (Mbps) and.
System Resources.
Exercise 2 The Motherboard
1 CS503: Operating Systems Spring 2014 Dongyan Xu Department of Computer Science Purdue University.
Buses Warning: some of the terminology is used inconsistently within the field.
4 Linking the Components. © 2005 Pearson Addison-Wesley. All rights reserved Figure 4.1 This chapter focuses on how the hardware layer components are.
2007 Oct 18SYSC2001* - Dept. Systems and Computer Engineering, Carleton University Fall SYSC2001-Ch7.ppt 1 Chapter 7 Input/Output 7.1 External Devices.
LIS508 lecture 3: looking at a computer Thomas Krichel
IWORID P.Randaccio Medipix2 Parallel Readout System 4-th IWORID Amsterdam 8 – 12 September 2002 V. Fanti, R. Marzeddu, P. Randaccio Dipartamento.
BUS IN MICROPROCESSOR. Topics to discuss Bus Interface ISA VESA local PCI Plug and Play.
Buses All devices in the computer are connected to the External Data Bus Extension to External Data Bus called Expansion Bus –Used for devices that might.
EEE440 Computer Architecture
The BUS The Central Communications Network Copyright © Curt Hill.
CS-350 TERM PROJECT COMPUTER BUSES By : AJIT UMRANI.
Copyright 2003 The McGraw-Hill Companies, Inc CHAPTER The System Unit computing ESSENTIALS    
ECEG-3202 Computer Architecture and Organization Chapter 3 Top Level View of Computer Function and Interconnection.
Organisasi Sistem Komputer Materi VIII (Input Output)
CHAPTER Microcomputer as a Communication Device. Chapter Objectives Examine the components of the motherboard that relate to communication Describe a.
DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK– PARALLEL BUS DEVICE PROTOCOLS 1.
By Fernan Naderzad.  Today we’ll go over: Von Neumann Architecture, Hardware and Software Approaches, Computer Functions, Interrupts, and Buses.
Dr Mohamed Menacer College of Computer Science and Engineering, Taibah University CE-321: Computer.
PCI Buses Peripheral Component Interconnect Interface.
1 Chapter 2 Central Processing Unit. 2 CPU The "brain" of the computer system is called the central processing unit. Everything that a computer does is.
System Buses Blane Adcock Eric Bartel Kevin Estep Jason Losco.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Local-Area Networks. Topology Defines the Structure of the Network – Physical topology – actual layout of the wire (media) – Logical topology – defines.
Input/Output Organization III: Commercial Bus Standards CE 140 A1/A2 20 August 2003.
System Bus.
PHY 201 (Blum) Comparators and Buses. PHY 201 (Blum) What is it? A comparator is circuitry that compares two inputs A and B, determining whether the following.
3/22 How a Bus Works. Roll Call Lecture: –general traces addresses sizes types –How a PCI bus works.
Key Terms – Chapter 2 from Enhanced A+ Guide to Managing and Maintaining Your PC Enhanced Third Edition by Jean Andrews Richard Goldman.
Group 1 chapter 3 Alex Francisco Mario Palomino Mohammed Ur-Rehman Maria Lopez.
Lesson 5 Installation and Configuration Core Hardware Fundamentals.
SEPTEMBER 8, 2015 Computer Hardware 1-1. HARDWARE TERMS CPU — Central Processing Unit RAM — Random-Access Memory  “random-access” means the CPU can read.
Intro to PCI 2002 년 1 월 21 일 신 준 헌. Contents PCI bus features General PCI bus model PCI Device vs. Function Specifications.
Linux PCI drivers Michael Opdenacker Free Electrons
Components of Computer
The PCI bus (Peripheral Component Interconnect ) is the most commonly used peripheral bus on desktops and bigger computers. higher-level bus architectures.
Chapter Overview Understanding Expansion Buses
SYSTEM BUS.
I/O BUSES.
Five Key Computer Components
PC Buses & Standards Bus = Pathway across which data can travel. Can be established between two or more computer elements. PC has a hierarchy of different.
CH15 Overview Of Peripheral Buses
Presentation transcript:

PCI Drivers 陳俐如 (greener)

Bus architecture  The higher-level bus architectures  Consist of programming interface and electrical interface  PCI  ISA

PCI Interface  PCI (Peripheral Component Interconnect)  How a PCI driver can find its hardware and gain access to it  Replace the ISA standard, with three main goals get better performance when transferring data between the cpu and its peripherals platform independent simplify adding and removing peripherals to the system  The PCI bus achieves better performance by using a higher clock rate than ISA  PCI devices are jumperless (unlike most older peripherals) and are automatically configured at boot time without any probing (Cf. device driver)

PCI Addressing  Each PCI peripheral is identified by a 16-bits number, or key, including a bus number (8 bits), a device number (5 bits), and a function number (3 bits)  The 16-bit address, or key, is hardware address of PCI  A PCI domain – > 256 buses – > 32 devices – > a multifunction board with a maximum of 8 functions  Device drivers written for Linux use a specific data structure, called pci_dev, to act on the devices.  Bridges, joining two buses  The 16-bit hardware addresses, hidden in the struct pci_dev object, Output of lspci and the layout of information in /proc/pci and /proc/bus/pci

PCI Addressing (cont’d)

 The hardware circuitry of each peripheral board three address spaces memory locations I/O ports configuration registers  Geographical addressing configuration queries address only one slot at a time  Addresses are supposed to be unique to one device, but software may erroneously configure two devices to the same address, making it impossible to access either one unless playing with registers it shouldn ’ t touch  The firmware initializes PCI hardware at system boot, mapping each region to a different address to avoid collisions in configuration registers

Boot Time  That ’ s when the devices are configured to accessible by the system – configuration transaction  Firmware BIOS NVRAM PROM  Map the device ’ s memory and I/O ports to the system ’ s address space  Information in /proc/bus/pci/devices or /proc/pci

Configuration Registers and Initialization Little-endian

Configuration Registers and Initialization (cont’d)  struct pci_device_id { __u32 vendor; __u32 device; __u32 subvendor; __u32 subdevice; __u32 class; __u32 class_mask; kernel_ulong_t driver_data; PCI_DEVICE(vendor, device) PCI_DEVICE_CLASS(device_class, device_class_mask) }

MODULE_DEVICE_TABLE  Macro – know what modules works with what devices  /lib/modules/ /mo dules.pcimap  hotplug

Registering a PCI Driver  struct pci_driver { const char *name; const struct pci_device_id *id_table; int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); void (*remove) (struct pci_dev *dev); int (*suspend) (struct pci_dev *dev, u32 state); int (*resume) (struct pci_dev *dev); }  static struct pci_driver pci_driver = {.name = "pci_skel",.id_table = ids,.probe = probe,.remove = remove, };  static int __init pci_skel_init(void);  static void __exit pci_skel_exit(void);  int pci_enable_device(struct pci_dev *dev);

Accessing the Configuration Space  Devices ’ memory, port, and configuration space (memory and I/O port map)  PCI controller – access configuration space  Defined in int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val); int pci_read_config_word(struct pci_dev *dev, int where, u16 *val); int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val); int pci_write_config_byte(struct pci_dev *dev, int where, u8 val); int pci_write_config_word(struct pci_dev *dev, int where, u16 val); int pci_write_config_dword(struct pci_dev *dev, int where, u32 val);

Accessing the I/O and Memory Spaces  6 I/O address regions, being memory or I/O regions  “ prefetchable ” – the cpu can cache the memory region ’ s content  Generic resource management unsigned long pci_resource_start(struct pci_dev *dev, int bar); unsigned long pci_resource_end(struct pci_dev *dev, int bar); unsigned long pci_resource_flags(struct pci_dev *dev, int bar); In  IORESOURCE_IO  IORESOURCE_MEM-- associated I/O region exists  IORESOURCE_PREFETCH  IORESOURCE_READONLY-- prefetchable and/or write protected

PCI Interrupts  IRQ in configuration register 60 (PCI_INTERRUPT_LINE)  Configuration register 60 (PCI_INTERRUPT_PIN) If the value = 0, supporting interrupts Tell which single pin is used

Hardware Abstractions  C language uses structure containing methods and pointers to simulate OOP  struct pci_ops { int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val); int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size u32 val); };  The actual implementa-tion of pci_read_config_byte(dev, where, val) is dev- >bus->ops->read(bus, devfn, where, 8, val);

A Look Back: ISA  Poor performer  Build your own ISA devices easily  Cons ISA is that it ’ s tightly bound to the PC architecture The lack of geographical addressing

Hardware Resources  I/O ports  Memory areas  Interrupt lines

ISA Programming  Not easy to access to ISA devices  Registers of I/O port and IRQ lines

The Plug-and-Play Specification  Relocatable I/O regions  PC BIOS is responsible for the relocation (like PCI)  Geographical addressing supported 64-bits Card Select Number, CSN  PnP detail See drivers/net/3c509.c

PC/104 and PC/104+  Pug-and-socket  The electrical and logical layout of the two buses is identical to ISA (PC/104) and PCI (PC/104+)

Other PC Buses  MCA (Micro Channel Architecture) ISA < MCA < PCI  EISA (Extended ISA)  VLB (VESA Local Bus) One of extended ISA  SBus Old Sparc Virual address Physical address, connecting to the MMU of CPU  NuBus Old Mac Drivers/nubus/nubus.c (reverse engineering)  External Buses USB, FireWire (IEEE 1394), and IEEE 1284