cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

tannergooding
Journeyman III

Frequency-Determination Assembler Code

The Frequency-Determination Assembler Code is mentioned in all of the AMD BKDG but I can't find it anywhere on the site.

Ok, so in all of the BIOS and Kernel Developers Guides, they have a bios checklist and mention that you should perform CPU speed detection. It says to see the example frequency-determination assembler code available on the AMD web site but I can not find it anywhere. Any help in locating it would be greatly appreciated.

The following is from Page 327 of the 'BIOS and Kernel Developer's Guide for AMD Athlon(tm) 64 and AMD Opteron(tm) Processors". Publication #26094

12.2 CPU Speed Detection

The BIOS can use the time-stamp counter (TSC) to clock a timed operation and compare the result to the Real-Time Clock (RTC) to determine the operating frequency. See the example of frequency-determination assembler code available on the AMD web site.



0 Likes
5 Replies
avk
Adept III

Well, I think that you wish to determine a CPU's frequency, right? Not sure about the AMD's example, but you may use the QueryPerformanceCounter funtion if you're using Windows. It's safer than RDTSC/RDTSCP, IMHO.

0 Likes

The only issue with that, is that I am not using windows. I am developing a non UNIX/POSIX based Operating System and am in the midst of creating an UEFI Emulation Layer for Computers that still have the legacy BIOS installed instead.

0 Likes

Wow! Your own OS - it's cool!

Well, so are you working in the real (i.e. 16-bit) mode? If yes, then you may use BIOS like I did, back in DOS era:


    rdtsc
    mov    ebx, eax

    mov    cx, 0
    mov    dx, 977*50
    mov    ah, 86h
    int    15h

    rdtsc
    sub    eax, ebx


0 Likes

Thanks AVK, the code, or something similiar will probably work for 16-bit mode and I will implement it for now. But, I would still like to find AMD's example Frequency-Determination Assembler code, so I have something I can use in protected and long mode.

0 Likes

You're welcome . BTW, I'd suggest you to disassemble that BIOS function (int 15h, ah = 86h). I believe that you'll get very small and easy to understand piece of code which you'd implement for your needs.

0 Likes