A look at memory issues Data-transfers must occur between system memory and the network interface controller.

Slides:



Advertisements
Similar presentations
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
Advertisements

The ATA/IDE Interface Can we write a character-mode device driver for the hard disk?
Khaled A. Al-Utaibi  Computers are Every Where  What is Computer Engineering?  Design Levels  Computer Engineering Fields  What.
Dr A Sahu Dept of Comp Sc & Engg. IIT Guwahati. PCI Devices NIC Cards NIC card architecture Access to NIC register – PCI access.
Programming Super-VGA Graphics Devices Introduction to VESA graphics modes and to organization of the linear frame-buffer memory.
The Linux PCI Interface An introduction to the PCI configuration space registers.
Linux Memory Issues An introduction to some low-level and some high-level memory management concepts.
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
The RealTek interface Introduction to the RTL-8139 network controller registers.
Timeout for some demos An instructive look at how the Linux Operating System sets up system data-structures.
Accessing network hardware The Network Interface Controllers are part of a larger scheme used in modern PCs for device control.
Memory Management (II)
Exploring a modern NIC An introduction to programming the Intel 82573L gigabit ethernet network interface controller.
“Virtual” Memory How does the OS kernel provide “private” and “shared” memory areas to multiple concurrent processes?
CE6105 Linux 作業系統 Linux Operating System 許 富 皓. Chapter 2 Memory Addressing.
04/16/2010CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying an earlier edition.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Linux Memory Issues Introduction. Some Architecture History 8080 (late-1970s) 16-bit address (64-KB) 8086 (early-1980s) 20-bit address (1-MB) (mid-’80s)
Managing physical memory
Detecting PCI devices On identifying the peripheral equipment installed in our PC.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
The IDE/ATA Interface How can our mini-Operating System, executing in protected mode, access the hard disk?
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display.
OPERATING SYSTEMS Introduction
Introduction to the Intel x86’s support for “virtual” memory
What’s needed to transmit? A look at the minimum steps required for programming our anchor nic’s to send packets.
On 64-bit ‘code-relocation’ How we can launch a procedure in 64-bit mode that resides in a page-frame at a high address.
Linux Memory Management How does the Linux kernel keep track of the Virtual Memory Areas that each process uses?
Accessing the NIC A look at the mechanisms that software can use to interact with our 82573L network interface.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Chapter 5 Computer Organization ( 計算機組織 ). Distinguish between the three components of a computer hardware. List the functionality of each component.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Copyright ©: Nahrstedt, Angrave, Abdelzaher
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Instructor: Yuzhuang Hu Memory Hierarchy.
Memory Addressing in Linux  Logical Address machine language instruction location  Linear address (virtual address) a single 32 but unsigned integer.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Ethernet Driver Changes for NET+OS V5.1. Design Changes Resides in bsp\devices\ethernet directory. Source code broken into more C files. Native driver.
CS 6560 Operating System Design Lecture 8: Memory Management.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
January 10, Kits Workshop 1 Washington WASHINGTON UNIVERSITY IN ST LOUIS A Smart Port Card Tutorial --- Software John DeHart Washington University.
Computer Organization & Assembly Language © by DR. M. Amer.
80386DX functional Block Diagram PIN Description Register set Flags Physical address space Data types.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
10. Epilogue ENGI 3655 Lab Sessions.  We took control of the computer as early as possible, right after the end of the BIOS  Our multi-stage bootloader.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
ECE 456 Computer Architecture Lecture #9 – Input/Output Instructor: Dr. Honggang Wang Fall 2013.
Linux Boot Process on the Raspberry Pi 2 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis,
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT Operating Systems.
Homework Reading Machine Projects Labs
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
Operating Systems (CS 340 D)
Memory Management References text: Tanenbaum ch.4.
CS 286 Computer Organization and Architecture
The PCI bus (Peripheral Component Interconnect ) is the most commonly used peripheral bus on desktops and bigger computers. higher-level bus architectures.
CS703 - Advanced Operating Systems
CSCI 315 Operating Systems Design
Memory Management References text: Tanenbaum ch.4.
Operating Systems Chapter 5: Input/Output Management
Introduction to the Intel x86’s support for “virtual” memory
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Presentation transcript:

