All pastes #646381 Raw Edit

VESA GDI driver

public text v1 · immutable
#646381 ·published 2007-08-05 14:17 UTC
rendered paste body
; **********************************************************

;	Name: VESA Graphic Device Interface
;	Autor: Peter Kleissner
;	Version: 1.00
;	Date: 04.08.2007 21:52
;	last Update: 04.08.2007 21:52
;	see document: ToasterOS.pdf

; **********************************************************

[BITS 32]
CPU 386


%define	Type_System
%include "interface.asm"


org VESA_GDI



; VGA, SVGA, VESA Interface port registers
; 
;  Attribute Controller Registers
;  
;     Index/Data Register               3C0h   [Write]
;     Data Register                     3C1h   [Read]
;  
;        Indexes of the Attribute Controller Register
;           Palette Registers                   00h - 0Fh
;           Attribute Mode Control Register     10h
;           Overscan Color Register             11h
;           Color Plane Enable Register         12h
;           Horizontal Pixel Panning Register   13h
;           Color Select Register               14h
;           Miscellanenous                      16h            [undocumented, na]
; 
;  Miscellaneous Registers
;  
;     Miscellaneous Output Register     3C2h   [Write]
;     Miscellaneous Output Register     3CCh   [Read]
;     Input Status 0 Register           3C2h   [Read]
;     Video Subsystem Enable            3C3h   (46E8h)
; 
;  Sequencer Registers
;  
;     TS Index Register                 3C4h   [EGA, Write]
;     TS Data Register                  3C5h   [EGA, Write]
;     
;     Sequence Index Register           3C4h   [VGA]
;     Sequence Data Register            3C5h   [VGA]
; 
;  Digital-Analog Converter Registers
;  
;     PEL Mask Register                 3C6h   [MCGA=0FFh, VGA]
;     DAC State Register                3C7h   [Read]
;     PEL Address Register              3C7h   [Write]
;     PEL Address Register              3C8h   [Write-Mode]
;     PEL Data Register                 3C9h
; 
;  Graphics Device Controller Position Registers
;  
;     Feature Control Register          3CAh   [Read]
;     Graphics 2 Position Register      3CAh   [Write]
;     Segment Select Register           3CBh
;     Graphics 1 Position Register      3CCh   [Write]
;     Select Segment Register           3CDh
; 
;  Graphics Device Controller Registers
;  
;     Index Register                    3CEh   [EGA, Write]
;     Data Register                     3CFh   [EGA, Write]
;     Address/Index Register            3CEh   [VGA]
;     Graphics Register                 3CFh   [VGA, unused, undocumented]
; 
;  Clear Flip/Flop Registers (for Port 3C2h)
;  
;     EGA/VGA mono Feature Control Register    3BAh
;     VGA graphics Feature Control Register    3DAh




; VBE Interface port registers [bochs, qemu]
;   VBE Display Interface I/O Port Index     1CEh
;   VBE Display Interface I/O Port Data      1CFh
;   
;   Indexes:
;   
;     VBE Display Index Idendification      0
;     VBE Display Index X resolution        1
;     VBE Display Index Y resolution        2
;     VBE Display Index Bits per Pixel      3
;     VBE Display Index Enable              4
;     VBE Display Index Bank                5
;     VBE Display Index Virtual Width       6
;     VBE Display Index Virtual Height      7
;     VBE Display Index X Offset            8
;     VBE Display Index Y Offset            9
;   
;   Data Values:
;   
;     VBE Display Index Disabled            0
;     VBE Display Index Enabled             1
;     VBE Display Index Get Capabilities    2
;     VBE Display Index 8 Bit Digital-Analog-Converter       20h
;     VBE Display Index Linear Frame Buffer Enabled          40h
;     VBE Display Index No Clear Memory                      80h













; *************************************************************
;   Function: Write Index/Value to Attribute Control Register
;   
;   Input:	
;            al    Index
;            ah    Data
; *************************************************************

Send_Attribute_Control_Register:

; clear flip/flop [for both Text Mode and graphics Mode]
mov bl,al
mov dx,3BAh
in al,dx
mov dx,3DAh
in al,dx
mov al,bl

; send the Index
mov al,bl
mov dx,3C0h
out dx,al

; send the Data
mov al,ah
out dx,al

ret





; *************************************************************
;   Function: Write Value to Miscellaneous Output Register
;   
;   Input:
;            al    Value
; *************************************************************

Send_Miscellaneous_Output_Register:

; send the Data
mov dx,3C2h
out dx,al

ret





; *************************************************************
;   Function: Write Index/Value to Sequencer Register
;   
;   Input:
;            al    Index
;            ah    Data
; *************************************************************

Send_Sequencer_Register:

; if Index = 1 assume EGA (whyever)
cmp al,1
jne Send_Sequencer_Register_1

; send something
mov bl,ah
mov ax,0100h
mov dx,3C4h
out dx,ax

; send the Index
mov al,1
out dx,al

; send the Data
mov al,bl
inc dx
out dx,al
dec dx

; send something else
mov ax,0300h
out dx,ax

ret

Send_Sequencer_Register_1:

; send the Index
mov dx,3C4h
out dx,al

; send the Data
mov al,ah
inc dx
out dx,ah

ret





; *************************************************************
;   Function: Write Value to DAC Mask Register
;   
;   Input:
;            al    Value
; *************************************************************

Send_DAC_Mask_Register:

; send the Data
mov dx,3C6h
out dx,al

ret





; *************************************************************
;   Function: Write Index/Value to Graphics Controller Register
;   
;   Input:
;            al    Index
;            ah    Data
; *************************************************************

Send_Graphics_Controller_Register:

; send the Index
mov dx,3CEh
out dx,al

; send the Data
mov al,ah
inc dx
out dx,al

ret





; *************************************************************
;   Function: Write Index/Value to CRTC Controller
;   
;   Input:
;            al    Index
;            ah    Data
; *************************************************************

Send_CRTC_Controller:

; send the Index
mov dx,3D4h
out dx,al

; send the Data
mov al,ah
inc dx
out dx,al

ret





; *************************************************************
;   Function: VBE Port I/O write
;   
;   Input:
;            al    Index
;            ah    Data
; *************************************************************

Write_VBE_Port:

; write the Index
mov dx,1CEh
out dx,al

; write the Data
mov al,ah
inc dx
out dx,al

ret