From 4ba939d3c8ceda5aa0030bcc62d0f175a0acb1df Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Sun, 2 Aug 2015 07:43:48 +0000 Subject: [PATCH] kolibri-acpi: add some checks in hpet initialization code git-svn-id: svn://kolibrios.org@5645 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/Kolibri-acpi/core/apic.inc | 13 ++++++++++++- kernel/branches/Kolibri-acpi/init.inc | 10 ++++++++++ kernel/branches/Kolibri-acpi/kernel.asm | 14 ++++++++++---- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/kernel/branches/Kolibri-acpi/core/apic.inc b/kernel/branches/Kolibri-acpi/core/apic.inc index ef7b72105c..a073b65ec6 100644 --- a/kernel/branches/Kolibri-acpi/core/apic.inc +++ b/kernel/branches/Kolibri-acpi/core/apic.inc @@ -441,11 +441,16 @@ pci_irq_fixup: align 4 get_clock_ns: + + mov eax, [hpet_base] + test eax, eax + jz .old_tics + push ebx pushfd cli - mov ebx, [hpet_base] + mov ebx, eax @@: mov edx, [ebx+0xF4] mov eax, [ebx+0xF0] @@ -463,3 +468,9 @@ get_clock_ns: pop ebx ret +.old_tics: + mov eax, [timer_ticks] + mov edx, 10000000 + mul edx + ret + diff --git a/kernel/branches/Kolibri-acpi/init.inc b/kernel/branches/Kolibri-acpi/init.inc index 9941c8e5a5..9e4a2ff1ba 100644 --- a/kernel/branches/Kolibri-acpi/init.inc +++ b/kernel/branches/Kolibri-acpi/init.inc @@ -438,6 +438,7 @@ acpi_ioapic_base rd 1 acpi_hpet_base rd 1 hpet_base rd 1 hpet_period rd 1 +hpet_timers rd 1 cpu_count rd 1 smpt rd 16 @@ -605,6 +606,14 @@ HPET_CFG equ 0x010 align 4 init_hpet: mov ebx, [hpet_base-OS_BASE] + test ebx, ebx + jz @F + + mov eax, [ebx] + and ah, 0x1F + inc ah + movzx eax, ah + mov [hpet_timers-OS_BASE], eax mov eax, [ebx+HPET_PERIOD] mov edx, 0x431BDE83 @@ -622,6 +631,7 @@ init_hpet: or eax, HPET_CFG_ENABLE mov [ebx+HPET_CFG], eax ;and start again +@@: ret diff --git a/kernel/branches/Kolibri-acpi/kernel.asm b/kernel/branches/Kolibri-acpi/kernel.asm index e0f713083e..c9177b3857 100644 --- a/kernel/branches/Kolibri-acpi/kernel.asm +++ b/kernel/branches/Kolibri-acpi/kernel.asm @@ -698,17 +698,23 @@ setvideomode: @@: mov [clipboard_main_list], eax - mov eax, [acpi_hpet_base] - DEBUGF 1, "K : ACPI HPET base %x\n", eax - mov eax, [hpet_base] + mov eax, [hpet_base] + test eax, eax + jz @F DEBUGF 1, "K : HPET base %x\n", eax - mov eax, [hpet_period] + mov eax, [hpet_period] DEBUGF 1, "K : HPET period %d\n", eax + mov eax, [hpet_timers] + DEBUGF 1, "K : HPET timers %d\n", eax mov eax, [hpet_base] stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR mov [hpet_base], eax + mov eax, [eax] + DEBUGF 1, "K : HPET caps %x\n", eax + +@@: ; SET UP OS TASK mov esi, boot_setostask