nachos.kernel.userprog
Class NoffHeader

java.lang.Object
  extended by nachos.kernel.userprog.NoffHeader

 class NoffHeader
extends java.lang.Object

A NoffHeader object is the kernel representation of the header portion of a NOFF executable file. It contains information about the three segments (code, initialized data, uninitialized) data in the file, which is needed for initializing a user address space.


Nested Class Summary
(package private) static class NoffHeader.NoffSegment
          A NoffSegment object contains information about one segment of a NOFF executable file.
 
Field Summary
(package private)  NoffHeader.NoffSegment code
          Information about the executable code segment.
(package private)  NoffHeader.NoffSegment initData
          Information about the initialized data segment.
(package private) static int noffMagic
          Magic number found at the beginning of a NOFF file.
(package private)  NoffHeader.NoffSegment uninitData
          Information about the "uninitialized" data segment, which must be zeroed before use.
 
Constructor Summary
private NoffHeader()
          Private constructor, to force use of readHeader() to initialize a NoffHeader.
 
Method Summary
private static boolean checkMagic(OpenFile f)
          Read a word from a file and check that it matches noffMagic.
private static int convertByte(byte raw)
          Take bytes read from the file and interpret them as unsigned rather than signed values.
private static int convertWord(byte[] raw)
          Take four bytes read from the file and assemble them into an unsigned integer.
(package private) static NoffHeader readHeader(OpenFile f)
          Initialize a NoffHeader object by reading its values from a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

noffMagic

static final int noffMagic
Magic number found at the beginning of a NOFF file. It permits the kernel to immediately reject files that are definitely not executable.

See Also:
Constant Field Values

code

NoffHeader.NoffSegment code
Information about the executable code segment.


initData

NoffHeader.NoffSegment initData
Information about the initialized data segment.


uninitData

NoffHeader.NoffSegment uninitData
Information about the "uninitialized" data segment, which must be zeroed before use.

Constructor Detail

NoffHeader

private NoffHeader()
Private constructor, to force use of readHeader() to initialize a NoffHeader.

Method Detail

convertByte

private static int convertByte(byte raw)
Take bytes read from the file and interpret them as unsigned rather than signed values.

Parameters:
raw - A raw byte read from the file.
Returns:
The value of the byte when it is interpreted as an unsigned integer quantity.

convertWord

private static int convertWord(byte[] raw)
Take four bytes read from the file and assemble them into an unsigned integer.

Parameters:
raw - The four bytes read from the file.
Returns:
The value of the four bytes when interpreted as an unsigned integer.

checkMagic

private static boolean checkMagic(OpenFile f)
Read a word from a file and check that it matches noffMagic.

Parameters:
f - The file to read.
Returns:
true if the word read matches noffMagic, false if it does not or a word could not be read from the file.

readHeader

static NoffHeader readHeader(OpenFile f)
Initialize a NoffHeader object by reading its values from a file.