diff options
| author | Jake Mannens <jake72360@gmail.com> | 2018-10-09 23:11:46 +1100 |
|---|---|---|
| committer | Jake Mannens <jake72360@gmail.com> | 2018-10-09 23:11:46 +1100 |
| commit | a8a4f0710210ed91097a30fc26308c50be73d4de (patch) | |
| tree | b75f3f30429e2c9c69177aa00832ea6b7fe836e5 /kernel/con.c | |
| parent | 4dc73ef6bbefb1f5d108ab19a72349563c586e28 (diff) | |
Added the f_inode element to struct file as a pointer to the file's
inode in memory.
Added a jump instruction in front of the multiboot header so that the
kernel may be run as a binary image. The jump instruction will skip over
the multiboot header to the beginning of the kernel's startup procedure
in kboot.
Moved the call to initialize the timer to earlier in the boot sequence.
This is to allow for some drivers that may require it's functionality
during the startup to function properly.
Added functionality for the 'fast-gate' to the enable_a20 subroutine.
Now, if the keyboard controller method fails when enabling the gate, an
attempt is made to enable the A20 gate using the PS/2's fast-gate
interface. If this also fails, the kernel will panic.
Implemented TTY output for the console. The console is now TTY device 0
(the default for new userspace programs).
Diffstat (limited to 'kernel/con.c')
| -rw-r--r-- | kernel/con.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/kernel/con.c b/kernel/con.c index 2000fbc..5a9d2e9 100644 --- a/kernel/con.c +++ b/kernel/con.c @@ -5,6 +5,7 @@ */ #include <asm/io.h> +#include <kernel/tty.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> @@ -12,6 +13,14 @@ #define COLS 80 #define ROWS 25 +/* internal function prototypes */ +static void con_write(void); + +struct tty_struct tty_con = { + .init = NULL, + .write = &con_write +}; + static uint8_t *vram = (uint8_t*) 0xB8000; static int pos; @@ -91,6 +100,40 @@ static int con_puts(char *s) { return 0; } +/* same as con_puts() but deals with bytes rather than strings */ +static void con_write(void) { + char c; + int copied = 0; + uint8_t *p = &vram[pos]; + struct tty_queue *q = &tty_con.wqueue; + + while(q->pread != q->pwrite) { + c = q->buf[q->pread]; + if(c == '\n') { + pos = (int) (p - vram); + pos = ((pos / (COLS << 1)) + 1) * (COLS << 1); + p = &vram[pos]; + } else { + *p = c; + p += 2; + } + + q->pread = (q->pread + 1) % TTY_BUF_SIZE; + copied = 1; + + pos = (int) (p - vram); + + if(pos >= (COLS * ROWS) << 1) + scroll_up(); + } + + /* update the cursor position */ + cursorpos(pos); + + if(copied) + wake_up(&q->waiting); +} + int printk(char *fmt, ...) { int ret; char buf[1024]; |
