Browse Source

[bios] Allow rtc_entropy.c to be compiled for x86_64

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
9c58ba2cd7
1 changed files with 13 additions and 16 deletions
  1. 13
    16
      src/arch/i386/interface/pcbios/rtc_entropy.c

+ 13
- 16
src/arch/i386/interface/pcbios/rtc_entropy.c View File

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

Loading…
Cancel
Save