summaryrefslogtreecommitdiff
path: root/kernel/rs.s
diff options
context:
space:
mode:
authorJake Mannens <jake72360@gmail.com>2018-08-06 00:32:06 +1000
committerJake Mannens <jake72360@gmail.com>2018-08-06 00:32:06 +1000
commit3ed830019561a06b0cb98f792cc447a157fd4ef2 (patch)
tree08d6bcd81a84881a8158752e73a144f2989253f8 /kernel/rs.s
parent8e933fac9fd068343bb602f13175c8d70a6c5768 (diff)
Defined ssize_t in unistd.h.
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.
Diffstat (limited to 'kernel/rs.s')
-rw-r--r--kernel/rs.s25
1 files changed, 25 insertions, 0 deletions
diff --git a/kernel/rs.s b/kernel/rs.s
new file mode 100644
index 0000000..9f3d4a6
--- /dev/null
+++ b/kernel/rs.s
@@ -0,0 +1,25 @@
+global rs_isr
+extern rs_handler
+extern rsputs
+
+rs_isr:
+ pusha
+ mov ax, ds
+ push ax
+ mov ax, 0x10
+ mov ds, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+
+ call rs_handler
+ mov al, 0x20
+ out 0x20, al
+
+ pop ax
+ mov ds, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+ popa
+ iret