nachos.machine
Class StandardConsole

java.lang.Object
  extended by nachos.machine.StandardConsole
All Implemented Interfaces:
SerialConsole

public class StandardConsole
extends Object
implements SerialConsole

A text-based console that uses System.in and System.out.


Constructor Summary
StandardConsole(Privilege privilege)
          Allocate a new standard console.
 
Method Summary
protected  int in()
          Attempt to read a byte from the object backing this console.
protected  void out(int value)
          Write a byte to the object backing this console.
 int readByte()
          Return the next unsigned byte received (in the range 0 through 255).
 void setInterruptHandlers(Runnable receiveInterruptHandler, Runnable sendInterruptHandler)
          Set this console's receive and send interrupt handlers.
 void writeByte(int value)
          Send another byte.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardConsole

public StandardConsole(Privilege privilege)
Allocate a new standard console.

Parameters:
privilege - encapsulates privileged access to the Nachos machine.
Method Detail

setInterruptHandlers

public final void setInterruptHandlers(Runnable receiveInterruptHandler,
                                       Runnable sendInterruptHandler)
Description copied from interface: SerialConsole
Set this console's receive and send interrupt handlers.

The receive interrupt handler is called every time another byte arrives and can be read using readByte().

The send interrupt handler is called every time a byte sent with writeByte() is finished being sent. This means that another byte can be sent.

Specified by:
setInterruptHandlers in interface SerialConsole
Parameters:
receiveInterruptHandler - the callback to call when a byte arrives.
sendInterruptHandler - the callback to call when another byte can be sent.

in

protected int in()
Attempt to read a byte from the object backing this console.

Returns:
the byte read, or -1 of no data is available.

readByte

public final int readByte()
Description copied from interface: SerialConsole
Return the next unsigned byte received (in the range 0 through 255).

Specified by:
readByte in interface SerialConsole
Returns:
the next byte read, or -1 if no byte is available.

out

protected void out(int value)
Write a byte to the object backing this console.

Parameters:
value - the byte to write.

writeByte

public final void writeByte(int value)
Description copied from interface: SerialConsole
Send another byte. If a byte is already being sent, the result is not defined.

Specified by:
writeByte in interface SerialConsole
Parameters:
value - the byte to be sent (the upper 24 bits are ignored).