emulation - ES40 Emulator

advertisement
Developing a Portable,
Open Source Alpha Emulator
Camiel Vanderhoeven
OpenVMS Advanced Technical Bootcamp
May 18-23, Nashua, NH
Topics
1.
2.
3.
4.
5.
6.
Emulation
ES40 Emulator
Current problem areas
Portability and Open-source
Become involved
Questions?
1. Emulation
What it is
 When to use it
 How to do it

Emulation: Definition
An emulator duplicates (provides an emulation
of) the functions of one system using a different
system, so that the second system behaves like
(and appears to be) the first system. This focus
on exact reproduction of external behavior is in
contrast to some other forms of computer
simulation, which can concern an abstract model
of the system being simulated.
(Wikipedia)
Emulation
Application
OpenVMS (Alpha)
AlphaServer
Emulation
Application
OpenVMS (Alpha)
AlphaServer
Emulation
Migration
Application
OpenVMS (Alpha)
Integrity Server
AlphaServer
Emulation
Migration
Application
OpenVMS
(Integrity)
OpenVMS (Alpha)
Integrity Server
AlphaServer
Emulation
Migration
Application
(after
recompilation)
Application
OpenVMS
(Integrity)
OpenVMS (Alpha)
Integrity Server
AlphaServer
Emulation
Migration
Application
(after
recompilation)
Application
OpenVMS
(Integrity)
OpenVMS (Alpha)
Integrity Server
AlphaServer
Emulation
Migration
Emulation
Application
(after
recompilation)
Application
OpenVMS
(Integrity)
OpenVMS (Alpha)
Integrity Server
AlphaServer
ES40 Emulator
Emulation
Migration
Emulation
Application
(after
recompilation)
Application
OpenVMS
(Integrity)
OpenVMS (Alpha)
Integrity Server
AlphaServer
ES40 Emulator
Any OS
Any Hardware
Emulation
Migration
Emulation
Application
(after
recompilation)
Application
OpenVMS
(Integrity)
OpenVMS (Alpha)
OpenVMS (Alpha)
Integrity Server
AlphaServer
ES40 Emulator
Any OS
Any Hardware
Emulation
Migration
Emulation
Application
Application
Application
OpenVMS
(Integrity)
OpenVMS (Alpha)
OpenVMS (Alpha)
Integrity Server
AlphaServer
ES40 Emulator
(after
recompilation)
Any OS
Any Hardware
Emulation: Why?
Get rid of unsupported hardware
 Datacenter consolidation
 Reduce space, power requirements
(blades)

While:
 Protecting investment in software
Emulation: When?
Binary programs w/o source code
 Obsolete programming languages
 Software support for obsolete platform

Hands-On Education
 Scenario Testing

Emulation: How?

Get documentation on original system



Technical Reference Manuals
Study driver code (Linux, FreeBSD)
Beware of hidden features, bugs...

Analyse original system
 Reduce to logical requirements
 Implement in software
 Observe behaviour

And re-iterate...
2. ES40 Emulator
How it was done?
 ES40 Hardware Map
 Emulator Software Map

ES40: How?

Start with bare minimum:
CPU, SRM console firmware
 Chipset, memory
 Serial port


Then start adding:


IDE controller, disks
First boot, then add:

