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

61 行
1.6 KiB

  1. /*
  2. * libcaca
  3. * libcaca Colour ASCII-Art library
  4. * Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
  5. * 2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
  6. * All Rights Reserved
  7. *
  8. * $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
  9. *
  10. * This library is free software. It comes without any warranty, to
  11. * the extent permitted by applicable law. You can redistribute it
  12. * and/or modify it under the terms of the Do What The Fuck You Want
  13. * To Public License, Version 2, as published by Sam Hocevar. See
  14. * http://sam.zoy.org/wtfpl/COPYING for more details.
  15. */
  16. #include "kernel.h"
  17. #include "klibc.h"
  18. #include "processor.h"
  19. int processor_get_info(struct processor_info *processor_info)
  20. {
  21. processor_info->id = 0;
  22. /* Vendor String */
  23. int code = CPUID_GETVENDORSTRING;
  24. unsigned int where[5];
  25. char *s;
  26. asm volatile ("cpuid":"=a" (*where), "=b"(*(where + 1)),
  27. "=c"(*(where + 2)), "=d"(*(where + 3)):"0"(code));
  28. s = (char *)where;
  29. unsigned int a = 0;
  30. unsigned int b = where[1];
  31. unsigned int d = where[3];
  32. unsigned int c = where[2];
  33. where[0] = b;
  34. where[1] = d;
  35. where[2] = c;
  36. where[3] = 0;
  37. memcpy(processor_info->vendor, where, 13);
  38. /* Features */
  39. code = CPUID_GETFEATURES;
  40. asm volatile ("cpuid":"=a" (a), "=d"(d):"0"(code):"ecx", "ebx");
  41. processor_info->features = a;
  42. return 0;
  43. }
  44. void processor_print_info(struct processor_info *processor_info)
  45. {
  46. printf("CPU%d\n", processor_info->id);
  47. printf("Vendor ID : %s\n", processor_info->vendor);
  48. printf("Features : 0x%x\n", processor_info->features);
  49. }