Subversion Repositories Kolibri OS

Rev

Rev 709 | Rev 726 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 709 Rev 713
Line 9... Line 9...
9
;;  KolibriOS 16-bit loader,                                    ;;
9
;;  KolibriOS 16-bit loader,                                    ;;
10
;;                        based on bootcode for MenuetOS        ;;
10
;;                        based on bootcode for MenuetOS        ;;
11
;;                                                              ;;
11
;;                                                              ;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 13... Line 13...
13
 
13
 
Line 14... Line 14...
14
$Revision: 709 $
14
$Revision: 713 $
15
 
15
 
16
 
16
 
Line 103... Line 103...
103
;
103
;
104
;                           16 BIT CODE
104
;                           16 BIT CODE
105
;
105
;
106
;=========================================================================
106
;=========================================================================
Line -... Line 107...
-
 
107
 
Line 107... Line 108...
107
 
108
include 'bootvesa.inc'                 ;Include source for boot vesa 
108
 
109
 
109
start_of_code:
110
start_of_code:
110
        cld
111
        cld
Line 283... Line 284...
283
        in      al, 64h
284
        in      al, 64h
284
        and     al, 00000010b  ; ready flag
285
        and     al, 00000010b  ; ready flag
285
; wait until 8042 controller is ready
286
; wait until 8042 controller is ready
286
        loopnz  wait_loop
287
        loopnz  wait_loop
Line -... Line 288...
-
 
288
 
-
 
289
;;;/diamond today   5.02.2008
-
 
290
; set keyboard typematic rate & delay
-
 
291
        mov     al, 0xf3
-
 
292
        out     0x60, al
-
 
293
        xor     cx, cx
-
 
294
@@:
-
 
295
        in      al, 64h
-
 
296
        test    al, 2
-
 
297
        loopnz  @b
-
 
298
        mov     al, 0
-
 
299
        out     0x60, al
-
 
300
        xor     cx, cx
-
 
301
@@:
-
 
302
        in      al, 64h
-
 
303
        test    al, 2
-
 
304
        loopnz  @b
287
 
305
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
288
; --------------- APM ---------------------
306
; --------------- APM ---------------------
289
        and     word [es:0x9044], 0     ; ver = 0.0 (APM not found)
307
        and     word [es:0x9044], 0     ; ver = 0.0 (APM not found)
290
        mov     ax, 0x5300
308
        mov     ax, 0x5300
291
        xor     bx, bx
309
        xor     bx, bx
Line 319... Line 337...
319
        mov     [es:0x9054], dx
337
        mov     [es:0x9054], dx
Line 320... Line 338...
320
 
338
 
321
apm_end:
339
apm_end:
Line -... Line 340...
-
 
340
        _setcursor d80x25_top_num, 0
-
 
341
 
-
 
342
;CHECK current of code
-
 
343
        cmp     [cfgmanager.loader_block], -1
-
 
344
        jz      noloaderblock
-
 
345
        les     bx, [cfgmanager.loader_block]
-
 
346
        cmp     byte [es:bx], 1
-
 
347
        mov     si, loader_block_error
-
 
348
        jnz     sayerr
322
        _setcursor d80x25_top_num, 0
349
 
-
 
350
noloaderblock:
-
 
351
; DISPLAY VESA INFORMATION
-
 
352
         call    print_vesa_info
Line 323... Line -...
323
 
-
 
324
; DISPLAY VESA INFORMATION
-
 
325
 
-
 
326
        mov     ax, 0x4f00
-
 
327
        mov     di, 0xa000
-
 
328
        int     0x10
-
 
329
        cmp     ax, 0x004f
-
 
330
        mov     si, novesa
-
 
331
        jnz     @f
-
 
332
        mov     ax, [es:di+4]
-
 
333
        add     ax, '0'*256+'0'
-
 
334
        mov     si, vervesa
-
 
Line 335... Line 353...
335
        mov     [si+vervesa_off], ah
353
         call    calc_vmodes_table
336
        mov     [si+vervesa_off+2], al
354
         call    check_first_parm  ;check and enable cursor_pos
337
@@:     call    print
355
 
338
 
356
 
