Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

machine.h File Reference

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

Go to the source code of this file.

Compounds

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! The procedures in this class are defined in machine.cc, mipssim.cc, and translate.cc. More...


Defines

#define StackReg   29
 User's stack pointer. More...

#define RetAddrReg   31
 Holds return address for procedure calls. More...

#define NumGPRegs   32
 32 general purpose registers on MIPS. More...

#define HiReg   32
 Double register to hold multiply result. More...

#define LoReg   33
#define PCReg   34
 Current program counter. More...

#define NextPCReg   35
 Next program counter (for branch delay). More...

#define PrevPCReg   36
 Previous program counter (for debugging). More...

#define LoadReg   37
 The register target of a delayed load. More...

#define LoadValueReg   38
 The value to be loaded by a delayed load. More...

#define BadVAddrReg   39
 The failing virtual address on an exception. More...

#define NumTotalRegs   40

Enumerations

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

Functions

void ExceptionHandler (ExceptionType which)
 Entry point into Nachos for handling user system calls and exceptions Defined in exception.cc. More...

unsigned int WordToHost (unsigned int word)
unsigned short ShortToHost (unsigned short shortword)
unsigned int WordToMachine (unsigned int word)
unsigned short ShortToMachine (unsigned short shortword)

Variables

const int PageSize = 128
 set the page size equal to the disk sector size, for simplicity. More...

const int NumPhysPages = 32
const int MemorySize = (NumPhysPages * PageSize)
const int TLBSize = 4
 if there is a TLB, make it small. More...


Define Documentation

#define BadVAddrReg   39
 

The failing virtual address on an exception.

Definition at line 68 of file machine.h.

#define HiReg   32
 

Double register to hold multiply result.

Definition at line 61 of file machine.h.

#define LoReg   33
 

Definition at line 62 of file machine.h.

#define LoadReg   37
 

The register target of a delayed load.

Definition at line 66 of file machine.h.

#define LoadValueReg   38
 

The value to be loaded by a delayed load.

Definition at line 67 of file machine.h.

#define NextPCReg   35
 

Next program counter (for branch delay).

Definition at line 64 of file machine.h.

#define NumGPRegs   32
 

32 general purpose registers on MIPS.

Definition at line 60 of file machine.h.

#define NumTotalRegs   40
 

Definition at line 70 of file machine.h.

#define PCReg   34
 

Current program counter.

Definition at line 63 of file machine.h.

#define PrevPCReg   36
 

Previous program counter (for debugging).

Definition at line 65 of file machine.h.

#define RetAddrReg   31
 

Holds return address for procedure calls.

Definition at line 59 of file machine.h.

#define StackReg   29
 

User's stack pointer.

Definition at line 58 of file machine.h.


Enumeration Type Documentation

enum ExceptionType
 

Enumeration values:
NoException   Everything ok!
SyscallException   A program executed a system call.
PageFaultException   No valid translation found.
ReadOnlyException   Write attempted to page marked "read-only".
BusErrorException   Translation resulted in an invalid physical address.
AddressErrorException   Unaligned reference or one that was beyond the end of the address space.
OverflowException   Integer overflow in add or sub.
IllegalInstrException   Unimplemented or reserved instr.
NumExceptionTypes  

Definition at line 37 of file machine.h.


Function Documentation

void ExceptionHandler ( ExceptionType which )
 

Entry point into Nachos for handling user system calls and exceptions Defined in exception.cc.

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!

"which" is the kind of exception. The list of possible exceptions are in machine.h.

Definition at line 57 of file exception.cc.

unsigned short ShortToHost ( unsigned short shortword )
 

Definition at line 54 of file translate.cc.

unsigned short ShortToMachine ( unsigned short shortword )
 

Definition at line 69 of file translate.cc.

unsigned int WordToHost ( unsigned int word )
 

Definition at line 40 of file translate.cc.

unsigned int WordToMachine ( unsigned int word )
 

Definition at line 66 of file translate.cc.


Variable Documentation

const int MemorySize = (NumPhysPages * PageSize)
 

Definition at line 34 of file machine.h.

const int NumPhysPages = 32
 

Definition at line 33 of file machine.h.

const int PageSize = 128
 

set the page size equal to the disk sector size, for simplicity.

Definition at line 30 of file machine.h.

const int TLBSize = 4
 

if there is a TLB, make it small.

Definition at line 35 of file machine.h.


Generated at Wed Jul 4 11:32:22 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001