Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ha | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; BOOTCODE.INC ;; |
||
4 | ;; ;; |
||
5 | ;; 16 bit bootcode for MenuetOS ;; |
||
6 | ;; ;; |
||
7 | ;; Copyright 2002 Ville Turjanmaa ;; |
||
8 | ;; ;; |
||
9 | ;; See file COPYING for details ;; |
||
10 | ;; ;; |
||
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
12 | |||
13 | |||
14 | |||
15 | ;========================================================================== |
||
16 | ; |
||
17 | ; 16 BIT FUNCTIONS |
||
18 | ; |
||
19 | ;========================================================================== |
||
20 | |||
21 | print: push si |
||
22 | mov si,leftpr-0x10000 |
||
23 | call printplain |
||
24 | pop si |
||
25 | |||
26 | printplain: pusha |
||
27 | mov dx,0x1000 |
||
28 | mov es,dx |
||
29 | cmp byte [es:display_atboot-0x10000],2 |
||
30 | je printplain_exit |
||
31 | mov ds,dx |
||
32 | cld |
||
33 | lodsb |
||
34 | prpl1: |
||
35 | mov ah,0xe |
||
36 | xor bh,bh |
||
37 | int 0x10 |
||
38 | lodsb |
||
39 | cmp al,0 |
||
40 | jne prpl1 |
||
41 | printplain_exit: |
||
42 | popa |
||
43 | ret |
||
44 | |||
45 | setbase1000: push ax |
||
46 | mov ax,0x1000 |
||
47 | mov es,ax |
||
48 | mov ds,ax |
||
49 | pop ax |
||
50 | ret |
||
51 | |||
52 | getkey: push ecx |
||
53 | push edx |
||
54 | add ebx,0x0101 |
||
55 | xor eax,eax |
||
56 | |||
57 | gk1: |
||
58 | in al,0x60 |
||
59 | mov cl,al |
||
60 | gk0: |
||
61 | in al,0x60 |
||
62 | cmp al,cl |
||
63 | je gk0 |
||
64 | cmp ax,11 |
||
65 | jg gk0 |
||
66 | gk0_1: |
||
67 | mov cl,al |
||
68 | |||
69 | ; add al,47 |
||
70 | ; mov [ds:keyinbs-0x10000],al |
||
71 | ; mov si,keyinbs-0x10000 |
||
72 | ; call printplain |
||
73 | |||
74 | gk12: |
||
75 | in al,0x60 |
||
76 | cmp al,cl |
||
77 | je gk12 |
||
78 | cmp ax,240 |
||
79 | jne gk13 |
||
80 | mov al,cl |
||
81 | jmp gk14 |
||
82 | gk13: |
||
83 | add cl,128 |
||
84 | cmp al,cl |
||
85 | jne gk1 |
||
86 | sub al,128 |
||
87 | gk14: |
||
88 | |||
89 | movzx edx,bl |
||
90 | cmp eax,edx |
||
91 | jb gk1 |
||
92 | movzx edx,bh |
||
93 | cmp eax,edx |
||
94 | jg gk1 |
||
95 | test ebx,0x010000 |
||
96 | jnz gk3 |
||
97 | mov cx,0x1000 |
||
98 | mov dx,cx |
||
99 | add eax,47 |
||
100 | mov cx,ax |
||
101 | cmp cx,58 |
||
102 | jb gk_nozero |
||
103 | sub cx,10 |
||
104 | gk_nozero: |
||
105 | mov [ds:keyin-0x10000],cl |
||
106 | mov si,keyin-0x10000 |
||
107 | call printplain |
||
108 | gk3: |
||
109 | sub eax,48 |
||
110 | pop edx |
||
111 | pop ecx |
||
112 | ret |
||
113 | |||
114 | |||
115 | ;========================================================================= |
||
116 | ; |
||
117 | ; 16 BIT CODE |
||
118 | ; |
||
119 | ;========================================================================= |
||
120 | |||
121 | |||
122 | start_of_code: |
||
123 | |||
124 | ; RESET 16 BIT SELECTORS/REGISTERS/STACK |
||
125 | |||
126 | mov ax,0x1000 |
||
127 | mov es,ax |
||
128 | mov ds,ax |
||
129 | |||
130 | mov ax,0x2000 |
||
131 | mov ss,ax |
||
132 | mov sp,0xffff |
||
133 | |||
134 | xor ax,ax |
||
135 | xor bx,bx |
||
136 | xor cx,cx |
||
137 | xor dx,dx |
||
138 | xor si,si |
||
139 | xor di,di |
||
140 | xor bp,bp |
||
141 | |||
142 | |||
143 | |||
144 | ; DRAW FRAMES |
||
145 | |||
146 | call setbase1000 |
||
147 | |||
148 | cmp byte [es:display_atboot-0x10000],2 |
||
149 | je no_mode_atboot |
||
150 | |||
151 | mov ax,0x0003 |
||
152 | mov bx,0x0000 |
||
153 | mov dx,0x0000 |
||
154 | int 0x10 |
||
155 | |||
156 | no_mode_atboot: |
||
157 | |||
158 | ; Load & set russian VGA font (RU.INC) |
||
159 | mov bp,RU_FNT1-10000h ; RU_FNT1 - First part |
||
160 | mov bx,1000h ; 768 bytes |
||
161 | mov cx,30h ; 48 symbols |
||
162 | mov dx,80h ; 128 - position of first symbol |
||
163 | mov ax,1100h |
||
164 | push cs |
||
165 | pop es |
||
166 | int 10h |
||
167 | |||
168 | mov bp,RU_FNT2-10000h ; RU_FNT2 -Second part |
||
169 | mov bx,1000h ; 512 bytes |
||
170 | mov cx,20h ; 32 symbols |
||
171 | mov dx,0E0h ; 224 - position of first symbol |
||
172 | mov ax,1100h |
||
173 | push cs |
||
174 | pop es |
||
175 | int 10h |
||
176 | ; End set VGA russian font |
||
177 | |||
178 | call setbase1000 |
||
179 | mov ax,0xb800 |
||
180 | mov es,ax |
||
181 | mov di,0 |
||
182 | mov si,d80x25-0x10000 |
||
183 | mov cx,80*25 |
||
184 | mov ah,1*16+15 |
||
185 | dfl1: |
||
186 | cld |
||
187 | lodsb |
||
188 | stosw |
||
189 | loop dfl1 |
||
190 | |||
191 | call setbase1000 |
||
192 | |||
193 | |||
194 | ; SAY HI TO USER |
||
195 | |||
196 | mov si,linef2-0x10000 |
||
197 | call printplain |
||
198 | mov si,version-0x10000 |
||
199 | call print |
||
200 | |||
201 | |||
202 | ; TEST FOR 386+ |
||
203 | |||
204 | pushf |
||
205 | pop ax |
||
206 | mov dx,ax |
||
207 | xor ax,0x4000 |
||
208 | push ax |
||
209 | popf |
||
210 | pushf |
||
211 | pop ax |
||
212 | and ax,0x4000 |
||
213 | and dx,0x4000 |
||
214 | cmp ax,dx |
||
215 | jnz cpugood |
||
216 | mov si,not386-0x10000 |
||
217 | call print |
||
218 | jmp $ |
||
219 | cpugood: |
||
220 | |||
221 | ; RESET 32 BIT SELECTORS/REGISTERS/SELECTORS |
||
222 | |||
223 | mov ax,0x1000 |
||
224 | mov es,ax |
||
225 | mov ds,ax |
||
226 | |||
227 | mov ax,0x2000 |
||
228 | mov ss,ax |
||
229 | mov esp,0xffff |
||
230 | |||
231 | xor eax,eax |
||
232 | xor ebx,ebx |
||
233 | xor ecx,ecx |
||
234 | xor edx,edx |
||
235 | xor esi,esi |
||
236 | xor edi,edi |
||
237 | xor ebp,ebp |
||
238 | |||
239 | |||
240 | |||
241 | ; FLUSH 8042 KEYBOARD CONTROLLER |
||
242 | |||
243 | ;// mike.dld [ |
||
244 | ; mov al,0xED |
||
245 | ; out 0x60,al |
||
246 | ; or cx,-1 |
||
247 | ; @@: |
||
248 | ; in al,0x64 |
||
249 | ; test al,2 |
||
250 | ; jz @f |
||
251 | ; loop @b |
||
252 | ; @@: |
||
253 | ; mov al,0 |
||
254 | ; out 0x60,al |
||
255 | ; or cx,-1 |
||
256 | ; @@: |
||
257 | ; in al,0x64 |
||
258 | ; test al,2 |
||
259 | ; jz @f |
||
260 | ; loop @b |
||
261 | ; @@: |
||
262 | ;// mike.dld ] |
||
263 | |||
264 | ; mov ecx,10000 |
||
265 | ; fl1: |
||
266 | ; in al,0x64 |
||
267 | ; loop fl1 |
||
268 | ; test al,1 |
||
269 | ; jz fl2 |
||
270 | ; in al,0x60 |
||
271 | ; jmp fl1 |
||
272 | ; fl2: |
||
273 | |||
274 | ;**************************************************************** |
||
275 | ; The function is modified Mario79 |
||
276 | ;***************************************************************** |
||
277 | ; wait_kbd: ; variant 1 |
||
278 | ; mov cx,2500h ;задержка порядка 10 мсек |
||
279 | ; test_kbd: |
||
280 | ; in al,64h ;читаем состояние клавиатуры |
||
281 | ; test al,2 ;проверка бита готовности |
||
282 | ; loopnz test_kbd |
||
283 | |||
284 | mov al,0xf6 ; Сброс клавиатуры, разрешить сканирование |
||
285 | out 0x60,al |
||
286 | mov cx,0 |
||
287 | wait_loop: ; variant 2 |
||
288 | ; reading state of port of 8042 controller |
||
289 | in al,64h |
||
290 | and al,00000010b ; ready flag |
||
291 | ; wait until 8042 controller is ready |
||
292 | loopnz wait_loop |
||
293 | |||
294 | ; DISPLAY VESA INFORMATION |
||
295 | |||
296 | mov ax,0x0 |
||
297 | mov es,ax |
||
298 | mov ax,0x4f00 |
||
299 | mov di,0xa000 |
||
300 | int 0x10 |
||
301 | cmp ax,0x004f |
||
302 | je vesaok2 |
||
303 | mov dx,0x1000 |
||
304 | mov es,dx |
||
305 | mov si,novesa-0x10000 |
||
306 | call print |
||
307 | mov ax,16 |
||
308 | jmp novesafound |
||
309 | vesaok2: |
||
310 | mov ax,[es:di+4] |
||
311 | mov dx,ax |
||
312 | add ax,'0'*256+'0' |
||
313 | push word 0x1000 |
||
314 | pop es |
||
315 | mov [es:vervesa+vervesa_off-0x10000], ah |
||
316 | mov [es:vervesa+vervesa_off+2-0x10000], al |
||
317 | ; ivan 24/11/2004 begin |
||
318 | ;push ax |
||
319 | ; ivan 24/11/2004 end |
||
320 | mov si,vervesa-0x10000 |
||
321 | call print |
||
322 | novesafound: |
||
323 | call setbase1000 |
||
324 | ; ivan 24/11/2004 begin |
||
325 | ;pop bx |
||
326 | ; ivan 24/11/2004 end |
||
327 | |||
328 | |||
329 | ; ASK GRAPHICS MODE |
||
330 | |||
331 | movzx eax,byte [es:preboot_graph-0x10000] |
||
332 | cmp eax,0 |
||
333 | jne pre_graph |
||
334 | mov si,gr_mode-0x10000 |
||
335 | call printplain |
||
336 | gml0: |
||
337 | mov ebx,0x0A01 |
||
338 | call getkey |
||
339 | pre_graph: |
||
340 | cmp eax,1 |
||
341 | jl sgml1 |
||
342 | cmp eax,8 |
||
343 | jg sgml1 |
||
344 | mov si,ax |
||
345 | sub si,1 |
||
346 | shl si,4 |
||
347 | add si,gr_table-0x10000 |
||
348 | mov bx,[es:si+0] |
||
349 | mov cx,[es:si+4] |
||
350 | mov dx,[es:si+8] |
||
351 | jmp gml10 |
||
352 | sgml1: |
||
353 | cmp al,9 |
||
354 | jnz gml00 |
||
355 | mov bx,0x13 |
||
356 | mov cx,640 |
||
357 | mov dx,480 |
||
358 | push word 0x0 |
||
359 | pop es |
||
360 | mov [es:0x9000],byte 32 |
||
361 | mov dword [es:0x9018],0x800000 |
||
362 | push word 0x1000 |
||
363 | pop es |
||
364 | jmp gml10 |
||
365 | gml00: |
||
366 | cmp al,0xa |
||
367 | jnz gml02 |
||
368 | mov bx,0x12 |
||
369 | mov cx,640 |
||
370 | mov dx,480 |
||
371 | push word 0x0 |
||
372 | pop es |
||
373 | mov [es:0x9000],byte 32 |
||
374 | mov dword [es:0x9018],0x800000 |
||
375 | push word 0x1000 |
||
376 | pop es |
||
377 | jmp gml10 |
||
378 | gml02: |
||
379 | jmp gml0 |
||
380 | gr_table: |
||
381 | dd 0x112+0100000000000000b , 640 , 480 , 0 |
||
382 | dd 0x115+0100000000000000b , 800 , 600 , 0 |
||
383 | dd 0x118+0100000000000000b , 1024 , 768 , 0 |
||
384 | dd 0x11B+0100000000000000b , 1280 , 1024 , 0 |
||
385 | dd 0x112 , 640 , 480 , 0 |
||
386 | dd 0x115 , 800 , 600 , 0 |
||
387 | dd 0x118 , 1024 , 768 , 0 |
||
388 | dd 0x11B , 1280 ,1024 , 0 |
||
389 | gml10: |
||
390 | push word 0x0000 |
||
391 | pop es |
||
392 | mov [es:0x9008],bx |
||
393 | mov [es:0x900A],cx |
||
394 | mov [es:0x900C],dx |
||
395 | push word 0x1000 |
||
396 | pop es |
||
397 | mov ax,32 |
||
398 | cmp bx,0x13 |
||
399 | je nov |
||
400 | cmp bx,0x12 |
||
401 | je nov |
||
402 | |||
403 | |||
404 | ; USE DEFAULTS OR PROBE |
||
405 | |||
406 | ; bx - mode : cx - x size : dx - y size |
||
407 | |||
408 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
409 | movzx ax,[es:preboot_gprobe-0x10000] |
||
410 | test ax,ax |
||
411 | jne pre_probe |
||
412 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
413 | |||
414 | test bx,0100000000000000b |
||
415 | jz noprobe |
||
416 | |||
417 | mov si,probetext-0x10000 |
||
418 | call printplain |
||
419 | push bx |
||
420 | mov ebx,0x0201 |
||
421 | call getkey |
||
422 | pop bx |
||
423 | |||
424 | pre_probe: |
||
425 | cmp ax,1 |
||
426 | je noprobe |
||
427 | |||
428 | push cx dx |
||
429 | |||
430 | mov bx,0x100 |
||
431 | |||
432 | newprobe: |
||
433 | |||
434 | inc bx |
||
435 | cmp bx,0x17f |
||
436 | jne probemore |
||
437 | |||
438 | mov si,prnotfnd-0x10000 |
||
439 | call printplain |
||
440 | |||
441 | jmp $ |
||
442 | |||
443 | probemore: |
||
444 | |||
445 | mov ax,0x4f01 |
||
446 | mov cx,bx |
||
447 | and cx,0xfff |
||
448 | push word 0x0000 |
||
449 | pop es |
||
450 | mov di,0xa000 |
||
451 | int 0x10 |
||
452 | |||
453 | mov eax,[es:di] ; lfb ? |
||
454 | test eax,10000000b |
||
455 | jz newprobe |
||
456 | |||
457 | mov eax,[es:di+0x12] ; x size ? |
||
458 | cmp ax,word [esp+2] |
||
459 | jne newprobe |
||
460 | |||
461 | mov eax,[es:di+0x14] ; y size ? |
||
462 | cmp ax,dx |
||
463 | jne newprobe |
||
464 | |||
465 | movzx eax,byte [es:di+0x19] |
||
466 | cmp eax,32 ;24 |
||
467 | jb newprobe |
||
468 | |||
469 | push word 0x0000 ; save probed mode |
||
470 | pop es |
||
471 | add bx,0100000000000000b |
||
472 | mov [es:0x9008],bx |
||
473 | push word 0x1000 |
||
474 | pop es |
||
475 | |||
476 | push bx |
||
477 | |||
478 | mov si,prid-0x10000 |
||
479 | call printplain |
||
480 | |||
481 | pop bx dx cx |
||
482 | |||
483 | noprobe: |
||
484 | |||
485 | |||
486 | ; FIND VESA 2.0 LFB & BPP |
||
487 | |||
488 | mov ax,0x4f01 |
||
489 | mov cx,bx |
||
490 | and cx,0xfff |
||
491 | push word 0x0000 |
||
492 | pop es |
||
493 | mov di,0xa000 |
||
494 | int 0x10 |
||
495 | ; LFB |
||
496 | mov ecx,[es:di+0x28] |
||
497 | mov [es:0x9018],ecx |
||
498 | ; BPP |
||
499 | movzx ax,byte [es:di+0x19] |
||
500 | mov [es:0x9000],ax |
||
501 | ; ---- vbe voodoo |
||
502 | BytesPerScanLine equ 0x10 |
||
503 | push ax |
||
504 | mov ax, [es:di+BytesPerScanLine] |
||
505 | mov [es:0x9001],ax |
||
506 | pop ax |
||
507 | ; ----- |
||
508 | nov: |
||
509 | cmp ax,24 |
||
510 | jnz nbpp24 |
||
511 | mov si,bt24-0x10000 |
||
512 | jmp bppl |
||
513 | nbpp24: |
||
514 | cmp ax,32 |
||
515 | jnz nbpp32 |
||
516 | mov si,bt32-0x10000 |
||
517 | jmp bppl |
||
518 | nbpp32: |
||
519 | mov si,btns-0x10000 |
||
520 | call print |
||
521 | jmp $ |
||
522 | bppl: |
||
523 | call printplain |
||
524 | |||
525 | |||
526 | ; FIND VESA 1.2 PM BANK SWITCH ADDRESS |
||
527 | |||
528 | mov ax,0x4f0A |
||
529 | mov bx,0x0 |
||
530 | int 0x10 |
||
531 | xor eax,eax |
||
532 | xor ebx,ebx |
||
533 | mov ax,es |
||
534 | shl eax,4 |
||
535 | mov bx,di |
||
536 | add eax,ebx |
||
537 | xor ebx,ebx |
||
538 | mov bx,[es:di] |
||
539 | add eax,ebx |
||
540 | push word 0x0 |
||
541 | pop es |
||
542 | mov [es:0x9014],eax |
||
543 | push word 0x1000 |
||
544 | pop es |
||
545 | |||
546 | |||
547 | |||
548 | ; GRAPHICS ACCELERATION |
||
549 | |||
550 | mov al, [es:preboot_mtrr-0x10000] |
||
551 | test al,al |
||
552 | jne pre_mtrr |
||
553 | mov si,gr_acc-0x10000 |
||
554 | call printplain |
||
555 | mov ebx,0x0201 |
||
556 | call getkey |
||
557 | pre_mtrr: |
||
558 | push word 0x0000 |
||
559 | pop es |
||
560 | mov [es:0x901C],al |
||
561 | push word 0x1000 |
||
562 | pop es |
||
563 | mov si,linef-0x10000 |
||
564 | call printplain |
||
565 | |||
566 | |||
567 | ; VRR_M USE |
||
568 | |||
569 | mov al,[es:preboot_vrrm-0x10000] |
||
570 | test al,al |
||
571 | jne pre_vrrm |
||
572 | mov si,vrrmprint-0x10000 |
||
573 | call print |
||
574 | mov ebx,0x0301 |
||
575 | call getkey |
||
576 | pre_vrrm: |
||
577 | push word 0x0000 |
||
578 | pop es |
||
579 | mov [es:0x9030],al |
||
580 | push word 0x1000 |
||
581 | pop es |
||
582 | mov si,linef2-0x10000 |
||
583 | call printplain |
||
584 | |||
585 | |||
586 | ; MEMORY MODEL |
||
587 | |||
588 | ; movzx eax,byte [es:preboot_memory-0x10000] |
||
589 | ; cmp eax,0 |
||
590 | ; jne pre_mem |
||
591 | ;;;;;;;;;;;;;;;;;;;;;;;;; |
||
592 | ; mario79 - memory size ; |
||
593 | ;;;;;;;;;;;;;;;;;;;;;;;;; |
||
594 | ; mov ax,0E801h |
||
595 | ;;; xor bx,bx ; thanks to Alexei for bugfix [18.07.2004] |
||
596 | ; xor cx, cx |
||
597 | ; xor dx, dx |
||
598 | ; int 0x15 |
||
599 | ; movzx ebx, dx ;bx |
||
600 | ; movzx eax, cx ;ax |
||
601 | ; shl ebx,6 ; перевод в килобайты (x64) |
||
602 | ; add eax,ebx |
||
603 | ; add eax, 1000h ;440h |
||
604 | ; cmp eax,40000h ; 256? |
||
605 | ; jge mem_256_z |
||
606 | ; cmp eax,20000h ; 128? |
||
607 | ; jge mem_128_z |
||
608 | ; cmp eax,10000h ; 64? |
||
609 | ; jge mem_64_z |
||
610 | ; cmp eax,8000h ; 32? |
||
611 | ; jge mem_32_z |
||
612 | ; jmp mem_16_z |
||
613 | ; |
||
614 | ;mem_256_z: mov si,memokz256-0x10000 |
||
615 | ; call printplain |
||
616 | ; mov eax,5 |
||
617 | ; jmp pre_mem |
||
618 | ;mem_128_z: mov si,memokz128-0x10000 |
||
619 | ; call printplain |
||
620 | ; mov eax,4 |
||
621 | ; jmp pre_mem |
||
622 | ;mem_64_z: mov si,memokz64-0x10000 |
||
623 | ; call printplain |
||
624 | ; mov eax,3 |
||
625 | ; jmp pre_mem |
||
626 | ;mem_32_z: mov si,memokz32-0x10000 |
||
627 | ; call printplain |
||
628 | ; mov eax,2 |
||
629 | ; jmp pre_mem |
||
630 | ;mem_16_z: mov si,memokz16-0x10000 |
||
631 | ; call printplain |
||
632 | ; mov eax,1 |
||
633 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
634 | ; pre_mem: |
||
635 | ; push word 0x0000 |
||
636 | ; pop es |
||
637 | ; mov [es:0x9030],al |
||
638 | ; push word 0x1000 |
||
639 | ; pop es |
||
640 | ; mov si,linef-0x10000 |
||
641 | ; call printplain |
||
642 | |||
643 | |||
644 | |||
645 | |||
646 | ; DIRECT WRITE TO LFB, PAGING DISABLED |
||
647 | |||
648 | ; movzx eax,byte [es:preboot_lfb-0x10000] |
||
649 | ; mov eax,1 ; paging disabled |
||
650 | ; cmp eax,0 |
||
651 | ; jne pre_lfb |
||
652 | ; mov si,gr_direct-0x10000 |
||
653 | ; call printplain |
||
654 | ; mov ebx,0x0201 |
||
655 | ; call getkey |
||
656 | ; pre_lfb: |
||
657 | ; push word 0x0000 |
||
658 | ; pop es |
||
659 | ; mov [es:0x901E],al |
||
660 | ; mov ax,0x1000 |
||
661 | ; mov es,ax |
||
662 | ; mov si,linef-0x10000 |
||
663 | ; call printplain |
||
664 | push 0 |
||
665 | pop es |
||
666 | mov [es:0x901E],byte 1 |
||
667 | push 0x1000 |
||
668 | pop es |
||
669 | |||
670 | |||
671 | |||
672 | ; BOOT DEVICE |
||
673 | |||
674 | movzx eax,byte [es:preboot_device-0x10000] |
||
675 | cmp eax,0 |
||
676 | jne pre_device |
||
677 | mov si,bdev-0x10000 |
||
678 | call printplain |
||
679 | mov ebx,0x0301 |
||
680 | call getkey |
||
681 | pre_device: |
||
682 | dec al |
||
683 | mov [es:boot_dev-0x10000],al |
||
684 | mov si,linef-0x10000 |
||
685 | call printplain |
||
686 | |||
687 | |||
688 | |||
689 | ; READ DISKETTE TO MEMORY |
||
690 | |||
691 | cmp [boot_dev-0x10000],0 |
||
692 | jne no_sys_on_floppy |
||
693 | mov si,diskload-0x10000 |
||
694 | call print |
||
695 | mov ax,0x0000 ; reset drive |
||
696 | mov dx,0x0000 |
||
697 | int 0x13 |
||
698 | mov cx,0x0001 ; startcyl,startsector |
||
699 | mov dx,0x0000 ; starthead,drive |
||
700 | push word 80*2 ; read no of sect |
||
701 | reads: |
||
702 | pusha |
||
703 | xor si,si |
||
704 | newread: |
||
705 | push word 0x0 |
||
706 | pop es |
||
707 | mov bx,0xa000 ; es:bx -> data area |
||
708 | mov ax,0x0200+18 ; read, no of sectors to read |
||
709 | int 0x13 |
||
710 | cmp ah,0 |
||
711 | jz goodread |
||
712 | add si,1 |
||
713 | cmp si,10 |
||
714 | jnz newread |
||
715 | mov si,badsect-0x10000 |
||
716 | call printplain |
||
717 | jmp $ |
||
718 | goodread: |
||
719 | ; move -> 1mb |
||
720 | mov si,movedesc-0x10000 |
||
721 | push word 0x1000 |
||
722 | pop es |
||
723 | mov cx,256*18 |
||
724 | mov ah,0x87 |
||
725 | int 0x15 |
||
726 | |||
727 | cmp ah,0 ; was the move successfull ? |
||
728 | je goodmove |
||
729 | mov dx,0x3f2 ; floppy motor off |
||
730 | mov al,0 |
||
731 | out dx,al |
||
732 | mov si,memmovefailed-0x10000 |
||
733 | call print |
||
734 | jmp $ |
||
735 | goodmove: |
||
736 | |||
737 | mov eax,[es:movedesc-0x10000+0x18+2] |
||
738 | add eax,512*18 |
||
739 | mov [es:movedesc-0x10000+0x18+2],eax |
||
740 | popa |
||
741 | inc dh |
||
742 | cmp dh,2 |
||
743 | jnz bb2 |
||
744 | mov dh,0 |
||
745 | inc ch |
||
746 | pusha ; print prosentage |
||
747 | push word 0x1000 |
||
748 | pop es |
||
749 | xor eax,eax ; 5 |
||
750 | mov al,ch |
||
751 | shr eax,2 |
||
752 | and eax,1 |
||
753 | mov ebx,5 |
||
754 | mul bx |
||
755 | add al,48 |
||
756 | mov [es:pros+1-0x10000],al |
||
757 | xor eax,eax ; 10 |
||
758 | mov al,ch |
||
759 | shr eax,3 |
||
760 | add al,48 |
||
761 | mov [es:pros-0x10000],al |
||
762 | mov si,pros-0x10000 |
||
763 | call printplain |
||
764 | popa |
||
765 | bb2: |
||
766 | pop ax |
||
767 | dec ax |
||
768 | push ax |
||
769 | cmp ax,0 |
||
770 | jnz rs |
||
771 | jmp readdone |
||
772 | rs: |
||
773 | jmp reads |
||
774 | movedesc: |
||
775 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
776 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
777 | |||
778 | db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0 |
||
779 | db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0 |
||
780 | |||
781 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
782 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
783 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
784 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
785 | readdone: |
||
786 | pop ax |
||
787 | mov dx,0x3f2 ; floppy motor off |
||
788 | mov al,0 |
||
789 | out dx,al |
||
790 | mov si,backspace-0x10000 |
||
791 | call printplain |
||
792 | call printplain |
||
793 | mov si,okt-0x10000 |
||
794 | call printplain |
||
795 | no_sys_on_floppy: |
||
796 | mov ax,0x0000 ; reset drive |
||
797 | mov dx,0x0000 |
||
798 | int 0x13 |
||
799 | mov dx,0x3f2 ; floppy motor off |
||
800 | mov al,0 |
||
801 | out dx,al |
||
802 | |||
803 | |||
804 | ; PAGE TABLE |
||
805 | |||
806 | push word 0x0000 |
||
807 | pop es |
||
808 | mov ecx,[es:0x9018] |
||
809 | push ecx |
||
810 | |||
811 | map_mem equ 64 ; amount of memory to map |
||
812 | |||
813 | mov bx,0x6000 |
||
814 | mov es,bx ; [es:di] = 6000:0 |
||
815 | xor edi,edi |
||
816 | mov ecx,256*map_mem ; Map (mapmem) M |
||
817 | mov eax,7 |
||
818 | cld |
||
819 | pt2: |
||
820 | cmp ecx,256*(map_mem-8) ; 8 M map to LFB |
||
821 | jnz pt3 |
||
822 | pop eax |
||
823 | add eax,7 |
||
824 | pt3: |
||
825 | cmp ecx,256*(map_mem-12) ; 12 M back to linear = physical |
||
826 | jnz pt4 |
||
827 | mov eax,12*0x100000 + 7 |
||
828 | pt4: |
||
829 | stosd |
||
830 | add eax,4096 |
||
831 | loop pt2 |
||
832 | |||
833 | mov bx,0x7100 |
||
834 | mov es,bx |
||
835 | xor edi,edi |
||
836 | mov eax,8*0x100000+7 |
||
837 | mov ecx,256*4 |
||
838 | pt5: |
||
839 | stosd |
||
840 | add eax,0x1000 |
||
841 | loop pt5 |
||
842 | |||
843 | ; 4 KB PAGE DIRECTORY |
||
844 | |||
845 | mov bx , 0x7F00 |
||
846 | mov es , bx ; [es:di] = 7000:0 |
||
847 | xor edi, edi |
||
848 | mov ecx, 64 / 4 |
||
849 | mov eax, 0x60007 ; for 0 M |
||
850 | cld |
||
851 | pd4k: |
||
852 | stosd |
||
853 | add eax, 0x1000 |
||
854 | loop pd4k |
||
855 | mov dword [es:0x800],0x71007 ;map region 0x80000000-0x803FFFFF to 0x800000-0xCFFFFF |
||
856 | xor esi,esi |
||
857 | mov edi,second_base_address shr 20 |
||
858 | mov ecx,64/4 |
||
859 | mov bx,0x7F00 |
||
860 | mov ds,bx |
||
861 | rep movsd |
||
862 | mov bx,0x1000 |
||
863 | mov ds,bx |
||
864 | |||
865 | mov eax, 0x7F000 +8+16 ; Page directory and enable caches |
||
866 | mov cr3, eax |
||
867 | |||
868 | ; SET GRAPHICS |
||
869 | |||
870 | mov dx,0x0000 |
||
871 | mov es,dx |
||
872 | mov bx,[es:0x9008] |
||
873 | mov ax,bx ; vga & 320x200 |
||
874 | cmp ax,0x13 |
||
875 | je setgr |
||
876 | cmp ax,0x12 |
||
877 | je setgr |
||
878 | mov ax,0x4f02 ; Vesa |
||
879 | setgr: |
||
880 | int 0x10 |
||
881 | cmp ah,0 |
||
882 | jz gmok |
||
883 | mov si,fatalsel-0x10000 |
||
884 | call print |
||
885 | jmp $ |
||
886 | |||
887 | gmok: |
||
888 | mov dx,0x1000 |
||
889 | mov es,dx |
||
890 | |||
891 | ; set mode 0x12 graphics registers: |
||
892 | |||
893 | cmp bx,0x12 |
||
894 | jne gmok2 |
||
895 | |||
896 | mov al,0x05 |
||
897 | mov dx,0x03ce |
||
898 | out dx,al ; select GDC mode register |
||
899 | mov al,0x02 |
||
900 | mov dx,0x03cf |
||
901 | out dx,al ; set write mode 2 |
||
902 | |||
903 | mov al,0x02 |
||
904 | mov dx,0x03c4 |
||
905 | out dx,al ; select VGA sequencer map mask register |
||
906 | mov al,0x0f |
||
907 | mov dx,0x03c5 |
||
908 | out dx,al ; set mask for all planes 0-3 |
||
909 | |||
910 | mov al,0x08 |
||
911 | mov dx,0x03ce |
||
912 | out dx,al ; select GDC bit mask register |
||
913 | ; for writes to 0x03cf |
||
914 | |||
915 | gmok2: |
||
916 | mov dx,0x1000 |
||
917 | mov es,dx |