VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/orgs.asm@ 42392

Last change on this file since 42392 was 42392, checked in by vboxsync, 13 years ago

BIOS: Use new C implementation for 32-bit PCI BIOS, too.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 35.7 KB
Line 
1;;
2;; Copyright (C) 2006-2011 Oracle Corporation
3;;
4;; This file is part of VirtualBox Open Source Edition (OSE), as
5;; available from http://www.virtualbox.org. This file is free software;
6;; you can redistribute it and/or modify it under the terms of the GNU
7;; General Public License (GPL) as published by the Free Software
8;; Foundation, in version 2 as it comes in the "COPYING" file of the
9;; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10;; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11;; --------------------------------------------------------------------
12;;
13;; This code is based on:
14;;
15;; ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
16;;
17;; Copyright (C) 2002 MandrakeSoft S.A.
18;;
19;; MandrakeSoft S.A.
20;; 43, rue d'Aboukir
21;; 75002 Paris - France
22;; http://www.linux-mandrake.com/
23;; http://www.mandrakesoft.com/
24;;
25;; This library is free software; you can redistribute it and/or
26;; modify it under the terms of the GNU Lesser General Public
27;; License as published by the Free Software Foundation; either
28;; version 2 of the License, or (at your option) any later version.
29;;
30;; This library is distributed in the hope that it will be useful,
31;; but WITHOUT ANY WARRANTY; without even the implied warranty of
32;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33;; Lesser General Public License for more details.
34;;
35;; You should have received a copy of the GNU Lesser General Public
36;; License along with this library; if not, write to the Free Software
37;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
38;;
39;;
40
41
42EBDA_SEG equ 09FC0h ; starts at 639K
43EBDA_SIZE equ 1 ; 1K
44BASE_MEM_IN_K equ (640 - EBDA_SIZE)
45
46CMOS_ADDR equ 070h
47CMOS_DATA equ 071h
48
49
50PIC_CMD_EOI equ 020h
51PIC_MASTER equ 020h
52PIC_SLAVE equ 0A0h
53
54BIOS_FIX_BASE equ 0E000h
55
56SYS_MODEL_ID equ 0FCh ; PC/AT
57SYS_SUBMODEL_ID equ 0
58BIOS_REVISION equ 1
59
60BIOS_BUILD_DATE equ '06/23/99'
61BIOS_COPYRIGHT equ 'Oracle VM VirtualBox BIOS'
62
63BX_ROMBIOS32 equ 0
64BX_CALL_INT15_4F equ 1
65
66;; Set a fixed BIOS location, with a marker for verification
67BIOSORG macro addr
68 org addr - BIOS_FIX_BASE - 2
69 db 'XM'
70 endm
71
72;; Set an interrupt vector (not very efficient if multiple vectors are
73;; programmed in one go)
74SET_INT_VECTOR macro vec, segm, offs
75 mov ax, offs
76 mov ds:[vec*4], ax
77 mov ax, segm
78 mov ds:[vec*4+2], ax
79endm
80
81; Set up an environment C code expects. DS must point to the BIOS segment
82; and the direction flag must be cleared(!)
83C_SETUP macro
84 push cs
85 pop ds
86 cld
87endm
88
89;; External function in separate modules
90extrn _dummy_isr_function:near
91extrn _log_bios_start:near
92extrn _nmi_handler_msg:near
93extrn _int18_panic_msg:near
94extrn _int09_function:near
95extrn _int13_diskette_function:near
96extrn _int13_eltorito:near
97extrn _int13_cdemu:near
98extrn _int13_cdrom:near
99extrn _cdemu_isactive:near
100extrn _cdemu_emulated_drive:near
101extrn _int13_harddisk:near
102extrn _int13_harddisk_ext:near
103extrn _int14_function:near
104extrn _int15_function:near
105extrn _int15_function_mouse:near
106extrn _int15_function32:near
107extrn _int16_function:near
108extrn _int17_function:near
109extrn _int19_function:near
110extrn _int1a_function:near
111extrn _pci16_function:near
112extrn _int70_function:near
113extrn _int74_function:near
114extrn _ata_init:near
115extrn _ahci_init:near
116extrn _scsi_init:near
117extrn _ata_detect:near
118extrn _cdemu_init:near
119extrn _keyboard_init:near
120extrn _print_bios_banner:near
121
122
123;; Symbols referenced from C code
124public _diskette_param_table
125public _pmode_IDT
126public _rmode_IDT
127public post
128public eoi_both_pics
129public rtc_post
130
131;; Additional publics for easier disassembly and debugging
132ifndef DEBUG
133 DEBUG equ 1
134endif
135ifdef DEBUG
136
137public int08_handler
138public int0e_handler
139public int11_handler
140public int12_handler
141public int13_handler
142public int13_relocated
143public int15_handler
144public int17_handler
145public int19_handler
146public int19_relocated
147public dummy_iret
148public nmi
149public rom_fdpt
150public cpu_reset
151public normal_post
152public eoi_jmp_post
153public eoi_master_pic
154public ebda_post
155public hard_drive_post
156public int13_legacy
157public int70_handler
158public int75_handler
159public int15_handler32
160public int15_handler_mouse
161public iret_modify_cf
162public rom_scan
163public rom_checksum
164public init_pic
165public floppy_post
166public int13_out
167public int13_disk
168public int13_notfloppy
169public int13_legacy
170public int13_noeltorito
171public int1c_handler
172public int10_handler
173public int74_handler
174public int76_handler
175public detect_parport
176public detect_serial
177public font8x8
178
179endif
180
181;; NOTE: The last 8K of the ROM BIOS are peppered with fixed locations which
182;; must be retained for compatibility. As a consequence, some of the space is
183;; going to be wasted, but the gaps should be filled with miscellaneous code
184;; and data when possible.
185
186.286p
187
188BIOSSEG segment 'CODE'
189 assume cs:BIOSSEG
190
191;;
192;; Start of fixed code - eoi_jmp_post is kept here to allow short jumps.
193;;
194 BIOSORG 0E030h
195eoi_jmp_post:
196 call eoi_both_pics
197 xor ax, ax
198 mov ds, ax
199 jmp dword ptr ds:[0467h]
200
201eoi_both_pics:
202 mov al, PIC_CMD_EOI
203 out PIC_SLAVE, al
204eoi_master_pic:
205 mov al, PIC_CMD_EOI
206 out PIC_MASTER, al
207 ret
208
209;; --------------------------------------------------------
210;; POST entry point
211;; --------------------------------------------------------
212 BIOSORG 0E05Bh
213post:
214 xor ax, ax
215
216 ;; reset the DMA controllers
217 out 00Dh, al
218 out 0DAh, al
219
220 ;; then initialize the DMA controllers
221 mov al, 0C0h
222 out 0D6h, al ; enable channel 4 cascade
223 mov al, 0
224 out 0D4h, al ; unmask channel 4
225
226 ;; read the CMOS shutdown status
227 mov al, 0Fh
228 out CMOS_ADDR, al
229 in al, CMOS_DATA
230
231 ;; save status
232 mov bl, al
233
234 ;; reset the shutdown status in CMOS
235 mov al, 0Fh
236 out CMOS_ADDR, al
237 mov al, 0
238 out CMOS_DATA, al
239
240 ;; examine the shutdown status code
241 mov al, bl
242 cmp al, 0
243 jz normal_post
244 cmp al, 0Dh
245 jae normal_post
246 cmp al, 9
247 je normal_post ;; TODO: really?!
248
249 ;; 05h = EOI + jump through 40:67
250 cmp al, 5
251 je eoi_jmp_post
252
253 ;; any other shutdown status values are ignored
254 ;; OpenSolaris sets the status to 0Ah in some cases?
255 jmp normal_post
256
257
258 ;; routine to write the pointer in DX:AX to memory starting
259 ;; at DS:BX (repeat CX times)
260 ;; - modifies BX, CX
261set_int_vects proc near
262
263 mov [bx], ax
264 mov [bx+2], dx
265 add bx, 4
266 loop set_int_vects
267 ret
268
269set_int_vects endp
270
271normal_post:
272 ;; shutdown code 0: normal startup
273 cli
274 ;; Set up the stack top at 0:7800h. The stack should not be
275 ;; located above 0:7C00h; that conflicts with PXE, which
276 ;; considers anything above that address to be fair game.
277 ;; The traditional locations are 30:100 (PC) or 0:400 (PC/AT).
278 mov ax, 7800h
279 mov sp, ax
280 xor ax, ax
281 mov ds, ax
282 mov ss, ax
283
284 ;; clear the bottom of memory except for the word at 40:72
285 ;; TODO: Why not clear all of it? What's the point?
286 mov es, ax
287 xor di, di
288 cld
289 mov cx, 0472h / 2
290 rep stosw
291 inc di
292 inc di
293 mov cx, (1000h - 0472h - 2) / 2
294 rep stosw
295
296 ;; clear the remaining base memory except for the top
297 ;; of the EBDA (the MP table is planted there)
298 xor bx, bx
299memory_zero_loop:
300 add bx, 1000h
301 cmp bx, 9000h
302 jae memory_cleared
303 mov es, bx
304 xor di, di
305 mov cx, 8000h ; 32K words
306 rep stosw
307 jmp memory_zero_loop
308memory_cleared:
309 mov es, bx
310 xor di, di
311 mov cx, 7E00h ; all but the last 1K
312 rep stosw
313 xor bx, bx
314
315
316 C_SETUP
317 call _log_bios_start
318
319 call pmode_setup
320
321 ;; set all interrupts in 00h-5Fh range to default handler
322 xor bx, bx
323 mov ds, bx
324 mov cx, 60h ; leave the rest as zeros
325 mov ax, dummy_iret
326 mov dx, BIOSSEG
327 call set_int_vects
328
329 ;; also set 68h-77h to default handler; note that the
330 ;; 60h-67h range must contain zeros for certain programs
331 ;; to function correctly
332 mov bx, 68h * 4
333 mov cx, 10h
334 call set_int_vects
335
336 ;; base memory in K to 40:13
337 mov ax, BASE_MEM_IN_K
338 mov ds:[413h], ax
339
340 ;; manufacturing test at 40:12
341 ;; zeroed out above
342
343 ;; set up various service vectors
344 ;; TODO: This should use the table at FEF3h instead
345 SET_INT_VECTOR 11h, BIOSSEG, int11_handler
346 SET_INT_VECTOR 12h, BIOSSEG, int12_handler
347 SET_INT_VECTOR 15h, BIOSSEG, int15_handler
348 SET_INT_VECTOR 17h, BIOSSEG, int17_handler
349 SET_INT_VECTOR 18h, BIOSSEG, int18_handler
350 SET_INT_VECTOR 19h, BIOSSEG, int19_handler
351 SET_INT_VECTOR 1Ch, BIOSSEG, int1c_handler
352
353 call ebda_post
354
355 ;; PIT setup
356 SET_INT_VECTOR 08h, BIOSSEG, int08_handler
357 mov al, 34h ; timer 0, binary, 16-bit, mode 2
358 out 43h, al
359 mov al, 0 ; max count -> ~18.2 Hz
360 out 40h, al
361 out 40h, al
362
363 ;; keyboard setup
364 SET_INT_VECTOR 09h, BIOSSEG, int09_handler
365 SET_INT_VECTOR 16h, BIOSSEG, int16_handler
366
367 xor ax, ax
368 mov ds, ax
369 ;; TODO: What's the point? The BDA is zeroed already?!
370 mov ds:[417h], al ; keyboard shift flags, set 1
371 mov ds:[418h], al ; keyboard shift flags, set 2
372 mov ds:[419h], al ; keyboard Alt-numpad work area
373 mov ds:[471h], al ; keyboard Ctrl-Break flag
374 mov ds:[497h], al ; keyboard status flags 4
375 mov al, 10h
376 mov ds:[496h], al ; keyboard status flags 3
377
378 mov bx, 1Eh
379 mov ds:[41Ah], bx ; keyboard buffer head
380 mov ds:[41Ch], bx ; keyboard buffer tail
381 mov ds:[480h], bx ; keyboard buffer start
382 mov bx, 3Eh
383 mov ds:[482h], bx ; keyboard buffer end
384
385 push ds
386 C_SETUP
387 call _keyboard_init
388 pop ds
389
390
391 ;; store CMOS equipment byte in BDA
392 mov al, 14h
393 out CMOS_ADDR, al
394 in al, CMOS_DATA
395 mov ds:[410h], al
396
397 ;; parallel setup
398 SET_INT_VECTOR 0Fh, BIOSSEG, dummy_iret
399 xor ax, ax
400 mov ds, ax
401 xor bx, bx
402 mov cl, 14h ; timeout value
403 mov dx, 378h ; parallel port 1
404 call detect_parport
405 mov dx, 278h ; parallel port 2
406 call detect_parport
407 shl bx, 0Eh
408 mov ax, ds:[410h] ; equipment word
409 and ax, 3FFFh
410 or ax, bx ; set number of parallel ports
411 mov ds:[410h], ax ; store in BDA
412
413 ;; Serial setup
414 SET_INT_VECTOR 0Bh, BIOSSEG, dummy_isr
415 SET_INT_VECTOR 0Ch, BIOSSEG, dummy_isr
416 SET_INT_VECTOR 14h, BIOSSEG, int14_handler
417 xor bx, bx
418 mov cl, 0Ah ; timeout value
419 mov dx, 3F8h ; first serial address
420 call detect_serial
421 mov dx, 2F8h ; second serial address
422 call detect_serial
423 mov dx, 3E8h ; third serial address
424 call detect_serial
425 mov dx, 2E8h ; fourth serial address
426 call detect_serial
427 shl bx, 9
428 mov ax, ds:[410h] ; equipment word
429 and ax, 0F1FFh ; bits 9-11 determine serial ports
430 or ax, bx
431 mov ds:[410h], ax
432
433 ;; CMOS RTC
434 SET_INT_VECTOR 1Ah, BIOSSEG, int1a_handler
435 SET_INT_VECTOR 4Ah, BIOSSEG, dummy_iret ; TODO: redundant?
436 SET_INT_VECTOR 70h, BIOSSEG, int70_handler
437 ;; BIOS DATA AREA 4CEh ???
438 call rtc_post
439
440 ;; PS/2 mouse setup
441 SET_INT_VECTOR 74h, BIOSSEG, int74_handler
442
443 ;; IRQ 13h (FPU exception) setup
444 SET_INT_VECTOR 75h, BIOSSEG, int75_handler
445
446 ;; Video setup
447 SET_INT_VECTOR 10h, BIOSSEG, int10_handler
448
449 call init_pic
450
451 call pcibios_init_iomem_bases
452 call pcibios_init_irqs
453
454 call rom_scan
455
456 C_SETUP
457 ;; ATA/ATAPI driver setup
458 call _ata_init
459 call _ata_detect
460
461ifdef VBOX_WITH_SCSI
462 ; SCSI driver setup
463 call _scsi_init
464endif
465
466ifdef VBOX_WITH_AHCI
467 ; AHCI driver setup
468 call _ahci_init
469endif
470
471 ;; floppy setup
472 call floppy_post
473
474 ;; hard drive setup
475 call hard_drive_post
476
477 C_SETUP ; in case assembly code changed things
478 call _print_bios_banner
479
480 ;; El Torito floppy/hard disk emulation
481 call _cdemu_init
482
483 ; TODO: what's the point of enabling interrupts here??
484 sti ; enable interrupts
485 int 19h
486 ;; does not return here
487 sti
488wait_forever:
489 hlt
490 jmp wait_forever
491 cli
492 hlt
493
494
495;; --------------------------------------------------------
496;; NMI handler
497;; --------------------------------------------------------
498 BIOSORG 0E2C3h
499nmi:
500 C_SETUP
501 call _nmi_handler_msg
502 iret
503
504int75_handler:
505 out 0F0h, al ; clear IRQ13
506 call eoi_both_pics
507 int 2 ; emulate legacy NMI
508 iret
509
510
511hard_drive_post proc near
512
513 ;; TODO Why? And what about secondary controllers?
514 mov al, 0Ah ; disable IRQ 14
515 mov dx, 03F6h
516 out dx, al
517
518 xor ax, ax
519 mov ds, ax
520 ;; TODO: Didn't we just clear the entire EBDA?
521 mov ds:[474h], al ; last HD operation status
522 mov ds:[477h], al ; HD port offset (XT only???)
523 mov ds:[48Ch], al ; HD status register
524 mov ds:[48Dh], al ; HD error register
525 mov ds:[48Eh], al ; HD task complete flag
526 mov al, 0C0h
527 mov ds:[476h], al ; HD control byte
528 ;; set up hard disk interrupt vectors
529 SET_INT_VECTOR 13h, BIOSSEG, int13_handler
530 SET_INT_VECTOR 76h, BIOSSEG, int76_handler
531 ;; INT 41h/46h: hard disk 0/1 dpt
532 ; TODO: This should be done from the code which
533 ; builds the DPTs?
534 SET_INT_VECTOR 41h, EBDA_SEG, 3Dh
535 SET_INT_VECTOR 46h, EBDA_SEG, 4Dh
536 ret
537
538hard_drive_post endp
539
540
541;; --------------------------------------------------------
542;; INT 13h handler - Disk services
543;; --------------------------------------------------------
544 BIOSORG 0E3FEh
545
546int13_handler:
547 jmp int13_relocated
548
549
550;; --------------------------------------------------------
551;; Fixed Disk Parameter Table
552;; --------------------------------------------------------
553;; BIOSORG 0E401h - fixed wrt preceding
554
555rom_fdpt:
556
557;; --------------------------------------------------------
558;; INT 19h handler - Boot load service
559;; --------------------------------------------------------
560 BIOSORG 0E6F2h
561
562int19_handler:
563 jmp int19_relocated
564
565
566
567;; --------------------------------------------------------
568;; System BIOS Configuration Table
569;; --------------------------------------------------------
570;; BIOSORG 0E6F5h - fixed wrt preceding
571; must match BIOS_CONFIG_TABLE
572bios_cfg_table:
573 dw 9 ; table size in bytes
574 db SYS_MODEL_ID
575 db SYS_SUBMODEL_ID
576 db BIOS_REVISION
577 ; Feature byte 1
578 ; b7: 1=DMA channel 3 used by hard disk
579 ; b6: 1=2 interrupt controllers present
580 ; b5: 1=RTC present
581 ; b4: 1=BIOS calls int 15h/4Fh for every key
582 ; b3: 1=wait for extern event supported (Int 15h/41h)
583 ; b2: 1=extended BIOS data area used
584 ; b1: 0=AT or ESDI bus, 1=MicroChannel
585 ; b0: 1=Dual bus (MicroChannel + ISA)
586ifdef BX_CALL_INT15_4F
587 db 74h; or USE_EBDA
588else
589 db 64h; or USE_EBDA
590endif
591 ; Feature byte 2
592 ; b7: 1=32-bit DMA supported
593 ; b6: 1=int16h, function 9 supported
594 ; b5: 1=int15h/C6h (get POS data) supported
595 ; b4: 1=int15h/C7h (get mem map info) supported
596 ; b3: 1=int15h/C8h (en/dis CPU) supported
597 ; b2: 1=non-8042 kb controller
598 ; b1: 1=data streaming supported
599 ; b0: reserved
600 db 40h
601 ; Feature byte 3
602 ; b7: not used
603 ; b6: reserved
604 ; b5: reserved
605 ; b4: POST supports ROM-to-RAM enable/disable
606 ; b3: SCSI on system board
607 ; b2: info panel installed
608 ; b1: Initial Machine Load (IML) system - BIOS on disk
609 ; b0: SCSI supported in IML
610 db 0
611 ; Feature byte 4
612 ; b7: IBM private
613 ; b6: EEPROM present
614 ; b5-3: ABIOS presence (011 = not supported)
615 ; b2: private
616 ; b1: memory split above 16Mb supported
617 ; b0: POSTEXT directly supported by POST
618 db 0
619 ; Feature byte 5 (IBM)
620 ; b1: enhanced mouse
621 ; b0: flash EPROM
622 db 0
623
624
625;; --------------------------------------------------------
626;; Baud Rate Generator Table
627;; --------------------------------------------------------
628 BIOSORG 0E729h
629
630
631;; --------------------------------------------------------
632;; INT 14h handler - Serial Communication Service
633;; --------------------------------------------------------
634 BIOSORG 0E739h
635int14_handler:
636 push ds
637 push es
638 pusha
639 C_SETUP
640 call _int14_function
641 popa
642 pop es
643 pop ds
644 iret
645
646
647
648;;
649;; Handler for unexpected hardware interrupts
650;;
651dummy_isr:
652 push ds
653 push es
654 pusha
655 C_SETUP
656 call _dummy_isr_function
657 popa
658 pop es
659 pop ds
660 iret
661
662
663rom_checksum proc near
664 push ax
665ifdef CHECKSUM_ROMS
666 push bx
667 push cx
668 xor ax, ax
669 xor bx, bx
670 xor cx, cx
671 mov ch, ds:[2]
672 shl cx, 1
673checksum_loop:
674 add al, [bx]
675 inc bx
676 loop checksum_loop
677 and al, 0FFh ; set flags
678 pop cx
679 pop bx
680else
681 xor al, al
682endif
683 pop ax
684 ret
685rom_checksum endp
686
687
688;;
689;; ROM scan - scan for valid ROMs and initialize them
690;;
691rom_scan:
692 mov cx, 0C000h ; start at C000
693rom_scan_loop:
694 mov ds, cx
695 mov ax, 4 ; scan in 2K increments
696 cmp word ptr ds:[0], 0AA55h ; look for signature
697 jne rom_scan_increment
698
699 call rom_checksum
700 jnz rom_scan_increment
701
702 mov al, ds:[2] ; set increment to ROM length
703 test al, 3
704 jz block_count_rounded
705
706 and al, 0FCh ; round up
707 add al, 4 ; to nearest 2K
708block_count_rounded:
709 xor bx, bx
710 mov ds, bx
711 push ax
712 push cx ; push segment...
713 push 3 ; ...and offset of ROM entry
714 mov bp, sp
715 call dword ptr [bp] ; call ROM init routine
716 cli ; in case ROM enabled interrupts
717 add sp, 2 ; get rid of offset
718 pop cx ; restore registers
719 pop ax
720rom_scan_increment:
721 shl ax, 5 ; convert to 16-byte increments
722 add cx, ax
723 cmp cx, 0E800h ; must encompass VBOX_LANBOOT_SEG!
724 jbe rom_scan_loop
725
726 xor ax, ax ; DS back to zero
727 mov ds, ax
728 ret
729
730init_pic proc near
731
732 mov al, 11h ; send init commands
733 out PIC_MASTER, al
734 out PIC_SLAVE, al
735 mov al, 08h ; base 08h
736 out PIC_MASTER+1, al
737 mov al, 70h ; base 70h
738 out PIC_SLAVE+1, al
739 mov al, 04h ; master PIC
740 out PIC_MASTER+1, al
741 mov al, 02h ; slave PIC
742 out PIC_SLAVE+1, al
743 mov al, 01h
744 out PIC_MASTER+1, al
745 out PIC_SLAVE+1, al
746 mov al, 0B8h ; unmask IRQs 0/1/2/6
747 out PIC_MASTER+1, al
748 mov al, 08Fh
749 out PIC_SLAVE+1, al ; unmask IRQs 12/13/14
750 ret
751
752init_pic endp
753
754ebda_post proc near
755
756 SET_INT_VECTOR 0Dh, BIOSSEG, dummy_isr ; IRQ 5
757 SET_INT_VECTOR 0Fh, BIOSSEG, dummy_isr ; IRQ 7
758 SET_INT_VECTOR 72h, BIOSSEG, dummy_isr ; IRQ 11
759 SET_INT_VECTOR 77h, BIOSSEG, dummy_isr ; IRQ 15
760
761 mov ax, EBDA_SEG
762 mov ds, ax
763 mov byte ptr ds:[0], EBDA_SIZE
764 ;; store EBDA seg in 40:0E
765 xor ax, ax
766 mov ds, ax
767 mov word ptr ds:[40Eh], EBDA_SEG
768 ret
769
770ebda_post endp
771
772
773
774;; --------------------------------------------------------
775;; INT 16h handler - Keyboard service
776;; --------------------------------------------------------
777 BIOSORG 0E82Eh
778int16_handler:
779 sti
780 push es
781 push ds
782 pusha
783
784 cmp ah, 0
785 je int16_F00
786
787 cmp ah, 10h
788 je int16_F00
789
790 C_SETUP
791 call _int16_function
792 popa
793 pop ds
794 pop es
795 iret
796
797int16_F00:
798 mov bx, 40h ; TODO: why 40h here and 0 elsewhere?
799 mov ds, bx
800int16_wait_for_key:
801 cli
802 mov bx, ds:[1Ah]
803 cmp bx, ds:[1Ch]
804 jne int16_key_found
805 sti
806 nop
807; TODO: review/enable?
808if 0
809 push ax
810 mov ax, 9002h
811 int 15h
812 pop ax
813endif
814 jmp int16_wait_for_key
815
816int16_key_found:
817 C_SETUP
818 call _int16_function
819 popa
820 pop ds
821 pop es
822; TODO: review/enable? If so, flags should be restored here?
823if 0
824 push ax
825 mov ax, 9202h
826 int 15h
827 pop ax
828endif
829 iret
830
831
832;; Quick and dirty protected mode entry/exit routines
833include pmode.inc
834
835;; Initialization code which needs to run in protected mode (LAPIC etc.)
836include pmsetup.inc
837
838
839KBDC_DISABLE EQU 0ADh
840KBDC_ENABLE EQU 0AEh
841KBC_CMD EQU 64h
842KBC_DATA EQU 60h
843
844;; --------------------------------------------------------
845;; INT 09h handler - Keyboard ISR (IRQ 1)
846;; --------------------------------------------------------
847 BIOSORG 0E987h
848int09_handler:
849 cli ; TODO: why? they're off already!
850 push ax
851 mov al, KBDC_DISABLE
852 out KBC_CMD, al
853
854 mov al, 0Bh
855 out PIC_MASTER, al
856 in al, PIC_MASTER
857 and al, 2
858 jz int09_finish
859
860 in al, KBC_DATA
861 push ds
862 pusha
863 cld ; Before INT 15h (and any C code)
864ifdef BX_CALL_INT15_4F
865 mov ah, 4Fh
866 stc
867 int 15h ; keyboard intercept
868 jnc int09_done
869endif
870 sti ; Only after calling INT 15h
871
872 ;; check for extended key
873 cmp al, 0E0h
874 jne int09_check_pause
875 xor ax, ax
876 mov ds, ax
877 mov al, ds:[496h] ; mf2_state |= 0x02
878 or al, 2 ; TODO: why not RMW?
879 mov ds:[496h], al
880 jmp int09_done
881
882int09_check_pause:
883 cmp al, 0E1h ; pause key?
884 jne int09_process_key
885 xor ax, ax
886 mov ds, ax ; TODO: haven't we just done that??
887 mov al, ds:[496h]
888 or al, 1
889 mov ds:[496h], al ; TODO: why not RMW?
890 jmp int09_done
891
892int09_process_key:
893 push es
894 C_SETUP
895 call _int09_function
896 pop es
897
898int09_done:
899 popa
900 pop ds
901 cli
902 call eoi_master_pic
903
904int09_finish:
905 mov al, KBDC_ENABLE
906 out KBC_CMD, al
907 pop ax
908 iret
909
910
911;; --------------------------------------------------------
912;; INT 13h handler - Diskette service
913;; --------------------------------------------------------
914 BIOSORG 0EC59h
915int13_diskette:
916 jmp int13_noeltorito
917
918
919
920;; --------------------------------------------------------
921;; INT 13h handler - Disk service
922;; --------------------------------------------------------
923int13_relocated:
924 ;; check for an El-Torito function
925 cmp ah, 4Ah
926 jb int13_not_eltorito
927
928 cmp ah, 4Dh
929 ja int13_not_eltorito
930
931 pusha
932 push es
933 push ds
934 C_SETUP ; TODO: setup C envrionment only once?
935 push int13_out ; simulate a call
936 jmp _int13_eltorito ; ELDX not used
937
938int13_not_eltorito:
939 push es
940 push ax ; TODO: better register save/restore
941 push bx
942 push cx
943 push dx
944
945 ;; check if emulation is active
946 call _cdemu_isactive
947 cmp al, 0
948 je int13_cdemu_inactive
949
950 ;; check if access to the emulated drive
951 call _cdemu_emulated_drive
952 pop dx ; recover dx (destroyed by C code)
953 push dx
954 cmp al, dl ; INT 13h on emulated drive
955 jne int13_nocdemu
956
957 pop dx
958 pop cx
959 pop bx
960 pop ax
961 pop es
962
963 pusha
964 push es
965 push ds
966 C_SETUP ; TODO: setup environment only once?
967
968 push int13_out ; simulate a call
969 jmp _int13_cdemu ; ELDX not used
970
971int13_nocdemu:
972 and dl, 0E0h ; mask to get device class
973 cmp al, dl
974 jne int13_cdemu_inactive
975
976 pop dx
977 pop cx
978 pop bx
979 pop ax
980 pop es
981
982 push ax
983 push cx
984 push dx
985 push bx
986
987 dec dl ; real drive is dl - 1
988 jmp int13_legacy
989
990int13_cdemu_inactive:
991 pop dx
992 pop cx
993 pop bx
994 pop ax
995 pop es
996
997int13_noeltorito:
998 push ax
999 push cx
1000 push dx
1001 push bx
1002int13_legacy:
1003 push dx ; push eltorito dx in place of sp
1004 push bp
1005 push si
1006 push di
1007 push es
1008 push ds
1009 C_SETUP ; TODO: setup environment only once?
1010
1011 ;; now the registers can be restored with
1012 ;; pop ds; pop es; popa; iret
1013 test dl, 80h ; non-removable?
1014 jnz int13_notfloppy
1015
1016 push int13_out ; simulate a near call
1017 jmp _int13_diskette_function
1018
1019int13_notfloppy:
1020 cmp dl, 0E0h
1021 jb int13_notcdrom
1022
1023 ;; ebx may be modified, save here
1024 ;; TODO: check/review 32-bit register use
1025 .386
1026 shr ebx, 16
1027 push bx
1028 call _int13_cdrom
1029 pop bx
1030 shl ebx, 16
1031 .286
1032
1033 jmp int13_out
1034
1035int13_notcdrom:
1036int13_disk:
1037 cmp ah,40h
1038 ja int13x
1039 call _int13_harddisk
1040 jmp int13_out
1041
1042int13x:
1043 call _int13_harddisk_ext
1044
1045int13_out:
1046 pop ds
1047 pop es
1048 popa
1049 iret
1050
1051
1052
1053; parallel port detection: port in dx, index in bx, timeout in cl
1054detect_parport proc near
1055
1056 push dx
1057 inc dx
1058 inc dx
1059 in al, dx
1060 and al, 0DFh ; clear input mode
1061 out dx, al
1062 pop dx
1063 mov al, 0AAh
1064 out dx, al
1065 in al, dx
1066 cmp al, 0AAh
1067 jne no_parport
1068
1069 push bx
1070 shl bx, 1
1071 mov [bx+408h], dx ; parallel I/O address
1072 pop bx
1073 mov [bx+478h], cl ; parallel printer timeout
1074 inc bx
1075no_parport:
1076 ret
1077
1078detect_parport endp
1079
1080; setial port detection: port in dx, index in bx, timeout in cl
1081detect_serial proc near
1082
1083 push dx
1084 inc dx
1085 mov al, 2
1086 out dx, al
1087 in al, dx
1088 cmp al, 2
1089 jne no_serial
1090
1091 inc dx
1092 in al, dx
1093 cmp al, 2
1094 jne no_serial
1095
1096 dec dx
1097 xor al, al
1098 pop dx
1099 push bx
1100 shl bx, 1
1101 mov [bx+400h], dx ; serial I/O address
1102 pop bx
1103 mov [bx+47Ch], cl ; serial timeout
1104 inc bx
1105 ret
1106
1107no_serial:
1108 pop dx
1109 ret
1110
1111detect_serial endp
1112
1113
1114;;
1115;; POST: Floppy drive
1116;;
1117floppy_post proc near
1118
1119 xor ax, ax
1120 mov ds, ax
1121
1122 ;; TODO: This code is really stupid. Zeroing the BDA byte
1123 ;; by byte is dumb, and it's been already zeroed elsewhere!
1124 mov al, 0
1125 mov ds:[43Eh], al ; drive 0/1 uncalibrated, no IRQ
1126 mov ds:[43Fh], al ; motor status
1127 mov ds:[440h], al ; motor timeout counter
1128 mov ds:[441h], al ; controller status return code
1129 mov ds:[442h], al ; hd/floppy ctlr status register
1130 mov ds:[443h], al ; controller status register 1
1131 mov ds:[444h], al ; controller status register 2
1132 mov ds:[445h], al ; cylinder number
1133 mov ds:[446h], al ; head number
1134 mov ds:[447h], al ; sector number
1135 mov ds:[448h], al ; bytes written
1136
1137 mov ds:[48Bh], al ; configuration data
1138
1139 mov al, 10h ; floppy drive type
1140 out CMOS_ADDR, al
1141 in al, CMOS_DATA
1142 mov ah, al ; save drive type byte
1143
1144look_drive0:
1145 ; TODO: pre-init bl to reduce jumps
1146 shr al, 4 ; drive 0 in high nibble
1147 jz f0_missing ; jump if no drive
1148 mov bl, 7 ; drv0 determined, multi-rate, chgline
1149 jmp look_drive1
1150
1151f0_missing:
1152 mov bl, 0 ; no drive 0
1153
1154look_drive1:
1155 mov al, ah ; restore CMOS data
1156 and al, 0Fh ; drive 1 in low nibble
1157 jz f1_missing
1158 or bl, 70h ; drv1 determined, multi-rate, chgline
1159f1_missing:
1160 mov ds:[48Fh], bl ; store in BDA
1161
1162 ;; TODO: See above. Dumb *and* redundant!
1163 mov al, 0
1164 mov ds:[490h], al ; drv0 media state
1165 mov ds:[491h], al ; drv1 media state
1166 mov ds:[492h], al ; drv0 operational state
1167 mov ds:[493h], al ; drv1 operational state
1168 mov ds:[494h], al ; drv0 current cylinder
1169 mov ds:[495h], al ; drv1 current cylinder
1170
1171 mov al, 2
1172 out 0Ah, al ; unmask DMA channel 2
1173
1174 SET_INT_VECTOR 1Eh, BIOSSEG, _diskette_param_table
1175 SET_INT_VECTOR 40h, BIOSSEG, int13_diskette
1176 SET_INT_VECTOR 0Eh, BIOSSEG, int0e_handler ; IRQ 6
1177
1178 ret
1179
1180floppy_post endp
1181
1182
1183bcd_to_bin proc near
1184
1185 ;; in : AL in packed BCD format
1186 ;; out: AL in binary, AH always 0
1187 shl ax, 4
1188 shr al, 4
1189 aad
1190 ret
1191
1192bcd_to_bin endp
1193
1194rtc_post proc near
1195
1196 .386
1197 ;; get RTC seconds
1198 xor eax, eax
1199 mov al, 0
1200 out CMOS_ADDR, al
1201 in al, CMOS_DATA ; RTC seconds, in BCD
1202 call bcd_to_bin ; eax now has seconds in binary
1203 mov edx, 18206507
1204 mul edx
1205 mov ebx, 1000000
1206 xor edx, edx
1207 div ebx
1208 mov ecx, eax ; total ticks in ecx
1209
1210 ;; get RTC minutes
1211 xor eax, eax
1212 mov al, 2
1213 out CMOS_ADDR, al
1214 in al, CMOS_DATA ; RTC minutes, in BCD
1215 call bcd_to_bin ; eax now has minutes in binary
1216 mov edx, 10923904
1217 mul edx
1218 mov ebx, 10000
1219 xor edx, edx
1220 div ebx
1221 add ecx, eax ; add to total ticks
1222
1223 ;; get RTC hours
1224 xor eax, eax
1225 mov al, 4
1226 out CMOS_ADDR, al
1227 in al, CMOS_DATA ; RTC hours, in BCD
1228 call bcd_to_bin ; eax now has hours in binary
1229 mov edx, 65543427
1230 mul edx
1231 mov ebx, 1000
1232 xor edx, edx
1233 div ebx
1234 add ecx, eax ; add to total ticks
1235
1236 mov ds:[46Ch], ecx ; timer tick count
1237 xor al, al ; TODO: redundant?
1238 mov ds:[470h], al ; rollover flag
1239 .286
1240 ret
1241
1242rtc_post endp
1243
1244
1245
1246;; --------------------------------------------------------
1247;; INT 0Eh handler - Diskette IRQ 6 ISR
1248;; --------------------------------------------------------
1249 BIOSORG 0EF57h
1250int0e_handler:
1251 push ax
1252 push dx
1253 mov dx, 3F4h
1254 in al, dx
1255 and al, 0C0h
1256 cmp al, 0C0h
1257 je int0e_normal
1258 mov dx, 3F5h
1259 mov al, 08h ; sense interrupt
1260 out dx, al
1261int0e_loop1:
1262 mov dx, 3F4h ; TODO: move out of the loop?
1263 in al, dx
1264 and al, 0C0h
1265 cmp al, 0C0h
1266 jne int0e_loop1
1267
1268int0e_loop2:
1269 mov dx, 3F5h ; TODO: inc/dec dx instead
1270 in al, dx
1271 mov dx, 3F4h
1272 in al, dx
1273 and al, 0C0h
1274 cmp al, 0C0h
1275 je int0e_loop2
1276
1277int0e_normal:
1278 push ds
1279 xor ax, ax
1280 mov ds, ax
1281 call eoi_master_pic
1282 ; indicate that an interrupt occurred
1283 or byte ptr ds:[43Eh], 80h
1284 pop ds
1285 pop dx
1286 pop ax
1287 iret
1288
1289
1290;; --------------------------------------------------------
1291;; Diskette Parameter Table
1292;; --------------------------------------------------------
1293 BIOSORG 0EFC7h
1294_diskette_param_table:
1295 db 0AFh
1296 db 2 ; HLT=1, DMA mode
1297 db 025h
1298 db 2
1299 db 18 ; SPT (good for 1.44MB media)
1300 db 01Bh
1301 db 0FFh
1302 db 06Ch
1303 db 0F6h ; format filler
1304 db 15
1305 db 8
1306
1307
1308
1309;; --------------------------------------------------------
1310;; INT 17h handler - Printer service
1311;; --------------------------------------------------------
1312;; BIOSORG 0EFD2h - fixed WRT preceding code
1313int17_handler:
1314 push ds
1315 push es
1316 pusha
1317 C_SETUP
1318 call _int17_function
1319 popa
1320 pop es
1321 pop ds
1322 iret
1323
1324
1325
1326;; Protected mode IDT descriptor
1327;;
1328;; The limit is 0 to cause a shutdown if an exception occurs
1329;; in protected mode. TODO: Is that what we really want?
1330;;
1331;; Set base to F0000 to correspond to beginning of BIOS,
1332;; in case an IDT is defined later.
1333
1334_pmode_IDT:
1335 dw 0 ; limit 15:0
1336 dw 0 ; base 15:0
1337 dw 0Fh ; base 23:16
1338
1339
1340;; Real mode IDT descriptor
1341;;
1342;; Set to typical real-mode values.
1343;; base = 000000
1344;; limit = 03ff
1345
1346_rmode_IDT:
1347 dw 3FFh ; limit 15:00
1348 dw 0 ; base 15:00
1349 dw 0 ; base 23:16
1350
1351
1352;;
1353;; INT 1Ch
1354;;
1355;; TODO: Why does this need a special handler?
1356int1c_handler: ;; user timer tick
1357 iret
1358
1359
1360
1361;; --------------------------------------------------------
1362;; INT 10h functions 0-Fh entry point
1363;; --------------------------------------------------------
1364 BIOSORG 0F045h
1365i10f0f_entry:
1366 iret
1367
1368
1369;; --------------------------------------------------------
1370;; INT 10h handler - MDA/CGA video
1371;; --------------------------------------------------------
1372 BIOSORG 0F065h
1373int10_handler:
1374 ;; do nothing - assumes VGA
1375 iret
1376
1377
1378;; --------------------------------------------------------
1379;; MDA/CGA Video Parameter Table (INT 1Dh)
1380;; --------------------------------------------------------
1381 BIOSORG 0F0A4h
1382mdacga_vpt:
1383
1384
1385;;
1386;; INT 18h - boot failure
1387;;
1388int18_handler:
1389 C_SETUP
1390 call _int18_panic_msg
1391 ;; TODO: handle failure better?
1392 hlt
1393 iret
1394
1395;;
1396;; INT 19h - boot service - relocated
1397;;
1398int19_relocated:
1399; If an already booted OS calls int 0x19 to reboot, it is not sufficient
1400; just to try booting from the configured drives. All BIOS variables and
1401; interrupt vectors need to be reset, otherwise strange things may happen.
1402; The approach used is faking a warm reboot (which just skips showing the
1403; logo), which is a bit more than what we need, but hey, it's fast.
1404 mov bp, sp
1405 mov ax, [bp+2] ; TODO: redundant? address via sp?
1406 cmp ax, BIOSSEG ; check caller's segment
1407 jz bios_initiated_boot
1408
1409 xor ax, ax
1410 mov ds, ax
1411 mov ax, 1234h
1412 mov ds:[472], ax
1413 jmp post
1414
1415bios_initiated_boot:
1416 ;; The C worker function returns the boot drive in bl and
1417 ;; the boot segment in ax. In case of failure, the boot
1418 ;; segment will be zero.
1419 C_SETUP ; TODO: Here? Now?
1420 push bp
1421 mov bp, sp
1422
1423 ;; 1st boot device
1424 mov ax, 1
1425 push ax
1426 call _int19_function
1427 inc sp
1428 inc sp
1429 test ax, ax ; if 0, try next device
1430 jnz boot_setup
1431
1432 ;; 2nd boot device
1433 mov ax, 2
1434 push ax
1435 call _int19_function
1436 inc sp
1437 inc sp
1438 test ax, ax ; if 0, try next device
1439 jnz boot_setup
1440
1441 ; 3rd boot device
1442 mov ax, 3
1443 push 3
1444 call _int19_function
1445 inc sp
1446 inc sp
1447 test ax, ax ; if 0, try next device
1448 jnz boot_setup
1449
1450 ; 4th boot device
1451 mov ax, 4
1452 push ax
1453 call _int19_function
1454 inc sp
1455 inc sp
1456 test ax, ax ; if 0, invoke INT 18h
1457 jz int18_handler
1458
1459boot_setup:
1460; TODO: the drive should be in dl already??
1461;; mov dl, bl ; tell guest OS what boot drive is
1462 .386 ; NB: We're getting garbage into high eax bits
1463 shl eax, 4 ; convert seg to ip
1464 mov [bp+2], ax ; set ip
1465
1466 shr eax, 4 ; get cs back
1467 .286
1468 and ax, BIOSSEG ; remove what went in ip
1469 mov [bp+4], ax ; set cs
1470 xor ax, ax
1471 mov ds, ax
1472 mov es, ax
1473 mov [bp], ax ; TODO: what's this?!
1474 mov ax, 0AA55h ; set ok flag ; TODO: and this?
1475
1476 pop bp ; TODO: why'd we just zero it??
1477 iret ; beam me up scotty
1478
1479;; PCI BIOS
1480
1481include pcibios.inc
1482include pirq.inc
1483
1484
1485;; --------------------------------------------------------
1486;; INT 12h handler - Memory size
1487;; --------------------------------------------------------
1488 BIOSORG 0F841h
1489int12_handler:
1490 ;; Don't touch - fixed size!
1491 sti
1492 push ds
1493 mov ax, 40h
1494 mov ds, ax
1495 mov ax, ds:[13h]
1496 pop ds
1497 iret
1498
1499
1500;; --------------------------------------------------------
1501;; INT 11h handler - Equipment list service
1502;; --------------------------------------------------------
1503;; BIOSORG 0F84Dh - fixed wrt preceding code
1504int11_handler:
1505 ;; Don't touch - fixed size!
1506 sti
1507 push ds
1508 mov ax, 40h
1509 mov ds, ax
1510 mov ax, ds:[10h]
1511 pop ds
1512 iret
1513
1514
1515;; --------------------------------------------------------
1516;; INT 15h handler - System services
1517;; --------------------------------------------------------
1518;; BIOSORG 0F859h - fixed wrt preceding code
1519int15_handler:
1520 pushf
1521 cmp ah, 53h ; APM function?
1522 je apm_call
1523 push ds
1524 push es
1525 C_SETUP
1526 cmp ah, 86h
1527 je int15_handler32
1528 cmp ah, 0E8h
1529 je int15_handler32
1530 pusha
1531 cmp ah, 0C2h
1532 je int15_handler_mouse
1533
1534 call _int15_function
1535int15_handler_mouse_ret:
1536 popa
1537int15_handler32_ret:
1538 pop es
1539 pop ds
1540 popf
1541 jmp iret_modify_cf
1542
1543apm_call:
1544; TODO!!
1545 popf
1546 stc
1547 jmp iret_modify_cf
1548; jmp apmreal_entry
1549
1550int15_handler_mouse:
1551 call _int15_function_mouse
1552 jmp int15_handler_mouse_ret
1553
1554int15_handler32:
1555 ;; need to save/restore 32-bit registers
1556 .386
1557 pushad
1558 call _int15_function32
1559 popad
1560 .286
1561 jmp int15_handler32_ret
1562
1563;;
1564;; Perform an IRET but retain the current carry flag value
1565;;
1566iret_modify_cf:
1567 jc carry_set
1568 push bp
1569 mov bp, sp
1570 and byte ptr [bp + 6], 0FEh
1571 pop bp
1572 iret
1573carry_set:
1574 push bp
1575 mov bp, sp
1576 or byte ptr [bp + 6], 1
1577 pop bp
1578 iret
1579
1580;;
1581;; INT 74h handler - PS/2 mouse (IRQ 12)
1582;;
1583int74_handler proc
1584
1585 sti
1586 pusha
1587 push es
1588 push ds
1589 push 0 ; placeholder for status
1590 push 0 ; placeholder for X
1591 push 0 ; placeholder for Y
1592 push 0 ; placeholder for Z
1593 push 0 ; placeholder for make_far_call bool
1594 C_SETUP
1595 call _int74_function
1596 pop cx ; pop make_far_call flag
1597 jcxz int74_done
1598
1599 ;; make far call to EBDA:0022
1600 push 0
1601 pop ds
1602 push ds:[40Eh]
1603 pop ds
1604 call far ptr ds:[22h]
1605int74_done:
1606 cli
1607 call eoi_both_pics
1608 add sp, 8 ; remove status, X, Y, Z
1609 pop ds
1610 pop es
1611 popa
1612 iret
1613
1614int74_handler endp
1615
1616int76_handler proc
1617
1618 ;; record completion in BIOS task complete flag
1619 push ax
1620 push ds
1621 mov ax, 40h
1622 mov ds, ax
1623 mov byte ptr ds:[8Eh], 0FFh
1624 call eoi_both_pics
1625 pop ds
1626 pop ax
1627 iret
1628
1629int76_handler endp
1630
1631;; --------------------------------------------------------
1632;; 8x8 font (first 128 characters)
1633;; --------------------------------------------------------
1634 BIOSORG 0FA6Eh
1635include font8x8.inc
1636
1637
1638;; --------------------------------------------------------
1639;; INT 1Ah handler - Time of the day + PCI BIOS
1640;; --------------------------------------------------------
1641;; BIOSORG 0FE6Eh - fixed wrt preceding table
1642int1a_handler:
1643 cmp ah, 0B1h
1644 jne int1a_normal
1645
1646 push es
1647 push ds
1648 C_SETUP
1649 .386
1650 pushad
1651 call _pci16_function
1652 popad
1653 .286
1654 pop ds
1655 pop es
1656 iret
1657
1658int1a_normal:
1659 push es
1660 push ds
1661 pusha
1662 C_SETUP
1663int1a_callfunction:
1664 call _int1a_function
1665 popa
1666 pop ds
1667 pop es
1668 iret
1669
1670
1671;;
1672;; IRQ 8 handler (RTC)
1673;;
1674int70_handler:
1675 push es
1676 push ds
1677 pusha
1678 C_SETUP
1679 call _int70_function
1680 popa
1681 pop ds
1682 pop es
1683 iret
1684
1685
1686;; --------------------------------------------------------
1687;; Timer tick - IRQ 0 handler
1688;; --------------------------------------------------------
1689 BIOSORG 0FEA5h
1690int08_handler:
1691 .386
1692 sti
1693 push eax
1694 push ds
1695 xor ax, ax
1696 mov ds, ax
1697
1698 ;; time to turn off floppy driv motor(s)?
1699 mov al, ds:[440h]
1700 or al, al
1701 jz int08_floppy_off
1702 ;; turn motor(s) off
1703 push dx
1704 mov dx, 03F2h
1705 in al, dx
1706 and al, 0CFh
1707 out dx, al
1708 pop dx
1709
1710int08_floppy_off:
1711 mov eax, ds:[46Ch] ; get ticks dword
1712 inc eax
1713
1714 ;; compare eax to one day's worth of ticks (at 18.2 Hz)
1715 cmp eax, 1800B0h
1716 jb int08_store_ticks
1717 ;; there has been a midnight rollover
1718 xor eax, eax
1719 inc byte ptr ds:[470h] ; increment rollover flag
1720
1721int08_store_ticks:
1722 mov ds:[46Ch], eax
1723 int 1Ch ; call the user timer handler
1724 cli
1725 call eoi_master_pic
1726 pop ds
1727 pop eax
1728 .286
1729 iret
1730
1731
1732;; --------------------------------------------------------
1733;; Initial interrupt vector offsets for POST
1734;; --------------------------------------------------------
1735 BIOSORG 0FEF3h
1736vector_table:
1737
1738
1739
1740;; --------------------------------------------------------
1741;; BIOS copyright string
1742;; --------------------------------------------------------
1743 BIOSORG 0FF00h
1744bios_string:
1745 db BIOS_COPYRIGHT
1746
1747
1748;; --------------------------------------------------------
1749;; IRET - default interrupt handler
1750;; --------------------------------------------------------
1751 BIOSORG 0FF53h
1752
1753dummy_iret:
1754 iret
1755
1756
1757;; --------------------------------------------------------
1758;; INT 05h - Print Screen service
1759;; --------------------------------------------------------
1760;; BIOSORG 0FF54h - fixed wrt preceding
1761int05_handler:
1762 ;; Not implemented
1763 iret
1764
1765include smidmi.inc
1766
1767;; --------------------------------------------------------
1768;; Processor reset entry point
1769;; --------------------------------------------------------
1770 BIOSORG 0FFF0h
1771cpu_reset:
1772 ;; This is where the CPU starts executing after a reset
1773 jmp far ptr post
1774
1775 ;; BIOS build date
1776 db BIOS_BUILD_DATE
1777 db 0 ; padding
1778 ;; System model ID
1779 db SYS_MODEL_ID
1780 ;; Checksum byte
1781 db 0FFh
1782
1783
1784BIOSSEG ends
1785
1786 end
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette