]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/uac/uac.c
This commit was generated by cvs2svn to compensate for changes in r154182,
[FreeBSD/FreeBSD.git] / usr.bin / uac / uac.c
1 /*
2  * Copyright (c) 2000 Andrew Gallatin and David E. O'Brien
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer 
10  *    in this position and unchanged.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30
31 #include <sys/types.h>
32 #include <machine/sysarch.h>
33 #include <machine/proc.h>
34
35 #include <stdio.h>
36 #include <unistd.h>
37 #include <err.h>
38
39 static void usage ();
40
41 struct parms {
42         u_int64_t uac;
43 };
44
45 int
46 alpha_setuac(u_int64_t uac)
47 {
48         struct parms p;
49
50         p.uac = uac;
51         return (sysarch(ALPHA_SET_UAC, &p));
52 }
53
54 int
55 alpha_getuac(u_int64_t *uac)
56 {
57         struct parms p;
58         int error;
59
60         error = sysarch(ALPHA_GET_UAC, &p);
61         *uac = p.uac;
62         return (error);
63 }
64
65 static void
66 print_uac(u_int64_t uac)
67 {
68
69         printf("parent printing is ");
70         if (uac & MDP_UAC_NOPRINT)
71                 printf("off\n");
72         else 
73                 printf("on\n");
74
75         printf("parent fixup is ");
76         if (uac & MDP_UAC_NOFIX)
77                 printf("off\n");
78         else 
79                 printf("on\n");
80
81         printf("parent sigbus is ");
82         if (uac & MDP_UAC_SIGBUS)
83                 printf("on \n");
84         else 
85                 printf("off\n");
86 }
87
88 int
89 main(argc, argv)
90         int argc;
91         char **argv;
92 {
93         int c;
94         u_int64_t uac;
95
96         if (alpha_getuac(&uac) != 0)
97                 err(1, NULL);
98
99         while ((c = getopt(argc, argv, "fpsr")) != -1) {
100                 switch (c) {
101                 case 'f':
102                         uac |= MDP_UAC_NOFIX;
103                         break;
104                 case 'p':
105                         uac |= MDP_UAC_NOPRINT;
106                         break;
107                 case 's':
108                         uac |= MDP_UAC_SIGBUS;
109                         break;
110                 case 'r':
111                         uac = 0;
112                         break;
113                 default:
114                         usage();
115                         /* NOTREACHED */   
116                 }
117         }
118
119         if (argc != 1) {        
120                 if (alpha_setuac(uac) != 0)
121                         err(1, NULL);
122         }
123
124         print_uac(uac);
125         return 0;
126 }
127
128 static void
129 usage ()
130 {
131
132         fprintf(stderr, "usage: uac [-fprs]\n");
133 }