Main Page | Directories | File List | Globals

tsc.c

Go to the documentation of this file.
00001 /*
00002  * kernel_arch/i386/kernel/cpu/tsc.c
00003  *
00004  * Copyright (c) 2003-2004 Lukasz Dembinski <dembol@nasa.com.pl>
00005  * All Rights Reserved
00006  * 
00007  * Date:        2004/01
00008  * Author:      Lukasz Dembinski
00009  * Info:        tsc.c core file
00010  * Contact:     mailto: <dembol@nasa.com.pl>
00011  *
00012  */
00013 
00014 #include <agnix/agnix.h>
00015 #include <agnix/adi/adi.h>
00016 #include <agnix/console.h>
00017 #include <agnix/math64.h>
00018 #include <asm/cpu_ops.h>
00019 #include <agnix/ioport.h>
00020 
00021 #define MOD_NAME        "\tTSC: "
00022 
00023 extern struct chip_s cpu_chip;
00024 
00025 int __init tsc_get_speed(void)
00026 {
00027     u32 tsc[2];
00028     u32 tsc_s[2];
00029     u32 tsc_e[2];
00030 
00031     outb(0xb0, 0x43);
00032     outb((i8254_RELOAD_COUNT) & 0xFF, 0x42);
00033     outb((i8254_RELOAD_COUNT >> 8) & 0xFF, 0x42);
00034 
00035     rdtsc(tsc_s[0], tsc_s[1]);
00036 
00037     while(!(inb(0x61) & 0x20));
00038     
00039     rdtsc(tsc_e[0], tsc_e[1]);
00040     
00041     sub_64_64(tsc, tsc_e, tsc_s);
00042 
00043     return (tsc[0]);    
00044 }
00045 
00046 void __init cpu_tsc_init(void)
00047 {
00048     if (cpu_capable(X86_FEATURE_TSC)) {
00049         write_cr4(read_cr4() & (~CPU_CR4_TSD));
00050         
00051         if (read_cr4() & CPU_CR4_TSD) {
00052             printk(MOD_NAME "Tsc cannot be enabled\n");
00053         }
00054     }
00055 }
Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix