Presentation is loading. Please wait.

Presentation is loading. Please wait.

SICvm A SIC Based Virtual Machine

Similar presentations


Presentation on theme: "SICvm A SIC Based Virtual Machine"— Presentation transcript:

1 SICvm A SIC Based Virtual Machine
Prepared by Anoop U.Thomas V Hariharan Hari Sankar S Santhosh N.Raju

2 SICvm – A SIC Based Virtual Machine
Introduction In this project we aim to develop a Virtual Machine The Machine will be based on the Hypothetical Machine described by Leland L.Beck in System Software called Simplified Instructional Computer (SIC) SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

3 A Background on Virtual Machines
The term virtual machine is used to refer to the environment created by an emulator, where software is used to emulate an operating system for the end user. Church–Turing thesis - implies that any operating environment can be emulated within any other. In practice, it can be quite difficult, particularly when the exact behavior of the system to be emulated is not documented and has to be deduced through reverse engineering SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

4 How to Achieve Virtualization ?
This can be done using three major ways: Full Virtualization — the virtual machine simulates the complete hardware, allowing an unmodified OS for a completely different CPU to be run. Paravirtualization — the virtual machine does not simulate hardware but instead offers a special API that requires OS modifications. Native Virtualization — the virtual machine only partially simulates enough hardware to allow an unmodified OS to be run in isolation, but the guest OS must be designed for the same type of CPU. In order to achieve Virtualization we need to have two things. A Virtual Machine (VM) A Virtual Machine Monitor (VMM) SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

5 SICvm – A SIC Based Virtual Machine
A Background On SIC Simplified Instructional Computer (SIC) is a hypothetical computer described in Leland Beck's book System Software. Most real microprocessors have lots of quirks built-in to increase efficiency. SIC provides a much simplified view of systems hardware from the perspective of systems programmer SIC has two versions, a standard version, SIC, and an extended version, SIC/XE. SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

6 SICvm – A SIC Based Virtual Machine
The SIC Architecture Memory: Word size: 3 bytes (24 bits) Total size: 32,768 bytes (215). Thus any memory address will need at most 15 bits to be referenced ('almost' four hex characters) Registers: Total Registers: Five Accumulator (A): Used for most of the operations (number 0) Index (X): Used for indexed addressing (number 1) Linkage (L): Stores return addresses for JSUB (number 2) Program Counter (PC): Address for next instruction (number 8) Status Word (SW): Information and condition codes (number 9). SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

7 The SIC Architecture (Continued…)
Instruction Formats: Opcode: First 8 bits, direct translation from the Operation Code Table Flag (x): next bit indicates address mode (0 direct - 1 indexed) Address: next 15 bits, indicate address of operand according to address mode. Addressing Modes: Only two possible addressing modes Direct (x = 0): operand address goes as it is Indexed (x = 1): value to be added to the value stored at the register x to obtain real address of the operand. OPCODE X ADDRESS SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

8 Why Choose SIC To Make A Virtual Machine ?
SIC is a generic view point of a system, that is simple to develop and implement compared to architectures like x86 etc The SIC architecture is pretty flexible and extendible to other architectures just by simple modifications. This can be achieved in the VM by simple code modifications SIC machine is used as a study tool for systems programming and this VM helps the better understanding of this machine SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

9 SICvm – A SIC Based Virtual Machine
The Planning Process Virtual Machines can be designed in two ways High Level Emulation (Top Down Approach) Low Level Emulation (Bottom Up Approach) We choose Low Level Emulation The system to be developed was not a very complex system The operational details of the system was known in detail SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

10 Issues Faced In The Planning Process
We couldn’t get enough detailed documentation on how to develop a Virtual Machine Existing projects like Bochs and Xen were too complex and large to be studied in the given short period of time SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

11 The Development Process
The Development Process is divided into 3 Stages Development of SICvm – The Virtual Machine Development of the SIC Assembler Development of the Essential System Programs for SIC SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

12 Tools Used in Development of SICvm
gcc – The GNU compiler collection make utility gdb – The GNU Debugger emacs, vi etc – Text Editing Windows / Linux Operating System Environment was used in development SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

13 SICvm – A SIC Based Virtual Machine
The SICvm Machine Usually an emulator is divided into modules that correspond roughly to the emulated computer's subsystems. In our SICvm we have the following modules A CPU emulator or CPU simulator (the two terms are mostly interchangeable) A memory subsystem module The I/O devices emulators Buses are not emulated in SICvm SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

