Subversion Repositories HelenOS-historic

Rev

Rev 1291 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1291 Rev 1641
Line 72... Line 72...
72
	movl %eax, grub_eax							# save parameters from GRUB
72
	movl %eax, grub_eax							# save parameters from GRUB
73
	movl %ebx, grub_ebx
73
	movl %ebx, grub_ebx
74
	
74
	
75
#ifdef CONFIG_FB
75
#ifdef CONFIG_FB
76
	mov $vesa_init,%esi;
76
	mov $vesa_init, %esi;
77
	mov $VESA_INIT_SEGMENT<<4,%edi;
77
	mov $VESA_INIT_SEGMENT << 4, %edi
78
	mov $e_vesa_init-vesa_init,%ecx;
78
	mov $e_vesa_init - vesa_init, %ecx
79
	cld;
79
	cld
80
	rep movsb;
80
	rep movsb
81
 
81
 
82
	mov $VESA_INIT_SEGMENT<<4,%edi;
82
	mov $VESA_INIT_SEGMENT << 4, %edi
83
	call *%edi;
83
	jmpl *%edi
-
 
84
	
-
 
85
	vesa_meeting_point:
-
 
86
	
84
	mov %esi,KA2PA(vesa_ph_addr);
87
	mov %esi, KA2PA(vesa_ph_addr)
85
	mov %di,KA2PA(vesa_height);
88
	mov %di, KA2PA(vesa_height)
86
	shr $16,%edi;
89
	shr $16, %edi
87
	mov %di,KA2PA(vesa_width);
90
	mov %di, KA2PA(vesa_width)
88
	mov %bx,KA2PA(vesa_scanline);
91
	mov %bx, KA2PA(vesa_scanline)
89
	shr $16,%ebx;
92
	shr $16, %ebx
90
	mov %bx,KA2PA(vesa_bpp);
93
	mov %bx, KA2PA(vesa_bpp)
91
#endif	
94
#endif	
92
 
95
 
93
	# Protected 32-bit. We want to reuse the code-seg descriptor,
96
	# Protected 32-bit. We want to reuse the code-seg descriptor,
94
	# the Default operand size must not be 1 when entering long mode
97
	# the Default operand size must not be 1 when entering long mode
95
	
98
	
Line 272... Line 275...
272
	hlt
275
	hlt
273
 
276
 
274
#ifdef CONFIG_FB
277
#ifdef CONFIG_FB
275
.code32
278
.code32
276
vesa_init:
279
vesa_init:
277
	jmp $gdtselector(VESA_INIT_DES),$vesa_init_real-vesa_init;
280
	jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init
-
 
281
	
278
.code16
282
.code16
279
vesa_init_real:	
283
vesa_init_real:
280
 
284
	
281
	mov %cr0,%eax;
285
	mov %cr0, %eax
282
	and $~1,%eax;
286
	and $~1, %eax
283
	mov %eax,%cr0;
287
	mov %eax, %cr0
284
 
-
 
285
 
288
	
286
	jmp $VESA_INIT_SEGMENT,$vesa_init_real2-vesa_init;
289
	jmp $VESA_INIT_SEGMENT, $vesa_init_real2 - vesa_init
287
 
290
	
288
vesa_init_real2:	
291
vesa_init_real2:
289
 
292
	
-
 
293
	mov $VESA_INIT_SEGMENT, %bx
290
 
294
	
291
	mov %esp,%ebp;
-
 
292
	mov %ss,%cx;
-
 
293
	mov $VESA_INIT_SEGMENT,%bx;
-
 
294
	mov %bx,%ss;
295
	mov %bx, %es
295
	mov $0x0000fffc,%esp;
-
 
296
	push %ds;
-
 
297
	push %es;
-
 
298
	push %fs;
-
 
299
	push %gs;
-
 
300
	push %ebp;
-
 
301
	push %cx;
-
 
302
 
-
 
303
	mov %bx,%ds;
296
	mov %bx, %fs
304
	mov %bx,%es;
297
	mov %bx, %gs
305
	mov %bx,%fs;
298
	mov %bx, %ds
306
	mov %bx,%gs;
299
	mov %bx, %ss
307
 
300
	
308
	
-
 
309
	mov $vesa_idt-vesa_init,%ebx;
301
	movl $0x0000fffc, %esp
310
	lidtl (%ebx);
302
    movl $0x0000fffc, %ebp
311
 
303
	
312
#define VESA_INFO_SIZE 1024
304
#define VESA_INFO_SIZE 1024
313
 
305
 
