2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2003-06-03 00:36:30 +04:00
|
|
|
// $Id: keyboard.cc,v 1.77 2003-06-02 20:36:30 vruppert Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2002-01-08 22:00:06 +03:00
|
|
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
|
|
|
// Now features proper implementation of keyboard opcodes 0xF4 to 0xF6
|
|
|
|
// Silently ignores PS/2 keyboard extensions (0xF7 to 0xFD)
|
|
|
|
// Explicit panic on resend (0xFE)
|
|
|
|
//
|
|
|
|
// Emmanuel Marty <core@ggi-project.org>
|
|
|
|
|
2001-06-13 21:01:36 +04:00
|
|
|
// NB: now the PS/2 mouse support is in, outb changes meaning
|
|
|
|
// in conjunction with auxb
|
|
|
|
// auxb == 0 && outb == 0 => both buffers empty (nothing to read)
|
|
|
|
// auxb == 0 && outb == 1 => keyboard controller output buffer full
|
|
|
|
// auxb == 1 && outb == 0 => not used
|
|
|
|
// auxb == 1 && outb == 1 => mouse output buffer full.
|
|
|
|
// (das)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-12-22 03:00:33 +03:00
|
|
|
// Notes from Christophe Bothamy <cbbochs@free.fr>
|
|
|
|
//
|
|
|
|
// This file includes code from Ludovic Lange (http://ludovic.lange.free.fr)
|
|
|
|
// Implementation of 3 scancodes sets mf1,mf2,mf3 with or without translation.
|
|
|
|
// Default is mf2 with translation
|
|
|
|
// Ability to switch between scancodes sets
|
|
|
|
// Ability to turn translation on or off
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
|
|
|
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
|
|
|
// is used to know when we are exporting symbols and when we are importing.
|
|
|
|
#define BX_PLUGGABLE
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "bochs.h"
|
2002-09-21 02:42:29 +04:00
|
|
|
#include <math.h>
|
2001-12-22 03:00:33 +03:00
|
|
|
#include "scancodes.h"
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
#define LOG_THIS theKeyboard->
|
2001-05-03 04:42:29 +04:00
|
|
|
#define VERBOSE_KBD_DEBUG 0
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
bx_keyb_c *theKeyboard = NULL;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
int
|
|
|
|
libkeyboard_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
|
|
|
|
{
|
|
|
|
// Create one instance of the keyboard device object.
|
|
|
|
theKeyboard = new bx_keyb_c ();
|
|
|
|
// Before this plugin was loaded, pluginKeyboard pointed to a stub.
|
|
|
|
// Now make it point to the real thing.
|
|
|
|
bx_devices.pluginKeyboard = theKeyboard;
|
|
|
|
// Register this device.
|
|
|
|
BX_REGISTER_DEVICE_DEVMODEL (plugin, type, theKeyboard, BX_PLUGIN_KEYBOARD);
|
|
|
|
return(0); // Success
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
libkeyboard_LTX_plugin_fini(void)
|
|
|
|
{
|
|
|
|
BX_INFO (("keyboard plugin_fini"));
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
bx_keyb_c::bx_keyb_c(void)
|
|
|
|
{
|
|
|
|
// constructor
|
2002-10-25 01:07:56 +04:00
|
|
|
put("KBD");
|
|
|
|
settype(KBDLOG);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bx_keyb_c::~bx_keyb_c(void)
|
|
|
|
{
|
|
|
|
// destructor
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("Exit."));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// flush internal buffer and reset keyboard settings to power-up condition
|
|
|
|
void
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_keyb_c::resetinternals(bx_bool powerup)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
Bit32u i;
|
|
|
|
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.num_elements = 0;
|
|
|
|
for (i=0; i<BX_KBD_ELEMENTS; i++)
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.buffer[i] = 0;
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.head = 0;
|
|
|
|
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.expecting_typematic = 0;
|
|
|
|
|
2001-12-22 03:00:33 +03:00
|
|
|
// Default scancode set is mf2 with translation
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_scancodes_set = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.current_scancodes_set = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.scancodes_translate = 1;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
if (powerup) {
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.expecting_led_write = 0;
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.delay = 1; // 500 mS
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.repeat_rate = 0x0b; // 10.9 chars/sec
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-10-25 01:07:56 +04:00
|
|
|
bx_keyb_c::init(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2003-06-03 00:36:30 +04:00
|
|
|
BX_DEBUG(("Init $Id: keyboard.cc,v 1.77 2003-06-02 20:36:30 vruppert Exp $"));
|
2001-04-10 05:04:59 +04:00
|
|
|
Bit32u i;
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_register_irq(1, "8042 Keyboard controller");
|
|
|
|
DEV_register_irq(12, "8042 Keyboard controller (PS/2 mouse)");
|
|
|
|
|
|
|
|
DEV_register_ioread_handler(this, read_handler,
|
|
|
|
0x0060, "8042 Keyboard controller", 3);
|
|
|
|
DEV_register_ioread_handler(this, read_handler,
|
|
|
|
0x0064, "8042 Keyboard controller", 3);
|
|
|
|
DEV_register_iowrite_handler(this, write_handler,
|
|
|
|
0x0060, "8042 Keyboard controller", 3);
|
|
|
|
DEV_register_iowrite_handler(this, write_handler,
|
|
|
|
0x0064, "8042 Keyboard controller", 3);
|
|
|
|
BX_KEY_THIS timer_handle = bx_pc_system.register_timer( this, timer_handler,
|
|
|
|
bx_options.Okeyboard_serial_delay->get(), 1, 1,
|
|
|
|
"8042 Keyboard controller");
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
resetinternals(1);
|
|
|
|
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.led_status = 0;
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.scanning_enabled = 1;
|
|
|
|
|
|
|
|
BX_KEY_THIS s.mouse_internal_buffer.num_elements = 0;
|
|
|
|
for (i=0; i<BX_MOUSE_BUFF_SIZE; i++)
|
|
|
|
BX_KEY_THIS s.mouse_internal_buffer.buffer[i] = 0;
|
|
|
|
BX_KEY_THIS s.mouse_internal_buffer.head = 0;
|
|
|
|
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 0 auxb 0",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.pare = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.tim = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.auxb = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.keyl = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.c_d = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.sysf = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.inpb = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 0;
|
|
|
|
|
|
|
|
BX_KEY_THIS s.kbd_controller.kbd_clock_enabled = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_clock_enabled = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.allow_irq1 = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.allow_irq12 = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.kbd_output_buffer = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_output_buffer = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.last_comm = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq1_requested = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq12_requested = 0;
|
2002-10-25 01:07:56 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_mouse_parameter = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-20 18:01:39 +04:00
|
|
|
//BX_DEBUG(( "# Okeyboard_serial_delay is %u usec",
|
|
|
|
// (unsigned) bx_options.Okeyboard_serial_delay->get ()));
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.timer_pending = 0;
|
|
|
|
|
|
|
|
// Mouse initialization stuff
|
|
|
|
BX_KEY_THIS s.mouse.sample_rate = 100; // reports per second
|
|
|
|
BX_KEY_THIS s.mouse.resolution_cpmm = 4; // 4 counts per millimeter
|
|
|
|
BX_KEY_THIS s.mouse.scaling = 1; /* 1:1 (default) */
|
|
|
|
BX_KEY_THIS s.mouse.mode = MOUSE_MODE_RESET;
|
|
|
|
BX_KEY_THIS s.mouse.enable = 0;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dx = 0;
|
|
|
|
BX_KEY_THIS s.mouse.delayed_dy = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
for (i=0; i<BX_KBD_CONTROLLER_QSIZE; i++)
|
|
|
|
BX_KEY_THIS s.controller_Q[i] = 0;
|
|
|
|
BX_KEY_THIS s.controller_Qsize = 0;
|
|
|
|
BX_KEY_THIS s.controller_Qsource = 0;
|
|
|
|
|
2002-03-11 18:04:58 +03:00
|
|
|
// clear paste buffer
|
|
|
|
BX_KEY_THIS pastebuf = NULL;
|
|
|
|
BX_KEY_THIS pastebuf_len = 0;
|
|
|
|
BX_KEY_THIS pastebuf_ptr = 0;
|
2002-03-26 17:46:03 +03:00
|
|
|
BX_KEY_THIS paste_delay_changed ();
|
2002-12-27 01:19:44 +03:00
|
|
|
BX_KEY_THIS stop_paste = 0;
|
2002-03-11 18:04:58 +03:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
// mouse port installed on system board
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_cmos_set_reg(0x14, DEV_cmos_get_reg(0x14) | 0x04);
|
2002-03-11 18:04:58 +03:00
|
|
|
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
#if BX_WITH_WX
|
2002-10-25 15:44:41 +04:00
|
|
|
static bx_bool first_time = 1;
|
2002-10-01 02:23:57 +04:00
|
|
|
if (first_time) {
|
|
|
|
first_time = 0;
|
|
|
|
// register shadow params (Experimental, not a complete list by far)
|
|
|
|
bx_list_c *list = new bx_list_c (BXP_KBD_PARAMETERS, "Keyboard State", "", 20);
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_IRQ1_REQ,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard IRQ1 requested: ", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.irq1_requested));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_IRQ12_REQ,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard IRQ12 requested: ", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.irq12_requested));
|
|
|
|
list->add (new bx_shadow_num_c (BXP_KBD_TIMER_PENDING,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard timer pending: ", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.timer_pending));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_PARE,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard PARE", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.pare));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_TIM,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard TIM", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.tim));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_AUXB,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard AUXB", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.auxb));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_KEYL,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard KEYL", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.keyl));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_C_D,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard C_D", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.c_d));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_SYSF,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard SYSF", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.sysf));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_INPB,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard INPB", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.inpb));
|
|
|
|
list->add (new bx_shadow_bool_c (BXP_KBD_OUTB,
|
- upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values. This
allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
with an without the description arg. I eliminated the ones
that had no description, and also removed the min/max arg from
all. I still need a bunch of constructors though, for
Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
Having all these constructors allows us to write
new bx_shadow_num (bxid, name, description, &value)
for basically any integer variable. They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
configure main.cc cpu/init.cc iodev/keyboard.cc
gui/siminterface.cc gui/siminterface.h
2002-10-16 23:39:27 +04:00
|
|
|
"Keyboard OUTB", "",
|
2002-10-01 02:23:57 +04:00
|
|
|
&BX_KEY_THIS s.kbd_controller.outb));
|
|
|
|
}
|
- apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc
----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep 6 12:13:28 EDT 2002
Description:
Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.) This is the first step toward
making something resembling a wxWindows debugger.
First, variables which are going to be visible in the CI must be
registered as parameters. For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.
To deal with this, I introduced the concept of a shadow parameter. A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value. Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods. Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.
To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.
The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class). I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value. At the moment, in the
Debug:Show CPU dialog, changing the values has no effect. However
this is trivial to add when it's time (just call CommitChanges!). It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.
The Refresh() method must be called periodically or else the dialog
will show the initial values forever. At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().
Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
implement shadow parameter class for Boolean, called bx_shadow_bool_c.
more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
its display. For now, the refresh event causes the CI to check every
parameter it is watching and change the display value. Later, it may
be worth the trouble to keep track of which parameters have actually
changed. Code in the simulator thread calls SIM->refresh_ci(), which
creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
the config interface. When it arrives in the wxWindows gui thread,
it calls RefreshDialogs(), which calls the Refresh() method on any
dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
is printed. Otherwise, the refresh would wait until the next
SIM->periodic(), which might be thousands of cycles. This way,
when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
which tells whether it has any need for refresh events. If no
dialogs are showing that need refresh events, then no event is sent
between threads.
- add a few defaults to the param classes that affect the settings of
newly created parameters. When declaring a lot of params with
similar settings it's more compact to set the default for new params
rather than to change each one separately. default_text_format is
the printf format string for displaying numbers. default_base is
the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
boxes such as "Debug:Show CPU". The new Refresh() method queries
all the parameters for their current value and changes the value in
the wxWindows control. The ParamDialog class still needs a little
work; for example, if it's modal it should have Cancel/Ok buttons,
but if it's going to be modeless it should maybe have Apply (commit
any changes) and Close.
2002-09-06 20:43:26 +04:00
|
|
|
#endif
|
2002-08-27 23:54:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::reset(unsigned type)
|
|
|
|
{
|
2002-12-27 01:19:44 +03:00
|
|
|
if (BX_KEY_THIS pastebuf != NULL) {
|
|
|
|
BX_KEY_THIS stop_paste = 1;
|
|
|
|
}
|
2002-03-26 17:46:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::paste_delay_changed()
|
|
|
|
{
|
|
|
|
BX_KEY_THIS pastedelay = bx_options.Okeyboard_paste_delay->get()/BX_IODEV_HANDLER_PERIOD;
|
|
|
|
BX_INFO(("will paste characters every %d keyboard ticks",BX_KEY_THIS pastedelay));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// static IO port read callback handler
|
|
|
|
// redirects to non-static class handler to avoid virtual functions
|
|
|
|
|
2001-06-13 21:01:36 +04:00
|
|
|
// read function - the big picture:
|
|
|
|
// if address == data port then
|
|
|
|
// if byte for mouse then return it
|
|
|
|
// else if byte for keyboard then return it
|
|
|
|
// else address== status port
|
|
|
|
// assemble the status bits and return them.
|
|
|
|
//
|
2001-04-10 05:04:59 +04:00
|
|
|
Bit32u
|
|
|
|
bx_keyb_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
|
|
|
|
{
|
|
|
|
#if !BX_USE_KEY_SMF
|
|
|
|
bx_keyb_c *class_ptr = (bx_keyb_c *) this_ptr;
|
|
|
|
|
|
|
|
return( class_ptr->read(address, io_len) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bit32u
|
|
|
|
bx_keyb_c::read(Bit32u address, unsigned io_len)
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
UNUSED(this_ptr);
|
|
|
|
#endif // !BX_USE_KEY_SMF
|
|
|
|
|
|
|
|
if (io_len > 1)
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("kbd: io read to address %08x, len=%u",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) address, (unsigned) io_len));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "read from port 0x%04x", (unsigned) address));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (address == 0x60) { /* output buffer */
|
|
|
|
Bit8u val;
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.auxb) { /* mouse byte available */
|
|
|
|
val = BX_KEY_THIS s.kbd_controller.aux_output_buffer;
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_output_buffer = 0;
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 0 auxb 0",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.auxb = 0;
|
2002-03-27 19:42:54 +03:00
|
|
|
BX_KEY_THIS s.kbd_controller.irq12_requested = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (BX_KEY_THIS s.controller_Qsize) {
|
|
|
|
unsigned i;
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_output_buffer = BX_KEY_THIS s.controller_Q[0];
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 1 auxb 1",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.auxb = 1;
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.allow_irq12)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq12_requested = 1;
|
|
|
|
for (i=0; i<BX_KEY_THIS s.controller_Qsize-1; i++) {
|
|
|
|
// move Q elements towards head of queue by one
|
|
|
|
BX_KEY_THIS s.controller_Q[i] = BX_KEY_THIS s.controller_Q[i+1];
|
|
|
|
}
|
|
|
|
BX_KEY_THIS s.controller_Qsize--;
|
|
|
|
}
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(("mouse: ___io_read aux = 0x%02x", (unsigned) val));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_pic_lower_irq(12);
|
2001-04-10 05:04:59 +04:00
|
|
|
activate_timer();
|
2001-06-13 21:01:36 +04:00
|
|
|
BX_DEBUG(("READ(%02x) (from mouse) = %02x", (unsigned) address,
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) val));
|
2002-03-27 19:42:54 +03:00
|
|
|
return val;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
else if (BX_KEY_THIS s.kbd_controller.outb) { /* kbd byte available */
|
|
|
|
val = BX_KEY_THIS s.kbd_controller.kbd_output_buffer;
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 0 auxb 0",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.auxb = 0;
|
2002-03-27 19:42:54 +03:00
|
|
|
BX_KEY_THIS s.kbd_controller.irq1_requested = 0;
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "___io_read kbd"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (BX_KEY_THIS s.controller_Qsize) {
|
|
|
|
unsigned i;
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_output_buffer = BX_KEY_THIS s.controller_Q[0];
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 1 auxb 1",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.auxb = 1;
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.allow_irq1)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq1_requested = 1;
|
|
|
|
for (i=0; i<BX_KEY_THIS s.controller_Qsize-1; i++) {
|
|
|
|
// move Q elements towards head of queue by one
|
|
|
|
BX_KEY_THIS s.controller_Q[i] = BX_KEY_THIS s.controller_Q[i+1];
|
|
|
|
}
|
2002-03-27 19:42:54 +03:00
|
|
|
BX_DEBUG(("s.controller_Qsize: %02X",BX_KEY_THIS s.controller_Qsize));
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.controller_Qsize--;
|
|
|
|
}
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_pic_lower_irq(1);
|
2001-04-10 05:04:59 +04:00
|
|
|
activate_timer();
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("READ(%02x) = %02x", (unsigned) address,
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) val));
|
2002-03-27 19:42:54 +03:00
|
|
|
return val;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
else {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("num_elements = %d", BX_KEY_THIS s.kbd_internal_buffer.num_elements));
|
|
|
|
BX_DEBUG(("read from port 60h with outb empty"));
|
2002-03-27 19:42:54 +03:00
|
|
|
// val = BX_KEY_THIS s.kbd_controller.kbd_output_buffer;
|
|
|
|
return BX_KEY_THIS s.kbd_controller.kbd_output_buffer;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_CPU_LEVEL >= 2
|
|
|
|
else if (address == 0x64) { /* status register */
|
|
|
|
|
2002-03-27 19:42:54 +03:00
|
|
|
return (BX_KEY_THIS s.kbd_controller.pare << 7) |
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_KEY_THIS s.kbd_controller.tim << 6) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.auxb << 5) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.keyl << 4) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.c_d << 3) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.sysf << 2) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.inpb << 1) |
|
|
|
|
BX_KEY_THIS s.kbd_controller.outb;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* BX_CPU_LEVEL > 0 */
|
|
|
|
/* XT MODE, System 8255 Mode Register */
|
|
|
|
else if (address == 0x64) { /* status register */
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("IO read from port 64h, system 8255 mode register"));
|
2002-03-27 19:42:54 +03:00
|
|
|
return BX_KEY_THIS s.kbd_controller.outb;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
#endif /* BX_CPU_LEVEL > 0 */
|
|
|
|
|
2002-03-27 19:42:54 +03:00
|
|
|
BX_PANIC(("unknown address in io read to keyboard port %x",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) address));
|
2002-03-27 19:42:54 +03:00
|
|
|
return 0; /* keep compiler happy */
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static IO port write callback handler
|
|
|
|
// redirects to non-static class handler to avoid virtual functions
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len)
|
|
|
|
{
|
|
|
|
#if !BX_USE_KEY_SMF
|
|
|
|
bx_keyb_c *class_ptr = (bx_keyb_c *) this_ptr;
|
|
|
|
|
|
|
|
class_ptr->write(address, value, io_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::write( Bit32u address, Bit32u value, unsigned io_len)
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
UNUSED(this_ptr);
|
|
|
|
#endif // !BX_USE_KEY_SMF
|
|
|
|
Bit8u command_byte;
|
2002-02-21 23:26:48 +03:00
|
|
|
static int kbd_initialized=0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (io_len > 1)
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("kbd: io write to address %08x, len=%u",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) address, (unsigned) io_len));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("keyboard: 8-bit write to %04x = %02x", (unsigned)address, (unsigned)value));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(("WRITE(%02x) = %02x", (unsigned) address,
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
// (unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
switch (address) {
|
|
|
|
case 0x60: // input buffer
|
|
|
|
// if expecting data byte from command last sent to port 64h
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.expecting_port60h) {
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 0;
|
|
|
|
// data byte written last to 0x60
|
|
|
|
BX_KEY_THIS s.kbd_controller.c_d = 0;
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.inpb) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("write to port 60h, not ready for write"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
switch (BX_KEY_THIS s.kbd_controller.last_comm) {
|
|
|
|
case 0x60: // write command byte
|
|
|
|
{
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool scan_convert, disable_keyboard,
|
2001-04-10 05:04:59 +04:00
|
|
|
disable_aux;
|
|
|
|
|
|
|
|
scan_convert = (value >> 6) & 0x01;
|
|
|
|
disable_aux = (value >> 5) & 0x01;
|
|
|
|
disable_keyboard = (value >> 4) & 0x01;
|
|
|
|
BX_KEY_THIS s.kbd_controller.sysf = (value >> 2) & 0x01;
|
|
|
|
BX_KEY_THIS s.kbd_controller.allow_irq1 = (value >> 0) & 0x01;
|
|
|
|
BX_KEY_THIS s.kbd_controller.allow_irq12 = (value >> 1) & 0x01;
|
|
|
|
set_kbd_clock_enable(!disable_keyboard);
|
|
|
|
set_aux_clock_enable(!disable_aux);
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.allow_irq12 && BX_KEY_THIS s.kbd_controller.auxb)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq12_requested = 1;
|
|
|
|
else if (BX_KEY_THIS s.kbd_controller.allow_irq1 && BX_KEY_THIS s.kbd_controller.outb)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq1_requested = 1;
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(( " allow_irq12 set to %u", (unsigned)
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.allow_irq12));
|
2001-04-10 05:04:59 +04:00
|
|
|
if ( !scan_convert )
|
2001-06-13 20:53:58 +04:00
|
|
|
BX_ERROR(("keyboard: (mch) scan convert turned off"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// (mch) NT needs this
|
2001-12-22 03:00:33 +03:00
|
|
|
BX_KEY_THIS s.kbd_controller.scancodes_translate = scan_convert;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xd1: // write output port
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("write output port with value %02xh",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_SET_ENABLE_A20( (value & 0x02) != 0 );
|
2001-05-25 18:25:25 +04:00
|
|
|
if (!(value & 0x01))
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("IO write: processor reset requested!"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case 0xd4: // Write to mouse
|
|
|
|
// I don't think this enables the AUX clock
|
|
|
|
//set_aux_clock_enable(1); // enable aux clock line
|
|
|
|
kbd_ctrl_to_mouse(value);
|
|
|
|
// ??? should I reset to previous value of aux enable?
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xd3: // write mouse output buffer
|
|
|
|
// Queue in mouse output buffer
|
|
|
|
controller_enQ(value, 1);
|
|
|
|
break;
|
|
|
|
|
2002-04-11 04:28:55 +04:00
|
|
|
case 0xd2:
|
|
|
|
// Queue in keyboard output buffer
|
|
|
|
controller_enQ(value, 0);
|
|
|
|
break;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("=== unsupported write to port 60h(lastcomm=%02x): %02x",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) BX_KEY_THIS s.kbd_controller.last_comm, (unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// data byte written last to 0x60
|
|
|
|
BX_KEY_THIS s.kbd_controller.c_d = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 0;
|
|
|
|
/* pass byte to keyboard */
|
|
|
|
/* ??? should conditionally pass to mouse device here ??? */
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.kbd_clock_enabled==0) {
|
2001-06-13 20:53:58 +04:00
|
|
|
BX_ERROR(("keyboard disabled & send of byte %02x to kbd",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
kbd_ctrl_to_kbd(value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x64: // control register
|
|
|
|
// command byte written last to 0x64
|
|
|
|
BX_KEY_THIS s.kbd_controller.c_d = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.last_comm = value;
|
|
|
|
// most commands NOT expecting port60 write next
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 0;
|
|
|
|
|
|
|
|
switch (value) {
|
|
|
|
case 0x20: // get keyboard command byte
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("get keyboard command byte"));
|
2001-04-10 05:04:59 +04:00
|
|
|
// controller output buffer must be empty
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb) {
|
2001-06-13 20:53:58 +04:00
|
|
|
BX_ERROR(("kbd: OUTB set and command 0x%02x encountered", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
command_byte =
|
2001-12-22 03:00:33 +03:00
|
|
|
(BX_KEY_THIS s.kbd_controller.scancodes_translate << 6) |
|
2001-04-10 05:04:59 +04:00
|
|
|
((!BX_KEY_THIS s.kbd_controller.aux_clock_enabled) << 5) |
|
|
|
|
((!BX_KEY_THIS s.kbd_controller.kbd_clock_enabled) << 4) |
|
|
|
|
(0 << 3) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.sysf << 2) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.allow_irq12 << 1) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.allow_irq1 << 0);
|
|
|
|
controller_enQ(command_byte, 0);
|
|
|
|
break;
|
|
|
|
case 0x60: // write command byte
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("write command byte"));
|
2001-04-10 05:04:59 +04:00
|
|
|
// following byte written to port 60h is command byte
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xa1:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_ERROR(("Dummy out Green PC for now : 0xa1"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xa7: // disable the aux device
|
|
|
|
set_aux_clock_enable(0);
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("aux device disabled"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case 0xa8: // enable the aux device
|
|
|
|
set_aux_clock_enable(1);
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("aux device enabled"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case 0xa9: // Test Mouse Port
|
|
|
|
// controller output buffer must be empty
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("kbd: OUTB set and command 0x%02x encountered", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
controller_enQ(0x00, 0); // no errors detected
|
|
|
|
break;
|
|
|
|
case 0xaa: // motherboard controller self test
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("Self Test"));
|
2002-02-21 23:26:48 +03:00
|
|
|
if( kbd_initialized == 0 )
|
|
|
|
{
|
|
|
|
BX_KEY_THIS s.controller_Qsize = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 0;
|
|
|
|
kbd_initialized++;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
// controller output buffer must be empty
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb) {
|
2001-12-08 17:02:57 +03:00
|
|
|
BX_ERROR(("kbd: OUTB set and command 0x%02x encountered", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// (mch) Why is this commented out??? Enabling
|
|
|
|
BX_KEY_THIS s.kbd_controller.sysf = 1; // self test complete
|
|
|
|
controller_enQ(0x55, 0); // controller OK
|
|
|
|
break;
|
|
|
|
case 0xab: // Interface Test
|
|
|
|
// controller output buffer must be empty
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("kbd: OUTB set and command 0x%02x encountered", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
controller_enQ(0x00, 0);
|
|
|
|
break;
|
|
|
|
case 0xad: // disable keyboard
|
|
|
|
set_kbd_clock_enable(0);
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("keyboard disabled"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case 0xae: // enable keyboard
|
|
|
|
set_kbd_clock_enable(1);
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("keyboard enabled"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case 0xc0: // read input port
|
|
|
|
// controller output buffer must be empty
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("kbd: OUTB set and command 0x%02x encountered", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// keyboard power normal
|
|
|
|
controller_enQ(0x00, 0);
|
|
|
|
break;
|
|
|
|
case 0xd0: // read output port: next byte read from port 60h
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("io write to port 64h, command d0h (partial)"));
|
2001-04-10 05:04:59 +04:00
|
|
|
// controller output buffer must be empty
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("kbd: OUTB set and command 0x%02x encountered", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
controller_enQ(
|
|
|
|
(BX_KEY_THIS s.kbd_controller.auxb << 5) |
|
|
|
|
(BX_KEY_THIS s.kbd_controller.outb << 4) |
|
|
|
|
(BX_GET_ENABLE_A20() << 1) |
|
|
|
|
0x01, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xd1: // write output port: next byte written to port 60h
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("write output port"));
|
2001-04-10 05:04:59 +04:00
|
|
|
// following byte to port 60h written to output port
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xd3: // write mouse output buffer
|
2001-04-10 06:12:30 +04:00
|
|
|
//FIXME: Why was this a panic?
|
2001-10-02 22:38:03 +04:00
|
|
|
BX_DEBUG(("io write 0x64: command = 0xD3(write mouse outb)"));
|
2001-04-10 06:12:30 +04:00
|
|
|
// following byte to port 60h written to output port as mouse write.
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xd4: // write to mouse
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("io write 0x64: command = 0xD4 (write to mouse)"));
|
2001-04-10 05:04:59 +04:00
|
|
|
// following byte written to port 60h
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xd2: // write keyboard output buffer
|
2002-04-11 04:28:55 +04:00
|
|
|
BX_DEBUG(("io write 0x64: write keyboard output buffer"));
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_port60h = 1;
|
|
|
|
break;
|
2001-04-10 05:04:59 +04:00
|
|
|
case 0xdd: // Disable A20 Address Line
|
2002-04-11 04:28:55 +04:00
|
|
|
BX_SET_ENABLE_A20(0);
|
|
|
|
break;
|
2001-04-10 05:04:59 +04:00
|
|
|
case 0xdf: // Enable A20 Address Line
|
2002-04-11 04:28:55 +04:00
|
|
|
BX_SET_ENABLE_A20(1);
|
|
|
|
break;
|
2001-04-10 05:04:59 +04:00
|
|
|
case 0xc1: // Continuous Input Port Poll, Low
|
|
|
|
case 0xc2: // Continuous Input Port Poll, High
|
|
|
|
case 0xe0: // Read Test Inputs
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("io write 0x64: command = %02xh", (unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xfe: // System Reset, transition to real mode
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("system reset"));
|
2001-05-08 21:59:38 +04:00
|
|
|
bx_pc_system.ResetSignal( PCS_SET ); /* XXX is this right? */
|
2001-05-23 11:48:11 +04:00
|
|
|
{
|
|
|
|
for (int i=0; i<BX_SMP_PROCESSORS; i++)
|
|
|
|
BX_CPU(i)->reset(BX_RESET_HARDWARE);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
// Use bx_pc_system if necessary bx_cpu.reset_cpu();
|
2001-05-08 21:59:38 +04:00
|
|
|
// bx_pc_system.ResetSignal( PCS_SET );
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (value==0xff || (value>=0xf0 && value<=0xfd)) {
|
|
|
|
/* useless pulse output bit commands ??? */
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("io write to port 64h, useless command %02x",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("unsupported io write to keyboard port %x, value = %x",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) address, (unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
default: BX_PANIC(("unknown address in bx_keyb_c::write()"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-11 18:04:58 +03:00
|
|
|
// service_paste_buf() transfers data from the paste buffer to the hardware
|
|
|
|
// keyboard buffer. It tries to transfer as many chars as possible at a
|
|
|
|
// time, but because different chars require different numbers of scancodes
|
|
|
|
// we have to be conservative. Note that this process depends on the
|
|
|
|
// keymap tables to know what chars correspond to what keys, and which
|
|
|
|
// chars require a shift or other modifier.
|
|
|
|
void
|
|
|
|
bx_keyb_c::service_paste_buf ()
|
|
|
|
{
|
|
|
|
if (!BX_KEY_THIS pastebuf) return;
|
2002-03-26 17:46:03 +03:00
|
|
|
BX_DEBUG (("service_paste_buf: ptr at %d out of %d", BX_KEY_THIS pastebuf_ptr, BX_KEY_THIS pastebuf_len));
|
2002-03-11 18:04:58 +03:00
|
|
|
int fill_threshold = BX_KBD_ELEMENTS - 8;
|
2002-12-27 01:19:44 +03:00
|
|
|
while ( (BX_KEY_THIS pastebuf_ptr < BX_KEY_THIS pastebuf_len) && ! BX_KEY_THIS stop_paste) {
|
2002-03-11 18:04:58 +03:00
|
|
|
if (BX_KEY_THIS s.kbd_internal_buffer.num_elements >= fill_threshold)
|
|
|
|
return;
|
|
|
|
// there room in the buffer for a keypress and a key release.
|
|
|
|
// send one keypress and a key release.
|
|
|
|
Bit8u byte = BX_KEY_THIS pastebuf[BX_KEY_THIS pastebuf_ptr];
|
2002-10-08 10:14:53 +04:00
|
|
|
BXKeyEntry *entry = bx_keymap.findAsciiChar (byte);
|
2002-03-11 18:04:58 +03:00
|
|
|
if (!entry) {
|
|
|
|
BX_ERROR (("paste character 0x%02x ignored", byte));
|
|
|
|
} else {
|
|
|
|
BX_DEBUG (("pasting character 0x%02x. baseKey is %04x", byte, entry->baseKey));
|
|
|
|
if (entry->modKey != BX_KEYMAP_UNKNOWN)
|
2002-10-25 01:07:56 +04:00
|
|
|
BX_KEY_THIS gen_scancode (entry->modKey);
|
|
|
|
BX_KEY_THIS gen_scancode (entry->baseKey);
|
|
|
|
BX_KEY_THIS gen_scancode (entry->baseKey | BX_KEY_RELEASED);
|
2002-03-11 18:04:58 +03:00
|
|
|
if (entry->modKey != BX_KEYMAP_UNKNOWN)
|
2002-10-25 01:07:56 +04:00
|
|
|
BX_KEY_THIS gen_scancode (entry->modKey | BX_KEY_RELEASED);
|
2002-03-11 18:04:58 +03:00
|
|
|
}
|
|
|
|
BX_KEY_THIS pastebuf_ptr++;
|
|
|
|
}
|
|
|
|
// reached end of pastebuf. free the memory it was using.
|
2002-09-25 03:52:54 +04:00
|
|
|
delete [] BX_KEY_THIS pastebuf;
|
2002-03-11 18:04:58 +03:00
|
|
|
BX_KEY_THIS pastebuf = NULL;
|
2002-12-27 01:19:44 +03:00
|
|
|
BX_KEY_THIS stop_paste = 0;
|
2002-03-11 18:04:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// paste_bytes schedules an arbitrary number of ASCII characters to be
|
|
|
|
// inserted into the hardware queue as it become available. Any previous
|
2002-03-11 19:25:52 +03:00
|
|
|
// paste which is still in progress will be thrown out. BYTES is a pointer
|
|
|
|
// to a region of memory containing the chars to be pasted. When the paste
|
2002-09-05 19:57:37 +04:00
|
|
|
// is complete, the keyboard code will call delete [] bytes;
|
2002-03-11 18:04:58 +03:00
|
|
|
void
|
|
|
|
bx_keyb_c::paste_bytes (Bit8u *bytes, Bit32s length)
|
|
|
|
{
|
|
|
|
BX_DEBUG (("paste_bytes: %d bytes", length));
|
|
|
|
if (BX_KEY_THIS pastebuf) {
|
|
|
|
BX_ERROR (("previous paste was not completed! %d chars lost",
|
|
|
|
BX_KEY_THIS pastebuf_len - BX_KEY_THIS pastebuf_ptr));
|
2002-09-25 03:52:54 +04:00
|
|
|
delete [] BX_KEY_THIS pastebuf; // free the old paste buffer
|
2002-03-11 18:04:58 +03:00
|
|
|
}
|
2002-09-25 03:52:54 +04:00
|
|
|
BX_KEY_THIS pastebuf = bytes;
|
2002-03-11 18:04:58 +03:00
|
|
|
BX_KEY_THIS pastebuf_ptr = 0;
|
|
|
|
BX_KEY_THIS pastebuf_len = length;
|
|
|
|
BX_KEY_THIS service_paste_buf ();
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::gen_scancode(Bit32u key)
|
|
|
|
{
|
2001-12-22 03:00:33 +03:00
|
|
|
unsigned char *scancode;
|
|
|
|
Bit8u i;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(( "gen_scancode %lld %x", bx_pc_system.time_ticks(), key));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-12-22 03:00:33 +03:00
|
|
|
if (!BX_KEY_THIS s.kbd_controller.scancodes_translate)
|
|
|
|
BX_DEBUG(("keyboard: gen_scancode with scancode_translate cleared"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("gen_scancode(): scancode: %08x", (unsigned) key));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// Ignore scancode if keyboard clock is driven low
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.kbd_clock_enabled==0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Ignore scancode if scanning is disabled
|
|
|
|
if (BX_KEY_THIS s.kbd_internal_buffer.scanning_enabled==0)
|
|
|
|
return;
|
|
|
|
|
2001-12-22 03:00:33 +03:00
|
|
|
// Switch between make and break code
|
2001-04-10 05:04:59 +04:00
|
|
|
if (key & BX_KEY_RELEASED)
|
2001-12-22 03:00:33 +03:00
|
|
|
scancode=(unsigned char *)scancodes[(key&0xFF)][BX_KEY_THIS s.kbd_controller.current_scancodes_set].brek;
|
|
|
|
else
|
|
|
|
scancode=(unsigned char *)scancodes[(key&0xFF)][BX_KEY_THIS s.kbd_controller.current_scancodes_set].make;
|
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.scancodes_translate) {
|
|
|
|
// Translate before send
|
|
|
|
Bit8u escaped=0x00;
|
|
|
|
|
|
|
|
for (i=0; i<strlen( (const char *)scancode ); i++) {
|
|
|
|
if (scancode[i] == 0xF0)
|
|
|
|
escaped=0x80;
|
|
|
|
else {
|
|
|
|
kbd_enQ(translation8042[scancode[i] ] | escaped );
|
|
|
|
BX_DEBUG(("keyboard: writing translated %02x",translation8042[scancode[i] ] | escaped));
|
|
|
|
escaped=0x00;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Send raw data
|
|
|
|
for (i=0; i<strlen( (const char *)scancode ); i++) {
|
|
|
|
kbd_enQ( scancode[i] );
|
|
|
|
BX_DEBUG(("keyboard: writing raw %02x",scancode[i]));
|
|
|
|
}
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1)
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_keyb_c::set_kbd_clock_enable(Bit8u value)
|
|
|
|
{
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool prev_kbd_clock_enabled;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (value==0) {
|
|
|
|
BX_KEY_THIS s.kbd_controller.kbd_clock_enabled = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* is another byte waiting to be sent from the keyboard ? */
|
|
|
|
prev_kbd_clock_enabled = BX_KEY_THIS s.kbd_controller.kbd_clock_enabled;
|
|
|
|
BX_KEY_THIS s.kbd_controller.kbd_clock_enabled = 1;
|
|
|
|
|
|
|
|
if (prev_kbd_clock_enabled==0 && BX_KEY_THIS s.kbd_controller.outb==0) {
|
|
|
|
activate_timer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::set_aux_clock_enable(Bit8u value)
|
|
|
|
{
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool prev_aux_clock_enabled;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("set_aux_clock_enable(%u)", (unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
if (value==0) {
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_clock_enabled = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* is another byte waiting to be sent from the keyboard ? */
|
|
|
|
prev_aux_clock_enabled = BX_KEY_THIS s.kbd_controller.aux_clock_enabled;
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_clock_enabled = 1;
|
|
|
|
if (prev_aux_clock_enabled==0 && BX_KEY_THIS s.kbd_controller.outb==0)
|
|
|
|
activate_timer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Bit8u
|
|
|
|
bx_keyb_c::get_kbd_enable(void)
|
|
|
|
{
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("get_kbd_enable(): getting kbd_clock_enabled of: %02x",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) BX_KEY_THIS s.kbd_controller.kbd_clock_enabled));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
return(BX_KEY_THIS s.kbd_controller.kbd_clock_enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::controller_enQ(Bit8u data, unsigned source)
|
|
|
|
{
|
|
|
|
// source is 0 for keyboard, 1 for mouse
|
|
|
|
|
2001-06-13 21:01:36 +04:00
|
|
|
BX_DEBUG(("controller_enQ(%02x) source=%02x", (unsigned) data,source));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb)
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_ERROR(("controller_enQ(): OUTB set!"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// see if we need to Q this byte from the controller
|
2001-06-13 21:01:36 +04:00
|
|
|
// remember this includes mouse bytes.
|
2001-04-10 05:04:59 +04:00
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb) {
|
|
|
|
if (BX_KEY_THIS s.controller_Qsize >= BX_KBD_CONTROLLER_QSIZE)
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("controller_enq(): controller_Q full!"));
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.controller_Q[BX_KEY_THIS s.controller_Qsize++] = data;
|
|
|
|
BX_KEY_THIS s.controller_Qsource = source;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-06-13 21:01:36 +04:00
|
|
|
// the Q is empty
|
2001-04-10 05:04:59 +04:00
|
|
|
if (source == 0) { // keyboard
|
|
|
|
BX_KEY_THIS s.kbd_controller.kbd_output_buffer = data;
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 1 auxb 0",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.auxb = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.inpb = 0;
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.allow_irq1)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq1_requested = 1;
|
|
|
|
}
|
|
|
|
else { // mouse
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_output_buffer = data;
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 1 auxb 1",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.auxb = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.inpb = 0;
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.allow_irq12)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq12_requested = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::kbd_enQ_imm(Bit8u val)
|
|
|
|
{
|
|
|
|
int tail;
|
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_internal_buffer.num_elements >= BX_KBD_ELEMENTS) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("internal keyboard buffer full (imm)"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enqueue scancode in multibyte internal keyboard buffer */
|
|
|
|
tail = (BX_KEY_THIS s.kbd_internal_buffer.head + BX_KEY_THIS s.kbd_internal_buffer.num_elements) %
|
|
|
|
BX_KBD_ELEMENTS;
|
|
|
|
|
|
|
|
BX_KEY_THIS s.kbd_controller.kbd_output_buffer = val;
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 1",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 1;
|
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.allow_irq1)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq1_requested = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::kbd_enQ(Bit8u scancode)
|
|
|
|
{
|
|
|
|
int tail;
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("enQ(%02x)", (unsigned) scancode));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_internal_buffer.num_elements >= BX_KBD_ELEMENTS) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("internal keyboard buffer full, ignoring scancode.(%02x)",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) scancode));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enqueue scancode in multibyte internal keyboard buffer */
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("enQ: putting scancode %02x in internal buffer",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) scancode));
|
2001-04-10 05:04:59 +04:00
|
|
|
tail = (BX_KEY_THIS s.kbd_internal_buffer.head + BX_KEY_THIS s.kbd_internal_buffer.num_elements) %
|
|
|
|
BX_KBD_ELEMENTS;
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.buffer[tail] = scancode;
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.num_elements++;
|
|
|
|
|
|
|
|
if (!BX_KEY_THIS s.kbd_controller.outb && BX_KEY_THIS s.kbd_controller.kbd_clock_enabled) {
|
|
|
|
activate_timer();
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("activating timer..."));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# not activating timer...");
|
|
|
|
//BX_DEBUG(( "# allow_irq1 = %u", (unsigned) BX_KEY_THIS s.kbd_controller.allow_irq1);
|
|
|
|
//BX_DEBUG(( "# outb = %u", (unsigned) BX_KEY_THIS s.kbd_controller.outb);
|
|
|
|
//BX_DEBUG(( "# clock_enab = %u", (unsigned) BX_KEY_THIS s.kbd_controller.kbd_clock_enabled);
|
|
|
|
//BX_DEBUG(( "# out_buffer = %u", (unsigned) BX_KEY_THIS s.kbd_controller.kbd_output_buffer);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
bx_bool BX_CPP_AttrRegparmN(3)
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_keyb_c::mouse_enQ_packet(Bit8u b1, Bit8u b2, Bit8u b3)
|
|
|
|
{
|
|
|
|
if ((BX_KEY_THIS s.mouse_internal_buffer.num_elements + 3) >= BX_MOUSE_BUFF_SIZE) {
|
|
|
|
return(0); /* buffer doesn't have the space */
|
|
|
|
}
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(("mouse: enQ_packet(%02x, %02x, %02x)",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
// (unsigned) b1, (unsigned) b2, (unsigned) b3));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
mouse_enQ(b1);
|
|
|
|
mouse_enQ(b2);
|
|
|
|
mouse_enQ(b3);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::mouse_enQ(Bit8u mouse_data)
|
|
|
|
{
|
|
|
|
int tail;
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("mouse_enQ(%02x)", (unsigned) mouse_data));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (BX_KEY_THIS s.mouse_internal_buffer.num_elements >= BX_MOUSE_BUFF_SIZE) {
|
2001-06-13 20:53:58 +04:00
|
|
|
BX_ERROR(("mouse: internal mouse buffer full, ignoring mouse data.(%02x)",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) mouse_data));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# mouse_enq() aux_clock_enabled = %u",
|
2001-04-10 05:04:59 +04:00
|
|
|
// (unsigned) BX_KEY_THIS s.kbd_controller.aux_clock_enabled);
|
|
|
|
|
|
|
|
/* enqueue mouse data in multibyte internal mouse buffer */
|
|
|
|
tail = (BX_KEY_THIS s.mouse_internal_buffer.head + BX_KEY_THIS s.mouse_internal_buffer.num_elements) %
|
|
|
|
BX_MOUSE_BUFF_SIZE;
|
|
|
|
BX_KEY_THIS s.mouse_internal_buffer.buffer[tail] = mouse_data;
|
|
|
|
BX_KEY_THIS s.mouse_internal_buffer.num_elements++;
|
|
|
|
|
|
|
|
if (!BX_KEY_THIS s.kbd_controller.outb && BX_KEY_THIS s.kbd_controller.aux_clock_enabled) {
|
|
|
|
activate_timer();
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# activating timer...");
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# not activating timer...");
|
|
|
|
//BX_DEBUG(( "# allow_irq12= %u", (unsigned) BX_KEY_THIS s.kbd_controller.allow_irq12);
|
|
|
|
//BX_DEBUG(( "# outb = %u", (unsigned) BX_KEY_THIS s.kbd_controller.outb);
|
|
|
|
//BX_DEBUG(( "# clock_enab = %u", (unsigned) BX_KEY_THIS s.kbd_controller.aux_clock_enabled);
|
|
|
|
//BX_DEBUG(( "# out_buffer = %u", (unsigned) BX_KEY_THIS s.kbd_controller.aux_output_buffer);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::kbd_ctrl_to_kbd(Bit8u value)
|
|
|
|
{
|
2001-12-12 13:38:39 +03:00
|
|
|
|
- commit patch from David Haslam <dch@sirius.clara.co.uk>
posted to bochs-developers on Wed, 29 Aug 2001 00:08:45 +0100
David Haslam wrote:
> I have been looking at the keyboard problem with Minix, which for
> those that haven't tried Minix results in every key press giving the
> response: ^@
>
> I am aware of the comments in the changelog that suggest removing 2
> keyboard ACKs in iodev/keyboard.cc, but this is a bit of a hack,
> (which is presumably why it was never incorporated).
>
> The problem seems to be that the Minix keyboard driver doesn't obey
> the rules, and Bochs doesn't model the 8042 accurately. When issuing
> commands to set the LEDs, Minix polls the 8042 output data register
> waiting for an ACK even though the OBF flag isn't set.
>
> Bochs returns zero under these circumstances, which seems to
> trigger obscure behaviour that messes up the Minix internal
> keyboard queue. I don't fully understand why Minix breaks, but I
> think the fact that the ACK generates an interrupt, and Minix treats
> it as a scan code also has something to do with it.
>
> In any case, I believe, the fix is for Bochs to return the output
> buffer contents, regardless of whether the OBF flag (called outb in
> Bochs) is set.
>
> I expect the real hardware allows the register to be read at anytime,
> and with this fix we are modelling the behaviour of the hardware more
> accurately.
>
> I have tested it with Minix 2.0.0. Also DOS 6.22 still works after this fix.
> Does anyone think this will break anything else?
>
> This diff is against the latest CVS of iodev/keyboard.cc, version 1.29
> The last part of the diff is a minor fix to an unrelated debug print.
2001-09-11 20:49:54 +04:00
|
|
|
BX_DEBUG(("controller passed byte %02xh to keyboard", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_internal_buffer.expecting_typematic) {
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.expecting_typematic = 0;
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.delay = (value >> 5) & 0x03;
|
|
|
|
switch (BX_KEY_THIS s.kbd_internal_buffer.delay) {
|
2001-11-14 04:28:53 +03:00
|
|
|
case 0: BX_INFO(("setting delay to 250 mS (unused)")); break;
|
|
|
|
case 1: BX_INFO(("setting delay to 500 mS (unused)")); break;
|
|
|
|
case 2: BX_INFO(("setting delay to 750 mS (unused)")); break;
|
|
|
|
case 3: BX_INFO(("setting delay to 1000 mS (unused)")); break;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.repeat_rate = value & 0x1f;
|
2002-10-31 02:58:03 +03:00
|
|
|
double cps = 1 /((double)(8 + (value & 0x07)) * (double)exp(log((double)2) * (double)((value >> 3) & 0x03)) * 0.00417);
|
2001-11-14 04:28:53 +03:00
|
|
|
BX_INFO(("setting repeat rate to %.1f cps (unused)", cps));
|
2001-04-10 05:04:59 +04:00
|
|
|
kbd_enQ(0xFA); // send ACK
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_internal_buffer.expecting_led_write) {
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.expecting_led_write = 0;
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.led_status = value;
|
2001-09-01 02:02:29 +04:00
|
|
|
BX_DEBUG(("LED status set to %02x",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) BX_KEY_THIS s.kbd_internal_buffer.led_status));
|
2001-04-10 05:04:59 +04:00
|
|
|
kbd_enQ(0xFA); // send ACK %%%
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-12-22 03:00:33 +03:00
|
|
|
if (BX_KEY_THIS s.kbd_controller.expecting_scancodes_set) {
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_scancodes_set = 0;
|
|
|
|
if( value != 0 ) {
|
|
|
|
if( value<4 ) {
|
|
|
|
BX_KEY_THIS s.kbd_controller.current_scancodes_set = (value-1);
|
|
|
|
BX_INFO(("Switched to scancode set %d\n",
|
2003-04-25 04:23:21 +04:00
|
|
|
(unsigned) BX_KEY_THIS s.kbd_controller.current_scancodes_set + 1));
|
2001-12-22 03:00:33 +03:00
|
|
|
kbd_enQ(0xFA);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BX_ERROR(("Received scancodes set out of range: %d\n", value ));
|
|
|
|
kbd_enQ(0xFF); // send ERROR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Send current scancodes set to port 0x60
|
|
|
|
kbd_enQ( 1 + (BX_KEY_THIS s.kbd_controller.current_scancodes_set) );
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
switch (value) {
|
|
|
|
case 0x00: // ??? ignore and let OS timeout with no response
|
|
|
|
kbd_enQ(0xFA); // send ACK %%%
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x05: // ???
|
|
|
|
// (mch) trying to get this to work...
|
|
|
|
BX_KEY_THIS s.kbd_controller.sysf = 1;
|
|
|
|
kbd_enQ_imm(0xfe);
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xed: // LED Write
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.expecting_led_write = 1;
|
2001-12-05 23:36:03 +03:00
|
|
|
kbd_enQ_imm(0xFA); // send ACK %%%
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xee: // echo
|
|
|
|
kbd_enQ(0xEE); // return same byte (EEh) as echo diagnostic
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2001-12-22 03:00:33 +03:00
|
|
|
case 0xf0: // Select alternate scan code set
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_scancodes_set = 1;
|
|
|
|
BX_DEBUG(("Expecting scancode set info...\n"));
|
|
|
|
kbd_enQ(0xFA); // send ACK
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
case 0xf2: // identify keyboard
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("identify keyboard command received"));
|
2001-12-12 13:38:39 +03:00
|
|
|
|
2001-12-22 03:00:33 +03:00
|
|
|
// XT sends nothing, AT sends ACK
|
|
|
|
// MFII with translation sends ACK+ABh+41h
|
|
|
|
// MFII without translation sends ACK+ABh+83h
|
2001-12-12 13:38:39 +03:00
|
|
|
if (bx_options.Okeyboard_type->get() != BX_KBD_XT_TYPE) {
|
|
|
|
kbd_enQ(0xFA);
|
|
|
|
if (bx_options.Okeyboard_type->get() == BX_KBD_MF_TYPE) {
|
|
|
|
kbd_enQ(0xAB);
|
2001-12-22 03:00:33 +03:00
|
|
|
|
|
|
|
if(BX_KEY_THIS s.kbd_controller.scancodes_translate)
|
|
|
|
kbd_enQ(0x41);
|
|
|
|
else
|
|
|
|
kbd_enQ(0x83);
|
2001-12-12 13:38:39 +03:00
|
|
|
}
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xf3: // typematic info
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.expecting_typematic = 1;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("setting typematic info"));
|
2001-04-10 05:04:59 +04:00
|
|
|
kbd_enQ(0xFA); // send ACK
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2003-06-03 00:36:30 +04:00
|
|
|
case 0xf4: // enable keyboard
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.scanning_enabled = 1;
|
2003-06-03 00:36:30 +04:00
|
|
|
kbd_enQ(0xFA); // send ACK
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xf5: // reset keyboard to power-up settings and disable scanning
|
|
|
|
resetinternals(1);
|
|
|
|
kbd_enQ(0xFA); // send ACK
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.scanning_enabled = 0;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("reset-disable command received"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xf6: // reset keyboard to power-up settings and enable scanning
|
|
|
|
resetinternals(1);
|
|
|
|
kbd_enQ(0xFA); // send ACK
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.scanning_enabled = 1;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("reset-enable command received"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xf7: // PS/2 Set All Keys To Typematic
|
|
|
|
case 0xf8: // PS/2 Set All Keys to Make/Break
|
|
|
|
case 0xf9: // PS/2 PS/2 Set All Keys to Make
|
|
|
|
case 0xfa: // PS/2 Set All Keys to Typematic Make/Break
|
|
|
|
case 0xfb: // PS/2 Set Key Type to Typematic
|
|
|
|
case 0xfc: // PS/2 Set Key Type to Make/Break
|
|
|
|
case 0xfd: // PS/2 Set Key Type to Make
|
|
|
|
// Silently ignore and let the OS timeout, for now.
|
|
|
|
// If anyone has code around that makes use of that, I can
|
|
|
|
// provide documentation on their behavior (ask core@ggi-project.org)
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xfe: // resend. aiiee.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC( ("got 0xFE (resend)"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xff: // reset: internal keyboard reset and afterwards the BAT
|
2001-11-26 12:55:30 +03:00
|
|
|
BX_DEBUG(("reset command received"));
|
2003-06-03 00:36:30 +04:00
|
|
|
resetinternals(1);
|
2001-04-10 05:04:59 +04:00
|
|
|
kbd_enQ(0xFA); // send ACK
|
|
|
|
kbd_enQ(0xAA); // BAT test passed
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2001-11-26 12:55:30 +03:00
|
|
|
case 0xd3:
|
|
|
|
kbd_enQ(0xfa);
|
|
|
|
return;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
default:
|
2001-05-09 01:19:57 +04:00
|
|
|
/* XXX fix this properly:
|
|
|
|
http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/mouse/mouse.html
|
|
|
|
http://sourceforge.net/tracker/index.php?func=detail&aid=422457&group_id=12580&atid=112580
|
|
|
|
*/
|
2001-09-01 02:02:29 +04:00
|
|
|
BX_ERROR(("kbd_ctrl_to_kbd(): got value of %02x",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
kbd_enQ(0xFA); /* send ACK ??? */
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void
|
|
|
|
bx_keyb_c::timer_handler(void *this_ptr)
|
|
|
|
{
|
|
|
|
bx_keyb_c *class_ptr = (bx_keyb_c *) this_ptr;
|
|
|
|
unsigned retval;
|
|
|
|
|
|
|
|
// retval=class_ptr->periodic( bx_options.Okeyboard_serial_delay->get());
|
|
|
|
retval=class_ptr->periodic(1);
|
|
|
|
|
|
|
|
if(retval&0x01)
|
|
|
|
DEV_pic_raise_irq(1);
|
|
|
|
if(retval&0x02)
|
|
|
|
DEV_pic_raise_irq(12);
|
|
|
|
}
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
unsigned
|
|
|
|
bx_keyb_c::periodic( Bit32u usec_delta )
|
|
|
|
{
|
2003-01-05 04:37:21 +03:00
|
|
|
/* static int multiple=0; */
|
2002-06-30 22:08:02 +04:00
|
|
|
static unsigned count_before_paste=0;
|
2001-04-10 05:04:59 +04:00
|
|
|
Bit8u retval;
|
|
|
|
|
|
|
|
UNUSED( usec_delta );
|
|
|
|
|
2002-03-26 16:51:48 +03:00
|
|
|
if (BX_KEY_THIS s.kbd_controller.kbd_clock_enabled ) {
|
|
|
|
if(++count_before_paste>=BX_KEY_THIS pastedelay) {
|
2002-03-26 17:46:03 +03:00
|
|
|
// after the paste delay, consider adding moving more chars
|
|
|
|
// from the paste buffer to the keyboard buffer.
|
2002-03-26 16:51:48 +03:00
|
|
|
BX_KEY_THIS service_paste_buf ();
|
|
|
|
count_before_paste=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
retval = BX_KEY_THIS s.kbd_controller.irq1_requested | (BX_KEY_THIS s.kbd_controller.irq12_requested << 1);
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq1_requested = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq12_requested = 0;
|
|
|
|
|
|
|
|
if ( BX_KEY_THIS s.kbd_controller.timer_pending == 0 ) {
|
|
|
|
return(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( usec_delta >= BX_KEY_THIS s.kbd_controller.timer_pending ) {
|
|
|
|
BX_KEY_THIS s.kbd_controller.timer_pending = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BX_KEY_THIS s.kbd_controller.timer_pending -= usec_delta;
|
|
|
|
return(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.outb) {
|
|
|
|
return(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nothing in outb, look for possible data xfer from keyboard or mouse */
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.kbd_clock_enabled && BX_KEY_THIS s.kbd_internal_buffer.num_elements) {
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# servicing keyboard code");
|
|
|
|
BX_DEBUG(("service_keyboard: key in internal buffer waiting"));
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.kbd_output_buffer =
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.buffer[BX_KEY_THIS s.kbd_internal_buffer.head];
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 1",__LINE__)); // das
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 1;
|
2001-06-13 21:01:36 +04:00
|
|
|
// commented out since this would override the current state of the
|
|
|
|
// mouse buffer flag - no bug seen - just seems wrong (das)
|
|
|
|
// BX_KEY_THIS s.kbd_controller.auxb = 0;
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# ___kbd::periodic kbd");
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.head = (BX_KEY_THIS s.kbd_internal_buffer.head + 1) %
|
|
|
|
BX_KBD_ELEMENTS;
|
|
|
|
BX_KEY_THIS s.kbd_internal_buffer.num_elements--;
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.allow_irq1)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq1_requested = 1;
|
|
|
|
}
|
2001-08-24 17:48:05 +04:00
|
|
|
else {
|
|
|
|
create_mouse_packet(0);
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.aux_clock_enabled && BX_KEY_THIS s.mouse_internal_buffer.num_elements) {
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# servicing mouse code");
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_DEBUG(("service_keyboard: key(from mouse) in internal buffer waiting"));
|
|
|
|
BX_KEY_THIS s.kbd_controller.aux_output_buffer =
|
|
|
|
BX_KEY_THIS s.mouse_internal_buffer.buffer[BX_KEY_THIS s.mouse_internal_buffer.head];
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-13 21:01:36 +04:00
|
|
|
// BX_INFO(("kbd: %04d outb 1 auxb 1",__LINE__)); //das
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.kbd_controller.outb = 1;
|
|
|
|
BX_KEY_THIS s.kbd_controller.auxb = 1;
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# ___kbd:periodic aux");
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse_internal_buffer.head = (BX_KEY_THIS s.mouse_internal_buffer.head + 1) %
|
|
|
|
BX_MOUSE_BUFF_SIZE;
|
|
|
|
BX_KEY_THIS s.mouse_internal_buffer.num_elements--;
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "# allow12 = %u", (unsigned) BX_KEY_THIS s.kbd_controller.allow_irq12);
|
2001-08-24 17:48:05 +04:00
|
|
|
if (BX_KEY_THIS s.kbd_controller.allow_irq12)
|
|
|
|
BX_KEY_THIS s.kbd_controller.irq12_requested = 1;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-08-24 17:48:05 +04:00
|
|
|
else {
|
|
|
|
BX_DEBUG(("service_keyboard(): no keys waiting"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-08-24 17:48:05 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
return(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::activate_timer(void)
|
|
|
|
{
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.timer_pending == 0) {
|
2002-10-25 01:07:56 +04:00
|
|
|
// BX_KEY_THIS s.kbd_controller.timer_pending = bx_options.Okeyboard_serial_delay->get ();
|
|
|
|
BX_KEY_THIS s.kbd_controller.timer_pending = 1;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::kbd_ctrl_to_mouse(Bit8u value)
|
|
|
|
{
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("MOUSE: kbd_ctrl_to_mouse(%02xh)", (unsigned) value));
|
|
|
|
BX_DEBUG((" enable = %u", (unsigned) BX_KEY_THIS s.mouse.enable));
|
|
|
|
BX_DEBUG((" allow_irq12 = %u",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) BX_KEY_THIS s.kbd_controller.allow_irq12));
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG((" aux_clock_enabled = %u",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) BX_KEY_THIS s.kbd_controller.aux_clock_enabled));
|
2001-05-30 22:56:02 +04:00
|
|
|
//BX_DEBUG(( "MOUSE: kbd_ctrl_to_mouse(%02xh)", (unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// an ACK (0xFA) is always the first response to any valid input
|
|
|
|
// received from the system other than Set-Wrap-Mode & Resend-Command
|
|
|
|
|
|
|
|
|
|
|
|
if (BX_KEY_THIS s.kbd_controller.expecting_mouse_parameter) {
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_mouse_parameter = 0;
|
|
|
|
switch (BX_KEY_THIS s.kbd_controller.last_mouse_command) {
|
|
|
|
case 0xf3: // Set Mouse Sample Rate
|
|
|
|
BX_KEY_THIS s.mouse.sample_rate = value;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Sampling rate set: %d Hz", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
controller_enQ(0xFA, 1); // ack
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xe8: // Set Mouse Resolution
|
|
|
|
switch (value) {
|
|
|
|
case 0:
|
|
|
|
BX_KEY_THIS s.mouse.resolution_cpmm = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
BX_KEY_THIS s.mouse.resolution_cpmm = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BX_KEY_THIS s.mouse.resolution_cpmm = 4;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BX_KEY_THIS s.mouse.resolution_cpmm = 8;
|
|
|
|
break;
|
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("[mouse] Unknown resolution %d", value));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
}
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Resolution set to %d counts per mm",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
BX_KEY_THIS s.mouse.resolution_cpmm));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
controller_enQ(0xFA, 1); // ack
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("MOUSE: unknown last command (%02xh)", (unsigned) BX_KEY_THIS s.kbd_controller.last_mouse_command));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_mouse_parameter = 0;
|
|
|
|
BX_KEY_THIS s.kbd_controller.last_mouse_command = value;
|
2001-06-13 21:01:36 +04:00
|
|
|
|
|
|
|
// test for wrap mode first
|
|
|
|
if (BX_KEY_THIS s.mouse.mode == MOUSE_MODE_WRAP) {
|
|
|
|
// if not a reset command or reset wrap mode
|
|
|
|
// then just echo the byte.
|
|
|
|
if ((value != 0xff) && (value != 0xec)) {
|
|
|
|
if (bx_dbg.mouse)
|
|
|
|
BX_INFO(("[mouse] wrap mode: Ignoring command %0X02.",value));
|
|
|
|
controller_enQ(value,1);
|
|
|
|
// bail out
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
switch ( value ) {
|
|
|
|
case 0xe6: // Set Mouse Scaling to 1:1
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
BX_KEY_THIS s.mouse.scaling = 2;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Scaling set to 1:1"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xe7: // Set Mouse Scaling to 2:1
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
BX_KEY_THIS s.mouse.scaling = 2;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Scaling set to 2:1"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xe8: // Set Mouse Resolution
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_mouse_parameter = 1;
|
|
|
|
break;
|
|
|
|
|
2001-06-13 21:01:36 +04:00
|
|
|
case 0xea: // Set Stream Mode
|
|
|
|
if (bx_dbg.mouse)
|
|
|
|
BX_INFO(("[mouse] Mouse stream mode on."));
|
|
|
|
BX_KEY_THIS s.mouse.mode = MOUSE_MODE_STREAM;
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xec: // Reset Wrap Mode
|
|
|
|
// unless we are in wrap mode ignore the command
|
|
|
|
if ( BX_KEY_THIS s.mouse.mode == MOUSE_MODE_WRAP) {
|
|
|
|
if (bx_dbg.mouse)
|
|
|
|
BX_INFO(("[mouse] Mouse wrap mode off."));
|
|
|
|
// restore previous mode except disable stream mode reporting.
|
|
|
|
// ### TODO disabling reporting in stream mode
|
|
|
|
BX_KEY_THIS s.mouse.mode = BX_KEY_THIS s.mouse.saved_mode;
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xee: // Set Wrap Mode
|
|
|
|
// ### TODO flush output queue.
|
|
|
|
// ### TODO disable interrupts if in stream mode.
|
|
|
|
if (bx_dbg.mouse)
|
|
|
|
BX_INFO(("[mouse] Mouse wrap mode on."));
|
|
|
|
BX_KEY_THIS s.mouse.saved_mode = BX_KEY_THIS s.mouse.mode;
|
|
|
|
BX_KEY_THIS s.mouse.mode = MOUSE_MODE_WRAP;
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xf0: // Set Remote Mode (polling mode, i.e. not stream mode.)
|
|
|
|
if (bx_dbg.mouse)
|
|
|
|
BX_INFO(("[mouse] Mouse remote mode on."));
|
|
|
|
// ### TODO should we flush/discard/ignore any already queued packets?
|
|
|
|
BX_KEY_THIS s.mouse.mode = MOUSE_MODE_REMOTE;
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
case 0xf2: // Read Device Type
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
controller_enQ(0x00, 1); // Device ID
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Read mouse ID"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xf3: // Set Mouse Sample Rate (sample rate written to port 60h)
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
BX_KEY_THIS s.kbd_controller.expecting_mouse_parameter = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xf4: // Enable (in stream mode)
|
|
|
|
BX_KEY_THIS s.mouse.enable = 1;
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Mouse enabled (stream mode)"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xf5: // Disable (in stream mode)
|
|
|
|
BX_KEY_THIS s.mouse.enable = 0;
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Mouse disabled (stream mode)"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
2001-05-03 21:50:50 +04:00
|
|
|
case 0xf6: // Set Defaults
|
|
|
|
BX_KEY_THIS s.mouse.sample_rate = 100; /* reports per second (default) */
|
|
|
|
BX_KEY_THIS s.mouse.resolution_cpmm = 4; /* 4 counts per millimeter (default) */
|
|
|
|
BX_KEY_THIS s.mouse.scaling = 1; /* 1:1 (default) */
|
|
|
|
BX_KEY_THIS s.mouse.enable = 0;
|
|
|
|
BX_KEY_THIS s.mouse.mode = MOUSE_MODE_STREAM;
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Set Defaults"));
|
2001-05-03 21:50:50 +04:00
|
|
|
break;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
case 0xff: // Reset
|
|
|
|
BX_KEY_THIS s.mouse.sample_rate = 100; /* reports per second (default) */
|
|
|
|
BX_KEY_THIS s.mouse.resolution_cpmm = 4; /* 4 counts per millimeter (default) */
|
|
|
|
BX_KEY_THIS s.mouse.scaling = 1; /* 1:1 (default) */
|
|
|
|
BX_KEY_THIS s.mouse.mode = MOUSE_MODE_RESET;
|
|
|
|
BX_KEY_THIS s.mouse.enable = 0;
|
|
|
|
/* (mch) NT expects an ack here */
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
controller_enQ(0xAA, 1); // completion code
|
|
|
|
controller_enQ(0x00, 1); // ID code (normal mouse, wheelmouse has id 0x3)
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Mouse reset"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xe9: // Get mouse information
|
|
|
|
// should we ack here? (mch): Yes
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
|
|
|
controller_enQ(BX_KEY_THIS s.mouse.get_status_byte(), 1); // status
|
|
|
|
controller_enQ(BX_KEY_THIS s.mouse.get_resolution_byte(), 1); // resolution
|
|
|
|
controller_enQ(BX_KEY_THIS s.mouse.sample_rate, 1); // sample rate
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("[mouse] Get mouse information"));
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
|
2001-04-10 06:12:30 +04:00
|
|
|
case 0xeb: // Read Data (send a packet when in Remote Mode)
|
|
|
|
controller_enQ(0xFA, 1); // ACK
|
2001-06-13 21:01:36 +04:00
|
|
|
// perhaps we should be adding some movement here.
|
2001-04-10 06:12:30 +04:00
|
|
|
mouse_enQ_packet( ((BX_KEY_THIS s.mouse.button_status & 0x0f) | 0x08),
|
|
|
|
0x00, 0x00 ); // bit3 of first byte always set
|
|
|
|
//assumed we really aren't in polling mode, a rather odd assumption.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_ERROR(("[mouse] Warning: Read Data command partially supported."));
|
2001-04-10 06:12:30 +04:00
|
|
|
break;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2001-05-03 21:50:50 +04:00
|
|
|
//FEh Resend
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("MOUSE: kbd_ctrl_to_mouse(%02xh)", (unsigned) value));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-24 17:48:05 +04:00
|
|
|
void
|
|
|
|
bx_keyb_c::create_mouse_packet(bool force_enq) {
|
2001-04-10 05:04:59 +04:00
|
|
|
Bit8u b1, b2, b3;
|
|
|
|
|
2001-08-24 17:48:05 +04:00
|
|
|
// BX_DEBUG("Calling create_mouse_packet: force_enq=%d\n",force_enq);
|
2001-06-13 21:01:36 +04:00
|
|
|
|
2001-08-24 17:48:05 +04:00
|
|
|
if(BX_KEY_THIS s.mouse_internal_buffer.num_elements && !force_enq)
|
2001-06-13 21:01:36 +04:00
|
|
|
return;
|
|
|
|
|
2001-08-24 17:48:05 +04:00
|
|
|
// BX_DEBUG("Got to first milestone: force_enq=%d\n",force_enq);
|
2001-06-13 21:01:36 +04:00
|
|
|
|
2001-08-24 17:48:05 +04:00
|
|
|
Bit16s delta_x = BX_KEY_THIS s.mouse.delayed_dx;
|
|
|
|
Bit16s delta_y = BX_KEY_THIS s.mouse.delayed_dy;
|
|
|
|
Bit8u button_state=BX_KEY_THIS s.mouse.button_status | 0x08;
|
|
|
|
|
|
|
|
if(!force_enq && !delta_x && !delta_y) {
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
2001-08-24 17:48:05 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-08-24 17:48:05 +04:00
|
|
|
// BX_DEBUG("Got to second milestone: delta_x=%d, delta_y=%d\n",delta_x,delta_y);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-08-24 17:48:05 +04:00
|
|
|
if(delta_x>254) delta_x=254;
|
|
|
|
if(delta_x<-254) delta_x=-254;
|
|
|
|
if(delta_y>254) delta_y=254;
|
|
|
|
if(delta_y<-254) delta_y=-254;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
b1 = (button_state & 0x0f) | 0x08; // bit3 always set
|
|
|
|
|
|
|
|
if ( (delta_x>=0) && (delta_x<=255) ) {
|
2002-09-26 13:00:52 +04:00
|
|
|
b2 = (Bit8u) delta_x;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dx-=delta_x;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
else if ( delta_x > 255 ) {
|
2002-09-26 13:00:52 +04:00
|
|
|
b2 = (Bit8u) 0xff;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dx-=255;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
else if ( delta_x >= -256 ) {
|
2002-09-26 13:00:52 +04:00
|
|
|
b2 = (Bit8u) delta_x;
|
2001-04-10 05:04:59 +04:00
|
|
|
b1 |= 0x10;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dx-=delta_x;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
else {
|
2002-09-26 13:00:52 +04:00
|
|
|
b2 = (Bit8u) 0x00;
|
2001-04-10 05:04:59 +04:00
|
|
|
b1 |= 0x10;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dx+=256;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( (delta_y>=0) && (delta_y<=255) ) {
|
2002-09-26 13:00:52 +04:00
|
|
|
b3 = (Bit8u) delta_y;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dy-=delta_y;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
else if ( delta_y > 255 ) {
|
2002-09-26 13:00:52 +04:00
|
|
|
b3 = (Bit8u) 0xff;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dy-=255;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
else if ( delta_y >= -256 ) {
|
2002-09-26 13:00:52 +04:00
|
|
|
b3 = (Bit8u) delta_y;
|
2001-04-10 05:04:59 +04:00
|
|
|
b1 |= 0x20;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dy-=delta_y;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
else {
|
2002-09-26 13:00:52 +04:00
|
|
|
b3 = (Bit8u) 0x00;
|
2001-04-10 05:04:59 +04:00
|
|
|
b1 |= 0x20;
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_KEY_THIS s.mouse.delayed_dy+=256;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
mouse_enQ_packet(b1, b2, b3);
|
|
|
|
}
|
|
|
|
|
2001-09-21 06:46:17 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::mouse_enabled_changed(bool enabled) {
|
2002-10-25 01:07:56 +04:00
|
|
|
if(s.mouse.delayed_dx || BX_KEY_THIS s.mouse.delayed_dy) {
|
2001-09-21 06:46:17 +04:00
|
|
|
create_mouse_packet(1);
|
|
|
|
}
|
2002-10-25 01:07:56 +04:00
|
|
|
s.mouse.delayed_dx=0;
|
|
|
|
s.mouse.delayed_dy=0;
|
2001-09-21 06:46:17 +04:00
|
|
|
BX_DEBUG(("Keyboard mouse disable called."));
|
|
|
|
}
|
|
|
|
|
2001-08-24 17:48:05 +04:00
|
|
|
void
|
|
|
|
bx_keyb_c::mouse_motion(int delta_x, int delta_y, unsigned button_state)
|
|
|
|
{
|
|
|
|
bool force_enq=0;
|
|
|
|
|
|
|
|
// If mouse events are disabled on the GUI headerbar, don't
|
|
|
|
// generate any mouse data
|
|
|
|
if (bx_options.Omouse_enabled->get () == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// don't generate interrupts if we are in remote mode.
|
|
|
|
if ( BX_KEY_THIS s.mouse.mode == MOUSE_MODE_REMOTE)
|
|
|
|
// is there any point in doing any work if we don't act on the result
|
|
|
|
// so go home.
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Note: enable only applies in STREAM MODE.
|
|
|
|
if ( BX_KEY_THIS s.mouse.enable==0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// scale down the motion
|
|
|
|
if ( (delta_x < -1) || (delta_x > 1) )
|
|
|
|
delta_x /= 2;
|
|
|
|
if ( (delta_y < -1) || (delta_y > 1) )
|
|
|
|
delta_y /= 2;
|
|
|
|
|
|
|
|
#ifdef VERBOSE_KBD_DEBUG
|
|
|
|
if (delta_x != 0 || delta_y != 0)
|
|
|
|
BX_DEBUG(("[mouse] Dx=%d Dy=%d", delta_x, delta_y));
|
|
|
|
#endif /* ifdef VERBOSE_KBD_DEBUG */
|
|
|
|
|
2002-06-30 22:08:02 +04:00
|
|
|
if( (delta_x==0) && (delta_y==0) && (BX_KEY_THIS s.mouse.button_status == (button_state & 0x3) ) ) {
|
2001-08-24 17:48:05 +04:00
|
|
|
BX_DEBUG(("Ignoring useless mouse_motion call:\n"));
|
|
|
|
BX_DEBUG(("This should be fixed in the gui code.\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(BX_KEY_THIS s.mouse.button_status != (button_state & 0x3)) {
|
|
|
|
force_enq=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_KEY_THIS s.mouse.button_status = button_state & 0x3;
|
|
|
|
|
|
|
|
if(delta_x>255) delta_x=255;
|
|
|
|
if(delta_y>255) delta_y=255;
|
|
|
|
if(delta_x<-256) delta_x=-256;
|
|
|
|
if(delta_y<-256) delta_y=-256;
|
|
|
|
|
|
|
|
BX_KEY_THIS s.mouse.delayed_dx+=delta_x;
|
|
|
|
BX_KEY_THIS s.mouse.delayed_dy+=delta_y;
|
|
|
|
|
|
|
|
if((BX_KEY_THIS s.mouse.delayed_dx>255)||
|
|
|
|
(BX_KEY_THIS s.mouse.delayed_dx<-256)||
|
|
|
|
(BX_KEY_THIS s.mouse.delayed_dy>255)||
|
|
|
|
(BX_KEY_THIS s.mouse.delayed_dy<-256)) {
|
|
|
|
force_enq=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
create_mouse_packet(force_enq);
|
|
|
|
}
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
bx_keyb_c::put_scancode( unsigned char *code, int count )
|
|
|
|
{
|
|
|
|
for ( int i = 0 ; i < count ; i++ ) {
|
|
|
|
kbd_enQ( code[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_keyb_c::SaveState( class state_file *fd )
|
|
|
|
{
|
|
|
|
fd->write_check ("keyboard start");
|
|
|
|
fd->write (&BX_KEY_THIS s, sizeof (BX_KEY_THIS s));
|
|
|
|
fd->write_check ("keyboard end");
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_keyb_c::LoadState( class state_file *fd )
|
|
|
|
{
|
|
|
|
fd->read_check ("keyboard start");
|
|
|
|
fd->read (&BX_KEY_THIS s, sizeof (BX_KEY_THIS s));
|
|
|
|
fd->read_check ("keyboard end");
|
|
|
|
return(0);
|
|
|
|
}
|
2002-10-25 01:07:56 +04:00
|
|
|
|