|
@@ -1,5 +1,3 @@
|
1
|
|
-#define PXENV_UNDI_CLEANUP 0x02
|
2
|
|
-#define PXENV_UNDI_SHUTDOWN 0x05
|
3
|
1
|
#define PXENV_STOP_UNDI 0x15
|
4
|
2
|
#define PXENV_UNLOAD_STACK 0x70
|
5
|
3
|
#define PXENV_STOP_BASE 0x76
|
|
@@ -118,88 +116,76 @@ print_structure_information:
|
118
|
116
|
call print_segoff
|
119
|
117
|
|
120
|
118
|
/*****************************************************************************
|
121
|
|
- * Unload PXE base code and UNDI driver
|
|
119
|
+ * Calculate base memory usage by UNDI
|
122
|
120
|
*****************************************************************************
|
123
|
121
|
*/
|
124
|
|
-#ifdef PXELOADER_KEEP_ALL
|
125
|
|
- xorw %ax, %ax /* Force zero flag to show success */
|
126
|
|
- jmp do_not_free_base_mem /* Skip the unloading */
|
127
|
|
-#endif /* PXELOADER_KEEP_ALL */
|
128
|
|
-
|
129
|
|
-unload_pxe:
|
130
|
|
- movw $PXENV_UNLOAD_STACK, %bx
|
131
|
|
- call pxe_call
|
132
|
|
- movw $PXENV_STOP_UNDI, %bx
|
|
122
|
+find_undi_basemem_usage:
|
|
123
|
+ movw undi_code_segment, %ax
|
|
124
|
+ movw undi_code_size, %bx
|
|
125
|
+ movw undi_data_segment, %cx
|
|
126
|
+ movw undi_data_size, %dx
|
|
127
|
+ cmpw %ax, %cx
|
|
128
|
+ ja 1f
|
|
129
|
+ xchgw %ax, %cx
|
|
130
|
+ xchgw %bx, %dx
|
|
131
|
+1: /* %ax:%bx now describes the lower region, %cx:%dx the higher */
|
|
132
|
+ shrw $6, %ax /* Round down to nearest kB */
|
|
133
|
+ movw %ax, undi_fbms_start
|
|
134
|
+ addw $0x0f, %dx /* Round up to next segment */
|
|
135
|
+ shrw $4, %dx
|
|
136
|
+ addw %dx, %cx
|
|
137
|
+ addw $((1024 / 16) - 1), %cx /* Round up to next kB */
|
|
138
|
+ shrw $6, %cx
|
|
139
|
+ movw %cx, undi_fbms_end
|
|
140
|
+
|
|
141
|
+/*****************************************************************************
|
|
142
|
+ * Unload PXE base code
|
|
143
|
+ *****************************************************************************
|
|
144
|
+ */
|
|
145
|
+unload_base_code:
|
|
146
|
+ movw $PXENV_STOP_BASE, %bx
|
133
|
147
|
call pxe_call
|
134
|
|
- pushfw /* Ignore PXENV_UNDI_CLEANUP errors */
|
135
|
|
- movw $PXENV_UNDI_CLEANUP, %bx
|
|
148
|
+ movw $PXENV_UNLOAD_STACK, %bx
|
136
|
149
|
call pxe_call
|
137
|
|
- popfw
|
138
|
|
- /* On exit, zero flag is set iff all calls were successful */
|
139
|
|
-
|
|
150
|
+ jnz do_not_free_base_code
|
|
151
|
+free_base_code:
|
|
152
|
+ movw %fs:(0x13), %si
|
|
153
|
+ movw undi_fbms_start, %di
|
|
154
|
+ call free_basemem
|
|
155
|
+do_not_free_base_code:
|
|
156
|
+
|
140
|
157
|
/*****************************************************************************
|
141
|
|
- * Free base memory
|
|
158
|
+ * Unload UNDI driver
|
142
|
159
|
*****************************************************************************
|
143
|
160
|
*/
|
144
|
|
-free_base_mem:
|
145
|
|
- jnz do_not_free_base_mem /* Using zero flag from unload_pxe */
|
146
|
|
-
|
147
|
|
- movw undi_code_segment, %bx
|
148
|
|
- movw undi_data_segment, %cx
|
149
|
|
- movw undi_code_size, %ax
|
150
|
|
- cmpw %bx, %cx
|
151
|
|
- jb 1f
|
152
|
|
- movw %cx, %bx
|
153
|
|
- movw undi_data_size, %ax
|
154
|
|
-1: addw $0x0f, %ax /* Round up to next segment */
|
155
|
|
- shrw $4, %ax
|
156
|
|
- addw %bx, %ax /* Highest segment address into %ax */
|
157
|
|
- addw $(1024 / 16 - 1), %ax /* Round up to next kb */
|
158
|
|
- shrw $6, %ax /* New free basemem size in %ax */
|
159
|
|
- movw %fs:(0x13), %bx /* Old free base memory in %bx */
|
160
|
|
- movw %ax, %fs:(0x13) /* Store new free base memory size */
|
161
|
|
-
|
162
|
|
- /* Note that zero_mem_loop will also zero out our stack, so make
|
163
|
|
- * sure the stack is empty at this point.
|
164
|
|
- */
|
165
|
|
- movw %ax, %dx
|
166
|
|
- subw %bx, %dx /* numberof kb to zero in %dx */
|
167
|
|
- shlw $6, %bx /* Segment address into %bx */
|
168
|
|
-zero_mem_loop:
|
169
|
|
- movw %bx, %es /* kB boundary into %es:00 */
|
170
|
|
- xorw %ax, %ax
|
171
|
|
- xorw %di, %di
|
172
|
|
- movw $0x400, %cx
|
173
|
|
- rep stosb /* fill kB with zeroes */
|
174
|
|
- addw $(1024 / 16), %bx
|
175
|
|
- decw %dx
|
176
|
|
- jnz zero_mem_loop
|
177
|
|
- /* Will exit here with zero flag set, so no need to set it explicitly
|
178
|
|
- * in order to indicate success.
|
179
|
|
- */
|
180
|
|
-
|
181
|
|
-do_not_free_base_mem:
|
182
|
|
- pushfw /* Save success (zero) flag status */
|
183
|
|
- movw %fs:(0x13), %ax /* Free base memory in %ax */
|
184
|
|
- call print_hex_word /* Print free base memory */
|
185
|
|
- popfw /* Restore success (zero) flag */
|
|
161
|
+unload_undi:
|
|
162
|
+ movw $PXENV_STOP_UNDI, %bx
|
|
163
|
+ call pxe_call
|
|
164
|
+#ifndef PXELOADER_KEEP_UNDI
|
|
165
|
+ jnz do_not_free_undi
|
|
166
|
+free_undi:
|
|
167
|
+ movw undi_fbms_start, %si
|
|
168
|
+ movw undi_fbms_end, %di
|
|
169
|
+ call free_basemem
|
|
170
|
+do_not_free_undi:
|
|
171
|
+#endif /* PXELOADER_KEEP_UNDI */
|
186
|
172
|
|
187
|
173
|
/*****************************************************************************
|
188
|
174
|
* Exit point
|
189
|
|
- * Jump to finished with the zero flag set to indicate success, or to
|
190
|
|
- * finished_with_error to always report an error
|
191
|
175
|
*****************************************************************************
|
192
|
176
|
*/
|
193
|
177
|
finished:
|
194
|
178
|
movw $10f, %si
|
|
179
|
+ movw pxe_overall_status, %ax
|
|
180
|
+ testw %ax, %ax
|
195
|
181
|
jz 1f
|
196
|
182
|
finished_with_error:
|
197
|
183
|
movw $20f, %si
|
198
|
184
|
1:
|
199
|
185
|
call print_message
|
200
|
186
|
jmp run_etherboot
|
201
|
|
-10: .asciz " ok\n"
|
202
|
|
-20: .asciz " err\n"
|
|
187
|
+10: .asciz "ok\n"
|
|
188
|
+20: .asciz "err\n"
|
203
|
189
|
|
204
|
190
|
/*****************************************************************************
|
205
|
191
|
* Subroutine: print character in %al (with LF -> LF,CR translation)
|
|
@@ -262,13 +248,40 @@ print_segoff:
|
262
|
248
|
movb $0x20, %al /* ' ' */
|
263
|
249
|
call print_character
|
264
|
250
|
ret
|
265
|
|
-
|
|
251
|
+
|
|
252
|
+/*****************************************************************************
|
|
253
|
+ * Subroutine: free and zero base memory from %si kB to %di kB
|
|
254
|
+ *****************************************************************************
|
|
255
|
+ */
|
|
256
|
+free_basemem:
|
|
257
|
+ movw %fs:(0x13), %ax /* Current FBMS to %ax */
|
|
258
|
+ cmpw %ax, %si /* Update FBMS only if "old" value */
|
|
259
|
+ jne 1f /* is correct */
|
|
260
|
+ movw %di, %fs:(0x13)
|
|
261
|
+1: movw %di, %bx
|
|
262
|
+zero_kb:
|
|
263
|
+ movw %si, %ax /* Zero kB at %si */
|
|
264
|
+ shlw $6, %ax
|
|
265
|
+ movw %ax, %es
|
|
266
|
+ xorw %ax, %ax
|
|
267
|
+ xorw %di, %di
|
|
268
|
+ movw $0x400, %cx
|
|
269
|
+ rep stosb
|
|
270
|
+ incw %si /* Move to next kB */
|
|
271
|
+ cmpw %si, %bx
|
|
272
|
+ jne zero_kb /* Loop until done */
|
|
273
|
+ movw %fs:(0x13), %ax /* Print free base memory */
|
|
274
|
+ call print_hex_word
|
|
275
|
+ movb $0x20, %al /* ' ' */
|
|
276
|
+ call print_character
|
|
277
|
+ ret
|
|
278
|
+
|
266
|
279
|
/*****************************************************************************
|
267
|
280
|
* Make a PXE API call. Works with either !PXE or PXENV+ API.
|
268
|
281
|
* Opcode in %bx. pxe_parameter_structure always used.
|
269
|
|
- * Returns status code (not exit code) in %bx and prints it.
|
270
|
|
- * ORs status code with overall status code in pxe_overall_status, returns
|
271
|
|
- * with zero flag set iff all PXE API calls have been successful.
|
|
282
|
+ *
|
|
283
|
+ * Returns status code (not exit code) in %bx and prints it. Returns
|
|
284
|
+ * with zero flag set if status code is zero (PXENV_STATUS_SUCCESS).
|
272
|
285
|
*****************************************************************************
|
273
|
286
|
*/
|
274
|
287
|
pxe_call:
|
|
@@ -291,6 +304,7 @@ pxe_call:
|
291
|
304
|
call print_character
|
292
|
305
|
popw %bx
|
293
|
306
|
orw %bx, pxe_overall_status
|
|
307
|
+ testw %bx, %bx
|
294
|
308
|
ret
|
295
|
309
|
|
296
|
310
|
/*****************************************************************************
|
|
@@ -298,8 +312,6 @@ pxe_call:
|
298
|
312
|
*****************************************************************************
|
299
|
313
|
*/
|
300
|
314
|
|
301
|
|
-pxe_overall_status: .word 0
|
302
|
|
-
|
303
|
315
|
pxe_entry_segoff:
|
304
|
316
|
pxe_entry_offset: .word 0
|
305
|
317
|
pxe_entry_segment: .word 0
|
|
@@ -312,10 +324,15 @@ undi_data_segoff:
|
312
|
324
|
undi_data_size: .word 0
|
313
|
325
|
undi_data_segment: .word 0
|
314
|
326
|
|
|
327
|
+undi_fbms_start: .word 0
|
|
328
|
+undi_fbms_end: .word 0
|
|
329
|
+
|
315
|
330
|
pxe_parameter_structure:
|
316
|
331
|
.word 0
|
317
|
332
|
.word 0,0,0,0,0
|
318
|
333
|
|
|
334
|
+pxe_overall_status: .word 0
|
|
335
|
+
|
319
|
336
|
/*****************************************************************************
|
320
|
337
|
* Run Etherboot main code
|
321
|
338
|
*****************************************************************************
|