void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len)

{

    unsigned int i;

    uint32_t start = 0, end;

    struct OpenBIOS_nvpart_v1 *part_header;



    // OpenBIOS nvram variables

    // Variable partition

    part_header = (struct OpenBIOS_nvpart_v1 *)nvr->data;

    part_header->signature = OPENBIOS_PART_SYSTEM;

    pstrcpy(part_header->name, sizeof(part_header->name), "system");



    end = start + sizeof(struct OpenBIOS_nvpart_v1);

    for (i = 0; i < nb_prom_envs; i++)

        end = OpenBIOS_set_var(nvr->data, end, prom_envs[i]);



    // End marker

    nvr->data[end++] = '\0';



    end = start + ((end - start + 15) & ~15);

    /* XXX: OpenBIOS is not able to grow up a partition. Leave some space for

       new variables. */

    if (end < DEF_SYSTEM_SIZE)

        end = DEF_SYSTEM_SIZE;

    OpenBIOS_finish_partition(part_header, end - start);



    // free partition

    start = end;

    part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start];

    part_header->signature = OPENBIOS_PART_FREE;

    pstrcpy(part_header->name, sizeof(part_header->name), "free");



    end = len;

    OpenBIOS_finish_partition(part_header, end - start);

}

void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len)

{

    unsigned int i;

    uint32_t start = 0, end;

    struct OpenBIOS_nvpart_v1 *part_header;



    

    

    part_header = (struct OpenBIOS_nvpart_v1 *)nvr->data;

    part_header->signature = OPENBIOS_PART_SYSTEM;

    pstrcpy(part_header->name, sizeof(part_header->name), "system");



    end = start + sizeof(struct OpenBIOS_nvpart_v1);

    for (i = 0; i < nb_prom_envs; i++)

        end = OpenBIOS_set_var(nvr->data, end, prom_envs[i]);



    

    nvr->data[end++] = '\0';



    end = start + ((end - start + 15) & ~15);

    



    if (end < DEF_SYSTEM_SIZE)

        end = DEF_SYSTEM_SIZE;

    OpenBIOS_finish_partition(part_header, end - start);



    

    start = end;

    part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start];

    part_header->signature = OPENBIOS_PART_FREE;

    pstrcpy(part_header->name, sizeof(part_header->name), "free");



    end = len;

    OpenBIOS_finish_partition(part_header, end - start);

}

void FUNC_0 (MacIONVRAMState *VAR_0, int VAR_1)

{

    unsigned int VAR_2;

    uint32_t start = 0, end;

    struct OpenBIOS_nvpart_v1 *VAR_3;



    

    

    VAR_3 = (struct OpenBIOS_nvpart_v1 *)VAR_0->data;

    VAR_3->signature = OPENBIOS_PART_SYSTEM;

    pstrcpy(VAR_3->name, sizeof(VAR_3->name), "system");



    end = start + sizeof(struct OpenBIOS_nvpart_v1);

    for (VAR_2 = 0; VAR_2 < nb_prom_envs; VAR_2++)

        end = OpenBIOS_set_var(VAR_0->data, end, prom_envs[VAR_2]);



    

    VAR_0->data[end++] = '\0';



    end = start + ((end - start + 15) & ~15);

    



    if (end < DEF_SYSTEM_SIZE)

        end = DEF_SYSTEM_SIZE;

    OpenBIOS_finish_partition(VAR_3, end - start);



    

    start = end;

    VAR_3 = (struct OpenBIOS_nvpart_v1 *)&VAR_0->data[start];

    VAR_3->signature = OPENBIOS_PART_FREE;

    pstrcpy(VAR_3->name, sizeof(VAR_3->name), "free");



    end = VAR_1;

    OpenBIOS_finish_partition(VAR_3, end - start);

}

void FUNC_0 (MacIONVRAMState *VAR_0, int VAR_1)
{ unsigned int VAR_2; uint32_t start = 0, end; struct OpenBIOS_nvpart_v1 *VAR_3; VAR_3 = (struct OpenBIOS_nvpart_v1 *)VAR_0->data; VAR_3->signature = OPENBIOS_PART_SYSTEM; pstrcpy(VAR_3->name, sizeof(VAR_3->name), "system"); end = start + sizeof(struct OpenBIOS_nvpart_v1); for (VAR_2 = 0; VAR_2 < nb_prom_envs; VAR_2++) end = OpenBIOS_set_var(VAR_0->data, end, prom_envs[VAR_2]); VAR_0->data[end++] = '\0'; end = start + ((end - start + 15) & ~15); if (end < DEF_SYSTEM_SIZE)
end = DEF_SYSTEM_SIZE; OpenBIOS_finish_partition(VAR_3, end - start); start = end; VAR_3 = (struct OpenBIOS_nvpart_v1 *)&VAR_0->data[start]; VAR_3->signature = OPENBIOS_PART_FREE; pstrcpy(VAR_3->name, sizeof(VAR_3->name), "free"); end = VAR_1; OpenBIOS_finish_partition(VAR_3, end - start); }