Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
129 mikedld 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                        ;;
3
;;  BOOTCODE.INC                                          ;;
4
;;                                                        ;;
5
;;  KolibriOS 16-bit loader,                              ;;
6
;;                        based on bootcode for MenuetOS  ;;
7
;;                                                        ;;
8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9
 
10
 
11
 
12
;==========================================================================
13
;
14
;                           16 BIT FUNCTIONS
15
;
16
;==========================================================================
17
 
18
include 'drawtext.inc'
19
 
20
putchar:
21
; in: al=character
22
    mov    ah, 0Eh
23
    mov    bh, 0
24
    int    10h
25
    ret
26
 
27
print:
28
; in: si->string
29
    mov    al, 186
30
    call    putchar
31
    mov    al, ' '
32
    call    putchar
33
 
34
printplain:
35
; in: si->string
36
    pusha
37
    lodsb
38
@@:
39
    call    putchar
40
    lodsb
41
    cmp    al, 0
42
    jnz    @b
43
    popa
44
    ret
45
 
46
; Now int 16 is used for keyboard support.
47
; This is shorter, simpler and more reliable.
48
if 0
49
getkey:      push  ecx
50
             push  edx
51
             add   ebx,0x0101
52
             xor   eax,eax
53
 
54
           gk1:
55
             in    al,0x60
56
             mov   cl,al
57
           gk0:
58
             in    al,0x60
59
             cmp   al,cl
60
             je    gk0
61
             cmp   ax,11
62
             jg    gk0
63
             gk0_1:
64
             mov   cl,al
65
 
66
;             add   al,47
67
;             mov   [ds:keyinbs-0x10000],al
68
;             mov   si,keyinbs-0x10000
69
;             call  printplain
70
 
71
           gk12:
72
             in    al,0x60
73
             cmp   al,cl
74
             je    gk12
75
             cmp   ax,240
76
             jne   gk13
77
             mov   al,cl
78
             jmp   gk14
79
           gk13:
80
             add   cl,128
81
             cmp   al,cl
82
             jne   gk1
83
             sub   al,128
84
           gk14:
85
 
86
             movzx edx,bl
87
             cmp   eax,edx
88
             jb    gk1
89
             movzx edx,bh
90
             cmp   eax,edx
91
             jg    gk1
92
             test  ebx,0x010000
93
             jnz   gk3
94
             mov   cx,0x1000
95
             mov   dx,cx
96
             add   eax,47
97
             mov   cx,ax
98
             cmp   cx,58
99
             jb    gk_nozero
100
             sub   cx,10
101
           gk_nozero:
102
             mov   [ds:keyin-0x10000],cl
103
             mov   si,keyin-0x10000
104
             call  printplain
105
           gk3:
106
             sub   eax,48
107
             pop   edx
108
             pop   ecx
109
             ret
110
end if
111
 
112
getkey:
113
; get number in range [bl,bh] (bl,bh in ['0'..'9'])
114
; in: bx=range
115
; out: ax=digit (1..9, 10 for 0)
116
    mov    ah, 0
117
    int    16h
118
    cmp    al, bl
119
    jb    getkey
120
    cmp    al, bh
121
    ja    getkey
122
    push    ax
123
    call    putchar
124
    pop    ax
125
    and    ax, 0Fh
126
    jnz    @f
127
    mov    al, 10
128
@@:
129
    ret
130
 
131
setcursor:
132
; in: dl=column, dh=row
133
    mov    ah, 2
134
    mov    bh, 0
135
    int    10h
136
    ret
137
 
138
macro _setcursor row,column
139
{
140
    mov    dx, row*256 + column
141
    call    setcursor
142
}
143
 
144
pagetable_set:
145
;eax - physical address
146
;es:di - page table
147
;ecx - number of pages to map
148
    or    al, 7
149
@@:
150
    stosd
151
    add    eax, 1000h
152
    loop    @b
153
    ret
154
 
