1 | /*
|
---|
2 | ** Copyright 2002-2003, Michael Noisternig. All rights reserved.
|
---|
3 | ** Distributed under the terms of the NewOS License.
|
---|
4 | */
|
---|
5 | #ifndef _VESA3_H_
|
---|
6 | #define _VESA3_H_
|
---|
7 |
|
---|
8 | #include <kernel/kernel.h>
|
---|
9 |
|
---|
10 | #define VESA_MAGIC ('P'|('M'<<8)|('I'<<16)|('D'<<24)) // 'PMID'
|
---|
11 |
|
---|
12 | #define VESA_CODE_SIZE 0x10000
|
---|
13 | #define VESA_STACK_SIZE 0x2000
|
---|
14 | #define VESA_DATA_SIZE 0x600
|
---|
15 |
|
---|
16 | typedef struct vesa3_pm_infoblock {
|
---|
17 | uint32 signature; // PM Info Block signature ('PMID')
|
---|
18 | uint16 call_offs; // offset of PM entry point within BIOS
|
---|
19 | uint16 init_offs; // offset of PM initialization entry point
|
---|
20 | uint16 sel_bios_data; // selector to BIOS data area emulation block
|
---|
21 | uint16 sel_a0000; // selector to 0xa0000
|
---|
22 | uint16 sel_b0000; // selector to 0xb0000
|
---|
23 | uint16 sel_b8000; // selector to 0xb8000
|
---|
24 | uint16 sel_code; // selector to access code segment as data
|
---|
25 | uint8 in_pm; // true iff in protected mode
|
---|
26 | uint8 checksum; // sum of all bytes in this struct must match 0
|
---|
27 | } _PACKED vesa3_pm_infoblock;
|
---|
28 |
|
---|
29 | typedef struct vesa3_infoblock {
|
---|
30 | uint32 signature; // VBE Info Block signature ('VESA')
|
---|
31 | uint16 version; // VBE version (0x300)
|
---|
32 | uint32 oem_string_ptr; // OEM string
|
---|
33 | uint8 capabilities[4]; // capabilities of graphics controller
|
---|
34 | uint32 video_mode_ptr; // video mode pointer
|
---|
35 | uint16 total_memory; // # 64kb memory blocks
|
---|
36 | uint16 oem_software_rev; // VBE implementation software revision
|
---|
37 | uint32 oem_vendor_name_ptr; // vendor name
|
---|
38 | uint32 oem_product_name_ptr; // product name
|
---|
39 | uint32 oem_product_rev_ptr; // product revision
|
---|
40 | uint8 _reserved[222]; // VBE implementation scratch area
|
---|
41 | uint8 oem_data[256]; // data area for OEM strings
|
---|
42 | } _PACKED vesa3_infoblock;
|
---|
43 |
|
---|
44 | typedef struct vesa3_mode_infoblock {
|
---|
45 |
|
---|
46 | // mandatory information for all VBE revisions
|
---|
47 | uint16 mode_attributes; // mode attributes
|
---|
48 | uint8 win_A_attributes; // window A attributes
|
---|
49 | uint8 win_B_attributes; // window B attributes
|
---|
50 | uint16 win_granularity; // window granularity
|
---|
51 | uint16 win_size; // window size
|
---|
52 | uint16 win_A_segment; // window A start segment
|
---|
53 | uint16 win_B_segment; // window B start segment
|
---|
54 | uint32 win_func_ptr; // real mode pointer to window function
|
---|
55 | uint16 bytes_per_scanline; // bytes per scan line
|
---|
56 |
|
---|
57 | // mandatory information for VBE 1.2 and above
|
---|
58 | uint16 x_resolution; // horizontal resolution in pixels (characters)
|
---|
59 | uint16 y_resolution; // vertical resolution in pixels (characters)
|
---|
60 | uint8 x_char_size; // character cell width in pixels
|
---|
61 | uint8 y_char_size; // character cell height in pixels
|
---|
62 | uint8 nr_planes; // number of memory planes
|
---|
63 | uint8 bits_per_pixel; // bits per pixel
|
---|
64 | uint8 nr_banks; // number of banks
|
---|
65 | uint8 memory_model; // memory model type
|
---|
66 | uint8 bank_size; // bank size in KB
|
---|
67 | uint8 nr_image_pages; // number of images
|
---|
68 | uint8 _reserved1; // reserved for page function
|
---|
69 |
|
---|
70 | // direct color fields (required for direct/6 and YUV/7 memory models)
|
---|
71 | uint8 red_mask_size; // size of direct color red mask in bits
|
---|
72 | uint8 red_field_pos; // bit posision of LSB of red mask
|
---|
73 | uint8 green_mask_size; // size of direct color green mask in bits
|
---|
74 | uint8 green_field_pos; // bit posision of LSB of green mask
|
---|
75 | uint8 blue_mask_size; // size of direct color blue mask in bits
|
---|
76 | uint8 blue_field_pos; // bit posision of LSB of blue mask
|
---|
77 | uint8 rsvd_mask_size; // size of direct color reserved mask in bits
|
---|
78 | uint8 rsvd_field_pos; // bit posision of LSB of reserved mask
|
---|
79 | uint8 direct_color_mode_info; // direct color mode attributes
|
---|
80 |
|
---|
81 | // mandatory information for VBE 2.0 and above
|
---|
82 | uint32 phys_base_ptr; // physical address for flat memory frame buffer
|
---|
83 | uint32 _reserved2; // 0
|
---|
84 | uint16 _reserved3; // 0
|
---|
85 |
|
---|
86 | // mandatory information for VBE 3.0 and above
|
---|
87 | uint16 linear_bytes_per_scanline; // linear modes: bytes per scanline
|
---|
88 | uint8 banked_nr_image_pages; // banked modes: number of images
|
---|
89 | uint8 linear_nr_image_pages; // linear modes: number of images
|
---|
90 | uint8 linear_red_mask_size; // linear modes: size of direct color red mask
|
---|
91 | uint8 linear_red_field_pos; // linear modes: bit position of LSB of red mask
|
---|
92 | uint8 linear_green_mask_size; // linear modes: size of direct color green mask
|
---|
93 | uint8 linear_green_field_pos; // linear modes: bit position of LSB of green mask
|
---|
94 | uint8 linear_blue_mask_size; // linear modes: size of direct color blue mask
|
---|
95 | uint8 linear_blue_field_pos; // linear modes: bit position of LSB of blue mask
|
---|
96 | uint8 linear_rsvd_mask_size; // linear modes: size of direct color rsvd mask
|
---|
97 | uint8 linear_rsvd_field_pos; // linear modes: bit position of LSB of rsvd mask
|
---|
98 | uint32 max_pixel_clock; // maximum pixel clock (in Hz) for graphics mode
|
---|
99 |
|
---|
100 | uint8 _reserved4[189+1];
|
---|
101 | } _PACKED vesa3_mode_infoblock;
|
---|
102 |
|
---|
103 | enum vesa3_CRTC_flags {
|
---|
104 | VESA3_CRTC_DOUBLE_SCAN = 1,
|
---|
105 | VESA3_CRTC_INTERLACED = 2,
|
---|
106 | VESA3_CRTC_HSYNC_NEGATIVE = 4,
|
---|
107 | VESA3_CRTC_VSYNC_NEGATIVE = 8
|
---|
108 | };
|
---|
109 |
|
---|
110 | /* For an explanation of what values to fill in this structure
|
---|
111 | * I've pasted some comments from Andy Ritger's gtf.c here:
|
---|
112 | *
|
---|
113 | * --- gtf.c --->
|
---|
114 | *
|
---|
115 | * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive)
|
---|
116 | * implementation of the GTF Timing Standard, is available at:
|
---|
117 | *
|
---|
118 | * ftp://ftp.vesa.org/pub/GTF/GTF_V1R1.xls
|
---|
119 | *
|
---|
120 | * Timing description:
|
---|
121 | *
|
---|
122 | * <--------1--------> <--2--> <--3--> <--4-->
|
---|
123 | * _________
|
---|
124 | * |-------------------|_______| |_______
|
---|
125 | *
|
---|
126 | * R SS SE FL
|
---|
127 | *
|
---|
128 | * 1: visible image
|
---|
129 | * 2: blank before sync (aka front porch)
|
---|
130 | * 3: sync pulse
|
---|
131 | * 4: blank after sync (aka back porch)
|
---|
132 | * R: Resolution
|
---|
133 | * SS: Sync Start
|
---|
134 | * SE: Sync End
|
---|
135 | * FL: Frame Length
|
---|
136 | *
|
---|
137 | * <-------------
|
---|
138 | *
|
---|
139 | * So the h/v values are computed as follows:
|
---|
140 | *
|
---|
141 | * sync_start = visible pixels + front porch
|
---|
142 | * sync_end = sync_start + sync pulse
|
---|
143 | * total = sync_end + back porch
|
---|
144 | */
|
---|
145 | typedef struct vesa3_CRTC_infoblock {
|
---|
146 | uint16 horizontal_total; // horizontal total in pixels
|
---|
147 | uint16 horizontal_sync_start; // horizontal sync start in pixels
|
---|
148 | uint16 horizontal_sync_end; // horizontal sync end in pixels
|
---|
149 | uint16 vertical_total; // vertical total in lines
|
---|
150 | uint16 vertical_sync_start; // vertical sync start in lines
|
---|
151 | uint16 vertical_sync_end; // vertical sync end in lines
|
---|
152 | uint8 flags; // flags (double-scan, interlaced, h/v-sync polarity)
|
---|
153 | uint32 pixel_clock; // pixel clock in units of Hz
|
---|
154 | uint16 refresh_rate; // refresh rate in units of 0.01 Hz
|
---|
155 | uint8 _reserved[40];
|
---|
156 | } _PACKED vesa3_CRTC_infoblock;
|
---|
157 |
|
---|
158 | #endif
|
---|