Main Page   Compound List   File List   Compound Members   File Members  

machine.h File Reference

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

Go to the source code of this file.

Compounds

class  Instruction
class  Machine

Defines

#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
}

Functions

void ExceptionHandler (ExceptionType which)
unsigned int WordToHost (unsigned int word)
unsigned short ShortToHost (unsigned short shortword)
unsigned int WordToMachine (unsigned int word)
unsigned short ShortToMachine (unsigned short shortword)


Define Documentation

#define BadVAddrReg   39
 

Definition at line 70 of file machine.h.

Referenced by Machine::RaiseException.

#define HiReg   32
 

Definition at line 63 of file machine.h.

Referenced by Machine::DumpState, and Machine::OneInstruction.

#define LoadReg   37
 

Definition at line 68 of file machine.h.

Referenced by Machine::DelayedLoad, Machine::DumpState, and Machine::OneInstruction.

#define LoadValueReg   38
 

Definition at line 69 of file machine.h.

Referenced by Machine::DelayedLoad, Machine::DumpState, and Machine::OneInstruction.

#define LoReg   33
 

Definition at line 64 of file machine.h.

Referenced by Machine::DumpState, and Machine::OneInstruction.

#define MemorySize   (NumPhysPages * PageSize)
 

Definition at line 36 of file machine.h.

Referenced by Machine::Machine, and Machine::Translate.

#define NextPCReg   35
 

Definition at line 66 of file machine.h.

Referenced by Machine::DumpState, AddrSpace::InitRegisters, and Machine::OneInstruction.

#define NumGPRegs   32
 

Definition at line 62 of file machine.h.

Referenced by Machine::DumpState.

#define NumPhysPages   32
 

Definition at line 35 of file machine.h.

Referenced by AddrSpace::AddrSpace, and Machine::Translate.

#define NumTotalRegs   40
 

Definition at line 72 of file machine.h.

Referenced by AddrSpace::InitRegisters, Machine::Machine, Machine::ReadRegister, and Machine::WriteRegister.

#define PageSize   SectorSize
 

Definition at line 31 of file machine.h.

Referenced by AddrSpace::AddrSpace, AddrSpace::InitRegisters, and Machine::Translate.

#define PCReg   34
 

Definition at line 65 of file machine.h.

Referenced by Machine::DumpState, AddrSpace::InitRegisters, and Machine::OneInstruction.

#define PrevPCReg   36
 

Definition at line 67 of file machine.h.

Referenced by Machine::DumpState, and Machine::OneInstruction.

#define RetAddrReg   31
 

Definition at line 61 of file machine.h.

Referenced by Machine::DumpState.

#define StackReg   29
 

Definition at line 60 of file machine.h.

Referenced by Machine::DumpState, and AddrSpace::InitRegisters.

#define TLBSize   4
 

Definition at line 37 of file machine.h.

Referenced by Machine::Machine, and Machine::Translate.


Enumeration Type Documentation

enum ExceptionType
 

Enumeration values:
NoException 
SyscallException 
PageFaultException 
ReadOnlyException 
BusErrorException 
AddressErrorException 
OverflowException 
IllegalInstrException 
NumExceptionTypes 

Definition at line 39 of file machine.h.

Referenced by ExceptionHandler, Machine::RaiseException, Machine::ReadMem, and Machine::WriteMem.

00039                    { NoException,           // Everything ok!
00040                      SyscallException,      // A program executed a system call.
00041                      PageFaultException,    // No valid translation found
00042                      ReadOnlyException,     // Write attempted to page marked 
00043                                             // "read-only"
00044                      BusErrorException,     // Translation resulted in an 
00045                                             // invalid physical address
00046                      AddressErrorException, // Unaligned reference or one that
00047                                             // was beyond the end of the
00048                                             // address space
00049                      OverflowException,     // Integer overflow in add or sub.
00050                      IllegalInstrException, // Unimplemented or reserved instr.
00051                      
00052                      NumExceptionTypes
00053 };


Function Documentation

void ExceptionHandler ExceptionType    which
 

Definition at line 52 of file exception.cc.

References NumExceptionTypes.

00053 {
00054     int type = machine->ReadRegister(2);
00055 
00056     if ((which == SyscallException) && (type == SC_Halt)) {
00057         DEBUG('a', "Shutdown, initiated by user program.\n");
00058         interrupt->Halt();
00059     } else {
00060         printf("Unexpected user mode exception %d %d\n", which, type);
00061         ASSERT(FALSE);
00062     }
00063 }

unsigned short ShortToHost unsigned short    shortword
 

Definition at line 56 of file translate.cc.

00056                                       {
00057 #ifdef HOST_IS_BIG_ENDIAN
00058          register unsigned short result;
00059          result = (shortword << 8) & 0xff00;
00060          result |= (shortword >> 8) & 0x00ff;
00061          return result;
00062 #else 
00063          return shortword;
00064 #endif /* HOST_IS_BIG_ENDIAN */
00065 }

unsigned short ShortToMachine unsigned short    shortword
 

Definition at line 71 of file translate.cc.

00071 { return ShortToHost(shortword); }

unsigned int WordToHost unsigned int    word
 

Definition at line 42 of file translate.cc.

References AddressErrorException, BusErrorException, IllegalInstrException, OverflowException, and ReadOnlyException.

00042                               {
00043 #ifdef HOST_IS_BIG_ENDIAN
00044          register unsigned long result;
00045          result = (word >> 24) & 0x000000ff;
00046          result |= (word >> 8) & 0x0000ff00;
00047          result |= (word << 8) & 0x00ff0000;
00048          result |= (word << 24) & 0xff000000;
00049          return result;
00050 #else 
00051          return word;
00052 #endif /* HOST_IS_BIG_ENDIAN */
00053 }

unsigned int WordToMachine unsigned int    word
 

Definition at line 68 of file translate.cc.

00068 { return WordToHost(word); }


Generated on Mon Feb 10 09:54:50 2003 for nachos by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees