void vga_common_init(VGACommonState *s)

{

    int i, j, v, b;



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

        v = 0;

        for(j = 0; j < 8; j++) {

            v |= ((i >> j) & 1) << (j * 4);

        }

        expand4[i] = v;



        v = 0;

        for(j = 0; j < 4; j++) {

            v |= ((i >> (2 * j)) & 3) << (j * 4);

        }

        expand2[i] = v;

    }

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

        v = 0;

        for(j = 0; j < 4; j++) {

            b = ((i >> j) & 1);

            v |= b << (2 * j);

            v |= b << (2 * j + 1);

        }

        expand4to8[i] = v;

    }



    /* valid range: 1 MB -> 256 MB */

    s->vram_size = 1024 * 1024;

    while (s->vram_size < (s->vram_size_mb << 20) &&

           s->vram_size < (256 << 20)) {

        s->vram_size <<= 1;

    }

    s->vram_size_mb = s->vram_size >> 20;



    s->is_vbe_vmstate = 1;

    memory_region_init_ram(&s->vram, "vga.vram", s->vram_size);

    vmstate_register_ram_global(&s->vram);

    xen_register_framebuffer(&s->vram);

    s->vram_ptr = memory_region_get_ram_ptr(&s->vram);

    s->get_bpp = vga_get_bpp;

    s->get_offsets = vga_get_offsets;

    s->get_resolution = vga_get_resolution;

    s->update = vga_update_display;

    s->invalidate = vga_invalidate_display;

    s->screen_dump = vga_screen_dump;

    s->text_update = vga_update_text;

    switch (vga_retrace_method) {

    case VGA_RETRACE_DUMB:

        s->retrace = vga_dumb_retrace;

        s->update_retrace_info = vga_dumb_update_retrace_info;

        break;



    case VGA_RETRACE_PRECISE:

        s->retrace = vga_precise_retrace;

        s->update_retrace_info = vga_precise_update_retrace_info;

        break;

    }

    vga_dirty_log_start(s);

}

void vga_common_init(VGACommonState *s)

{

    int i, j, v, b;



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

        v = 0;

        for(j = 0; j < 8; j++) {

            v |= ((i >> j) & 1) << (j * 4);

        }

        expand4[i] = v;



        v = 0;

        for(j = 0; j < 4; j++) {

            v |= ((i >> (2 * j)) & 3) << (j * 4);

        }

        expand2[i] = v;

    }

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

        v = 0;

        for(j = 0; j < 4; j++) {

            b = ((i >> j) & 1);

            v |= b << (2 * j);

            v |= b << (2 * j + 1);

        }

        expand4to8[i] = v;

    }



    

    s->vram_size = 1024 * 1024;

    while (s->vram_size < (s->vram_size_mb << 20) &&

           s->vram_size < (256 << 20)) {

        s->vram_size <<= 1;

    }

    s->vram_size_mb = s->vram_size >> 20;



    s->is_vbe_vmstate = 1;

    memory_region_init_ram(&s->vram, "vga.vram", s->vram_size);

    vmstate_register_ram_global(&s->vram);

    xen_register_framebuffer(&s->vram);

    s->vram_ptr = memory_region_get_ram_ptr(&s->vram);

    s->get_bpp = vga_get_bpp;

    s->get_offsets = vga_get_offsets;

    s->get_resolution = vga_get_resolution;

    s->update = vga_update_display;

    s->invalidate = vga_invalidate_display;

    s->screen_dump = vga_screen_dump;

    s->text_update = vga_update_text;

    switch (vga_retrace_method) {

    case VGA_RETRACE_DUMB:

        s->retrace = vga_dumb_retrace;

        s->update_retrace_info = vga_dumb_update_retrace_info;

        break;



    case VGA_RETRACE_PRECISE:

        s->retrace = vga_precise_retrace;

        s->update_retrace_info = vga_precise_update_retrace_info;

        break;

    }

    vga_dirty_log_start(s);

}

void FUNC_0(VGACommonState *VAR_0)

