Commit graph

51 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto 49b672d829 [NTVDM]: Implement BOP_DEBUGGER (see: "Undocumented DOS" by Schulman et al., page 267) which allows you to break into a debugger from a 16-bit app (Vampyre, it can be useful for you ;) ).
svn path=/branches/ntvdm/; revision=61282
2013-12-16 23:57:35 +00:00
Hermès Bélusca-Maïto de64fe5965 [NTVDM]
- Add/fix few comments;
- Don't forget to redisable access to AC registers after modifying them in int 10h. Usurp, please retest Rescue Rover 2 :)
- Make EmulatorGet/Set/ClearFlag internal functions only and use set/get<FLAG> instead.

svn path=/branches/ntvdm/; revision=61263
2013-12-12 20:09:24 +00:00
Hermès Bélusca-Maïto 4fb7f6e1d7 [NTVDM]
- Move some PS/2 initialization from bios.c to ps2.c
- NULLify interrupt entries which are in fact pointers to data tables.
- Add a framework for adding I/O port handlers.

svn path=/branches/ntvdm/; revision=61107
2013-11-26 20:20:51 +00:00
Hermès Bélusca-Maïto c519c1610e [NTVDM]
- Implement and export getEFLAGS and setEFLAGS.
- Do some code reorganization (move all registers-related functions into "registers.c").

svn path=/branches/ntvdm/; revision=61033
2013-11-18 00:45:00 +00:00
Aleksandar Andrejevic c3c7bb89c1 [FAST486]
Modularize linear memory access by adding two new functions:
Fast486ReadLinearMemory and Fast486WriteLinearMemory.
Implement Fast486GetPageTableEntry.


