MP3 1.0
This is the Doxygen document for ECE391 MP3.
Loading...
Searching...
No Matches
Functions
terminal.c File Reference

Functions related with terminals. More...

#include "terminal.h"
#include "keyboard.h"
#include "lib.h"
#include "pcb.h"
#include "sys_call.h"
#include "i8259.h"

Functions

int terminalWrite (int32_t fd, const void *buf, int32_t nbytes)
 Write output arg buffer to the screen. More...
 
int terminalRead (int32_t fd, void *buf, int32_t nbytes)
 Start recording key presses. Ends when enter is pressed. 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...
 

Detailed Description

Functions related with terminals.

Author
Group 8
Version
1.0
Date
2023-03-17

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.

◆ 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.

◆ terminalClose()

int terminalClose ( int32_t  fd)

Close terminal.

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.

◆ 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

◆ 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.