xref: /freebsd/sys/powerpc/ps3/ps3-hv-header.awk (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
1# This script generates the PS3 hypervisor call header from a hypervisor
2# interface definition file. All lines that do not begin with HVCALL
3# or a bare # for comments are copied to the output header so that
4# enums, constant, C comments and the like can be passed through into the
5# header.
6#
7# Invoke like so: awk -f ps3-hv-header.awk < ps3-hvcall.master > ps3-hv.h
8#
9
10!/HVCALL.*/ && (!/#.*/ || /#define.*/ || /#include.*/) {
11	print($0);
12}
13
14/HVCALL.*/ {
15	split($5, outs, ",")
16	if ($4 == "UNUSED")
17		split("", ins, ",")
18	else
19		split($4, ins, ",")
20
21	printf("int %s(",$3);
22	for (i = 1; i <= length(ins); i++) {
23		printf("uint64_t %s", ins[i]);
24		if (i < length(ins)) printf(", ");
25	}
26
27	if (length(outs) > 0 && length(ins) > 0)
28		printf(", ");
29
30	for (i = 1; i <= length(outs); i++) {
31		printf("uint64_t *%s", outs[i]);
32		if (i < length(outs)) printf(", ");
33	}
34
35	if (length(outs) == 0 && length(ins) == 0)
36		printf("void");
37
38	printf(");\n");
39}
40
41