ia64/xen-unstable

view xen/common/kernel.c @ 5650:95685fbba2ca

Replace implicit 16-byte arg to xen_extraversion with an
explicit typedef.
Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Jul 03 12:39:03 2005 +0000 (2005-07-03)
parents 649cd37aa1ab
children 09067ce92303 f8acd354e129
line source
1 /******************************************************************************
2 * kernel.c
3 *
4 * Copyright (c) 2002-2005 K A Fraser
5 */
7 #include <xen/config.h>
8 #include <xen/init.h>
9 #include <xen/lib.h>
10 #include <xen/errno.h>
11 #include <xen/compile.h>
12 #include <xen/sched.h>
13 #include <asm/current.h>
14 #include <public/version.h>
16 void cmdline_parse(char *cmdline)
17 {
18 char opt[100], *optval, *p = cmdline, *q;
19 struct kernel_param *param;
21 if ( p == NULL )
22 return;
24 /* Skip whitespace and the image name. */
25 while ( *p == ' ' )
26 p++;
27 if ( (p = strchr(p, ' ')) == NULL )
28 return;
30 for ( ; ; )
31 {
32 /* Skip whitespace. */
33 while ( *p == ' ' )
34 p++;
35 if ( *p == '\0' )
36 break;
38 /* Grab the next whitespace-delimited option. */
39 q = opt;
40 while ( (*p != ' ') && (*p != '\0') )
41 *q++ = *p++;
42 *q = '\0';
44 /* Search for value part of a key=value option. */
45 optval = strchr(opt, '=');
46 if ( optval != NULL )
47 *optval++ = '\0';
49 for ( param = &__setup_start; param != &__setup_end; param++ )
50 {
51 if ( strcmp(param->name, opt ) != 0 )
52 continue;
54 switch ( param->type )
55 {
56 case OPT_STR:
57 if ( optval != NULL )
58 {
59 strncpy(param->var, optval, param->len);
60 ((char *)param->var)[param->len-1] = '\0';
61 }
62 break;
63 case OPT_UINT:
64 if ( optval != NULL )
65 *(unsigned int *)param->var =
66 simple_strtol(optval, (char **)&optval, 0);
67 break;
68 case OPT_BOOL:
69 *(int *)param->var = 1;
70 break;
71 case OPT_CUSTOM:
72 if ( optval != NULL )
73 ((void (*)(char *))param->var)(optval);
74 break;
75 }
76 }
77 }
78 }
80 /*
81 * Simple hypercalls.
82 */
84 long do_xen_version(int cmd, void *arg)
85 {
86 switch ( cmd )
87 {
88 case XENVER_version:
89 {
90 return (XEN_VERSION<<16) | (XEN_SUBVERSION);
91 }
93 case XENVER_extraversion:
94 {
95 xen_extraversion_t extraversion;
96 safe_strcpy(extraversion, XEN_EXTRAVERSION);
97 if ( copy_to_user(arg, extraversion, sizeof(extraversion)) )
98 return -EFAULT;
99 return 0;
100 }
102 case XENVER_compile_info:
103 {
104 struct xen_compile_info info;
105 safe_strcpy(info.compiler, XEN_COMPILER);
106 safe_strcpy(info.compile_by, XEN_COMPILE_BY);
107 safe_strcpy(info.compile_domain, XEN_COMPILE_DOMAIN);
108 safe_strcpy(info.compile_date, XEN_COMPILE_DATE);
109 if ( copy_to_user(arg, &info, sizeof(info)) )
110 return -EFAULT;
111 return 0;
112 }
113 }
115 return -ENOSYS;
116 }
118 long do_vm_assist(unsigned int cmd, unsigned int type)
119 {
120 return vm_assist(current->domain, cmd, type);
121 }
123 long do_ni_hypercall(void)
124 {
125 /* No-op hypercall. */
126 return -ENOSYS;
127 }
129 /*
130 * Local variables:
131 * mode: C
132 * c-set-style: "BSD"
133 * c-basic-offset: 4
134 * tab-width: 4
135 * indent-tabs-mode: nil
136 * End:
137 */