MP3 1.0
This is the Doxygen document for ECE391 MP3.
Loading...
Searching...
No Matches
Macros | Functions | Variables
terminal.h File Reference

Header files for terminal.c. More...

#include "types.h"
#include "keyboard.h"
#include "lib.h"

Go to the source code of this file.

Macros

#define MAX_NUM_TERMINALS   (3)
 
#define X_POS   (0)
 
#define Y_POS   (1)
 

Functions

int terminalRead (int32_t fd, void *buf, int32_t nbytes)
 Start recording key presses. Ends when enter is pressed. More...
 
int terminalWrite (int32_t fd, const void *buf, int32_t nbytes)
 Write output arg buffer to the screen. More...
 
int terminalOpen (const uint8_t *filename)
 Open Terminal. More...
 
int terminalClose (int32_t fd)
 Close terminal. More...
 
void swapTerminal (uint8_t terminalNum)
 Swaps the active terminal to the specified terminal number. More...
 
void initTerminal ()
 Initializes the terminal. More...
 

Variables

char terminalBuf [MAX_NUM_TERMINALS][KEYBOARD_BUF_SIZE]
 2D array so each terminal has their own buffer More...
 
char cursorPos [MAX_NUM_TERMINALS][2]
 2D array holding the cursor position for each terminal. More...
 
int volatile activeTerminal
 ID of the active (currently displayed) terminal. More...
 
int executingTerminalID
 Terminal ID for the current active process. More...
 
int8_t terminalPIDArray [MAX_NUM_TERMINALS]
 

Detailed Description

Header files for terminal.c.

Author
Group 8
Version
1.0
Date
2023-03-17

Macro Definition Documentation

◆ MAX_NUM_TERMINALS

#define MAX_NUM_TERMINALS   (3)

◆ X_POS

#define X_POS   (0)

◆ Y_POS

#define Y_POS   (1)

Function Documentation

◆ initTerminal()

void initTerminal ( )

Initializes the terminal.

This function initializes the terminal by setting up the page tables for video memory, and clearing the terminal screen for each terminal. It also initializes the terminal PID array and the cursor location.

Note
Should only be called in kernel.c.

This function initializes the terminal by setting up the page tables for video memory, and clearing the terminal screen for each terminal. It also initializes the terminal PID array and the cursor location.

Note
Should only be called in kernel.c.

◆ swapTerminal()

void swapTerminal ( uint8_t  terminalNum)

Swaps the active terminal to the specified terminal number.

This function performs a swap between the current active terminal and the specified terminal. It handles memory copying, updating cursors, changing the page table, and initializes the new terminal by running a new shell if it doesn't exist.

Parameters
terminalNumThe terminal number to swap to (0, 1, or 2).
Note
This function assumes it runs within a critical section, since it is only called within keyboardInterrupt.
Warning
This function only supports 3 terminals associated with numbers 0, 1, and 2.

This function performs a swap between the current active terminal and the specified terminal. It handles memory copying, updating cursors, changing the page table, and initializes the new terminal by running a new shell if it doesn't exist.

Parameters
terminalNumThe terminal number to swap to (0, 1, or 2).
Note
This function assumes it runs within a critical section, since it is only called within keyboardInterrupt.
Warning
This function only supports 3 terminals associated with numbers 0, 1, and 2.

◆ terminalClose()

int terminalClose ( int32_t  fd)

Close terminal.

Parameters
fdNot used.
Returns
0
Note
Does nothing.
Parameters
fdNot used.
Returns
0
Note
Does nothing.

◆ terminalOpen()

int terminalOpen ( const uint8_t filename)

Open Terminal.

Parameters
filenameNot used.
Returns
0
Note
Does nothing.
Parameters
filenameNot used.
Returns
0
Note
Does nothing.

◆ terminalRead()

int terminalRead ( int32_t  fd,
void *  buf,
int32_t  nbytes 
)

Start recording key presses. Ends when enter is pressed.

Parameters
fdNot used.
bufWhere the bytes read will be stored.
nbytesNumber of bytes to read.
Returns
-1 on failure.
Number of bytes read.
Note
The args read will be stored in buf.
See also
terminalBuf
Parameters
fdNot used.
bufWhere the bytes read will be stored.
nbytesNumber of bytes to read.
Returns
-1 on failure.
Number of bytes read.
Note
The args read will be stored in buf.
See also
terminalBuf

◆ terminalWrite()

int terminalWrite ( int32_t  fd,
const void *  buf,
int32_t  nbytes 
)

Write output arg buffer to the screen.

Parameters
fdNot used.
bufBuffer to write to the screen.
nbytesNumber of bytes to write.
Returns
0 on success.
-1 on failure.
Parameters
fdNot used.
bufBuffer to write to the screen.
nbytesNumber of bytes to write.
Returns
0 on success.
-1 on failure.

Variable Documentation

◆ activeTerminal

int volatile activeTerminal

ID of the active (currently displayed) terminal.

◆ cursorPos

char cursorPos[MAX_NUM_TERMINALS][2]

2D array holding the cursor position for each terminal.

◆ executingTerminalID

int executingTerminalID

Terminal ID for the current active process.

◆ terminalBuf

2D array so each terminal has their own buffer

◆ terminalPIDArray

int8_t terminalPIDArray[MAX_NUM_TERMINALS]