svn path=/branches/ntvdm/; revision=60923
2013-11-10 22:27:24 +00:00
Hermès Bélusca-Maïto bf2731fb9f [NTVDM]
- BIOS: Reorganize a bit the header, and close the input thread before closing the input handle (and not after).
- INT32: Fix a comment.
- CMOS: Put CMOS data into a structure called CMOS_MEMORY, introduce READ/WRITE_CMOS_DATA macros for simplifying code. Save CMOS memory into a file (à la Windows' NTVDM), which is loaded at startup.

svn path=/branches/ntvdm/; revision=60913
2013-11-10 13:12:02 +00:00
Hermès Bélusca-Maïto 6da6a5ce56 [NTVDM]
Start my work on modularizing registration of "32-bit" interrupts, i.e.
interrupts that are implemented in 32-bit mode, but are stubbed with 16-bit
code (so that 16-bit apps can call them).
The 16-bit stub code uses a BOP call to our Control BOP function (BOP 0xFF) which
can handle in theory many sub-functions (as the BOP 0x58 documented here: http://www.ragestorm.net/tutorial?id=27)
specified as an additional BYTE in the call:
0xC4 0xC4 bop_code <optional_bop_subfunction>
Here, for calling 32-bit interrupts we use our BOP 0xFF, subfunction 0xFF.
The final aim would be to generate the 16-bit stub code when one calls the RegisterInt32 helper function
(contrary to what's happening now, that is, the 16-bit stub code is generated for all of the interrupts
at BIOS initialization time, and we use it for BIOS and DOS interrupts).

svn path=/branches/ntvdm/; revision=60907
2013-11-09 22:15:40 +00:00
Aleksandar Andrejevic f4f6809d67 [NTVDM]
Make the emulator callbacks non-static.
In BiosPrintCallback, use EmulatorWriteMemory instead of VgaWriteMemory, because
VgaWriteMemory does not do any input validation.
Improve EmulatorWriteMemory input validation and bound checking.


svn path=/branches/ntvdm/; revision=60903
2013-11-09 17:16:04 +00:00
Hermès Bélusca-Maïto ecd0b33743 [FAST486][NTVDM]: Rename the last two IO functions parameters in the same way as some CSR functions (ElementCount == DataCount; ElementSize == DataSize).
svn path=/branches/ntvdm/; revision=60896
2013-11-09 15:00:19 +00:00
Aleksandar Andrejevic 43ee57f2f7 [FAST486][NTVDM]
The behavior of the I/O port bus depends on the data width. In the case
of 16-bit/32-bit access, two/four adjacent ports will be accessed.


svn path=/branches/ntvdm/; revision=60891
2013-11-09 03:30:27 +00:00
Aleksandar Andrejevic 36afa0ea12 [NTVDM]
Implement the CMOS and Real Time Clock (RTC).
Improve the performance of the PIT and RTC (correctly this time).


svn path=/branches/ntvdm/; revision=60854
2013-11-03 21:33:22 +00:00
Hermès Bélusca-Maïto e9f8b230a6 [NTVDM]
Start to implement a basic emulated PC speaker, using the Beep driver.

svn path=/branches/ntvdm/; revision=60853
2013-11-03 20:31:19 +00:00
Aleksandar Andrejevic a0587b741a [NTVDM]
Improve the I/O read/write callbacks to allow multiple reads or writes
at once.


svn path=/branches/ntvdm/; revision=60849
2013-11-03 14:37:30 +00:00
Hermès Bélusca-Maïto 5c220ef022 [FAST486]
Fix the type of a variable.

[NTVDM]
Introduce a BOP handler table for the 256 possible BOP functions and use it.

svn path=/branches/ntvdm/; revision=60818
2013-11-01 02:28:47 +00:00
Hermès Bélusca-Maïto 861776bd7e [FAST486][NTVDM]
- Introduce a Fast486Initialize which is used to set up the CPU callbacks (and use default ones if some of the given callbacks are NULL), and to reset it the first time. Now Fast486Reset is meant to be used for only resetting the CPU to a safe state.
- Hence we are now sure that State->WhateverCallback is never NULL (and is theoretically valid), so don't do NULL-checks when calling them, but call them directly. The default cases for those checks become the default calls for the default callbacks.
- Remove the now-unneeded EmulatorIdle function.

svn path=/branches/ntvdm/; revision=60814
2013-11-01 01:46:58 +00:00
Hermès Bélusca-Maïto 39a527a21e [FAST486][NTVDM]
BOP numbers are 1 byte and map to a function (over 255). But one can pass additional "parameters" to those functions by adding extra bytes, however such functions must advance "by hand" the instruction pointer.

[NTVDM]
- Take into account our previous remark for the BIOS interrupt stubs, and comment them.
- Rework EmulatorBiosOperation (move almost all of its existing code into subfunctions in bop.c) so that one can call many other BOP functions in the future (WIP). The BOP number (still called) EMULATOR_INT_BOP (of value 0xFF) is used for internal 16 --> 32 bit switching for our 32bit bios.
- It appears that the IoRead/WriteCallback and IdleCallback must not be NULL for using fast486. I'm committing a temporary fix that I will definitely fix in a subsequent commit.

svn path=/branches/ntvdm/; revision=60812
2013-11-01 00:01:07 +00:00
Hermès Bélusca-Maïto d35b972d75 [NTVDM]: Use SEG_OFF_TO_PTR ( $+ \epsilon * code _eorganization$ ).
svn path=/branches/ntvdm/; revision=60776
2013-10-27 22:13:18 +00:00
Hermès Bélusca-Maïto 4d28af9bb5 [NTVDM]: Fix the callback prototypes.
svn path=/branches/ntvdm/; revision=60769
2013-10-27 12:17:06 +00:00
Aleksandar Andrejevic f5d3c9254c [FAST486]
Separate external interrupts from interrupt signals (which are
interrupts whose number is not known until they can be serviced,
just like hardware interrupts on a real CPU).
[NTVDM]
Improve the PIC emulation code (IRQ priorities, etc...).
Instead of checking for interrupts in the main loop, move the
PS/2 input parsing to a different thread.
Improve BIOS keyboard IRQ handling.


svn path=/branches/ntvdm/; revision=60761
2013-10-27 00:37:01 +00:00
Aleksandar Andrejevic 0981b0859f [NTVDM]
Remove softx86 support, and use only fast486, since it is now
sufficiently functional.


svn path=/branches/ntvdm/; revision=60755
2013-10-26 20:48:31 +00:00
Aleksandar Andrejevic 01d5a36cf5 [NTVDM]
Remove the code that performs waiting in 32-bit mode since that blocks the emulator
and prevents interrupts from working.
Implement a 16-bit waiting system in the interrupt handlers.
Fix the PS/2 interrupt code.


svn path=/branches/ntvdm/; revision=60739
2013-10-24 01:01:49 +00:00
Hermès Bélusca-Maïto 51040fc61e Bye bye Soft386, welcome Fast486, courtesy Aleksandar Andrejevic.
[NTVDM]: Define by default NEW_EMULATOR, i.e. use Fast486 instead of softx86.

svn path=/branches/ntvdm/; revision=60703
2013-10-19 16:55:51 +00:00
Aleksandar Andrejevic 0e8be812b0 [SOFT386]
Implement the hardware interrupt system.
Modify Soft386Interrupt to assume hardware interrupts, because
software interrupts from outside the emulator may cause race conditions.


svn path=/branches/ntvdm/; revision=60696
2013-10-18 22:50:00 +00:00
Aleksandar Andrejevic c425bbc689 [SOFT386]
Implement Soft386Interrupt.
[NTVDM]
Implement EmulatorInterrupt and EmulatorExternalInterrupt for NEW_EMULATOR.


svn path=/branches/ntvdm/; revision=60628
2013-10-12 13:58:34 +00:00
Aleksandar Andrejevic aef0bf1635 [SOFT386]
Implement an API for external segment modification.
[NTVDM]
Implement EmulatorSetRegister for NEW_EMULATOR.


svn path=/branches/ntvdm/; revision=60591
2013-10-09 21:48:52 +00:00
Aleksandar Andrejevic 7e119cf40b [SOFT386]
Implement the LES and LDS instructions.
Add optional support for BOPs (NTVDM-specific).
Fix prefix handling in some functions.
[NTVDM]
Enable BOPs for Soft386 (when NEW_EMULATOR is defined).
Fix the calling convention issue (softx86 uses cdecl, soft386 uses stdcall).


svn path=/branches/ntvdm/; revision=60395
2013-09-28 00:29:16 +00:00
Aleksandar Andrejevic 7328873681 [SOFT386]
Implement external stack modification.
[NTVDM]
Implement EmulatorSetStack for NEW_EMULATOR.


svn path=/branches/ntvdm/; revision=60257
2013-09-21 00:41:41 +00:00
Aleksandar Andrejevic 758bdf41d9 [SOFT386]
Fix the "persistant prefix" bug.
Fix the conditional jump bug.
Implement Soft386ExecuteAt.
[NTVDM]
Add Soft386 support to ntvdm.


svn path=/branches/ntvdm/; revision=59929
2013-08-31 19:18:12 +00:00
Aleksandar Andrejevic 5ffc6554be [NTVDM]
Remove the "new emulator" started in emulator.c in favor of Soft386.


svn path=/branches/ntvdm/; revision=59753
2013-08-16 19:33:04 +00:00
Aleksandar Andrejevic 022895e518 [NTVDM]
Synchronize with trunk again to fix important bugs in the build system.
Implement register control functions which should be exported (Adapted from a patch by Hermes Belusca-Maito).
The actual export is temporarily disabled because a bug in the build system compiles ntvdm as a DLL instead of an EXE.


svn path=/branches/ntvdm/; revision=59684
2013-08-09 23:52:08 +00:00
Aleksandar Andrejevic b4ed87bb3a [NTVDM]
Fix coding style.
Fix initial cursor position bug.
Fix memory limit constant for VGA memory modes 0 and 1 (64 KB not 32 KB).


svn path=/branches/ntvdm/; revision=59669
2013-08-07 19:56:28 +00:00
Aleksandar Andrejevic 5e69cb4dcb [NTVDM]
Fix MSVC warnings.


svn path=/branches/ntvdm/; revision=59666
2013-08-07 15:01:38 +00:00
Hermès Bélusca-Maïto 5bc19fdbfb [NTVDM]
- Don't leak console input/output handles when opening them in BiosInitialize.
- Deinitialize the emulator in the reverse order it was initialized.
- Simplify VgaGetVideoBaseAddress and VgaGetVideoLimitAddress and use the former one in VgaTranslate[Read-Write]Address.
- Use only unicode Win32 APIs where it's needed.

svn path=/branches/ntvdm/; revision=59659
2013-08-06 20:01:05 +00:00
Aleksandar Andrejevic 455deb3bde [NTVDM]
Implement Video Graphics Array (VGA) support.
Replace the old BIOS video code with new code that uses the VGA.


svn path=/branches/ntvdm/; revision=59648
2013-08-05 23:20:25 +00:00
Aleksandar Andrejevic b49476f20c [NTVDM]
Modify the flags on the stack instead of the flags register directly.
The flags register is restored during IRET so changing it directly does nothing.


svn path=/branches/ntvdm/; revision=59566
2013-07-23 21:43:57 +00:00
Aleksandar Andrejevic 6be35ef0bb [NTVDM]
Remove the old "INT 0xFF" hack and instead use an invalid opcode sequence for emulator operations.
Fix the flags register update bug.


svn path=/branches/ntvdm/; revision=59565
2013-07-23 19:31:00 +00:00
Aleksandar Andrejevic c04b008f1f [NTVDM]
Add debug output.


svn path=/branches/ntvdm/; revision=59555
2013-07-22 13:51:26 +00:00
Aleksandar Andrejevic 59e28c4f15 [SOFTX86]
Fix jump conditions.
[NTVDM]
Implement BIOS teletype output command.
Start implementation of a new CPU emulator to replace softx86.


svn path=/branches/ntvdm/; revision=59450
2013-07-07 20:53:23 +00:00
Aleksandar Andrejevic 1f4d89e7d7 [NTVDM]
Improve vertical refresh performance.
Properly synchronize access to the framebuffer.


svn path=/branches/ntvdm/; revision=59425
2013-07-05 01:31:50 +00:00
Aleksandar Andrejevic 01fd2f9aa3 [NTVDM]
Implement BIOS video mode setting.
Fix bugs in video memory access emulation.


svn path=/branches/ntvdm/; revision=59424
2013-07-05 00:08:18 +00:00
Aleksandar Andrejevic 988c4490a8 [NTVDM]
Fix bugs in video memory access emulation.
Implement several missing INT 10h functions.
Resize the console screen buffer on startup.


svn path=/branches/ntvdm/; revision=59421
2013-07-03 23:38:51 +00:00
Aleksandar Andrejevic c4ef9b6f44 [NTVDM]
Add more debug output.
[SOFTX86]
Properly set the carry and overflow flags.


svn path=/branches/ntvdm/; revision=59410
2013-07-02 21:40:11 +00:00
Aleksandar Andrejevic 36f251eca0 [NTVDM]
Fix several bugs:
The file was not entirely read due to an integer overflow.
The second WORD of the Program Segment Prefix (PSP) is not the number of allocated
paragraphs, but the segment of the last paragraph.
Fix the order of registers (SI and DI were mixed up with SP and BP).
Implement interrupt 0x11.
Implement redirection for reading/writing characters.


svn path=/branches/ntvdm/; revision=59409
2013-07-02 02:08:30 +00:00
Aleksandar Andrejevic ed9f26ccca [NTVDM]
Fix several bugs.
Implement some interrupt 1Ah services in the BIOS.


svn path=/branches/ntvdm/; revision=59374
2013-06-29 21:37:44 +00:00
Aleksandar Andrejevic 944d6e8b5a [NTVDM]
Implement "Get DOS Version" API call.
Implement BIOS keyboard IRQ handler and some "INT 16h" functions.


svn path=/branches/ntvdm/; revision=59350
2013-06-28 20:52:40 +00:00
Aleksandar Andrejevic 4c4c69fc37 [NTVDM]
Clean up the code and properly separate different modules into different files.


svn path=/branches/ntvdm/; revision=59344
2013-06-26 22:58:41 +00:00
Aleksandar Andrejevic 44f2787b1f [NTVDM]
Use 286 mode in softx86.
Implement "Get / Set Disk Transfer Area".
Start implementation of PS/2 controller.
Improve hardware interrupts. Fix CLI / STI / HLT instruction support.


svn path=/branches/ntvdm/; revision=59343
2013-06-26 17:15:45 +00:00
Aleksandar Andrejevic ca06374c9f [NTOSKRNL]
Check for old-style MZ executable in PeFmtCreateSection.
[NTVDM]
Fix bugs.
Implement MZ executable loading.


svn path=/branches/ntvdm/; revision=59328
2013-06-24 01:59:09 +00:00
Aleksandar Andrejevic 030a935096 [NTVDM]
Remove whitespace from empty lines.


svn path=/branches/ntvdm/; revision=59296
2013-06-23 00:11:45 +00:00
Aleksandar Andrejevic da877e495e [NTVDM]
Implement Programmable Interval Timer (PIT) emulation. Fix bugs in interrupts and PIC emulation.


svn path=/branches/ntvdm/; revision=59271
2013-06-21 00:47:07 +00:00