155
		org $+0x10000
156
 
157
; table for move to extended memory (int 15h, ah=87h)
158
       movedesc:
159
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
160
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
161
 
162
        db      0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
163
        db      0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
164
 
165
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
166
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
167
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
168
        db      0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
169
        	org $-0x10000
170
include 'bootvesa.inc'
171
 
172
;=========================================================================
173
;
174
;                           16 BIT CODE
175
;
176
;=========================================================================
177
 
178
 
179
start_of_code:
180
    cld
181
; \begin{diamond}[02.12.2005]
182
    cmp    ax, 'KL'
183
    jnz    @f
184
    mov    word [cs:cfgmanager.loader_block-0x10000], si
185
    mov    word [cs:cfgmanager.loader_block+2-0x10000], ds
186
@@:
187
; \end{diamond}[02.12.2005]
188
 
189
; set up stack
190
    mov    ax, 3000h
191
    mov    ss, ax
192
    mov    sp, 0EC00h
193
; set up segment registers
194
    push    cs
195
    pop    ds
196
    push    cs
197
    pop    es
198
 
199
; set videomode
200
    mov    ax, 3
201
        int  0x10
202
 
203
if lang eq ru
204
 ; Load & set russian VGA font (RU.INC)
205
        mov  bp,RU_FNT1-10000h   ; RU_FNT1 - First part
206
          mov  bx,1000h            ; 768 bytes
207
          mov  cx,30h              ; 48 symbols
208
          mov  dx,80h              ; 128 - position of first symbol
209
        mov  ax,1100h
210
          int  10h
211
 
212
        mov  bp,RU_FNT2-10000h   ; RU_FNT2 -Second part
213
        mov  bx,1000h            ; 512 bytes
214
        mov  cx,20h              ; 32 symbols
215
        mov  dx,0E0h             ; 224 - position of first symbol
216
        mov  ax,1100h
217
          int  10h
218
 ; End set VGA russian font
219
end if
220
 
221
; draw frames
222
    push    0xb800
223
    pop    es
224
    xor    di, di
225
;        mov  si,d80x25-0x10000
226
;        mov  cx,80*25
227
;        mov  ah,1*16+15
228
;       dfl1:
229
;        lodsb
230
;        stosw
231
;        loop dfl1
232
    mov    ah, 1*16+15
233
; draw top
234
    mov    si, d80x25_top - 0x10000
235
    mov    cx, d80x25_top_num * 80
236
@@:
237
    lodsb
238
    stosw
239
    loop    @b
240
; draw spaces
241
    mov    si, space_msg - 0x10000
242
    mov    cx, 25 - d80x25_top_num - d80x25_bottom_num
243
dfl1:
244
    push    cx
245
    push    si
246
    mov    cx, 80
247
@@:
248
    lodsb
249
    stosw
250
    loop    @b
251
    pop    si
252
    pop    cx
253
    loop    dfl1
254
; draw bottom
255
    mov    si, d80x25_bottom - 0x10000
256
    mov    cx, d80x25_bottom_num * 80
257
@@:
258
    lodsb
259
    stosw
260
    loop    @b
261
 
262
    mov    byte [space_msg-0x10000+80], 0    ; now space_msg is null terminated
263
 
264
    _setcursor d80x25_top_num,0
265
 
266
 
267
; TEST FOR 386+
268
 
269
    mov    bx, 0x4000
270
        pushf
271
        pop     ax
272
        mov     dx,ax
273
        xor     ax,bx
274
        push    ax
275
        popf
276
        pushf
277
        pop     ax
278
        and     ax,bx
279
        and     dx,bx
280
        cmp     ax,dx
281
        jnz     cpugood
282
        mov     si,not386-0x10000
283
sayerr:
284
        call    print
285
        jmp     $
286
     cpugood:
287
 
288
; set up esp
289
    movzx    esp, sp
290
 
291
; FLUSH 8042 KEYBOARD CONTROLLER
292
 
