mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-17 08:37:17 -04:00
Add Programmable Interval Timer support
Add uptime command
This commit is contained in:
parent
ae784bc2b7
commit
df4adf66f7
@ -4,6 +4,7 @@ sysinfo_command_str db 'sysinfo', 0
|
||||
reboot_command_str db 'reboot', 0
|
||||
clear_command_str db 'clear', 0
|
||||
help_command_str db 'help', 0
|
||||
uptime_command_str db 'uptime', 0
|
||||
|
||||
STRING sysinfo_vendor_id, "Vendor ID: "
|
||||
STRING sysinfo_stepping, "Stepping: "
|
||||
@ -25,6 +26,7 @@ STRING sysinfo_ht, "ht "
|
||||
STRING sysinfo_fpu, "fpu "
|
||||
STRING sysinfo_aes, "aes "
|
||||
|
||||
STRING uptime_message, "Uptime (s): "
|
||||
STRING available_commands, "Available commands: "
|
||||
STRING tab, " "
|
||||
|
||||
@ -42,6 +44,9 @@ command_table:
|
||||
dq clear_command_str
|
||||
dq clear_command
|
||||
|
||||
dq uptime_command_str
|
||||
dq uptime_command
|
||||
|
||||
dq help_command_str
|
||||
dq help_command
|
||||
|
||||
@ -333,6 +338,22 @@ help_command:
|
||||
|
||||
ret
|
||||
|
||||
uptime_command:
|
||||
push r8
|
||||
push r9
|
||||
|
||||
mov r8, uptime_message
|
||||
mov r9, uptime_message_length
|
||||
call print_normal
|
||||
|
||||
mov r8, [timer_seconds]
|
||||
call print_int_normal
|
||||
|
||||
pop r9
|
||||
pop r8
|
||||
|
||||
ret
|
||||
|
||||
reboot_command:
|
||||
; Reboot using the 8042 keyboard controller
|
||||
; by pulsing the CPU's reset pin
|
||||
|
@ -97,6 +97,8 @@ lm_start:
|
||||
|
||||
sti
|
||||
|
||||
call install_timer
|
||||
|
||||
; Enter the shell
|
||||
call shell_start
|
||||
|
||||
@ -107,6 +109,7 @@ lm_start:
|
||||
%include "src/utils/macros.asm"
|
||||
%include "src/utils/console.asm"
|
||||
|
||||
%include "src/timer.asm"
|
||||
%include "src/interrupts.asm"
|
||||
%include "src/shell.asm"
|
||||
|
||||
|
47
src/timer.asm
Normal file
47
src/timer.asm
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
install_timer:
|
||||
mov r8, 1193180 / 1000
|
||||
|
||||
mov al, 0x36
|
||||
out 0x43, al ; Command byte
|
||||
|
||||
mov rax, r8
|
||||
out 0x40, al ; low bytes of divisor
|
||||
|
||||
mov rax, r8
|
||||
shr rax, 8
|
||||
out 0x40, al ; high bytes of divisor
|
||||
|
||||
mov r8, 0
|
||||
mov r9, irq_timer_handler
|
||||
call register_irq_handler
|
||||
|
||||
ret
|
||||
|
||||
irq_timer_handler:
|
||||
push rax
|
||||
|
||||
mov rax, [timer_ticks]
|
||||
inc rax
|
||||
mov [timer_ticks], rax
|
||||
|
||||
xor rdx, rdx
|
||||
mov rcx, 1000
|
||||
div rcx
|
||||
cmp rdx, 0
|
||||
jnz .end
|
||||
|
||||
mov rax, [timer_seconds]
|
||||
inc rax
|
||||
mov [timer_seconds], rax
|
||||
|
||||
.end:
|
||||
|
||||
pop r8
|
||||
|
||||
ret
|
||||
|
||||
; Variables
|
||||
|
||||
timer_ticks dq 0
|
||||
timer_seconds dq 0
|
Loading…
x
Reference in New Issue
Block a user