339
; \begin{diamond}[30.11.2005]
357
; \begin{diamond}[30.11.2005]
340
cfgmanager:
358
cfgmanager:
341
; settings:
359
; settings:
342
; a) preboot_graph = graphical mode
360
; a) preboot_graph = graphical mode
343
;    preboot_gprobe = probe this mode?
-
 
344
; b) preboot_biosdisk  = use BIOS disks through V86 emulation?
-
 
345
; c) preboot_vrrm = use VRR?
-
 
346
; d) preboot_device = from what boot?
-
 
347
        mov     di, preboot_graph
-
 
348
; check bootloader block
-
 
349
        cmp     [.loader_block], -1
-
 
350
        jz      .noloaderblock
-
 
351
        les     bx, [.loader_block]
-
 
352
        cmp     byte [es:bx], 1
-
 
353
        mov     si, loader_block_error
-
 
354
        jnz     sayerr
-
 
355
        test    byte [es:bx+1], 1
-
 
356
        jz      @f
-
 
357
; image in memory present
361
;    preboot_gprobe = probe this mode?
358
        cmp     [di+preboot_device-preboot_graph], 0
-
 
359
        jnz     @f
362
; b) preboot_dma  = use DMA access?
360
        mov     [di+preboot_device-preboot_graph], 3
363
; c) preboot_vrrm = use VRR?
361
@@:
-
 
362
.noloaderblock:
-
 
363
; determine default settings
-
 
364
        mov     [.bSettingsChanged], 0
-
 
365
        cmp     byte [di], 0
-
 
366
        jnz     .preboot_gr_end
-
 
367
        mov     [di+preboot_gprobe-preboot_graph], 0
-
 
368
        mov     al, [vervesa+vervesa_off]
-
 
369
        cmp     al, 'x'
-
 
370
        jz      .novesa
-
 
371
        cmp     al, '1'
-
 
372
        jz      .vesa12
-
 
373
        mov     [di+preboot_gprobe-preboot_graph], 2
-
 
374
        mov     al, 3
-
 
375
        jmp     @f
-
 
376
.vesa12:
-
 
377
        mov     al, 7
364
; d) preboot_device = from what boot?
378
        jmp     @f
-
 
379
.novesa:
365
 
380
        mov     al, 10
366
; determine default settings
381
@@:
367
        mov     [.bSettingsChanged], 0
382
        mov     [di], al
368
 
383
.preboot_gr_end:
-
 
384
; following 8 lines set variables to 1 if its current value is 0
-
 
385
        cmp     [di+preboot_dma-preboot_graph], 1
369
;.preboot_gr_end:
386
        adc     [di+preboot_dma-preboot_graph], 0
370
; following 6 lines set variables to 1 if its current value is 0
387
        cmp     [di+preboot_biosdisk-preboot_graph], 1
371
        cmp     byte[preboot_dma], 1
388
        adc     [di+preboot_biosdisk-preboot_graph], 0
372
        adc     byte[preboot_dma], 0
389
        cmp     [di+preboot_vrrm-preboot_graph], 1
373
        cmp     byte[preboot_vrrm], 1
-
 
374
        adc     byte[preboot_vrrm], 0
-
 
375
        cmp     byte[preboot_device], 1
390
        adc     [di+preboot_vrrm-preboot_graph], 0
376
        adc     byte[preboot_device], 0
391
        cmp     [di+preboot_device-preboot_graph], 1
377
; notify user
392
        adc     [di+preboot_device-preboot_graph], 0
378
        _setcursor 5,2
393
; notify user
379
 
394
        mov     si, linef
380
        mov     si, linef
395
        call    print
381
        call    printplain
396
        mov     si, start_msg
382
        mov     si, start_msg
Line 406... Line 392...
406
        _setcursor 9,0
392
        _setcursor 9,0
407
        mov     si, current_cfg_msg
393
        mov     si, current_cfg_msg
408
        call    print
394
        call    print
409
        mov     si, curvideo_msg
395
        mov     si, curvideo_msg
410
        call    print
396
        call    print
411
        mov     al, [preboot_graph]
-
 
412
        cmp     al, 8
-
 
413
        ja      .pnovesa
-
 
