Browse Source

[bios] Allow librm to be compiled for x86_64

This commit does not make librm functional for x86_64; it merely
allows it to compile without errors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
1a457e933a

+ 12
- 3
src/arch/i386/include/librm.h View File

173
 extern uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size );
173
 extern uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size );
174
 extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
174
 extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
175
 
175
 
176
+/* CODE_DEFAULT: restore default .code32/.code64 directive */
177
+#ifdef __x86_64__
178
+#define CODE_DEFAULT ".code64"
179
+#else
180
+#define CODE_DEFAULT ".code32"
181
+#endif
182
+
176
 /* TEXT16_CODE: declare a fragment of code that resides in .text16 */
183
 /* TEXT16_CODE: declare a fragment of code that resides in .text16 */
177
 #define TEXT16_CODE( asm_code_str )			\
184
 #define TEXT16_CODE( asm_code_str )			\
178
 	".section \".text16\", \"ax\", @progbits\n\t"	\
185
 	".section \".text16\", \"ax\", @progbits\n\t"	\
179
 	".code16\n\t"					\
186
 	".code16\n\t"					\
180
 	asm_code_str "\n\t"				\
187
 	asm_code_str "\n\t"				\
181
-	".code32\n\t"					\
188
+	CODE_DEFAULT "\n\t"				\
182
 	".previous\n\t"
189
 	".previous\n\t"
183
 
190
 
184
 /* REAL_CODE: declare a fragment of code that executes in real mode */
191
 /* REAL_CODE: declare a fragment of code that executes in real mode */
185
 #define REAL_CODE( asm_code_str )			\
192
 #define REAL_CODE( asm_code_str )			\
186
-	"pushl $1f\n\t"					\
193
+	"push $1f\n\t"					\
187
 	"call real_call\n\t"				\
194
 	"call real_call\n\t"				\
188
 	"addl $4, %%esp\n\t"				\
195
 	"addl $4, %%esp\n\t"				\
189
 	TEXT16_CODE ( "\n1:\n\t"			\
196
 	TEXT16_CODE ( "\n1:\n\t"			\
194
 /* PHYS_CODE: declare a fragment of code that executes in flat physical mode */
201
 /* PHYS_CODE: declare a fragment of code that executes in flat physical mode */
195
 #define PHYS_CODE( asm_code_str )			\
202
 #define PHYS_CODE( asm_code_str )			\
196
 	"call _virt_to_phys\n\t"			\
203
 	"call _virt_to_phys\n\t"			\
204
+	".code32\n\t"					\
197
 	asm_code_str					\
205
 	asm_code_str					\
198
-	"call _phys_to_virt\n\t"
206
+	"call _phys_to_virt\n\t"			\
207
+	CODE_DEFAULT "\n\t"
199
 
208
 
200
 /** Number of interrupts */
209
 /** Number of interrupts */
201
 #define NUM_INT 256
210
 #define NUM_INT 256

+ 5
- 5
src/arch/i386/transitions/librm_mgmt.c View File

80
 	idte = &idt[intr];
80
 	idte = &idt[intr];
81
 	idte->segment = VIRTUAL_CS;
81
 	idte->segment = VIRTUAL_CS;
82
 	idte->attr = ( vector ? ( IDTE_PRESENT | IDTE_TYPE_IRQ32 ) : 0 );
82
 	idte->attr = ( vector ? ( IDTE_PRESENT | IDTE_TYPE_IRQ32 ) : 0 );
83
-	idte->low = ( ( ( uint32_t ) vector ) & 0xffff );
84
-	idte->high = ( ( ( uint32_t ) vector ) >> 16 );
83
+	idte->low = ( ( ( intptr_t ) vector ) & 0xffff );
84
+	idte->high = ( ( ( intptr_t ) vector ) >> 16 );
85
 }
85
 }
86
 
86
 
