OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 6:36 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [SOLVED] Bochs and HPET: How to detect ?
PostPosted: Thu Mar 29, 2018 3:03 am 
Offline
Member
Member
User avatar

Joined: Fri Nov 01, 2013 4:05 pm
Posts: 90
Location: Fribourg, Switzerland
Hi,

I've had an HPET driver working correctly for quite some time on Qemu. Before, it was not detecting any HPET in Bochs, but now Bochs added an ACPI Table for HPET and my OS detect that there is support for HPET. However, I'm having issues from Bochs telling me that I read (or write) to invalid HPET Register.

Here is what I'm doing to Detect HPET support for my OS:

  1. Check if the Table is here
  2. Check if possible to handle legacy replacement mode
  3. Check if the main counter is 64 bits
  4. Check if timer #0 is 64-bits

With Bochs, the three first tests pass without issue, but it crashes with:

Quote:
Unsupported HPET read at address 0x0000fed00100


Is there any way to do a better detection so that step 4. does not fail ?
Is my HPET detection wrong ?

I was thinking to detect the number of timers, but Bochs tell me there are two counters...

Thanks

_________________
Thor Operating System: C++ 64 bits OS: https://github.com/wichtounet/thor-os
Good osdeving!


Last edited by wichtounet on Thu Mar 29, 2018 3:27 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Bochs and HPET: How to detect ?
PostPosted: Thu Mar 29, 2018 3:19 am 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 210
The function hpet_read raises that error if the read size is not 4 or 8 bytes.

You may want to disassemble your binary to determine if any optimizations have caused it to contain such attempts at reading the hpet registers.


Top
 Profile  
 
 Post subject: Re: Bochs and HPET: How to detect ?
PostPosted: Thu Mar 29, 2018 3:26 am 
Offline
Member
Member
User avatar

Joined: Fri Nov 01, 2013 4:05 pm
Posts: 90
Location: Fribourg, Switzerland
linuxyne wrote:
The function hpet_read raises that error if the read size is not 4 or 8 bytes.

You may want to disassemble your binary to determine if any optimizations have caused it to contain such attempts at reading the hpet registers.


Oh my god, you were right, I was missing a volatile!

Thanks a lot. It works now. It seems incredibly slow compared to qemu though.

I also tried patching the hpet_read function to handle small reads and it also works.

_________________
Thor Operating System: C++ 64 bits OS: https://github.com/wichtounet/thor-os
Good osdeving!


Top
 Profile  
 
 Post subject: Re: Bochs and HPET: How to detect ?
PostPosted: Thu Mar 29, 2018 11:29 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
wichtounet wrote:
I also tried patching the hpet_read function to handle small reads and it also works.

That's against the spec though. The HPET spec only allows DWORD reads/writes at DWORD-aligned boundaries, and QWORD read/writes at QWORD-aligned boundaries.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: Bochs and HPET: How to detect ?
PostPosted: Tue Apr 03, 2018 1:45 am 
Offline
Member
Member
User avatar

Joined: Fri Nov 01, 2013 4:05 pm
Posts: 90
Location: Fribourg, Switzerland
omarrx024 wrote:
wichtounet wrote:
I also tried patching the hpet_read function to handle small reads and it also works.

That's against the spec though. The HPET spec only allows DWORD reads/writes at DWORD-aligned boundaries, and QWORD read/writes at QWORD-aligned boundaries.


Thanks, I didn't know that :)

_________________
Thor Operating System: C++ 64 bits OS: https://github.com/wichtounet/thor-os
Good osdeving!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 153 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group