summaryrefslogtreecommitdiff
path: root/kernel/tty.c
AgeCommit message (Collapse)Author
2018-10-09Added the f_inode element to struct file as a pointer to the file'sJake Mannens
inode in memory. Added a jump instruction in front of the multiboot header so that the kernel may be run as a binary image. The jump instruction will skip over the multiboot header to the beginning of the kernel's startup procedure in kboot. Moved the call to initialize the timer to earlier in the boot sequence. This is to allow for some drivers that may require it's functionality during the startup to function properly. Added functionality for the 'fast-gate' to the enable_a20 subroutine. Now, if the keyboard controller method fails when enabling the gate, an attempt is made to enable the A20 gate using the PS/2's fast-gate interface. If this also fails, the kernel will panic. Implemented TTY output for the console. The console is now TTY device 0 (the default for new userspace programs).
2018-09-01Removed the sys_puts system call in favour of calls to tty_write().Jake Mannens
Removed the rsputs() function in favour of calls to tty_write(). Corrected a bug in the serial driver and TTY subsystem where a full buffer wouldn't be detected. This was caused by a missing set of brackets on several operations involving the modulus operator. Added the ability for the serial driver to automatically take data from the TTY device's write buffer and push it to the serial port. This can happen in one of two ways; 1) the TTY subsystem notifies the serial driver of new data by calling the write() function pointer in the tty_struct or, 2) the serial port issues an interrupt signalling that it has finished sending data prompting the driver to check the buffers for any more pending data.
2018-08-26Updated the style of the code in lib/string.c to conform to the rest ofJake Mannens
the project. Added the system call 'sys_panic' as well as the corresponding library function panic() whose prototype is defined in unistd.h. This is to allow userspace programs to deliberately crash the kernel for the purpose of debugging. Added the element 'write' as a function pointer in the tty_struct structure. The purpose of this function pointer is to provide a means for the TTY subsystem to notify the device driver of any newly added data to the write queue. Added the tty_write() function to the TTY subsystem. This function will copy data provided by the user into the specified TTY device's write queue, blocking if the queue's buffer is full. tty_write() will then call the driver's write() function to notify it of new data. Added the rsint_tx() function to the serial driver to handle transmit interrupts by re-supplying the UART's transmit FIFO.
2018-08-22Added the header file limits.h which contains one definition forJake Mannens
SSIZE_MAX which is needed to limit the number of bytes read() will transfer. Laid the foundation for a TTY subsystem. This works by taking the previously used buffer and r/w pointers concept and implements it as a 'tty_queue' struct. The struct 'tty_struct' is used to represent a TTY device. This struct currently contains three elements; a read queue for data flowing from the device to the user, a write queue for data flowing from the user to the device and a function pointer to an init function. The latter element will reduce complexity by allowing the TTY subsystem to initialize each TTY device driver (when it's ready), rather than each driver having to be initialized during bootup. Each TTY device is implemented as a pointer to a tty_struct. The structures are defined separately by each driver as well as tracked and maintained by pointers in the table 'ttys' in tty.c. Modified the RS232 serial driver to make use of the new TTY subsystem for transferring data to the user. Currently, write calls are still handled manually through the rsputs() function though this will change in future. Modified the read() system call to direct read calls to the TTY subsystem which will further direct the call to the appropriate TTY device driver. The serial driver's interrupt routine now uses the wake_up() function to wake processes blocking for serial data. This is to ensure the scheduler is notified of the wakeup. This function is the preferred method for waking processes since accessing the task state field directly may not be possible in the future and is discouraged. The reason for this is that the scheduler's behaviour may change to require being notified of task wakeup events in the future.