293
;// mike.dld [
294
 ;       mov     al,0xED
295
 ;       out     0x60,al
296
 ;       or      cx,-1
297
 ;     @@:
298
 ;       in      al,0x64
299
 ;       test    al,2
300
 ;       jz      @f
301
 ;       loop    @b
302
 ;     @@:
303
 ;       mov     al,0
304
 ;       out     0x60,al
305
 ;       or      cx,-1
306
 ;     @@:
307
 ;       in      al,0x64
308
 ;       test    al,2
309
 ;       jz      @f
310
 ;       loop    @b
311
 ;     @@:
312
;// mike.dld ]
313
 
314
;       mov     ecx,10000
315
;      fl1:
316
;       in      al,0x64
317
;       loop    fl1
318
;       test    al,1
319
;       jz      fl2
320
;       in      al,0x60
321
;       jmp     fl1
322
;      fl2:
323
 
324
;****************************************************************
325
; The function is modified Mario79
326
;*****************************************************************
327
; wait_kbd:        ; variant 1
328
;       mov      cx,2500h  ;задержка порядка 10 мсек
329
; test_kbd:
330
;       in       al,64h    ;читаем состояние клавиатуры
331
;       test     al,2      ;проверка бита готовности
332
;       loopnz   test_kbd
333
 
334
    mov   al,0xf6         ; Сброс клавиатуры, разрешить сканирование
335
    out   0x60,al
336
    xor   cx,cx
337
wait_loop:       ; variant 2
338
; reading state of port of 8042 controller
339
        in      al,64h
340
        and     al,00000010b  ; ready flag
341
; wait until 8042 controller is ready
342
        loopnz  wait_loop
343
 
344
; --------------- APM ---------------------
345
    push    0
346
    pop    es
347
    mov    word [es : 0x9044], 0        ; ver = 0.0 (APM not found)
348
    mov    ax, 0x5300
349
    xor    bx, bx
350
    int    0x15
351
    jc    apm_end                ; APM not found
352
    test    cx, 2
353
    jz    apm_end                ; APM 32-bit protected-mode interface not supported
354
    mov    [es : 0x9044], ax        ; Save APM Version
355
    mov    [es : 0x9046], cx        ; Save APM flags
356
 
357
    ; Write APM ver ----
358
    and    ax, 0xf0f
359
    add    ax, '00'
360
    mov    si, msg_apm - 0x10000
361
    mov    [si + 5], ah
362
    mov    [si + 7], al
363
    _setcursor 0, 3
364
    call    printplain
365
    _setcursor d80x25_top_num,0
366
    ; ------------------
367
 
368
    mov    ax, 0x5304            ; Disconnect interface
369
    xor    bx, bx
370
    int    0x15
371
    mov    ax, 0x5303            ; Connect 32 bit mode interface
372
    xor    bx, bx
373
    int    0x15
374
    ; init selectors
375
    movzx    eax, ax ; real-mode segment base address of protected-mode 32-bit code segment
376
    shl    eax, 4
377
    mov    [apm_code_32 - 0x10000 + 2], ax
378
    shr    eax, 16
379
    mov    [apm_code_32 - 0x10000 + 4], al
380
    movzx    ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment
381
    shl    ecx, 4
382
    mov    [apm_code_16 - 0x10000 + 2], cx
383
    shr    ecx, 16
384
    mov    [apm_code_16 - 0x10000 + 4], cl
385
    movzx    edx, dx ; real-mode segment base address of protected-mode 16-bit data segment
386
    shl    edx, 4
387
    mov    [apm_data_16 - 0x10000 + 2], dx
388
    shr    edx, 16
389
    mov    [apm_data_16 - 0x10000 + 4], dl
390
    mov    [es : 0x9040], ebx              ; offset of APM entry point
391
apm_end:
392
; -----------------------------------------
393
 
394
; DISPLAY VESA INFORMATION
395
 
396
        call    print_vesa_info
397
 
398
; \begin{diamond}[30.11.2005]
399
cfgmanager:
400
; settings:
401
; a) preboot_graph = graphical mode
402
;    preboot_gprobe = probe this mode?
403
; b) preboot_mtrr = use hardware acceleration?
404
; c) preboot_vrrm = use VRR?
405
; d) preboot_device = from what boot?
406
    mov    di, preboot_graph-0x10000
407
; check bootloader block
408
    cmp    [.loader_block-0x10000], 0
409
    jz    .noloaderblock
410
    les    bx, [.loader_block-0x10000]
411
    cmp    byte [es:bx], 1
412
    mov    si, loader_block_error-0x10000
413
    jnz    sayerr
414
    test    byte [es:bx+1], 1
415
    jz    @f
416
; image in memory present
417
    cmp    [di+preboot_device-preboot_graph], 0
418
    jnz    @f
419
    mov    [di+preboot_device-preboot_graph], 3
420
@@:
421
.noloaderblock:
422
; determine default settings
423
    mov    [.bSettingsChanged-0x10000], 0
424
        call    calc_vmodes_table
425
.preboot_gr_end:
426
    cmp    [di+preboot_mtrr-preboot_graph], 1
427
    adc    [di+preboot_mtrr-preboot_graph], 0
428
    cmp    [di+preboot_vrrm-preboot_graph], 1
429
    adc    [di+preboot_vrrm-preboot_graph], 0
430
    cmp    [di+preboot_device-preboot_graph], 1
431
    adc    [di+preboot_device-preboot_graph], 0
432
; notify user
433
    mov    si, linef-0x10000
434
    call    print
435
    mov    si, start_msg-0x10000
436
    call    print
437
    mov    si, time_msg-0x10000
438
    call    print
439
; get start time
440
    call    .gettime
441
    mov    [.starttime-0x10000], eax
442
    mov    word [.timer-0x10000], .newtimer
443
    mov    word [.timer-0x10000+2], cs
444
.printcfg:
445
    _setcursor 9,0
446
    mov    si, current_cfg_msg-0x10000
447
    call    print
448
    mov    si, curvideo_msg-0x10000
449
    call    print
450
        call    draw_current_vmode
451
    mov    si, linef-0x10000
452
    call    printplain
453
    mov    si, mtrr_msg-0x10000
454
    cmp    [preboot_mtrr-0x10000], 1
455
    call    .say_on_off
456
    mov    si, vrrm_msg-0x10000
457
    cmp    [preboot_vrrm-0x10000], 1
458
    call    .say_on_off
459
    mov    si, preboot_device_msg-0x10000
460
    call    print
461
    mov    al, [preboot_device-0x10000]
462
    and    eax, 3
463
    mov    si, [preboot_device_msgs-0x10000+eax*2]
464
    call    printplain
465
.wait:
466
    _setcursor 25,0        ; out of screen
467
; set timer interrupt handler
468
    cli
469
    push    0
470
    pop    es
471
    mov    eax, [es:8*4]
472
    mov    [.oldtimer-0x10000], eax
473
    mov    eax, [.timer-0x10000]
474
    mov    [es:8*4], eax
475
    sti
476
; wait for keypressed
477
    mov    ah, 0
478
    int    16h
479
    push    ax
480
; restore timer interrupt
481
    push    0
482
    pop    es
483
    mov    eax, [.oldtimer-0x10000]
484
    mov    [es:8*4], eax
485
    mov    [.timer-0x10000], eax
486
        _setcursor (d80x25_top_num+3),0
487
    mov    si, space_msg-0x10000
488
    call    printplain
489
    pop    ax
490
; switch on key
491
    cmp    al, 13
492
    jz    .continue
493
    or    al, 20h
494
    cmp    al, 'a'
495
    jz    .change_a
496
    cmp    al, 'b'
497
    jz    .change_b
498
    cmp    al, 'c'
499
    jz    .change_c
500
    cmp    al, 'd'
501
    jnz    .wait
502
    _setcursor 15,0
503
    mov     si,bdev-0x10000
504
    call    print
505
    mov     bx,'13'
506
    call    getkey
507
    mov    [preboot_device-0x10000], al
508
    _setcursor 13,0
509
.d:
510
    mov    [.bSettingsChanged-0x10000], 1
511
    mov    si, space_msg-0x10000
512
    call    printplain
513
    _setcursor 15,0
514
    mov    cx, 6
515
@@:
516
    call    printplain
517
    loop    @b
518
    jmp    .printcfg
519
.change_a:
520
  .lp0: call    draw_vmodes_table
521
  .lp1: mov     al,[vm_row]
522
        sub     al,[ln_top]
523
        jge     @f
524
        dec     [ln_top]
525
        jmp     .lp0
526
    @@: cmp     al,[ln_num]
527
        jl      .lp2
528
        inc     [ln_top]
529
        jmp     .lp0
530
  .lp2: mov     cx,0x1A1B
531
        call    draw_vmodes_table_cursor
532
        mov     ax,0x0000
533
        int     0x16
534
        push    ax
535
        mov     cx,'  ';0x1A1B
536
        call    draw_vmodes_table_cursor
537
        pop     ax
538
        cmp     ah,0x48;x,0x48E0               ; up
539
        jne     @f
540
        dec     [vm_row]
541
        jge     .lp1
542
        mov     [vm_row],0
543
        jmp     .lp1
544
    @@: cmp     ah,0x50;x,0x50E0               ; down
545
        jne     @f
546
        inc     [vm_row]
547
        mov     al,[ln_cnt]
548
        dec     al
549
        cmp     [vm_row],al
550
        jle     .lp1
551
        mov     [vm_row],al
552
        jmp     .lp1
553
    @@: cmp     ah,0x4B;x,0x4BE0               ; left
554
        jne     @f
555
        dec     [vm_col]
556
        jge     .lp1
557
        mov     [vm_col],0
558
        jmp     .lp1
559
    @@: cmp     ah,0x4D;x,0x4DE0               ; right
560
        jne     @f
561
        inc     [vm_col]
562
        cmp     [vm_col],5
563
        jle     .lp1
564
        mov     [vm_col],5
565
        jmp     .lp1
566
    @@: cmp     al,0x0D;x,0x1C0D               ; enter
567
        jne     .lp2
568
    _setcursor 10,0
569
    jmp    .d
570
.change_b:
571
    _setcursor 15,0
572
    mov    si, gr_acc-0x10000
573
    call    print
574
    mov    bx, '12'
575
    call    getkey
576
    mov    [preboot_mtrr-0x10000], al
577
    _setcursor 11,0
578
    jmp    .d
579
.change_c:
580
    _setcursor 15,0
581
    mov    si, vrrmprint-0x10000
582
    call    print
583
    mov    bx, '12'
584
    call    getkey
585
    mov    [preboot_vrrm-0x10000], al
586
    _setcursor 12,0
587
    jmp    .d
588
.say_on_off:
589
    pushf
590
    call    print
591
    mov    si, on_msg-0x10000
592
    popf
593
    jz    @f
594
    mov    si, off_msg-0x10000
595
@@:    call    printplain
596
    ret
597
; novesa and vervesa strings are not used at the moment of executing this code
598
virtual at novesa
599
.oldtimer dd ?
600
.starttime dd ?
601
.bSettingsChanged db ?
602
.timer dd ?
603
end virtual
604
	org $+0x10000
605
.loader_block dd 0
606
	org $-0x10000
607
.gettime:
608
    mov    ah, 0
609
    int    1Ah
610
    xchg    ax, cx
611
    shl    eax, 10h
612
    xchg    ax, dx
613
    ret
614
.newtimer:
615
    push    ds
616
    push    cs
