9pfs: make pdu_marshal() and pdu_unmarshal() static functions
[qemu.git] / hw / ppc / fdt.c
blob38a7234b463346ed4a92c414401317a94f7465a4
1 /*
2 * QEMU PowerPC helper routines for the device tree.
4 * Copyright (C) 2016 IBM Corp.
6 * This code is licensed under the GPL version 2 or later. See the
7 * COPYING file in the top-level directory.
8 */
10 #include "qemu/osdep.h"
11 #include "qapi/error.h"
12 #include "target/ppc/cpu.h"
14 #include "hw/ppc/fdt.h"
16 #if defined(TARGET_PPC64)
17 size_t ppc_create_page_sizes_prop(CPUPPCState *env, uint32_t *prop,
18 size_t maxsize)
20 size_t maxcells = maxsize / sizeof(uint32_t);
21 int i, j, count;
22 uint32_t *p = prop;
24 for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) {
25 struct ppc_one_seg_page_size *sps = &env->sps.sps[i];
27 if (!sps->page_shift) {
28 break;
30 for (count = 0; count < PPC_PAGE_SIZES_MAX_SZ; count++) {
31 if (sps->enc[count].page_shift == 0) {
32 break;
35 if ((p - prop) >= (maxcells - 3 - count * 2)) {
36 break;
38 *(p++) = cpu_to_be32(sps->page_shift);
39 *(p++) = cpu_to_be32(sps->slb_enc);
40 *(p++) = cpu_to_be32(count);
41 for (j = 0; j < count; j++) {
42 *(p++) = cpu_to_be32(sps->enc[j].page_shift);
43 *(p++) = cpu_to_be32(sps->enc[j].pte_enc);
47 return (p - prop) * sizeof(uint32_t);
49 #endif