mirror of https://github.com/ipxe/ipxe.git
Updated to REAL_CODE().
parent
04d6005d77
commit
c4d688c005
|
@ -1,71 +1,73 @@
|
||||||
/* Etherboot routines for PCBIOS firmware.
|
/*
|
||||||
|
* Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
|
||||||
*
|
*
|
||||||
* Body of routines taken from old pcbios.S
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "realmode.h"
|
#include <realmode.h>
|
||||||
#include "console.h"
|
#include <console.h>
|
||||||
|
|
||||||
#define ZF ( 1 << 6 )
|
/**
|
||||||
|
* Print a character to BIOS console
|
||||||
/**************************************************************************
|
*
|
||||||
bios_putchar - Print a character on console
|
* @v character Character to be printed
|
||||||
**************************************************************************/
|
*/
|
||||||
static void bios_putchar ( int character ) {
|
static void bios_putchar ( int character ) {
|
||||||
REAL_EXEC ( rm_console_putc,
|
|
||||||
"sti\n\t"
|
|
||||||
"movb $0x0e, %%ah\n\t"
|
|
||||||
"movl $1, %%ebx\n\t"
|
|
||||||
"int $0x10\n\t"
|
|
||||||
"cli\n\t",
|
|
||||||
1,
|
|
||||||
OUT_CONSTRAINTS ( "=a" ( character ) ),
|
|
||||||
IN_CONSTRAINTS ( "a" ( character ) ),
|
|
||||||
CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
|
|
||||||
|
|
||||||
/* NOTE: %eax may be clobbered, so must be specified as an output
|
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
||||||
* parameter, even though we don't then do anything with it.
|
"int $0x10\n\t"
|
||||||
*/
|
"cli\n\t" )
|
||||||
|
: : "a" ( character | 0x0e00 ), "b" ( 1 )
|
||||||
|
: "ebp" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**
|
||||||
bios_getchar - Get a character from console
|
* Get character from BIOS console
|
||||||
**************************************************************************/
|
*
|
||||||
|
* @ret character Character read from console
|
||||||
|
*/
|
||||||
static int bios_getchar ( void ) {
|
static int bios_getchar ( void ) {
|
||||||
uint16_t character;
|
uint8_t character;
|
||||||
|
|
||||||
REAL_EXEC ( rm_console_getc,
|
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
||||||
"sti\n\t"
|
"int $0x16\n\t"
|
||||||
"xorw %%ax, %%ax\n\t"
|
"cli\n\t" )
|
||||||
"int $0x16\n\t"
|
: "=a" ( character ) : "a" ( 0x0000 ) );
|
||||||
"cli\n\t",
|
|
||||||
1,
|
|
||||||
OUT_CONSTRAINTS ( "=a" ( character ) ),
|
|
||||||
IN_CONSTRAINTS (),
|
|
||||||
CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
|
|
||||||
|
|
||||||
return ( character & 0xff );
|
return character;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**
|
||||||
bios_iskey - Check for keyboard interrupt
|
* Check for character ready to read from BIOS console
|
||||||
**************************************************************************/
|
*
|
||||||
|
* @ret True Character available to read
|
||||||
|
* @ret False No character available to read
|
||||||
|
*/
|
||||||
static int bios_iskey ( void ) {
|
static int bios_iskey ( void ) {
|
||||||
uint16_t flags;
|
unsigned int discard_a;
|
||||||
|
unsigned int flags;
|
||||||
|
|
||||||
REAL_EXEC ( rm_console_ischar,
|
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
||||||
"sti\n\t"
|
"int $0x16\n\t"
|
||||||
"movb $1, %%ah\n\t"
|
"pushfw\n\t"
|
||||||
"int $0x16\n\t"
|
"popw %w0\n\t"
|
||||||
"pushfw\n\t"
|
"cli\n\t" )
|
||||||
"popw %%ax\n\t"
|
: "=r" ( flags ), "=a" ( discard_a )
|
||||||
"cli\n\t",
|
: "a" ( 0x0001 ) );
|
||||||
1,
|
|
||||||
OUT_CONSTRAINTS ( "=a" ( flags ) ),
|
|
||||||
IN_CONSTRAINTS (),
|
|
||||||
CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
|
|
||||||
|
|
||||||
return ( ( flags & ZF ) == 0 );
|
return ( ! ( flags & ZF ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
struct console_driver bios_console __console_driver = {
|
struct console_driver bios_console __console_driver = {
|
||||||
|
|
Loading…
Reference in New Issue