Subversion Repositories HelenOS

Rev

Rev 4346 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4346 Rev 4347
Line 2... Line 2...
2
 
2
 
3
#include <macros.h>
3
#include <macros.h>
4
 
4
 
5
#define VESA_INFO_SIZE 1024
5
#define VESA_INFO_SIZE 1024
6
 
6
 
7
#define VESA_MODE_ATTRIBUTES_OFFSET 0
7
#define VESA_MODE_ATTRIBUTES_OFFSET  0
8
#define VESA_MODE_LIST_PTR_OFFSET 14
8
#define VESA_MODE_LIST_PTR_OFFSET    14
9
#define VESA_MODE_SCANLINE_OFFSET 16
9
#define VESA_MODE_SCANLINE_OFFSET    16
10
#define VESA_MODE_WIDTH_OFFSET 18
10
#define VESA_MODE_WIDTH_OFFSET       18
11
#define VESA_MODE_HEIGHT_OFFSET 20
11
#define VESA_MODE_HEIGHT_OFFSET      20
12
#define VESA_MODE_BPP_OFFSET 25
12
#define VESA_MODE_BPP_OFFSET         25
-
 
13
#define VESA_MODE_RED_MASK_OFFSET    31
-
 
14
#define VESA_MODE_RED_POS_OFFSET     32
-
 
15
#define VESA_MODE_GREEN_MASK_OFFSET  33
-
 
16
#define VESA_MODE_GREEN_POS_OFFSET   34
-
 
17
#define VESA_MODE_BLUE_MASK_OFFSET   35
-
 
18
#define VESA_MODE_BLUE_POS_OFFSET    36
13
#define VESA_MODE_PHADDR_OFFSET 40
19
#define VESA_MODE_PHADDR_OFFSET      40
14
 
20
 
15
#define VESA_END_OF_MODES 0xffff
21
#define VESA_END_OF_MODES  0xffff
16
 
22
 
17
#define VESA_OK 0x4f
23
#define VESA_OK  0x4f
18
 
24
 
19
#define VESA_GET_INFO 0x4f00
25
#define VESA_GET_INFO       0x4f00
20
#define VESA_GET_MODE_INFO 0x4f01
26
#define VESA_GET_MODE_INFO  0x4f01
21
#define VESA_SET_MODE 0x4f02
27
#define VESA_SET_MODE       0x4f02
22
#define VESA_SET_PALETTE 0x4f09
28
#define VESA_SET_PALETTE    0x4f09
23
 
29
 
24
.code32
30
.code32
25
vesa_init:
31
vesa_init:
26
	jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init
32
	jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init
27
	
33
	
Line 161... Line 167...
161
	
167
	
162
	next_mode:
168
	next_mode:
163
		# try next mode
169
		# try next mode
164
		mov %gs:(%si), %cx
170
		mov %gs:(%si), %cx
165
		cmp $VESA_END_OF_MODES, %cx
171
		cmp $VESA_END_OF_MODES, %cx
166
		jz no_mode
172
		je no_mode
167
		
173
		
168
		inc %si
174
		inc %si
169
		inc %si
175
		inc %si
170
		push %cx
176
		push %cx
171
		push %di
177
		push %di
Line 175... Line 181...
175
		
181
		
176
		pop %si
182
		pop %si
177
		pop %di
183
		pop %di
178
		pop %cx
184
		pop %cx
179
		cmp $VESA_OK, %al
185
		cmp $VESA_OK, %al
180
		jnz no_mode
186
		jne no_mode
-
 
187
		
-
 
188
		# check for proper attributes (supported, color, graphics, linear framebuffer)
-
 
189
		
-
 
190
		mov VESA_MODE_ATTRIBUTES_OFFSET(%di), %ax
-
 
191
		and $0x99, %ax
-
 
192
		cmp $0x99, %ax
-
 
193
		jne next_mode
-
 
194
		
-
 
195
		# check for proper resolution
181
		
196
		
182
		mov default_width - vesa_init, %ax
197
		mov default_width - vesa_init, %ax
183
		cmp VESA_MODE_WIDTH_OFFSET(%di), %ax
198
		cmp VESA_MODE_WIDTH_OFFSET(%di), %ax
184
		jnz next_mode
199
		jne next_mode
185
		
200
		
186
		mov default_height - vesa_init, %ax
201
		mov default_height - vesa_init, %ax
