diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/boot.s | 13 | ||||
| -rw-r--r-- | kernel/con.c | 43 | ||||
| -rw-r--r-- | kernel/hd.c | 2 | ||||
| -rw-r--r-- | kernel/sched.c | 2 | ||||
| -rw-r--r-- | kernel/tty.c | 3 |
5 files changed, 58 insertions, 5 deletions
diff --git a/kernel/boot.s b/kernel/boot.s index 8d07354..5050705 100644 --- a/kernel/boot.s +++ b/kernel/boot.s @@ -18,6 +18,7 @@ extern tty_init ; Multiboot header section .mboothdr +jmp kboot mboot_hdr: align 4 dd 0x1BADB002 @@ -44,10 +45,10 @@ kboot: call printk add esp, 4 ; initialize secondary subsystems + call timer_init call fs_init call tty_init ; last minute setup, then transfer to kmain - call timer_init call kmain ; if kmain decides to return (which it shouldn't), ; disable interrupts and halt the system. @@ -243,6 +244,14 @@ enable_a20: xchg ax, cx or al, 0x02 out 0x60, al + ; check if the gate is now enabled + call .testgate + jne .end + ; if the gate is still not working, try the fast-gate method + in al, 0x92 + and al, 0xFE + or al, 0x02 + out 0x92, al ; make sure the gate is working (panic if not) call .testgate jne .end @@ -272,7 +281,7 @@ enable_a20: pop ebp ret .tmp: dw 0xDEAD -.msg: db "Failed to enable A20 gate!", 10, 0 +.msg: db "Failed to enable the A20 gate!", 10, 0 pic_init: push ebp 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]; diff --git a/kernel/hd.c b/kernel/hd.c index eab82dc..3b2aa3c 100644 --- a/kernel/hd.c +++ b/kernel/hd.c @@ -183,5 +183,5 @@ void hd_init(void) { return; } - printk("[hd] Primary bus master drive initialized! (status: 0x%02x, nblocks: 0x%01x)\n", s, nblocks); + printk("[hd] Primary bus master drive initialized! (status: 0x%02x, nsects: 0x%01x)\n", s, nblocks); } diff --git a/kernel/sched.c b/kernel/sched.c index a17b58c..da55fa3 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -209,7 +209,7 @@ void sched_init(void) { ctask = NULL; create_proc(&_usrbin_start, (size_t) &_usrbin_size); - /* create_proc(&_usrbin_start, (size_t) &_usrbin_size); */ + create_proc(&_usrbin_start, (size_t) &_usrbin_size); switch_to(0, &tasks[0]); } diff --git a/kernel/tty.c b/kernel/tty.c index bfbf775..529d955 100644 --- a/kernel/tty.c +++ b/kernel/tty.c @@ -1,5 +1,6 @@ #include <asm/interrupt.h> #include <errno.h> +#include <kernel/con.h> #include <kernel/sched.h> #include <kernel/serial.h> #include <kernel/tty.h> @@ -12,7 +13,7 @@ (sizeof(ttys) / sizeof(struct tty_struct*)) static struct tty_struct *ttys[] = { - NULL, + &tty_con, &tty_rs }; |
