Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hw/ppc: add a ppc_create_page_sizes_prop() helper routine
The exact same routine will be used in PowerNV. Signed-off-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
- Loading branch information
Showing
4 changed files
with
56 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* QEMU PowerPC helper routines for the device tree. | ||
* | ||
* Copyright (C) 2016 IBM Corp. | ||
* | ||
* This code is licensed under the GPL version 2 or later. See the | ||
* COPYING file in the top-level directory. | ||
*/ | ||
|
||
#include "qemu/osdep.h" | ||
#include "qapi/error.h" | ||
#include "target-ppc/cpu.h" | ||
|
||
#include "hw/ppc/fdt.h" | ||
|
||
#if defined(TARGET_PPC64) | ||
size_t ppc_create_page_sizes_prop(CPUPPCState *env, uint32_t *prop, | ||
size_t maxsize) | ||
{ | ||
size_t maxcells = maxsize / sizeof(uint32_t); | ||
int i, j, count; | ||
uint32_t *p = prop; | ||
|
||
for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { | ||
struct ppc_one_seg_page_size *sps = &env->sps.sps[i]; | ||
|
||
if (!sps->page_shift) { | ||
break; | ||
} | ||
for (count = 0; count < PPC_PAGE_SIZES_MAX_SZ; count++) { | ||
if (sps->enc[count].page_shift == 0) { | ||
break; | ||
} | ||
} | ||
if ((p - prop) >= (maxcells - 3 - count * 2)) { | ||
break; | ||
} | ||
*(p++) = cpu_to_be32(sps->page_shift); | ||
*(p++) = cpu_to_be32(sps->slb_enc); | ||
*(p++) = cpu_to_be32(count); | ||
for (j = 0; j < count; j++) { | ||
*(p++) = cpu_to_be32(sps->enc[j].page_shift); | ||
*(p++) = cpu_to_be32(sps->enc[j].pte_enc); | ||
} | ||
} | ||
|
||
return (p - prop) * sizeof(uint32_t); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters