Annotation of src/sys/arch/xen/xen/xen_machdep.c, Revision 1.4.12.5
1.4.12.5! jym 1: /* $NetBSD: xen_machdep.c,v 1.7 2009/10/23 02:32:34 snj Exp $ */
1.2 bouyer 2:
3: /*
4: * Copyright (c) 2006 Manuel Bouyer.
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: * 1. Redistributions of source code must retain the above copyright
10: * notice, this list of conditions and the following disclaimer.
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: *
15: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25: *
26: */
27:
28: /*
29: *
30: * Copyright (c) 2004 Christian Limpach.
31: * All rights reserved.
32: *
33: * Redistribution and use in source and binary forms, with or without
34: * modification, are permitted provided that the following conditions
35: * are met:
36: * 1. Redistributions of source code must retain the above copyright
37: * notice, this list of conditions and the following disclaimer.
38: * 2. Redistributions in binary form must reproduce the above copyright
39: * notice, this list of conditions and the following disclaimer in the
40: * documentation and/or other materials provided with the distribution.
41: *
42: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
43: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
44: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
45: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
46: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
48: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
49: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
51: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52: */
53:
54:
55: #include <sys/cdefs.h>
1.4.12.5! jym 56: __KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.7 2009/10/23 02:32:34 snj Exp $");
1.2 bouyer 57:
58: #include "opt_xen.h"
59:
60: #include <sys/param.h>
61: #include <sys/systm.h>
62: #include <sys/boot_flag.h>
63: #include <sys/mount.h>
64: #include <sys/reboot.h>
1.4 ad 65: #include <sys/timetc.h>
66:
1.2 bouyer 67: #include <xen/hypervisor.h>
68:
1.4 ad 69: u_int tsc_get_timecount(struct timecounter *);
70:
1.3 ad 71: uint64_t tsc_freq; /* XXX */
72:
1.2 bouyer 73: void
74: xen_parse_cmdline(int what, union xen_cmdline_parseinfo *xcp)
75: {
76: char _cmd_line[256], *cmd_line, *opt, *s;
77: int b, i, ipidx = 0;
78: uint32_t xi_ip[5];
79: size_t len;
80:
81: len = strlcpy(_cmd_line, xen_start_info.cmd_line, sizeof(_cmd_line));
82: if (len > sizeof(_cmd_line)) {
83: printf("command line exceeded limit of 255 chars. Truncated.\n");
84: }
85: cmd_line = _cmd_line;
86:
87: switch (what) {
88: case XEN_PARSE_BOOTDEV:
89: xcp->xcp_bootdev[0] = 0;
90: break;
91: case XEN_PARSE_CONSOLE:
92: xcp->xcp_console[0] = 0;
93: break;
94: }
95:
96: while (cmd_line && *cmd_line) {
97: opt = cmd_line;
98: cmd_line = strchr(opt, ' ');
99: if (cmd_line)
100: *cmd_line = 0;
101:
102: switch (what) {
103: case XEN_PARSE_BOOTDEV:
104: if (strncasecmp(opt, "bootdev=", 8) == 0) {
105: strncpy(xcp->xcp_bootdev, opt + 8,
106: sizeof(xcp->xcp_bootdev));
107: break;
108: }
109: if (strncasecmp(opt, "root=", 5) == 0) {
110: strncpy(xcp->xcp_bootdev, opt + 5,
111: sizeof(xcp->xcp_bootdev));
112: break;
113: }
114: break;
115:
116: case XEN_PARSE_NETINFO:
117: if (xcp->xcp_netinfo.xi_root &&
118: strncasecmp(opt, "nfsroot=", 8) == 0)
119: strncpy(xcp->xcp_netinfo.xi_root, opt + 8,
120: MNAMELEN);
121:
122: if (strncasecmp(opt, "ip=", 3) == 0) {
123: memset(xi_ip, 0, sizeof(xi_ip));
124: opt += 3;
125: ipidx = 0;
126: while (opt && *opt) {
127: s = opt;
128: opt = strchr(opt, ':');
129: if (opt)
130: *opt = 0;
131:
132: switch (ipidx) {
133: case 0: /* ip */
134: case 1: /* nfs server */
135: case 2: /* gw */
136: case 3: /* mask */
137: case 4: /* host */
138: if (*s == 0)
139: break;
140: for (i = 0; i < 4; i++) {
141: b = strtoul(s, &s, 10);
142: xi_ip[ipidx] = b + 256
143: * xi_ip[ipidx];
144: if (*s != '.')
145: break;
146: s++;
147: }
148: if (i < 3)
149: xi_ip[ipidx] = 0;
150: break;
151: case 5: /* interface */
152: if (!strncmp(s, "xennet", 6))
153: s += 6;
154: else if (!strncmp(s, "eth", 3))
155: s += 3;
156: else
157: break;
158: if (xcp->xcp_netinfo.xi_ifno
159: == strtoul(s, NULL, 10))
160: memcpy(xcp->
161: xcp_netinfo.xi_ip,
162: xi_ip,
163: sizeof(xi_ip));
164: break;
165: }
166: ipidx++;
167:
168: if (opt)
169: *opt++ = ':';
170: }
171: }
172: break;
173:
174: case XEN_PARSE_CONSOLE:
175: if (strncasecmp(opt, "console=", 8) == 0)
176: strncpy(xcp->xcp_console, opt + 8,
177: sizeof(xcp->xcp_console));
178: break;
179:
180: case XEN_PARSE_BOOTFLAGS:
181: if (*opt == '-') {
182: opt++;
183: while(*opt != '\0') {
184: BOOT_FLAG(*opt, boothowto);
185: opt++;
186: }
187: }
188: break;
1.4.12.2 jym 189: case XEN_PARSE_PCIBACK:
190: if (strncasecmp(opt, "pciback.hide=", 13) == 0)
191: strncpy(xcp->xcp_pcidevs, opt + 13,
192: sizeof(xcp->xcp_pcidevs));
193: break;
1.2 bouyer 194: }
195:
196: if (cmd_line)
197: *cmd_line++ = ' ';
198: }
199: }
1.4 ad 200:
201: u_int
202: tsc_get_timecount(struct timecounter *tc)
203: {
204:
205: panic("xen: tsc_get_timecount");
206: }
CVSweb <webmaster@jp.NetBSD.org>