@@ -25,21 +25,26 @@ init_timer_phys:
2525 mov rax , [ p_HPET_Address ]
2626 cmp rax , 0
2727 jz init_timer_error
28+ ; Initialize the HPET
2829 call init_timer_hpet
2930 mov qword [ sys_timer ], hpet_delay
3031 jmp init_timer_done
3132
3233init_timer_virt:
34+ ; Initialize the KVM timer
3335 call init_timer_kvm
3436 mov qword [ sys_timer ], kvm_delay
37+ jmp init_timer_done
3538
3639init_timer_error:
40+ jmp $ ; Spin forever as there was no timer source
3741
3842init_timer_done:
3943 ret
4044
4145
4246; -----------------------------------------------------------------------------
47+ ; init_timer_hpet -- Initialize the HPET
4348init_timer_hpet:
4449 ; Verify the capabilities of HPET
4550 mov ecx , HPET_GEN_CAP
@@ -87,7 +92,11 @@ init_timer_hpet_disable_int:
8792 mov ecx , HPET_GEN_CONF
8893 call hpet_write
8994
95+ jmp init_timer_hpet_done
96+
9097init_timer_hpet_error:
98+
99+ init_timer_hpet_done:
91100 ret
92101; -----------------------------------------------------------------------------
93102
@@ -160,6 +169,7 @@ hpet_delay_end:
160169
161170
162171; -----------------------------------------------------------------------------
172+ ; init_timer_kvm - Initialize the KVM timer
163173init_timer_kvm:
164174 ; Check hypervisor feature bits
165175 mov eax , 0x40000001
@@ -179,7 +189,7 @@ init_timer_kvm_clocksource:
179189
180190init_timer_kvm_configure:
181191 xor edx , edx
182- mov eax , p_timer
192+ mov eax , p_timer ; Memory address for structure
183193 bts eax , 0 ; Enable bit
184194 wrmsr
185195
@@ -230,11 +240,11 @@ kvm_get_usec_wait:
230240
231241 ; Apply tsc_shift
232242 cmp cl , 0
233- jl kvm_get_usec_shift_right
243+ jl kvm_get_usec_shift_right ; Signed comparison
234244 shl rax , cl
235245 jmp kvm_get_usec_shift_done
236246kvm_get_usec_shift_right:
237- neg cl
247+ neg cl ; Ex: 0xFF = tsc shift of -1
238248 shr rax , cl
239249kvm_get_usec_shift_done:
240250
0 commit comments