-
Notifications
You must be signed in to change notification settings - Fork 199
Terminal Input Output
Neelabh Gupta edited this page Apr 11, 2016
·
2 revisions
This page aims to provide a detailed overview of how typed characters are received, processed, and displayed on the terminal.
For other details of how jor1k works, check out the Technical details Wiki page.
Jor1k currently supports the following input devices:
- A "terminal input" device, which sends and receives data through UART
- An Opencores keyboard device
- A Virtio input device
The goal of the detailed description below is to better understand and document this process so that issue #26 can be addressed effectively.
- Jor1k master registers handlers for DOM input events ((master) system.js#L140)
- Terminal-Linux registers handler for
tty0/tty1
message from worker ((master) terminal-linux.js#L9) - Worker initializes the UART devices for each of the two TTYs and assigns them interrupt vectors ((worker) system.js#L140)
- The UART devices register handlers for
tty0/tty1
messages from master ((worker) uart.js#L79)
- On keyboard input, the master checks if a terminal was focused earlier ((master) system.js#L141)
- Master calls TerminalInput's
OnKeyPress/OnKeyDown/OnKeyUp
method ((master) system.js#L143) - TerminalInput transforms keys and calls master's
SendChars
method ((master) terminal-input.js#L34) -
SendChars
sends thetty0/tty1
message to worker with data ((master) system.js#L252) - UART receives the characters and pushes them into its receive buffer ((worker) uart.js#L118)
- UART raises interrupt (
UART_IIR_CTI
, signifying a character timeout) ((worker) uart.js#L123) - CPU handles interrupt ((worker) system.js#L223)
- ... CPU, OS stuff ...
- CPU writes to UART register using memory-mapped I/O ((worker) ram.js#L166)
- UART adds characters to transmit buffer ((worker) uart.js#L247)
- UART raises interrupt (
UART_IIR_THRI
, signifying that the transmitter holding register is empty, because the transmitter buffer is immediately emptied) ((worker) uart.js#L251) - UART empties the transmission buffer and sends its data with the
tty0/tty1
message to master ((worker) uart.js#L111) - Terminal-Linux calls Terminal's
PutChar
method ((master) terminal-linux.js#L11) -
PutChar
transforms and "prints" the message data to the DOM ((master) terminal.js#L736) - Terminal-Linux calls the optional
onCharReceived
callback function supplied by client code ((master) terminal.js#L835)