tac0S
Template Affectional Command Operating System
Classes | Macros | Enumerations | Functions
machine.h File Reference

Data structures for simulating the execution of user programs running on top of Nachos. More...

#include "copyright.h"
#include "utility.h"
#include "translate.h"
#include "disk.h"

Go to the source code of this file.

Classes

class  Instruction
 The following class defines an instruction, represented in both undecoded binary form decoded to identify operation to do registers to act on any immediate operand value. More...
 
class  Machine
 The following class defines the simulated host workstation hardware, as seen by user programs – the CPU registers, main memory, etc. User programs shouldn't be able to tell that they are running on our simulator or on the real hardware, except we don't support floating point instructions the system call interface to Nachos is not the same as UNIX (10 system calls in Nachos vs. 200 in UNIX!) If we were to implement more of the UNIX system calls, we ought to be able to run Nachos on top of Nachos! More...
 

Macros

#define PageSize   SectorSize
 
#define NumPhysPages   32
 
#define MemorySize   (NumPhysPages * PageSize)
 
#define TLBSize   4
 
#define StackReg   29
 
#define RetAddrReg   31
 
#define NumGPRegs   32
 
#define HiReg   32
 
#define LoReg   33
 
#define PCReg   34
 
#define NextPCReg   35
 
#define PrevPCReg   36
 
#define LoadReg   37
 
#define LoadValueReg   38
 
#define BadVAddrReg   39
 
#define NumTotalRegs   40
 

Enumerations

enum  ExceptionType {
  NoException, SyscallException, PageFaultException, ReadOnlyException,
  BusErrorException, AddressErrorException, OverflowException, IllegalInstrException,
  NumExceptionTypes, CharInsteadOfInt, IntOutOfBounds
}
 

Functions

void ExceptionHandler (ExceptionType which)
 ExceptionHandler Entry point into the Nachos kernel. Called when a user program is executing, and either does a syscall, or generates an addressing or arithmetic exception. More...
 
unsigned int WordToHost (unsigned int word)
 Routines for converting Words and Short Words to and from the simulated machine's format of little endian. These end up being NOPs when the host machine is also little endian (DEC and Intel).
 
unsigned short ShortToHost (unsigned short shortword)
 
unsigned int WordToMachine (unsigned int word)
 
unsigned short ShortToMachine (unsigned short shortword)
 

Detailed Description

Data structures for simulating the execution of user programs running on top of Nachos.

Author
Olivier Hureau, Hugo Feydel , Julien ALaimo User programs are loaded into "mainMemory"; to Nachos, this looks just like an array of bytes. Of course, the Nachos kernel is in memory too – but as in most machines these days, the kernel is loaded into a separate memory region from user programs, and accesses to kernel memory are not translated or paged.

In Nachos, user programs are executed one instruction at a time, by the simulator. Each memory reference is translated, checked for errors, etc.

DO NOT CHANGE – part of the machine emulation

Copyright (c) 1992-1993 The Regents of the University of California. All rights reserved. See copyright.h for copyright notice and limitation of liability and disclaimer of warranty provisions.

Function Documentation

void ExceptionHandler ( ExceptionType  which)

ExceptionHandler Entry point into the Nachos kernel. Called when a user program is executing, and either does a syscall, or generates an addressing or arithmetic exception.

For system calls, the following is the calling convention:

system call code – r2 arg1 – r4 arg2 – r5 arg3 – r6 arg4 – r7

The result of the system call, if any, must be put back into r2.

And don't forget to increment the pc before returning. (Or else you'll loop making the same system call forever!

Parameters
whichis the kind of exception. The list of possible exceptions are in machine.h.