Browse Source

Split out REAL_CODE() from REAL_EXEC(), preparatory to removing REAL_EXEC

completely.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
7a53d07027
2 changed files with 35 additions and 31 deletions
  1. 20
    19
      src/arch/i386/include/libkir.h
  2. 15
    12
      src/arch/i386/include/librm.h

+ 20
- 19
src/arch/i386/include/libkir.h View File

@@ -213,31 +213,32 @@ virt_to_user ( void * virtual ) {
213 213
 #define BASEMEM_PARAMETER_INIT BASEMEM_PARAMETER_INIT_LIBKIR
214 214
 #define BASEMEM_PARAMETER_DONE BASEMEM_PARAMETER_DONE_LIBKIR
215 215
 
216
+/* REAL_CODE: declare a fragment of code that executes in real mode */
217
+#define REAL_CODE( asm_code_str )	\
218
+	".code16\n\t"			\
219
+	"pushw %%gs\n\t"		\
220
+	"pushw %%fs\n\t"		\
221
+	"pushw %%es\n\t"		\
222
+	"pushw %%ds\n\t"		\
223
+	asm_code_str			\
224
+	"popw %%ds\n\t"			\
225
+	"popw %%es\n\t"			\
226
+	"popw %%fs\n\t"			\
227
+	"popw %%gs\n\t"			\
228
+	".code16gcc\n\t"
229
+
216 230
 /* REAL_EXEC: execute some inline assembly code in a way that matches
217 231
  * the interface of librm
218 232
  */
219 233
 #define OUT_CONSTRAINTS(...) __VA_ARGS__
220 234
 #define IN_CONSTRAINTS(...)  __VA_ARGS__
221 235
 #define CLOBBER(...) __VA_ARGS__
222
-#define REAL_EXEC( name, asm_code_str, num_out_constraints, out_constraints, \
223
-		   in_constraints, clobber )				     \
224
-	__asm__ __volatile__ (						     \
225
-		".code16\n\t"						     \
226
-		"pushw %%gs\n\t"					     \
227
-		"pushw %%fs\n\t"					     \
228
-		"pushw %%es\n\t"					     \
229
-		"pushw %%ds\n\t"					     \
230
-		"\n" #name ":\n\t"					     \
231
-		asm_code_str						     \
232
-		"popw %%ds\n\t"						     \
233
-		"popw %%es\n\t"						     \
234
-		"popw %%fs\n\t"						     \
235
-		"popw %%gs\n\t"						     \
236
-		".code16gcc\n\t"					     \
237
-		: out_constraints					     \
238
-		: in_constraints					     \
239
-		: clobber				   		     \
240
-		);
236
+#define REAL_EXEC( name, asm_code_str, num_out_constraints,		\
237
+		   out_constraints, in_constraints, clobber ) do {	\
238
+	__asm__ __volatile__ (						\
239
+		REAL_CODE ( asm_code_str )				\
240
+		: out_constraints : in_constraints : clobber );		\
241
+	} while ( 0 )
241 242
 
242 243
 #endif /* ASSEMBLY */
243 244
 

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

@@ -177,6 +177,20 @@ extern void remove_from_rm_stack ( void *data, size_t size );
177 177
 #define BASEMEM_PARAMETER_INIT BASEMEM_PARAMETER_INIT_LIBRM
178 178
 #define BASEMEM_PARAMETER_DONE BASEMEM_PARAMETER_DONE_LIBRM
179 179
 
180
+/* REAL_CODE: declare a fragment of code that executes in real mode */
181
+#define REAL_CODE( asm_code_str )			\
182
+	"pushl $1f\n\t"					\
183
+	"call real_call\n\t"				\
184
+	"addl $4, %%esp\n\t"				\
185
+	".section \".text16\", \"ax\", @progbits\n\t"	\
186
+	".code16\n\t"					\
187
+	".arch i386\n\t"				\
188
+	"\n1:\n\t"					\
189
+	asm_code_str "\n\t"				\
190
+	"ret\n\t"					\
191
+	".code32\n\t"					\
192
+	".previous\n\t"
193
+
180 194
 /* REAL_EXEC: execute a fragment of code in real mode */
181 195
 #define OUT_CONSTRAINTS(...) __VA_ARGS__
182 196
 #define IN_CONSTRAINTS(...) __VA_ARGS__
@@ -184,18 +198,7 @@ extern void remove_from_rm_stack ( void *data, size_t size );
184 198
 #define REAL_EXEC( name, asm_code_str, num_out_constraints,		\
185 199
 		   out_constraints, in_constraints, clobber ) do {	\
186 200
 	__asm__ __volatile__ (						\
187
-		".section \".text16\", \"ax\", @progbits\n\t"		\
188
-		".code16\n\t"						\
189
-		".arch i386\n\t"					\
190
-		#name ":\n\t"						\
191
-		asm_code_str "\n\t"					\
192
-		"ret\n\t"						\
193
-		".size " #name ", . - " #name "\n\t"			\
194
-		".code32\n\t"						\
195
-		".previous\n\t"						\
196
-		"pushl $" #name "\n\t"					\
197
-		"call real_call\n\t"					\
198
-		"addl $4, %%esp\n\t"					\
201
+		REAL_CODE ( asm_code_str )				\
199 202
 		: out_constraints : in_constraints : clobber );		\
200 203
 	} while ( 0 )
201 204
 

Loading…
Cancel
Save