Commit Graph

473 Commits

Author SHA1 Message Date
Volker Ruppert
171697da03 Fixed save/restore with debugger enabled. 2024-02-17 09:23:39 +01:00
Volker Ruppert
fc6703a2f7 VGA update timer using vertical frequency now supported by Voodoo devices.
TODO: update docs.
2024-01-11 17:48:11 +01:00
Volker Ruppert
cfa7276cb9 Added support for driving the VGA display update timer with VSYNC.
- Using the special value of 0 enables this feature. In that case the vertical
  frequency is used for the display updates. The update() method is called at
  the "vertical retrace end" time and sets the time of the display start. This
  value is used to set the vertical retrace indicator in VGA register 0x03da.
- This feature is not yet enabled if Voodoo support is present. The Voodoo device
  has it's own vertical timer and needs some more testing and possibly some changes.
2024-01-09 21:48:19 +01:00
Volker Ruppert
c13ef56378 Increase maximum VGA update frequency to 75 and default to 10.
Small cleanups in the VGA code.
2024-01-07 11:15:04 +01:00
Volker Ruppert
1699f30d64 Reduce default keyboard serial delay to 150 to avoid timeouts.
Some cleanups in the keyboard code.
2023-12-31 10:47:10 +01:00
Volker Ruppert
0d49d2a8df Added 'flash_data' parameter to the romimage option.
This parameter defines the file name for the flash BIOS config space loaded
startup if existing and saved on exit if modified. The Bochs BIOS doesn't
use this feature yet. Updated 'romimage' option documentation.
2023-12-09 17:52:33 +01:00
Volker Ruppert
20b61b31f2 Improved parsing bochsrc options passed on the command line (see issue #160).
If the last char of an argument is a colon, equal sign or comma and there is
at least one more argument, then concatenate these arguments to one and pass
it to parse_line_unformatted().
2023-12-08 14:17:40 +01:00
Volker Ruppert
54aeba83d3 Moved CMOS image runtime options setup to cmos.cc. 2023-12-05 18:16:24 +01:00
Volker Ruppert
7fcf4a419a Added support for saving CMOS image at runtime.
- Added CMOS image options to runtime menu (except RTC init).
- Fixed default size of Bochs CMOS RAM (s.max_reg).
- Fixed bochsrc parse to make 'rtc_init' parameter work.
- In textconfig now using SERIES_ASK for CMOS image options.
2023-12-04 20:39:24 +01:00
Volker Ruppert
7f420fc260 Added modeless message box in the restore code and some related fixes.
- Show message box while restoring hardware state.
- Set modeless message box handle to NULL after destroying it.
- Reset all config options to default before restoring config.
- Fixed CMOS RTC value after restore if in 12-hour-mode.
- Fixed possible segfault in the plugins code caused by Voodoo plugin in VGA mode
  (found at restore code testing).
2023-12-03 12:34:03 +01:00
Stanislav Shwartsman
ffc722f4e8
Porting #SF patch #565 Real Time Clock /CMOS fix (#4)
by Michele Giacomone

Detailed description:

  -Observed issues

   Due to some limitations only dates between 1980 and 2038 can be
   used in a reliable way.
   Also, bochs incorrectly assumes a linear correspondence between
   the data returned by the <time.h> functions localtime() and
   mktime(), and isn't setting the latter properly.
   Bochs keeps its internal time value dependent to these functions
   after setup, assuming that their internal settings won't change
   on the go - which is not the case.
   In my OS, and in my timezone, this leads to incorrect startup values
   for 5 months each year and unreliable values if the simulation is
   kept going for a long time. (a feedback between localtime() and
   mktime() is created which keeps shifting back the time)
   Also, the RTC simulation is not realistic since the clock fixes
   itself across DST changes, without updating any DST related flag,
   a behavior that no guest OS expects.

  -Proposed fix

   This is implemented in such way that no bochs' previous behavior
   is changed, a part from the broken ones, with legacy in mind
   == the user can keep using bochs exactly as before knowing nothing
      of this patch

   +Make the internal s.timeval variable a Bit64s, so it can fit all
    values that the cmos can correctly represent, reported below:
    MIN     setting  -62167219200 =>  0000/01/01 SAT  0:00:00
    MAX BCD setting  253402300799 =>  9999/12/31 FRI 23:59:59
    MAX BIN setting  745690751999 => 25599/12/31 FRI 23:59:59
    And then fix each reference to these so it can handle such values
    And make bochs correctly wrap around for under/overflows, so that
    only the most significant bits of the century are lost.

   +Do the same thing to the bochs time0 parameter, so all the above
    values can be chosen at startup (despite being now legal values,
    1 and 2 will still be treated as "local" and "utc"). Note that
    normally only BCD settings are valid since bochs' CMOS defaults
    to such operating mode - the only way to use the binary range
    is by loading a cmos memory map.

   +Make the internal s.timeval variable independent from external
    factors. This means providing a small set of time handling
    functions, contained in "iodev/utctime.h", which must work in
    any environment in which bochs compiles, accessing no external
    resource. This also means that after startup, s.timeval will only
    be changed internally, and no call to the OS time functions will
    be made.

   +Make the internal s.timeval variable timezone independent, to
    have a linear correlation between its values and valid CMOS
    settings. To make it easier, s.timeval is gonna be treated as
    if the current timezone was UTC: so,
     - if the user selects UTC as time0, s.timeval will become current
       time(NULL)
     - if the user selects localtime, s.timeval will be computed as
       the value which will display the same broken down time as
       localtime(&now)
     - if the user inputs a time formatted string the proper s.timeval
       to displayed will be easily calculated,
     - if the user inputs a starting time value, s.timeval will be
       computed as the value which will display the same broken down
       time as localtime(&user_input) to ensure the same operation as
       before.
    A "tz=utc" is displayed when bochs prints out the current time
    value, to warn users about the difference in meaning between the
    internally kept time value and the value they can set through
    the "time0=" parameter. This might be changed to communicate
    instead the time value they can input to get the same setting,
    but performing such calculation (except for the startup time)
    suffers from all the mktime()/localtime() problems listed above
    so I did not do it.
    The range of "time0" is automatically adjusted so all users in
    all time zones can set any legal value despite "time0=" having a
    local meaning.

  A thorough explanation of what I did and why can be found in the
  "iodev/utctime.h" library header.

---------

Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
Co-authored-by: Volker Ruppert <Volker.Ruppert@t-online.de>
2023-12-01 22:55:35 +01:00
Volker Ruppert
b319a6cb5d Some more memory leak fixes.
- delete SIM object
- delete i/o port to handler tables
- free plugin tables for enum parameters
2023-11-26 15:44:38 +01:00
Volker Ruppert
86e4675a1d Fixed some memory leaks in the paramtree code (discussion #144).
- root_param was never deleted
- modified set_format() and set_long_format() to get rid of strdup()
2023-11-25 13:28:51 +01:00
Benjamin David Lunt
01a262306f
Improved and enhanced the floppy emulation (#135)
This improves and enhances the floppy emulation.
This adds the ability to specify a controller type.
This adds all but one, known, controller command.
This fixes the format command. Issue #123 
This fixes the error with older Windows guests.
2023-11-21 09:35:07 +02:00
Volker Ruppert
aa8224b14e Added BX_PANIC in case no plugins are found to avoid segfault. 2023-11-12 00:09:42 +01:00
Shwartsman
30d285b80f use common method to parse and dump memory params in .bochsrc 2023-11-07 15:40:20 +02:00
Shwartsman
fb6dae6846 add block_size size param to saved .bochsrc 2023-10-31 15:36:46 +02:00
Benjamin David Lunt
5e87c5a8cf
add ehci and xchi parameters to suspend config (#111)
This changes the recent PR to use get_selected() instead of hard coding
the "uhci" and "ohci".
This also adds the xHCI options.
2023-10-23 17:01:45 +03:00
Stanislav Shwartsman
c48a50141b remove unused variable 2023-10-23 09:55:42 +03:00
Benjamin David Lunt
b7f2aee9fd
write companion to save file (#110)
This fix adds the `companion=uhci\ohci` parameter to the saved config
file on suspend.
2023-10-23 07:53:22 +03:00
Benjamin David Lunt
0d1d6c671a
Ehci companion (#104)
This PR adds the ability to choose which companion controller the EHCI
uses.
`#usb_ehci: enabled=1, companion=uhci`
`#usb_ehci: enabled=1, companion=ohci`

UHCI is enabled by default:
`#usb_ehci: enabled=1`

This breaks up `usb_ohci.cc/h` into `usb_ohci.cc/h` and `ohci_core.cc/h`
to be like the existing `usb_uhci.cc/h` and `uhci_core.cc/h`.
This adds the ability to define a Port Routing string in the
`HcspPortRoute` register, and is optional via the `EHCI_PORT_ROUTE`
define.

Currently `EHCI_N_CC` and `EHCI_N_PCC` must remain as currently set (3
and 2 respectively), however with a little more work, I think these can
be modified and have up to 7 companion controllers with more ports per
companion, as long as the combined total is <= 15 total ports.

Please verify the `Makefile.in` changes. I do not use GCC and can not
verify it is correct.
2023-10-20 21:00:59 +03:00
Stanislav Shwartsman
e0cc12471c
fixed issue #95 port_e9_hack (#101)
refactoring of port_e9_hack configuration options
do not allow port e9 access for all rings if port_e9_hack is not enabled

Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
2023-10-18 08:19:33 +03:00
Benjamin David Lunt
e7910a30a0
Xhci options (#92)
This adds a "hint" to the xHCI port configuration "option" entries,
hinting that the port number must or must not be super-speed.
2023-10-15 21:47:24 +03:00
Benjamin David Lunt
fae8e698c7
Usb common (#75)
This catches (possible) errors in the Bochrc file when declaring USB
port options.
The first catches when the user defines a port twice.  This will PANIC.
```
usb_ohci: port1=mouse, options1="speed:low, model:m228"
usb_ohci: port1=keyboard, options1="speed:low"
```
The second catches a possible error if the user copy/pastes a line and
forgets to update the options# part as in the example below.
```
usb_ohci: port1=tablet, options1="speed:low"
usb_ohci: port2=disk, options1="speed:full, path:hdd.img"
```
However, this will not PANIC since the following is completely legal:
```
usb_ohci: port2=disk
usb_ohci: options2="speed:full"
usb_ohci: options2="path:hdd.img"
```
This will simply display an error on the Bochs console window.
2023-09-09 07:46:43 +03:00
Dreg
86eff7597d
add iodebug support for all rings complement #64 (#66)
This PR is for "I/O Interface to Bochs Debugger" from ring3 (port range:
**0x8A00 - 0x8A01**)

PR #64 was for E9 HACK (port **0xE9**)

By enabling the iodebug's 'all_rings' option, you can utilize the port
I/O Interface to Bochs Debugger from ring3. This PR allows the code
running inside Bochs (ring3) to monitor memory ranges, trace individual
instructions, and observe register values during execution.


https://bochs.sourceforge.io/doc/docbook/development/debugger-advanced.html

IMO very useful for:

- user-mode sandbox (ex Cuckoo)
- malware analysis
- API/SYSCALL hook/monitor from ring3
- automation + instrumentation from user mode code
...

A complement for PR #64

**This PR is 100% backward compatibility**

![IODEBUG ALL
RINGS](https://github.com/bochs-emu/Bochs/assets/9882181/6308ad0f-c189-43f3-a92b-dccde3542ad6)

btw, @stlintel I'm not certain about:
- if misc is the ideal location for this.. should I create a new
iodebug-option for this?
- should I remove the #if in 'new bx_param_bool_c'?
- the new .bochsrc entry makes sense for you?
2023-08-27 18:34:01 +02:00
Dreg
da43cc4580
add port e9 hack support for all rings (#64)
By enabling the 'all_rings' option, you can utilize the port e9 hack
from ring3

IMO very useful for:
- user-mode sandbox (ex Cuckoo)
- malware analysis
- API/SYSCALL logger with a simple hook from ring3
- automation + instrumentation from user mode code
- ...

So yes, from this PR a user-mode-sandbox can display on the console of
the system running Bochs anything that is written to 0xE9 port


![porte9hackallrings](https://github.com/bochs-emu/Bochs/assets/9882181/ddbca3fa-729b-4a3e-95ad-078e44c7a17a)

**This PR is 100% backward compatibility**

btw, @stlintel I'm not certain if **bochs/config.cc** is the ideal
location to define **bool port_e9_hack_all_rings** (unmapped io/dev is
better?)
2023-08-26 18:37:55 +03:00
Dreg
244033e234
improvement of the magic breakpoints fix #55 (#58) 2023-08-20 18:21:16 +03:00
Vort
ace4a4dfa9 Use correct directory separator in Windows builds 2023-04-16 12:22:45 +03:00
Benjamin David Lunt
a0e4106f4a
Add over-current signaling
This adds over-current signaling to the USBs four host controllers.
To signal an OC, use the runtime configuration and set the checkbox (GUI) or text config's parameter to 1.
This pull request also adds USB documentation to user.dbk.
2023-03-22 16:12:08 -07:00
Benjamin David Lunt
8ef4dcc7d1
Allow a usb port number to be more than one digit 2023-03-12 16:36:22 -07:00
Benjamin David Lunt
86b50988be
USB emulation update
Added examples for new options.
xhci: model= option
usb disk: proto= option
2023-03-10 11:29:06 -07:00
Stanislav Shwartsman
1e4f1624c8 remove trailing whitespace from source files 2022-08-23 21:46:04 +03:00
Stanislav Shwartsman
e32d536abe
added ability to select memory block size configurable (#25)
very large memory configurations require large memory block (or very large amount of blocks)
2022-07-30 13:56:09 +03:00
Volker Ruppert
1408de3ad2 Fixed and improved PCI slot config error handling. 2021-10-14 17:59:08 +00:00
Volker Ruppert
e34d017f60 Some fixes for compiling for WIN64 with MSVC.
- Added check in config.h whether or not Bochs is configured and compiled for
  the same target platform (WIN32 / WIN64).
- Fixed some warnings that occur in the MSVC WIN64 case.
2021-07-12 19:05:25 +00:00
Volker Ruppert
7e75d3d66b Two fixes in the USB code.
- Fixed possible segfault in the EHCI code.
- Fixed and improved backward compatibility code for USB port options.
2021-06-30 15:50:49 +00:00
Volker Ruppert
d9dd62e42f Improved conversion of old-style USB device options to new format. 2021-06-24 19:45:20 +00:00
Volker Ruppert
4db9f76819 Added port 0xE9 hack switch to runtime options. 2021-05-11 14:42:31 +00:00
Volker Ruppert
adf209fe9e Fixed some issues reported by valgrind. 2021-04-18 17:20:41 +00:00
Volker Ruppert
8e8414aae4 Some cleanup in the plugins code and related documentation additions. 2021-04-01 19:36:59 +00:00
Volker Ruppert
249fcf9442 Set the device type correctly for all media types when parsing floppy options.
- Added helper function get_floppy_devtype_from_type().
- The floppy type option now accepts the value "none".
- Added parameter handler for "devtype" to handle the BX_FDD_NONE case.
- Cleaned up floppy options parser code.
2021-03-29 11:17:03 +00:00
Volker Ruppert
b1c36691de Partly fixed floppy issues caused by previous commit. If device type is set to
"none" the dependent parameters cannot be set. That's why the bochsrc parser
needs to set device type first.
- Set initial device type of first floppy to '3.5" 1.44M'.
- Detect device type along with image type if necessary.
- TODO: fixes for media types like "1_44" and some more cleanup.
2021-03-28 08:40:28 +00:00
Volker Ruppert
3fcc320897 Added new plugin type PLUGTYPE_CI for config interfaces. Updated related code
and documentation.
2021-03-27 17:23:31 +00:00
Volker Ruppert
0c2a9c69d6 Some config option changes.
- Moved serial and parallel config parameter list creation to the corresponding
  device code.
- Unregister serial and parallel bochsrc options in PLUGIN_FINI mode.
- Moved USB config and runtime parameter list creation to bx_init_usb_options().
- textconfig.cc: Small fixes in the optional plugin control.
2021-03-07 11:54:50 +00:00
Volker Ruppert
66d9fd53b5 Two more disabled options fixes in the config interfaces. 2021-03-05 21:25:13 +00:00
Volker Ruppert
e8709d58e4 Fixes in the config interfaces handling of disabled options.
- Don't show dialog or menu if selected list is NULL or empty.
- Don't create list for lowlevel sound options if disabled in config.h.
2021-03-05 16:52:26 +00:00
Volker Ruppert
a475fee44f Fixed compilation with networking and USB support disabled. 2021-03-03 17:47:15 +00:00
Volker Ruppert
2aadd3e470 Changed type of the PCI slot option to bx_param_enum_c and build choices list
from plugin devives with PLUGFLAG_PCI set.
2021-02-27 10:23:05 +00:00
Volker Ruppert
8aaf9d858e Changed type of vga and svga_cirrus plugins to PLUGTYPE_VGA. Modified vga
extension option init to make this work correctly. The choices "none" and "vbe"
load the vga plugin, "cirrus" loads svga_cirrus.
2021-02-23 08:12:24 +00:00
Volker Ruppert
7a479ff4c9 Upgraded MSVC workspace files for VS2019 and fixed some MSVC warnings. 2021-02-21 08:08:06 +00:00