選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

51 行
1.1 KiB

  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. int processor_get_info(struct processor_info *processor_info)
  13. {
  14. /* Vendor String */
  15. int code = CPUID_GETVENDORSTRING;
  16. unsigned int where[5];
  17. char *s;
  18. asm volatile ("cpuid":"=a" (*where), "=b"(*(where + 1)),
  19. "=c"(*(where + 2)), "=d"(*(where + 3)):"0"(code));
  20. s = (char *)where;
  21. unsigned int a = 0;
  22. unsigned int b = where[1];
  23. unsigned int d = where[3];
  24. unsigned int c = where[2];
  25. where[0] = b;
  26. where[1] = d;
  27. where[2] = c;
  28. where[3] = 0;
  29. memcpy(processor_info->vendor, where, 13);
  30. /* Features */
  31. code = CPUID_GETFEATURES;
  32. asm volatile ("cpuid":"=a" (a), "=d"(d):"0"(code):"ecx", "ebx");
  33. processor_info->features = a;
  34. return 0;
  35. }
  36. void processor_print_info(struct processor_info *processor_info)
  37. {
  38. printf("CPU%d\n", processor_info->id);
  39. printf("Vendor ID : %s\n", processor_info->vendor);
  40. printf("Features : 0x%x\n", processor_info->features);
  41. }