2 * (C) Copyright 2007-2010 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
12 *! \tok{\sc STOre} \tok{\sc STOrage} <address> <value>
17 *! Sets a word in guest's storage at address to value
19 static int cmd_store_storage(struct virt_sys
*sys
, char *cmd
, int len
)
22 u64 guest_addr
, host_addr
;
25 SHELL_CMD_AUTH(sys
, G
);
27 cmd
= parse_addrspec(&guest_addr
, NULL
, cmd
);
29 con_printf(sys
->con
, "STORE: Invalid addr-spec\n");
33 /* consume any extra whitespace */
34 cmd
= __consume_ws(cmd
);
37 cmd
= __extract_hex(cmd
, &val
);
42 * round down to the nearest word
44 guest_addr
&= ~((u64
) 3ULL);
46 /* walk the page tables to find the real page frame */
47 ret
= virt2phy_current(guest_addr
, &host_addr
);
49 con_printf(sys
->con
, "STORE: Specified address is not part of "
50 "guest configuration\n");
54 *((u32
*) host_addr
) = (u32
) val
;
56 con_printf(sys
->con
, "Store complete.\n");
64 *! \tok{\sc STOre} \tok{\sc Gpr} <gpr> <value>
68 *! Sets a guest's general purpose register to the specified value
70 static int cmd_store_gpr(struct virt_sys
*sys
, char *cmd
, int len
)
72 u64
*ptr
= (u64
*) &sys
->task
->cpu
->regs
.gpr
;
75 SHELL_CMD_AUTH(sys
, G
);
77 cmd
= __extract_dec(cmd
, &gpr
);
83 cmd
= __consume_ws(cmd
);
85 cmd
= __extract_hex(cmd
, &val
);
91 con_printf(sys
->con
, "Store complete.\n");
99 *! \tok{\sc STOre} \tok{\sc Fpr} <fpr> <value>
103 *! Sets a guest's floating point register to the specified value
105 static int cmd_store_fpr(struct virt_sys
*sys
, char *cmd
, int len
)
107 u64
*ptr
= (u64
*) &sys
->task
->cpu
->regs
.fpr
;
110 SHELL_CMD_AUTH(sys
, G
);
112 cmd
= __extract_dec(cmd
, &fpr
);
118 cmd
= __consume_ws(cmd
);
120 cmd
= __extract_hex(cmd
, &val
);
126 con_printf(sys
->con
, "Store complete.\n");
134 *! \tok{\sc STOre} \tok{\sc FPCR} <value>
138 *! Sets a guest's floating point control register to the specified value
140 static int cmd_store_fpcr(struct virt_sys
*sys
, char *cmd
, int len
)
144 SHELL_CMD_AUTH(sys
, G
);
146 cmd
= __extract_hex(cmd
, &val
);
149 if (val
> 0xffffffffULL
)
152 sys
->task
->cpu
->regs
.fpcr
= (u32
) val
;
154 con_printf(sys
->con
, "Store complete.\n");
162 *! \tok{\sc STOre} \tok{\sc Cr} <cr> <value>
166 *! Sets a guest's control register to the specified value
168 static int cmd_store_cr(struct virt_sys
*sys
, char *cmd
, int len
)
170 u64
*ptr
= (u64
*) &sys
->task
->cpu
->sie_cb
.gcr
;
173 SHELL_CMD_AUTH(sys
, G
);
175 cmd
= __extract_dec(cmd
, &cr
);
181 cmd
= __consume_ws(cmd
);
183 cmd
= __extract_hex(cmd
, &val
);
189 con_printf(sys
->con
, "Store complete.\n");
197 *! \tok{\sc STOre} \tok{\sc Ar} <ar> <value>
201 *! Sets a guest's access register to the specified value
203 static int cmd_store_ar(struct virt_sys
*sys
, char *cmd
, int len
)
205 u32
*ptr
= (u32
*) &sys
->task
->cpu
->regs
.ar
;
208 SHELL_CMD_AUTH(sys
, G
);
210 cmd
= __extract_dec(cmd
, &ar
);
216 cmd
= __consume_ws(cmd
);
218 cmd
= __extract_hex(cmd
, &val
);
221 if (val
> 0xffffffffULL
)
226 con_printf(sys
->con
, "Store complete.\n");
235 *! \tok{\sc STOre} \tok{\sc PSW}
238 *! \begin{stack} \\ <hexword1>
239 *! \end{stack} <hexword2>
240 *! \end{stack} <hexword3>
248 *! Alters all or a part of the PSW.
253 *! \textbf{For an ESA/390 guest:}
255 *! Alters all or part of the PSW with the data specified in hexword3
256 *! and hexword4. If only hexword4 is specified, it is stored to PSW bits
257 *! 32-63. If hexword3 and hexword4 are specified, hexword3 is stored to
258 *! PSW bits 0-31, and hexword4 to PSW bits 32-63.
260 *! If more than two values are specified, the PSW remains unchanged and an
261 *! message indicating an error is printed.
263 *! \textbf{For a z/Architecture guest:}
265 *! If only one hexword4 is specified, PSW bits 96-127 are set to it.
267 *! If hexword3 and hexword4 are specified, PSW bits 64-95 are set to
268 *! hexword3, and bits 96-127 are set to hexword4.
270 *! If hexword2, hexword3, and hexword4 are specified, PSW bits 32-63 are
271 *! set to hexword2, bits 64-95 are set to hexword3, and bits 96-127 are
274 *! If hexword1, hexword2, hexword3, and hexword4 are specified, PSW bits
275 *! 0-31 are set to hexword1, bits 32-63 are set to hexword2, bits 64-95
276 *! are set to hexword3, and bits 96-127 are set to hexword4.
280 static int cmd_store_psw(struct virt_sys
*sys
, char *cmd
, int len
)
282 u32
*ptr
= (u32
*) &sys
->task
->cpu
->sie_cb
.gpsw
;
284 u64 new_words
[4] = {0, 0, 0, 0};
287 SHELL_CMD_AUTH(sys
, G
);
289 for (cnt
=0; cnt
<4; cnt
++) {
290 cmd
= __extract_hex(cmd
, &new_words
[cnt
]);
294 cmd
= __consume_ws(cmd
);
300 if (!VCPU_ZARCH(sys
->task
->cpu
)) {
303 con_printf(sys
->con
, "STORE: ERROR ESA/390 PSW USES ONLY TWO WORDS\n");
308 * This is a simple "hack" to make the stores go into the
309 * right place. If he had a single word, we want it to go
310 * the the second word of the 16-byte PSW, not the 4th.
311 * Similarly, if we had two words, we want them to go into
312 * the first and second words of the 16-byte PSW.
319 ptr
[0] = (u32
) new_words
[0];
320 ptr
[1] = (u32
) new_words
[1];
321 ptr
[2] = (u32
) new_words
[2];
322 ptr
[3] = (u32
) new_words
[3];
325 ptr
[1] = (u32
) new_words
[0];
326 ptr
[2] = (u32
) new_words
[1];
327 ptr
[3] = (u32
) new_words
[2];
330 ptr
[2] = (u32
) new_words
[0];
331 ptr
[3] = (u32
) new_words
[1];
334 ptr
[3] = (u32
) new_words
[0];
340 con_printf(sys
->con
, "Store complete.\n");
344 static struct cpcmd cmd_tbl_store
[] = {
345 {"AR", cmd_store_ar
, NULL
},
346 {"A", cmd_store_ar
, NULL
},
348 {"CR", cmd_store_cr
, NULL
},
349 {"C", cmd_store_cr
, NULL
},
351 {"FPCR", cmd_store_fpcr
, NULL
},
353 {"FPR", cmd_store_fpr
, NULL
},
354 {"FP", cmd_store_fpr
, NULL
},
355 {"F", cmd_store_fpr
, NULL
},
357 {"GPR", cmd_store_gpr
, NULL
},
358 {"GP", cmd_store_gpr
, NULL
},
359 {"G", cmd_store_gpr
, NULL
},
361 {"PSW", cmd_store_psw
, NULL
},
363 {"STORAGE", cmd_store_storage
, NULL
},
364 {"STORAG", cmd_store_storage
, NULL
},
365 {"STORA", cmd_store_storage
, NULL
},
366 {"STOR", cmd_store_storage
, NULL
},
367 {"STO", cmd_store_storage
, NULL
},