414
        mov     dl, al
-
 
415
        and     eax, 3
-
 
416
        mov     si, [modes_msg+eax*2]
-
 
417
        call    printplain
-
 
418
        mov     si, modevesa20
-
 
419
        cmp     dl, 4
-
 
420
        jbe     @f
-
 
421
        mov     si, modevesa12
-
 
422
@@:
397
 
423
        call    printplain
-
 
424
        cmp     dl, 4
-
 
425
        ja      .x
-
 
426
        mov     si, probeno_msg
-
 
427
        cmp     [preboot_gprobe], 2
-
 
428
        jnz     @f
-
 
429
        mov     si, probeok_msg
-
 
430
@@:
-
 
431
        call    printplain
398
            call    draw_current_vmode
432
.x:
-
 
433
        jmp     .c
-
 
434
.pnovesa:
-
 
435
        cmp     al, 9
-
 
436
        mov     si, mode9
-
 
437
        jz      @b
-
 
438
        mov     si, mode10
-
 
439
        jmp     @b
-
 
440
.c:
399
 
441
        mov     si, linef
-
 
442
        call    printplain
-
 
443
;        mov     si, dma_msg
-
 
444
;        call    print
-
 
445
;        cmp     [preboot_dma], 2
-
 
446
;        mov     si, on_msg
-
 
447
;        jb      @f
-
 
448
;        mov     si, off_msg
-
 
449
;        ja      @f
-
 
450
;        mov     si, readonly_msg
-
 
451
;@@:
-
 
452
;        call    printplain
-
 
453
        mov     si, usebd_msg
400
        mov     si, usebd_msg
454
        cmp     [preboot_biosdisk], 1
401
        cmp     [preboot_biosdisk], 1
455
        call    .say_on_off
402
        call    .say_on_off
456
        mov     si, vrrm_msg
403
        mov     si, vrrm_msg
457
        cmp     [preboot_vrrm], 1
404
        cmp     [preboot_vrrm], 1
Line 466... Line 413...
466
        _setcursor 25,0         ; out of screen
413
        _setcursor 25,0         ; out of screen
467
; set timer interrupt handler
414
; set timer interrupt handler
468
        cli
415
        cli
469
        push    0
416
        push    0
470
        pop     es
417
        pop     es
-
 
418
        push    dword [es:8*4]
-
 
419
        pop     dword [.oldtimer]
-
 
420
        push    dword [.timer]
-
 
421
        pop     dword [es:8*4]    
471
        mov     eax, [es:8*4]
422
;        mov     eax, [es:8*4]
472
        mov     [.oldtimer], eax
423
;        mov     [.oldtimer], eax
473
        mov     eax, [.timer]
424
;        mov     eax, [.timer]
474
        mov     [es:8*4], eax
425
;        mov     [es:8*4], eax
475
        sti
426
        sti
476
; wait for keypressed
427
; wait for keypressed
477
        mov     ah, 0
428
        xor     ax,ax
478
        int     16h
429
        int     16h
479
        push    ax
430
        push    ax
480
; restore timer interrupt
431
; restore timer interrupt
481
        push    0
432
;        push    0
482
        pop     es
433
;        pop     es
483
        mov     eax, [.oldtimer]
434
        mov     eax, [.oldtimer]
484
        mov     [es:8*4], eax
435
        mov     [es:8*4], eax
485
        mov     [.timer], eax
436
        mov     [.timer], eax
486
        _setcursor 7,0
437
        _setcursor 7,0
487
        mov     si, space_msg
438
        mov     si, space_msg
Line 506... Line 457...
506
        call    getkey
457
        call    getkey
507
        mov     [preboot_device], al
458
        mov     [preboot_device], al
508
        _setcursor 13,0
459
        _setcursor 13,0
509
.d:
460
.d:
510
        mov     [.bSettingsChanged], 1
461
        mov     [.bSettingsChanged], 1
511
        mov     si, space_msg
462
        call    clear_vmodes_table             ;clear vmodes_table
512
        call    printplain
-
 
513
        _setcursor 15,0
-
 
514
        mov     cx, 6
-
 
515
@@:
-
 
516
        call    printplain
-
 
