summaryrefslogtreecommitdiff
path: root/include/kernel/con.h
AgeCommit message (Collapse)Author
2018-08-06Defined ssize_t in unistd.h.Jake Mannens
Added the _syscall2 macro to unistd.h to facilitate system calls that require two arguments to be passed. Modified the ATA driver to simply abort initialisation if a drive is not found, or cannot be configured. This will allow the kernel to function on a diskless system without invoking panic() unnecessarily. Added the functions irq_enable() and irq_disable() to asm/interrupt.h to make it easier for C code to mask and unmask IRQ's on each PIC. Moved the declaration for rsputs() from kernel/con.h to the new kernel/serial.h file since this is a function provided by the serial driver. Implemented a basic I/O input framework. This involves the new system call sys_read, which takes an I/O read request and directs it to the appropriate kernel handler function depending on the calling process' ctty value. This mechanism is identical to the sys_puts system call. Added the rsread() function to service sys_read calls from processes whose ctty value is equal to 1. This function will continually copy data from the serial buffer to the location specified. If there is not a sufficient amount of new data in the buffer to satisfy the request, the process is put into the TSTATE_UNINTERRUPTIBLE state and the scheduler is called to switch tasks. Prior to calling the scheduler, the function will set the waiting_task pointer to the calling process. This pointer will later be used by the interrupt handler to wake the process when new data arrives. Added an interrupt handler to service the IRQ4 (UART) interrupt. This subroutine is a stub which will save the machine's state then transfer control to rs_handler() in serial.c which will read bytes from the serial port and place them in a buffer. Before returning, rs_handler() checks the waiting_task pointer to see if a task is waiting for the newly received data and if so, it sets the task's state to TSTATE_RUNNING before resetting the pointer to NULL and returning. Ideally, the scheduler should be invoked at this point to select another task but since our basic round-robin scheduler currently has no concept of task priorities (and for the sake of simplicity), we will avoid invoking the scheduler in response to interrupts for now.
2018-08-01Defined EOF as -1 in stdio.h.Jake Mannens
Implemented the sprintf() library function in lib/stdio.c which uses the vsprintf() function. Implemented a very primative controlling TTY for each process. This is achieved by a switch in the sys_puts system call which uses the 'ctty' element of the process' task structure to determine an appropriate I/O channel. A negative ctty value doesn't equate to any I/O channel effectively disabling the process' output. Added the sys_ctty system call which allows a process to set it's own ctty value. Removed the sys_rsputs system call. Output to serial is now performed by the process first setting it's ctty value to 1, then invoking sys_puts.
2018-07-25Added missing prototype for puts() in stdio.h.Jake Mannens
Implemented a basic serial interface using COM0 which can be accessed with the system call sys_puts as well as the library functions rsputs() and rsprintf(). Renamed puts() in con.c to con_puts() and made the function static to avoid interference with the library function puts().
2018-07-08Added a printf() function to the library under stdio.c which uses theJake Mannens
vsprintf() function to render formatted strings and then the puts system call to output them. Moved the vsprintf() function from the kernel to the library. Furthermore, the prototype for the function has been moved from the kernel's headers, to the new header file stdio.h. Renamed the kernel's internal printf() function to printk() in order to avoid confusion with the library provided function. Renamed the sys_print system call to the more appropriate name, sys_puts. Added a new system call sys_time, which returns the system's uptime in seconds. This is mainly for testing the userspace binary and will not be permanent. Added the file time.c to the library which contains the caller for sys_time and a helper routine sleep() which delays execution for the specified number of seconds. The new header file time.h contains prototypes for both these functions as well as the definition for the type time_t. Fixed a bug in which the value of EAX was not properly passed to the system call handler, resulting in the wrong system call being executed. This was caused by the code in the SAVE macro not properly preserving the value. Fixed a bug in which the value of EAX was not preserved during a return from system call, but rather restored with the original EAX value prior to the call. As a result, system call return codes were not properly passed. This has been corrected by introducing a new macro RESTORE_SYS which carries out the same restore operations, but maintains EAX prior to the return.
2018-06-19Added foundation code to initialize the PIT and create a 10ms jiffiesJake Mannens
counter.
2018-06-17Cleaned up console I/O functions in con.c and con.h respectively.Jake Mannens
2018-06-16Initial commitJake Mannens