title: Bochs with graphics
body: <p>I am using Bochs on Linux.
  It works fine but there is a problem I haven't managed to cope with.
  I get the vga-info (available modes, address of linear framebuffer(LFB)) and then switch to 1024*768*24 in real mode.
  According to the vga-info mode 118h (1024*768*24) is supported and the LFB is from E000:0000 (i.e. E0000 because of segment:offset, or 0xE0000000 in flat addressing but that memory doesn't exist because it's almost 3.5Gb).
  Later I switch to protected mode(PM) and write data to E0000, but no pixels appear. Neither do if I write to 0xE0000000. However they do if I write to A0000 but only A0000-C0000 memory (128Kb) is mapped. I'd like to use PM because of the 32bits and the LFB (no paging). I know that the videomemory of lower resolutions (e.g. 320*200*256) is mapped to A0000.
  In Bochs-config vbe is enabled (vga: extension=vbe) . bochsout.txt says "VBE Bochs Display Extension Enabled".</p>
  
  <p>The questions:
  Why the videomemory is from A0000 and not from E0000?
  Why is there only 128Kb videomemory? (It should be: 1024*768*3 bytes, i.e. 2.25 Mb)</p>
  
  <p>This way no graphics can be done in PM without paging or I am doing something wrong.</p>
  
  <p>Thanks in advance,
  rob</p>
  
  <p>I found something at <a href="http://wiki.osdev.org/Bochs_Graphics_Adaptor" rel="nofollow">http://wiki.osdev.org/Bochs_Graphics_Adaptor</a> :</p>
  
  <p>"Using a linear frame buffer (LFB)</p>
  
  <p>When using a linear frame buffer, the BGA exposes all of the graphics memory in a linear fashion. In older versions of Bochs and QEMU the location is fixed at 0xE0000000 (VBE_DISPI_LFB_PHYSICAL_ADDRESS). However, when Bochs is configured to emulate a PCI video card rather than an ISA one, the address of the framebuffer is no longer fixed, but can be read from the first PCI BAR of device 0x1234:0x1111 To enable the LFB, use the VBE_DISPI_LFB_ENABLED flag (0x40) when enabling the VBE extensions (so write a value of VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED (0x41)).</p>
  
  <p>QEMU does not pay attention to the VBE_DISPI_LFB_ENABLED flag. Both the linear frame buffer and memory bank are available at all times. Bochs pays attention to the flag. In LFB mode it ignores requests to change the bank and nothing happens when you write to the bank memory. In banked mode nothing happens when you write to the LFB memory. "</p>
  
  <p>I don't understand this 0xE0000000 because Bochs supports maximum 1Gb memory and this is by far more. By the way enabling vbe by compiling Bochs with --enable-vbe is depricated, "vga: extension=vbe" should be used instead in bochs-configfile.</p>
  
  <p><em><strong>SOLUTION</em></strong> found (set bit "use LFB" during setting the vbe mode):</p>
  
  <p>mov ax, 4F02h              ; set vbe mode</p>
  
  <p>mov bx, 118h               ; mode 1024*768*24</p>
  
  <p>or bx, 0100000000000000b   ; set bit 14th (use LFB)</p>
  
  <p>int 10h </p>
  
  <p>And LFB is from 0xE0000000 as the vga-modeinfo-block said.</p>