517
        loop    @b
-
 
518
        jmp    .printcfg
463
        jmp    .printcfg
519
.change_a:
464
.change_a:
-
 
465
.loops:
520
        _setcursor 15,0
466
        call    draw_vmodes_table
-
 
467
 
521
        mov     si, gr_mode
468
        xor     ax,ax
522
        call    printplain
469
        int     0x16
-
 
470
;        call    clear_table_cursor             ;clear current position of cursor
-
 
471
 
523
        mov     bx, '09'
472
        mov     si,word [cursor_pos]
-
 
473
 
-
 
474
        cmp     ah,0x48;x,0x48E0               ; up
524
        call    getkey
475
        jne     .down
525
        mov     [preboot_graph], al
476
        cmp     si,modes_table
526
        cmp     al, 4
477
        jbe     .loops
-
 
478
        sub     word [cursor_pos],size_of_step
527
        ja      @f
479
        jmp     .loops
-
 
480
 
-
 
481
.down:  cmp     ah,0x50;x,0x50E0               ; down
528
        mov     si, probetext
482
        jne     .enter
529
        call    printplain
483
        cmp     word[es:si+10],-1
530
        mov     bx, '12'
484
        je      .loops        
531
        call    getkey
485
        add     word [cursor_pos],size_of_step
532
        mov     [preboot_gprobe], al
486
        jmp     .loops
533
@@:
487
 
-
 
488
.enter: cmp     al,0x0D;x,0x1C0D               ; enter
534
        _setcursor 10,0
489
        jne     .loops
-
 
490
        push    word [cursor_pos]
-
 
491
        pop     word [preboot_graph]           ;save choose
535
        jmp    .d
492
        jmp    .d
-
 
493
 
536
.change_b:
494
.change_b:
537
        _setcursor 15,0
495
        _setcursor 15,0
538
;        mov     si, ask_dma
496
;        mov     si, ask_dma
539
;        call    print
497
;        call    print
540
;        mov     bx, '13'
498
;        mov     bx, '13'
Line 554... Line 512...
554
        mov     bx, '12'
512
        mov     bx, '12'
555
        call    getkey
513
        call    getkey
556
        mov     [preboot_vrrm], al
514
        mov     [preboot_vrrm], al
557
        _setcursor 12,0
515
        _setcursor 12,0
558
        jmp     .d
516
        jmp     .d
-
 
517
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
559
.say_on_off:
518
.say_on_off:
560
        pushf
519
        pushf
561
        call    print
520
        call    print
562
        mov     si, on_msg
521
        mov     si, on_msg
563
        popf
522
        popf
Line 685... Line 644...
685
.load:
644
.load:
686
; \end{diamond}[02.12.2005]
645
; \end{diamond}[02.12.2005]
Line 687... Line 646...
687
 
646
 
Line 688... Line -...
688
; ASK GRAPHICS MODE
-
 
689
 
-
 
690
        movzx   ax, [preboot_graph]
-
 
691
        push    0
-
 
692
        pop     es
-
 
693
; address is gr_table+6*(ax-1)
-
 
694
        add     ax, ax
-
 
695
        lea     si, [gr_table + eax + eax*2 - 6]
-
 
696
        mov     bx, [si+0]
-
 
697
        mov     cx, [si+2]
-
 
698
        mov     dx, [si+4]
-
 
699
        cmp     al, 9*2
-
 
700
        mov     al, 32    ; BPP
-
 
701
        jb      @f
-
 
702
        mov     [es:0x9000], al
-
 
703
        or      dword [es:0x9018], 0xFFFFFFFF; 0x800000
-
 
704
@@:
-
 
705
        mov     [es:0x9008], bx
-
 
706
        mov     [es:0x900A], cx
-
 
707
        mov     [es:0x900C], dx
-
 
708
        test    bh, bh
-
 
709
        jz      nov
-
 
710
 
-
 
711
; USE DEFAULTS OR PROBE
-
 
712
 
-
 
713
; bx - mode : cx - x size : dx - y size
-
 
714
        cmp     [preboot_gprobe], 1
-
 
715
        jz      noprobe
-
 
716
 
-
 
717
        mov     bx, 0x100
