Переглянути джерело

[prefix] Add printing functions to libprefix.S

Move the printing functions from pxeprefix.S into libprefix.S, so they
are available for debug from any prefix.
tags/v0.9.4
Michael Brown 16 роки тому
джерело
коміт
297002d7bd

+ 108
- 0
src/arch/i386/prefix/libprefix.S Переглянути файл

@@ -43,6 +43,114 @@
43 43
 
44 44
 #define CR0_PE 1
45 45
 
46
+/*****************************************************************************
47
+ * Utility function: print character (with LF -> LF,CR translation)
48
+ *
49
+ * Parameters:
50
+ *   %al : character to print
51
+ * Returns:
52
+ *   Nothing
53
+ * Corrupts:
54
+ *   %ax
55
+ *****************************************************************************
56
+ */
57
+	.section ".prefix.lib"
58
+	.code16
59
+	.globl	print_character
60
+print_character:
61
+	/* Preserve registers */
62
+	pushw	%bx
63
+	pushw	%bp
64
+	/* Print character */
65
+	movw	$0x0007, %bx		/* page 0, attribute 7 (normal) */
66
+	movb	$0x0e, %ah		/* write char, tty mode */
67
+	cmpb	$0x0a, %al		/* '\n'? */
68
+	jne	1f
69
+	int	$0x10
70
+	movb	$0x0d, %al
71
+1:	int	$0x10
72
+	/* Restore registers and return */
73
+	popw	%bp
74
+	popw	%bx
75
+	ret
76
+	.size	print_character, . - print_character
77
+
78
+/*****************************************************************************
79
+ * Utility function: print a NUL-terminated string
80
+ *
81
+ * Parameters:
82
+ *   %ds:si : string to print
83
+ * Returns:
84
+ *   %ds:si : character after terminating NUL
85
+ *****************************************************************************
86
+ */
87
+	.section ".prefix.lib"
88
+	.code16
89
+	.globl	print_message
90
+print_message:
91
+	/* Preserve registers */
92
+	pushw	%ax
93
+	/* Print string */
94
+1: 	lodsb
95
+	testb	%al, %al
96
+	je	2f
97
+	call	print_character
98
+	jmp	1b
99
+2:	/* Restore registers and return */
100
+	popw	%ax
101
+	ret
102
+	.size	print_message, . - print_message
103
+
104
+/*****************************************************************************
105
+ * Utility functions: print hex digit/byte/word/dword
106
+ *
107
+ * Parameters:
108
+ *   %al (low nibble) : digit to print
109
+ *   %al : byte to print
110
+ *   %ax : word to print
111
+ *   %eax : dword to print
112
+ * Returns:
113
+ *   Nothing
114
+ *****************************************************************************
115
+ */
116
+	.section ".prefix.lib"
117
+	.code16
118
+	.globl	print_hex_dword
119
+print_hex_dword:
120
+	rorl	$16, %eax
121
+	call	print_hex_word
122
+	rorl	$16, %eax
123
+	/* Fall through */
124
+	.size	print_hex_dword, . - print_hex_dword
125
+	.globl	print_hex_word
126
+print_hex_word:
127
+	xchgb	%al, %ah
128
+	call	print_hex_byte
129
+	xchgb	%al, %ah
130
+	/* Fall through */
131
+	.size	print_hex_word, . - print_hex_word
132
+	.globl	print_hex_byte
133
+print_hex_byte:
134
+	rorb	$4, %al
135
+	call	print_hex_nibble
136
+	rorb	$4, %al
137
+	/* Fall through */
138
+	.size	print_hex_byte, . - print_hex_byte
139
+	.globl	print_hex_nibble
140
+print_hex_nibble:
141
+	/* Preserve registers */
142
+	pushw	%ax
143
+	/* Print digit (technique by Norbert Juffa <norbert.juffa@amd.com> */
144
+	andb	$0x0f, %al
145
+	cmpb	$10, %al
146
+	sbbb	$0x69, %al
147
+	das
148
+	call	print_character
149
+	/* Restore registers and return */
150
+	popw	%ax
151
+	ret
152
+	.size	print_hex_nibble, . - print_hex_nibble
153
+
46 154
 /****************************************************************************
47 155
  * pm_call (real-mode near call)
48 156
  *

+ 0
- 106
src/arch/i386/prefix/pxeprefix.S Переглянути файл

@@ -320,112 +320,6 @@ print_free_basemem:
320 320
 finished:
321 321
 	jmp	run_etherboot
322 322
 
323
-/*****************************************************************************
324
- * Subroutine: print character (with LF -> LF,CR translation)
325
- *
326
- * Parameters:
327
- *   %al : character to print
328
- * Returns:
329
- *   Nothing
330
- *****************************************************************************
331
- */
332
-print_character:
333
-	/* Preserve registers */
334
-	pushw	%ax
335
-	pushw	%bx
336
-	pushw	%bp
337
-	/* Print character */
338
-	movw	$0x0007, %bx		/* page 0, attribute 7 (normal) */
339
-	movb	$0x0e, %ah		/* write char, tty mode */
340
-	cmpb	$0x0a, %al		/* '\n'? */
341
-	jne	1f
342
-	int	$0x10
343
-	movb	$0x0d, %al
344
-1:	int	$0x10
345
-	/* Restore registers and return */
346
-	popw	%bp
347
-	popw	%bx
348
-	popw	%ax
349
-	ret
350
-	
351
-/*****************************************************************************
352
- * Subroutine: print a NUL-terminated string
353
- *
354
- * Parameters:
355
- *   %ds:%si : string to print
356
- * Returns:
357
- *   Nothing
358
- *****************************************************************************
359
- */	
360
-print_message:
361
-	/* Preserve registers */
362
-	pushw	%ax
363
-	pushw	%si
364
-	/* Print string */
365
-1: 	lodsb
366
-	testb	%al, %al
367
-	je	2f
368
-	call	print_character
369
-	jmp	1b
370
-2:	/* Restore registers and return */
371
-	popw	%si
372
-	popw	%ax
373
-	ret
374
-
375
-/*****************************************************************************
376
- * Subroutine: print hex digit
377
- *
378
- * Parameters:
379
- *   %al (low nibble) : digit to print
380
- * Returns:
381
- *   Nothing
382
- *****************************************************************************
383
- */
384
-print_hex_nibble:
385
-	/* Preserve registers */
386
-	pushw	%ax
387
-	/* Print digit (technique by Norbert Juffa <norbert.juffa@amd.com> */
388
-	andb	$0x0f, %al
389
-	cmpb	$10, %al
390
-	sbbb	$0x69, %al
391
-	das
392
-	call	print_character
393
-	/* Restore registers and return */
394
-	popw	%ax
395
-	ret	
396
-
397
-/*****************************************************************************
398
- * Subroutine: print hex byte
399
- *
400
- * Parameters:
401
- *   %al : byte to print
402
- * Returns:
403
- *   Nothing
404
- *****************************************************************************
405
- */
406
-print_hex_byte:
407
-	rorb	$4, %al
408
-	call	print_hex_nibble
409
-	rorb	$4, %al
410
-	call	print_hex_nibble
411
-	ret
412
-
413
-/*****************************************************************************
414
- * Subroutine: print hex word
415
- *
416
- * Parameters:
417
- *   %ax : word to print
418
- * Returns:
419
- *   Nothing
420
- *****************************************************************************
421
- */
422
-print_hex_word:
423
-	xchgb	%al, %ah
424
-	call	print_hex_byte
425
-	xchgb	%al, %ah
426
-	call	print_hex_byte
427
-	ret
428
-
429 323
 /*****************************************************************************
430 324
  * Subroutine: print segment:offset address
431 325
  *

+ 4
- 22
src/arch/i386/prefix/romprefix.S Переглянути файл

@@ -180,7 +180,8 @@ gotpmm:	/* PMM allocation succeeded: copy ROM to PMM block */
180 180
 	/* Shrink ROM and update checksum */
181 181
 	xorw	%bx, %bx
182 182
 	xorw	%si, %si
183
-	movb	$_prefix_size_sect, romheader_size
183
+	movw	$_prefix_size_sect, %cx
184
+	movb	%cl, romheader_size
184 185
 	shlw	$9, %cx
185 186
 1:	lodsb
186 187
 	addb	%al, %bl
@@ -213,7 +214,7 @@ init_message_pmm_failed:
213 214
 	.asciz	" (failed)"
214 215
 	.size init_message_pmm_failed, . - init_message_pmm_failed
215 216
 init_message_crlf:
216
-	.asciz	"\r\n"
217
+	.asciz	"\n"
217 218
 	.size	init_message_crlf, . - init_message_crlf
218 219
 
219 220
 /* ROM image location
@@ -309,7 +310,7 @@ exec:	/* Set %ds = %cs */
309 310
 	.previous
310 311
 
311 312
 exec_message:
312
-	.asciz	"gPXE starting boot\r\n"
313
+	.asciz	"gPXE starting boot\n"
313 314
 	.size exec_message, . - exec_message
314 315
 
315 316
 /* UNDI loader
@@ -350,22 +351,3 @@ undiloader:
350 351
 	popl	%esi
351 352
 	lret
352 353
 	.size undiloader, . - undiloader
353
-				
354
-/* Utility function: print string
355
- */
356
-print_message:
357
-	pushw	%ax
358
-	pushw	%bx
359
-	pushw	%bp
360
-	movw    $0x0007, %bx
361
-1:	lodsb
362
-	testb	%al, %al
363
-	je	2f
364
-	movb    $0x0e, %ah              /* write char, tty mode */
365
-	int     $0x10
366
-	jmp	1b
367
-2:	popw	%bp
368
-	popw	%bx
369
-	popw	%ax
370
-	ret
371
-	.size print_message, . - print_message

Завантаження…
Відмінити
Зберегти