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
 	/* Preserve real-mode segment values and temporary registers */
254
 	/* Preserve real-mode segment values and temporary registers */
255
 	pushw	%es
255
 	pushw	%es
256
 	pushw	%ds
256
 	pushw	%ds
257
+	pushw	%bp
257
 	pushl	%eax
258
 	pushl	%eax
258
 
259
 
259
 	/* Set GDT base and load GDT */
260
 	/* Set GDT base and load GDT */
261
 	movw	%cs, %ax
262
 	movw	%cs, %ax
262
 	shll	$4, %eax
263
 	shll	$4, %eax
263
 	addl	$gdt, %eax
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
 	/* Switch to protected mode */
271
 	/* Switch to protected mode */
268
 	movl	%cr0, %eax
272
 	movl	%cr0, %eax
281
 
285
 
282
 	/* Restore real-mode segment values and temporary registers */
286
 	/* Restore real-mode segment values and temporary registers */
283
 	popl	%eax
287
 	popl	%eax
288
+	popw	%bp
284
 	popw	%ds
289
 	popw	%ds
285
 	popw	%es
290
 	popw	%es
286
 	ret
291
 	ret

Loading…
Cancel
Save