diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/console.rv | 16 | ||||
| -rw-r--r-- | kernel/input.rv | 9 | ||||
| -rw-r--r-- | kernel/main.rv | 6 |
3 files changed, 29 insertions, 2 deletions
diff --git a/kernel/console.rv b/kernel/console.rv index a894141..a949cd2 100644 --- a/kernel/console.rv +++ b/kernel/console.rv @@ -3,7 +3,7 @@ const FH = 16 # glyph height in pixels (8x16 VGA bitmap font) const FG = 0xd0d0d0 const CON_BG = 0x101018 -global con = { col = 0, row = 0, scale = 1 } +global con = { col = 0, row = 0, scale = 1, cur_on = :true, blink = 0 } # cell size in pixels at the current zoom. named cell_* (not cw/ch) so they don't # collide with draw_glyph's `ch` character parameter. @@ -65,5 +65,19 @@ global flush_console = fn() do con_putc(string.of_ascii(c)) c = serial_next() end + # after any output the cursor is solid at the new head restart the blink phase + con.cur_on = :true + con.blink = 0 cursor_paint(CUR) end + +# the PIT fires ~100x/sec +# blink the cursor every 50 ticks (~2 Hz) +global on_tick = fn(t) do + con.blink += 1 + if con.blink >= 50 do + con.blink = 0 + con.cur_on = not con.cur_on + cursor_paint(if con.cur_on CUR else CON_BG) + end +end diff --git a/kernel/input.rv b/kernel/input.rv index fde962d..d069521 100644 --- a/kernel/input.rv +++ b/kernel/input.rv @@ -14,6 +14,15 @@ fn pic_remap() do end fn pic_unmask(line) outb(0x21, inb(0x21) band (255 bxor (1 shl line))) +# 8253/8254 PIT channel 0, mode 3 (square wave) +# divisor 11931 -> ~100 Hz (1193182 / 11931) +# the ISR just counts ticks +fn pit_init() do + outb(0x43, 0x36) + outb(0x40, 11931 band 0xff) + outb(0x40, (11931 shr 8) band 0xff) +end + # she stroke my keys till i handle # no fr this is just a key stroke handler global sh = { line = "", shift = :false } diff --git a/kernel/main.rv b/kernel/main.rv index d3f1b23..35413ef 100644 --- a/kernel/main.rv +++ b/kernel/main.rv @@ -1,6 +1,10 @@ # kmain pic_remap() -pic_unmask(1) +pit_init() + +pic_unmask(0) # PIT (IRQ0) -> cursor blink / uptime +pic_unmask(1) # keyboard (IRQ1) + cmd_clear() puts("revel shell, live in revo. type `help`\n> ") flush_console() |
