Browse Source

Code segment may not be writable; create the temporary pointer to the GDT

on the stack.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
e7eca7b7cb
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      src/arch/i386/prefix/libprefix.S

+ 7
- 2
src/arch/i386/prefix/libprefix.S View File

@@ -254,6 +254,7 @@ flatten_real_mode:
254 254
 	/* Preserve real-mode segment values and temporary registers */
255 255
 	pushw	%es
256 256
 	pushw	%ds
257
+	pushw	%bp
257 258
 	pushl	%eax
258 259
 
259 260
 	/* Set GDT base and load GDT */
@@ -261,8 +262,11 @@ flatten_real_mode:
261 262
 	movw	%cs, %ax
262 263
 	shll	$4, %eax
263 264
 	addl	$gdt, %eax
264
-	movl	%eax, %cs:gdt_base
265
-	lgdt	%cs:gdt
265
+	pushl	%eax
266
+	pushw	%cs:gdt_limit
267
+	movw	%sp, %bp
268
+	lgdt	(%bp)
269
+	addw	$6, %sp
266 270
 
267 271
 	/* Switch to protected mode */
268 272
 	movl	%cr0, %eax
@@ -281,6 +285,7 @@ flatten_real_mode:
281 285
 
282 286
 	/* Restore real-mode segment values and temporary registers */
283 287
 	popl	%eax
288
+	popw	%bp
284 289
 	popw	%ds
285 290
 	popw	%es
286 291
 	ret

Loading…
Cancel
Save