source: xtideuniversalbios/trunk/Assembly_Library/Inc/SystemTimer.inc@ 618

Last change on this file since 618 was 589, checked in by Krister Nordvall, 9 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 4.9 KB
Line 
1; Project name : Assembly Library
2; Description : System Timer (8254) related equates and macros.
3%ifndef SYSTEMTIMER_INC
4%define SYSTEMTIMER_INC
5
6; Timer/Counter to program
7TIMER_0 EQU (0<<6)
8TIMER_1 EQU (1<<6)
9TIMER_2 EQU (2<<6)
10
11; Counter commands
12LATCH EQU (0<<4) ; Counter Latch Command (latches the count for reading)
13READ_OR_WRITE_LSB_ONLY EQU (1<<4) ; MSB is always zero
14READ_OR_WRITE_MSB_ONLY EQU (2<<4) ; LSB is always zero
15READ_OR_WRITE_LSB_THEN_MSB EQU (3<<4)
16
17; Timer modes
18MODE_0_SINGLE_TIMEOUT EQU (0<<1) ; Interrupt on Terminal Count
19MODE_1_ONE_SHOT EQU (1<<1) ; Hardware Retriggerable One-Shot
20MODE_2_RATE_GENERATOR EQU (2<<1)
21MODE_3_SQUARE_WAVE_MODE EQU (3<<1)
22MODE_4_SOFTWARE_TRIGGERED_STROBE EQU (4<<1)
23MODE_5_HARDWARE_RETRIGGERABLE_STROBE EQU (5<<1)
24
25; Binary / BCD Mode
26BINARY_COUNTER EQU 0
27BCD_COUNTER EQU 1
28
29
30; Ports
31COUNT_REGISTER_0 EQU 40h ; Timer 0 Count Register (System Timer Ticks)
32COUNT_REGISTER_1 EQU 41h ; Timer 1 Count Register (DRAM Refresh)
33COUNT_REGISTER_2 EQU 42h ; Timer 2 Count Register (General Use)
34CONTROL_WORD_REGISTER_out EQU 43h
35
36; Timer 2 is connected to PC Speaker that can be controlled from port 61h.
37SPEAKER_CONTROL_REGISTER EQU 61h
38FLG_TIMER_2_OUTPUT_in EQU (1<<5) ; AT+ only
39FLG_SPEAKER_DATA_ENABLED EQU (1<<1)
40FLG_SPEAKER_GATE_TIMER_2_ON EQU (1<<0)
41
42
43; The duration of one tick
44TIMER_CYCLE_TIME EQU 838 ; nanosecs
45
46
47
48
49;--------------------------------------------------------------------
50; OUTPUT_COUNTER_COMMAND_TO
51; Parameters:
52; %1: TIMER_0, TIMER_1 or TIMER_2
53; %2: Command to counter
54; %3: Timer mode
55; %4: BINARY_COUNTER or BCD_COUNTER
56; Returns:
57; Nothing
58; Corrupts registers:
59; AL
60;--------------------------------------------------------------------
61%macro OUTPUT_COUNTER_COMMAND_TO 4
62 mov al, %1 | %2 | %3 | %4
63 out CONTROL_WORD_REGISTER_out, al
64%endmacro
65
66
67;--------------------------------------------------------------------
68; WRITE_COUNT_FROM_AL_TO
69; WRITE_COUNT_FROM_AX_TO
70; Parameters:
71; %1: TIMER_0, TIMER_1 or TIMER_2
72; AX: Count to write to timer
73; Returns:
74; Nothing
75; Corrupts registers:
76; AL (WRITE_COUNT_FROM_AX_TO only)
77;--------------------------------------------------------------------
78%macro WRITE_COUNT_FROM_AL_TO 1
79 %ifidni %1, TIMER_0
80 out COUNT_REGISTER_0, al
81 %elifidni %1, TIMER_1
82 out COUNT_REGISTER_1, al
83 %elifidni %1, TIMER_2
84 out COUNT_REGISTER_2, al
85 %else
86 %error "Invalid timer name passed to WRITE_COUNT_FROM_AL_TO"
87 %endif
88%endmacro
89
90%macro WRITE_COUNT_FROM_AX_TO 1
91 %ifidni %1, TIMER_0
92 out COUNT_REGISTER_0, al
93 mov al, ah
94 out COUNT_REGISTER_0, al
95 %elifidni %1, TIMER_1
96 out COUNT_REGISTER_1, al
97 mov al, ah
98 out COUNT_REGISTER_1, al
99 %elifidni %1, TIMER_2
100 out COUNT_REGISTER_2, al
101 mov al, ah
102 out COUNT_REGISTER_2, al
103 %else
104 %error "Invalid timer name passed to WRITE_COUNT_FROM_AX_TO"
105 %endif
106%endmacro
107
108
109;--------------------------------------------------------------------
110; READ_COUNT_TO_AL_FROM
111; READ_COUNT_TO_AX_FROM
112; Parameters:
113; %1: TIMER_0, TIMER_1 or TIMER_2
114; Returns:
115; AL/AX: Counter value
116; Corrupts registers:
117; Nothing
118;--------------------------------------------------------------------
119%macro READ_COUNT_TO_AL_FROM 1
120 %ifidni %1, TIMER_0
121 in al, COUNT_REGISTER_0
122 %elifidni %1, TIMER_1
123 in al, COUNT_REGISTER_1
124 %elifidni %1, TIMER_2
125 in al, COUNT_REGISTER_2
126 %else
127 %error "Invalid timer name passed to READ_COUNT_TO_AL_FROM"
128 %endif
129%endmacro
130
131%macro READ_COUNT_TO_AX_FROM 1
132 %ifidni %1, TIMER_0
133 in al, COUNT_REGISTER_0
134 mov ah, al
135 in al, COUNT_REGISTER_0
136 %elifidni %1, TIMER_1
137 in al, COUNT_REGISTER_1
138 mov ah, al
139 in al, COUNT_REGISTER_1
140 %elifidni %1, TIMER_2
141 in al, COUNT_REGISTER_2
142 mov ah, al
143 in al, COUNT_REGISTER_2
144 %else
145 %error "Invalid timer name passed to READ_COUNT_TO_AX_FROM"
146 %endif
147 xchg al, ah
148%endmacro
149
150
151;--------------------------------------------------------------------
152; START_PRECISE_EVENT_TIMER
153; Parameters:
154; Nothing
155; Returns:
156; Nothing
157; Corrupts registers:
158; AL
159;--------------------------------------------------------------------
160%macro START_PRECISE_EVENT_TIMER 0
161 in al, SPEAKER_CONTROL_REGISTER
162 or al, FLG_SPEAKER_GATE_TIMER_2_ON
163 out SPEAKER_CONTROL_REGISTER, al
164%endmacro
165
166
167;--------------------------------------------------------------------
168; STOP_PRECISE_EVENT_TIMER
169; Parameters:
170; Nothing
171; Returns:
172; Nothing
173; Corrupts registers:
174; AL
175;--------------------------------------------------------------------
176%macro STOP_PRECISE_EVENT_TIMER 0
177 in al, SPEAKER_CONTROL_REGISTER
178 and al, ~(FLG_SPEAKER_DATA_ENABLED | FLG_SPEAKER_GATE_TIMER_2_ON)
179 out SPEAKER_CONTROL_REGISTER, al
180%endmacro
181
182
183%endif ; SYSTEMTIMER_INC
Note: See TracBrowser for help on using the repository browser.