2 * QEMU PowerPC pSeries Logical Partition (aka sPAPR) hardware System Emulator
4 * Hypercall based emulated RTAS
6 * Copyright (c) 2010-2011 David Gibson, IBM Corporation.
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 #include "qemu/osdep.h"
30 #include "qemu/error-report.h"
31 #include "sysemu/sysemu.h"
32 #include "sysemu/char.h"
34 #include "sysemu/device_tree.h"
35 #include "sysemu/cpus.h"
36 #include "sysemu/kvm.h"
38 #include "hw/ppc/spapr.h"
39 #include "hw/ppc/spapr_vio.h"
40 #include "hw/ppc/spapr_rtas.h"
41 #include "hw/ppc/ppc.h"
42 #include "qapi-event.h"
43 #include "hw/boards.h"
46 #include "hw/ppc/spapr_drc.h"
47 #include "qemu/cutils.h"
49 #include "hw/ppc/fdt.h"
51 static sPAPRConfigureConnectorState
*spapr_ccs_find(sPAPRMachineState
*spapr
,
54 sPAPRConfigureConnectorState
*ccs
= NULL
;
56 QTAILQ_FOREACH(ccs
, &spapr
->ccs_list
, next
) {
57 if (ccs
->drc_index
== drc_index
) {
65 static void spapr_ccs_add(sPAPRMachineState
*spapr
,
66 sPAPRConfigureConnectorState
*ccs
)
68 g_assert(!spapr_ccs_find(spapr
, ccs
->drc_index
));
69 QTAILQ_INSERT_HEAD(&spapr
->ccs_list
, ccs
, next
);
72 static void spapr_ccs_remove(sPAPRMachineState
*spapr
,
73 sPAPRConfigureConnectorState
*ccs
)
75 QTAILQ_REMOVE(&spapr
->ccs_list
, ccs
, next
);
79 void spapr_ccs_reset_hook(void *opaque
)
81 sPAPRMachineState
*spapr
= opaque
;
82 sPAPRConfigureConnectorState
*ccs
, *ccs_tmp
;
84 QTAILQ_FOREACH_SAFE(ccs
, &spapr
->ccs_list
, next
, ccs_tmp
) {
85 spapr_ccs_remove(spapr
, ccs
);
89 static void rtas_display_character(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
90 uint32_t token
, uint32_t nargs
,
92 uint32_t nret
, target_ulong rets
)
94 uint8_t c
= rtas_ld(args
, 0);
95 VIOsPAPRDevice
*sdev
= vty_lookup(spapr
, 0);
98 rtas_st(rets
, 0, RTAS_OUT_HW_ERROR
);
100 vty_putchars(sdev
, &c
, sizeof(c
));
101 rtas_st(rets
, 0, RTAS_OUT_SUCCESS
);
105 static void rtas_power_off(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
106 uint32_t token
, uint32_t nargs
, target_ulong args
,
107 uint32_t nret
, target_ulong rets
)
109 if (nargs
!= 2 || nret
!= 1) {
110 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
113 qemu_system_shutdown_request();
115 rtas_st(rets
, 0, RTAS_OUT_SUCCESS
);
118 static void rtas_system_reboot(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
119 uint32_t token
, uint32_t nargs
,
121 uint32_t nret
, target_ulong rets
)
123 if (nargs
!= 0 || nret
!= 1) {
124 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
127 qemu_system_reset_request();
128 rtas_st(rets
, 0, RTAS_OUT_SUCCESS
);
131 static void rtas_query_cpu_stopped_state(PowerPCCPU
*cpu_
,
132 sPAPRMachineState
*spapr
,
133 uint32_t token
, uint32_t nargs
,
135 uint32_t nret
, target_ulong rets
)
140 if (nargs
!= 1 || nret
!= 2) {
141 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
145 id
= rtas_ld(args
, 0);
146 cpu
= ppc_get_vcpu_by_dt_id(id
);
148 if (CPU(cpu
)->halted
) {
154 rtas_st(rets
, 0, RTAS_OUT_SUCCESS
);
158 /* Didn't find a matching cpu */
159 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
163 * Set the timebase offset of the CPU to that of first CPU.
164 * This helps hotplugged CPU to have the correct timebase offset.
166 static void spapr_cpu_update_tb_offset(PowerPCCPU
*cpu
)
168 PowerPCCPU
*fcpu
= POWERPC_CPU(first_cpu
);
170 cpu
->env
.tb_env
->tb_offset
= fcpu
->env
.tb_env
->tb_offset
;
173 static void spapr_cpu_set_endianness(PowerPCCPU
*cpu
)
175 PowerPCCPU
*fcpu
= POWERPC_CPU(first_cpu
);
176 PowerPCCPUClass
*pcc
= POWERPC_CPU_GET_CLASS(fcpu
);
178 if (!pcc
->interrupts_big_endian(fcpu
)) {
179 cpu
->env
.spr
[SPR_LPCR
] |= LPCR_ILE
;
183 static void rtas_start_cpu(PowerPCCPU
*cpu_
, sPAPRMachineState
*spapr
,
184 uint32_t token
, uint32_t nargs
,
186 uint32_t nret
, target_ulong rets
)
188 target_ulong id
, start
, r3
;
191 if (nargs
!= 3 || nret
!= 1) {
192 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
196 id
= rtas_ld(args
, 0);
197 start
= rtas_ld(args
, 1);
198 r3
= rtas_ld(args
, 2);
200 cpu
= ppc_get_vcpu_by_dt_id(id
);
202 CPUState
*cs
= CPU(cpu
);
203 CPUPPCState
*env
= &cpu
->env
;
206 rtas_st(rets
, 0, RTAS_OUT_HW_ERROR
);
210 /* This will make sure qemu state is up to date with kvm, and
211 * mark it dirty so our changes get flushed back before the
213 kvm_cpu_synchronize_state(cs
);
215 env
->msr
= (1ULL << MSR_SF
) | (1ULL << MSR_ME
);
219 spapr_cpu_set_endianness(cpu
);
220 spapr_cpu_update_tb_offset(cpu
);
224 rtas_st(rets
, 0, RTAS_OUT_SUCCESS
);
228 /* Didn't find a matching cpu */
229 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
232 static void rtas_stop_self(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
233 uint32_t token
, uint32_t nargs
,
235 uint32_t nret
, target_ulong rets
)
237 CPUState
*cs
= CPU(cpu
);
238 CPUPPCState
*env
= &cpu
->env
;
243 * While stopping a CPU, the guest calls H_CPPR which
244 * effectively disables interrupts on XICS level.
245 * However decrementer interrupts in TCG can still
246 * wake the CPU up so here we disable interrupts in MSR
248 * As rtas_start_cpu() resets the whole MSR anyway, there is
249 * no need to bother with specific bits, we just clear it.
254 static inline int sysparm_st(target_ulong addr
, target_ulong len
,
255 const void *val
, uint16_t vallen
)
257 hwaddr phys
= ppc64_phys_to_real(addr
);
260 return RTAS_OUT_SYSPARM_PARAM_ERROR
;
262 stw_be_phys(&address_space_memory
, phys
, vallen
);
263 cpu_physical_memory_write(phys
+ 2, val
, MIN(len
- 2, vallen
));
264 return RTAS_OUT_SUCCESS
;
267 static void rtas_ibm_get_system_parameter(PowerPCCPU
*cpu
,
268 sPAPRMachineState
*spapr
,
269 uint32_t token
, uint32_t nargs
,
271 uint32_t nret
, target_ulong rets
)
273 target_ulong parameter
= rtas_ld(args
, 0);
274 target_ulong buffer
= rtas_ld(args
, 1);
275 target_ulong length
= rtas_ld(args
, 2);
279 case RTAS_SYSPARM_SPLPAR_CHARACTERISTICS
: {
280 char *param_val
= g_strdup_printf("MaxEntCap=%d,"
285 current_machine
->ram_size
/ M_BYTE
,
288 ret
= sysparm_st(buffer
, length
, param_val
, strlen(param_val
) + 1);
292 case RTAS_SYSPARM_DIAGNOSTICS_RUN_MODE
: {
293 uint8_t param_val
= DIAGNOSTICS_RUN_MODE_DISABLED
;
295 ret
= sysparm_st(buffer
, length
, ¶m_val
, sizeof(param_val
));
298 case RTAS_SYSPARM_UUID
:
299 ret
= sysparm_st(buffer
, length
, (unsigned char *)&qemu_uuid
,
300 (qemu_uuid_set
? 16 : 0));
303 ret
= RTAS_OUT_NOT_SUPPORTED
;
306 rtas_st(rets
, 0, ret
);
309 static void rtas_ibm_set_system_parameter(PowerPCCPU
*cpu
,
310 sPAPRMachineState
*spapr
,
311 uint32_t token
, uint32_t nargs
,
313 uint32_t nret
, target_ulong rets
)
315 target_ulong parameter
= rtas_ld(args
, 0);
316 target_ulong ret
= RTAS_OUT_NOT_SUPPORTED
;
319 case RTAS_SYSPARM_SPLPAR_CHARACTERISTICS
:
320 case RTAS_SYSPARM_DIAGNOSTICS_RUN_MODE
:
321 case RTAS_SYSPARM_UUID
:
322 ret
= RTAS_OUT_NOT_AUTHORIZED
;
326 rtas_st(rets
, 0, ret
);
329 static void rtas_ibm_os_term(PowerPCCPU
*cpu
,
330 sPAPRMachineState
*spapr
,
331 uint32_t token
, uint32_t nargs
,
333 uint32_t nret
, target_ulong rets
)
335 target_ulong ret
= 0;
337 qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE
, &error_abort
);
339 rtas_st(rets
, 0, ret
);
342 static void rtas_set_power_level(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
343 uint32_t token
, uint32_t nargs
,
344 target_ulong args
, uint32_t nret
,
347 int32_t power_domain
;
349 if (nargs
!= 2 || nret
!= 2) {
350 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
354 /* we currently only use a single, "live insert" powerdomain for
355 * hotplugged/dlpar'd resources, so the power is always live/full (100)
357 power_domain
= rtas_ld(args
, 0);
358 if (power_domain
!= -1) {
359 rtas_st(rets
, 0, RTAS_OUT_NOT_SUPPORTED
);
363 rtas_st(rets
, 0, RTAS_OUT_SUCCESS
);
364 rtas_st(rets
, 1, 100);
367 static void rtas_get_power_level(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
368 uint32_t token
, uint32_t nargs
,
369 target_ulong args
, uint32_t nret
,
372 int32_t power_domain
;
374 if (nargs
!= 1 || nret
!= 2) {
375 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
379 /* we currently only use a single, "live insert" powerdomain for
380 * hotplugged/dlpar'd resources, so the power is always live/full (100)
382 power_domain
= rtas_ld(args
, 0);
383 if (power_domain
!= -1) {
384 rtas_st(rets
, 0, RTAS_OUT_NOT_SUPPORTED
);
388 rtas_st(rets
, 0, RTAS_OUT_SUCCESS
);
389 rtas_st(rets
, 1, 100);
392 static bool sensor_type_is_dr(uint32_t sensor_type
)
394 switch (sensor_type
) {
395 case RTAS_SENSOR_TYPE_ISOLATION_STATE
:
396 case RTAS_SENSOR_TYPE_DR
:
397 case RTAS_SENSOR_TYPE_ALLOCATION_STATE
:
404 static void rtas_set_indicator(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
405 uint32_t token
, uint32_t nargs
,
406 target_ulong args
, uint32_t nret
,
409 uint32_t sensor_type
;
410 uint32_t sensor_index
;
411 uint32_t sensor_state
;
412 uint32_t ret
= RTAS_OUT_SUCCESS
;
413 sPAPRDRConnector
*drc
;
414 sPAPRDRConnectorClass
*drck
;
416 if (nargs
!= 3 || nret
!= 1) {
417 ret
= RTAS_OUT_PARAM_ERROR
;
421 sensor_type
= rtas_ld(args
, 0);
422 sensor_index
= rtas_ld(args
, 1);
423 sensor_state
= rtas_ld(args
, 2);
425 if (!sensor_type_is_dr(sensor_type
)) {
426 goto out_unimplemented
;
429 /* if this is a DR sensor we can assume sensor_index == drc_index */
430 drc
= spapr_dr_connector_by_index(sensor_index
);
432 trace_spapr_rtas_set_indicator_invalid(sensor_index
);
433 ret
= RTAS_OUT_PARAM_ERROR
;
436 drck
= SPAPR_DR_CONNECTOR_GET_CLASS(drc
);
438 switch (sensor_type
) {
439 case RTAS_SENSOR_TYPE_ISOLATION_STATE
:
440 /* if the guest is configuring a device attached to this
441 * DRC, we should reset the configuration state at this
442 * point since it may no longer be reliable (guest released
443 * device and needs to start over, or unplug occurred so
444 * the FDT is no longer valid)
446 if (sensor_state
== SPAPR_DR_ISOLATION_STATE_ISOLATED
) {
447 sPAPRConfigureConnectorState
*ccs
= spapr_ccs_find(spapr
,
450 spapr_ccs_remove(spapr
, ccs
);
453 ret
= drck
->set_isolation_state(drc
, sensor_state
);
455 case RTAS_SENSOR_TYPE_DR
:
456 ret
= drck
->set_indicator_state(drc
, sensor_state
);
458 case RTAS_SENSOR_TYPE_ALLOCATION_STATE
:
459 ret
= drck
->set_allocation_state(drc
, sensor_state
);
462 goto out_unimplemented
;
466 rtas_st(rets
, 0, ret
);
470 /* currently only DR-related sensors are implemented */
471 trace_spapr_rtas_set_indicator_not_supported(sensor_index
, sensor_type
);
472 rtas_st(rets
, 0, RTAS_OUT_NOT_SUPPORTED
);
475 static void rtas_get_sensor_state(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
476 uint32_t token
, uint32_t nargs
,
477 target_ulong args
, uint32_t nret
,
480 uint32_t sensor_type
;
481 uint32_t sensor_index
;
482 uint32_t sensor_state
= 0;
483 sPAPRDRConnector
*drc
;
484 sPAPRDRConnectorClass
*drck
;
485 uint32_t ret
= RTAS_OUT_SUCCESS
;
487 if (nargs
!= 2 || nret
!= 2) {
488 ret
= RTAS_OUT_PARAM_ERROR
;
492 sensor_type
= rtas_ld(args
, 0);
493 sensor_index
= rtas_ld(args
, 1);
495 if (sensor_type
!= RTAS_SENSOR_TYPE_ENTITY_SENSE
) {
496 /* currently only DR-related sensors are implemented */
497 trace_spapr_rtas_get_sensor_state_not_supported(sensor_index
,
499 ret
= RTAS_OUT_NOT_SUPPORTED
;
503 drc
= spapr_dr_connector_by_index(sensor_index
);
505 trace_spapr_rtas_get_sensor_state_invalid(sensor_index
);
506 ret
= RTAS_OUT_PARAM_ERROR
;
509 drck
= SPAPR_DR_CONNECTOR_GET_CLASS(drc
);
510 ret
= drck
->entity_sense(drc
, &sensor_state
);
513 rtas_st(rets
, 0, ret
);
514 rtas_st(rets
, 1, sensor_state
);
517 /* configure-connector work area offsets, int32_t units for field
518 * indexes, bytes for field offset/len values.
520 * as documented by PAPR+ v2.7, 13.5.3.5
522 #define CC_IDX_NODE_NAME_OFFSET 2
523 #define CC_IDX_PROP_NAME_OFFSET 2
524 #define CC_IDX_PROP_LEN 3
525 #define CC_IDX_PROP_DATA_OFFSET 4
526 #define CC_VAL_DATA_OFFSET ((CC_IDX_PROP_DATA_OFFSET + 1) * 4)
527 #define CC_WA_LEN 4096
529 static void configure_connector_st(target_ulong addr
, target_ulong offset
,
530 const void *buf
, size_t len
)
532 cpu_physical_memory_write(ppc64_phys_to_real(addr
+ offset
),
533 buf
, MIN(len
, CC_WA_LEN
- offset
));
536 static void rtas_ibm_configure_connector(PowerPCCPU
*cpu
,
537 sPAPRMachineState
*spapr
,
538 uint32_t token
, uint32_t nargs
,
539 target_ulong args
, uint32_t nret
,
545 sPAPRDRConnector
*drc
;
546 sPAPRDRConnectorClass
*drck
;
547 sPAPRConfigureConnectorState
*ccs
;
548 sPAPRDRCCResponse resp
= SPAPR_DR_CC_RESPONSE_CONTINUE
;
552 if (nargs
!= 2 || nret
!= 1) {
553 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
557 wa_addr
= ((uint64_t)rtas_ld(args
, 1) << 32) | rtas_ld(args
, 0);
559 drc_index
= rtas_ld(wa_addr
, 0);
560 drc
= spapr_dr_connector_by_index(drc_index
);
562 trace_spapr_rtas_ibm_configure_connector_invalid(drc_index
);
563 rc
= RTAS_OUT_PARAM_ERROR
;
567 drck
= SPAPR_DR_CONNECTOR_GET_CLASS(drc
);
568 fdt
= drck
->get_fdt(drc
, NULL
);
570 trace_spapr_rtas_ibm_configure_connector_missing_fdt(drc_index
);
571 rc
= SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE
;
575 ccs
= spapr_ccs_find(spapr
, drc_index
);
577 ccs
= g_new0(sPAPRConfigureConnectorState
, 1);
578 (void)drck
->get_fdt(drc
, &ccs
->fdt_offset
);
579 ccs
->drc_index
= drc_index
;
580 spapr_ccs_add(spapr
, ccs
);
586 const struct fdt_property
*prop
;
587 int fdt_offset_next
, prop_len
;
589 tag
= fdt_next_tag(fdt
, ccs
->fdt_offset
, &fdt_offset_next
);
594 name
= fdt_get_name(fdt
, ccs
->fdt_offset
, NULL
);
596 /* provide the name of the next OF node */
597 wa_offset
= CC_VAL_DATA_OFFSET
;
598 rtas_st(wa_addr
, CC_IDX_NODE_NAME_OFFSET
, wa_offset
);
599 configure_connector_st(wa_addr
, wa_offset
, name
, strlen(name
) + 1);
600 resp
= SPAPR_DR_CC_RESPONSE_NEXT_CHILD
;
604 if (ccs
->fdt_depth
== 0) {
605 /* done sending the device tree, don't need to track
608 drck
->set_configured(drc
);
609 spapr_ccs_remove(spapr
, ccs
);
611 resp
= SPAPR_DR_CC_RESPONSE_SUCCESS
;
613 resp
= SPAPR_DR_CC_RESPONSE_PREV_PARENT
;
617 prop
= fdt_get_property_by_offset(fdt
, ccs
->fdt_offset
,
619 name
= fdt_string(fdt
, fdt32_to_cpu(prop
->nameoff
));
621 /* provide the name of the next OF property */
622 wa_offset
= CC_VAL_DATA_OFFSET
;
623 rtas_st(wa_addr
, CC_IDX_PROP_NAME_OFFSET
, wa_offset
);
624 configure_connector_st(wa_addr
, wa_offset
, name
, strlen(name
) + 1);
626 /* provide the length and value of the OF property. data gets
627 * placed immediately after NULL terminator of the OF property's
630 wa_offset
+= strlen(name
) + 1,
631 rtas_st(wa_addr
, CC_IDX_PROP_LEN
, prop_len
);
632 rtas_st(wa_addr
, CC_IDX_PROP_DATA_OFFSET
, wa_offset
);
633 configure_connector_st(wa_addr
, wa_offset
, prop
->data
, prop_len
);
634 resp
= SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY
;
637 resp
= SPAPR_DR_CC_RESPONSE_ERROR
;
639 /* keep seeking for an actionable tag */
643 ccs
->fdt_offset
= fdt_offset_next
;
645 } while (resp
== SPAPR_DR_CC_RESPONSE_CONTINUE
);
649 rtas_st(rets
, 0, rc
);
652 static struct rtas_call
{
655 } rtas_table
[RTAS_TOKEN_MAX
- RTAS_TOKEN_BASE
];
657 target_ulong
spapr_rtas_call(PowerPCCPU
*cpu
, sPAPRMachineState
*spapr
,
658 uint32_t token
, uint32_t nargs
, target_ulong args
,
659 uint32_t nret
, target_ulong rets
)
661 if ((token
>= RTAS_TOKEN_BASE
) && (token
< RTAS_TOKEN_MAX
)) {
662 struct rtas_call
*call
= rtas_table
+ (token
- RTAS_TOKEN_BASE
);
665 call
->fn(cpu
, spapr
, token
, nargs
, args
, nret
, rets
);
670 /* HACK: Some Linux early debug code uses RTAS display-character,
671 * but assumes the token value is 0xa (which it is on some real
672 * machines) without looking it up in the device tree. This
673 * special case makes this work */
675 rtas_display_character(cpu
, spapr
, 0xa, nargs
, args
, nret
, rets
);
679 hcall_dprintf("Unknown RTAS token 0x%x\n", token
);
680 rtas_st(rets
, 0, RTAS_OUT_PARAM_ERROR
);
684 uint64_t qtest_rtas_call(char *cmd
, uint32_t nargs
, uint64_t args
,
685 uint32_t nret
, uint64_t rets
)
689 for (token
= 0; token
< RTAS_TOKEN_MAX
- RTAS_TOKEN_BASE
; token
++) {
690 if (strcmp(cmd
, rtas_table
[token
].name
) == 0) {
691 sPAPRMachineState
*spapr
= SPAPR_MACHINE(qdev_get_machine());
692 PowerPCCPU
*cpu
= POWERPC_CPU(first_cpu
);
694 rtas_table
[token
].fn(cpu
, spapr
, token
+ RTAS_TOKEN_BASE
,
695 nargs
, args
, nret
, rets
);
702 void spapr_rtas_register(int token
, const char *name
, spapr_rtas_fn fn
)
704 assert((token
>= RTAS_TOKEN_BASE
) && (token
< RTAS_TOKEN_MAX
));
706 token
-= RTAS_TOKEN_BASE
;
708 assert(!rtas_table
[token
].name
);
710 rtas_table
[token
].name
= name
;
711 rtas_table
[token
].fn
= fn
;
714 void spapr_dt_rtas_tokens(void *fdt
, int rtas
)
718 for (i
= 0; i
< RTAS_TOKEN_MAX
- RTAS_TOKEN_BASE
; i
++) {
719 struct rtas_call
*call
= &rtas_table
[i
];
725 _FDT(fdt_setprop_cell(fdt
, rtas
, call
->name
, i
+ RTAS_TOKEN_BASE
));
729 void spapr_load_rtas(sPAPRMachineState
*spapr
, void *fdt
, hwaddr addr
)
734 /* Copy RTAS blob into guest RAM */
735 cpu_physical_memory_write(addr
, spapr
->rtas_blob
, spapr
->rtas_size
);
737 ret
= fdt_add_mem_rsv(fdt
, addr
, spapr
->rtas_size
);
739 error_report("Couldn't add RTAS reserve entry: %s",
744 /* Update the device tree with the blob's location */
745 rtas_node
= fdt_path_offset(fdt
, "/rtas");
746 assert(rtas_node
>= 0);
748 ret
= fdt_setprop_cell(fdt
, rtas_node
, "linux,rtas-base", addr
);
750 error_report("Couldn't add linux,rtas-base property: %s",
755 ret
= fdt_setprop_cell(fdt
, rtas_node
, "linux,rtas-entry", addr
);
757 error_report("Couldn't add linux,rtas-entry property: %s",
762 ret
= fdt_setprop_cell(fdt
, rtas_node
, "rtas-size", spapr
->rtas_size
);
764 error_report("Couldn't add rtas-size property: %s",
770 static void core_rtas_register_types(void)
772 spapr_rtas_register(RTAS_DISPLAY_CHARACTER
, "display-character",
773 rtas_display_character
);
774 spapr_rtas_register(RTAS_POWER_OFF
, "power-off", rtas_power_off
);
775 spapr_rtas_register(RTAS_SYSTEM_REBOOT
, "system-reboot",
777 spapr_rtas_register(RTAS_QUERY_CPU_STOPPED_STATE
, "query-cpu-stopped-state",
778 rtas_query_cpu_stopped_state
);
779 spapr_rtas_register(RTAS_START_CPU
, "start-cpu", rtas_start_cpu
);
780 spapr_rtas_register(RTAS_STOP_SELF
, "stop-self", rtas_stop_self
);
781 spapr_rtas_register(RTAS_IBM_GET_SYSTEM_PARAMETER
,
782 "ibm,get-system-parameter",
783 rtas_ibm_get_system_parameter
);
784 spapr_rtas_register(RTAS_IBM_SET_SYSTEM_PARAMETER
,
785 "ibm,set-system-parameter",
786 rtas_ibm_set_system_parameter
);
787 spapr_rtas_register(RTAS_IBM_OS_TERM
, "ibm,os-term",
789 spapr_rtas_register(RTAS_SET_POWER_LEVEL
, "set-power-level",
790 rtas_set_power_level
);
791 spapr_rtas_register(RTAS_GET_POWER_LEVEL
, "get-power-level",
792 rtas_get_power_level
);
793 spapr_rtas_register(RTAS_SET_INDICATOR
, "set-indicator",
795 spapr_rtas_register(RTAS_GET_SENSOR_STATE
, "get-sensor-state",
796 rtas_get_sensor_state
);
797 spapr_rtas_register(RTAS_IBM_CONFIGURE_CONNECTOR
, "ibm,configure-connector",
798 rtas_ibm_configure_connector
);
801 type_init(core_rtas_register_types
)