Subversion Repositories Kolibri OS

Rev

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

Rev 134 Rev 384
Line 15... Line 15...
15
;
15
;
16
;==========================================================================
16
;==========================================================================
Line 17... Line 17...
17
 
17
 
Line -... Line 18...
-
 
18
include 'drawtext.inc'
-
 
19
 
-
 
20
; 16-bit data
-
 
21
		org $+0x10000
-
 
22
 
-
 
23
old_ints_h:
-
 
24
        dw      0x400
-
 
25
        dd      0
-
 
26
        dw      0
-
 
27
 
-
 
28
kernel_restart_bootblock:
-
 
29
    db    1    ; version
-
 
30
    dw    1    ; floppy image is in memory
-
 
31
    dd    0    ; cannot save parameters
-
 
32
 
-
 
33
 
-
 
34
align 32
-
 
35
 
-
 
36
; GDT TABLE
-
 
37
 
-
 
38
gdts:
-
 
39
 
-
 
40
        dw     gdte-$-1
-
 
41
        dd     gdts
-
 
42
        dw     0
-
 
43
 
-
 
44
; Attention! The order first four selectors not to change, is used in Fast System Call
-
 
45
; must be : os_code, os_data, app_code, app_data, ....
-
 
46
 
-
 
47
int_code_l:
-
 
48
os_code_l:
-
 
49
        dw     0xffff
-
 
50
        dw     0x0000
-
 
51
        db     0x00
-
 
52
        dw     11011111b *256 +10011010b
-
 
53
        db     0x00
-
 
54
 
-
 
55
int_data_l:
-
 
56
os_data_l:
-
 
57
        dw     0xffff
-
 
58
        dw     0x0000
-
 
59
        db     0x00
-
 
60
        dw     11011111b *256 +10010010b
-
 
61
        db     0x00
-
 
62
 
-
 
63
app_code_l:
-
 
64
        dw 0xFFFF
-
 
65
        dw 0
-
 
66
        db 0
-
 
67
        db cpl3
-
 
68
        dw G32+D32+0x8000+0x7;
-
 
69
 
-
 
70
app_data_l:
-
 
71
        dw 0xFFFF
-
 
72
        dw 0
-
 
73
        db 0
-
 
74
        db drw3
-
 
75
        dw G32+D32+0x8000+0x7;
-
 
76
 
-
 
77
; --------------- APM ---------------------
-
 
78
apm_code_32:
-
 
79
        dw     0x0f        ; limit 64kb
-
 
80
        db     0, 0, 0
-
 
81
        dw     11010000b *256 +10011010b
-
 
82
        db     0x00
-
 
83
apm_code_16:
-
 
84
        dw     0x0f
-
 
85
        db     0, 0, 0
-
 
86
        dw     10010000b *256 +10011010b
-
 
87
        db     0x00
-
 
88
apm_data_16:
-
 
89
        dw     0x0f
-
 
90
        db     0, 0, 0
-
 
91
        dw     10010000b *256 +10010010b
-
 
92
        db     0x00
-
 
93
; -----------------------------------------
-
 
94
 
-
 
95
graph_data_l:
-
 
96
 
-
 
97
        dw     0x7ff
-
 
98
        dw     0x0000
-
 
99
        db     0x00
-
 
100
        dw     11010000b *256 +11110010b
-
 
101
        db     0x00
-
 
102
 
-
 
103
tss0_l:
-
 
104
;      times (max_processes+10) dd 0,0
-
 
105
gdte = $ + (max_processes+10)*8
-
 
106
 
-
 
107
 
-
 
108
; table for move to extended memory (int 15h, ah=87h)
-
 
109
       movedesc:
-
 
110
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
111
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
112
 
-
 
113
        db      0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
-
 
114
        db      0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
-
 
115
 
-
 
116
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
117
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
118
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
119
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
18
include 'drawtext.inc'
120
        	org $-0x10000
19
 
121
 
20
putchar:
122
putchar:
21
; in: al=character
123
; in: al=character
22
    mov    ah, 0Eh
124
    mov    ah, 0Eh
Line 139... Line 241...
139
{
241
{
140
    mov    dx, row*256 + column
242
    mov    dx, row*256 + column
141
    call    setcursor
243
    call    setcursor
142
}
244
}
Line 143... Line 245...
143
 
245
 
144
pagetable_set:
246
;pagetable_set:
145
;eax - physical address
247
;eax - physical address
146
;es:di - page table
248
;es:di - page table
147
;ecx - number of pages to map
249
;ecx - number of pages to map
148
    or    al, 7
250
;    or    al, 7
149
@@:
251
;@@:
150
    stosd
252
;    stosd
151
    add    eax, 1000h
253
;    add    eax, 1000h
152
    loop    @b
254
;    loop    @b
Line 153... Line 255...
153
    ret
255
;    ret
154
 
256
 
155
boot_read_floppy:
257
boot_read_floppy:
156
        push    si
258
        push    si
Line 170... Line 272...
170
        jmp     $
272
        jmp     $
171
@@:
273
@@:
172
        pop     si
274
        pop     si
173
        ret
275
        ret
Line 174... Line -...
174
 
-
 
175
		org $+0x10000
-
 
176
 
-
 
177
; table for move to extended memory (int 15h, ah=87h)
-
 
178
       movedesc:
-
 
179
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
180
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
181
 
-
 
182
        db      0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
-
 
183
        db      0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
-
 
184
 
-
 
185
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
186
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
187
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
188
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
-
 
189
        	org $-0x10000
276
 
Line 190... Line 277...
190
include 'bootvesa.inc'
277
include 'bootvesa.inc'
191
 
278
 
192
;=========================================================================
279
;=========================================================================
Line 234... Line 321...
234
        mov  cx,20h              ; 32 symbols
321
        mov  cx,20h              ; 32 symbols
235
        mov  dx,0E0h             ; 224 - position of first symbol
322
        mov  dx,0E0h             ; 224 - position of first symbol
236
        mov  ax,1100h
323
        mov  ax,1100h
237
          int  10h
324
          int  10h
238
 ; End set VGA russian font
325
 ; End set VGA russian font
-
 
326
else if lang eq et
-
 
327
        mov  bp,ET_FNT-10000h   ; ET_FNT1
-
 
328
        mov  bx,1000h           ;
-
 
329
        mov  cx,255             ; 256 symbols
-
 
330
        mov  dx,0h              ; 0 - position of first symbol
-
 
331
        mov  ax,1100h
-
 
332
        int  10h
239
end if
333
end if
Line 240... Line 334...
240
 
334
 
241
; draw frames
335
; draw frames
242
    push    0xb800
336
    push    0xb800
Line 349... Line 443...
349
; test_kbd:
443
; test_kbd:
350
;       in       al,64h    ;÷èòàåì ñîñòîÿíèå êëàâèàòóðû
444
;       in       al,64h    ;÷èòàåì ñîñòîÿíèå êëàâèàòóðû
351
;       test     al,2      ;ïðîâåðêà áèòà ãîòîâíîñòè
445
;       test     al,2      ;ïðîâåðêà áèòà ãîòîâíîñòè
352
;       loopnz   test_kbd
446
;       loopnz   test_kbd
Line -... Line 447...
-
 
447
 
-
 
448
        push    0
-
 
449
        pop     es
-
 
450
        and     word [es:0x9031], 0
-
 
451
; \begin{Mario79}
-
 
452
; find HDD IDE DMA PCI device
-
 
453
; check for PCI BIOS
-
 
454
        mov     ax, 0xB101
-
 
455
        int     0x1A
-
 
456
        jc      .nopci
-
 
457
        cmp     edx, 'PCI '
-
 
458
        jnz     .nopci
-
 
459
; find PCI class code
-
 
460
; class 1 = mass storage
-
 
461
; subclass 1 = IDE controller
-
 
462
; a) class 1, subclass 1, programming interface 0x80
-
 
463
        mov     ax, 0xB103
-
 
464
        mov     ecx, 1*10000h + 1*100h + 0x80
-
 
465
        mov     si, 0   ; device index = 0
-
 
466
        int     0x1A
-
 
467
        jnc     .found
-
 
468
; b) class 1, subclass 1, programming interface 0x8A
-
 
469
        mov     ax, 0xB103
-
 
470
        mov     ecx, 1*10000h + 1*100h + 0x8A
-
 
471
        mov     si, 0   ; device index = 0
-
 
472
        int     0x1A
-
 
473
        jnc     .found
-
 
474
; c) class 1, subclass 1, programming interface 0x85
-
 
475
        mov     ax, 0xB103
-
 
476
        mov     ecx, 1*10000h + 1*100h + 0x85
-
 
477
        mov     si, 0
-
 
478
        int     0x1A
-
 
479
        jc      .nopci
-
 
480
.found:
-
 
481
; get memory base
-
 
482
        mov     ax, 0xB10A
-
 
483
        mov     di, 0x20        ; memory base is config register at 0x20
-
 
484
        int     0x1A
-
 
485
        jc      .nopci
-
 
486
        and     cx, 0xFFF0      ; clear address decode type
-
 
487
        mov     [es:0x9031], cx
-
 
488
.nopci:
-
 
489
; \end{Mario79}
353
 
490
 
354
    mov   al,0xf6         ; Ñáðîñ êëàâèàòóðû, ðàçðåøèòü ñêàíèðîâàíèå
491
    mov   al,0xf6         ; Ñáðîñ êëàâèàòóðû, ðàçðåøèòü ñêàíèðîâàíèå
355
    out   0x60,al
492
    out   0x60,al
356
    xor   cx,cx
493
    xor   cx,cx
357
wait_loop:       ; variant 2
494
wait_loop:       ; variant 2
Line 418... Line 555...
418
; \begin{diamond}[30.11.2005]
555
; \begin{diamond}[30.11.2005]
419
cfgmanager:
556
cfgmanager:
420
; settings:
557
; settings:
421
; a) preboot_graph = graphical mode
558
; a) preboot_graph = graphical mode
422
;    preboot_gprobe = probe this mode?
559
;    preboot_gprobe = probe this mode?
423
; b) preboot_mtrr = use hardware acceleration?
560
; b) preboot_dma_write  = use DMA write?
424
; c) preboot_vrrm = use VRR?
561
; c) preboot_vrrm = use VRR?
425
; d) preboot_device = from what boot?
562
; d) preboot_device = from what boot?
426
    mov    di, preboot_graph-0x10000
563
    mov    di, preboot_graph-0x10000
427
; check bootloader block
564
; check bootloader block
428
    cmp    [.loader_block-0x10000], 0
565
    cmp    [.loader_block-0x10000], -1
429
    jz    .noloaderblock
566
    jz    .noloaderblock
430
    les    bx, [.loader_block-0x10000]
567
    les    bx, [.loader_block-0x10000]
431
    cmp    byte [es:bx], 1
568
    cmp    byte [es:bx], 1
432
    mov    si, loader_block_error-0x10000
569
    mov    si, loader_block_error-0x10000
433
    jnz    sayerr
570
    jnz    sayerr
Line 441... Line 578...
441
.noloaderblock:
578
.noloaderblock:
442
; determine default settings
579
; determine default settings
443
    mov    [.bSettingsChanged-0x10000], 0
580
    mov    [.bSettingsChanged-0x10000], 0
444
        call    calc_vmodes_table
581
        call    calc_vmodes_table
445
.preboot_gr_end:
582
.preboot_gr_end:
446
    cmp    [di+preboot_mtrr-preboot_graph], 1
583
    cmp    [di+preboot_dma_write-preboot_graph], 1
447
    adc    [di+preboot_mtrr-preboot_graph], 0
584
    adc    [di+preboot_dma_write-preboot_graph], 0
448
    cmp    [di+preboot_vrrm-preboot_graph], 1
585
    cmp    [di+preboot_vrrm-preboot_graph], 1
449
    adc    [di+preboot_vrrm-preboot_graph], 0
586
    adc    [di+preboot_vrrm-preboot_graph], 0
450
    cmp    [di+preboot_device-preboot_graph], 1
587
    cmp    [di+preboot_device-preboot_graph], 1
451
    adc    [di+preboot_device-preboot_graph], 0
588
    adc    [di+preboot_device-preboot_graph], 0
452
; notify user
589
; notify user
Line 468... Line 605...
468
    mov    si, curvideo_msg-0x10000
605
    mov    si, curvideo_msg-0x10000
469
    call    print
606
    call    print
470
        call    draw_current_vmode
607
        call    draw_current_vmode
471
    mov    si, linef-0x10000
608
    mov    si, linef-0x10000
472
    call    printplain
609
    call    printplain
473
    mov    si, mtrr_msg-0x10000
610
    mov    si, dma_msg-0x10000
474
    cmp    [preboot_mtrr-0x10000], 1
611
    cmp    [preboot_dma_write-0x10000], 1
475
    call    .say_on_off
612
    call    .say_on_off
476
    mov    si, vrrm_msg-0x10000
613
    mov    si, vrrm_msg-0x10000
477
    cmp    [preboot_vrrm-0x10000], 1
614
    cmp    [preboot_vrrm-0x10000], 1
478
    call    .say_on_off
615
    call    .say_on_off
479
    mov    si, preboot_device_msg-0x10000
616
    mov    si, preboot_device_msg-0x10000
Line 587... Line 724...
587
        jne     .lp2
724
        jne     .lp2
588
    _setcursor 10,0
725
    _setcursor 10,0
589
    jmp    .d
726
    jmp    .d
590
.change_b:
727
.change_b:
591
    _setcursor 15,0
728
    _setcursor 15,0
592
    mov    si, gr_acc-0x10000
729
    mov    si, ask_dma-0x10000
593
    call    print
730
    call    print
594
    mov    bx, '12'
731
    mov    bx, '12'
595
    call    getkey
732
    call    getkey
596
    mov    [preboot_mtrr-0x10000], al
733
    mov    [preboot_dma_write-0x10000], al
597
    _setcursor 11,0
734
    _setcursor 11,0
598
    jmp    .d
735
    jmp    .d
599
.change_c:
736
.change_c:
600
    _setcursor 15,0
737
    _setcursor 15,0
601
    mov    si, vrrmprint-0x10000
738
    mov    si, vrrmprint-0x10000
Line 620... Line 757...
620
.starttime dd ?
757
.starttime dd ?
621
.bSettingsChanged db ?
758
.bSettingsChanged db ?
622
.timer dd ?
759
.timer dd ?
623
end virtual
760
end virtual
624
	org $+0x10000
761
	org $+0x10000
625
.loader_block dd 0
762
.loader_block dd -1
626
	org $-0x10000
763
	org $-0x10000
627
.gettime:
764
.gettime:
628
    mov    ah, 0
765
    mov    ah, 0
629
    int    1Ah
766
    int    1Ah
630
    xchg    ax, cx
767
    xchg    ax, cx
Line 655... Line 792...
655
    cmp    al, 1
792
    cmp    al, 1
656
    mov    cl, 'ã'
793
    mov    cl, 'ã'
657
    jz    @f
794
    jz    @f
658
    mov    cl, 'ë'
795
    mov    cl, 'ë'
659
@@:    mov    [time_str+9-0x10000], cl
796
@@:    mov    [time_str+9-0x10000], cl
-
 
797
else if lang eq et
-
 
798
    cmp    al, 1
-
 
799
    ja     @f
-
 
800
    mov    [time_str+9-0x10000], ' '
-
 
801
    mov    [time_str+10-0x10000],' '
-
 
802
@@:
660
else
803
else
661
; wait 5/4/3/2 seconds, 1 second
804
; wait 5/4/3/2 seconds, 1 second
662
    cmp    al, 1
805
    cmp    al, 1
663
    mov    cl, 's'
806
    mov    cl, 's'
664
    ja    @f
807
    ja    @f
Line 690... Line 833...
690
    mov    si, loading_msg-0x10000
833
    mov    si, loading_msg-0x10000
691
    call    print
834
    call    print
692
    _setcursor 15,0
835
    _setcursor 15,0
693
    cmp    [.bSettingsChanged-0x10000], 0
836
    cmp    [.bSettingsChanged-0x10000], 0
694
    jz    .load
837
    jz    .load
695
    cmp    [.loader_block-0x10000], 0
838
    cmp    [.loader_block-0x10000], -1
696
    jz    .load
839
    jz    .load
697
    les    bx, [.loader_block-0x10000]
840
    les    bx, [.loader_block-0x10000]
698
    mov    eax, [es:bx+3]
841
    mov    eax, [es:bx+3]
699
    push    ds
842
    push    ds
700
    pop    es
843
    pop    es
Line 736... Line 879...
736
 
879
 
Line 737... Line 880...
737
 
880
 
738
 
881
 
Line 739... Line 882...
739
; GRAPHICS ACCELERATION
882
; GRAPHICS ACCELERATION
Line 740... Line 883...
740
 
883
 
741
        mov     al, [preboot_mtrr-0x10000]
884
        mov     al, [preboot_dma_write-0x10000]
Line 1043... Line 1186...
1043
        int     0x13
1186
        int     0x13
1044
       mov dx,0x3f2 ; floppy motor off
1187
       mov dx,0x3f2 ; floppy motor off
1045
       mov al,0
1188
       mov al,0
1046
       out dx,al
1189
       out dx,al
Line 1047... Line 1190...
1047
 
1190
 
1048
    push    es
1191
;   push    es
Line 1049... Line 1192...
1049
; PAGE TABLE
1192
; PAGE TABLE
1050
 
1193
 
1051
    push    dword [es:0x9018]
1194
;    push    dword [es:0x9018]
1052
 
1195
;
1053
        map_mem equ 64                ; amount of memory to map
1196
;        mmap_mem equ 64                ; amount of memory to map
1054
 
1197
;
1055
        push    0x6000
1198
        push    0x6000
1056
        pop    es                    ; es:di = 6000:0
1199
        pop    es                    ; es:di = 6000:0
1057
        xor     di,di
1200
;        xor     di,di
1058
        mov     cx,256*map_mem         ; Map (mapmem) M
1201
;        mov     cx,256*mmap_mem         ; Map (mapmem) M
1059
; initialize as identity mapping
1202
;; initialize as identity mapping
1060
    xor    eax, eax
1203
;        xor    eax, eax
1061
    call    pagetable_set
1204
;        call    pagetable_set
1062
 
1205
;
-
 
1206
;
-
 
1207
; 4 KB PAGE DIRECTORY
-
 
1208
;
-
 
1209
;       push    0x7F00
-
 
1210
;       pop    es                ; es:di = 7F00:0
-
 
1211
;        xor     di, di
-
 
1212
;        mov     cx, 64 / 4
-
 
1213
;        mov     eax, 0x60007            ; for 0 M
-
 
1214
;        call    pagetable_set
-
 
1215
;        xor     si,si
-
 
1216
;        mov     di,second_base_address shr 20
Line 1063... Line -...
1063
        
-
 
1064
; 4 KB PAGE DIRECTORY
-
 
1065
 
-
 
1066
    push    0x7F00
-
 
1067
    pop    es                ; es:di = 7F00:0
-
 
1068
        xor     di, di
-
 
1069
        mov     cx, 64 / 4
-
 
1070
        mov     eax, 0x60007            ; for 0 M
-
 
1071
        call    pagetable_set
-
 
1072
        xor     si,si
-
 
1073
        mov     di,second_base_address shr 20
-
 
1074
        mov     cx,64/2
1217
;        mov     cx,64/2
1075
        rep     movs word [es:di], [es:si]
1218
;        rep     movs word [es:di], [es:si]
Line 1076... Line 1219...
1076
       
1219
 
Line 1077... Line 1220...
1077
        mov     eax, 0x7F000 +8+16      ; Page directory and enable caches
1220
;        mov     eax, 0x7F000 +8+16      ; Page directory and enable caches
1078
        mov     cr3, eax
1221
;        mov     cr3, eax
1079
 
1222
 
1080
; SET GRAPHICS
1223
; SET GRAPHICS
1081
 
1224
 
1082
        pop     es
1225
;       pop     es