314
#define VESA_MODE_LIST_PTR_OFFSET 14 
306
#define VESA_MODE_LIST_PTR_OFFSET 14
315
#define VESA_MODE_WIDTH_OFFSET 18
307
#define VESA_MODE_WIDTH_OFFSET 18
Line 331... Line 323...
331
#if CONFIG_VESA_BPP==24
323
#if CONFIG_VESA_BPP == 24
332
#undef CONFIG_VESA_BPP_a
324
#undef CONFIG_VESA_BPP_a
333
#define CONFIG_VESA_BPP_a 32
325
#define CONFIG_VESA_BPP_a 32
334
#endif
326
#endif
335
 
327
	
336
 
-
 
337
	mov $VESA_GET_INFO,%ax;
328
	mov $VESA_GET_INFO, %ax
338
	mov $e_vesa_init-vesa_init,%di
329
	mov $e_vesa_init - vesa_init, %di
339
	push %di;
330
	push %di
340
	int $0x10;	
331
	int $0x10
341
	pop %di;
-
 
342
	cmp $VESA_OK,%al;
-
 
343
	jnz 0f;
-
 
344
	mov 2+VESA_MODE_LIST_PTR_OFFSET(%di),%si;
-
 
345
	mov %si,%gs;
-
 
346
	mov VESA_MODE_LIST_PTR_OFFSET(%di),%si;
-
 
347
 
332
	
-
 
333
	pop %di
-
 
334
	cmp $VESA_OK, %al
-
 
335
	jnz 0f
-
 
336
	
-
 
337
	mov 2 + VESA_MODE_LIST_PTR_OFFSET(%di), %si
-
 
338
	mov %si, %gs
-
 
339
	mov VESA_MODE_LIST_PTR_OFFSET(%di), %si
-
 
340
	
348
	add $VESA_INFO_SIZE,%di;
341
	add $VESA_INFO_SIZE, %di
349
 
342
	
350
1:# Try next mode
343
1:# Try next mode
351
	mov %gs:(%si),%cx;
344
	mov %gs:(%si), %cx
352
	cmp $VESA_END_OF_MODES,%cx;
345
	cmp $VESA_END_OF_MODES, %cx
353
	jz 0f;
346
	jz 0f
-
 
347
	
354
	inc %si;
348
	inc %si
355
	inc %si;
349
	inc %si
356
	push %cx;
350
	push %cx
357
	push %di;
351
	push %di
358
	push %si;
352
	push %si
359
	mov $VESA_GET_MODE_INFO,%ax;
353
	mov $VESA_GET_MODE_INFO, %ax
360
	int $0x10;
354
	int $0x10
-
 
355
	
361
	pop %si;
356
	pop %si
362
	pop %di;
357
	pop %di
363
	pop %cx;
358
	pop %cx
364
	cmp $VESA_OK,%al;
359
	cmp $VESA_OK, %al
365
	jnz 0f;
360
	jnz 0f
366
 
-
 
367
 
361
	
368
	mov $CONFIG_VESA_WIDTH,%ax;
362
	mov $CONFIG_VESA_WIDTH, %ax
369
	cmp VESA_MODE_WIDTH_OFFSET(%di),%ax;
363
	cmp VESA_MODE_WIDTH_OFFSET(%di), %ax
370
	jnz 1b;
364
	jnz 1b
-
 
365
	
371
	mov $CONFIG_VESA_HEIGHT,%ax;
366
	mov $CONFIG_VESA_HEIGHT, %ax
372
	cmp VESA_MODE_HEIGHT_OFFSET(%di),%ax;
367
	cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax
373
	jnz 1b;
368
	jnz 1b
-
 
369
	
374
	mov $CONFIG_VESA_BPP,%al;
370
	mov $CONFIG_VESA_BPP, %al
375
	cmp VESA_MODE_BPP_OFFSET(%di),%al;
371
	cmp VESA_MODE_BPP_OFFSET(%di), %al
376
	jz 2f;
372
	jz 2f
-
 
373
	
377
	mov $CONFIG_VESA_BPP_a,%al;
374
	mov $CONFIG_VESA_BPP_a, %al
378
	cmp VESA_MODE_BPP_OFFSET(%di),%al;
375
	cmp VESA_MODE_BPP_OFFSET(%di), %al
379
	jnz 1b;
376
	jnz 1b
380
 
377
	
381
2:
378
2:
382
 
379
	
383
	mov %cx,%bx;
380
	mov %cx, %bx
384
	or $0xC000,%bx;
381
	or $0xc000, %bx
385
	push %di;
382
	push %di
386
	mov $VESA_SET_MODE,%ax;
383
	mov $VESA_SET_MODE, %ax
387
	int $0x10;
384
	int $0x10
-
 
385
	
388
	pop %di;
386
	pop %di
389
	cmp $VESA_OK,%al;
387
	cmp $VESA_OK, %al
390
	jnz 0f;
388
	jnz 0f
391
	
389
	
392
	mov VESA_MODE_PHADDR_OFFSET(%di),%esi;
390
	mov VESA_MODE_PHADDR_OFFSET(%di), %esi
