mkcpustr.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* ----------------------------------------------------------------------- *
  3. *
  4. * Copyright 2008 rPath, Inc. - All Rights Reserved
  5. *
  6. * ----------------------------------------------------------------------- */
  7. /*
  8. * This is a host program to preprocess the CPU strings into a
  9. * compact format suitable for the setup code.
  10. */
  11. #include <stdio.h>
  12. #include "../include/asm/required-features.h"
  13. #include "../include/asm/disabled-features.h"
  14. #include "../include/asm/cpufeatures.h"
  15. #include "../include/asm/vmxfeatures.h"
  16. #include "../kernel/cpu/capflags.c"
  17. int main(void)
  18. {
  19. int i, j;
  20. const char *str;
  21. printf("static const char x86_cap_strs[] =\n");
  22. for (i = 0; i < NCAPINTS; i++) {
  23. for (j = 0; j < 32; j++) {
  24. str = x86_cap_flags[i*32+j];
  25. if (i == NCAPINTS-1 && j == 31) {
  26. /* The last entry must be unconditional; this
  27. also consumes the compiler-added null
  28. character */
  29. if (!str)
  30. str = "";
  31. printf("\t\"\\x%02x\\x%02x\"\"%s\"\n",
  32. i, j, str);
  33. } else if (str) {
  34. printf("#if REQUIRED_MASK%d & (1 << %d)\n"
  35. "\t\"\\x%02x\\x%02x\"\"%s\\0\"\n"
  36. "#endif\n",
  37. i, j, i, j, str);
  38. }
  39. }
  40. }
  41. printf("\t;\n");
  42. return 0;
  43. }