summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJake Mannens <jake72360@gmail.com>2018-08-01 02:27:57 +1000
committerJake Mannens <jake72360@gmail.com>2018-08-01 02:27:57 +1000
commit8e933fac9fd068343bb602f13175c8d70a6c5768 (patch)
tree2d0c2ef1c1165d701d94617986e80c7598d0fc4d /include
parent7babda5d4573d432441a416f880cb8cc8c15b55b (diff)
Defined EOF as -1 in stdio.h.
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.
Diffstat (limited to 'include')
-rw-r--r--include/kernel/con.h2
-rw-r--r--include/kernel/sched.h1
-rw-r--r--include/kernel/sys.h8
-rw-r--r--include/stdio.h7
-rw-r--r--include/unistd.h6
5 files changed, 15 insertions, 9 deletions
diff --git a/include/kernel/con.h b/include/kernel/con.h
index 9dd9dbe..d28daff 100644
--- a/include/kernel/con.h
+++ b/include/kernel/con.h
@@ -13,4 +13,6 @@ void con_clear(void);
int printk(char*, ...);
+int rsputs(char*);
+
#endif
diff --git a/include/kernel/sched.h b/include/kernel/sched.h
index 6b0488e..4d2aca0 100644
--- a/include/kernel/sched.h
+++ b/include/kernel/sched.h
@@ -50,6 +50,7 @@ struct task_struct {
pid_t pid;
int state;
uint32_t signal;
+ int ctty;
unsigned int alarm;
void *sig_handlers[NRSIG];
struct tss_struct tss;
diff --git a/include/kernel/sys.h b/include/kernel/sys.h
index ba2dc0c..32788b1 100644
--- a/include/kernel/sys.h
+++ b/include/kernel/sys.h
@@ -5,9 +5,9 @@ extern int sys_time(void);
extern int sys_getpid(void);
extern int sys_getpdir(void);
extern int sys_signal(void);
-extern int sys_rsputs(void);
extern int sys_alarm(void);
extern int sys_pause(void);
+extern int sys_ctty(void);
extern int sys_dummy(void);
syscall_t call_table[256] = {
@@ -16,9 +16,9 @@ syscall_t call_table[256] = {
[2] = &sys_getpid,
[3] = &sys_getpdir,
[4] = &sys_signal,
- [5] = &sys_rsputs,
- [6] = &sys_alarm,
- [7] = &sys_pause,
+ [5] = &sys_alarm,
+ [6] = &sys_pause,
+ [7] = &sys_ctty,
[8] = &sys_dummy,
[9] = &sys_dummy,
[10] = &sys_dummy,
diff --git a/include/stdio.h b/include/stdio.h
index 94cf227..824eb31 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -3,12 +3,15 @@
#include <stdarg.h>
+#define EOF -1
+
int puts(char*);
-int rsputs(char*);
int printf(char*, ...);
-int rsprintf(char*, ...);
+int sprintf(char*, char*, ...);
int vsprintf(char*, char*, va_list);
+int ctty(int ctty);
+
#endif
diff --git a/include/unistd.h b/include/unistd.h
index 30d41c6..746c829 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -10,9 +10,9 @@ typedef uint16_t pid_t;
#define __SYS_getpid 2
#define __SYS_getpdir 3
#define __SYS_signal 4
-#define __SYS_rsputs 5
-#define __SYS_alarm 6
-#define __SYS_pause 7
+#define __SYS_alarm 5
+#define __SYS_pause 6
+#define __SYS_ctty 7
#define _syscall0(type, name) \
type name(void) { \