~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Bochs x86 Emulator
bochs/iodev/biosdev.cc

Version: ~ [ SVN-2014-01-05 ] ~ [ 2.6.2 ] ~

** Warning: Cannot open xref database.

1 ///////////////////////////////////////////////////////////////////////// 2 // $Id: biosdev.cc 11058 2012-02-23 17:16:35Z vruppert $ 3 ///////////////////////////////////////////////////////////////////////// 4 // 5 // Copyright (C) 2002-2009 The Bochs Project 6 // 7 // This library is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU Lesser General Public 9 // License as published by the Free Software Foundation; either 10 // version 2 of the License, or (at your option) any later version. 11 // 12 // This library is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 // Lesser General Public License for more details. 16 // 17 // You should have received a copy of the GNU Lesser General Public 18 // License along with this library; if not, write to the Free Software 19 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 21 22 // Here are the virtual ports use to display messages from the bioses : 23 // 24 // 0x0400 : rombios Panic port with line number 25 // 0x0401 : rombios Panic port with message, panic flag or line number 26 // 0x0402 : rombios Info port with message 27 // 0x0403 : rombios Debug port with message 28 // 29 // 0x0500 : vgabios Info port with message 30 // 0x0501 : vgabios Panic port with line number 31 // 0x0502 : vgabios Panic port with message, panic flag or line number 32 // 0x0503 : vgabios Debug port with message 33 34 35 // Define BX_PLUGGABLE in files that can be compiled into plugins. For 36 // platforms that require a special tag on exported symbols, BX_PLUGGABLE 37 // is used to know when we are exporting symbols and when we are importing. 38 #define BX_PLUGGABLE 39 40 #include "iodev.h" 41 #include "biosdev.h" 42 43 bx_biosdev_c *theBiosDevice = NULL; 44 45 logfunctions *bioslog; 46 logfunctions *vgabioslog; 47 48 int libbiosdev_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[]) 49 { 50 theBiosDevice = new bx_biosdev_c(); 51 BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theBiosDevice, BX_PLUGIN_BIOSDEV); 52 return(0); // Success 53 } 54 55 void libbiosdev_LTX_plugin_fini(void) 56 { 57 delete theBiosDevice; 58 } 59 60 bx_biosdev_c::bx_biosdev_c(void) 61 { 62 memset(&s, 0, sizeof(s)); 63 64 bioslog = new logfunctions(); 65 bioslog->put("BIOS"); 66 67 vgabioslog = new logfunctions(); 68 vgabioslog->put("vgabios", "VBIOS"); 69 } 70 71 bx_biosdev_c::~bx_biosdev_c(void) 72 { 73 bioslog->ldebug("Exit"); 74 if (bioslog != NULL) { 75 delete bioslog; 76 bioslog = NULL; 77 } 78 if (vgabioslog != NULL) { 79 delete vgabioslog; 80 vgabioslog = NULL; 81 } 82 } 83 84 void bx_biosdev_c::init(void) 85 { 86 DEV_register_iowrite_handler(this, write_handler, 0x0400, "Bios Panic Port 1", 3); 87 DEV_register_iowrite_handler(this, write_handler, 0x0401, "Bios Panic Port 2", 3); 88 DEV_register_iowrite_handler(this, write_handler, 0x0402, "Bios Info Port", 1); 89 DEV_register_iowrite_handler(this, write_handler, 0x0403, "Bios Debug Port", 1); 90 91 DEV_register_iowrite_handler(this, write_handler, 0x0500, "VGABios Info Port", 1); 92 DEV_register_iowrite_handler(this, write_handler, 0x0501, "VGABios Panic Port 1", 3); 93 DEV_register_iowrite_handler(this, write_handler, 0x0502, "VGABios Panic Port 2", 3); 94 DEV_register_iowrite_handler(this, write_handler, 0x0503, "VGABios Debug Port", 1); 95 } 96 97 // static IO port write callback handler 98 // redirects to non-static class handler to avoid virtual functions 99 100 void bx_biosdev_c::write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len) 101 { 102 #if !BX_USE_BIOS_SMF 103 bx_biosdev_c *class_ptr = (bx_biosdev_c *) this_ptr; 104 105 class_ptr->write(address, value, io_len); 106 } 107 108 void bx_biosdev_c::write(Bit32u address, Bit32u value, unsigned io_len) 109 { 110 #else 111 UNUSED(this_ptr); 112 #endif // !BX_USE_BIOS_SMF 113 UNUSED(io_len); 114 115 116 switch (address) { 117 // 0x400-0x401 are used as panic ports for the rombios 118 case 0x0401: 119 if (value==0) { 120 // The next message sent to the info port will cause a panic 121 BX_BIOS_THIS s.bios_panic_flag = 1; 122 break; 123 } else if (BX_BIOS_THIS s.bios_message_i > 0) { 124 // if there are bits of message in the buffer, print them as the 125 // panic message. Otherwise fall into the next case. 126 if (BX_BIOS_THIS s.bios_message_i >= BX_BIOS_MESSAGE_SIZE) 127 BX_BIOS_THIS s.bios_message_i = BX_BIOS_MESSAGE_SIZE-1; 128 BX_BIOS_THIS s.bios_message[ BX_BIOS_THIS s.bios_message_i] = 0; 129 BX_BIOS_THIS s.bios_message_i = 0; 130 bioslog->panic("%s", BX_BIOS_THIS s.bios_message); 131 break; 132 } 133 case 0x0400: 134 if (value > 0) { 135 bioslog->panic("BIOS panic at rombios.c, line %d", value); 136 } 137 break; 138 139 // 0x0402 is used as the info port for the rombios 140 // 0x0403 is used as the debug port for the rombios 141 case 0x0402: 142 case 0x0403: 143 BX_BIOS_THIS s.bios_message[BX_BIOS_THIS s.bios_message_i] = 144 (Bit8u) value; 145 BX_BIOS_THIS s.bios_message_i ++; 146 if (BX_BIOS_THIS s.bios_message_i >= BX_BIOS_MESSAGE_SIZE) { 147 BX_BIOS_THIS s.bios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0; 148 BX_BIOS_THIS s.bios_message_i = 0; 149 if (address==0x403) 150 bioslog->ldebug("%s", BX_BIOS_THIS s.bios_message); 151 else 152 bioslog->info("%s", BX_BIOS_THIS s.bios_message); 153 } else if ((value & 0xff) == '\n') { 154 BX_BIOS_THIS s.bios_message[ BX_BIOS_THIS s.bios_message_i - 1 ] = 0; 155 BX_BIOS_THIS s.bios_message_i = 0; 156 if (BX_BIOS_THIS s.bios_panic_flag==1) 157 bioslog->panic("%s", BX_BIOS_THIS s.bios_message); 158 else if (address==0x403) 159 bioslog->ldebug("%s", BX_BIOS_THIS s.bios_message); 160 else 161 bioslog->info("%s", BX_BIOS_THIS s.bios_message); 162 BX_BIOS_THIS s.bios_panic_flag = 0; 163 } 164 break; 165 166 // 0x501-0x502 are used as panic ports for the vgabios 167 case 0x0502: 168 if (value==0) { 169 BX_BIOS_THIS s.vgabios_panic_flag = 1; 170 break; 171 } else if (BX_BIOS_THIS s.vgabios_message_i > 0) { 172 // if there are bits of message in the buffer, print them as the 173 // panic message. Otherwise fall into the next case. 174 if (BX_BIOS_THIS s.vgabios_message_i >= BX_BIOS_MESSAGE_SIZE) 175 BX_BIOS_THIS s.vgabios_message_i = BX_BIOS_MESSAGE_SIZE-1; 176 BX_BIOS_THIS s.vgabios_message[ BX_BIOS_THIS s.vgabios_message_i] = 0; 177 BX_BIOS_THIS s.vgabios_message_i = 0; 178 vgabioslog->panic("%s", BX_BIOS_THIS s.vgabios_message); 179 break; 180 } 181 case 0x0501: 182 if (value > 0) { 183 vgabioslog->panic("VGABIOS panic at vgabios.c, line %d", value); 184 } 185 break; 186 187 // 0x0500 is used as the message port for the vgabios 188 case 0x0500: 189 case 0x0503: 190 BX_BIOS_THIS s.vgabios_message[BX_BIOS_THIS s.vgabios_message_i] = 191 (Bit8u) value; 192 BX_BIOS_THIS s.vgabios_message_i ++; 193 if (BX_BIOS_THIS s.vgabios_message_i >= BX_BIOS_MESSAGE_SIZE) { 194 BX_BIOS_THIS s.vgabios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0; 195 BX_BIOS_THIS s.vgabios_message_i = 0; 196 if (address==0x503) 197 vgabioslog->ldebug("%s", BX_BIOS_THIS s.vgabios_message); 198 else 199 vgabioslog->info("%s", BX_BIOS_THIS s.vgabios_message); 200 } else if ((value & 0xff) == '\n') { 201 BX_BIOS_THIS s.vgabios_message[ BX_BIOS_THIS s.vgabios_message_i - 1 ] = 0; 202 BX_BIOS_THIS s.vgabios_message_i = 0; 203 if (BX_BIOS_THIS s.vgabios_panic_flag==1) 204 vgabioslog->panic("%s", BX_BIOS_THIS s.vgabios_message); 205 else if (address==0x503) 206 vgabioslog->ldebug("%s", BX_BIOS_THIS s.vgabios_message); 207 else 208 vgabioslog->info("%s", BX_BIOS_THIS s.vgabios_message); 209 BX_BIOS_THIS s.vgabios_panic_flag = 0; 210 } 211 break; 212 213 default: 214 break; 215 } 216 } 217

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.