Rest of stuff (SCSI, NIC, VGA...)
ES40 Internals
How the hardware structure of the ES40
maps to the software structure of the
Emulator
System Block Diagram
Control
CChip
CPU
B-Cache
System Block Diagram
Control
Control
Control
Control
CChip
CPU
CPU
CPU
CPU
B-Cache
B-Cache
B-Cache
B-Cache
System Block Diagram
Control
Control
Control
Control
CChip
CPU
CPU
CPU
CPU
Memory
Data
8 DChips
Data
Data
Data
Data
Data
B-Cache
B-Cache
B-Cache
B-Cache
Two 256-bit
wide data
busses
Memory
System Block Diagram
Control
Control
Control
Control
CChip
8-bit TIG Bus
CPU
CPU
CPU
CPU
Memory
Data
8 DChips
Data
Data
Data
B-Cache
B-Cache
B-Cache
B-Cache
Data
Data
Memory
System Block Diagram
PChip
CAP Bus
CPU
CPU
CPU
CPU
64-bit PCI Bus
PAD Bus
Control
Control
Control
Control
PChip
64-bit PCI Bus
PAD Bus
CChip
8-bit TIG Bus
Memory
Data
8 DChips
Data
Data
Data
B-Cache
B-Cache
B-Cache
B-Cache
Data
Data
Memory
I/O Block Diagram
PChip0
CChip
PChip1
PCI 0
TIG-Bus
PCI 1
I/O Block Diagram
PChip0
PCI 0
Interrupt
Logic
CChip
PChip1
TIG-Bus
PCI 1
I/O Block Diagram
PChip0
PCI 0
Interrupt
Logic
CChip
PChip1
Flash
(NVRAM)
TIG-Bus
PCI 1
I/O Block Diagram
PChip0
PCI 0
Interrupt
Logic
CChip
PChip1
Flash
(NVRAM)
TIG-Bus
PCI 1
DIP
Switches
I/O Block Diagram
USB
ISA
Ali
Chipset
PChip0
PCI 0
Interrupt
Logic
CChip
PChip1
Flash
(NVRAM)
TIG-Bus
PCI 1
DIP
Switches
I/O Block Diagram
USB
Floppy
ISA
Ali
Chipset
PChip0
PCI 0
Interrupt
Logic
CChip
PChip1
Flash
(NVRAM)
TIG-Bus
PCI 1
DIP
Switches
I/O Block Diagram
USB
Floppy
ISA
Ali
Chipset
PChip0
PCI 0
Interrupt
Logic
CChip
PChip1
Flash
(NVRAM)
TIG-Bus
PCI 1
Serial,
LPT
DIP
Switches
I/O Block Diagram
USB
Floppy
ISA
Ali
Chipset
PChip0
PCI 0
Interrupt
Logic
CChip
PChip1
Flash
(NVRAM)
TIG-Bus
PCI 1
Serial,
LPT
DIP
Switches
TOY
I/O Block Diagram
USB
Floppy
CChip
PChip1
Keyboard,
Mouse
PCI 0
Interrupt
Logic
Flash
(NVRAM)
TIG-Bus
PCI 1
TOY
ISA
Ali
Chipset
PChip0
Serial,
LPT
DIP
Switches
I/O Block Diagram
USB
Ali
Chipset
PChip0
PCI 0
Interrupt
Logic
CChip
PChip1
Flash
(NVRAM)
TIG-Bus
PCI 1
Floppy
Serial,
LPT
TOY
ISA
IDE
CDROM
DIP
Switches
Keyboard,
Mouse
I/O Block Diagram
USB
Ali
Chipset
PChip0
CChip
Flash
(NVRAM)
TIG-Bus
SCSI
PChip1
PCI 1
Serial,
LPT
TOY
ISA
Keyboard,
Mouse
IDE
CDROM
PCI 0
Interrupt
Logic
Floppy
DIP
Switches
Disk
SCSI
Tape
I/O Block Diagram
USB
Ali
Chipset
PChip0
CChip
Flash
(NVRAM)
TIG-Bus
NIC
PChip1
PCI 1
Serial,
LPT
TOY
ISA
Keyboard,
Mouse
IDE
CDROM
PCI 0
Interrupt
Logic
Floppy
SCSI
DIP
Switches
Disk
SCSI
Tape
I/O Block Diagram
USB
Ali
Chipset
VGA
PChip0
CChip
Flash
(NVRAM)
TIG-Bus
NIC
PChip1
PCI 1
Serial,
LPT
TOY
ISA
Keyboard,
Mouse
IDE
CDROM
PCI 0
Interrupt
Logic
Floppy
SCSI
DIP
Switches
Disk
SCSI
Tape
Software structure
Device
CPU
System
(chipset)
Device
Function Calls
Device
.
Emulator Structure
CChips
DChips
Memory
PChips
Emulator Structure
CChips
DChips
Memory
PChips
CPU
.
Emulator Structure
Serial
CChips
DChips
Memory
PChips
CPU
.
Emulator Structure
7%
Interactive
Debugger
Serial
CChips
DChips
Memory
PChips
CPU
.
Emulator Structure
Telnet Port
7%
Interactive
Debugger
Serial
CChips
DChips
Memory
PChips
CPU
.
Emulator Structure
Telnet Port
7%
Interactive
Debugger
Serial
CChips
DChips
Memory
PChips
IDE
CPU
.
Emulator Structure
Telnet Port
7%
Interactive
Debugger
Serial
CChips
VGA
CPU
DChips
Memory
PChips
IDE
NIC
SCSI
.
Emulator Structure
Telnet Port
7%
Interactive
Debugger
Serial
CChips
VGA
CPU
DChips
Memory
PChips
IDE
NIC
SCSI
Image files
.
Raw devices
RAM disks
.
Emulator Structure
Telnet Port
7%
Interactive
Debugger
Serial
CChips
VGA
CPU
DChips
.
Memory
PChips
IDE
NIC
SCSI
Image files
.
Raw devices
RAM disks
PCAP
Emulator Structure
Telnet Port
7%
Interactive
Debugger
Serial
SDL
X11
win32
CChips
VGA
CPU
DChips
.
Memory
PChips
IDE
NIC
SCSI
Image files
.
Raw devices
RAM disks
PCAP
Emulator Structure
Telnet Port
7%
Interactive
Debugger
Serial
SDL
CPU
.
X11
win32
CChips
VGA
CPU
DChips
.
Memory
PChips
IDE
NIC
POCO Threading
SCSI
Image files
.
Raw devices
RAM disks
PCAP
3. Current Problem Areas
Current Problem Areas
Performance
 Floating-Point Instructions
 Multi-CPU Support
 Access/Alignment faults

Performance Issues...
Current: Interpretation
 Each instruction is decoded and executed
separately
 Lots of overhead