{

    int VAR_1, VAR_2, VAR_3, VAR_4;



    for(VAR_1 = 0;VAR_1 < 256; VAR_1++) {

        VAR_3 = 0;

        for(VAR_2 = 0; VAR_2 < 8; VAR_2++) {

            VAR_3 |= ((VAR_1 >> VAR_2) & 1) << (VAR_2 * 4);

        }

        expand4[VAR_1] = VAR_3;



        VAR_3 = 0;

        for(VAR_2 = 0; VAR_2 < 4; VAR_2++) {

            VAR_3 |= ((VAR_1 >> (2 * VAR_2)) & 3) << (VAR_2 * 4);

        }

        expand2[VAR_1] = VAR_3;

    }

    for(VAR_1 = 0; VAR_1 < 16; VAR_1++) {

        VAR_3 = 0;

        for(VAR_2 = 0; VAR_2 < 4; VAR_2++) {

            VAR_4 = ((VAR_1 >> VAR_2) & 1);

            VAR_3 |= VAR_4 << (2 * VAR_2);

            VAR_3 |= VAR_4 << (2 * VAR_2 + 1);

        }

        expand4to8[VAR_1] = VAR_3;

    }



    

    VAR_0->vram_size = 1024 * 1024;

    while (VAR_0->vram_size < (VAR_0->vram_size_mb << 20) &&

           VAR_0->vram_size < (256 << 20)) {

        VAR_0->vram_size <<= 1;

    }

    VAR_0->vram_size_mb = VAR_0->vram_size >> 20;



    VAR_0->is_vbe_vmstate = 1;

    memory_region_init_ram(&VAR_0->vram, "vga.vram", VAR_0->vram_size);

    vmstate_register_ram_global(&VAR_0->vram);

    xen_register_framebuffer(&VAR_0->vram);

    VAR_0->vram_ptr = memory_region_get_ram_ptr(&VAR_0->vram);

    VAR_0->get_bpp = vga_get_bpp;

    VAR_0->get_offsets = vga_get_offsets;

    VAR_0->get_resolution = vga_get_resolution;

    VAR_0->update = vga_update_display;

    VAR_0->invalidate = vga_invalidate_display;

    VAR_0->screen_dump = vga_screen_dump;

    VAR_0->text_update = vga_update_text;

    switch (vga_retrace_method) {

    case VGA_RETRACE_DUMB:

        VAR_0->retrace = vga_dumb_retrace;

        VAR_0->update_retrace_info = vga_dumb_update_retrace_info;

        break;



    case VGA_RETRACE_PRECISE:

        VAR_0->retrace = vga_precise_retrace;

        VAR_0->update_retrace_info = vga_precise_update_retrace_info;

        break;

    }

    vga_dirty_log_start(VAR_0);

}

void FUNC_0(VGACommonState *VAR_0)
{ int VAR_1, VAR_2, VAR_3, VAR_4; for(VAR_1 = 0;VAR_1 < 256; VAR_1++) { VAR_3 = 0; for(VAR_2 = 0; VAR_2 < 8; VAR_2++) { VAR_3 |= ((VAR_1 >> VAR_2) & 1) << (VAR_2 * 4); } expand4[VAR_1] = VAR_3; VAR_3 = 0; for(VAR_2 = 0; VAR_2 < 4; VAR_2++) { VAR_3 |= ((VAR_1 >> (2 * VAR_2)) & 3) << (VAR_2 * 4); } expand2[VAR_1] = VAR_3; } for(VAR_1 = 0; VAR_1 < 16; VAR_1++) { VAR_3 = 0; for(VAR_2 = 0; VAR_2 < 4; VAR_2++) { VAR_4 = ((VAR_1 >> VAR_2) & 1); VAR_3 |= VAR_4 << (2 * VAR_2); VAR_3 |= VAR_4 << (2 * VAR_2 + 1); } expand4to8[VAR_1] = VAR_3; } VAR_0->vram_size = 1024 * 1024; while (VAR_0->vram_size < (VAR_0->vram_size_mb << 20) &&
VAR_0->vram_size < (256 << 20)) { VAR_0->vram_size <<= 1; } VAR_0->vram_size_mb = VAR_0->vram_size >> 20; VAR_0->is_vbe_vmstate = 1; memory_region_init_ram(&VAR_0->vram, "vga.vram", VAR_0->vram_size); vmstate_register_ram_global(&VAR_0->vram); xen_register_framebuffer(&VAR_0->vram); VAR_0->vram_ptr = memory_region_get_ram_ptr(&VAR_0->vram); VAR_0->get_bpp = vga_get_bpp; VAR_0->get_offsets = vga_get_offsets; VAR_0->get_resolution = vga_get_resolution; VAR_0->update = vga_update_display; VAR_0->invalidate = vga_invalidate_display; VAR_0->screen_dump = vga_screen_dump; VAR_0->text_update = vga_update_text; switch (vga_retrace_method) { case VGA_RETRACE_DUMB:
VAR_0->retrace = vga_dumb_retrace; VAR_0->update_retrace_info = vga_dumb_update_retrace_info; break; case VGA_RETRACE_PRECISE:
VAR_0->retrace = vga_precise_retrace; VAR_0->update_retrace_info = vga_precise_update_retrace_info; break; } vga_dirty_log_start(VAR_0); }