|
@@ -36,10 +36,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
36
|
36
|
#include <rtc.h>
|
37
|
37
|
#include <ipxe/entropy.h>
|
38
|
38
|
|
39
|
|
-/** RTC "interrupt triggered" flag */
|
40
|
|
-static uint8_t __text16 ( rtc_flag );
|
41
|
|
-#define rtc_flag __use_text16 ( rtc_flag )
|
42
|
|
-
|
43
|
39
|
/** RTC interrupt handler */
|
44
|
40
|
extern void rtc_isr ( void );
|
45
|
41
|
|
|
@@ -58,23 +54,24 @@ static void rtc_hook_isr ( void ) {
|
58
|
54
|
/* Preserve registers */
|
59
|
55
|
"pushw %%ax\n\t"
|
60
|
56
|
/* Set "interrupt triggered" flag */
|
61
|
|
- "cs movb $0x01, %c0\n\t"
|
|
57
|
+ "movb $0x01, %%cs:rtc_flag\n\t"
|
62
|
58
|
/* Read RTC status register C to
|
63
|
59
|
* acknowledge interrupt
|
64
|
60
|
*/
|
65
|
|
- "movb %3, %%al\n\t"
|
66
|
|
- "outb %%al, %1\n\t"
|
67
|
|
- "inb %2\n\t"
|
|
61
|
+ "movb %2, %%al\n\t"
|
|
62
|
+ "outb %%al, %0\n\t"
|
|
63
|
+ "inb %1\n\t"
|
68
|
64
|
/* Send EOI */
|
69
|
65
|
"movb $0x20, %%al\n\t"
|
70
|
66
|
"outb %%al, $0xa0\n\t"
|
71
|
67
|
"outb %%al, $0x20\n\t"
|
72
|
68
|
/* Restore registers and return */
|
73
|
69
|
"popw %%ax\n\t"
|
74
|
|
- "iret\n\t" )
|
|
70
|
+ "iret\n\t"
|
|
71
|
+ "\nrtc_flag:\n\t"
|
|
72
|
+ ".byte 0\n\t" )
|
75
|
73
|
:
|
76
|
|
- : "p" ( __from_text16 ( &rtc_flag ) ),
|
77
|
|
- "i" ( CMOS_ADDRESS ), "i" ( CMOS_DATA ),
|
|
74
|
+ : "i" ( CMOS_ADDRESS ), "i" ( CMOS_DATA ),
|
78
|
75
|
"i" ( RTC_STATUS_C ) );
|
79
|
76
|
|
80
|
77
|
hook_bios_interrupt ( RTC_INT, ( intptr_t ) rtc_isr, &rtc_old_handler );
|
|
@@ -167,9 +164,9 @@ uint8_t rtc_sample ( void ) {
|
167
|
164
|
REAL_CODE ( /* Enable interrupts */
|
168
|
165
|
"sti\n\t"
|
169
|
166
|
/* Wait for RTC interrupt */
|
170
|
|
- "cs movb %b2, %c4\n\t"
|
|
167
|
+ "movb %b2, %%cs:rtc_flag\n\t"
|
171
|
168
|
"\n1:\n\t"
|
172
|
|
- "cs xchgb %b2, %c4\n\t" /* Serialize */
|
|
169
|
+ "xchgb %b2, %%cs:rtc_flag\n\t" /* Serialize */
|
173
|
170
|
"testb %b2, %b2\n\t"
|
174
|
171
|
"jz 1b\n\t"
|
175
|
172
|
/* Read "before" TSC */
|
|
@@ -178,9 +175,9 @@ uint8_t rtc_sample ( void ) {
|
178
|
175
|
"pushl %0\n\t"
|
179
|
176
|
/* Wait for another RTC interrupt */
|
180
|
177
|
"xorb %b2, %b2\n\t"
|
181
|
|
- "cs movb %b2, %c4\n\t"
|
|
178
|
+ "movb %b2, %%cs:rtc_flag\n\t"
|
182
|
179
|
"\n1:\n\t"
|
183
|
|
- "cs xchgb %b2, %c4\n\t" /* Serialize */
|
|
180
|
+ "xchgb %b2, %%cs:rtc_flag\n\t" /* Serialize */
|
184
|
181
|
"testb %b2, %b2\n\t"
|
185
|
182
|
"jz 1b\n\t"
|
186
|
183
|
/* Read "after" TSC */
|
|
@@ -191,7 +188,7 @@ uint8_t rtc_sample ( void ) {
|
191
|
188
|
"cli\n\t"
|
192
|
189
|
)
|
193
|
190
|
: "=a" ( after ), "=d" ( before ), "=q" ( temp )
|
194
|
|
- : "2" ( 0 ), "p" ( __from_text16 ( &rtc_flag ) ) );
|
|
191
|
+ : "2" ( 0 ) );
|
195
|
192
|
|
196
|
193
|
return ( after - before );
|
197
|
194
|
}
|