Skip to content

Commit a6756cd

Browse files
author
Ian Seyler
committed
Add kvm timer code
Exclude floppy code by default
1 parent 51c555e commit a6756cd

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/init/timer.asm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ init_timer_phys:
2626
cmp rax, 0
2727
jz init_timer_error
2828
call init_timer_hpet
29+
mov qword [sys_timer], hpet_delay
2930
jmp init_timer_done
3031

3132
init_timer_virt:
3233
call init_timer_kvm
34+
mov qword [sys_timer], kvm_delay
3335

3436
init_timer_error:
3537

@@ -239,6 +241,10 @@ kvm_get_usec_shift_done:
239241
pop rcx ; Restore tsc_to_system_mul
240242

241243
; Calculate nanoseconds as (delta * mul) >> 32
244+
mul rcx ; RDX:RAX = RAX * RCX
245+
shl rdx, 32
246+
shr rax, 32
247+
or rax, rdx
242248

243249
; Add system time to nanoseconds
244250
add rax, rbx
@@ -297,15 +303,9 @@ kvm_delay_wait:
297303
; There are 1,000 milliseconds in a second
298304
timer_delay:
299305
push rax
300-
push rbx
301306

302-
; Detect which timer is to be used
307+
call [sys_timer]
303308

304-
305-
call hpet_delay
306-
; call kvm_delay
307-
308-
pop rbx
309309
pop rax
310310
ret
311311
; -----------------------------------------------------------------------------

src/interrupt.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interrupt_gate: ; handler for all other interrupts
2626
; -----------------------------------------------------------------------------
2727
; Floppy drive interrupt. IRQ 0x06, INT 0x26
2828
; This IRQ runs when floppy drive reads from or writes to whole disk
29-
%ifdef BIOS
29+
%ifdef FLOPPY
3030
align 16
3131
floppy_irq:
3232
push rdi

src/pure64.asm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ lfb_wc_end:
946946
mov rsi, msg_kernel
947947
call debug_msg
948948

949-
%ifdef BIOS
949+
%ifdef FLOPPY
950950
cmp byte [p_BootDisk], 'F' ; Check if sys is booted from floppy?
951951
jnz clear_regs
952952
call read_floppy ; Then load whole floppy at memory
@@ -977,7 +977,7 @@ clear_regs:
977977
%include "init/serial.asm"
978978
%include "init/smp.asm"
979979
%include "init/timer.asm"
980-
%ifdef BIOS
980+
%ifdef FLOPPY
981981
%include "fdc/dma.asm"
982982
%include "fdc/fdc_64.asm"
983983
%endif
@@ -1044,7 +1044,7 @@ nextline:
10441044
; -----------------------------------------------------------------------------
10451045
%endif
10461046

1047-
%ifdef BIOS
1047+
%ifdef FLOPPY
10481048
; -----------------------------------------------------------------------------
10491049
; debug_progressbar
10501050
; IN: EBX = Index #

src/sysvar.asm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ VBEModeInfoBlock: equ 0x0000000000005F00 ; 256 bytes
3737
; DQ - Starting at offset 0, increments by 0x8
3838
p_ACPITableAddress: equ SystemVariables + 0x00
3939
p_LocalAPICAddress: equ SystemVariables + 0x10
40-
p_Counter_Timer: equ SystemVariables + 0x18
41-
p_Counter_RTC: equ SystemVariables + 0x20
4240
p_HPET_Address: equ SystemVariables + 0x28
41+
sys_timer: equ SystemVariables + 0x30
4342

4443
; DD - Starting at offset 0x80, increments by 4
4544
p_BSP: equ SystemVariables + 0x80
@@ -63,7 +62,7 @@ p_HPET_Timers: equ SystemVariables + 0x184
6362
p_BootDisk: equ SystemVariables + 0x185 ; 'F' for Floppy drive
6463
p_1GPages: equ SystemVariables + 0x186 ; 1 if 1GB pages are supported
6564

66-
p_timer: equ SystemVariables + 0x1000
65+
p_timer: equ SystemVariables + 0x1000 ; This overwrites the memory details from firmware
6766

6867
align 16
6968
GDTR32: ; Global Descriptors Table Register

0 commit comments

Comments
 (0)