XenevaOS
Loading...
Searching...
No Matches
Functions | Variables
tty.c File Reference
#include <Fs\tty.h>
#include <Fs\vfs.h>
#include <Fs\dev\devfs.h>
#include <_null.h>
#include <Mm\kmalloc.h>
#include <string.h>
#include <stdio.h>
#include <process.h>
#include <Hal/AA64/sched.h>
#include <aucon.h>
Include dependency graph for tty.c:

Functions

void AuTTYInsert (TTY *tty)
 AuTTYInsert – insert a new tty to tty list.
 
void AuTTYDelete (TTY *tty)
 AuTTYDelete – remove a tty from the tty list.
 
void AuTTYWriteSlave (TTY *tty, uint8_t c)
 AuTTYWriteSlave – writes a character to to slave tty.
 
void AuTTYWriteMaster (TTY *tty, uint8_t c)
 AuTTYWriteMaster – writes a character to master tty.
 
void AuTTYProcessLine (TTY *tty, uint8_t c)
 AuTTYProcessLine – Line Discipline layer.
 
size_t AuTTYMasterRead (AuVFSNode *fs, AuVFSNode *file, uint64_t *buffer, uint32_t len)
 AuTTYMasterRead – vfs read callback for master tty.
 
size_t AuTTYMasterWrite (AuVFSNode *fs, AuVFSNode *file, uint64_t *buffer, uint32_t len)
 AuTTYMasterWrite – writing to master goes to slave buffer.
 
size_t AuTTYSlaveRead (AuVFSNode *fsys, AuVFSNode *file, uint64_t *buffer, uint32_t len)
 
size_t AuTTYSlaveWrite (AuVFSNode *fsys, AuVFSNode *file, uint64_t *buffer, uint32_t len)
 AuTTYSlaveWrite — writing to slave goes to master buffer.
 
int AuTTYSlaveClose (AuVFSNode *fs, AuVFSNode *file)
 
int AuTTYMasterClose (AuVFSNode *fs, AuVFSNode *file)
 
int AuTTYIoControl (AuVFSNode *file, int code, void *arg)
 
AuVFSNodeAuTTYCreateMaster (TTY *tty)
 AuTTYCreateMaster – create a master tty end and mount it to device directory.
 
AuVFSNodeAuTTYCreateSlave (TTY *tty)
 AuTTYCreateSlave – create a slave tty end and mount it to device directory.
 
int AuTTYCreate (int *master_fd, int *slave_fd)
 AuTTYCreate – create tty syscall for process.
 
void AuTTYInitialise ()
 AuTTYInitialise – initialize the TTY kernel resource.
 

Variables

size_t master_count = 0
 master_count – internal count value of total master tty
 
size_t slave_count = 0
 slave_count – internal slave tty count
 
TTYroot = NULL
 
TTYlast = NULL
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2025, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ AuTTYCreate()

int AuTTYCreate ( int *  master_fd,
int *  slave_fd 
)

AuTTYCreate – create tty syscall for process.

Parameters
master_fd– Pointer to memory area where to store master file descriptor
slave_fd– Pointer to memory area where to store slave file descriptor
Returns
1 on success and -1 on failure

◆ AuTTYCreateMaster()

AuVFSNode * AuTTYCreateMaster ( TTY tty)

AuTTYCreateMaster – create a master tty end and mount it to device directory.

Parameters
tty– pointer to tty device
Returns
pointer to newly created tty file

◆ AuTTYCreateSlave()

AuVFSNode * AuTTYCreateSlave ( TTY tty)

AuTTYCreateSlave – create a slave tty end and mount it to device directory.

Parameters
tty– pointer to tty device
Returns
pointer to newly created slave tty file

◆ AuTTYDelete()

void AuTTYDelete ( TTY tty)

AuTTYDelete – remove a tty from the tty list.

Parameters
tty– Pointer to the tty to delete

◆ AuTTYInitialise()

void AuTTYInitialise ( )

AuTTYInitialise – initialize the TTY kernel resource.

◆ AuTTYInsert()

void AuTTYInsert ( TTY tty)

AuTTYInsert – insert a new tty to tty list.

Parameters
tty– Pointer to newly created tty

◆ AuTTYIoControl()

int AuTTYIoControl ( AuVFSNode file,
int  code,
void *  arg 
)

@breif AuTTYIoControl – vfs io control callback for tty

Parameters
file– Pointer to tty file
code– control code
arg– Pointer to user data
Returns
requested value on success, -1 on failure

◆ AuTTYMasterClose()

int AuTTYMasterClose ( AuVFSNode fs,
AuVFSNode file 
)

◆ AuTTYMasterRead()

size_t AuTTYMasterRead ( AuVFSNode fs,
AuVFSNode file,
uint64_t buffer,
uint32_t  len 
)

AuTTYMasterRead – vfs read callback for master tty.

Parameters
fs– Pointer to current file system
file– Pointer to tty file
buffer– Pointer to buffer to read onto
len– total length in bytes to read
Returns
return the amount of bytes read

◆ AuTTYMasterWrite()

size_t AuTTYMasterWrite ( AuVFSNode fs,
AuVFSNode file,
uint64_t buffer,
uint32_t  len 
)

AuTTYMasterWrite – writing to master goes to slave buffer.

Parameters
fs– Pointer to current file system
file– Pointer to tty file
buffer– Pointer to buffer to write to
len– to length in bytes to write
Returns
return amount of data written in bytes

◆ AuTTYProcessLine()

void AuTTYProcessLine ( TTY tty,
uint8_t  c 
)

AuTTYProcessLine – Line Discipline layer.

Parameters
tty– Pointer to current tty
c– character to process

◆ AuTTYSlaveClose()

int AuTTYSlaveClose ( AuVFSNode fs,
AuVFSNode file 
)

◆ AuTTYSlaveRead()

size_t AuTTYSlaveRead ( AuVFSNode fsys,
AuVFSNode file,
uint64_t buffer,
uint32_t  len 
)

◆ AuTTYSlaveWrite()

size_t AuTTYSlaveWrite ( AuVFSNode fsys,
AuVFSNode file,
uint64_t buffer,
uint32_t  len 
)

AuTTYSlaveWrite — writing to slave goes to master buffer.

Parameters
fsys– self explanatory
file– self explanatory
buffer– self explanatory
len– self explanatory
Returns
return the amount of data written in bytes

◆ AuTTYWriteMaster()

void AuTTYWriteMaster ( TTY tty,
uint8_t  c 
)

AuTTYWriteMaster – writes a character to master tty.

Parameters
tty– Pointer to the tty where to write
c– character to write

◆ AuTTYWriteSlave()

void AuTTYWriteSlave ( TTY tty,
uint8_t  c 
)

AuTTYWriteSlave – writes a character to to slave tty.

Parameters
tty– Pointer to the tty where to write
c– character to write

Variable Documentation

◆ last

TTY* last = NULL

◆ master_count

size_t master_count = 0

master_count – internal count value of total master tty

◆ root

TTY* root = NULL

◆ slave_count

size_t slave_count = 0

slave_count – internal slave tty count