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

Bochs x86 Emulator
bochs/iodev/iodev.h

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

** Warning: Cannot open xref database.

1 ///////////////////////////////////////////////////////////////////////// 2 // $Id: iodev.h 12087 2013-12-30 22:39:21Z vruppert $ 3 ///////////////////////////////////////////////////////////////////////// 4 // 5 // Copyright (C) 2002-2013 The Bochs Project 6 // 7 // I/O port handlers API Copyright (C) 2003 by Frank Cornelis 8 // 9 // This library is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU Lesser General Public 11 // License as published by the Free Software Foundation; either 12 // version 2 of the License, or (at your option) any later version. 13 // 14 // This library is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 // Lesser General Public License for more details. 18 // 19 // You should have received a copy of the GNU Lesser General Public 20 // License along with this library; if not, write to the Free Software 21 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 // 23 ///////////////////////////////////////////////////////////////////////// 24 25 #ifndef IODEV_H 26 #define IODEV_H 27 28 #include "bochs.h" 29 #include "plugin.h" 30 #include "param_names.h" 31 32 /* number of IRQ lines supported. In an ISA PC there are two 33 PIC chips cascaded together. each has 8 IRQ lines, so there 34 should be 16 IRQ's total */ 35 #define BX_MAX_IRQS 16 36 37 /* size of internal buffer for mouse devices */ 38 #define BX_MOUSE_BUFF_SIZE 48 39 40 /* maximum size of the ISA DMA buffer */ 41 #define BX_DMA_BUFFER_SIZE 512 42 43 #define BX_MAX_PCI_DEVICES 20 44 45 typedef Bit32u (*bx_read_handler_t)(void *, Bit32u, unsigned); 46 typedef void (*bx_write_handler_t)(void *, Bit32u, Bit32u, unsigned); 47 48 typedef bx_bool (*bx_keyb_enq_t)(void *, Bit8u *); 49 typedef void (*bx_mouse_enq_t)(void *, int, int, int, unsigned, bx_bool); 50 typedef void (*bx_mouse_enabled_changed_t)(void *, bx_bool); 51 52 #if BX_USE_DEV_SMF 53 # define BX_DEV_SMF static 54 # define BX_DEV_THIS bx_devices. 55 #else 56 # define BX_DEV_SMF 57 # define BX_DEV_THIS this-> 58 #endif 59 60 ////////////////////////////////////////////////////////////////////// 61 // bx_devmodel_c declaration 62 ////////////////////////////////////////////////////////////////////// 63 64 // This class defines virtual methods that are common to all devices. 65 // Child classes do not need to implement all of them, because in this 66 // definition they are defined as empty, as opposed to being pure 67 // virtual (= 0). 68 class BOCHSAPI bx_devmodel_c : public logfunctions { 69 public: 70 virtual ~bx_devmodel_c() {} 71 virtual void init(void) {} 72 virtual void reset(unsigned type) {} 73 virtual void register_state(void) {} 74 virtual void after_restore_state(void) {} 75 #if BX_DEBUGGER 76 virtual void debug_dump(int argc, char **argv) {} 77 #endif 78 }; 79 80 ////////////////////////////////////////////////////////////////////// 81 // declare stubs for PCI devices 82 ////////////////////////////////////////////////////////////////////// 83 84 class bx_list_c; 85 class device_image_t; 86 class cdrom_base_c; 87 88 // the best should be deriving of bx_pci_device_stub_c from bx_devmodel_c 89 // but it make serious problems for cirrus_svga device 90 class BOCHSAPI bx_pci_device_stub_c { 91 public: 92 bx_pci_device_stub_c(): pci_rom(NULL), pci_rom_size(0) {} 93 virtual ~bx_pci_device_stub_c() { 94 if (pci_rom != NULL) delete [] pci_rom; 95 } 96 97 virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len) { 98 return 0; 99 } 100 101 virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len) {} 102 103 void init_pci_conf(Bit16u vid, Bit16u did, Bit8u rev, Bit32u classc, Bit8u headt); 104 void register_pci_state(bx_list_c *list); 105 void load_pci_rom(const char *path); 106 107 protected: 108 Bit8u pci_conf[256]; 109 Bit32u pci_base_address[6]; 110 Bit8u *pci_rom; 111 Bit32u pci_rom_address; 112 Bit32u pci_rom_size; 113 }; 114 115 ////////////////////////////////////////////////////////////////////// 116 // declare stubs for devices 117 ////////////////////////////////////////////////////////////////////// 118 119 ////////////////////////////////////////////////////////////////////// 120 #define STUBFUNC(dev,method) \ 121 pluginlog->panic("%s called in %s stub. you must not have loaded the %s plugin", #dev, #method, #dev) 122 ////////////////////////////////////////////////////////////////////// 123 124 class BOCHSAPI bx_keyb_stub_c : public bx_devmodel_c { 125 public: 126 virtual ~bx_keyb_stub_c() {} 127 // stubs for bx_keyb_c methods 128 virtual void gen_scancode(Bit32u key) { 129 STUBFUNC(keyboard, gen_scancode); 130 } 131 virtual void paste_bytes(Bit8u *data, Bit32s length) { 132 STUBFUNC(keyboard, paste_bytes); 133 } 134 }; 135 136 class BOCHSAPI bx_hard_drive_stub_c : public bx_devmodel_c { 137 public: 138 virtual void init() { 139 STUBFUNC(HD, init); 140 } 141 virtual void reset(unsigned type) { 142 STUBFUNC(HD, reset); 143 } 144 virtual Bit32u get_first_cd_handle(void) { 145 STUBFUNC(HD, get_first_cd_handle); return 0; 146 } 147 virtual unsigned get_cd_media_status(Bit32u handle) { 148 STUBFUNC(HD, get_cd_media_status); return 0; 149 } 150 virtual unsigned set_cd_media_status(Bit32u handle, unsigned status) { 151 STUBFUNC(HD, set_cd_media_status); return 0; 152 } 153 virtual Bit32u virt_read_handler(Bit32u address, unsigned io_len) 154 { 155 STUBFUNC(HD, virt_read_handler); return 0; 156 } 157 virtual void virt_write_handler(Bit32u address, 158 Bit32u value, unsigned io_len) 159 { 160 STUBFUNC(HD, virt_write_handler); 161 } 162 virtual bx_bool bmdma_read_sector(Bit8u channel, Bit8u *buffer, Bit32u *sector_size) { 163 STUBFUNC(HD, bmdma_read_sector); return 0; 164 } 165 virtual bx_bool bmdma_write_sector(Bit8u channel, Bit8u *buffer) { 166 STUBFUNC(HD, bmdma_write_sector); return 0; 167 } 168 virtual void bmdma_complete(Bit8u channel) { 169 STUBFUNC(HD, bmdma_complete); 170 } 171 }; 172 173 class BOCHSAPI bx_floppy_stub_c : public bx_devmodel_c { 174 public: 175 virtual unsigned set_media_status(unsigned drive, unsigned status) { 176 STUBFUNC(floppy, set_media_status); return 0; 177 } 178 }; 179 180 class BOCHSAPI bx_cmos_stub_c : public bx_devmodel_c { 181 public: 182 virtual Bit32u get_reg(unsigned reg) { 183 STUBFUNC(cmos, get_reg); return 0; 184 } 185 virtual void set_reg(unsigned reg, Bit32u val) { 186 STUBFUNC(cmos, set_reg); 187 } 188 virtual time_t get_timeval() { 189 return 0; 190 } 191 virtual void checksum_cmos(void) { 192 STUBFUNC(cmos, checksum); 193 } 194 }; 195 196 class BOCHSAPI bx_dma_stub_c : public bx_devmodel_c { 197 public: 198 virtual unsigned registerDMA8Channel( 199 unsigned channel, 200 Bit16u (* dmaRead)(Bit8u *data_byte, Bit16u maxlen), 201 Bit16u (* dmaWrite)(Bit8u *data_byte, Bit16u maxlen), 202 const char *name) 203 { 204 STUBFUNC(dma, registerDMA8Channel); return 0; 205 } 206 virtual unsigned registerDMA16Channel( 207 unsigned channel, 208 Bit16u (* dmaRead)(Bit16u *data_word, Bit16u maxlen), 209 Bit16u (* dmaWrite)(Bit16u *data_word, Bit16u maxlen), 210 const char *name) 211 { 212 STUBFUNC(dma, registerDMA16Channel); return 0; 213 } 214 virtual unsigned unregisterDMAChannel(unsigned channel) { 215 STUBFUNC(dma, unregisterDMAChannel); return 0; 216 } 217 virtual unsigned get_TC(void) { 218 STUBFUNC(dma, get_TC); return 0; 219 } 220 virtual void set_DRQ(unsigned channel, bx_bool val) { 221 STUBFUNC(dma, set_DRQ); 222 } 223 virtual void raise_HLDA(void) { 224 STUBFUNC(dma, raise_HLDA); 225 } 226 }; 227 228 class BOCHSAPI bx_pic_stub_c : public bx_devmodel_c { 229 public: 230 virtual void raise_irq(unsigned irq_no) { 231 STUBFUNC(pic, raise_irq); 232 } 233 virtual void lower_irq(unsigned irq_no) { 234 STUBFUNC(pic, lower_irq); 235 } 236 virtual void set_mode(bx_bool ma_sl, Bit8u mode) { 237 STUBFUNC(pic, set_mode); 238 } 239 virtual Bit8u IAC(void) { 240 STUBFUNC(pic, IAC); return 0; 241 } 242 }; 243 244 class BOCHSAPI bx_vga_stub_c : public bx_devmodel_c { 245 public: 246 virtual void redraw_area(unsigned x0, unsigned y0, 247 unsigned width, unsigned height) { 248 STUBFUNC(vga, redraw_area); 249 } 250 virtual Bit8u mem_read(bx_phy_address addr) { 251 STUBFUNC(vga, mem_read); return 0; 252 } 253 virtual void mem_write(bx_phy_address addr, Bit8u value) { 254 STUBFUNC(vga, mem_write); 255 } 256 virtual void get_text_snapshot(Bit8u **text_snapshot, 257 unsigned *txHeight, unsigned *txWidth) { 258 STUBFUNC(vga, get_text_snapshot); 259 } 260 virtual void set_override(bx_bool enabled, void *dev) { 261 STUBFUNC(vga, set_override); 262 } 263 virtual void refresh_display(void *this_ptr, bx_bool redraw) { 264 STUBFUNC(vga, refresh_display); 265 } 266 }; 267 268 class BOCHSAPI bx_pci2isa_stub_c : public bx_devmodel_c, public bx_pci_device_stub_c { 269 public: 270 virtual void pci_set_irq (Bit8u devfunc, unsigned line, bx_bool level) { 271 STUBFUNC(pci2isa, pci_set_irq); 272 } 273 }; 274 275 class BOCHSAPI bx_pci_ide_stub_c : public bx_devmodel_c, public bx_pci_device_stub_c { 276 public: 277 virtual bx_bool bmdma_present(void) { 278 return 0; 279 } 280 virtual void bmdma_set_irq(Bit8u channel) {} 281 }; 282 283 class BOCHSAPI bx_speaker_stub_c : public bx_devmodel_c { 284 public: 285 virtual void beep_on(float frequency) { 286 bx_gui->beep_on(frequency); 287 } 288 virtual void beep_off() { 289 bx_gui->beep_off(); 290 } 291 }; 292 293 #if BX_SUPPORT_PCI 294 class BOCHSAPI bx_acpi_ctrl_stub_c : public bx_devmodel_c, public bx_pci_device_stub_c { 295 public: 296 virtual void generate_smi(Bit8u value) {} 297 }; 298 #endif 299 300 #if BX_SUPPORT_IODEBUG 301 class BOCHSAPI bx_iodebug_stub_c : public bx_devmodel_c { 302 public: 303 virtual void mem_write(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data) {} 304 virtual void mem_read(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data) {} 305 }; 306 #endif 307 308 #if BX_SUPPORT_APIC 309 class BOCHSAPI bx_ioapic_stub_c : public bx_devmodel_c { 310 public: 311 virtual void set_enabled(bx_bool enabled, Bit16u base_offset) {} 312 virtual void receive_eoi(Bit8u vector) {} 313 virtual void set_irq_level(Bit8u int_in, bx_bool level) {} 314 }; 315 #endif 316 317 #if BX_SUPPORT_GAMEPORT 318 class BOCHSAPI bx_game_stub_c : public bx_devmodel_c { 319 public: 320 virtual void set_enabled(bx_bool val) { 321 STUBFUNC(gameport, set_enabled); 322 } 323 }; 324 #endif 325 326 #if BX_SUPPORT_PCIUSB 327 class BOCHSAPI bx_usb_devctl_stub_c : public bx_devmodel_c { 328 public: 329 virtual int init_device(bx_list_c *portconf, logfunctions *hub, void **dev, bx_list_c *sr_list) { 330 STUBFUNC(usb_devctl, init_device); return 0; 331 } 332 virtual void usb_send_msg(void *dev, int msg) {} 333 }; 334 #endif 335 336 class BOCHSAPI bx_hdimage_ctl_stub_c : public bx_devmodel_c { 337 public: 338 virtual device_image_t* init_image(Bit8u image_mode, Bit64u disk_size, const char *journal) { 339 STUBFUNC(hdimage_ctl, init_image); return NULL; 340 } 341 virtual cdrom_base_c* init_cdrom(const char *dev) { 342 STUBFUNC(hdimage_ctl, init_cdrom); return NULL; 343 } 344 }; 345 346 #if BX_SUPPORT_SOUNDLOW 347 class BOCHSAPI bx_soundmod_ctl_stub_c : public bx_devmodel_c { 348 public: 349 virtual void* get_module() { 350 STUBFUNC(soundmod_ctl, get_module); return NULL; 351 } 352 virtual bx_bool beep_on(float frequency) { 353 return 0; 354 } 355 virtual bx_bool beep_off() { 356 return 0; 357 } 358 virtual void VOC_init_file(FILE *stream) {} 359 virtual void VOC_write_block(FILE *stream, int block, Bit32u headerlen, 360 Bit8u header[], Bit32u datalen, Bit8u data[]) {} 361 virtual void pcm_apply_volume(Bit32u datalen, Bit8u data[], Bit16u volume, 362 Bit8u bits, bx_bool stereo, bx_bool issigned) {} 363 }; 364 #endif 365 366 #if BX_NETWORKING 367 class BOCHSAPI bx_netmod_ctl_stub_c : public bx_devmodel_c { 368 public: 369 virtual void* init_module(bx_list_c *base, void* rxh, void* rxstat, bx_devmodel_c *dev) { 370 STUBFUNC(netmod_ctl, init_module); return NULL; 371 } 372 }; 373 #endif 374 375 class BOCHSAPI bx_devices_c : public logfunctions { 376 public: 377 bx_devices_c(); 378 ~bx_devices_c(); 379 380 // Initialize the device stubs (in constructur and exit()) 381 void init_stubs(void); 382 // Register I/O addresses and IRQ lines. Initialize any internal 383 // structures. init() is called only once, even if the simulator 384 // reboots or is restarted. 385 void init(BX_MEM_C *); 386 // Enter reset state in response to a reset condition. 387 // The types of reset conditions are defined in bochs.h: 388 // power-on, hardware, or software. 389 void reset(unsigned type); 390 // Cleanup the devices when the simulation quits. 391 void exit(void); 392 void register_state(void); 393 void after_restore_state(void); 394 BX_MEM_C *mem; // address space associated with these devices 395 bx_bool register_io_read_handler(void *this_ptr, bx_read_handler_t f, 396 Bit32u addr, const char *name, Bit8u mask); 397 bx_bool unregister_io_read_handler(void *this_ptr, bx_read_handler_t f, 398 Bit32u addr, Bit8u mask); 399 bx_bool register_io_write_handler(void *this_ptr, bx_write_handler_t f, 400 Bit32u addr, const char *name, Bit8u mask); 401 bx_bool unregister_io_write_handler(void *this_ptr, bx_write_handler_t f, 402 Bit32u addr, Bit8u mask); 403 bx_bool register_io_read_handler_range(void *this_ptr, bx_read_handler_t f, 404 Bit32u begin_addr, Bit32u end_addr, 405 const char *name, Bit8u mask); 406 bx_bool register_io_write_handler_range(void *this_ptr, bx_write_handler_t f, 407 Bit32u begin_addr, Bit32u end_addr, 408 const char *name, Bit8u mask); 409 bx_bool unregister_io_read_handler_range(void *this_ptr, bx_read_handler_t f, 410 Bit32u begin, Bit32u end, Bit8u mask); 411 bx_bool unregister_io_write_handler_range(void *this_ptr, bx_write_handler_t f, 412 Bit32u begin, Bit32u end, Bit8u mask); 413 bx_bool register_default_io_read_handler(void *this_ptr, bx_read_handler_t f, const char *name, Bit8u mask); 414 bx_bool register_default_io_write_handler(void *this_ptr, bx_write_handler_t f, const char *name, Bit8u mask); 415 bx_bool register_irq(unsigned irq, const char *name); 416 bx_bool unregister_irq(unsigned irq, const char *name); 417 Bit32u inp(Bit16u addr, unsigned io_len) BX_CPP_AttrRegparmN(2); 418 void outp(Bit16u addr, Bit32u value, unsigned io_len) BX_CPP_AttrRegparmN(3); 419 420 void register_removable_keyboard(void *dev, bx_keyb_enq_t keyb_enq); 421 void unregister_removable_keyboard(void *dev); 422 void register_default_mouse(void *dev, bx_mouse_enq_t mouse_enq, bx_mouse_enabled_changed_t mouse_enabled_changed); 423 void register_removable_mouse(void *dev, bx_mouse_enq_t mouse_enq, bx_mouse_enabled_changed_t mouse_enabled_changed); 424 void unregister_removable_mouse(void *dev); 425 bx_bool optional_key_enq(Bit8u *scan_code); 426 void mouse_enabled_changed(bx_bool enabled); 427 void mouse_motion(int delta_x, int delta_y, int delta_z, unsigned button_state, bx_bool absxy); 428 429 #if BX_SUPPORT_PCI 430 Bit32u pci_get_confAddr(void) {return pci.confAddr;} 431 bx_bool register_pci_handlers(bx_pci_device_stub_c *device, Bit8u *devfunc, 432 const char *name, const char *descr); 433 bx_bool pci_set_base_mem(void *this_ptr, memory_handler_t f1, memory_handler_t f2, 434 Bit32u *addr, Bit8u *pci_conf, unsigned size); 435 bx_bool pci_set_base_io(void *this_ptr, bx_read_handler_t f1, bx_write_handler_t f2, 436 Bit32u *addr, Bit8u *pci_conf, unsigned size, 437 const Bit8u *iomask, const char *name); 438 #endif 439 440 static void timer_handler(void *); 441 void timer(void); 442 443 bx_pci2isa_stub_c *pluginPci2IsaBridge; 444 bx_pci_ide_stub_c *pluginPciIdeController; 445 #if BX_SUPPORT_PCI 446 bx_acpi_ctrl_stub_c *pluginACPIController; 447 #endif 448 bx_devmodel_c *pluginPitDevice; 449 bx_keyb_stub_c *pluginKeyboard; 450 bx_dma_stub_c *pluginDmaDevice; 451 bx_floppy_stub_c *pluginFloppyDevice; 452 bx_cmos_stub_c *pluginCmosDevice; 453 bx_vga_stub_c *pluginVgaDevice; 454 bx_pic_stub_c *pluginPicDevice; 455 bx_hard_drive_stub_c *pluginHardDrive; 456 bx_hdimage_ctl_stub_c *pluginHDImageCtl; 457 bx_speaker_stub_c *pluginSpeaker; 458 #if BX_SUPPORT_IODEBUG 459 bx_iodebug_stub_c *pluginIODebug; 460 #endif 461 #if BX_SUPPORT_APIC 462 bx_ioapic_stub_c *pluginIOAPIC; 463 #endif 464 #if BX_SUPPORT_GAMEPORT 465 bx_game_stub_c *pluginGameport; 466 #endif 467 #if BX_SUPPORT_PCIUSB 468 bx_usb_devctl_stub_c *pluginUsbDevCtl; 469 #endif 470 #if BX_SUPPORT_SOUNDLOW 471 bx_soundmod_ctl_stub_c *pluginSoundModCtl; 472 #endif 473 #if BX_NETWORKING 474 bx_netmod_ctl_stub_c *pluginNetModCtl; 475 #endif 476 477 // stub classes that the pointers (above) can point to until a plugin is 478 // loaded 479 bx_cmos_stub_c stubCmos; 480 bx_keyb_stub_c stubKeyboard; 481 bx_hard_drive_stub_c stubHardDrive; 482 bx_hdimage_ctl_stub_c stubHDImage; 483 bx_dma_stub_c stubDma; 484 bx_pic_stub_c stubPic; 485 bx_floppy_stub_c stubFloppy; 486 bx_vga_stub_c stubVga; 487 bx_pci2isa_stub_c stubPci2Isa; 488 bx_pci_ide_stub_c stubPciIde; 489 bx_speaker_stub_c stubSpeaker; 490 #if BX_SUPPORT_PCI 491 bx_acpi_ctrl_stub_c stubACPIController; 492 #endif 493 #if BX_SUPPORT_IODEBUG 494 bx_iodebug_stub_c stubIODebug; 495 #endif 496 #if BX_SUPPORT_APIC 497 bx_ioapic_stub_c stubIOAPIC; 498 #endif 499 #if BX_SUPPORT_GAMEPORT 500 bx_game_stub_c stubGameport; 501 #endif 502 #if BX_SUPPORT_PCIUSB 503 bx_usb_devctl_stub_c stubUsbDevCtl; 504 #endif 505 #if BX_SUPPORT_SOUNDLOW 506 bx_soundmod_ctl_stub_c stubSoundModCtl; 507 #endif 508 #if BX_NETWORKING 509 bx_netmod_ctl_stub_c stubNetModCtl; 510 #endif 511 512 // Some info to pass to devices which can handled bulk IO. This allows 513 // the interface to remain the same for IO devices which can't handle 514 // bulk IO. We should probably implement special INPBulk() and OUTBulk() 515 // functions which stick these values in the bx_devices_c class, and 516 // then call the normal functions rather than having gross globals 517 // variables. 518 Bit8u* bulkIOHostAddr; 519 unsigned bulkIOQuantumsRequested; 520 unsigned bulkIOQuantumsTransferred; 521 522 private: 523 524 struct io_handler_struct { 525 struct io_handler_struct *next; 526 struct io_handler_struct *prev; 527 void *funct; // C++ type checking is great, but annoying 528 void *this_ptr; 529 char *handler_name; // name of device 530 int usage_count; 531 Bit8u mask; // io_len mask 532 }; 533 struct io_handler_struct io_read_handlers; 534 struct io_handler_struct io_write_handlers; 535 #define PORTS 0x10000 536 struct io_handler_struct **read_port_to_handler; 537 struct io_handler_struct **write_port_to_handler; 538 539 // more for informative purposes, the names of the devices which 540 // are use each of the IRQ 0..15 lines are stored here 541 char *irq_handler_name[BX_MAX_IRQS]; 542 543 static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len); 544 static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len); 545 BX_DEV_SMF Bit32u read(Bit32u address, unsigned io_len); 546 BX_DEV_SMF void write(Bit32u address, Bit32u value, unsigned io_len); 547 548 static Bit32u default_read_handler(void *this_ptr, Bit32u address, unsigned io_len); 549 static void default_write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len); 550 551 bx_bool mouse_captured; // host mouse capture enabled 552 Bit8u mouse_type; 553 struct { 554 void *dev; 555 bx_mouse_enq_t enq_event; 556 bx_mouse_enabled_changed_t enabled_changed; 557 } bx_mouse[2]; 558 struct { 559 void *dev; 560 bx_keyb_enq_t enq_event; 561 } bx_keyboard; 562 563 struct { 564 bx_bool enabled; 565 #if BX_SUPPORT_PCI 566 Bit8u handler_id[0x100]; // 256 devices/functions 567 struct { 568 bx_pci_device_stub_c *handler; 569 } pci_handler[BX_MAX_PCI_DEVICES]; 570 unsigned num_pci_handlers; 571 572 bx_bool slot_used[BX_N_PCI_SLOTS]; 573 574 Bit32u confAddr; 575 #endif 576 } pci; 577 578 int timer_handle; 579 580 bx_bool network_enabled; 581 bx_bool sound_enabled; 582 bx_bool usb_enabled; 583 584 bx_bool is_harddrv_enabled(); 585 bx_bool is_network_enabled(); 586 bx_bool is_sound_enabled(); 587 bx_bool is_usb_enabled(); 588 }; 589 590 // memory stub has an assumption that there are no memory accesses splitting 4K page 591 BX_CPP_INLINE void DEV_MEM_READ_PHYSICAL(bx_phy_address phy_addr, unsigned len, Bit8u *ptr) 592 { 593 unsigned remainingInPage = 0x1000 - (phy_addr & 0xfff); 594 if (len <= remainingInPage) { 595 BX_MEM(0)->readPhysicalPage(NULL, phy_addr, len, ptr); 596 } 597 else { 598 BX_MEM(0)->readPhysicalPage(NULL, phy_addr, remainingInPage, ptr); 599 ptr += remainingInPage; 600 phy_addr += remainingInPage; 601 len -= remainingInPage; 602 BX_MEM(0)->readPhysicalPage(NULL, phy_addr, len, ptr); 603 } 604 } 605 606 BX_CPP_INLINE void DEV_MEM_READ_PHYSICAL_DMA(bx_phy_address phy_addr, unsigned len, Bit8u *ptr) 607 { 608 while(len > 0) { 609 unsigned remainingInPage = 0x1000 - (phy_addr & 0xfff); 610 if (len < remainingInPage) remainingInPage = len; 611 BX_MEM(0)->dmaReadPhysicalPage(phy_addr, remainingInPage, ptr); 612 ptr += remainingInPage; 613 phy_addr += remainingInPage; 614 len -= remainingInPage; 615 } 616 } 617 618 // memory stub has an assumption that there are no memory accesses splitting 4K page 619 BX_CPP_INLINE void DEV_MEM_WRITE_PHYSICAL(bx_phy_address phy_addr, unsigned len, Bit8u *ptr) 620 { 621 unsigned remainingInPage = 0x1000 - (phy_addr & 0xfff); 622 if (len <= remainingInPage) { 623 BX_MEM(0)->writePhysicalPage(NULL, phy_addr, len, ptr); 624 } 625 else { 626 BX_MEM(0)->writePhysicalPage(NULL, phy_addr, remainingInPage, ptr); 627 ptr += remainingInPage; 628 phy_addr += remainingInPage; 629 len -= remainingInPage; 630 BX_MEM(0)->writePhysicalPage(NULL, phy_addr, len, ptr); 631 } 632 } 633 634 BX_CPP_INLINE void DEV_MEM_WRITE_PHYSICAL_DMA(bx_phy_address phy_addr, unsigned len, Bit8u *ptr) 635 { 636 while(len > 0) { 637 unsigned remainingInPage = 0x1000 - (phy_addr & 0xfff); 638 if (len < remainingInPage) remainingInPage = len; 639 BX_MEM(0)->dmaWritePhysicalPage(phy_addr, remainingInPage, ptr); 640 ptr += remainingInPage; 641 phy_addr += remainingInPage; 642 len -= remainingInPage; 643 } 644 } 645 646 BOCHSAPI extern bx_devices_c bx_devices; 647 648 #endif /* IODEV_H */ 649

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