A look at memory issues Data-transfers must occur between system memory and the network interface controller

Typical Chipset Layout MCH Memory Controller Hub (Northbridge) ICH I/O Controller Hub (Southbridge) CPU Central Processing Unit DRAM Dynamic Random Access Memory NIC Network Interface Controller HDC Hard Disk Controller AC Audio Controller Graphics Controller TimerKeyboardMouseClock Multimedia Controller Firmware Hub USB controller

Typical Chipset Layout MCH Memory Controller Hub (Northbridge) ICH I/O Controller Hub (Southbridge) CPU Central Processing Unit DRAM Dynamic Random Access Memory NIC Network Interface Controller HDC Hard Disk Controller AC Audio Controller Graphics Controller TimerKeyboardMouseClock Multimedia Controller Firmware Hub USB controller DMA

PCI Bus Master DMA 82573L i/o-memory RX and TX FIFOs (32-KB total) Host’s Dynamic Random Access Memory Descriptor Queue packet-buffer DMA on-chip RX descriptors on-chip TX descriptors

Memory-mapped I/O We mentioned that Intel’s x86 architecture originally was designed with two separate address-spaces, one for memory and the other for I/O ports, unlike the designs for CPUs by many of Intel’s competitors in which I/O access was “memory-mapped” But now the newer Intel processors also can support memory-mapped I/O as well

Address-bus widths The Intel Core-2 Quad processors in our classroom and Lab machines potentially could address 2 36 physical memory cells (i.e., 64GB), although only 4GB of RAM actually are installed at the present time Some PCI-compliant hardware devices were designed for a 32-bit address-bus, thus they must be “mapped” below 4G

Physical-address assignments The CPU’s physical address-space Devices’ registers must be mapped to addresses in the bottom 4G Dynamic Random Access Memory

Virtual addresses Software running on the x86 processor is unable to use actual memory addresses, but instead uses ‘virtual’ addresses that map to physical addresses by means of mapping-tables which Linux dynamically defines for each different process it runs This complicates the steps software must take to arrange for the DMA to take place

Our ‘dram.c’ module To help us confirm that our hardware-level network software is working as we intend, or to diagnose our ‘bugs’ if it isn’t, we can use an LKM we’ve written that implements a character-mode device-driver for system memory, allowing us to view the contents of physical memory as if it were a file; for example, by using our ‘fileview.cpp’ tool

How to view system memory Download ‘dram.c’ from course website Compile it using our ‘mmake’ utility Install ‘dram.ko’ by using ‘/sbin/insmod Insure the ‘/dev/dram’ device-node exists Download ‘fileview.cpp’ from website and compile it with ‘g++’ (or with ‘make’) Execute ‘fileview /dev/dram’ and use the arrow-keys to navigate (or hit )

“canonical” addresses “non-canonical” (invalid) virtual addresses “canonical” addresses 0xFFFFFFFFFFFFFFFF … 0xFFFF x00007FFFFFFFFFFF … 0x Analogy using 5-bit values 64-bit “vrtual” address space

4-Levels of mapping Page Map Level-4 Table CR3 Page Directory Pointer Table Page Directory Page Table Page Frame (4KB) offset 64-bit ‘canonical’ virtual address sign-extension PML4PDPTPDIRPTBL Each mapping-table contains up to 512 quadword-size entries

4-level address-translation The CPU examines any virtual address it encounters, subdividing it into five fields offset into page-frame index into page-table bits9-bits12-bits index into page- directory index into page- directory pointer table index into level 4 page-map table 9-bits sign- extension Any 48-bit virtual-address is sign-extended to a 64-bit “canonical” address Only “canonical” 64-bit virtual-addresses are legal in 64-bit mode

