static void phys_page_set_level(PhysPageEntry *lp, hwaddr *index,

                                hwaddr *nb, uint16_t leaf,

                                int level)

{

    PhysPageEntry *p;

    int i;

    hwaddr step = (hwaddr)1 << (level * P_L2_BITS);



    if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) {

        lp->ptr = phys_map_node_alloc();

        p = next_map.nodes[lp->ptr];

        if (level == 0) {

            for (i = 0; i < P_L2_SIZE; i++) {

                p[i].skip = 0;

                p[i].ptr = PHYS_SECTION_UNASSIGNED;

            }

        }

    } else {

        p = next_map.nodes[lp->ptr];

    }

    lp = &p[(*index >> (level * P_L2_BITS)) & (P_L2_SIZE - 1)];



    while (*nb && lp < &p[P_L2_SIZE]) {

        if ((*index & (step - 1)) == 0 && *nb >= step) {

            lp->skip = 0;

            lp->ptr = leaf;

            *index += step;

            *nb -= step;

        } else {

            phys_page_set_level(lp, index, nb, leaf, level - 1);

        }

        ++lp;

    }

}

static void phys_page_set_level(PhysPageEntry *lp, hwaddr *index,

                                hwaddr *nb, uint16_t leaf,

                                int level)

{

    PhysPageEntry *p;

    int i;

    hwaddr step = (hwaddr)1 << (level * P_L2_BITS);



    if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) {

        lp->ptr = phys_map_node_alloc();

        p = next_map.nodes[lp->ptr];

        if (level == 0) {

            for (i = 0; i < P_L2_SIZE; i++) {

                p[i].skip = 0;

                p[i].ptr = PHYS_SECTION_UNASSIGNED;

            }

        }

    } else {

        p = next_map.nodes[lp->ptr];

    }

    lp = &p[(*index >> (level * P_L2_BITS)) & (P_L2_SIZE - 1)];



    while (*nb && lp < &p[P_L2_SIZE]) {

        if ((*index & (step - 1)) == 0 && *nb >= step) {

            lp->skip = 0;

            lp->ptr = leaf;

            *index += step;

            *nb -= step;

        } else {

            phys_page_set_level(lp, index, nb, leaf, level - 1);

        }

        ++lp;

    }

}

static void FUNC_0(PhysPageEntry *VAR_0, hwaddr *VAR_1,

                                hwaddr *VAR_2, uint16_t VAR_3,

                                int VAR_4)

{

    PhysPageEntry *p;

    int VAR_5;

    hwaddr step = (hwaddr)1 << (VAR_4 * P_L2_BITS);



    if (VAR_0->skip && VAR_0->ptr == PHYS_MAP_NODE_NIL) {

        VAR_0->ptr = phys_map_node_alloc();

        p = next_map.nodes[VAR_0->ptr];

        if (VAR_4 == 0) {

            for (VAR_5 = 0; VAR_5 < P_L2_SIZE; VAR_5++) {

                p[VAR_5].skip = 0;

                p[VAR_5].ptr = PHYS_SECTION_UNASSIGNED;

            }

        }

    } else {

        p = next_map.nodes[VAR_0->ptr];

    }

    VAR_0 = &p[(*VAR_1 >> (VAR_4 * P_L2_BITS)) & (P_L2_SIZE - 1)];



    while (*VAR_2 && VAR_0 < &p[P_L2_SIZE]) {

        if ((*VAR_1 & (step - 1)) == 0 && *VAR_2 >= step) {

            VAR_0->skip = 0;

            VAR_0->ptr = VAR_3;

            *VAR_1 += step;

            *VAR_2 -= step;

        } else {

            FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4 - 1);

        }

        ++VAR_0;

    }

}

static void FUNC_0(PhysPageEntry *VAR_0, hwaddr *VAR_1,
hwaddr *VAR_2, uint16_t VAR_3,
int VAR_4)
{ PhysPageEntry *p; int VAR_5; hwaddr step = (hwaddr)1 << (VAR_4 * P_L2_BITS); if (VAR_0->skip && VAR_0->ptr == PHYS_MAP_NODE_NIL) { VAR_0->ptr = phys_map_node_alloc(); p = next_map.nodes[VAR_0->ptr]; if (VAR_4 == 0) { for (VAR_5 = 0; VAR_5 < P_L2_SIZE; VAR_5++) { p[VAR_5].skip = 0; p[VAR_5].ptr = PHYS_SECTION_UNASSIGNED; } } } else { p = next_map.nodes[VAR_0->ptr]; } VAR_0 = &p[(*VAR_1 >> (VAR_4 * P_L2_BITS)) & (P_L2_SIZE - 1)]; while (*VAR_2 && VAR_0 < &p[P_L2_SIZE]) { if ((*VAR_1 & (step - 1)) == 0 && *VAR_2 >= step) { VAR_0->skip = 0; VAR_0->ptr = VAR_3; *VAR_1 += step; *VAR_2 -= step; } else { FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4 - 1); } ++VAR_0; } }