~ [ 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 12081 2013-12-29 12:56:52Z vruppert $ 3 ///////////////////////////////////////////////////////////////////////// 4 // 5 // Copyright (C) 2002-2013 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 #define bioslog theBiosDevice 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 put("biosdev", "BIOS"); 65 66 vgabioslog = new logfunctions(); 67 vgabioslog->put("vgabios", "VBIOS"); 68 } 69 70 bx_biosdev_c::~bx_biosdev_c(void) 71 { 72 bioslog->ldebug("Exit"); 73 if (vgabioslog != NULL) { 74 delete vgabioslog; 75 vgabioslog = NULL; 76 } 77 } 78 79 void bx_biosdev_c::init(void) 80 { 81 DEV_register_iowrite_handler(this, write_handler, 0x0400, "Bios Panic Port 1", 3); 82 DEV_register_iowrite_handler(this, write_handler, 0x0401, "Bios Panic Port 2", 3); 83 DEV_register_iowrite_handler(this, write_handler, 0x0402, "Bios Info Port", 1); 84 DEV_register_iowrite_handler(this, write_handler, 0x0403, "Bios Debug Port", 1); 85 86 DEV_register_iowrite_handler(this, write_handler, 0x0500, "VGABios Info Port", 1); 87 DEV_register_iowrite_handler(this, write_handler, 0x0501, "VGABios Panic Port 1", 3); 88 DEV_register_iowrite_handler(this, write_handler, 0x0502, "VGABios Panic Port 2", 3); 89 DEV_register_iowrite_handler(this, write_handler, 0x0503, "VGABios Debug Port", 1); 90 } 91 92 // static IO port write callback handler 93 // redirects to non-static class handler to avoid virtual functions 94 95 void bx_biosdev_c::write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len) 96 { 97 #if !BX_USE_BIOS_SMF 98 bx_biosdev_c *class_ptr = (bx_biosdev_c *) this_ptr; 99 100 class_ptr->write(address, value, io_len); 101 } 102 103 void bx_biosdev_c::write(Bit32u address, Bit32u value, unsigned io_len) 104 { 105 #else 106 UNUSED(this_ptr); 107 #endif // !BX_USE_BIOS_SMF 108 UNUSED(io_len); 109 110 111 switch (address) { 112 // 0x400-0x401 are used as panic ports for the rombios 113 case 0x0401: 114 if (value==0) { 115 // The next message sent to the info port will cause a panic 116 BX_BIOS_THIS s.bios_panic_flag = 1; 117 break; 118 } else if (BX_BIOS_THIS s.bios_message_i > 0) { 119 // if there are bits of message in the buffer, print them as the 120 // panic message. Otherwise fall into the next case. 121 if (BX_BIOS_THIS s.bios_message_i >= BX_BIOS_MESSAGE_SIZE) 122 BX_BIOS_THIS s.bios_message_i = BX_BIOS_MESSAGE_SIZE-1; 123 BX_BIOS_THIS s.bios_message[ BX_BIOS_THIS s.bios_message_i] = 0; 124 BX_BIOS_THIS s.bios_message_i = 0; 125 bioslog->panic("%s", BX_BIOS_THIS s.bios_message); 126 break; 127 } 128 case 0x0400: 129 if (value > 0) { 130 bioslog->panic("BIOS panic at rombios.c, line %d", value); 131 } 132 break; 133 134 // 0x0402 is used as the info port for the rombios 135 // 0x0403 is used as the debug port for the rombios 136 case 0x0402: 137 case 0x0403: 138 BX_BIOS_THIS s.bios_message[BX_BIOS_THIS s.bios_message_i] = 139 (Bit8u) value; 140 BX_BIOS_THIS s.bios_message_i ++; 141 if (BX_BIOS_THIS s.bios_message_i >= BX_BIOS_MESSAGE_SIZE) { 142 BX_BIOS_THIS s.bios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0; 143 BX_BIOS_THIS s.bios_message_i = 0; 144 if (address==0x403) 145 bioslog->ldebug("%s", BX_BIOS_THIS s.bios_message); 146 else 147 bioslog->info("%s", BX_BIOS_THIS s.bios_message); 148 } else if ((value & 0xff) == '\n') { 149 BX_BIOS_THIS s.bios_message[ BX_BIOS_THIS s.bios_message_i - 1 ] = 0; 150 BX_BIOS_THIS s.bios_message_i = 0; 151 if (BX_BIOS_THIS s.bios_panic_flag==1) 152 bioslog->panic("%s", BX_BIOS_THIS s.bios_message); 153 else if (address==0x403) 154 bioslog->ldebug("%s", BX_BIOS_THIS s.bios_message); 155 else 156 bioslog->info("%s", BX_BIOS_THIS s.bios_message); 157 BX_BIOS_THIS s.bios_panic_flag = 0; 158 } 159 break; 160 161 // 0x501-0x502 are used as panic ports for the vgabios 162 case 0x0502: 163 if (value==0) { 164 BX_BIOS_THIS s.vgabios_panic_flag = 1; 165 break; 166 } else if (BX_BIOS_THIS s.vgabios_message_i > 0) { 167 // if there are bits of message in the buffer, print them as the 168 // panic message. Otherwise fall into the next case. 169 if (BX_BIOS_THIS s.vgabios_message_i >= BX_BIOS_MESSAGE_SIZE) 170 BX_BIOS_THIS s.vgabios_message_i = BX_BIOS_MESSAGE_SIZE-1; 171 BX_BIOS_THIS s.vgabios_message[ BX_BIOS_THIS s.vgabios_message_i] = 0; 172 BX_BIOS_THIS s.vgabios_message_i = 0; 173 vgabioslog->panic("%s", BX_BIOS_THIS s.vgabios_message); 174 break; 175 } 176 case 0x0501: 177 if (value > 0) { 178 vgabioslog->panic("VGABIOS panic at vgabios.c, line %d", value); 179 } 180 break; 181 182 // 0x0500 is used as the message port for the vgabios 183 case 0x0500: 184 case 0x0503: 185 BX_BIOS_THIS s.vgabios_message[BX_BIOS_THIS s.vgabios_message_i] = 186 (Bit8u) value; 187 BX_BIOS_THIS s.vgabios_message_i ++; 188 if (BX_BIOS_THIS s.vgabios_message_i >= BX_BIOS_MESSAGE_SIZE) { 189 BX_BIOS_THIS s.vgabios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0; 190 BX_BIOS_THIS s.vgabios_message_i = 0; 191 if (address==0x503) 192 vgabioslog->ldebug("%s", BX_BIOS_THIS s.vgabios_message); 193 else 194 vgabioslog->info("%s", BX_BIOS_THIS s.vgabios_message); 195 } else if ((value & 0xff) == '\n') { 196 BX_BIOS_THIS s.vgabios_message[ BX_BIOS_THIS s.vgabios_message_i - 1 ] = 0; 197 BX_BIOS_THIS s.vgabios_message_i = 0; 198 if (BX_BIOS_THIS s.vgabios_panic_flag==1) 199 vgabioslog->panic("%s", BX_BIOS_THIS s.vgabios_message); 200 else if (address==0x503) 201 vgabioslog->ldebug("%s", BX_BIOS_THIS s.vgabios_message); 202 else 203 vgabioslog->info("%s", BX_BIOS_THIS s.vgabios_message); 204 BX_BIOS_THIS s.vgabios_panic_flag = 0; 205 } 206 break; 207 208 default: 209 break; 210 } 211 } 212

~ [ 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.