Move %fs initialization to assembly code; initialize %es explicitly.
authorhpa <hpa>
Mon, 10 Dec 2001 10:03:01 +0000 (10:03 +0000)
committerhpa <hpa>
Mon, 10 Dec 2001 10:03:01 +0000 (10:03 +0000)
memdisk/init.S16
memdisk/setup.c

index 465d63b..1cdff31 100644 (file)
@@ -115,18 +115,27 @@ ramdisk_max:      .long 0xffffffff        # Load ramdisk as high as
 /* ------------------- End of setup header --------------------------- */
 
 /*
- * Canonicalize CS to match the other segments; also, the C
- * code uses 32-bit registers to make sure the high part of
- * %esp is zero.
+ * Canonicalize CS to match the other segments
  */
 start:
-               .byte 0x66,0x0f,0xb7,0xe4       # movzwl %sp,%esp
                pushw %ds
-               pushw $main
+               pushw $start2
                lret
 
-main:
-               sti
+start2:
+/*
+ * Set up the operating environment expected by the C code.
+ * The C code uses 32-bit registers to make sure the high part of
+ * %esp is zero.
+ *
+ * The C code expects %cs == %ds == %es, and %fs == 0.
+ */
+               .byte 0x66,0x0f,0xb7,0xe4       # movzwl %sp,%esp
+               pushw %ds
+               popw %es
+               xorw %ax,%ax
+               movw %ax,%fs
+               sti                     # We may want to kill this?
                calll setup             # Call the C code
                # The setup function returns the drive number,
                # which should be returned in %dl
index cbd3699..64d66ec 100644 (file)
@@ -194,9 +194,6 @@ uint32_t setup(void)
 
   for(;;);
 
-  /* Point %fs to the zero page */
-  asm volatile("movw %0,%%fs" :: "r" (0));
-
   geometry = get_disk_image_geometry(shdr->ramdisk_image, shdr->ramdisk_size);
 
   get_mem();