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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
#!/bin/bash
#
# NAME:
# libacpica.sh - ACPICA release script library
#
#
if [ -z $SCRIPT ]; then
echo "SCRIPT is empty, please invoking libacpica.sh from release scripts."
exit 1
fi
CURDIR=`pwd`
TOOLDIR=$SCRIPT/bin
ACPISRC=$TOOLDIR/acpisrc
ACPI_TYPES=
linux_dirs()
{
local dirs
dirs="\
drivers/acpi/acpica \
include/acpi \
include/acpi/platform \
tools/power/acpi/common \
tools/power/acpi/os_specific/service_layers \
tools/power/acpi/tools/acpidump \
"
echo $dirs
}
acpica_privs()
{
local incs
incs="\
acapps.h \
accommon.h acconvert.h \
acdebug.h acdispat.h \
acevents.h \
acglobal.h \
achware.h \
acinterp.h \
aclocal.h \
acmacros.h \
acnamesp.h \
acobject.h acopcode.h \
acparser.h acpredef.h \
acresrc.h \
acstruct.h \
actables.h \
acutils.h \
amlcode.h amlresrc.h \
"
echo $incs
}
acpica_drivers_paths()
{
local paths incs inc
paths="\
components/debugger \
components/dispatcher \
components/events \
components/executer \
components/hardware \
components/namespace \
components/parser \
components/resources \
components/tables \
components/utilities \
"
incs=`acpica_privs`
for inc in $incs; do
paths="$paths include/$inc"
done
echo $paths
}
acpica_tools_paths()
{
local paths incs inc
paths="\
common/getopt.c \
common/cmfsize.c \
os_specific/service_layers/oslibcfs.c \
os_specific/service_layers/oslinuxtbl.c \
os_specific/service_layers/osunixdir.c \
os_specific/service_layers/osunixmap.c \
os_specific/service_layers/osunixxf.c \
tools/acpidump \
"
echo $paths
}
acpica_exclude_paths()
{
local paths
paths="\
include/acpi/acclib.h \
include/acpi/acdisasm.h \
include/acpi/platform/accygwin.h \
include/acpi/platform/acefi.h \
include/acpi/platform/acefiex.h \
include/acpi/platform/acfreebsd.h \
include/acpi/platform/achaiku.h \
include/acpi/platform/acmacosx.h \
include/acpi/platform/acmsvc.h \
include/acpi/platform/acmsvcex.h \
include/acpi/platform/acnetbsd.h \
include/acpi/platform/acos2.h \
include/acpi/platform/acqnx.h \
include/acpi/platform/acwin.h \
include/acpi/platform/acwinex.h \
include/acpi/platform/acwin64.h \
include/acpi/platform/acdragonfly.h \
include/acpi/platform/acdragonflyex.h \
drivers/acpi/acpica/utclib.c \
"
echo $paths
}
fulldir()
{
( cd $1; pwd )
}
getdir()
{
local lpath
lpath=`dirname $1`
fulldir $lpath
}
getfile()
{
local d f
d=`getdir $1`
f=`basename $1`
echo $d/$f
}
identify_bits()
{
local arch no64
arch=`uname -m`
no64=`echo ${arch%64}`
if [ "x$arch" != "x$no64" ] ; then
echo 64
else
echo 32
fi
}
make_tool()
{
local srcdir acpi_tool tooldir bits
srcdir=$1
acpi_tool=$2
tooldir=$srcdir/generate/unix
bits=`identify_bits`
mkdir -p $TOOLDIR
make -C $srcdir $acpi_tool
if [ ! -f $tooldir/bin$bits/$acpi_tool ]; then
bits=
fi
cp $tooldir/bin$bits/$acpi_tool $TOOLDIR
}
clean_tool()
{
local srcdir acpi_tool tooldir bits
srcdir=$1
acpi_tool=$2
tooldir=$srcdir/generate/unix
bits=`identify_bits`
if [ -f $tooldir/bin$bits/$acpi_tool ]; then
rm -f $tooldir/bin$bits/$acpi_tool
rm -rf $tooldir/$acpi_tool/obj$bits
fi
if [ -f $tooldir/bin/$acpi_tool ]; then
rm -f $tooldir/bin/$acpi_tool
rm -rf $tooldir/$acpi_tool/obj
fi
rm -f $tooldir/bin$bits/$acpi_tool
}
clean_acpisrc()
{
clean_tool $1 acpisrc
}
make_acpisrc()
{
if [ "x$2" = "xforce" ]; then
clean_tool $1 acpisrc
fi
make_tool $1 acpisrc
}
find_typedefs()
{
cat $1 | awk '
{
if (match($0, /^typedef[_a-zA-Z0-9\* \t]+;/)) {
s1=substr($0, RSTART, RLENGTH)
if (match(s1, /^typedef[ \t]+/)) {
s2=substr(s1, RLENGTH+1)
if (match(s2, /(signed|unsigned)[ \t]+/)) {
s3=substr(s2, RLENGTH+1)
} else {
s3=s2
}
if (match(s3, /[_a-zA-Z0-9]+[ \t]+/)) {
s4=substr(s3, RLENGTH+1)
if (match(s4, /\*[ \t]*/)) {
s5=substr(s4, RLENGTH+1)
} else {
s5=s4
}
if (match(s5, /[_a-zA-Z0-9]+/)) {
def=substr(s5, RSTART, RLENGTH)
print def
}
}
}
}
}
'
}
find_all_typedefs()
{
local f files
files=`find . -name "*.h"`
for f in $files; do
find_typedefs $f
done
}
lindent_find_typedefs()
{
ACPI_TYPES=`find_all_typedefs | sort | uniq`
}
lindent_single()
{
local t indent_flags
indent_flags="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -il0"
for t in $ACPI_TYPES; do
if [ "x$2" = "xtrue" ]; then
echo " Adding type $t"
fi
indent_flags="$indent_flags -T $t"
done
dos2unix $1 > /dev/null 2>&1
indent $indent_flags $1
}
lindent()
{
local files f verbose=true
(
cd $1
lindent_find_typedefs
files=`find . -name "*.[ch]" | cut -c3-`
for f in $files; do
lindent_single $f $verbose
verbose=false
done
find . -name "*~" | xargs rm -f
)
}
linuxize_format()
{
echo " Converting (acpisrc -l)..."
$ACPISRC -ldqy $1 $1 > /dev/null
echo " Converting (indent)..."
lindent $1
echo " Converting (acpisrc -i)..."
$ACPISRC -idqy $1 $1 > /dev/null
}
copy_linux_hierarchy()
{
local from to dirs dir
from=$1
to=$2
rm -rf $to
dirs=`linux_dirs`
for dir in $dirs; do
echo " Copying ($dir)..."
mkdir -p $to/$dir
cp $from/$dir/*.[ch] $to/$dir/
done
}
linuxize_hierarchy_ref()
{
local linux acpica to
local all_files
local t n d f
local private_includes inc
linux=$1
acpica=$2
to=$3
rm -rf $to
mkdir -p $to
#
# Ensure that the files in the two directories
# (native ACPICA and Linux ACPICA) match
#
all_files=`find $linux`
for t in $all_files ; do
if [ -f $t ] ; then
n=${t#${linux}/}
d=$to/`dirname $n`
f=`find $acpica/source -name \`basename $t\``
if [ ! -z $f ] ; then
mkdir -p $d
cp -f $f $d
else
echo " Removing ($n)..."
rm -f $t
fi
fi
done
private_includes=`acpica_privs`
# Do we need to perform things on private_includes?
for inc in $private_includes ; do
if [ -f $to/include/acpi/$inc ] ; then
echo "Warning: private include file $inc is now public. Please check the linuxize.sh"
elif [ ! -f $to/drivers/acpi/acpica/$inc ] ; then
echo "Warning: private include file $inc does not exist. Please check the linuxize.sh."
fi
done
}
linuxize_hierarchy_noref()
{
local repo_linux paths path
repo_linux=$1
(
cd $repo_linux
# Making hierarchy
# Making source files
mkdir -p drivers/acpi/acpica
paths=`acpica_drivers_paths`
for path in $paths; do
if [ -d source/$path ]; then
echo " Moving directory $path..."
mv source/$path/*.[ch] drivers/acpi/acpica/
fi
if [ -f source/$path ]; then
echo " Moving file $path..."
mv source/$path drivers/acpi/acpica/
fi
done
# Making include files
mkdir -p include/acpi
mv -f source/include/* include/acpi
# Making tools/power/acpi files
paths=`acpica_tools_paths`
for path in $paths; do
if [ -d source/$path ]; then
echo " Moving directory $path..."
mkdir -p tools/power/acpi/$path
mv source/$path/*.[ch] tools/power/acpi/$path/
fi
if [ -f source/$path ]; then
echo " Moving file $path..."
mkdir -p `dirname tools/power/acpi/$path`
mv source/$path tools/power/acpi/$path
fi
done
# Removing non-Linux files
paths=`acpica_exclude_paths`
for path in $paths; do
if [ -d $path ]; then
echo " Removing directory $path..."
rm -rf $path
fi
if [ -f $path ]; then
echo " Removing file $path..."
rm -f $path
fi
done
rm -rf source
)
}
SRCDIR=`fulldir $SCRIPT/../..`
|