Ver código fonte

Updated to REAL_CODE().

tags/v0.9.3
Michael Brown 18 anos atrás
pai
commit
c4d688c005
1 arquivos alterados com 55 adições e 53 exclusões
  1. 55
    53
      src/arch/i386/firmware/pcbios/bios_console.c

+ 55
- 53
src/arch/i386/firmware/pcbios/bios_console.c Ver arquivo

@@ -1,71 +1,73 @@
1
-/* Etherboot routines for PCBIOS firmware.
1
+/*
2
+ * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
2 3
  *
3
- * Body of routines taken from old pcbios.S
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4 17
  */
5 18
 
6
-#include "realmode.h"
7
-#include "console.h"
8
-
9
-#define ZF ( 1 << 6 )
19
+#include <realmode.h>
20
+#include <console.h>
10 21
 
11
-/**************************************************************************
12
-bios_putchar - Print a character on console
13
-**************************************************************************/
22
+/**
23
+ * Print a character to BIOS console
24
+ *
25
+ * @v character		Character to be printed
26
+ */
14 27
 static void bios_putchar ( int character ) {
15
-	REAL_EXEC ( rm_console_putc,
16
-		    "sti\n\t"
17
-		    "movb $0x0e, %%ah\n\t"
18
-		    "movl $1, %%ebx\n\t"
19
-		    "int $0x10\n\t"
20
-		    "cli\n\t",
21
-		    1,
22
-		    OUT_CONSTRAINTS ( "=a" ( character ) ),
23
-		    IN_CONSTRAINTS ( "a" ( character ) ),
24
-		    CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
25 28
 
26
-	/* NOTE: %eax may be clobbered, so must be specified as an output
27
-	 * parameter, even though we don't then do anything with it.
28
-	 */
29
+	__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
30
+					   "int $0x10\n\t"
31
+					   "cli\n\t" )
32
+			       : : "a" ( character | 0x0e00 ), "b" ( 1 )
33
+			       : "ebp" );
29 34
 }
30 35
 
31
-/**************************************************************************
32
-bios_getchar - Get a character from console
33
-**************************************************************************/
36
+/**
37
+ * Get character from BIOS console
38
+ *
39
+ * @ret character	Character read from console
40
+ */
34 41
 static int bios_getchar ( void ) {
35
-	uint16_t character;
36
-	
37
-	REAL_EXEC ( rm_console_getc,
38
-		    "sti\n\t"
39
-		    "xorw %%ax, %%ax\n\t"
40
-		    "int $0x16\n\t"
41
-		    "cli\n\t",
42
-		    1,
43
-		    OUT_CONSTRAINTS ( "=a" ( character ) ),
44
-		    IN_CONSTRAINTS (),
45
-		    CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
42
+	uint8_t character;
46 43
 	
47
-	return ( character & 0xff );
44
+	__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
45
+					   "int $0x16\n\t"
46
+					   "cli\n\t" )
47
+			       : "=a" ( character ) : "a" ( 0x0000 ) );
48
+
49
+	return character;
48 50
 }
49 51
 
50
-/**************************************************************************
51
-bios_iskey - Check for keyboard interrupt
52
-**************************************************************************/
52
+/**
53
+ * Check for character ready to read from BIOS console
54
+ *
55
+ * @ret True		Character available to read
56
+ * @ret False		No character available to read
57
+ */
53 58
 static int bios_iskey ( void ) {
54
-	uint16_t flags;
59
+	unsigned int discard_a;
60
+	unsigned int flags;
55 61
 	
56
-	REAL_EXEC ( rm_console_ischar,
57
-		    "sti\n\t"
58
-		    "movb $1, %%ah\n\t"
59
-		    "int $0x16\n\t"
60
-		    "pushfw\n\t"
61
-		    "popw %%ax\n\t"
62
-		    "cli\n\t",
63
-		    1,
64
-		    OUT_CONSTRAINTS ( "=a" ( flags ) ),
65
-		    IN_CONSTRAINTS (),
66
-		    CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
62
+	__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
63
+					   "int $0x16\n\t"
64
+					   "pushfw\n\t"
65
+					   "popw %w0\n\t"
66
+					   "cli\n\t" )
67
+			       : "=r" ( flags ), "=a" ( discard_a )
68
+			       : "a" ( 0x0001 ) );
67 69
 	
68
-	return ( ( flags & ZF ) == 0 );
70
+	return ( ! ( flags & ZF ) );
69 71
 }
70 72
 
71 73
 struct console_driver bios_console __console_driver = {

Carregando…
Cancelar
Salvar