6 # Copyright (c) 2004 Mark Santcroos <marks@ripe.net>
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 OUTPUT=
"acpi_quirks.h"
38 gsub("\^# ", "", VERSION
)
39 gsub("\\$", "", VERSION
)
41 printf("/*\n") > OUTPUT
;
42 printf(" * THIS FILE IS AUTOMAGICALLY GENERATED. DO NOT EDIT.\n") \
44 printf(" *\n") > OUTPUT
;
45 printf(" * Generated from:\n") > OUTPUT
;
46 printf(" * %s\n", VERSION
) > OUTPUT
;
47 printf(" */\n\n") > OUTPUT
;
50 # Ignore comments and empty lines
55 # NAME field: this is the first line of every entry
59 printf("const struct acpi_q_rule %s[] = {\n", ENTRY_NAME
) > OUTPUT
;
68 # Parse table type to match
72 M =
match ($
0, /\"[^
\"]*\"/);
73 OEM_ID =
substr($
0, M
, RLENGTH);
76 ANCHOR =
LENGTH - (M
+ RLENGTH - 1);
77 REMAINDER =
substr($
0, M
+ RLENGTH, ANCHOR
);
78 M =
match (REMAINDER
, /\"[^
\"]*\"/);
79 OEM_TABLE_ID =
substr(REMAINDER
, M
, RLENGTH);
81 printf("\t{ \"%s\", OEM, {%s}, {%s} },\n",
82 TABLE
, OEM_ID
, OEM_TABLE_ID
) > OUTPUT
;
89 # Parse table type to match
92 M =
match ($
0, /\"[^
\"]*\"/);
93 CREATOR =
substr($
0, M
, RLENGTH);
95 printf("\t{ \"%s\", CREATOR, {%s} },\n",
96 TABLE
, CREATOR
) > OUTPUT
;
108 OPERAND = trans_sign
(SIGN
);
110 printf("\t{ \"%s\", OEM_REV, {.op = %s}, {.rev = %s} },\n",
111 TABLE
, OPERAND
, VALUE
) > OUTPUT
;
115 # CREATOR REVISION field
117 $
1 ==
"creator_rev:" {
123 OPERAND = trans_sign
(SIGN
);
125 printf("\t{ \"%s\", CREATOR_REV, {.op = %s}, {.rev = %s} },\n",
126 TABLE
, OPERAND
, VALUE
) > OUTPUT
;
130 # QUIRKS field: This is the last line of every entry
133 printf("\t{ \"\" }\n};\n\n") > OUTPUT
;
136 sub(/^quirks
:[ ]*/ , "", QUIRKS
);
139 QUIRK_LIST
[QUIRK_COUNT
] = QUIRKS
;
140 QUIRK_NAME
[QUIRK_COUNT
] = ENTRY_NAME
;
144 # All information is gathered, now create acpi_quirks_table
148 printf("const struct acpi_q_entry acpi_quirks_table[] = {\n") \
151 # Array of all quirks
152 for (i =
1; i
<= QUIRK_COUNT
; i
++) {
153 printf("\t{ %s, %s },\n", QUIRK_NAME
[i
], QUIRK_LIST
[i
]) \
158 printf("\t{ NULL, 0 }\n") > OUTPUT
;
159 printf("};\n") > OUTPUT
;
165 # Translate math SIGN into verbal OPERAND
167 function trans_sign
(TMP_SIGN
)
170 TMP_OPERAND =
"OP_EQL";
171 else if (TMP_SIGN ==
"!=")
172 TMP_OPERAND =
"OP_NEQ";
173 else if (TMP_SIGN ==
"<=")
174 TMP_OPERAND =
"OP_LEQ";
175 else if (TMP_SIGN ==
">=")
176 TMP_OPERAND =
"OP_GEQ";
177 else if (TMP_SIGN ==
">")
178 TMP_OPERAND =
"OP_GTR";
179 else if (TMP_SIGN ==
"<")
180 TMP_OPERAND =
"OP_LES";
182 printf("error: unknown sign: " TMP_SIGN
"\n");
186 return (TMP_OPERAND
);