ps2mouse.c revision d47957e1fd302183e5fe7d15ae453c24cdb06cb8
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on:
*
*
* Copyright (C) 2002 MandrakeSoft S.A.
*
* MandrakeSoft S.A.
* 43, rue d'Aboukir
* 75002 Paris - France
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <stdint.h>
#include "biosint.h"
#include "inlines.h"
#if DEBUG_INT15_MS
#else
# define BX_DEBUG_INT15_MS(...)
#endif
#if DEBUG_INT74
#else
# define BX_DEBUG_INT74(...)
#endif
#if BX_USE_PS2_MOUSE
static const char panic_msg_keyb_buffer_full[] = "%s: keyboard input buffer full\n";
{
// wait for chance to write to ctrl
return(0);
}
{
int retries = 10000;
--retries;
if (!retries)
return(1);
return(0);
}
{
}
{
BX_DEBUG_INT74("entering int74_function\n");
make_farcall = 0;
return;
}
return;
}
if ( index >= package_count ) {
BX_DEBUG_INT74("int74_function: make_farcall=1\n");
Z = 0;
mouse_flags_1 = 0;
// check if far call handler installed
if (mouse_flags_2 & 0x80)
make_farcall = 1;
}
else {
}
}
void BIOSCALL int15_function_mouse(pusha_regs_t regs, uint16_t ES, uint16_t DS, volatile uint16_t FLAGS)
{
// Return Codes status in AH
// =========================
// 00: success
// 01: invalid subfunction (AL > 7)
// 02: invalid input value (out of allowable range)
// 03: interface error
// 04: resend command received from mouse controller,
// device driver should attempt command again
// 05: cannot enable mouse, since no far call has been installed
// 80/86: mouse service not implemented
BX_DEBUG_INT15_MS("unsupported subfn\n");
// invalid function
SET_CF();
return;
}
// Valid subfn; disable AUX input and IRQ12, assume no error
set_kbd_command_byte(0x65);
CLEAR_CF();
BX_DEBUG_INT15_MS("case 0: ");
// invalid subfunction
SET_CF();
break;
}
if ( (mouse_flags_2 & 0x80) == 0 ) {
BX_DEBUG_INT15_MS("INT 15h C2 Enable/Disable Mouse, no far call handler\n");
SET_CF();
break;
}
BX_DEBUG_INT15_MS("Disable Mouse\n");
} else {
BX_DEBUG_INT15_MS("Enable Mouse\n");
}
if (ret == 0) {
// success
break;
}
}
// interface error
SET_CF();
break;
case 5: // Initialize Mouse
// Valid package sizes are 1 to 8
SET_CF();
break;
}
// fall through!
case 1: // Reset Mouse
BX_DEBUG_INT15_MS("case 1 or 5:\n");
// clear current package byte index
if (ret == 0) {
// if no mouse attached, it will return RESEND
if (mouse_data3 == 0xfe) {
SET_CF();
break;
}
if (mouse_data3 != 0xfa)
if ( ret == 0 ) {
if ( ret == 0 ) {
if ( ret == 0 ) {
// success
break;
}
}
}
}
// interface error
SET_CF();
break;
case 2: // Set Sample Rate
BX_DEBUG_INT15_MS("case 2:\n");
default: mouse_data1 = 0;
}
if (mouse_data1 > 0) {
if (ret == 0) {
// success
} else {
// interface error
SET_CF();
}
} else {
// invalid input
SET_CF();
}
break;
case 3: // Set Resolution
BX_DEBUG_INT15_MS("case 3:\n");
// BX:
// 0 = 25 dpi, 1 count per millimeter
// 1 = 50 dpi, 2 counts per millimeter
// 2 = 100 dpi, 4 counts per millimeter
// 3 = 200 dpi, 8 counts per millimeter
if (ret == 0) {
if (mouse_data1 != 0xfa)
if (mouse_data1 != 0xfa)
// success
} else {
// interface error
SET_CF();
}
} else {
// invalid input
SET_CF();
}
break;
case 4: // Get Device ID
BX_DEBUG_INT15_MS("case 4:\n");
if (ret == 0) {
// success
} else {
// interface error
SET_CF();
}
break;
case 6: // Return Status & Set Scaling Factor...
BX_DEBUG_INT15_MS("case 6:\n");
case 0: // Return Status
if (ret == 0) {
if (mouse_data1 != 0xfa)
if (ret == 0) {
if ( ret == 0 ) {
if ( ret == 0 ) {
if ( ret == 0 ) {
// success
break;
}
}
}
}
}
// interface error
SET_CF();
break;
case 1: // Set Scaling Factor to 1:1
case 2: // Set Scaling Factor to 2:1
} else {
}
if (ret == 0) {
}
if (ret != 0) {
// interface error
SET_CF();
}
break;
default:
// invalid subfunction
SET_CF();
}
break;
case 7: // Set Mouse Handler Address
BX_DEBUG_INT15_MS("case 7:\n");
if (mouse_driver_offset == 0 && mouse_driver_seg == 0) {
/* remove handler */
if ( (mouse_flags_2 & 0x80) != 0 ) {
mouse_flags_2 &= ~0x80;
}
}
else {
/* install handler */
mouse_flags_2 |= 0x80;
}
break;
default:
BX_PANIC("INT 15h C2 default case entered\n");
// invalid subfunction
SET_CF();
}
// Re-enable AUX input and IRQ12
set_kbd_command_byte(0x47);
}
#endif // BX_USE_PS2_MOUSE