summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm/interrupt.h27
-rw-r--r--include/kernel/con.h2
-rw-r--r--include/kernel/serial.h10
-rw-r--r--include/kernel/sys.h3
-rw-r--r--include/stdio.h4
-rw-r--r--include/unistd.h21
6 files changed, 62 insertions, 5 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);
diff --git a/include/kernel/con.h b/include/kernel/con.h
index d28daff..9dd9dbe 100644
--- a/include/kernel/con.h
+++ b/include/kernel/con.h
@@ -13,6 +13,4 @@ void con_clear(void);
int printk(char*, ...);
-int rsputs(char*);
-
#endif
diff --git a/include/kernel/serial.h b/include/kernel/serial.h
new file mode 100644
index 0000000..dbfa7f2
--- /dev/null
+++ b/include/kernel/serial.h
@@ -0,0 +1,10 @@
+#ifndef _SERIAL_H
+#define _SERIAL_H
+
+#include <sys/types.h>
+
+int rsputs(char*);
+
+ssize_t rsread(void*, size_t);
+
+#endif
diff --git a/include/kernel/sys.h b/include/kernel/sys.h
index 32788b1..c428c72 100644
--- a/include/kernel/sys.h
+++ b/include/kernel/sys.h
@@ -8,6 +8,7 @@ extern int sys_signal(void);
extern int sys_alarm(void);
extern int sys_pause(void);
extern int sys_ctty(void);
+extern int sys_read(void);
extern int sys_dummy(void);
syscall_t call_table[256] = {
@@ -19,7 +20,7 @@ syscall_t call_table[256] = {
[5] = &sys_alarm,
[6] = &sys_pause,
[7] = &sys_ctty,
- [8] = &sys_dummy,
+ [8] = &sys_read,
[9] = &sys_dummy,
[10] = &sys_dummy,
[11] = &sys_dummy,
diff --git a/include/stdio.h b/include/stdio.h
index 824eb31..f94e783 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -2,6 +2,8 @@
#define _STDIO_H
#include <stdarg.h>
+#include <sys/types.h>
+#include <unistd.h>
#define EOF -1
@@ -12,6 +14,8 @@ int sprintf(char*, char*, ...);
int vsprintf(char*, char*, va_list);
+ssize_t read(void *buf, size_t len);
+
int ctty(int ctty);
#endif
diff --git a/include/unistd.h b/include/unistd.h
index 746c829..ef6d059 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -3,6 +3,11 @@
#include <stdint.h>
+#ifndef _SSIZE_T
+#define _SSIZE_T
+typedef int32_t ssize_t;
+#endif
+
typedef uint16_t pid_t;
#define __SYS_puts 0
@@ -13,6 +18,7 @@ typedef uint16_t pid_t;
#define __SYS_alarm 5
#define __SYS_pause 6
#define __SYS_ctty 7
+#define __SYS_read 8
#define _syscall0(type, name) \
type name(void) { \
@@ -21,7 +27,7 @@ typedef uint16_t pid_t;
"int $0x80" \
: "=a" (__res) \
: "a" (__SYS_##name) \
- :); \
+ ); \
return __res; \
}
@@ -32,7 +38,18 @@ typedef uint16_t pid_t;
"int $0x80" \
: "=a" (__res) \
: "a" (__SYS_##name), "b" (a) \
- :); \
+ ); \
+ return __res; \
+ }
+
+#define _syscall2(type, name, atype, a, btype, b) \
+ type name(atype a, btype b) { \
+ type __res; \
+ __asm__ volatile ( \
+ "int $0x80" \
+ : "=a" (__res) \
+ : "a" (__SYS_##name), "b" (a), "c" (b) \
+ ); \
return __res; \
}