nachos.machine
Class CoffSection

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

public class CoffSection
extends Object

A CoffSection manages a single section within a COFF executable.


Field Summary
protected  Coff coff
          The COFF object to which this section belongs.
protected  boolean executable
          True if this section contains code.
protected  int firstVPN
          The first virtual page number used by this section.
static int headerLength
          The length of a COFF section header.
protected  boolean initialized
          True if this section contains initialized data.
protected  String name
          The COFF name of this section.
protected  int numPages
          The number of virtual pages in this section.
protected  boolean readOnly
          True if this section is read-only.
 
Constructor Summary
protected CoffSection(Coff coff, String name, boolean executable, boolean readOnly, int numPages, int firstVPN)
          Allocate a new COFF section with the specified parameters.
  CoffSection(OpenFile file, Coff coff, int headerOffset)
          Load a COFF section from an executable.
 
Method Summary
 Coff getCoff()
          Return the COFF object used to load this executable instance.
 int getFirstVPN()
          Return the first virtual page number used by this section.
 int getLength()
          Return the length of this section in pages.
 String getName()
          Return the name of this section.
 boolean isInitialzed()
          Test whether this section is initialized.
 boolean isReadOnly()
          Test whether this section is read-only.
 void loadPage(int spn, int ppn)
          Load a page from this segment into physical memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coff

protected Coff coff
The COFF object to which this section belongs.


name

protected String name
The COFF name of this section.


executable

protected boolean executable
True if this section contains code.


readOnly

protected boolean readOnly
True if this section is read-only.


initialized

protected boolean initialized
True if this section contains initialized data.


numPages

protected int numPages
The number of virtual pages in this section.


firstVPN

protected int firstVPN
The first virtual page number used by this section.


headerLength

public static final int headerLength
The length of a COFF section header.

See Also:
Constant Field Values
Constructor Detail

CoffSection

protected CoffSection(Coff coff,
                      String name,
                      boolean executable,
                      boolean readOnly,
                      int numPages,
                      int firstVPN)
Allocate a new COFF section with the specified parameters.

Parameters:
coff - the COFF object to which this section belongs.
name - the COFF name of this section.
executable - true if this section contains code.
readOnly - true if this section is read-only.
numPages - the number of virtual pages in this section.
firstVPN - the first virtual page number used by this.

CoffSection

public CoffSection(OpenFile file,
                   Coff coff,
                   int headerOffset)
            throws EOFException
Load a COFF section from an executable.

Parameters:
file - the file containing the executable.
headerOffset - the offset of the section header in the executable.
Throws:
EOFException - if an error occurs.
Method Detail

getCoff

public Coff getCoff()
Return the COFF object used to load this executable instance.

Returns:
the COFF object corresponding to this section.

getName

public String getName()
Return the name of this section.

Returns:
the name of this section.

isReadOnly

public boolean isReadOnly()
Test whether this section is read-only.

Returns:
true if this section should never be written.

isInitialzed

public boolean isInitialzed()
Test whether this section is initialized. Loading a page from an initialized section requires a disk access, while loading a page from an uninitialized section requires only zero-filling the page.

Returns:
true if this section contains initialized data in the executable.

getLength

public int getLength()
Return the length of this section in pages.

Returns:
the number of pages in this section.

getFirstVPN

public int getFirstVPN()
Return the first virtual page number used by this section.

Returns:
the first virtual page number used by this section.

loadPage

public void loadPage(int spn,
                     int ppn)
Load a page from this segment into physical memory.

Parameters:
spn - the page number within this segment.
ppn - the physical page to load into.