617
    pop    ds
618
    pushf
619
    call    [.oldtimer-0x10000]
620
    pushad
621
    call    .gettime
622
    sub    eax, [.starttime-0x10000]
623
    sub    ax, 18*5
624
    jae    .timergo
625
    neg    ax
626
    add    ax, 18-1
627
    mov    bx, 18
628
    xor    dx, dx
629
    div    bx
630
if lang eq ru
631
; Ї®¤®¦¤ЁвҐ 5 ᥪ㭤, 4/3/2 ᥪ㭤л, 1 ᥪ㭤г
632
    cmp    al, 5
633
    mov    cl, ' '
634
    jae    @f
635
    cmp    al, 1
636
    mov    cl, 'г'
637
    jz    @f
638
    mov    cl, 'л'
639
@@:    mov    [time_str+9-0x10000], cl
640
else
641
; wait 5/4/3/2 seconds, 1 second
642
    cmp    al, 1
643
    mov    cl, 's'
644
    ja    @f
645
    mov    cl, ' '
646
@@:    mov    [time_str+9-0x10000], cl
647
end if
648
    add    al, '0'
649
    mov    [time_str+1-0x10000], al
650
    mov    si, time_msg-0x10000
651
        _setcursor (d80x25_top_num+3),0
652
    call    print
653
    _setcursor 25,0
654
    popad
655
    pop    ds
656
    iret
657
.timergo:
658
    push    0
659
    pop    es
660
    mov    eax, [.oldtimer-0x10000]
661
    mov    [es:8*4], eax
662
    mov    sp, 0EC00h
663
.continue:
664
    sti
665
    _setcursor 6,0
666
    mov    si, space_msg-0x10000
667
    call    printplain
668
    call    printplain
669
    _setcursor 6,0
670
    mov    si, loading_msg-0x10000
671
    call    print
672
    _setcursor 15,0
673
    cmp    [.bSettingsChanged-0x10000], 0
674
    jz    .load
675
    cmp    [.loader_block-0x10000], 0
676
    jz    .load
677
    les    bx, [.loader_block-0x10000]
678
    mov    eax, [es:bx+3]
679
    push    ds
680
    pop    es
681
    test    eax, eax
682
    jz    .load
683
    push    eax
684
    mov    si, save_quest-0x10000
685
    call    print
686
.waityn:
687
    mov    ah, 0
688
    int    16h
689
    or    al, 20h
690
    cmp    al, 'n'
691
    jz    .loadc
692
    cmp    al, 'y'
693
    jnz    .waityn
694
    call    putchar
695
    mov    byte [space_msg-0x10000+80], 186
696
    pop    eax
697
    push    cs
698
    push    .cont
699
    push    eax
700
    retf
701
.loadc:
702
    pop    eax
703
.cont:
704
    push    cs
705
    pop    ds
706
    mov    si, space_msg-0x10000
707
    mov    byte [si+80], 0
708
    _setcursor 15,0
709
    call    printplain
710
    _setcursor 15,0
711
.load:
712
; \end{diamond}[02.12.2005]
713
 
714
; ASK GRAPHICS MODE
715
        call    set_vmode
716
 
717
 
718
 
719
; GRAPHICS ACCELERATION
720
 
721
        mov     al, [preboot_mtrr-0x10000]
722
        mov     [es:0x901C],al
723
 
724
; VRR_M USE
725
 
726
        mov     al,[preboot_vrrm-0x10000]
727
        mov     [es:0x9030],al
728
 
729
 
730
; MEMORY MODEL
731
 
