summaryrefslogtreecommitdiff
path: root/vbe_display_api.txt
blob: a04a25fcc73ea76a1e019336e62eadd14b06a29a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
VBE Display API
-------------------------------------------------------------------------------------------------------------
  This document is part of the Bochs/VBEBios documentation,
  it specifies the bochs host <-> vbebios client communication.
  
  That means, the display code implementation and the vbebios code depend
  very heavily on each other. As such, this documents needs be synchronised 
  between bochs CVS and the vgabios CVS.
  
  This document does not describe hwo the VBEBios implements the VBE2/3 spec.
  This document does not describe how the Bochs display code will display gfx based upon this spec.
  

History
-------
  Version 0.5     2002 March 08   Jeroen Janssen
                  - Added documentation about panic behaviour / current limits of the data values.
                  - Changed BPP API (in order to include future (A)RGB formats)
                  - Initial version (based upon extended display text of the vbe bochs display patch)


Todo
----
  Version 0.5     - Update the VBEBios with the new API in this spec
                  - Update the Bochs display patch with the new API in this spec + add this document.
  
  Version 0.5+    [random order]
                  - Add lots of different (A)RGB formats
                  - Add Linear Frame Buffer API

  
References
----------
  [VBE3]          VBE 3 Specification at 
                  http://www.vesa.org/vbe3.pdf
                  
  [BOCHS]         Bochs Open Source IA-32 Emulator at 
                  http://bochs.sourceforge.net
                  
  [VBEBIOS]       VBE Bios for Bochs at 
                  http://savannah.gnu.org/projects/vgabios/
                  
  [Screenshots]   Screenshots of programs using the VBE Bios at 
                  http://japj.org/projects/bochs_plex86/screenshots.html

Abbreviations
-------------
  VBE             Vesa Bios Extension
  DISPI           (Bochs) Display Interface
  BPP             Bits Per Pixel
  LFB             Linear Frame Buffer


#defines
--------
  #define VBE_DISPI_BANK_ADDRESS          0xA0000
  #define VBE_DISPI_BANK_SIZE_KB          64
  
  #define VBE_DISPI_MAX_XRES              1024
  #define VBE_DISPI_MAX_YRES              768
  
  #define VBE_DISPI_IOPORT_INDEX          0xFF80
  #define VBE_DISPI_IOPORT_DATA           0xFF81
  
  #define VBE_DISPI_INDEX_ID              0x0
  #define VBE_DISPI_INDEX_XRES            0x1
  #define VBE_DISPI_INDEX_YRES            0x2
  #define VBE_DISPI_INDEX_BPP             0x3
  #define VBE_DISPI_INDEX_ENABLE          0x4
  #define VBE_DISPI_INDEX_BANK            0x5
  
  #define VBE_DISPI_ID0                   0xB0C0
  
  #define VBE_DISPI_BPP_8                 0x0
// The following is not support yet, but just for reference available.  
//  #define VBE_DISPI_BPP_RGB565            0x1
//  #define VBE_DISPI_BPP_RGB555            0x2

  #define VBE_DISPI_DISABLED              0x00
  #define VBE_DISPI_ENABLED               0x01


API
---
  The display api works by using a index (VBE_DISPI_IOPORT_INDEX) and 
  data (VBE_DISPI_IOPORT_DATA) ioport. One writes the index of the parameter to the index port.
  Next, the parameter value can be read or written.
  
  * VBE_DISPI_INDEX_ID  : WORD
    This parameter can be used to detect the current display API (both bochs & vbebios).
    The bios writes VBE_DISPI_ID0 to the dataport and reads it back again.
    This way, the display code knows the vbebios 'ID' and the vbebios can check if the correct
    display code is present.
    As a result, a PANIC can be generated if an incompatible vbebios/display code combination is detected.
    This panic can be generated from both the display code and the bios.
    
    Example values: VBE_DISPI_ID0
        
  * VBE_DISPI_INDEX_XRES : WORD
    This parameter can be used to read/write the vbe display X resolution (in pixels).
    It's illegal to set the XRES when the VBE is enabled (display code should generate PANIC).
    
    If the value written exceeds VBE_DISPI_MAX_XRES, the display code needs to generate a PANIC.
    
    Example values:   320,640,800,1024

  * VBE_DISPI_INDEX_YRES : WORD
    This parameter can be used to read/write the vbe display Y resolution (in pixels).
    It's illegal to set the YRES when the VBE is enabled (display code should generate PANIC).
    
    If the value written exceeds VBE_DISPI_MAX_YRES, the display code needs to generate a PANIC.
    
    Example values:   200,400,480,600,768
  
  * VBE_DISPI_INDEX_BPP : WORD
    This parameter can be used to read/write the vbe display BPP.
    It's illegal to set the BPP when the VBE is enabled (display code should generate PANIC).
    
    If the value written is an incompatible BPP, the display code needs to generate a PANIC.
    
    Example values:   VBE_DISPI_BPP_8
    
  * VBE_DISPI_INDEX_ENABLE : WORD
    This parameter can be used to read/write the vbe ENABLED state.
    If the bios writes VBE_DISPI_ENABLED then the display code will setup a hostside display mode 
    with the current XRES, YRES and BPP settings.
    If the bios write VBE_DISPI_DISABLED then the display code will switch back to normal vga mode behaviour.
    
    Example values: VBE_DISPI_ENABLED, VBE_DISPI_DISABLED
  
  * VBE_DISPI_INDEX_BANK : WORD
    This parameter can be used to read/write the current selected BANK (at 0xA0000).
    This can be used for switching banks in banked mode.


Displaying GFX
--------------
  Currently Linear Frame Buffer support is not available yet.
  The only other way of displaying (VBE) graphics is using banked modi.
  
  What happens is that the total screen is devided in banks of 'VBE_DISPI_BANK_SIZE_KB' KiloByte in size.
  If you want to set a pixel you can calculate its bank by doing:
  
    offset = pixel_x + pixel_y * resolution_x;
    bank = offset / 64 Kb (rounded 1.9999 -> 1)
    
    bank_pixel_pos = offset - bank * 64Kb
    
  Now you can set the current bank and put the pixel at VBE_DISPI_BANK_ADDRESS + bank_pixel_pos  


Notes
-----
  * Currently only Banked modi are 'officially' supported (although 320x200x8 LFB is available in the bios atm).
   
  * Since the XRES/YRES/BPP may not be written when VBE is enabled, if you want to switch from one VBE mode
    to another, you will need to disable VBE first.