812
813
typedef void vga_draw_line_func(VGAState *s1, uint8_t *d,
813
814
const uint8_t *s, int width);
815
static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b)
817
return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);
820
static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b)
822
return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
825
static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, unsigned b)
827
return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
830
static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b)
832
return (r << 16) | (g << 8) | b;
835
static inline unsigned int rgb_to_pixel32bgr(unsigned int r, unsigned int g, unsigned b)
837
return (b << 16) | (g << 8) | r;
841
817
#include "vga_template.h"
844
820
#include "vga_template.h"
824
#include "vga_template.h"
827
#include "vga_template.h"
847
831
#include "vga_template.h"
1788
1824
s->get_bpp = vga_get_bpp;
1789
1825
s->get_offsets = vga_get_offsets;
1790
1826
s->get_resolution = vga_get_resolution;
1791
graphic_console_init(s->ds, vga_update_display, vga_invalidate_display,
1792
vga_screen_dump, s);
1827
s->update = vga_update_display;
1828
s->invalidate = vga_invalidate_display;
1829
s->screen_dump = vga_screen_dump;
1795
1832
/* used by both ISA and PCI */
1796
static void vga_init(VGAState *s)
1833
void vga_init(VGAState *s)
1798
1835
int vga_io_memory;
1844
1881
vga_io_memory);
1884
/* Memory mapped interface */
1885
static uint32_t vga_mm_readb (void *opaque, target_phys_addr_t addr)
1887
VGAState *s = opaque;
1889
return vga_ioport_read(s, (addr - s->base_ctrl) >> s->it_shift) & 0xff;
1892
static void vga_mm_writeb (void *opaque,
1893
target_phys_addr_t addr, uint32_t value)
1895
VGAState *s = opaque;
1897
vga_ioport_write(s, (addr - s->base_ctrl) >> s->it_shift, value & 0xff);
1900
static uint32_t vga_mm_readw (void *opaque, target_phys_addr_t addr)
1902
VGAState *s = opaque;
1904
return vga_ioport_read(s, (addr - s->base_ctrl) >> s->it_shift) & 0xffff;
1907
static void vga_mm_writew (void *opaque,
1908
target_phys_addr_t addr, uint32_t value)
1910
VGAState *s = opaque;
1912
vga_ioport_write(s, (addr - s->base_ctrl) >> s->it_shift, value & 0xffff);
1915
static uint32_t vga_mm_readl (void *opaque, target_phys_addr_t addr)
1917
VGAState *s = opaque;
1919
return vga_ioport_read(s, (addr - s->base_ctrl) >> s->it_shift);
1922
static void vga_mm_writel (void *opaque,
1923
target_phys_addr_t addr, uint32_t value)
1925
VGAState *s = opaque;
1927
vga_ioport_write(s, (addr - s->base_ctrl) >> s->it_shift, value);
1930
static CPUReadMemoryFunc *vga_mm_read_ctrl[] = {
1936
static CPUWriteMemoryFunc *vga_mm_write_ctrl[] = {
1942
static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base,
1943
target_phys_addr_t ctrl_base, int it_shift)
1945
int s_ioport_ctrl, vga_io_memory;
1947
s->base_ctrl = ctrl_base;
1948
s->it_shift = it_shift;
1949
s_ioport_ctrl = cpu_register_io_memory(0, vga_mm_read_ctrl, vga_mm_write_ctrl, s);
1950
vga_io_memory = cpu_register_io_memory(0, vga_mem_read, vga_mem_write, s);
1952
register_savevm("vga", 0, 2, vga_save, vga_load, s);
1954
cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
1956
cpu_register_physical_memory(vram_base + 0x000a0000, 0x20000, vga_io_memory);
1847
1959
int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
1848
1960
unsigned long vga_ram_offset, int vga_ram_size)
1856
1968
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
1971
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump, s);
1859
1973
#ifdef CONFIG_BOCHS_VBE
1860
1974
/* XXX: use optimized standard vga accesses */
1861
1975
cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
1981
int isa_vga_mm_init(DisplayState *ds, uint8_t *vga_ram_base,
1982
unsigned long vga_ram_offset, int vga_ram_size,
1983
target_phys_addr_t vram_base, target_phys_addr_t ctrl_base,
1988
s = qemu_mallocz(sizeof(VGAState));
1992
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
1993
vga_mm_init(s, vram_base, ctrl_base, it_shift);
1995
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump, s);
1997
#ifdef CONFIG_BOCHS_VBE
1998
/* XXX: use optimized standard vga accesses */
1999
cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
2000
vga_ram_size, vga_ram_offset);
1867
2005
int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
1868
2006
unsigned long vga_ram_offset, int vga_ram_size,
1869
2007
unsigned long vga_bios_offset, int vga_bios_size)
1882
2020
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
2023
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump, s);
1884
2025
s->pci_dev = &d->dev;
1886
2027
pci_conf = d->dev.config;
1934
static int ppm_save(const char *filename, uint8_t *data,
1935
int w, int h, int linesize)
2075
int ppm_save(const char *filename, uint8_t *data,
2076
int w, int h, int linesize)
1938
2079
uint8_t *d, *d1;