732
;        movzx   eax,byte [es:preboot_memory-0x10000]
733
;        cmp     eax,0
734
;        jne     pre_mem
735
;;;;;;;;;;;;;;;;;;;;;;;;;
736
; mario79 - memory size ;
737
;;;;;;;;;;;;;;;;;;;;;;;;;
738
;           mov ax,0E801h
739
;;;           xor bx,bx    ; thanks to Alexei for bugfix [18.07.2004]
740
;           xor cx, cx
741
;           xor dx, dx
742
;           int 0x15
743
;           movzx ebx, dx ;bx
744
;           movzx eax, cx ;ax
745
;           shl   ebx,6   ; перевод в килобайты (x64)
746
;           add   eax,ebx
747
;           add eax, 1000h ;440h
748
;           cmp eax,40000h ; 256?
749
;           jge mem_256_z
750
;           cmp eax,20000h ; 128?
751
;           jge mem_128_z
752
;           cmp eax,10000h ; 64?
753
;           jge mem_64_z
754
;           cmp eax,8000h ; 32?
755
;           jge mem_32_z
756
;           jmp mem_16_z
757
;
758
;mem_256_z: mov     si,memokz256-0x10000
759
;           call    printplain
760
;           mov eax,5
761
;           jmp pre_mem
762
;mem_128_z: mov     si,memokz128-0x10000
763
;           call    printplain
764
;           mov eax,4
765
;           jmp pre_mem
766
;mem_64_z:  mov     si,memokz64-0x10000
767
;           call    printplain
768
;           mov eax,3
769
;           jmp pre_mem
770
;mem_32_z:  mov     si,memokz32-0x10000
771
;           call    printplain
772
;           mov eax,2
773
;           jmp pre_mem
774
;mem_16_z:  mov     si,memokz16-0x10000
775
;           call    printplain
776
;           mov eax,1
777
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
778
;      pre_mem:
779
;        push    word 0x0000
780
;        pop     es
781
;        mov     [es:0x9030],al
782
;        push    word 0x1000
783
;        pop     es
784
;        mov     si,linef-0x10000
785
;        call    printplain
786
 
787
 
788
 
789
 
790
; DIRECT WRITE TO LFB, PAGING DISABLED
791
 
792
;        movzx   eax,byte [es:preboot_lfb-0x10000]
793
;        mov     eax,1                             ; paging disabled
794
;        cmp     eax,0
795
;        jne     pre_lfb
796
;        mov     si,gr_direct-0x10000
797
;        call    printplain
798
;        mov     ebx,'12'
799
;        call    getkey
800
;      pre_lfb:
801
;        push    word 0x0000
802
;        pop     es
803
;        mov     [es:0x901E],al
804
;        mov     ax,0x1000
805
;        mov     es,ax
806
;        mov     si,linef-0x10000
807
;        call    printplain
808
        mov     [es:0x901E],byte 1
809
 
810
 
811
 
812
; BOOT DEVICE
813
 
814
    mov    al, [preboot_device-0x10000]
815
        dec     al
816
        mov     [boot_dev-0x10000],al
817
 
818
; READ DISKETTE TO MEMORY
819
 
820
;        cmp     [boot_dev-0x10000],0
821
        jne     no_sys_on_floppy
822
        mov     si,diskload-0x10000
823
        call    print
824
        xor    ax, ax            ; reset drive
825
        xor    dx, dx
826
        int     0x13
827
        mov     cx,0x0001               ; startcyl,startsector
828
        xor    dx, dx            ; starthead,drive
829
        push    word 80*2               ; read no of sect
830
       reads:
831
        pusha
832
        xor     si,si
833
       newread:
834
        mov     bx,0xa000               ; es:bx -> data area
835
        mov     ax,0x0200+18            ; read, no of sectors to read
836
        int     0x13
837
        test    ah, ah
838
        jz      goodread
839
        inc    si
840
        cmp     si,10
841
        jnz     newread
842
        mov     si,badsect-0x10000
843
sayerr_plain:
844
        call    printplain
845
        jmp     $
846
       goodread:
847
        ; move -> 1mb
848
        mov     si,movedesc-0x10000
849
        push    es
850
        push    ds
851
        pop     es
852
        mov     cx,256*18
853
        mov     ah,0x87
854
        int     0x15