393
	mov VESA_MODE_WIDTH_OFFSET(%di),%ax;
391
	mov VESA_MODE_WIDTH_OFFSET(%di), %ax
394
	shl $16,%eax;
392
	shl $16, %eax
395
	mov VESA_MODE_HEIGHT_OFFSET(%di),%ax;
393
	mov VESA_MODE_HEIGHT_OFFSET(%di), %ax
396
	mov VESA_MODE_BPP_OFFSET(%di),%bl;
394
	mov VESA_MODE_BPP_OFFSET(%di), %bl
397
	xor %bh,%bh;
395
	xor %bh, %bh
398
	shl $16,%ebx;
396
	shl $16, %ebx
399
	mov VESA_MODE_SCANLINE_OFFSET(%di),%bx;
397
	mov VESA_MODE_SCANLINE_OFFSET(%di), %bx
400
	mov %eax,%edi; 
398
	mov %eax, %edi
401
	
-
 
402
	
-
 
403
 
399
	
404
8:	
400
8:
405
 
401
	
406
	mov %cr0,%eax;
402
	mov %cr0, %eax
407
	or $1,%eax;
403
	or $1, %eax
408
	mov %eax,%cr0;
404
	mov %eax, %cr0
409
 
405
	
410
	jmp 9f;
406
	jmp 9f
411
9:
407
9:
412
 
408
	
413
	pop %cx;
-
 
414
	pop %ebp;
-
 
415
	pop %gs;
-
 
416
	pop %fs;
-
 
417
	pop %es;
-
 
418
	pop %ds;
-
 
419
	mov %cx,%ss;
-
 
420
	mov %ebp,%esp;
-
 
421
 
-
 
422
	ljmpl $gdtselector(KTEXT32_DES),$(vesa_init_protect-vesa_init+VESA_INIT_SEGMENT<<4);
409
	ljmpl $gdtselector(KTEXT32_DES), $(vesa_init_protect - vesa_init + VESA_INIT_SEGMENT << 4)
423
 
410
	
424
 
-
 
425
0:#Error no Prefered mode found
411
0:# No prefered mode found
426
  mov $0x111,%cx;
412
	mov $0x111, %cx
427
  push %di;
413
	push %di
428
  push %cx;
414
	push %cx
429
  mov $VESA_GET_MODE_INFO,%ax;
415
	mov $VESA_GET_MODE_INFO, %ax
430
  int $0x10;
416
	int $0x10
-
 
417
	
431
  pop %cx;
418
	pop %cx
432
  pop %di;
419
	pop %di
433
  cmp $VESA_OK,%al;
420
	cmp $VESA_OK, %al
434
  jnz 1f;
421
	jnz 1f
435
  jz 2b;    /* Force relative jump */
422
	jz 2b						# Force relative jump
436
 
423
 
437
																																	
-
 
-
 
424
1:
438
1:mov $0x0003,%ax;
425
	mov $0x0003, %ax
439
  int $0x10;
426
	int $0x10
440
  mov $0xffffffff,%edi; /* EGA text mode used, because of problems with VESA */
427
	mov $0xffffffff, %edi		# EGA text mode used, because of problems with VESA
441
  xor %ax,%ax
428
	xor %ax, %ax
442
  jz 8b;    /* Force relative jump */
429
	jz 8b						# Force relative jump
443
																																																								
430
	
444
 
431
	
445
vesa_init_protect:	
-
 
446
.code32
432
.code32
447
	ret;
433
vesa_init_protect:
-
 
434
	movw $gdtselector(KDATA_DES), %cx
-
 
435
	movw %cx, %es
-
 
436
	movw %cx, %ds							# kernel data + stack
-
 
437
	movw %cx, %ss
-
 
438
	# Simics seems to remove hidden part of GS on entering user mode
-
 
439
	#  when _visible_ part of GS does not point to user-mode segment
-
 
440
	movw $gdtselector(UDATA_DES), %cx
-
 
441
	movw %cx, %fs
-
 
442
	movw %cx, %gs
448
 
443
	
-
 
444
	jmpl $gdtselector(KTEXT32_DES), $vesa_meeting_point
449
 
445
	
450
vesa_idt:
-
 
451
.word 0x03ff
-
 
452
.long 0
-
 
453
.align 4
446
.align 4
454
e_vesa_init:
447
e_vesa_init:
455
#endif	
448
#endif	
456
 
449
				
457
 
-
 
458
				
-
 
459
.section K_DATA_START, "aw", @progbits
450
.section K_DATA_START, "aw", @progbits
460
.align 4096
451
.align 4096
461
 
452
 
462
# Identical mapping of first 64MB and the same of -2GB -> 0	
453
# Identical mapping of first 64MB and the same of -2GB -> 0	
463
.global ptl_2
454
.global ptl_2