summaryrefslogtreecommitdiff
path: root/arch/arm/tools/gen-mach-types
blob: ce319ef64bc108c6df94ac2b7b2c02e888050d35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/awk
#
# Awk script to generate include/asm-arm/mach-types.h
#
BEGIN	{ nr = 0 }
/^#/	{ next }
/^[ 	]*$/ { next }

NF == 4 {
	  machine_is[nr] = "machine_is_"$1;
	  config[nr] = "CONFIG_"$2;
	  mach_type[nr] = "MACH_TYPE_"$3;
	  num[nr] = $4; nr++
	}

NF == 3 {
	  machine_is[nr] = "machine_is_"$1;
	  config[nr] = "CONFIG_"$2;
	  mach_type[nr] = "MACH_TYPE_"$3;
	  num[nr] = ""; nr++
	}


END	{
	  printf("/*\n");
	  printf(" * This was automagically generated from %s!\n", FILENAME);
	  printf(" * Do NOT edit\n");
	  printf(" */\n\n");
	  printf("#ifndef __ASM_ARM_MACH_TYPE_H\n");
	  printf("#define __ASM_ARM_MACH_TYPE_H\n\n");
	  printf("#ifndef __ASSEMBLY__\n");
	  printf("/* The type of machine we're running on */\n");
	  printf("extern unsigned int __machine_arch_type;\n");
	  printf("#endif\n\n");

	  printf("/* see arch/arm/kernel/arch.c for a description of these */\n");
	  for (i = 0; i < nr; i++)
	    if (num[i] ~ /..*/)
	      printf("#define %-30s %d\n", mach_type[i], num[i]);

	  printf("\n");

	  for (i = 0; i < nr; i++)
	    if (num[i] ~ /..*/) {
	      printf("#ifdef %s\n", config[i]);
	      printf("# ifdef machine_arch_type\n");
	      printf("#  undef machine_arch_type\n");
	      printf("#  define machine_arch_type\t__machine_arch_type\n");
	      printf("# else\n");
	      printf("#  define machine_arch_type\t%s\n", mach_type[i]);
	      printf("# endif\n");
	      printf("# define %s()\t(machine_arch_type == %s)\n", machine_is[i], mach_type[i]);
	      printf("#else\n");
	      printf("# define %s()\t(0)\n", machine_is[i]);
	      printf("#endif\n\n");
	    }

	  printf("/*\n * These have not yet been registered\n */\n");
	  for (i = 0; i < nr; i++)
	    if (num[i] !~ /..*/)
	      printf("/* #define %-30s <<not registered>> */\n", mach_type[i]);

	  for (i = 0; i < nr; i++)
	    if (num[i] !~ /..*/) {
	      printf("#define %s()\t(0)\n", machine_is[i]);
	    }

	  printf("\n#ifndef machine_arch_type\n");
	  printf("#define machine_arch_type\t__machine_arch_type\n");
	  printf("#endif\n\n");
	  printf("#endif\n");
	}