From patchwork Thu Feb 7 11:28:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: pseries: Implements h_read hcall Date: Thu, 07 Feb 2013 01:28:20 -0000 From: Erlon Cruz X-Patchwork-Id: 218894 Message-Id: <1360236500-5613-1-git-send-email-erlon.cruz@fit-tecnologia.org.br> To: david@gibson.dropbear.id.au, agraf@suse.de Cc: Erlon Cruz , qemu-ppc@nongnu.org, qemu-devel@nongnu.org From: Erlon Cruz This h_call is useful for DLPAR in future amongst other things. Given an index it fetches the corresponding PTE stored in the htab. Signed-off-by: Erlon Cruz --- hw/spapr_hcall.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c index 2889742..5ba07e5 100644 --- a/hw/spapr_hcall.c +++ b/hw/spapr_hcall.c @@ -323,6 +323,63 @@ static target_ulong h_protect(PowerPCCPU *cpu, sPAPREnvironment *spapr, return H_SUCCESS; } +static target_ulong h_read(PowerPCCPU *cpu, sPAPREnvironment *spapr, + target_ulong opcode, target_ulong *args) +{ + CPUPPCState *env = &cpu->env; + target_ulong flags = args[0]; + target_ulong pte_index = args[1]; + uint8_t *hpte; + + if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) { + return H_PARAMETER; + } + + if (!(flags & H_READ_4)) { + target_ulong v, r; + target_ulong *pteh = &args[0]; + target_ulong *ptel = &args[1]; + + hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64); + + v = ldq_p(hpte); + r = ldq_p(hpte + (HASH_PTE_SIZE_64/2)); + + if (flags & H_R_XLATE) { + /* FIXME: include a valid logical page num in the pte */ + ; + } + + *pteh = v; + *ptel = r; + + } else { + int i, ridx = 0; + target_ulong v[4], r[4]; + + /* Clear the two low order bits */ + pte_index &= ~(3ULL); + hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64); + + for (i = 0; i < 4; i++) { + v[i] = ldq_p(hpte); + r[i] = ldq_p(hpte + (HASH_PTE_SIZE_64/2)); + + if (flags & H_R_XLATE) { + /* FIXME: include a valid logical page num in the pte */ + ; + } + + args[ridx++] = v[i]; + args[ridx++] = r[i]; + + hpte += HASH_PTE_SIZE_64; + } + } + + return H_SUCCESS; +} + static target_ulong h_set_dabr(PowerPCCPU *cpu, sPAPREnvironment *spapr, target_ulong opcode, target_ulong *args) { @@ -714,6 +771,7 @@ static void hypercall_register_types(void) spapr_register_hypercall(H_ENTER, h_enter); spapr_register_hypercall(H_REMOVE, h_remove); spapr_register_hypercall(H_PROTECT, h_protect); + spapr_register_hypercall(H_READ, h_read); /* hcall-bulk */ spapr_register_hypercall(H_BULK_REMOVE, h_bulk_remove);