2 # $NetBSD: makemachservices.sh,v 1.7 2005/12/11 12:20:20 christos Exp $
4 # Copyright (c) 2003 The NetBSD Foundation, Inc.
6 # This code is derived from software contributed to The NetBSD Foundation
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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
30 master
="mach_services.master"
31 table
="mach_services.c"
32 headers
="mach_services.h"
33 names
="mach_services_names.c"
47 headers = "'$headers'";
50 printf("/* \$NetBSD\$ *\/\n\n") > table;
51 printf("/*\n * Mach services table.\n *\n") > table;
52 printf(" * DO NOT EDIT -- this file is automatically generated.\n") > \
55 printf("/* \$NetBSD\$ *\/\n\n") > headers;
56 printf("/*\n * Mach services prototypes.\n *\n") > headers;
57 printf(" * DO NOT EDIT -- this file is automatically generated.\n") > \
60 printf("/* \$NetBSD\$ *\/\n\n") > names;
61 printf("/*\n * Mach services names. This file is not built\n") > names;
62 printf(" * by the kernel, it is included by kdump sources.\n *\n") > \
64 printf(" * DO NOT EDIT -- this file is automatically generated.\n") > \
68 gsub(/^[^\$]*\$/, "", $0);
69 gsub(/\$.*$/, "", $0);
71 printf(" * created from %s\n */\n\n", $0) > table;
72 printf("#include \<sys/cdefs.h\>\n__KERNEL_RCSID(0, " \
73 "\"\$NetBSD\$\");\n\n") > table;
75 printf(" * created from %s\n */\n\n", $0) > headers;
76 printf("#include \<sys/cdefs.h\>\n__KERNEL_RCSID(0, " \
77 "\"\$NetBSD\$\");\n\n") > headers;
78 printf("#include <compat/mach/mach_types.h>\n") > headers;
79 printf("#include <compat/mach/mach_message.h>\n") > headers;
81 printf(" * created from %s\n */\n\n", $0) > names;
82 printf("#include \<sys/cdefs.h\>\n__KERNEL_RCSID(0, " \
83 "\"\$NetBSD\$\");\n\n") > names;
84 printf("struct mach_service_name {\n") > names;
85 printf(" int srv_id;\n") > names;
86 printf(" const char *srv_name;\n") > names;
87 printf("};\n\n") > names;
90 (NF == 0 || $1 ~ /^;/) {
95 printf("\nstruct mach_service mach_services_table[] = {\n") > table;
96 printf("\n") > headers;
97 printf("struct mach_service_name mach_services_names[] = {\n") > names;
101 printf("%s\n", $0) > table;
104 (intable && $2 == "STD") {
105 printf(" {%d, mach_%s, \"%s\", " \
106 "sizeof(mach_%s_request_t), sizeof(mach_%s_reply_t)},\n", \
107 $1, $3, $3, $3, $3) > table;
108 printf("int mach_%s(struct mach_trap_args *);\n", $3) > headers;
109 printf(" {%d, \"%s\"},\n", $1, $3) > names;
111 (intable && $2 == "NODEF") {
112 printf(" {%d, NULL, \"%s\", 0, 0},\n", \
113 $1, $3, $3, $3, $3) > table;
114 printf(" {%d, \"%s\"},\n", $1, $3) > names;
116 (intable && $2 == "UNIMPL") {
117 printf(" {%d, NULL, \"unimpl. %s\", 0, 0},\n", \
118 $1, $3, $3, $3, $3) > table;
119 printf(" {%d, \"unimpl. %s\"},\n", $1, $3) > names;
121 (intable && $2 == "OBSOL") {
122 printf(" {%d, NULL, \"obsolete %s\", 0, 0},\n", \
123 $1, $3, $3, $3, $3) > table;
124 printf(" {%d, \"obsolete %s\"},\n", $1, $3) > names;
127 printf(" {0, NULL, NULL, 0, 0}\n") > table;
128 printf("};\n") > table;
130 printf(" {0, NULL}\n") > names;
131 printf("};\n") > names;