14 SICvm – A SIC Based Virtual Machine
The CPU Emulator In any virtual machine this is the most complicated part to emulate We have implemented an interpreter based CPU Emulation The logic of the simulated CPU can then more or less be directly translated into software algorithms, creating a software re-implementation that basically mirrors the original hardware implementation. SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

15 The CPU Implementation Details
Each regsiter is emulated using variables The CPU accomplishes basic fetch using the fetch() function that does 3 types of fetch Opcode fetch (1 Cycle) Operand fetch (2 Cycles) Data fetch (3 Cycles) Device Code fetch (1 Cycle Byte fetch) The CPU accomplished storing using a store() fuctions that does the storing of variables from registers to memory locations. This always does a 3 cycle operation The execute () function executes the instructions SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

16 The CPU Implementation Details (Continued…)
Basic CPU Operation was implemented using the following algorithm do { check Interrupts; opval = fetch (OPCODE); switch (opval) { case ADD: case MUL: case SUB: case DIV: operand = fetch (opval); execute (ARITHMETIC, opval, operand) break; case (logical instructions): …… case (load-store instructions): …… case (I/O Instructions): …… } } while (opval != HLT); SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

17 SICvm – A SIC Based Virtual Machine
The Memory Subsystem It is possible for the memory subsystem emulation to be reduced to simply an array of elements The SICvm has 1 MB of memory //Memory Declaration unsigned char *mem; //Allocate Memory Dynamically mem = (unsigned char*) malloc (MEMSIZE); The memory is segmented into System area (from 0x00000 to 0x00FFF) and User area (from 0x01000 to 0xFFFFF) The memory is accessed by the fetch () and store () fuctions. Direct memory access is also done by STCH and LDCH instructions SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

18 The Memory Subsystem (Continued…)
//Standard fetch function int fetch (int type) { int temp; switch (type) { //OPCODE fetching Logic case OPCODE: get opcode; return opcode; //OPERAND fetch Logic case OPERAND: get operand; return operand; //DATA fetch Logic case DATA: get data; return data; //Device Code Fetch Logic case DEVCODE: get devcode; return devcode; } return -1; //Standard store function void store (int reg) { int temp; //Store the 1st 8 bits temp = reg & 0xFF0000; temp = temp >> 16; mem[operand++] = temp; //Store the 2nd 8 bits temp = reg & 0xFF00; temp = temp >> 8; //Store the 3rd 8 bits temp = reg & 0xFF; mem[operand] = temp; } SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

19 The Memory Subsystem (Continued…)
Registers Memory Address Contents 1000 454F xxxxxx xxxxxxxx 1010 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx A X L PC SW OPCODE OPERAND DATA One Cycle Fetch Two Cycle Fetch Three Cycle Fetch SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

20 SICvm – A SIC Based Virtual Machine
The I/O Subsystem The current version of SICvm supports input devices and output devices The input devices are numbered F1, F2, … The output devices are numbered 01, 02, ... Special device 00 is the Boot ROM that contains the bootstrap loader Special device F0 is standard input (Keyboard) Special device A0 is standard output (Monitor) All other devices are represented as files in the running operating system with the prefix “DEV” Device Access Delays are emulated for actual device behaviour SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

21 The SICvm Architecture
SICvm’s Memory DEV00 (ROM) DEVA0 (Monitor) SICvm CPU DEVF0 (Keyboard) DEV06 DEVF1 SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

22 Interrupt Handling In SICvm
All Interrupts in SICvm are generated in the Emulated Hardware Level Interrupts are generated when errors (like division by zero) are found. Currently on detecting an interrupt the system goes into a HALT state and prevents further execution SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

23 Interrupts Defined in SICvm
Interrupts in SICvm are defined in “interrupt.h” INT_OVF //Overflow Interrupt INT_DIVZERO //Divide by Zero Interrupt INT_SEGFAULT //Segmentation Fault INT_INVALID //Invalid Instruction INT_BADMEM //Insufficient Memory INT_DEVERR //Bad or Inaccessible Device INT_BADBOOT //DEV00 Not found INT_BADLOAD //DEVF1 Not found INT_OUTOFMEM 8 //Memory Range out of Bounds INT_NONE //No Interrupts Set SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