Check
Interrupt
Status
Update
Counters
Fetch
Instruction
Decode
Instruction
Execute
Single
Instruction
Performance Issues...
Performance has been increased already by:
Selective interrupt checking
Replacing often-used SRM PALcode routines
with C++ code
Disabling the Instruction Cache when it is not
needed
Optimizing the size of the Translation Buffers
and keeping MRU (Most Recently Used)
information
Performance Issues...
Check
Interrupt
Status
Update
Counters
Known
Block?
Execute
Code
Block
Future: Dynamic Translation
 Each instruction is decoded
once
Fetch
Instruction
Decode
Instruction
Translate
Instruction
Jump?
Dynamic Translation
Dynamic translation drawbacks:
 Very complex
 Host processor specific code (less
portable)
 Need to keep track of changed code
pages
For now:
 First get it working, then get it fast
$QIO
SCSI
I/O Request
Data
OpenVMS DK
(SCSI Disk Class) Driver
SCSI Command
I/O Request
SCSI response
Data
OpenVMS PK
(SCSI Port) Driver
SCRIPT
SCSI Messages
SCSI Command
I/O Request
SCSI Messages
SCSI response
Data
EMULATED SCSI
CONTROLLER
SCSI Messages
SCSI Command
I/O Request
SCSI response
Data
EMULATED SCSI DISK
I/O Request
Data
FILESYSTEM, RAM DISK or
RAW DEVICE
$QIO
SCSI
I/O Request
$QIO
Data
OpenVMS DK
(SCSI Disk Class) Driver
SCSI Command
I/O Request
I/O Request
Data
Replaced DK Driver
SCSI response
Data
OpenVMS PK
(SCSI Port) Driver
Replaced PK Driver
SCRIPT
SCSI Messages
SCSI Command
I/O Request
SCSI Messages
SCSI response
Data
EMULATED SCSI
CONTROLLER
EMULATED SCSI
CONTROLLER
SCSI Messages
SCSI Command
I/O Request
SCSI response
Data
EMULATED SCSI DISK
I/O Request
Data
FILESYSTEM, RAM DISK or
RAW DEVICE
I/O Request
Data
EMULATED SCSI DISK
I/O Request
Data
FILESYSTEM, RAM DISK or
RAW DEVICE
Floating Point Problems

Floating-point implementation is complex





Emulations



5 different floating-point formats
In-memory format differs from in-register
Different rounding modes
Exception handling, denormals, infinity
“old” code: no exceptions, limited special values
“new” code: more complete, but bugs
Having CPU-level test suite would really help!
Multiple-CPU problems





SRM startup may hang
Extra CPU’s are seen from SRM and
OpenVMS
CPU’s fail to initialize in SRM
CPU’s never make it into the active set in
OpenVMS
Solution probably buried somewhere in the
SRM specs or source code. Where should the
extra CPU’s wait for initialization?
Access/Alignment faults
Access faults occur during OpenVMS
installation, network bootup
 Alingment faults during boot when they
shouldn’t occur. Alignment checking is
turned off temporarily.

4. Portability and Open Source
Portability
Open
Source resources
SourceForge
Portability
Portability is helped through:
 Portable libraries:
Standard C/C++ libraries
 Poco (threads, locks, etc.)
 Pcap (networking)
 SDL (graphics)


Buildchain management
UNIX build scripts (autoconf, automake)
 Generated DCL build scripts

Open-Source Resources

Compilers etc.:
GNU compiler collection (gcc)
 GNU autotools (autoconf, automake)


Websites etc. (collaboration):
Usenet (newsgroups)
 SourceForge.net
 Ohloh.net (code metrics)
 Newsletters (like Sue’s)

SourceForge
SourceForge.net helps out with:
 Project Website
 Downloads
 Version Control
 Forums
 Bug Tracking
 Statistics
Downloads tracked by SourceForge
ES40: Codebase growth
80000
70000
60000
50000
40000
30000
20000
m
ar
-0
8
ap
r08
08
fe
b-
08
ja
n-
07
fe
b-
07
ja
n-
m
ar
-0
7
ap
r07
IDB
0
SCSI
IDE
Threads
NIC VGA OSX
NIC
oc
t-0
7
no
v07
de
c07
10000
Become Involved
Play with it
 Contribute
 Help us out

Become Involved: play with it
Download the emulator, and
 Let us know what you think,
 Let us know what you’d like,
 Let us know about bugs

Become Involved: contribute
Submit patches for bugs
 Submit new code (add devices, for
instance)
 Suggest better ways of doing things

Become Involved: help us out
Help us get hold of low-level
documentation or information
 Help us get hold of hardware to port to
(Anyone willing to donate a real ES40, or
an Integrity system?)

Questions?
Contact Information

http://www.es40.org/

e-mail: camiel@es40.org

Skype: iamcamiel
This presentation is Copyright (c) 2008 by the Camiel Vanderhoeven.
Website: http://es40.org
E-mail : camiel@es40.org
The information contained herein may be freely distributed. The OpenVMS Bootcamp NDA does not apply to this
presentation.
Permission is granted to copy, distribute and/or modify these documents under the terms of the GNU Free
Documentation License, Version 1.2 or (at your option) any later version published by the Free Software
Foundation.
The GNU Free Documentation License, version 1.2, can be found at http://gnu.org/licenses/fdl-1.2.html
Download