Top Banner
X Ricardo A. Baratto NCL
25

X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Mar 28, 2015

Download

Documents

Skyler Lumbard
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

X

Ricardo A. Baratto

NCL

Page 2: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Overview

System overview

X protocol

X serverArchitecture

Porting process

XFree86 (device drivers)

Page 3: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

System Overview

HistoryCreated in 1984 in MIT.

X11 released on 1987 (latest R6.6 - April 2001)

The systemX clients (Xlib)

X protocol

X server

Page 4: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

System Overview (cont...)

FeaturesEvent Driven

Network Transparent

Device Independent

Policy Independent

Extensible

Page 5: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

X Protocol

Communication Client – ServerObject basedAsynchronousTypes of Messages:

Request (Client -> Server)ReplyEvent (Server -> Client)Error

Page 6: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

X Server

DoesProcess Output

Process Input

Extension Mechanism

Doesn’tDefine User Interface (X Toolkits)

Window Management (WM)

Each client responsible for its windows (Backing store)

Interpret input (Input Methods – Input Server)

Page 7: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

X Server (cont…)

Manages a DisplayScreens (physical monitor)

Input Devices

Everything is a windowCheap, unlimited

Tree structure

Root window: Complete screen

Top-level windows: main app window

Parent window clips children

Page 8: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

X Server Architecture

LayeredDIX: Device Independent

DDX: Device Dependent

Extensions

Everything controlled through resourcesScreens, GCs, windows, pixmaps, regions, colormaps, fonts, cursors

Created on demand

Used by clients to request operations -> Use ID

Page 9: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Dispatch LoopHeart of X server processing (DIX)

Process client requestsSend input events

Looks like:for(;;)

nready = WaitForSomething(…);while(nready--)

while(!isItTimeToYield)if(!ReadRequestFromClient(…))

break;(execute request);

Page 10: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Dispatch Loop (cont…)

Requests serviced round-robinExecs up to 10 requests from every client

ProblemsBusy client can monopolize server

select() not called often enough

Busy clients are not managed efficientlyselect() called too often

Page 11: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Dispatch Loop (cont…)

Fix: XFree86 smart schedulerUse time metric, not request-count metric

Dedicate time slice to each client

Gather many clients on every iterationPoll, don’t block

Delay yieldingGive clients a second chance

Prioritize clientsPenalize busy, praise user preferred

Page 12: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Screens

One for each physical screen

ScreenRec structure

Defines functions used to handle operations on resources

Main communication channel DIX-DDX

Page 13: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Drawables

Where drawing takes place

WindowsUsed for display output

May have own colormap

PixmapsOff-screen – own depth

Used to speed up operations

Page 14: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Graphic Contexts

Describe how to drawColors (fg, bg), fonts, line width, …

Normally set up once, used by manyStored in server

Requests specify GC, drawable and what to draw

Page 15: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Porting X Server

Code layersDIX -> Dev.Independent, don’t touch

OS -> OS specific

DDX -> Graphics Device specific

Extensions -> Add features

Porting Layer: OS + DDX

Porting process:Define functions required by DIX to handle resources

Page 16: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

OS Layer

Maintain client connections

Schedule work to be done for clientsIgnore/AttendClient()

File and memory managementFonts stored in files

Xalloc()/Xrealloc()/Xfree()

Page 17: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

WaitForSomething()

Input events from user or hardwareSetInputCheck()

Requests pending from existing clientsReadRequestFromClient()

New clientAccess control -> ClientAuthorized()

Create it -> NextAvailableClient()

Page 18: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

DDX Layer

Input ProcessingMouse movement

Key presses

Key mappings

Graphics Display

Page 19: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Graphics Output

Pixel based

Screen basic data structure

Manage all resources

Output done on drawables

Pixel data format defined by DDX

Pixmap format constant across screens

XYPixmap -> one bitmap for each plane

Zpixmap -> series of pixel values

Pixel values interpreted at display time

Page 20: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Output Initialization

InitOutput()Process arguments

Discover screensAddScreen()

Initialize pixmap formats

Additional implementation dependent stuff

Page 21: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

DDX Drawables

FieldsSerial number, depth, size and position

Procedures to manipulate them

Private DDX data

PixmapsRectangular array of pixel values

Reference counted

Bitmaps are depth-1

Page 22: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

DDX Drawables (cont…)

WindowsVisible rectangle on screenBorder drawn by DDX

Create, move, resize

Contents drawn by clientExpose EventsServer may provide backing storeBit gravity (resizing)

Clipped by parent and sibbling windows

Page 23: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

DDX 2D Graphics

Procedures for drawing primitivesLines, arcs, arc filling, text drawing

Clients may allow DDX optimizationse.g. Zero-width lines

GC defines how to draw primitivesMay use MI functions

Need only define basic Pixblit routinesRead/write pixel values & deal with image data

Page 24: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

XFree86 Device Drivers

Life’s easierAnother abstraction layer

Most previous procedures already defined

Drivers are loadable modulesNeed not distribute/recompile whole server

Module format X specificOS/Architecture independent

Additional formats supported (dlopen())

Page 25: X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)

Device Drivers (cont…)

Define only device specific routinesDiscovery of devices (PCI/ISA access)Device Initialization

Device Drivers have access to ScreenRecCan redefine resource proceduresOptimize for display hardware

Sample VGA device driverProvides basic functionality usable by others

Interface still unstable