24 SICvm – A SIC Based Virtual Machine
The Assembler The machine code for SIC is generated using a standard 2 Pass assembler as described in Leland L.Beck In order to support additional features few modifications were made to the assembler Support for the HLT instruction Support to generate bootstrap code Support to generate loader code Support for Immediate Indexed Addressing An External OPTAB.TXT for adding extra instructions The assembler is also accompanied by a macroprocessor if any macro expansion is required SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

25 Essential SIC Softwares
In order for the SIC Virtual Machine to work we needed essential system software A Bootstrap loader to be placed in DEV00 An Absolute Loader to load normal SIC programs into SICvm’s memory. Placed in DEVF1 A Shell in order to communicate with the SIC hardware in DEVF2 SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

26 The Bootstrap Loader Design
The bootstrap loader is based on Beck’s Bootstrap Loader mentioned in System Software Algorithm: read character while (1) { if (character != EOF) { convert to hex representation move byte to memory location increment location counter } else { goto memory location 0x80 } } SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

27 SICvm – A SIC Based Virtual Machine
The Loader Design The loader design algorithm is again borrowed from Beck’s System Software The loader implemented is an absolute loader Algorithm: read Header record verify Header read First Text record while (record type != ‘E’) { convert character object code to hex form move object code to specified location read next object program record } jump to specified address SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

28 SICvm – A SIC Based Virtual Machine
The Shell Design In order to make the SIC machine more interactive we designed a minimal shell to interact with the machine The current shell can interpret 3 commands Load from a device Execute the loaded program Quit the shell Algorithm: while (1) { get input from keyboard switch (input) { case ‘l’: invoke loader and load from dev break; case ‘e’: jump to currently loaded program address case ‘q’: jump to HLT } } SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

29 The Hierarchical Structure
SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

30 SICvm Features Demonstration
Now we will demonstrate various features of SICvm

31 Summary of Various Features
The Machine runs on the standard ASCII set (refer Appendix B of System Software by Leland L.Beck) The VM currently supports 5 Devices. 1 ROM device (DEV00), 3 Input Devices (DEVF1, DEVF2, DEVF3) and 1 Output Device (DEV06). The machine can work with up to 2 Devices (1 Input and 1 Output) simultaneously. Dynamic Memory dump of the machine can be shown on the screen. Supports 1 MB of Memory Space, Out of bounds error detection Introduced HLT instruction (opcode 0x76) for stopping program after execution. Introduced Interrupt handling to handle exceptions and error that is detected during the runtime of the program SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

32 Summary of Various Features (Continued…)
Introduction of 2 special devices F0 (standard input) and A0 (standard output) so that SIC machine can use Keyboard and Monitor Devices Developed a Minimal Shell to communicate with SIC Machine Directly Introduced Immediate Indexed Mode Addressing Runs programs in both user mode and supervisor mode Has the ability to work with 2 Devices (1 Input and 1 Output) Simultaneously Memory Management, In form of segmentation Advanced I/O device handling like emulating device delays Ability to run on both Linux and Windows Platform SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

33 Features Currently Underdevelopment
Introduction of clocking to CPU Introduction of a display device for SIC Extension of current machine to support SIC / XE Architecture A Full fledged working shell / operating environment for the machine A Dynamically Debuggable interactive interface A Virtual Machine Monitor for the SICvm SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

34 SICvm – A SIC Based Virtual Machine
Conclusion Provide developers a quick guide in understanding and developing emulators and virtual machines Easy Extensibility to support various Exisiting and non existing Machine Architectures Helping aid for students of computer science and engineering, especially when dealing with Systems programming as they will have an environment for developing and testing programs that are written for SIC SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

35 SICvm – A SIC Based Virtual Machine
References Leland L.Beck - System Software Hopcroft and Ullmann - Theory of Computation Hennesy and Patterson - Computer Organization and Design (Used in Referring General Computer Hardware Organization) A.K Ray - Advanced Microprocessors (Used In Studying of implementation of Segments in 8086) Dennis Ritche and Brian W.Kernigham - The C Programming Language (General Programming References) How to: Writing a computer Emulator (General Emulator Programming References) Wikipedia – (General Reference) SICvm – A SIC Based Virtual Machine sicvm.sourceforge.net

36 Any Questions or Queries
Thank You Any Questions or Queries


Download ppt "SICvm A SIC Based Virtual Machine"

Similar presentations


Ads by Google