-
 
718
     newprobe:
-
 
719
        inc     bx
-
 
720
        cmp     bx, 0x17f
-
 
721
        mov     si, prnotfnd
-
 
722
        jz      invalid_video_mode
-
 
723
 
-
 
724
     probemore:
-
 
725
        push    cx
-
 
726
        mov     ax, 0x4f01
-
 
727
        mov     cx, bx
-
 
728
        mov     di, 0xa000
-
 
729
        int     0x10
-
 
730
        pop     cx
-
 
731
 
-
 
732
        test    byte [es:di], 80h    ; lfb?
-
 
733
        jz      newprobe
-
 
734
        cmp     [es:di+0x12], cx    ; x size?
-
 
735
        jnz     newprobe
-
 
736
        cmp     [es:di+0x14], dx    ; y size?
-
 
737
        jnz     newprobe
-
 
738
        cmp     byte [es:di+0x19], 32 ;24
-
 
739
        jb      newprobe
-
 
740
 
-
 
741
;       add     bx, 0100000000000000b
-
 
742
        or      bh, 40h
-
 
743
        mov     [es:0x9008], bx
-
 
744
 
-
 
745
     noprobe:
-
 
746
 
-
 
747
 
-
 
748
; FIND VESA 2.0 LFB & BPP
-
 
749
 
-
 
750
        mov     ax, 0x4f01
-
 
751
        mov     cx, bx
-
 
752
        and     cx, 0xfff
-
 
753
        mov     di, 0xa000
-
 
754
        int     0x10
-
 
755
        ; LFB
-
 
756
        mov     eax, [es:di+0x28]
-
 
757
        mov     [es:0x9018], eax
-
 
758
        ; ---- vbe voodoo
-
 
759
        BytesPerLine equ 0x10
-
 
760
        mov     ax, [es:di+BytesPerLine]
-
 
761
        mov     [es:0x9001], ax
-
 
762
        ; BPP
-
 
763
        mov     al, byte [es:di+0x19]
-
 
764
        mov     [es:0x9000], al
-
 
765
nov:
-
 
766
        cmp     al, 24
-
 
767
        mov     si, bt24
-
 
768
        jz      bppl
-
 
769
        cmp     al, 32
-
 
770
        mov     si, bt32
-
 
771
        jz      bppl
-
 
772
        mov     si, btns
-
 
773
invalid_video_mode:
-
 
774
        call    print
-
 
775
        _setcursor (d80x25_top_num+2), 0
-
 
776
        mov     si, start_msg
-
 
777
        call    print
-
 
778
        jmp     cfgmanager.printcfg
647
; ASK GRAPHICS MODE
779
bppl:
-
 
780
        call    print
-
 
781
 
-
 
782
 
-
 
783
; FIND VESA 1.2 PM BANK SWITCH ADDRESS
-
 
784
 
-
 
785
        push    es
-
 
786
        mov     ax, 0x4f0A
-
 
787
        xor     bx, bx
-
 
788
        int     0x10
-
 
789
        xor     eax, eax
-
 
790
        mov     ax, es
-
 
791
        shl     eax, 4
-
 
792
        movzx   ebx, di
-
 
793
        add     eax, ebx
-
 
794
        mov     bx, [es:di]
-
 
795
        add     eax, ebx
-
 
796
        pop     es
-
 
Line 797... Line 648...
797
        mov     [es:0x9014], eax
648
 
798
 
649
        call    set_vmode
799
 
650
 
Line 1107... Line 958...
1107
        mov     ax, 0x4f02              ; Vesa
958
        mov     ax, 0x4f02              ; Vesa
1108
setgr:
959
setgr:
1109
        int     0x10
960
        int     0x10
1110
        test    ah, ah
961
        test    ah, ah
1111
        mov     si, fatalsel
962
        mov     si, fatalsel
1112
        jnz     sayerr
963
        jnz     v_mode_error
1113
; set mode 0x12 graphics registers:
964
; set mode 0x12 graphics registers:
1114
        cmp     bx, 0x12
965
        cmp     bx, 0x12
1115
        jne     gmok2
966
        jne     gmok2
Line 1116... Line 967...
1116
 
967