gen-mach-types 2.0 KB

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