瀏覽代碼

Optimise bios_putchar for speed(!) by avoiding two separate real-mode

calls.  This does make a visible difference when clearing the screen with
werase() inside bochs or qemu.
tags/v0.9.3
Michael Brown 18 年之前
父節點
當前提交
0aa1223264
共有 1 個文件被更改,包括 16 次插入11 次删除
  1. 16
    11
      src/arch/i386/firmware/pcbios/bios_console.c

+ 16
- 11
src/arch/i386/firmware/pcbios/bios_console.c 查看文件

@@ -148,26 +148,31 @@ static struct ansiesc_context bios_ansiesc_ctx = {
148 148
  * @v character		Character to be printed
149 149
  */
150 150
 static void bios_putchar ( int character ) {
151
+	int discard_a, discard_b, discard_c;
151 152
 
152 153
 	/* Intercept ANSI escape sequences */
153 154
 	character = ansiesc_process ( &bios_ansiesc_ctx, character );
154 155
 	if ( character < 0 )
155 156
 		return;
156 157
 
157
-	/* Set attribute for printable characters */
158
-	if ( character >= 0x20 ) {
159
-		__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
160
-						   "int $0x10\n\t"
161
-						   "cli\n\t" )
162
-				       : : "a" ( 0x0920 ), "b" ( bios_attr ),
163
-				           "c" ( 1 ) );
164
-	}
165
-
166
-	/* Print the character */
158
+	/* Print character with attribute */
167 159
 	__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
160
+					   /* Skip non-printable characters */
161
+					   "cmpb $0x20, %%al\n\t"
162
+					   "jb 1f\n\t"
163
+					   /* Set attribute */
164
+					   "movw $0x0001, %%cx\n\t"
165
+					   "movb $0x09, %%ah\n\t"
166
+					   "int $0x10\n\t"
167
+					   "\n1:\n\t"
168
+					   /* Print character */
169
+					   "xorw %%bx, %%bx\n\t"
170
+					   "movb $0x0e, %%ah\n\t"
168 171
 					   "int $0x10\n\t"
169 172
 					   "cli\n\t" )
170
-			       : : "a" ( character | 0x0e00 ), "b" ( 0 )
173
+			       : "=a" ( discard_a ), "=b" ( discard_b ),
174
+			         "=c" ( discard_c )
175
+			       : "a" ( character ), "b" ( bios_attr )
171 176
 			       : "ebp" );
172 177
 }
173 178
 

Loading…
取消
儲存