nachos.machine
Class Coff

java.lang.Object
  extended by nachos.machine.Coff

public class Coff
extends Object

A COFF (common object file format) loader.


Field Summary
protected  int entryPoint
          The virtual address of the first instruction of the program.
protected  CoffSection[] sections
          The sections in this COFF executable.
 
Constructor Summary
protected Coff()
          Allocate a new Coff object.
  Coff(OpenFile file)
          Load the COFF executable in the specified file.
 
Method Summary
 void close()
          Close the executable file and release any resources allocated by this loader.
 int getEntryPoint()
          Return the program entry point.
 int getNumSections()
          Return the number of sections in the executable.
 CoffSection getSection(int sectionNumber)
          Return an object that can be used to access the specified section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entryPoint

protected int entryPoint
The virtual address of the first instruction of the program.


sections

protected CoffSection[] sections
The sections in this COFF executable.

Constructor Detail

Coff

protected Coff()
Allocate a new Coff object.


Coff

public Coff(OpenFile file)
     throws EOFException
Load the COFF executable in the specified file.

Notes:

  1. If the constructor returns successfully, the file becomes the property of this loader, and should not be accessed any further.
  2. The autograder expects this loader class to be used. Do not load sections through any other mechanism.
  3. This loader will verify that the file is backed by a file system, by asserting that read() operations take non-zero simulated time to complete. Do not supply a file backed by a simulated cache (the primary purpose of this restriction is to prevent sections from being loaded instantaneously while handling page faults).

Parameters:
file - the file containing the executable.
Throws:
EOFException - if the executable is corrupt.
Method Detail

getNumSections

public int getNumSections()
Return the number of sections in the executable.

Returns:
the number of sections in the executable.

getSection

public CoffSection getSection(int sectionNumber)
Return an object that can be used to access the specified section. Valid section numbers include 0 through getNumSections() - 1.

Parameters:
sectionNumber - the section to select.
Returns:
an object that can be used to access the specified section.

getEntryPoint

public int getEntryPoint()
Return the program entry point. This is the value that to which the PC register should be initialized to before running the program.

Returns:
the program entry point.

close

public void close()
Close the executable file and release any resources allocated by this loader.