On 11-12-07 18:00, David P. Reed wrote:

Which port do you want me to test?

Oh, thought your previous reply was already responding to this. The "other diagnostic port", 0xed. The point is not so much that it's going to be a good alternate solution but to exclude it being a possible solution.

Also, I can run the timing test on my machine if you share the source
code so I can build it.

Thanks, would be interesting. This one:

Rene.
#include <stdlib.h>
#include <stdio.h>

#include <sys/io.h>

#define LOOPS 1000

unsigned long cycles[LOOPS];

int main(void)
{
        unsigned long overhead;
        unsigned long total;
        int i;

        if (iopl(3) < 0) {
                perror("iopl");
                return EXIT_FAILURE;
        }

        /* pull it in */
        for (i = 0; i < LOOPS; i++)
                cycles[i] = 0;

        asm volatile ("cli");
        for (i = 0; i < LOOPS; i++)
                asm (
                        "xor    %%eax, %%eax    \n\t"
                        "cpuid                  \n\t"   
                        "rdtsc                  \n\t"
                        "movl   %%eax, %%esi    \n\t"   
                        "xor    %%eax, %%eax    \n\t"
                        "cpuid                  \n\t"
                        "rdtsc                  \n\t"
                        "subl   %%esi, %%eax    \n\t"

                        : "=a" (cycles[i]) : : "ecx", "edx", "ebx", "esi");
        asm volatile ("sti");

        overhead = 0;
        for (i = 0; i < LOOPS; i++)
                overhead += cycles[i];

        asm volatile ("cli");
        for (i = 0; i < LOOPS; i++)
                asm (
                        "xor    %%eax, %%eax    \n\t"
                        "cpuid                  \n\t"   
                        "rdtsc                  \n\t"
                        "movl   %%eax, %%esi    \n\t"   
                        "outb   %%al, $0x80     \n\t"
                        "xor    %%eax, %%eax    \n\t"
                        "cpuid                  \n\t"
                        "rdtsc                  \n\t"
                        "subl   %%esi, %%eax    \n\t"

                        : "=a" (cycles[i]) : : "ecx", "edx", "ebx", "esi");
        asm volatile ("sti");

        total = 0;
        for (i = 0; i < LOOPS; i++)
                total += cycles[i];
        total -= overhead;

        printf("out: %lu\n", total / LOOPS);

        asm volatile ("cli");
        for (i = 0; i < LOOPS; i++)
                asm (
                        "xor    %%eax, %%eax    \n\t"
                        "cpuid                  \n\t"   
                        "rdtsc                  \n\t"
                        "movl   %%eax, %%esi    \n\t"   
                        "inb    $0x80, %%al     \n\t"
                        "xor    %%eax, %%eax    \n\t"
                        "cpuid                  \n\t"
                        "rdtsc                  \n\t"
                        "subl   %%esi, %%eax    \n\t"

                        : "=a" (cycles[i]) : : "ecx", "edx", "ebx", "esi");
        asm volatile ("sti");

        total = 0;
        for (i = 0; i < LOOPS; i++)
                total += cycles[i];
        total -= overhead;

        printf("in : %lu\n", total / LOOPS);

        return EXIT_SUCCESS;
}

Reply via email to