Browse Source

Setup now calls initialise() directly, rather than expecting the

prefix to do it.
tags/v0.9.3
Michael Brown 19 years ago
parent
commit
04682f9838
1 changed files with 24 additions and 16 deletions
  1. 24
    16
      src/arch/i386/core/setup.S

+ 24
- 16
src/arch/i386/core/setup.S View File

@@ -84,8 +84,9 @@ setup:
84 84
 	
85 85
 #endif /* CODE16 */
86 86
 	
87
-	/* Preserve flags (including interrupt status) */
87
+	/* Preserve flags (including interrupt status) and registers */
88 88
 	pushfl
89
+	pushl	%ebp
89 90
 
90 91
 	/* Switch to (uninitialised) internal environment.  This will
91 92
 	 * preserve the external environment for when we call
@@ -100,15 +101,13 @@ setup:
100 101
 	 * after the code segment.
101 102
 	 */
102 103
 	pushw	%ax
103
-	pushw	%bx
104 104
 	movw	%cs, %ax
105
-	movw	%ds, %bx
106
-	cmpw	%ax, %bx
105
+	movw	%ds, %bp
106
+	cmpw	%ax, %bp
107 107
 	jne	1f
108 108
 	addw	$_text_load_size_pgh, %ax
109 109
 	movw	%ax, %ds
110
-1:	popw	%bx
111
-	popw	%ax
110
+1:	popw	%ax
112 111
 		
113 112
 	/* Switch to internal stack */
114 113
 	pushw	%ds
@@ -117,11 +116,11 @@ setup:
117 116
 
118 117
 #else /* CODE16 && KEEP_IT_REAL */
119 118
 
120
-	/* Work out where we're running */
119
+	/* Work out where we're running and switch to internal pmode
120
+	 * stack
121
+	 */
121 122
 	call	1f
122 123
 1:	popl	%ebp
123
-
124
-	/* Switch to internal pmode stack */
125 124
 	leal	(_estack-1b)(%ebp), %esp
126 125
 
127 126
 	/* Set up GDT for virtual addressing */
@@ -134,17 +133,26 @@ setup:
134 133
 	 */
135 134
 	RETURN_TO_EXTERNAL
136 135
 
137
-	/* Pass pointer to entry-point function back to prefix.  %es
138
-	 * may, by now, have been destroyed, so we re-initialise it
139
-	 * from %cs.
136
+	/* Set %es:[e]di to point to entry-point function.
140 137
 	 */
141
-	pushw	%cs
142
-	popw	%es
138
+	push	%cs
139
+	pop	%es
143 140
 	mov	$ENTRY_POINT, %ENTRY_POINT_REGISTER
141
+
142
+	/* Far call to arch_initialise via the entry-point function.
143
+	 * arch_initialise() (or the entry-point function itself) may
144
+	 * update %es:[e]di to point to a new entry-point function for
145
+	 * subsequent calls.  librm will use this facility, since
146
+	 * arch_initialise() causes librm to be relocated.
147
+	 */
148
+	pushl	$arch_initialise
149
+	push	%cs		/* lcall %es:[x]di == %cs:[x]di */
150
+	call	*%ENTRY_POINT_REGISTER
151
+	popl	%ebp /* discard */
144 152
 	
145
-	/* Restore flags (including interrupt status) */
153
+	/* Restore flags (including interrupt status) and return */
154
+	popl	%ebp
146 155
 	popfl
147
-	
148 156
 	lret
149 157
 
150 158
 /****************************************************************************

Loading…
Cancel
Save