gen-mach-types 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/awk
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Awk script to generate include/generated/mach-types.h
  5. #
  6. BEGIN { nr = 0 }
  7. /^#/ { next }
  8. /^[ ]*$/ { next }
  9. NF == 4 {
  10. machine_is[nr] = "machine_is_"$1;
  11. config[nr] = "CONFIG_"$2;
  12. mach_type[nr] = "MACH_TYPE_"$3;
  13. num[nr] = $4; nr++
  14. }
  15. NF == 3 {
  16. machine_is[nr] = "machine_is_"$1;
  17. config[nr] = "CONFIG_"$2;
  18. mach_type[nr] = "MACH_TYPE_"$3;
  19. num[nr] = ""; nr++
  20. }
  21. END {
  22. printf("/*\n");
  23. printf(" * This was automagically generated from %s!\n", FILENAME);
  24. printf(" * Do NOT edit\n");
  25. printf(" */\n\n");
  26. printf("#ifndef __ASM_ARM_MACH_TYPE_H\n");
  27. printf("#define __ASM_ARM_MACH_TYPE_H\n\n");
  28. printf("#ifndef __ASSEMBLY__\n");
  29. printf("/* The type of machine we're running on */\n");
  30. printf("extern unsigned int __machine_arch_type;\n");
  31. printf("#endif\n\n");
  32. printf("/* see arch/arm/kernel/arch.c for a description of these */\n");
  33. for (i = 0; i < nr; i++)
  34. if (num[i] ~ /..*/)
  35. printf("#define %-30s %d\n", mach_type[i], num[i]);
  36. printf("\n");
  37. for (i = 0; i < nr; i++)
  38. if (num[i] ~ /..*/) {
  39. printf("#ifdef %s\n", config[i]);
  40. printf("# ifdef machine_arch_type\n");
  41. printf("# undef machine_arch_type\n");
  42. printf("# define machine_arch_type\t__machine_arch_type\n");
  43. printf("# else\n");
  44. printf("# define machine_arch_type\t%s\n", mach_type[i]);
  45. printf("# endif\n");
  46. printf("# define %s()\t(machine_arch_type == %s)\n", machine_is[i], mach_type[i]);
  47. printf("#else\n");
  48. printf("# define %s()\t(0)\n", machine_is[i]);
  49. printf("#endif\n\n");
  50. }
  51. printf("/*\n * These have not yet been registered\n */\n");
  52. for (i = 0; i < nr; i++)
  53. if (num[i] !~ /..*/)
  54. printf("/* #define %-30s <<not registered>> */\n", mach_type[i]);
  55. for (i = 0; i < nr; i++)
  56. if (num[i] !~ /..*/) {
  57. printf("#define %s()\t(0)\n", machine_is[i]);
  58. }
  59. printf("\n#ifndef machine_arch_type\n");
  60. printf("#define machine_arch_type\t__machine_arch_type\n");
  61. printf("#endif\n\n");
  62. printf("#endif\n");
  63. }