855
        pop    es
856
 
857
        test    ah,ah                  ; was the move successfull ?
858
        je      goodmove
859
        mov     dx,0x3f2              ; floppy motor off
860
        mov     al,0
861
        out     dx,al
862
        mov     si,memmovefailed-0x10000
863
        jmp    sayerr_plain
864
      goodmove:
865
 
866
    add    dword [movedesc-0x10000+0x18+2], 512*18
867
        popa
868
        inc     dh
869
        cmp     dh,2
870
        jnz     bb2
871
        mov     dh,0
872
        inc     ch
873
        pusha                        ; print prosentage
874
        mov     si,pros-0x10000
875
    shr    ch, 2
876
    mov    al, '5'
877
    test    ch, 1
878
    jnz    @f
879
    mov    al, '0'
880
@@:
881
    mov    [si+1], al
882
    shr    ch, 1
883
    add    ch, '0'
884
    mov    [si], ch
885
        call    printplain
886
        popa
887
       bb2:
888
        pop     ax
889
        dec     ax
890
        push    ax
891
        jnz     reads
892
       readdone:
893
        pop     ax
894
        mov     si,backspace2-0x10000
895
        call    printplain
896
        mov     si,okt-0x10000
897
        call    printplain
898
       no_sys_on_floppy:
899
        xor    ax, ax        ; reset drive
900
        xor    dx, dx
901
        int     0x13
902
       mov dx,0x3f2 ; floppy motor off
903
       mov al,0
904
       out dx,al
905
 
906
    push    es
907
; PAGE TABLE
908
 
909
    push    dword [es:0x9018]
910
 
911
        map_mem equ 64                ; amount of memory to map
912
 
913
        push    0x6000
914
        pop    es                    ; es:di = 6000:0
915
        xor     di,di
916
        mov     cx,256*map_mem         ; Map (mapmem) M
917
; initialize as identity mapping
918
    xor    eax, eax
919
    call    pagetable_set
920
 
921
 
922
; 4 KB PAGE DIRECTORY
923
 
924
    push    0x7F00
925
    pop    es                ; es:di = 7F00:0
926
        xor     di, di
927
        mov     cx, 64 / 4
928
        mov     eax, 0x60007            ; for 0 M
929
        call    pagetable_set
930
        xor     si,si
931
        mov     di,second_base_address shr 20
932
        mov     cx,64/2
933
        rep     movs word [es:di], [es:si]
934
 
935
        mov     eax, 0x7F000 +8+16      ; Page directory and enable caches
936
        mov     cr3, eax
937
 
938
; SET GRAPHICS
939
 
940
        pop     es
941
        push    0
942
    pop    es
943
        mov     ax,[es:0x9008]        ; vga & 320x200
944
        mov    bx, ax
945
        cmp     ax,0x13
946
        je      setgr
947
        cmp     ax,0x12
948
        je      setgr
949
        mov     ax,0x4f02            ; Vesa
950
       setgr:
951
        int     0x10
952
        test    ah,ah
953
        mov    si, fatalsel-0x10000
954
        jnz    sayerr
955
; set mode 0x12 graphics registers:
956
        cmp     bx,0x12
957
        jne     gmok2
958
 
959
        mov     al,0x05
960
        mov     dx,0x03ce
961
        push    dx
962
        out     dx,al      ; select GDC mode register
963
        mov     al,0x02
964
        inc    dx
965
        out     dx,al      ; set write mode 2
966
 
967
        mov     al,0x02
968
        mov     dx,0x03c4
969
        out     dx,al      ; select VGA sequencer map mask register
970
        mov     al,0x0f
971
        inc    dx
972
        out     dx,al      ; set mask for all planes 0-3
973
 
974
        mov     al,0x08
975
        pop    dx
976
        out     dx,al      ; select GDC bit mask register
977
                           ; for writes to 0x03cf
978
 
979
       gmok2:
980
        push    ds
981
        pop    es