187
		cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax
202
		cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax
188
		jnz next_mode
203
		jne next_mode
-
 
204
		
-
 
205
		# check for proper bpp
189
		
206
		
190
		mov default_bpp - vesa_init, %al
207
		mov default_bpp - vesa_init, %al
191
		cmp VESA_MODE_BPP_OFFSET(%di), %al
208
		cmp VESA_MODE_BPP_OFFSET(%di), %al
192
		jz set_mode
209
		je set_mode
193
		
210
		
194
		mov $24, %al
211
		mov $24, %al
195
		cmp default_bpp - vesa_init, %al
212
		cmp default_bpp - vesa_init, %al
196
		jnz next_mode
213
		jne next_mode
197
		
214
		
198
		# for 24 bpp modes accept also 32 bit bpp
215
		# for 24 bpp modes accept also 32 bit bpp
199
		
216
		
200
		mov $32, %al
217
		mov $32, %al
201
		cmp VESA_MODE_BPP_OFFSET(%di), %al
218
		cmp VESA_MODE_BPP_OFFSET(%di), %al
202
		jnz next_mode
219
		jne next_mode
203
	
220
	
204
	set_mode:
221
	set_mode:
205
		mov %cx, %bx
222
		mov %cx, %bx
206
		or $0xc000, %bx
223
		or $0xc000, %bx
207
		push %di
224
		push %di
Line 264... Line 281...
264
		
281
		
265
			pop %di
282
			pop %di
266
		
283
		
267
		vga_not_set:
284
		vga_not_set:
268
		
285
		
-
 
286
		# store mode parameters
-
 
287
		#  eax = bpp[8] scanline[16]
-
 
288
		#  ebx = width[16]  height[16]
-
 
289
		#  edx = red_mask[8] red_pos[8] green_mask[8] green_pos[8]
269
		mov VESA_MODE_PHADDR_OFFSET(%di), %esi
290
		#  esi = blue_mask[8] blue_pos[8]
-
 
291
		#  edi = linear frame buffer
-
 
292
		
270
		mov VESA_MODE_WIDTH_OFFSET(%di), %ax
293
		mov VESA_MODE_BPP_OFFSET(%di), %al
-
 
294
		xor %ah, %ah
271
		shl $16, %eax
295
		shl $16, %eax
272
		mov VESA_MODE_HEIGHT_OFFSET(%di), %ax
296
		mov VESA_MODE_SCANLINE_OFFSET(%di), %ax
-
 
297
		
273
		mov VESA_MODE_BPP_OFFSET(%di), %bl
298
		mov VESA_MODE_WIDTH_OFFSET(%di), %bx
274
		xor %bh, %bh
-
 
275
		shl $16, %ebx
299
		shl $16, %ebx
276
		mov VESA_MODE_SCANLINE_OFFSET(%di), %bx
300
		mov VESA_MODE_HEIGHT_OFFSET(%di), %bx
-
 
301
		
-
 
302
		mov VESA_MODE_BLUE_MASK_OFFSET(%di), %dl
-
 
303
		shl $8, %edx
-
 
304
		mov VESA_MODE_BLUE_POS_OFFSET(%di), %dl
277
		mov %eax, %edi
305
		mov %edx, %esi
-
 
306
		
-
 
307
		mov VESA_MODE_RED_MASK_OFFSET(%di), %dl
-
 
308
		shl $8, %edx
-
 
309
		mov VESA_MODE_RED_POS_OFFSET(%di), %dl
-
 
310
		shl $8, %edx
-
 
311
		mov VESA_MODE_GREEN_MASK_OFFSET(%di), %dl
-
 
312
		shl $8, %edx
-
 
313
		mov VESA_MODE_GREEN_POS_OFFSET(%di), %dl
-
 
314
		
-
 
315
		mov VESA_MODE_PHADDR_OFFSET(%di), %edi
278
		
316
		
279
		vesa_leave_real:
317
		vesa_leave_real:
280
		
318
		
281
			mov %cr0, %eax
319
			mov %cr0, %ecx
282
			or $1, %eax
320
			or $1, %ecx
283
			mov %eax, %cr0
321
			mov %ecx, %cr0
284
			
322
			
285
			jmp vesa_leave_real2
323
			jmp vesa_leave_real2
286
			
324
			
287
		vesa_leave_real2:
325
		vesa_leave_real2:
288
		
326