87
 /**
87
 /**
99
 		vec->movb = MOVB_INSN;
99
 		vec->movb = MOVB_INSN;
100
 		vec->intr = intr;
100
 		vec->intr = intr;
101
 		vec->jmp = JMP_INSN;
101
 		vec->jmp = JMP_INSN;
102
-		vec->offset = ( ( uint32_t ) interrupt_wrapper -
103
-				( uint32_t ) vec->next );
102
+		vec->offset = ( ( intptr_t ) interrupt_wrapper -
103
+				( intptr_t ) vec->next );
104
 		set_interrupt_vector ( intr, vec );
104
 		set_interrupt_vector ( intr, vec );
105
 	}
105
 	}
106
 	DBGC ( &intr_vec[0], "INTn vector at %p+%zxn (phys %#lx+%zxn)\n",
106
 	DBGC ( &intr_vec[0], "INTn vector at %p+%zxn (phys %#lx+%zxn)\n",
132
  *
132
  *
133
  * @v intr		Interrupt number
133
  * @v intr		Interrupt number
134
  */
134
  */
135
-void __attribute__ (( cdecl, regparm ( 1 ) )) interrupt ( int intr ) {
135
+void __attribute__ (( regparm ( 1 ) )) interrupt ( int intr ) {
136
 	struct profiler *profiler = interrupt_profiler ( intr );
136
 	struct profiler *profiler = interrupt_profiler ( intr );
137
 	uint32_t discard_eax;
137
 	uint32_t discard_eax;
138
 
138
 

+ 13
- 7
src/arch/i386/transitions/librm_test.c View File

69
 static void librm_test_exec ( void ) {
69
 static void librm_test_exec ( void ) {
70
 	unsigned int i;
70
 	unsigned int i;
71
 	unsigned long timestamp;
71
 	unsigned long timestamp;
72
-	unsigned long started;
73
-	unsigned long stopped;
74
-	unsigned int discard_d;
72
+	uint32_t timestamp_lo;
73
+	uint32_t timestamp_hi;
74
+	uint32_t started;
75
+	uint32_t stopped;
76
+	uint32_t discard_d;
75
 
77
 
76
 	/* Profile mode transitions.  We want to profile each
78
 	/* Profile mode transitions.  We want to profile each
77
 	 * direction of the transition separately, so perform an RDTSC
79
 	 * direction of the transition separately, so perform an RDTSC
81
 	for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
83
 	for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
82
 		profile_start ( &p2r_profiler );
84
 		profile_start ( &p2r_profiler );
83
 		__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t" )
85
 		__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t" )
84
-				       : "=a" ( timestamp ), "=d" ( discard_d )
86
+				       : "=a" ( timestamp_lo ),
87
+					 "=d" ( timestamp_hi )
85
 				       : );
88
 				       : );
89
+		timestamp = timestamp_lo;
90
+		if ( sizeof ( timestamp ) > sizeof ( timestamp_lo ) )
91
+			timestamp |= ( ( ( uint64_t ) timestamp_hi ) << 32 );
86
 		profile_start_at ( &r2p_profiler, timestamp );
92
 		profile_start_at ( &r2p_profiler, timestamp );
87
 		profile_stop ( &r2p_profiler );
93
 		profile_stop ( &r2p_profiler );
88
 		profile_stop_at ( &p2r_profiler, timestamp );
94
 		profile_stop_at ( &p2r_profiler, timestamp );
98
 	/* Profile complete protected-mode call cycle */
104
 	/* Profile complete protected-mode call cycle */
99
 	for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
105
 	for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
100
 		__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
106
 		__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
101
-						   "movl %0, %2\n\t"
102
-						   "pushl %3\n\t"
107
+						   "movl %k0, %k2\n\t"
108
+						   "pushl %k3\n\t"
103
 						   "pushw %%cs\n\t"
109
 						   "pushw %%cs\n\t"
104
 						   "call prot_call\n\t"
110
 						   "call prot_call\n\t"
105
 						   "addw $4, %%sp\n\t"
111
 						   "addw $4, %%sp\n\t"
106
 						   "rdtsc\n\t" )
112
 						   "rdtsc\n\t" )
107
 				       : "=a" ( stopped ), "=d" ( discard_d ),
113
 				       : "=a" ( stopped ), "=d" ( discard_d ),
108
-					 "=r" ( started )
114
+					 "=R" ( started )
109
 				       : "i" ( librm_test_prot_call ) );
115
 				       : "i" ( librm_test_prot_call ) );
110
 		profile_start_at ( &prot_call_profiler, started );
116
 		profile_start_at ( &prot_call_profiler, started );
111
 		profile_stop_at ( &prot_call_profiler, stopped );
117
 		profile_stop_at ( &prot_call_profiler, stopped );

Loading…
Cancel
Save