source: libcaca/trunk/kernel/drivers/processor.c @ 4154

Last change on this file since 4154 was 4154, checked in by Jean-Yves Lamoureux, 10 years ago
  • Total kernel rewrite
File size: 1.1 KB
Line 
1/*
2 *  processor.c
3 * 
4 *
5 *  Created by Jean-Yves Lamoureux on 12/19/09.
6 *  Copyright 2009 Frob. All rights reserved.
7 *
8 */
9#include "kernel.h"
10#include "klibc.h"
11#include "processor.h"
12
13
14int processor_get_info(struct processor_info *processor_info)
15{
16    /* Vendor String */
17    int code = CPUID_GETVENDORSTRING;
18    unsigned int where[5];
19    char *s;
20    asm volatile ("cpuid":"=a" (*where), "=b"(*(where + 1)),
21                  "=c"(*(where + 2)), "=d"(*(where + 3)):"0"(code));
22
23    s = (char *)where;
24
25    unsigned int a = 0;
26    unsigned int b = where[1];
27    unsigned int d = where[3];
28    unsigned int c = where[2];
29
30    where[0] = b;
31    where[1] = d;
32    where[2] = c;
33    where[3] = 0;
34
35    memcpy(processor_info->vendor, where, 13);
36
37    /* Features */
38    code = CPUID_GETFEATURES;
39    asm volatile ("cpuid":"=a" (a), "=d"(d):"0"(code):"ecx", "ebx");
40    processor_info->features = a;
41
42    return 0;
43}
44
45void processor_print_info(struct processor_info *processor_info)
46{
47    printf("CPU%d\n", processor_info->id);
48    printf("Vendor ID : %s\n", processor_info->vendor);
49    printf("Features : 0x%x\n", processor_info->features);
50}
Note: See TracBrowser for help on using the repository browser.