summaryrefslogtreecommitdiff
path: root/kernel/tty.c
AgeCommit message (Collapse)Author
2020-03-18Added decimal and octal conversion specifiers ('%d' and '%o') toJake Mannens
vsprintf(). Coverted all printk()/printf() functions to capatalised hex for readability. Tidied up some code.
2020-03-07Makefile now correctly calls i386 QEMU instead of x86_64Jake Mannens
Changed the type for block addresses from size_t to uint16_t. Added the '%c' conversion specifier to vsprintf(), so that it can now output individual characters passed as arguments. Added a an errno.h header containing a list of commonly used error codes, as well as a basic strerror() routine to fetch corresponding human-readable strings from a table. Implemented barebones floppy driver. Currently lacking many (essential) features, see TODO notes in floppy.c for more details. Buffer structs now have a b_present flag to indicate whether or not the data section is populated, as well as a b_wait element, as a queue for any tasks waiting on the buffer. All tasks waiting on a block wait in this queue, however, the task that originally called the driver to read, may wait in a separate queue maintained by the driver. This system may change in the future, and will likely depend on how head scheduling is implemented in the driver. The buffer_get_block() routine is now publically available in kernel/fs.h. It can be called to retrieve a block from the buffer cache (if readily available), or from the specified block device otherwise. This routine returns a pointer to the buffer containing the cache. The block_read() function now passes arguments and return values to the floppy driver regardless of the device specified. The block_write() function now indicates an error condition by setting b_device to zero in the allocated buffer structure, as no devices with write functionality currently exist. This behaviour will be updated in future, as more block devices are added. The mount_root() function has been modified to call buffer_get_block(), instead of calling block_read() directly. As of now, nothing should call block_read() or block_write() directly, as those functions are intended for use by the buffer subsystem only.
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.