2002-04-02 01:53:23 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-02-08 00:05:31 +03:00
|
|
|
// $Id: biosdev.cc,v 1.17 2009-02-07 21:05:30 sshwarts Exp $
|
2002-04-02 01:53:23 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
|
|
|
//
|
|
|
|
// 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
|
2009-02-08 00:05:31 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
|
2002-04-02 01:53:23 +04:00
|
|
|
|
|
|
|
|
2002-04-24 11:39:47 +04:00
|
|
|
// Here are the virtual ports use to display messages from the bioses :
|
|
|
|
//
|
2004-09-05 21:57:22 +04:00
|
|
|
// 0x0400 : rombios Panic port with line number
|
|
|
|
// 0x0401 : rombios Panic port with message, panic flag or line number
|
2002-04-24 11:39:47 +04:00
|
|
|
// 0x0402 : rombios Info port with message
|
|
|
|
// 0x0403 : rombios Debug port with message
|
|
|
|
//
|
|
|
|
// 0x0500 : vgabios Info port with message
|
2004-09-05 21:57:22 +04:00
|
|
|
// 0x0501 : vgabios Panic port with line number
|
|
|
|
// 0x0502 : vgabios Panic port with message, panic flag or line number
|
2002-04-24 11:39:47 +04:00
|
|
|
// 0x0503 : vgabios Debug port with message
|
2002-04-02 01:53:23 +04:00
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
2008-01-27 01:24:03 +03:00
|
|
|
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
2002-10-25 01:07:56 +04:00
|
|
|
// is used to know when we are exporting symbols and when we are importing.
|
|
|
|
#define BX_PLUGGABLE
|
|
|
|
|
2004-06-19 19:20:15 +04:00
|
|
|
#include "iodev.h"
|
2008-12-29 23:16:08 +03:00
|
|
|
#include "biosdev.h"
|
2002-04-02 01:53:23 +04:00
|
|
|
|
2006-09-10 21:18:44 +04:00
|
|
|
bx_biosdev_c *theBiosDevice = NULL;
|
2002-10-25 01:07:56 +04:00
|
|
|
|
2006-09-10 21:18:44 +04:00
|
|
|
logfunctions *bioslog;
|
|
|
|
logfunctions *vgabioslog;
|
|
|
|
|
|
|
|
int libbiosdev_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
2006-09-10 21:18:44 +04:00
|
|
|
theBiosDevice = new bx_biosdev_c();
|
2002-10-25 01:07:56 +04:00
|
|
|
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theBiosDevice, BX_PLUGIN_BIOSDEV);
|
|
|
|
return(0); // Success
|
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
|
2006-09-10 21:18:44 +04:00
|
|
|
void libbiosdev_LTX_plugin_fini(void)
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
2006-09-10 21:18:44 +04:00
|
|
|
delete theBiosDevice;
|
2002-10-25 01:07:56 +04:00
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
|
|
|
|
bx_biosdev_c::bx_biosdev_c(void)
|
|
|
|
{
|
|
|
|
bioslog = new logfunctions();
|
|
|
|
bioslog->put("BIOS");
|
|
|
|
|
|
|
|
vgabioslog = new logfunctions();
|
|
|
|
vgabioslog->put("VBIOS");
|
|
|
|
}
|
|
|
|
|
|
|
|
bx_biosdev_c::~bx_biosdev_c(void)
|
|
|
|
{
|
2006-09-10 21:18:44 +04:00
|
|
|
bioslog->ldebug("Exit");
|
|
|
|
if (bioslog != NULL) {
|
|
|
|
delete bioslog;
|
|
|
|
bioslog = NULL;
|
|
|
|
}
|
|
|
|
if (vgabioslog != NULL) {
|
|
|
|
delete vgabioslog;
|
|
|
|
vgabioslog = NULL;
|
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
}
|
|
|
|
|
2006-09-10 21:18:44 +04:00
|
|
|
void bx_biosdev_c::init(void)
|
2002-04-02 01:53:23 +04:00
|
|
|
{
|
2003-07-31 19:29:34 +04:00
|
|
|
DEV_register_iowrite_handler(this, write_handler, 0x0400, "Bios Panic Port 1", 3);
|
|
|
|
DEV_register_iowrite_handler(this, write_handler, 0x0401, "Bios Panic Port 2", 3);
|
|
|
|
DEV_register_iowrite_handler(this, write_handler, 0x0402, "Bios Info Port", 1);
|
2004-09-05 21:57:22 +04:00
|
|
|
DEV_register_iowrite_handler(this, write_handler, 0x0403, "Bios Debug Port", 1);
|
2003-07-31 19:29:34 +04:00
|
|
|
|
2004-09-05 21:57:22 +04:00
|
|
|
DEV_register_iowrite_handler(this, write_handler, 0x0500, "VGABios Info Port", 1);
|
2003-07-31 19:29:34 +04:00
|
|
|
DEV_register_iowrite_handler(this, write_handler, 0x0501, "VGABios Panic Port 1", 3);
|
|
|
|
DEV_register_iowrite_handler(this, write_handler, 0x0502, "VGABios Panic Port 2", 3);
|
|
|
|
DEV_register_iowrite_handler(this, write_handler, 0x0503, "VGABios Debug Port", 1);
|
2002-04-02 01:53:23 +04:00
|
|
|
|
2006-09-10 21:18:44 +04:00
|
|
|
s.bios_message_i = 0;
|
|
|
|
s.bios_panic_flag = 0;
|
|
|
|
s.vgabios_message_i = 0;
|
|
|
|
s.vgabios_panic_flag = 0;
|
2002-08-27 23:54:46 +04:00
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
|
|
|
|
// static IO port write callback handler
|
|
|
|
// redirects to non-static class handler to avoid virtual functions
|
|
|
|
|
2006-09-10 21:18:44 +04:00
|
|
|
void bx_biosdev_c::write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len)
|
2002-04-02 01:53:23 +04:00
|
|
|
{
|
|
|
|
#if !BX_USE_BIOS_SMF
|
|
|
|
bx_biosdev_c *class_ptr = (bx_biosdev_c *) this_ptr;
|
|
|
|
|
|
|
|
class_ptr->write(address, value, io_len);
|
|
|
|
}
|
|
|
|
|
2006-09-10 21:18:44 +04:00
|
|
|
void bx_biosdev_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
2002-04-02 01:53:23 +04:00
|
|
|
{
|
|
|
|
#else
|
|
|
|
UNUSED(this_ptr);
|
|
|
|
#endif // !BX_USE_BIOS_SMF
|
|
|
|
UNUSED(io_len);
|
|
|
|
|
|
|
|
|
|
|
|
switch (address) {
|
|
|
|
// 0x400-0x401 are used as panic ports for the rombios
|
|
|
|
case 0x0401:
|
2004-09-05 21:57:22 +04:00
|
|
|
if (value==0) {
|
|
|
|
// The next message sent to the info port will cause a panic
|
|
|
|
BX_BIOS_THIS s.bios_panic_flag = 1;
|
|
|
|
break;
|
|
|
|
} else if (BX_BIOS_THIS s.bios_message_i > 0) {
|
|
|
|
// if there are bits of message in the buffer, print them as the
|
|
|
|
// panic message. Otherwise fall into the next case.
|
|
|
|
if (BX_BIOS_THIS s.bios_message_i >= BX_BIOS_MESSAGE_SIZE)
|
|
|
|
BX_BIOS_THIS s.bios_message_i = BX_BIOS_MESSAGE_SIZE-1;
|
2002-04-02 01:53:23 +04:00
|
|
|
BX_BIOS_THIS s.bios_message[ BX_BIOS_THIS s.bios_message_i] = 0;
|
2004-09-05 21:57:22 +04:00
|
|
|
BX_BIOS_THIS s.bios_message_i = 0;
|
2002-04-02 01:53:23 +04:00
|
|
|
bioslog->panic("%s", BX_BIOS_THIS s.bios_message);
|
2004-09-05 21:57:22 +04:00
|
|
|
break;
|
2002-04-02 01:53:23 +04:00
|
|
|
}
|
|
|
|
case 0x0400:
|
2005-10-23 17:23:49 +04:00
|
|
|
if (value > 0) {
|
|
|
|
bioslog->panic("BIOS panic at rombios.c, line %d", value);
|
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
break;
|
|
|
|
|
2002-04-24 11:39:47 +04:00
|
|
|
// 0x0402 is used as the info port for the rombios
|
|
|
|
// 0x0403 is used as the debug port for the rombios
|
|
|
|
case 0x0402:
|
|
|
|
case 0x0403:
|
2002-04-02 01:53:23 +04:00
|
|
|
BX_BIOS_THIS s.bios_message[BX_BIOS_THIS s.bios_message_i] =
|
|
|
|
(Bit8u) value;
|
|
|
|
BX_BIOS_THIS s.bios_message_i ++;
|
2008-02-16 01:05:43 +03:00
|
|
|
if (BX_BIOS_THIS s.bios_message_i >= BX_BIOS_MESSAGE_SIZE) {
|
2002-04-02 01:53:23 +04:00
|
|
|
BX_BIOS_THIS s.bios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0;
|
|
|
|
BX_BIOS_THIS s.bios_message_i = 0;
|
2005-10-23 17:23:49 +04:00
|
|
|
if (address==0x403)
|
|
|
|
bioslog->ldebug("%s", BX_BIOS_THIS s.bios_message);
|
|
|
|
else
|
|
|
|
bioslog->info("%s", BX_BIOS_THIS s.bios_message);
|
2004-09-05 21:57:22 +04:00
|
|
|
} else if ((value & 0xff) == '\n') {
|
2002-04-02 01:53:23 +04:00
|
|
|
BX_BIOS_THIS s.bios_message[ BX_BIOS_THIS s.bios_message_i - 1 ] = 0;
|
|
|
|
BX_BIOS_THIS s.bios_message_i = 0;
|
2005-10-23 17:23:49 +04:00
|
|
|
if (BX_BIOS_THIS s.bios_panic_flag==1)
|
|
|
|
bioslog->panic("%s", BX_BIOS_THIS s.bios_message);
|
|
|
|
else if (address==0x403)
|
|
|
|
bioslog->ldebug("%s", BX_BIOS_THIS s.bios_message);
|
|
|
|
else
|
|
|
|
bioslog->info("%s", BX_BIOS_THIS s.bios_message);
|
2004-09-05 21:57:22 +04:00
|
|
|
BX_BIOS_THIS s.bios_panic_flag = 0;
|
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
// 0x501-0x502 are used as panic ports for the vgabios
|
|
|
|
case 0x0502:
|
2004-09-05 21:57:22 +04:00
|
|
|
if (value==0) {
|
|
|
|
BX_BIOS_THIS s.vgabios_panic_flag = 1;
|
|
|
|
break;
|
|
|
|
} else if (BX_BIOS_THIS s.vgabios_message_i > 0) {
|
|
|
|
// if there are bits of message in the buffer, print them as the
|
|
|
|
// panic message. Otherwise fall into the next case.
|
|
|
|
if (BX_BIOS_THIS s.vgabios_message_i >= BX_BIOS_MESSAGE_SIZE)
|
|
|
|
BX_BIOS_THIS s.vgabios_message_i = BX_BIOS_MESSAGE_SIZE-1;
|
2002-04-02 01:53:23 +04:00
|
|
|
BX_BIOS_THIS s.vgabios_message[ BX_BIOS_THIS s.vgabios_message_i] = 0;
|
2004-09-05 21:57:22 +04:00
|
|
|
BX_BIOS_THIS s.vgabios_message_i = 0;
|
2002-04-02 01:53:23 +04:00
|
|
|
vgabioslog->panic("%s", BX_BIOS_THIS s.vgabios_message);
|
2004-09-05 21:57:22 +04:00
|
|
|
break;
|
2002-04-02 01:53:23 +04:00
|
|
|
}
|
|
|
|
case 0x0501:
|
2005-10-23 17:23:49 +04:00
|
|
|
if (value > 0) {
|
|
|
|
vgabioslog->panic("VGABIOS panic at vgabios.c, line %d", value);
|
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
// 0x0500 is used as the message port for the vgabios
|
|
|
|
case 0x0500:
|
2002-04-24 11:39:47 +04:00
|
|
|
case 0x0503:
|
2002-04-02 01:53:23 +04:00
|
|
|
BX_BIOS_THIS s.vgabios_message[BX_BIOS_THIS s.vgabios_message_i] =
|
|
|
|
(Bit8u) value;
|
|
|
|
BX_BIOS_THIS s.vgabios_message_i ++;
|
2008-02-16 01:05:43 +03:00
|
|
|
if (BX_BIOS_THIS s.vgabios_message_i >= BX_BIOS_MESSAGE_SIZE) {
|
2002-04-02 01:53:23 +04:00
|
|
|
BX_BIOS_THIS s.vgabios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0;
|
|
|
|
BX_BIOS_THIS s.vgabios_message_i = 0;
|
2005-10-23 17:23:49 +04:00
|
|
|
if (address==0x503)
|
|
|
|
vgabioslog->ldebug("%s", BX_BIOS_THIS s.vgabios_message);
|
|
|
|
else
|
|
|
|
vgabioslog->info("%s", BX_BIOS_THIS s.vgabios_message);
|
2004-09-05 21:57:22 +04:00
|
|
|
} else if ((value & 0xff) == '\n') {
|
2002-04-02 01:53:23 +04:00
|
|
|
BX_BIOS_THIS s.vgabios_message[ BX_BIOS_THIS s.vgabios_message_i - 1 ] = 0;
|
|
|
|
BX_BIOS_THIS s.vgabios_message_i = 0;
|
2005-10-23 17:23:49 +04:00
|
|
|
if (BX_BIOS_THIS s.vgabios_panic_flag==1)
|
|
|
|
vgabioslog->panic("%s", BX_BIOS_THIS s.vgabios_message);
|
|
|
|
else if (address==0x503)
|
|
|
|
vgabioslog->ldebug("%s", BX_BIOS_THIS s.vgabios_message);
|
|
|
|
else
|
|
|
|
vgabioslog->info("%s", BX_BIOS_THIS s.vgabios_message);
|
2004-09-05 21:57:22 +04:00
|
|
|
BX_BIOS_THIS s.vgabios_panic_flag = 0;
|
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-09-05 21:57:22 +04:00
|
|
|
break;
|
2005-10-23 17:23:49 +04:00
|
|
|
}
|
2002-04-02 01:53:23 +04:00
|
|
|
}
|