summaryrefslogtreecommitdiff
path: root/include/asm
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 /include/asm
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 'include/asm')
-rw-r--r--include/asm/interrupt.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/asm/interrupt.h b/include/asm/interrupt.h
index d1ea6c1..1187fef 100644
--- a/include/asm/interrupt.h
+++ b/include/asm/interrupt.h
@@ -1,2 +1,29 @@
+#include <stdint.h>
+
+#define irq_enable(n) \
+ __asm__ volatile ( \
+ "inb $0xA1, %%al\n" \
+ "shl $8, %%ax\n" \
+ "inb $0x21, %%al\n" \
+ "xor $0xFFFF, %%bx\n" \
+ "and %%bx, %%ax\n" \
+ "outb %%al, $0x21\n" \
+ "shr $8, %%ax\n" \
+ "outb %%al, $0xA1\n" \
+ :: "b" (n) \
+ );
+
+#define irq_disable(n) \
+ __asm__ volatile ( \
+ "inb $0xA1, %%al\n" \
+ "shl $8, %%ax\n" \
+ "inb $0x21, %%al\n" \
+ "or %%bx, %%ax\n" \
+ "outb %%al, $0x21\n" \
+ "shr $8, %%ax\n" \
+ "outb %%al, $0xA1\n" \
+ :: "b" (n) \
+ );
+
void register_isr(uint8_t n, uint8_t dpl, void *handler);
void register_trap(uint8_t n, uint8_t dpl, void *handler);