Reserved (must be 0) Format of 64-bit table-entries Page-frame physical base-address[31..12] Page-frame physical base-address [39..32] EXBEXB PWU PWTPWT PCDPCD A avl Meaning of these bits varies with the table Legend: P = Present (1=yes, 0=no)PWT = Page Cache Disable (1=yes, 0=no) W = Writable (1=yes, 0=no)PWT = Page Write-Through (1=yes, 0=no) U = User-page (1=yes, 0=no) avl = available for user-defined purposes A = Accessed (1=yes, 0=no) EXB = Execution-disabled Bit (if EFER.NXE=1)

Our ‘mem64.c’ module We wrote an LKM to create a pseudo-file that will let us see how the virtual memory is being utilized by an application program Download this file, compile it with ‘mmake’ and install ‘mem64.ko’ in the Linux kernel Then view the virtual-memory mapping that is being used by the ‘cat’ program: $ cat /proc/mem64

The NIC’s PCI ‘resources’ Status Register Command Register DeviceID 0x109A VendorID 0x8086 BIST Cache Line Size Class Code Class/SubClass/ProgIF Revision ID Base Address 0 Subsystem Device ID Subsystem Vendor ID CardBus CIS Pointer reserved capabilities pointer Expansion ROM Base Address Minimum Grant Interrupt Pin reserved Latency Timer Header Type Base Address 1 Base Address 2Base Address 3 Base Address 4Base Address 5 Interrupt Line Maximum Latency doublewords Dwords

Mechanisms compared kernel memory-space NIC i/o-memory CPU’s ‘virtual’ address-space io user memory-space Each NIC register has its own address in memory (allows one-step access) addrdata Access to all of the NIC’s registers is muliplexed through a pair of I/O-ports (requires multiple instructions) CPU’s ‘I/O’ address-space

‘nicstatus.c’ Here’s an LKM that creates a pseudo-file (called ‘/proc/nicstatus’) which will allow a user to view the current value in our Intel 82573L Network Interface Controller’s ‘DEVICE_STATUS’ register It uses the I/O-port interface to the NIC’s registers, rather than a ‘memory-mapped’ interface to those device-registers

0 Device Status (0x0008) ? GIO Master EN PHY RA ASDV ILOSILOS SLUSLU 0 TX OFF 0 FDFD Function ID LULU SPEED FD = Full-Duplex LU = Link Up TXOFF = Transmission Paused SPEED (00=10Mbps,01=100Mbps, 10=1000Mbps, 11=reserved) ASDV = Auto-negotiation Speed Detection Value PHYRA = PHY Reset Asserted 82573L some undocumented functionality?

‘82573.c’ This is a more elaborate example of an LKM which not only creates a pseudo-file (i.e., ‘/proc/82573’) that we can view using the Linux ‘cat’ command and that lets us see our NIC’s PCI Configuration Space, but also implements some device-driver functions that let us view the NIC’s device registers by using our ‘fileview.cpp’ tool

Linux PCI helper-functions #include struct pci_dev*devp; unsigned intmmio_base; unsigned intmmio_size; void*io; devp = pci_get_device( VENDOR_ID, DEVICE_ID, NULL ); if ( devp == NULL ) return –ENODEV; mmio_base = pci_resource_start( devp, 0 ); mmio_size = pci_resource_len( devp, 0 ); io = ioremap_nocache( mmio_base, iomm_size ); if ( io == NULL ) return –ENOSPC;

In-class exercise Two of the NIC’s 32-bit device registers are used to hold its 48-bit Ethernet MAC address – which will be a different value for each of the hosts in our classroom These two registers are located at offsets 0x5400 and 0x5404 in device-memory The six bytes occur in network byte-order Write code to show the MAC address!