ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2013
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
16 participants
554 discussions
Start a n
N
ew thread
[hbelusca] 60196: [SOFT386] Use SOFT386_EXCEPTIONS instead of INT for the ExceptionCode parameter in Soft386ExceptionWithErrorCode and Soft386Exception.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Sep 17 23:17:50 2013 New Revision: 60196 URL:
http://svn.reactos.org/svn/reactos?rev=60196&view=rev
Log: [SOFT386] Use SOFT386_EXCEPTIONS instead of INT for the ExceptionCode parameter in Soft386ExceptionWithErrorCode and Soft386Exception. Modified: branches/ntvdm/lib/soft386/common.c branches/ntvdm/lib/soft386/common.h branches/ntvdm/lib/soft386/common.inl Modified: branches/ntvdm/lib/soft386/common.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.c?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.c [iso-8859-1] Tue Sep 17 23:17:50 2013 @@ -20,8 +20,7 @@ /* PRIVATE FUNCTIONS **********************************************************/ -static -inline +static inline ULONG Soft386GetPageTableEntry(PSOFT386_STATE State, ULONG VirtualAddress) @@ -434,7 +433,7 @@ VOID FASTCALL Soft386ExceptionWithErrorCode(PSOFT386_STATE State, - INT ExceptionCode, + SOFT386_EXCEPTIONS ExceptionCode, ULONG ErrorCode) { SOFT386_IDT_ENTRY IdtEntry; Modified: branches/ntvdm/lib/soft386/common.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.h?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.h [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.h [iso-8859-1] Tue Sep 17 23:17:50 2013 @@ -119,7 +119,7 @@ Soft386ExceptionWithErrorCode ( PSOFT386_STATE State, - INT ExceptionCode, + SOFT386_EXCEPTIONS ExceptionCode, ULONG ErrorCode ); Modified: branches/ntvdm/lib/soft386/common.inl URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.inl?re…
============================================================================== --- branches/ntvdm/lib/soft386/common.inl [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.inl [iso-8859-1] Tue Sep 17 23:17:50 2013 @@ -11,7 +11,7 @@ FORCEINLINE VOID Soft386Exception(PSOFT386_STATE State, - INT ExceptionCode) + SOFT386_EXCEPTIONS ExceptionCode) { /* Call the internal function */ Soft386ExceptionWithErrorCode(State, ExceptionCode, 0);
11 years, 3 months
1
0
0
0
[aandrejevic] 60195: [SOFT386] Fix the ARPL instruction. Use "inline" instead of FORCEINLINE for static functions.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Tue Sep 17 23:12:25 2013 New Revision: 60195 URL:
http://svn.reactos.org/svn/reactos?rev=60195&view=rev
Log: [SOFT386] Fix the ARPL instruction. Use "inline" instead of FORCEINLINE for static functions. Modified: branches/ntvdm/lib/soft386/common.c branches/ntvdm/lib/soft386/opcodes.c Modified: branches/ntvdm/lib/soft386/common.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.c?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.c [iso-8859-1] Tue Sep 17 23:12:25 2013 @@ -20,7 +20,8 @@ /* PRIVATE FUNCTIONS **********************************************************/ -static /* FORCEINLINE */ +static +inline ULONG Soft386GetPageTableEntry(PSOFT386_STATE State, ULONG VirtualAddress) Modified: branches/ntvdm/lib/soft386/opcodes.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opcodes.c?rev…
============================================================================== --- branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] Tue Sep 17 23:12:25 2013 @@ -3686,16 +3686,31 @@ { USHORT FirstValue, SecondValue; SOFT386_MOD_REG_RM ModRegRm; + BOOLEAN AddressSize = State->SegmentRegs[SOFT386_REG_CS].Size; if (!(State->ControlRegisters[SOFT386_REG_CR0] & SOFT386_CR0_PE) - || State->PrefixFlags) - { - /* No prefixes allowed, protected mode only */ - Soft386Exception(State, SOFT386_EXCEPTION_UD); - return FALSE; + || State->Flags.Vm + || (State->PrefixFlags & SOFT386_PREFIX_LOCK)) + { + /* Cannot be used in real mode or with a LOCK prefix */ + Soft386Exception(State, SOFT386_EXCEPTION_UD); + return FALSE; + } + + if (State->PrefixFlags & SOFT386_PREFIX_ADSIZE) + { + /* The ADSIZE prefix toggles the size */ + AddressSize = !AddressSize; } /* Get the operands */ + if (!Soft386ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + /* Read the operands */ if (!Soft386ReadModrmWordOperands(State, &ModRegRm, &FirstValue,
11 years, 3 months
1
0
0
0
[hbelusca] 60194: Fix a compilation error.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Sep 17 23:10:26 2013 New Revision: 60194 URL:
http://svn.reactos.org/svn/reactos?rev=60194&view=rev
Log: Fix a compilation error. Modified: branches/ntvdm/lib/soft386/common.c Modified: branches/ntvdm/lib/soft386/common.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.c?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.c [iso-8859-1] Tue Sep 17 23:10:26 2013 @@ -20,7 +20,7 @@ /* PRIVATE FUNCTIONS **********************************************************/ -static FORCEINLINE +static /* FORCEINLINE */ ULONG Soft386GetPageTableEntry(PSOFT386_STATE State, ULONG VirtualAddress)
11 years, 3 months
1
0
0
0
[hbelusca] 60193: [SOFT386] - Put inlined functions in a .inl file, which gets included by the corresponding header file (i.e. fix MSVC builds). - Use enums types instead of "only" INTs...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Sep 17 23:02:22 2013 New Revision: 60193 URL:
http://svn.reactos.org/svn/reactos?rev=60193&view=rev
Log: [SOFT386] - Put inlined functions in a .inl file, which gets included by the corresponding header file (i.e. fix MSVC builds). - Use enums types instead of "only" INTs... Added: branches/ntvdm/lib/soft386/common.inl (with props) Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h branches/ntvdm/lib/soft386/common.c branches/ntvdm/lib/soft386/common.h branches/ntvdm/lib/soft386/opcodes.c branches/ntvdm/lib/soft386/soft386.c Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/include/reactos/libs/soft…
============================================================================== --- branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] (original) +++ branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] Tue Sep 17 23:02:22 2013 @@ -44,7 +44,7 @@ struct _SOFT386_STATE; typedef struct _SOFT386_STATE SOFT386_STATE, *PSOFT386_STATE; -enum _SOFT386_GEN_REGS +typedef enum _SOFT386_GEN_REGS { SOFT386_REG_EAX, SOFT386_REG_ECX, @@ -54,9 +54,9 @@ SOFT386_REG_EBP, SOFT386_REG_ESI, SOFT386_REG_EDI -}; - -enum _SOFT386_SEG_REGS +} SOFT386_GEN_REGS, *PSOFT386_GEN_REGS; + +typedef enum _SOFT386_SEG_REGS { SOFT386_REG_ES, SOFT386_REG_CS, @@ -64,9 +64,9 @@ SOFT386_REG_DS, SOFT386_REG_FS, SOFT386_REG_GS -}; - -enum _SOFT386_CTRL_REGS +} SOFT386_SEG_REGS, *PSOFT386_SEG_REGS; + +typedef enum _SOFT386_CTRL_REGS { SOFT386_REG_CR0, SOFT386_REG_CR1, @@ -76,9 +76,9 @@ SOFT386_REG_CR5, SOFT386_REG_CR6, SOFT386_REG_CR7 -}; - -enum _SOFT386_DBG_REGS +} SOFT386_CTRL_REGS, *PSOFT386_CTRL_REGS; + +typedef enum _SOFT386_DBG_REGS { SOFT386_REG_DR0, SOFT386_REG_DR1, @@ -88,9 +88,9 @@ SOFT386_REG_DR5, SOFT386_REG_DR6, SOFT386_REG_DR7 -}; - -enum _SOFT386_EXCEPTIONS +} SOFT386_DBG_REGS, *PSOFT386_DBG_REGS; + +typedef enum _SOFT386_EXCEPTIONS { SOFT386_EXCEPTION_DE = 0x00, SOFT386_EXCEPTION_DB = 0x01, @@ -108,7 +108,7 @@ SOFT386_EXCEPTION_MF = 0x10, SOFT386_EXCEPTION_AC = 0x11, SOFT386_EXCEPTION_MC = 0x12 -}; +} SOFT386_EXCEPTIONS, *PSOFT386_EXCEPTIONS; typedef BOOLEAN @@ -303,7 +303,7 @@ ULONG DebugRegisters[SOFT386_NUM_DBG_REGS]; ULONG ExceptionCount; ULONG PrefixFlags; - INT SegmentOverride; + SOFT386_SEG_REGS SegmentOverride; BOOLEAN HardwareInt; }; Modified: branches/ntvdm/lib/soft386/common.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.c?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.c [iso-8859-1] Tue Sep 17 23:02:22 2013 @@ -12,24 +12,15 @@ // #define _INC_WINDOWS #include <windef.h> +// #define NDEBUG +#include <debug.h> + #include <soft386.h> #include "common.h" -// #define NDEBUG -#include <debug.h> - /* PRIVATE FUNCTIONS **********************************************************/ -static -inline -INT -Soft386GetCurrentPrivLevel(PSOFT386_STATE State) -{ - return GET_SEGMENT_RPL(State->SegmentRegs[SOFT386_REG_CS].Selector); -} - -static -inline +static FORCEINLINE ULONG Soft386GetPageTableEntry(PSOFT386_STATE State, ULONG VirtualAddress) @@ -42,10 +33,9 @@ /* PUBLIC FUNCTIONS ***********************************************************/ -inline BOOLEAN Soft386ReadMemory(PSOFT386_STATE State, - INT SegmentReg, + SOFT386_SEG_REGS SegmentReg, ULONG Offset, BOOLEAN InstFetch, PVOID Buffer, @@ -184,10 +174,9 @@ return TRUE; } -inline BOOLEAN Soft386WriteMemory(PSOFT386_STATE State, - INT SegmentReg, + SOFT386_SEG_REGS SegmentReg, ULONG Offset, PVOID Buffer, ULONG Size) @@ -321,334 +310,6 @@ return TRUE; } -inline -BOOLEAN -Soft386StackPush(PSOFT386_STATE State, ULONG Value) -{ - BOOLEAN Size = State->SegmentRegs[SOFT386_REG_SS].Size; - - /* The OPSIZE prefix toggles the size */ - if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) Size = !Size; - - if (Size) - { - /* 32-bit size */ - - /* Check if ESP is between 1 and 3 */ - if (State->GeneralRegs[SOFT386_REG_ESP].Long >= 1 - && State->GeneralRegs[SOFT386_REG_ESP].Long <= 3) - { - Soft386Exception(State, SOFT386_EXCEPTION_SS); - return FALSE; - } - - /* Subtract ESP by 4 */ - State->GeneralRegs[SOFT386_REG_ESP].Long -= 4; - - /* Store the value in SS:ESP */ - return Soft386WriteMemory(State, - SOFT386_REG_SS, - State->GeneralRegs[SOFT386_REG_ESP].Long, - &Value, - sizeof(ULONG)); - } - else - { - /* 16-bit size */ - USHORT ShortValue = LOWORD(Value); - - /* Check if SP is 1 */ - if (State->GeneralRegs[SOFT386_REG_ESP].Long == 1) - { - Soft386Exception(State, SOFT386_EXCEPTION_SS); - return FALSE; - } - - /* Subtract SP by 2 */ - State->GeneralRegs[SOFT386_REG_ESP].LowWord -= 2; - - /* Store the value in SS:SP */ - return Soft386WriteMemory(State, - SOFT386_REG_SS, - State->GeneralRegs[SOFT386_REG_ESP].LowWord, - &ShortValue, - sizeof(USHORT)); - } -} - -inline -BOOLEAN -Soft386StackPop(PSOFT386_STATE State, PULONG Value) -{ - ULONG LongValue; - USHORT ShortValue; - BOOLEAN Size = State->SegmentRegs[SOFT386_REG_SS].Size; - - /* The OPSIZE prefix toggles the size */ - if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) Size = !Size; - - if (Size) - { - /* 32-bit size */ - - /* Check if ESP is 0xFFFFFFFF */ - if (State->GeneralRegs[SOFT386_REG_ESP].Long == 0xFFFFFFFF) - { - Soft386Exception(State, SOFT386_EXCEPTION_SS); - return FALSE; - } - - /* Read the value from SS:ESP */ - if (!Soft386ReadMemory(State, - SOFT386_REG_SS, - State->GeneralRegs[SOFT386_REG_ESP].Long, - FALSE, - &LongValue, - sizeof(LongValue))) - { - /* An exception occurred */ - return FALSE; - } - - /* Increment ESP by 4 */ - State->GeneralRegs[SOFT386_REG_ESP].Long += 4; - - /* Store the value in the result */ - *Value = LongValue; - } - else - { - /* 16-bit size */ - - /* Check if SP is 0xFFFF */ - if (State->GeneralRegs[SOFT386_REG_ESP].LowWord == 0xFFFF) - { - Soft386Exception(State, SOFT386_EXCEPTION_SS); - return FALSE; - } - - /* Read the value from SS:SP */ - if (!Soft386ReadMemory(State, - SOFT386_REG_SS, - State->GeneralRegs[SOFT386_REG_ESP].LowWord, - FALSE, - &ShortValue, - sizeof(ShortValue))) - { - /* An exception occurred */ - return FALSE; - } - - /* Increment SP by 2 */ - State->GeneralRegs[SOFT386_REG_ESP].Long += 2; - - /* Store the value in the result */ - *Value = ShortValue; - } - - return TRUE; -} - -inline -BOOLEAN -Soft386LoadSegment(PSOFT386_STATE State, INT Segment, USHORT Selector) -{ - PSOFT386_SEG_REG CachedDescriptor; - SOFT386_GDT_ENTRY GdtEntry; - - ASSERT(Segment < SOFT386_NUM_SEG_REGS); - - /* Get the cached descriptor */ - CachedDescriptor = &State->SegmentRegs[Segment]; - - /* Check for protected mode */ - if (State->ControlRegisters[SOFT386_REG_CR0] & SOFT386_CR0_PE) - { - /* Make sure the GDT contains the entry */ - if (GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1)) - { - Soft386Exception(State, SOFT386_EXCEPTION_GP); - return FALSE; - } - - /* Read the GDT */ - // FIXME: This code is only correct when paging is disabled!!! - if (State->MemReadCallback) - { - State->MemReadCallback(State, - State->Gdtr.Address - + GET_SEGMENT_INDEX(Selector), - &GdtEntry, - sizeof(GdtEntry)); - } - else - { - RtlMoveMemory(&GdtEntry, - (PVOID)(State->Gdtr.Address - + GET_SEGMENT_INDEX(Selector)), - sizeof(GdtEntry)); - } - - /* Check if we are loading SS */ - if (Segment == SOFT386_REG_SS) - { - if (GET_SEGMENT_INDEX(Selector) == 0) - { - Soft386Exception(State, SOFT386_EXCEPTION_GP); - return FALSE; - } - - if (GdtEntry.Executable || !GdtEntry.ReadWrite) - { - Soft386Exception(State, SOFT386_EXCEPTION_GP); - return FALSE; - } - - if ((GET_SEGMENT_RPL(Selector) != Soft386GetCurrentPrivLevel(State)) - || (GET_SEGMENT_RPL(Selector) != GdtEntry.Dpl)) - { - Soft386Exception(State, SOFT386_EXCEPTION_GP); - return FALSE; - } - - if (!GdtEntry.Present) - { - Soft386Exception(State, SOFT386_EXCEPTION_SS); - return FALSE; - } - } - else - { - if ((GET_SEGMENT_RPL(Selector) > GdtEntry.Dpl) - && (Soft386GetCurrentPrivLevel(State) > GdtEntry.Dpl)) - { - Soft386Exception(State, SOFT386_EXCEPTION_GP); - return FALSE; - } - - if (!GdtEntry.Present) - { - Soft386Exception(State, SOFT386_EXCEPTION_NP); - return FALSE; - } - } - - /* Update the cache entry */ - CachedDescriptor->Selector = Selector; - CachedDescriptor->Base = GdtEntry.Base | (GdtEntry.BaseHigh << 24); - CachedDescriptor->Limit = GdtEntry.Limit | (GdtEntry.LimitHigh << 16); - CachedDescriptor->Accessed = GdtEntry.Accessed; - CachedDescriptor->ReadWrite = GdtEntry.ReadWrite; - CachedDescriptor->DirConf = GdtEntry.DirConf; - CachedDescriptor->Executable = GdtEntry.Executable; - CachedDescriptor->SystemType = GdtEntry.SystemType; - CachedDescriptor->Dpl = GdtEntry.Dpl; - CachedDescriptor->Present = GdtEntry.Present; - CachedDescriptor->Size = GdtEntry.Size; - - /* Check for page granularity */ - if (GdtEntry.Granularity) CachedDescriptor->Limit <<= 12; - } - else - { - /* Update the selector and base */ - CachedDescriptor->Selector = Selector; - CachedDescriptor->Base = Selector << 4; - } - - return TRUE; -} - -inline -BOOLEAN -Soft386FetchByte(PSOFT386_STATE State, PUCHAR Data) -{ - PSOFT386_SEG_REG CachedDescriptor; - - /* Get the cached descriptor of CS */ - CachedDescriptor = &State->SegmentRegs[SOFT386_REG_CS]; - - /* Read from memory */ - if (!Soft386ReadMemory(State, - SOFT386_REG_CS, - (CachedDescriptor->Size) ? State->InstPtr.Long - : State->InstPtr.LowWord, - TRUE, - Data, - sizeof(UCHAR))) - { - /* Exception occurred during instruction fetch */ - return FALSE; - } - - /* Advance the instruction pointer */ - if (CachedDescriptor->Size) State->InstPtr.Long++; - else State->InstPtr.LowWord++; - - return TRUE; -} - -inline -BOOLEAN -Soft386FetchWord(PSOFT386_STATE State, PUSHORT Data) -{ - PSOFT386_SEG_REG CachedDescriptor; - - /* Get the cached descriptor of CS */ - CachedDescriptor = &State->SegmentRegs[SOFT386_REG_CS]; - - /* Read from memory */ - // FIXME: Fix byte order on big-endian machines - if (!Soft386ReadMemory(State, - SOFT386_REG_CS, - (CachedDescriptor->Size) ? State->InstPtr.Long - : State->InstPtr.LowWord, - TRUE, - Data, - sizeof(USHORT))) - { - /* Exception occurred during instruction fetch */ - return FALSE; - } - - /* Advance the instruction pointer */ - if (CachedDescriptor->Size) State->InstPtr.Long += sizeof(USHORT); - else State->InstPtr.LowWord += sizeof(USHORT); - - return TRUE; -} - -inline -BOOLEAN -Soft386FetchDword(PSOFT386_STATE State, PULONG Data) -{ - PSOFT386_SEG_REG CachedDescriptor; - - /* Get the cached descriptor of CS */ - CachedDescriptor = &State->SegmentRegs[SOFT386_REG_CS]; - - /* Read from memory */ - // FIXME: Fix byte order on big-endian machines - if (!Soft386ReadMemory(State, - SOFT386_REG_CS, - (CachedDescriptor->Size) ? State->InstPtr.Long - : State->InstPtr.LowWord, - TRUE, - Data, - sizeof(ULONG))) - { - /* Exception occurred during instruction fetch */ - return FALSE; - } - - /* Advance the instruction pointer */ - if (CachedDescriptor->Size) State->InstPtr.Long += sizeof(ULONG); - else State->InstPtr.LowWord += sizeof(ULONG); - - return TRUE; -} - -inline BOOLEAN Soft386InterruptInternal(PSOFT386_STATE State, USHORT SegmentSelector, @@ -769,77 +430,11 @@ return TRUE; } -inline -BOOLEAN -Soft386GetIntVector(PSOFT386_STATE State, - UCHAR Number, - PSOFT386_IDT_ENTRY IdtEntry) -{ - ULONG FarPointer; - - /* Check for protected mode */ - if (State->ControlRegisters[SOFT386_REG_CR0] & SOFT386_CR0_PE) - { - /* Read from the IDT */ - // FIXME: This code is only correct when paging is disabled!!! - if (State->MemReadCallback) - { - State->MemReadCallback(State, - State->Idtr.Address - + Number * sizeof(*IdtEntry), - IdtEntry, - sizeof(*IdtEntry)); - } - else - { - RtlMoveMemory(IdtEntry, - (PVOID)(State->Idtr.Address - + Number * sizeof(*IdtEntry)), - sizeof(*IdtEntry)); - } - } - else - { - /* Read from the real-mode IVT */ - - /* Paging is always disabled in real mode */ - if (State->MemReadCallback) - { - State->MemReadCallback(State, - State->Idtr.Address - + Number * sizeof(FarPointer), - &FarPointer, - sizeof(FarPointer)); - } - else - { - RtlMoveMemory(IdtEntry, - (PVOID)(State->Idtr.Address - + Number * sizeof(FarPointer)), - sizeof(FarPointer)); - } - - /* Fill a fake IDT entry */ - IdtEntry->Offset = LOWORD(FarPointer); - IdtEntry->Selector = HIWORD(FarPointer); - IdtEntry->Zero = 0; - IdtEntry->Type = SOFT386_IDT_INT_GATE; - IdtEntry->Storage = FALSE; - IdtEntry->Dpl = 0; - IdtEntry->Present = TRUE; - IdtEntry->OffsetHigh = 0; - } - - /* - * Once paging support is implemented this function - * will not always return true - */ - return TRUE; -} - VOID FASTCALL -Soft386ExceptionWithErrorCode(PSOFT386_STATE State, INT ExceptionCode, ULONG ErrorCode) +Soft386ExceptionWithErrorCode(PSOFT386_STATE State, + INT ExceptionCode, + ULONG ErrorCode) { SOFT386_IDT_ENTRY IdtEntry; @@ -890,545 +485,4 @@ } } -inline -VOID -Soft386Exception(PSOFT386_STATE State, INT ExceptionCode) -{ - /* Call the internal function */ - Soft386ExceptionWithErrorCode(State, ExceptionCode, 0); -} - -inline -BOOLEAN -Soft386CalculateParity(UCHAR Number) -{ - Number ^= Number >> 1; - Number ^= Number >> 2; - Number ^= Number >> 4; - return !(Number & 1); -} - -inline -BOOLEAN -Soft386ParseModRegRm(PSOFT386_STATE State, - BOOLEAN AddressSize, - PSOFT386_MOD_REG_RM ModRegRm) -{ - UCHAR ModRmByte, Mode, RegMem; - - /* Fetch the MOD REG R/M byte */ - if (!Soft386FetchByte(State, &ModRmByte)) - { - /* Exception occurred */ - return FALSE; - } - - /* Unpack the mode and R/M */ - Mode = ModRmByte >> 6; - RegMem = ModRmByte & 0x07; - - /* Set the register operand */ - ModRegRm->Register = (ModRmByte >> 3) & 0x07; - - /* Check the mode */ - if ((ModRmByte >> 6) == 3) - { - /* The second operand is also a register */ - ModRegRm->Memory = FALSE; - ModRegRm->SecondRegister = RegMem; - - /* Done parsing */ - return TRUE; - } - - /* The second operand is memory */ - ModRegRm->Memory = TRUE; - - if (AddressSize) - { - if (RegMem == SOFT386_REG_ESP) - { - UCHAR SibByte; - ULONG Scale, Index, Base; - - /* Fetch the SIB byte */ - if (!Soft386FetchByte(State, &SibByte)) - { - /* Exception occurred */ - return FALSE; - } - - /* Unpack the scale, index and base */ - Scale = 1 << (SibByte >> 6); - Index = (SibByte >> 3) & 0x07; - if (Index != SOFT386_REG_ESP) Index = State->GeneralRegs[Index].Long; - else Index = 0; - Base = State->GeneralRegs[SibByte & 0x07].Long; - - /* Calculate the address */ - ModRegRm->MemoryAddress = Base + Index * Scale; - } - else if (RegMem == SOFT386_REG_EBP) - { - if (Mode) ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBP].Long; - else ModRegRm->MemoryAddress = 0; - } - else - { - /* Get the base from the register */ - ModRegRm->MemoryAddress = State->GeneralRegs[RegMem].Long; - } - - /* Check if there is no segment override */ - if (!(State->PrefixFlags & SOFT386_PREFIX_SEG)) - { - /* Check if the default segment should be SS */ - if ((RegMem == SOFT386_REG_EBP) && Mode) - { - /* Add a SS: prefix */ - State->PrefixFlags |= SOFT386_PREFIX_SEG; - State->SegmentOverride = SOFT386_REG_SS; - } - } - - if (Mode == 1) - { - CHAR Offset; - - /* Fetch the byte */ - if (!Soft386FetchByte(State, (PUCHAR)&Offset)) - { - /* Exception occurred */ - return FALSE; - } - - /* Add the signed offset to the address */ - ModRegRm->MemoryAddress += (LONG)Offset; - } - else if ((Mode == 2) || ((Mode == 0) && (RegMem == SOFT386_REG_EBP))) - { - LONG Offset; - - /* Fetch the dword */ - if (!Soft386FetchDword(State, (PULONG)&Offset)) - { - /* Exception occurred */ - return FALSE; - } - - /* Add the signed offset to the address */ - ModRegRm->MemoryAddress += Offset; - } - } - else - { - /* Check the operand */ - switch (RegMem) - { - case 0: - case 2: - { - /* (SS:)[BX + SI] */ - ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBX].LowWord - + State->GeneralRegs[SOFT386_REG_ESI].LowWord; - - break; - } - - case 1: - case 3: - { - /* (SS:)[BX + DI] */ - ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBX].LowWord - + State->GeneralRegs[SOFT386_REG_EDI].LowWord; - - break; - } - - case 4: - { - /* [SI] */ - ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_ESI].LowWord; - - break; - } - - case 5: - { - /* [DI] */ - ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EDI].LowWord; - - break; - } - - case 6: - { - if (Mode) - { - /* [BP] */ - ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBP].LowWord; - } - else - { - /* [constant] (added later) */ - ModRegRm->MemoryAddress = 0; - } - - break; - } - - case 7: - { - /* [BX] */ - ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBX].LowWord; - - break; - } - } - - /* Check if there is no segment override */ - if (!(State->PrefixFlags & SOFT386_PREFIX_SEG)) - { - /* Check if the default segment should be SS */ - if ((RegMem == 2) || (RegMem == 3) || ((RegMem == 6) && Mode)) - { - /* Add a SS: prefix */ - State->PrefixFlags |= SOFT386_PREFIX_SEG; - State->SegmentOverride = SOFT386_REG_SS; - } - } - - if (Mode == 1) - { - CHAR Offset; - - /* Fetch the byte */ - if (!Soft386FetchByte(State, (PUCHAR)&Offset)) - { - /* Exception occurred */ - return FALSE; - } - - /* Add the signed offset to the address */ - ModRegRm->MemoryAddress += (LONG)Offset; - } - else if ((Mode == 2) || ((Mode == 0) && (RegMem == 6))) - { - SHORT Offset; - - /* Fetch the word */ - if (!Soft386FetchWord(State, (PUSHORT)&Offset)) - { - /* Exception occurred */ - return FALSE; - } - - /* Add the signed offset to the address */ - ModRegRm->MemoryAddress += (LONG)Offset; - } - } - - return TRUE; -} - -inline -BOOLEAN -Soft386ReadModrmByteOperands(PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - PUCHAR RegValue, - PUCHAR RmValue) -{ - INT Segment = SOFT386_REG_DS; - - /* Get the register value */ - if (ModRegRm->Register & 0x04) - { - /* AH, CH, DH, BH */ - *RegValue = State->GeneralRegs[ModRegRm->Register & 0x03].HighByte; - } - else - { - /* AL, CL, DL, BL */ - *RegValue = State->GeneralRegs[ModRegRm->Register & 0x03].LowByte; - } - - if (!ModRegRm->Memory) - { - /* Get the second register value */ - if (ModRegRm->SecondRegister & 0x04) - { - /* AH, CH, DH, BH */ - *RmValue = State->GeneralRegs[ModRegRm->SecondRegister & 0x03].HighByte; - } - else - { - /* AL, CL, DL, BL */ - *RmValue = State->GeneralRegs[ModRegRm->SecondRegister & 0x03].LowByte; - } - } - else - { - /* Check for the segment override */ - if (State->PrefixFlags & SOFT386_PREFIX_SEG) - { - /* Use the override segment instead */ - Segment = State->SegmentOverride; - } - - /* Read memory */ - if (!Soft386ReadMemory(State, - Segment, - ModRegRm->MemoryAddress, - FALSE, - RmValue, - sizeof(UCHAR))) - { - /* Exception occurred */ - return FALSE; - } - } - - return TRUE; -} - -inline -BOOLEAN -Soft386ReadModrmWordOperands(PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - PUSHORT RegValue, - PUSHORT RmValue) -{ - INT Segment = SOFT386_REG_DS; - - /* Get the register value */ - *RegValue = State->GeneralRegs[ModRegRm->Register].LowWord; - - if (!ModRegRm->Memory) - { - /* Get the second register value */ - *RmValue = State->GeneralRegs[ModRegRm->SecondRegister].LowWord; - } - else - { - /* Check for the segment override */ - if (State->PrefixFlags & SOFT386_PREFIX_SEG) - { - /* Use the override segment instead */ - Segment = State->SegmentOverride; - } - - /* Read memory */ - if (!Soft386ReadMemory(State, - Segment, - ModRegRm->MemoryAddress, - FALSE, - RmValue, - sizeof(USHORT))) - { - /* Exception occurred */ - return FALSE; - } - } - - return TRUE; -} - -inline -BOOLEAN -Soft386ReadModrmDwordOperands(PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - PULONG RegValue, - PULONG RmValue) -{ - INT Segment = SOFT386_REG_DS; - - /* Get the register value */ - *RegValue = State->GeneralRegs[ModRegRm->Register].Long; - - if (!ModRegRm->Memory) - { - /* Get the second register value */ - *RmValue = State->GeneralRegs[ModRegRm->SecondRegister].Long; - } - else - { - /* Check for the segment override */ - if (State->PrefixFlags & SOFT386_PREFIX_SEG) - { - /* Use the override segment instead */ - Segment = State->SegmentOverride; - } - - /* Read memory */ - if (!Soft386ReadMemory(State, - Segment, - ModRegRm->MemoryAddress, - FALSE, - RmValue, - sizeof(ULONG))) - { - /* Exception occurred */ - return FALSE; - } - } - - return TRUE; -} - -inline -BOOLEAN -Soft386WriteModrmByteOperands(PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - BOOLEAN WriteRegister, - UCHAR Value) -{ - INT Segment = SOFT386_REG_DS; - - if (WriteRegister) - { - /* Store the value in the register */ - if (ModRegRm->Register & 0x04) - { - /* AH, CH, DH, BH */ - State->GeneralRegs[ModRegRm->Register & 0x03].HighByte = Value; - } - else - { - /* AL, CL, DL, BL */ - State->GeneralRegs[ModRegRm->Register & 0x03].LowByte = Value; - } - } - else - { - if (!ModRegRm->Memory) - { - /* Store the value in the second register */ - if (ModRegRm->SecondRegister & 0x04) - { - /* AH, CH, DH, BH */ - State->GeneralRegs[ModRegRm->SecondRegister & 0x03].HighByte = Value; - } - else - { - /* AL, CL, DL, BL */ - State->GeneralRegs[ModRegRm->SecondRegister & 0x03].LowByte = Value; - } - } - else - { - /* Check for the segment override */ - if (State->PrefixFlags & SOFT386_PREFIX_SEG) - { - /* Use the override segment instead */ - Segment = State->SegmentOverride; - } - - /* Write memory */ - if (!Soft386WriteMemory(State, - Segment, - ModRegRm->MemoryAddress, - &Value, - sizeof(UCHAR))) - { - /* Exception occurred */ - return FALSE; - } - } - } - - return TRUE; -} - -inline -BOOLEAN -Soft386WriteModrmWordOperands(PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - BOOLEAN WriteRegister, - USHORT Value) -{ - INT Segment = SOFT386_REG_DS; - - if (WriteRegister) - { - /* Store the value in the register */ - State->GeneralRegs[ModRegRm->Register].LowWord = Value; - } - else - { - if (!ModRegRm->Memory) - { - /* Store the value in the second register */ - State->GeneralRegs[ModRegRm->SecondRegister].LowWord = Value; - } - else - { - /* Check for the segment override */ - if (State->PrefixFlags & SOFT386_PREFIX_SEG) - { - /* Use the override segment instead */ - Segment = State->SegmentOverride; - } - - /* Write memory */ - if (!Soft386WriteMemory(State, - Segment, - ModRegRm->MemoryAddress, - &Value, - sizeof(USHORT))) - { - /* Exception occurred */ - return FALSE; - } - } - } - - return TRUE; -} - -inline -BOOLEAN -Soft386WriteModrmDwordOperands(PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - BOOLEAN WriteRegister, - ULONG Value) -{ - INT Segment = SOFT386_REG_DS; - - if (WriteRegister) - { - /* Store the value in the register */ - State->GeneralRegs[ModRegRm->Register].Long = Value; - } - else - { - if (!ModRegRm->Memory) - { - /* Store the value in the second register */ - State->GeneralRegs[ModRegRm->SecondRegister].Long = Value; - } - else - { - /* Check for the segment override */ - if (State->PrefixFlags & SOFT386_PREFIX_SEG) - { - /* Use the override segment instead */ - Segment = State->SegmentOverride; - } - - /* Write memory */ - if (!Soft386WriteMemory(State, - Segment, - ModRegRm->MemoryAddress, - &Value, - sizeof(ULONG))) - { - /* Exception occurred */ - return FALSE; - } - } - } - - return TRUE; -} - /* EOF */ Modified: branches/ntvdm/lib/soft386/common.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.h?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.h [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.h [iso-8859-1] Tue Sep 17 23:02:22 2013 @@ -32,11 +32,11 @@ typedef struct _SOFT386_MOD_REG_RM { - INT Register; + SOFT386_GEN_REGS Register; BOOLEAN Memory; union { - INT SecondRegister; + SOFT386_GEN_REGS SecondRegister; ULONG MemoryAddress; }; } SOFT386_MOD_REG_RM, *PSOFT386_MOD_REG_RM; @@ -84,79 +84,27 @@ /* FUNCTIONS ******************************************************************/ -inline BOOLEAN Soft386ReadMemory ( PSOFT386_STATE State, - INT SegmentReg, + SOFT386_SEG_REGS SegmentReg, ULONG Offset, BOOLEAN InstFetch, PVOID Buffer, ULONG Size ); -inline BOOLEAN Soft386WriteMemory ( PSOFT386_STATE State, - INT SegmentReg, + SOFT386_SEG_REGS SegmentReg, ULONG Offset, PVOID Buffer, ULONG Size ); -inline -BOOLEAN -Soft386StackPush -( - PSOFT386_STATE State, - ULONG Value -); - -inline -BOOLEAN -Soft386StackPop -( - PSOFT386_STATE State, - PULONG Value -); - -inline -BOOLEAN -Soft386LoadSegment -( - PSOFT386_STATE State, - INT Segment, - USHORT Selector -); - -inline -BOOLEAN -Soft386FetchByte -( - PSOFT386_STATE State, - PUCHAR Data -); - -inline -BOOLEAN -Soft386FetchWord -( - PSOFT386_STATE State, - PUSHORT Data -); - -inline -BOOLEAN -Soft386FetchDword -( - PSOFT386_STATE State, - PULONG Data -); - -inline BOOLEAN Soft386InterruptInternal ( @@ -164,15 +112,6 @@ USHORT SegmentSelector, ULONG Offset, BOOLEAN InterruptGate -); - -inline -BOOLEAN -Soft386GetIntVector -( - PSOFT386_STATE State, - UCHAR Number, - PSOFT386_IDT_ENTRY IdtEntry ); VOID @@ -184,89 +123,16 @@ ULONG ErrorCode ); -inline -VOID -Soft386Exception -( - PSOFT386_STATE State, - INT ExceptionCode -); +/* INLINED FUNCTIONS **********************************************************/ -inline -BOOLEAN -Soft386CalculateParity -( - UCHAR Number -); +/* static */ FORCEINLINE +INT +Soft386GetCurrentPrivLevel(PSOFT386_STATE State) +{ + return GET_SEGMENT_RPL(State->SegmentRegs[SOFT386_REG_CS].Selector); +} -inline -BOOLEAN -Soft386ParseModRegRm -( - PSOFT386_STATE State, - BOOLEAN AddressSize, - PSOFT386_MOD_REG_RM ModRegRm -); - -inline -BOOLEAN -Soft386ReadModrmByteOperands -( - PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - PUCHAR RegValue, - PUCHAR RmValue -); - -inline -BOOLEAN -Soft386ReadModrmWordOperands -( - PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - PUSHORT RegValue, - PUSHORT RmValue -); - -inline -BOOLEAN -Soft386ReadModrmDwordOperands -( - PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - PULONG RegValue, - PULONG RmValue -); - -inline -BOOLEAN -Soft386WriteModrmByteOperands -( - PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - BOOLEAN WriteRegister, - UCHAR Value -); - -inline -BOOLEAN -Soft386WriteModrmWordOperands -( - PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - BOOLEAN WriteRegister, - USHORT Value -); - -inline -BOOLEAN -Soft386WriteModrmDwordOperands -( - PSOFT386_STATE State, - PSOFT386_MOD_REG_RM ModRegRm, - BOOLEAN WriteRegister, - ULONG Value -); +#include "common.inl" #endif // _COMMON_H_ Added: branches/ntvdm/lib/soft386/common.inl URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.inl?re…
============================================================================== --- branches/ntvdm/lib/soft386/common.inl (added) +++ branches/ntvdm/lib/soft386/common.inl [iso-8859-1] Tue Sep 17 23:02:22 2013 @@ -0,0 +1,955 @@ +/* + * COPYRIGHT: GPL - See COPYING in the top level directory + * PROJECT: 386/486 CPU Emulation Library + * FILE: common.inl + * PURPOSE: Common functions used internally by Soft386 (inlined funtions). + * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org> + */ + +/* PUBLIC FUNCTIONS ***********************************************************/ + +FORCEINLINE +VOID +Soft386Exception(PSOFT386_STATE State, + INT ExceptionCode) +{ + /* Call the internal function */ + Soft386ExceptionWithErrorCode(State, ExceptionCode, 0); +} + +FORCEINLINE +BOOLEAN +Soft386StackPush(PSOFT386_STATE State, + ULONG Value) +{ + BOOLEAN Size = State->SegmentRegs[SOFT386_REG_SS].Size; + + /* The OPSIZE prefix toggles the size */ + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) Size = !Size; + + if (Size) + { + /* 32-bit size */ + + /* Check if ESP is between 1 and 3 */ + if (State->GeneralRegs[SOFT386_REG_ESP].Long >= 1 + && State->GeneralRegs[SOFT386_REG_ESP].Long <= 3) + { + Soft386Exception(State, SOFT386_EXCEPTION_SS); + return FALSE; + } + + /* Subtract ESP by 4 */ + State->GeneralRegs[SOFT386_REG_ESP].Long -= 4; + + /* Store the value in SS:ESP */ + return Soft386WriteMemory(State, + SOFT386_REG_SS, + State->GeneralRegs[SOFT386_REG_ESP].Long, + &Value, + sizeof(ULONG)); + } + else + { + /* 16-bit size */ + USHORT ShortValue = LOWORD(Value); + + /* Check if SP is 1 */ + if (State->GeneralRegs[SOFT386_REG_ESP].Long == 1) + { + Soft386Exception(State, SOFT386_EXCEPTION_SS); + return FALSE; + } + + /* Subtract SP by 2 */ + State->GeneralRegs[SOFT386_REG_ESP].LowWord -= 2; + + /* Store the value in SS:SP */ + return Soft386WriteMemory(State, + SOFT386_REG_SS, + State->GeneralRegs[SOFT386_REG_ESP].LowWord, + &ShortValue, + sizeof(USHORT)); + } +} + +FORCEINLINE +BOOLEAN +Soft386StackPop(PSOFT386_STATE State, + PULONG Value) +{ + ULONG LongValue; + USHORT ShortValue; + BOOLEAN Size = State->SegmentRegs[SOFT386_REG_SS].Size; + + /* The OPSIZE prefix toggles the size */ + if (State->PrefixFlags & SOFT386_PREFIX_OPSIZE) Size = !Size; + + if (Size) + { + /* 32-bit size */ + + /* Check if ESP is 0xFFFFFFFF */ + if (State->GeneralRegs[SOFT386_REG_ESP].Long == 0xFFFFFFFF) + { + Soft386Exception(State, SOFT386_EXCEPTION_SS); + return FALSE; + } + + /* Read the value from SS:ESP */ + if (!Soft386ReadMemory(State, + SOFT386_REG_SS, + State->GeneralRegs[SOFT386_REG_ESP].Long, + FALSE, + &LongValue, + sizeof(LongValue))) + { + /* An exception occurred */ + return FALSE; + } + + /* Increment ESP by 4 */ + State->GeneralRegs[SOFT386_REG_ESP].Long += 4; + + /* Store the value in the result */ + *Value = LongValue; + } + else + { + /* 16-bit size */ + + /* Check if SP is 0xFFFF */ + if (State->GeneralRegs[SOFT386_REG_ESP].LowWord == 0xFFFF) + { + Soft386Exception(State, SOFT386_EXCEPTION_SS); + return FALSE; + } + + /* Read the value from SS:SP */ + if (!Soft386ReadMemory(State, + SOFT386_REG_SS, + State->GeneralRegs[SOFT386_REG_ESP].LowWord, + FALSE, + &ShortValue, + sizeof(ShortValue))) + { + /* An exception occurred */ + return FALSE; + } + + /* Increment SP by 2 */ + State->GeneralRegs[SOFT386_REG_ESP].Long += 2; + + /* Store the value in the result */ + *Value = ShortValue; + } + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386LoadSegment(PSOFT386_STATE State, + INT Segment, + USHORT Selector) +{ + PSOFT386_SEG_REG CachedDescriptor; + SOFT386_GDT_ENTRY GdtEntry; + + ASSERT(Segment < SOFT386_NUM_SEG_REGS); + + /* Get the cached descriptor */ + CachedDescriptor = &State->SegmentRegs[Segment]; + + /* Check for protected mode */ + if (State->ControlRegisters[SOFT386_REG_CR0] & SOFT386_CR0_PE) + { + /* Make sure the GDT contains the entry */ + if (GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1)) + { + Soft386Exception(State, SOFT386_EXCEPTION_GP); + return FALSE; + } + + /* Read the GDT */ + // FIXME: This code is only correct when paging is disabled!!! + if (State->MemReadCallback) + { + State->MemReadCallback(State, + State->Gdtr.Address + + GET_SEGMENT_INDEX(Selector), + &GdtEntry, + sizeof(GdtEntry)); + } + else + { + RtlMoveMemory(&GdtEntry, + (PVOID)(State->Gdtr.Address + + GET_SEGMENT_INDEX(Selector)), + sizeof(GdtEntry)); + } + + /* Check if we are loading SS */ + if (Segment == SOFT386_REG_SS) + { + if (GET_SEGMENT_INDEX(Selector) == 0) + { + Soft386Exception(State, SOFT386_EXCEPTION_GP); + return FALSE; + } + + if (GdtEntry.Executable || !GdtEntry.ReadWrite) + { + Soft386Exception(State, SOFT386_EXCEPTION_GP); + return FALSE; + } + + if ((GET_SEGMENT_RPL(Selector) != Soft386GetCurrentPrivLevel(State)) + || (GET_SEGMENT_RPL(Selector) != GdtEntry.Dpl)) + { + Soft386Exception(State, SOFT386_EXCEPTION_GP); + return FALSE; + } + + if (!GdtEntry.Present) + { + Soft386Exception(State, SOFT386_EXCEPTION_SS); + return FALSE; + } + } + else + { + if ((GET_SEGMENT_RPL(Selector) > GdtEntry.Dpl) + && (Soft386GetCurrentPrivLevel(State) > GdtEntry.Dpl)) + { + Soft386Exception(State, SOFT386_EXCEPTION_GP); + return FALSE; + } + + if (!GdtEntry.Present) + { + Soft386Exception(State, SOFT386_EXCEPTION_NP); + return FALSE; + } + } + + /* Update the cache entry */ + CachedDescriptor->Selector = Selector; + CachedDescriptor->Base = GdtEntry.Base | (GdtEntry.BaseHigh << 24); + CachedDescriptor->Limit = GdtEntry.Limit | (GdtEntry.LimitHigh << 16); + CachedDescriptor->Accessed = GdtEntry.Accessed; + CachedDescriptor->ReadWrite = GdtEntry.ReadWrite; + CachedDescriptor->DirConf = GdtEntry.DirConf; + CachedDescriptor->Executable = GdtEntry.Executable; + CachedDescriptor->SystemType = GdtEntry.SystemType; + CachedDescriptor->Dpl = GdtEntry.Dpl; + CachedDescriptor->Present = GdtEntry.Present; + CachedDescriptor->Size = GdtEntry.Size; + + /* Check for page granularity */ + if (GdtEntry.Granularity) CachedDescriptor->Limit <<= 12; + } + else + { + /* Update the selector and base */ + CachedDescriptor->Selector = Selector; + CachedDescriptor->Base = Selector << 4; + } + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386FetchByte(PSOFT386_STATE State, + PUCHAR Data) +{ + PSOFT386_SEG_REG CachedDescriptor; + + /* Get the cached descriptor of CS */ + CachedDescriptor = &State->SegmentRegs[SOFT386_REG_CS]; + + /* Read from memory */ + if (!Soft386ReadMemory(State, + SOFT386_REG_CS, + (CachedDescriptor->Size) ? State->InstPtr.Long + : State->InstPtr.LowWord, + TRUE, + Data, + sizeof(UCHAR))) + { + /* Exception occurred during instruction fetch */ + return FALSE; + } + + /* Advance the instruction pointer */ + if (CachedDescriptor->Size) State->InstPtr.Long++; + else State->InstPtr.LowWord++; + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386FetchWord(PSOFT386_STATE State, + PUSHORT Data) +{ + PSOFT386_SEG_REG CachedDescriptor; + + /* Get the cached descriptor of CS */ + CachedDescriptor = &State->SegmentRegs[SOFT386_REG_CS]; + + /* Read from memory */ + // FIXME: Fix byte order on big-endian machines + if (!Soft386ReadMemory(State, + SOFT386_REG_CS, + (CachedDescriptor->Size) ? State->InstPtr.Long + : State->InstPtr.LowWord, + TRUE, + Data, + sizeof(USHORT))) + { + /* Exception occurred during instruction fetch */ + return FALSE; + } + + /* Advance the instruction pointer */ + if (CachedDescriptor->Size) State->InstPtr.Long += sizeof(USHORT); + else State->InstPtr.LowWord += sizeof(USHORT); + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386FetchDword(PSOFT386_STATE State, + PULONG Data) +{ + PSOFT386_SEG_REG CachedDescriptor; + + /* Get the cached descriptor of CS */ + CachedDescriptor = &State->SegmentRegs[SOFT386_REG_CS]; + + /* Read from memory */ + // FIXME: Fix byte order on big-endian machines + if (!Soft386ReadMemory(State, + SOFT386_REG_CS, + (CachedDescriptor->Size) ? State->InstPtr.Long + : State->InstPtr.LowWord, + TRUE, + Data, + sizeof(ULONG))) + { + /* Exception occurred during instruction fetch */ + return FALSE; + } + + /* Advance the instruction pointer */ + if (CachedDescriptor->Size) State->InstPtr.Long += sizeof(ULONG); + else State->InstPtr.LowWord += sizeof(ULONG); + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386GetIntVector(PSOFT386_STATE State, + UCHAR Number, + PSOFT386_IDT_ENTRY IdtEntry) +{ + ULONG FarPointer; + + /* Check for protected mode */ + if (State->ControlRegisters[SOFT386_REG_CR0] & SOFT386_CR0_PE) + { + /* Read from the IDT */ + // FIXME: This code is only correct when paging is disabled!!! + if (State->MemReadCallback) + { + State->MemReadCallback(State, + State->Idtr.Address + + Number * sizeof(*IdtEntry), + IdtEntry, + sizeof(*IdtEntry)); + } + else + { + RtlMoveMemory(IdtEntry, + (PVOID)(State->Idtr.Address + + Number * sizeof(*IdtEntry)), + sizeof(*IdtEntry)); + } + } + else + { + /* Read from the real-mode IVT */ + + /* Paging is always disabled in real mode */ + if (State->MemReadCallback) + { + State->MemReadCallback(State, + State->Idtr.Address + + Number * sizeof(FarPointer), + &FarPointer, + sizeof(FarPointer)); + } + else + { + RtlMoveMemory(IdtEntry, + (PVOID)(State->Idtr.Address + + Number * sizeof(FarPointer)), + sizeof(FarPointer)); + } + + /* Fill a fake IDT entry */ + IdtEntry->Offset = LOWORD(FarPointer); + IdtEntry->Selector = HIWORD(FarPointer); + IdtEntry->Zero = 0; + IdtEntry->Type = SOFT386_IDT_INT_GATE; + IdtEntry->Storage = FALSE; + IdtEntry->Dpl = 0; + IdtEntry->Present = TRUE; + IdtEntry->OffsetHigh = 0; + } + + /* + * Once paging support is implemented this function + * will not always return true + */ + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386CalculateParity(UCHAR Number) +{ + Number ^= Number >> 1; + Number ^= Number >> 2; + Number ^= Number >> 4; + return !(Number & 1); +} + +FORCEINLINE +BOOLEAN +Soft386ParseModRegRm(PSOFT386_STATE State, + BOOLEAN AddressSize, + PSOFT386_MOD_REG_RM ModRegRm) +{ + UCHAR ModRmByte, Mode, RegMem; + + /* Fetch the MOD REG R/M byte */ + if (!Soft386FetchByte(State, &ModRmByte)) + { + /* Exception occurred */ + return FALSE; + } + + /* Unpack the mode and R/M */ + Mode = ModRmByte >> 6; + RegMem = ModRmByte & 0x07; + + /* Set the register operand */ + ModRegRm->Register = (ModRmByte >> 3) & 0x07; + + /* Check the mode */ + if ((ModRmByte >> 6) == 3) + { + /* The second operand is also a register */ + ModRegRm->Memory = FALSE; + ModRegRm->SecondRegister = RegMem; + + /* Done parsing */ + return TRUE; + } + + /* The second operand is memory */ + ModRegRm->Memory = TRUE; + + if (AddressSize) + { + if (RegMem == SOFT386_REG_ESP) + { + UCHAR SibByte; + ULONG Scale, Index, Base; + + /* Fetch the SIB byte */ + if (!Soft386FetchByte(State, &SibByte)) + { + /* Exception occurred */ + return FALSE; + } + + /* Unpack the scale, index and base */ + Scale = 1 << (SibByte >> 6); + Index = (SibByte >> 3) & 0x07; + if (Index != SOFT386_REG_ESP) Index = State->GeneralRegs[Index].Long; + else Index = 0; + Base = State->GeneralRegs[SibByte & 0x07].Long; + + /* Calculate the address */ + ModRegRm->MemoryAddress = Base + Index * Scale; + } + else if (RegMem == SOFT386_REG_EBP) + { + if (Mode) ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBP].Long; + else ModRegRm->MemoryAddress = 0; + } + else + { + /* Get the base from the register */ + ModRegRm->MemoryAddress = State->GeneralRegs[RegMem].Long; + } + + /* Check if there is no segment override */ + if (!(State->PrefixFlags & SOFT386_PREFIX_SEG)) + { + /* Check if the default segment should be SS */ + if ((RegMem == SOFT386_REG_EBP) && Mode) + { + /* Add a SS: prefix */ + State->PrefixFlags |= SOFT386_PREFIX_SEG; + State->SegmentOverride = SOFT386_REG_SS; + } + } + + if (Mode == 1) + { + CHAR Offset; + + /* Fetch the byte */ + if (!Soft386FetchByte(State, (PUCHAR)&Offset)) + { + /* Exception occurred */ + return FALSE; + } + + /* Add the signed offset to the address */ + ModRegRm->MemoryAddress += (LONG)Offset; + } + else if ((Mode == 2) || ((Mode == 0) && (RegMem == SOFT386_REG_EBP))) + { + LONG Offset; + + /* Fetch the dword */ + if (!Soft386FetchDword(State, (PULONG)&Offset)) + { + /* Exception occurred */ + return FALSE; + } + + /* Add the signed offset to the address */ + ModRegRm->MemoryAddress += Offset; + } + } + else + { + /* Check the operand */ + switch (RegMem) + { + case 0: + case 2: + { + /* (SS:)[BX + SI] */ + ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBX].LowWord + + State->GeneralRegs[SOFT386_REG_ESI].LowWord; + + break; + } + + case 1: + case 3: + { + /* (SS:)[BX + DI] */ + ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBX].LowWord + + State->GeneralRegs[SOFT386_REG_EDI].LowWord; + + break; + } + + case 4: + { + /* [SI] */ + ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_ESI].LowWord; + + break; + } + + case 5: + { + /* [DI] */ + ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EDI].LowWord; + + break; + } + + case 6: + { + if (Mode) + { + /* [BP] */ + ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBP].LowWord; + } + else + { + /* [constant] (added later) */ + ModRegRm->MemoryAddress = 0; + } + + break; + } + + case 7: + { + /* [BX] */ + ModRegRm->MemoryAddress = State->GeneralRegs[SOFT386_REG_EBX].LowWord; + + break; + } + } + + /* Check if there is no segment override */ + if (!(State->PrefixFlags & SOFT386_PREFIX_SEG)) + { + /* Check if the default segment should be SS */ + if ((RegMem == 2) || (RegMem == 3) || ((RegMem == 6) && Mode)) + { + /* Add a SS: prefix */ + State->PrefixFlags |= SOFT386_PREFIX_SEG; + State->SegmentOverride = SOFT386_REG_SS; + } + } + + if (Mode == 1) + { + CHAR Offset; + + /* Fetch the byte */ + if (!Soft386FetchByte(State, (PUCHAR)&Offset)) + { + /* Exception occurred */ + return FALSE; + } + + /* Add the signed offset to the address */ + ModRegRm->MemoryAddress += (LONG)Offset; + } + else if ((Mode == 2) || ((Mode == 0) && (RegMem == 6))) + { + SHORT Offset; + + /* Fetch the word */ + if (!Soft386FetchWord(State, (PUSHORT)&Offset)) + { + /* Exception occurred */ + return FALSE; + } + + /* Add the signed offset to the address */ + ModRegRm->MemoryAddress += (LONG)Offset; + } + } + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386ReadModrmByteOperands(PSOFT386_STATE State, + PSOFT386_MOD_REG_RM ModRegRm, + PUCHAR RegValue, + PUCHAR RmValue) +{ + SOFT386_SEG_REGS Segment = SOFT386_REG_DS; + + /* Get the register value */ + if (ModRegRm->Register & 0x04) + { + /* AH, CH, DH, BH */ + *RegValue = State->GeneralRegs[ModRegRm->Register & 0x03].HighByte; + } + else + { + /* AL, CL, DL, BL */ + *RegValue = State->GeneralRegs[ModRegRm->Register & 0x03].LowByte; + } + + if (!ModRegRm->Memory) + { + /* Get the second register value */ + if (ModRegRm->SecondRegister & 0x04) + { + /* AH, CH, DH, BH */ + *RmValue = State->GeneralRegs[ModRegRm->SecondRegister & 0x03].HighByte; + } + else + { + /* AL, CL, DL, BL */ + *RmValue = State->GeneralRegs[ModRegRm->SecondRegister & 0x03].LowByte; + } + } + else + { + /* Check for the segment override */ + if (State->PrefixFlags & SOFT386_PREFIX_SEG) + { + /* Use the override segment instead */ + Segment = State->SegmentOverride; + } + + /* Read memory */ + if (!Soft386ReadMemory(State, + Segment, + ModRegRm->MemoryAddress, + FALSE, + RmValue, + sizeof(UCHAR))) + { + /* Exception occurred */ + return FALSE; + } + } + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386ReadModrmWordOperands(PSOFT386_STATE State, + PSOFT386_MOD_REG_RM ModRegRm, + PUSHORT RegValue, + PUSHORT RmValue) +{ + SOFT386_SEG_REGS Segment = SOFT386_REG_DS; + + /* Get the register value */ + *RegValue = State->GeneralRegs[ModRegRm->Register].LowWord; + + if (!ModRegRm->Memory) + { + /* Get the second register value */ + *RmValue = State->GeneralRegs[ModRegRm->SecondRegister].LowWord; + } + else + { + /* Check for the segment override */ + if (State->PrefixFlags & SOFT386_PREFIX_SEG) + { + /* Use the override segment instead */ + Segment = State->SegmentOverride; + } + + /* Read memory */ + if (!Soft386ReadMemory(State, + Segment, + ModRegRm->MemoryAddress, + FALSE, + RmValue, + sizeof(USHORT))) + { + /* Exception occurred */ + return FALSE; + } + } + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386ReadModrmDwordOperands(PSOFT386_STATE State, + PSOFT386_MOD_REG_RM ModRegRm, + PULONG RegValue, + PULONG RmValue) +{ + SOFT386_SEG_REGS Segment = SOFT386_REG_DS; + + /* Get the register value */ + *RegValue = State->GeneralRegs[ModRegRm->Register].Long; + + if (!ModRegRm->Memory) + { + /* Get the second register value */ + *RmValue = State->GeneralRegs[ModRegRm->SecondRegister].Long; + } + else + { + /* Check for the segment override */ + if (State->PrefixFlags & SOFT386_PREFIX_SEG) + { + /* Use the override segment instead */ + Segment = State->SegmentOverride; + } + + /* Read memory */ + if (!Soft386ReadMemory(State, + Segment, + ModRegRm->MemoryAddress, + FALSE, + RmValue, + sizeof(ULONG))) + { + /* Exception occurred */ + return FALSE; + } + } + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386WriteModrmByteOperands(PSOFT386_STATE State, + PSOFT386_MOD_REG_RM ModRegRm, + BOOLEAN WriteRegister, + UCHAR Value) +{ + SOFT386_SEG_REGS Segment = SOFT386_REG_DS; + + if (WriteRegister) + { + /* Store the value in the register */ + if (ModRegRm->Register & 0x04) + { + /* AH, CH, DH, BH */ + State->GeneralRegs[ModRegRm->Register & 0x03].HighByte = Value; + } + else + { + /* AL, CL, DL, BL */ + State->GeneralRegs[ModRegRm->Register & 0x03].LowByte = Value; + } + } + else + { + if (!ModRegRm->Memory) + { + /* Store the value in the second register */ + if (ModRegRm->SecondRegister & 0x04) + { + /* AH, CH, DH, BH */ + State->GeneralRegs[ModRegRm->SecondRegister & 0x03].HighByte = Value; + } + else + { + /* AL, CL, DL, BL */ + State->GeneralRegs[ModRegRm->SecondRegister & 0x03].LowByte = Value; + } + } + else + { + /* Check for the segment override */ + if (State->PrefixFlags & SOFT386_PREFIX_SEG) + { + /* Use the override segment instead */ + Segment = State->SegmentOverride; + } + + /* Write memory */ + if (!Soft386WriteMemory(State, + Segment, + ModRegRm->MemoryAddress, + &Value, + sizeof(UCHAR))) + { + /* Exception occurred */ + return FALSE; + } + } + } + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386WriteModrmWordOperands(PSOFT386_STATE State, + PSOFT386_MOD_REG_RM ModRegRm, + BOOLEAN WriteRegister, + USHORT Value) +{ + SOFT386_SEG_REGS Segment = SOFT386_REG_DS; + + if (WriteRegister) + { + /* Store the value in the register */ + State->GeneralRegs[ModRegRm->Register].LowWord = Value; + } + else + { + if (!ModRegRm->Memory) + { + /* Store the value in the second register */ + State->GeneralRegs[ModRegRm->SecondRegister].LowWord = Value; + } + else + { + /* Check for the segment override */ + if (State->PrefixFlags & SOFT386_PREFIX_SEG) + { + /* Use the override segment instead */ + Segment = State->SegmentOverride; + } + + /* Write memory */ + if (!Soft386WriteMemory(State, + Segment, + ModRegRm->MemoryAddress, + &Value, + sizeof(USHORT))) + { + /* Exception occurred */ + return FALSE; + } + } + } + + return TRUE; +} + +FORCEINLINE +BOOLEAN +Soft386WriteModrmDwordOperands(PSOFT386_STATE State, + PSOFT386_MOD_REG_RM ModRegRm, + BOOLEAN WriteRegister, + ULONG Value) +{ + SOFT386_SEG_REGS Segment = SOFT386_REG_DS; + + if (WriteRegister) + { + /* Store the value in the register */ + State->GeneralRegs[ModRegRm->Register].Long = Value; + } + else + { + if (!ModRegRm->Memory) + { + /* Store the value in the second register */ + State->GeneralRegs[ModRegRm->SecondRegister].Long = Value; + } + else + { + /* Check for the segment override */ + if (State->PrefixFlags & SOFT386_PREFIX_SEG) + { + /* Use the override segment instead */ + Segment = State->SegmentOverride; + } + + /* Write memory */ + if (!Soft386WriteMemory(State, + Segment, + ModRegRm->MemoryAddress, + &Value, + sizeof(ULONG))) + { + /* Exception occurred */ + return FALSE; + } + } + } + + return TRUE; +} + +/* EOF */ Propchange: branches/ntvdm/lib/soft386/common.inl ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/ntvdm/lib/soft386/opcodes.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opcodes.c?rev…
============================================================================== --- branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] Tue Sep 17 23:02:22 2013 @@ -12,12 +12,12 @@ // #define _INC_WINDOWS #include <windef.h> +// #define NDEBUG +#include <debug.h> + #include <soft386.h> #include "opcodes.h" #include "common.h" - -// #define NDEBUG -#include <debug.h> /* PUBLIC VARIABLES ***********************************************************/ Modified: branches/ntvdm/lib/soft386/soft386.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/soft386.c?rev…
============================================================================== --- branches/ntvdm/lib/soft386/soft386.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/soft386.c [iso-8859-1] Tue Sep 17 23:02:22 2013 @@ -12,12 +12,12 @@ // #define _INC_WINDOWS #include <windef.h> +// #define NDEBUG +#include <debug.h> + #include <soft386.h> #include "common.h" #include "opcodes.h" - -// #define NDEBUG -#include <debug.h> /* DEFINES ********************************************************************/
11 years, 3 months
1
0
0
0
[akhaldi] 60192: * Silence a debug print.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Tue Sep 17 22:49:56 2013 New Revision: 60192 URL:
http://svn.reactos.org/svn/reactos?rev=60192&view=rev
Log: * Silence a debug print. Modified: trunk/reactos/dll/win32/kernel32/client/proc.c Modified: trunk/reactos/dll/win32/kernel32/client/proc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] Tue Sep 17 22:49:56 2013 @@ -2873,7 +2873,7 @@ SxsWin32ExePath = PathBufferString; PathBuffer = PathBufferString.Buffer; PathBufferString.Buffer = NULL; - DPRINT1("SxS Path: %S\n", PathBuffer); + DPRINT("SxS Path: %S\n", PathBuffer); } /* Also set the .EXE path based on the path name */
11 years, 3 months
1
0
0
0
[akhaldi] 60191: [RSYM] * Pad the coff string space. Brought to you by Arty.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Tue Sep 17 22:39:29 2013 New Revision: 60191 URL:
http://svn.reactos.org/svn/reactos?rev=60191&view=rev
Log: [RSYM] * Pad the coff string space. Brought to you by Arty. Modified: trunk/reactos/tools/rsym/rsym.c Modified: trunk/reactos/tools/rsym/rsym.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rsym/rsym.c?rev=6019…
============================================================================== --- trunk/reactos/tools/rsym/rsym.c [iso-8859-1] (original) +++ trunk/reactos/tools/rsym/rsym.c [iso-8859-1] Tue Sep 17 22:39:29 2013 @@ -1163,6 +1163,8 @@ if (OutFileHeader->PointerToSymbolTable) { + int PaddingFrom = (OutFileHeader->PointerToSymbolTable + StringTableLength) % + OutOptHeader->FileAlignment; fseek(OutFile, OutFileHeader->PointerToSymbolTable, 0); /* COFF string section is preceeded by a length */ @@ -1172,6 +1174,15 @@ The string table length technically counts as part of the string table space itself. */ fwrite(StringTable + 4, 1, StringTableLength - 4, OutFile); + + if (PaddingFrom) + { + int PaddingSize = OutOptHeader->FileAlignment - PaddingFrom; + char *Padding = (char *)malloc(PaddingSize); + memset(Padding, 0, PaddingFrom); + fwrite(Padding, 1, PaddingSize, OutFile); + free(Padding); + } } if (PaddedRosSym)
11 years, 3 months
1
0
0
0
[akhaldi] 60190: [CMAKE] * Add a proper way to enable/disable PSEH3.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Tue Sep 17 22:31:33 2013 New Revision: 60190 URL:
http://svn.reactos.org/svn/reactos?rev=60190&view=rev
Log: [CMAKE] * Add a proper way to enable/disable PSEH3. Modified: trunk/reactos/CMakeLists.txt trunk/reactos/cmake/config.cmake trunk/reactos/cmake/gcc.cmake trunk/reactos/lib/pseh/CMakeLists.txt Modified: trunk/reactos/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/CMakeLists.txt?rev=60190&r…
============================================================================== --- trunk/reactos/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/CMakeLists.txt [iso-8859-1] Tue Sep 17 22:31:33 2013 @@ -127,10 +127,6 @@ if(_WINKD_) add_definitions(-D_WINKD_=1) - endif() - - if(USE_PSEH3) - add_definitions(-D_USE_PSEH3=1) endif() # Version Options Modified: trunk/reactos/cmake/config.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/config.cmake?rev=601…
============================================================================== --- trunk/reactos/cmake/config.cmake [iso-8859-1] (original) +++ trunk/reactos/cmake/config.cmake [iso-8859-1] Tue Sep 17 22:31:33 2013 @@ -71,15 +71,8 @@ "Whether to create a graphml dependency of dlls.") if(MSVC) - set(_PREFAST_ FALSE CACHE BOOL "Whether to enable PREFAST while compiling.") set(_VS_ANALYZE_ FALSE CACHE BOOL "Whether to enable static analysis while compiling.") - -else() - -set(USE_PSEH3 FALSE CACHE BOOL -"Whether to use the new PSEH3 library (requires GCC 4.5 and newer).") - endif() Modified: trunk/reactos/cmake/gcc.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/gcc.cmake?rev=60190&…
============================================================================== --- trunk/reactos/cmake/gcc.cmake [iso-8859-1] (original) +++ trunk/reactos/cmake/gcc.cmake [iso-8859-1] Tue Sep 17 22:31:33 2013 @@ -7,6 +7,14 @@ # PDB style debug info if(NOT DEFINED SEPARATE_DBG) set(SEPARATE_DBG FALSE) +endif() + +if(NOT DEFINED USE_PSEH3) + set(USE_PSEH3 0) +endif() + +if(USE_PSEH3) + add_definitions(-D_USE_PSEH3=1) endif() # Compiler Core Modified: trunk/reactos/lib/pseh/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/CMakeLists.txt?re…
============================================================================== --- trunk/reactos/lib/pseh/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/lib/pseh/CMakeLists.txt [iso-8859-1] Tue Sep 17 22:31:33 2013 @@ -1,7 +1,7 @@ if(NOT MSVC) - if (USE_PSEH3) + if(USE_PSEH3) include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs/pseh) list(APPEND SOURCE i386/pseh3.c
11 years, 3 months
1
0
0
0
[hbelusca] 60189: [SOFT386] - Code formatting (align on 4-space) - Fix union / struct problem in _SOFT386_PAGE_TABLE.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Sep 17 21:47:38 2013 New Revision: 60189 URL:
http://svn.reactos.org/svn/reactos?rev=60189&view=rev
Log: [SOFT386] - Code formatting (align on 4-space) - Fix union / struct problem in _SOFT386_PAGE_TABLE. Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h branches/ntvdm/lib/soft386/CMakeLists.txt branches/ntvdm/lib/soft386/common.h Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/include/reactos/libs/soft…
============================================================================== --- branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] (original) +++ branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] Tue Sep 17 21:47:38 2013 @@ -11,35 +11,35 @@ /* DEFINES ********************************************************************/ -#define SOFT386_NUM_GEN_REGS 8 -#define SOFT386_NUM_SEG_REGS 6 -#define SOFT386_NUM_CTRL_REGS 8 -#define SOFT386_NUM_DBG_REGS 8 - -#define SOFT386_CR0_PE (1 << 0) -#define SOFT386_CR0_MP (1 << 1) -#define SOFT386_CR0_EM (1 << 2) -#define SOFT386_CR0_TS (1 << 3) -#define SOFT386_CR0_ET (1 << 4) -#define SOFT386_CR0_NE (1 << 5) -#define SOFT386_CR0_WP (1 << 16) -#define SOFT386_CR0_AM (1 << 18) -#define SOFT386_CR0_NW (1 << 29) -#define SOFT386_CR0_CD (1 << 30) -#define SOFT386_CR0_PG (1 << 31) - -#define SOFT386_IDT_TASK_GATE 0x5 -#define SOFT386_IDT_INT_GATE 0x6 -#define SOFT386_IDT_TRAP_GATE 0x7 -#define SOFT386_IDT_INT_GATE_32 0xE -#define SOFT386_IDT_TRAP_GATE_32 0xF - -#define SOFT386_PREFIX_SEG (1 << 0) -#define SOFT386_PREFIX_OPSIZE (1 << 1) -#define SOFT386_PREFIX_ADSIZE (1 << 2) -#define SOFT386_PREFIX_LOCK (1 << 3) -#define SOFT386_PREFIX_REPNZ (1 << 4) -#define SOFT386_PREFIX_REP (1 << 5) +#define SOFT386_NUM_GEN_REGS 8 +#define SOFT386_NUM_SEG_REGS 6 +#define SOFT386_NUM_CTRL_REGS 8 +#define SOFT386_NUM_DBG_REGS 8 + +#define SOFT386_CR0_PE (1 << 0) +#define SOFT386_CR0_MP (1 << 1) +#define SOFT386_CR0_EM (1 << 2) +#define SOFT386_CR0_TS (1 << 3) +#define SOFT386_CR0_ET (1 << 4) +#define SOFT386_CR0_NE (1 << 5) +#define SOFT386_CR0_WP (1 << 16) +#define SOFT386_CR0_AM (1 << 18) +#define SOFT386_CR0_NW (1 << 29) +#define SOFT386_CR0_CD (1 << 30) +#define SOFT386_CR0_PG (1 << 31) + +#define SOFT386_IDT_TASK_GATE 0x5 +#define SOFT386_IDT_INT_GATE 0x6 +#define SOFT386_IDT_TRAP_GATE 0x7 +#define SOFT386_IDT_INT_GATE_32 0xE +#define SOFT386_IDT_TRAP_GATE_32 0xF + +#define SOFT386_PREFIX_SEG (1 << 0) +#define SOFT386_PREFIX_OPSIZE (1 << 1) +#define SOFT386_PREFIX_ADSIZE (1 << 2) +#define SOFT386_PREFIX_LOCK (1 << 3) +#define SOFT386_PREFIX_REPNZ (1 << 4) +#define SOFT386_PREFIX_REP (1 << 5) struct _SOFT386_STATE; typedef struct _SOFT386_STATE SOFT386_STATE, *PSOFT386_STATE; @@ -176,47 +176,47 @@ USHORT Selector; /* Descriptor cache */ - ULONG Accessed : 1; - ULONG ReadWrite : 1; - ULONG DirConf : 1; - ULONG Executable : 1; - ULONG SystemType : 1; - ULONG Dpl : 2; - ULONG Present : 1; - ULONG Size : 1; + ULONG Accessed : 1; + ULONG ReadWrite : 1; + ULONG DirConf : 1; + ULONG Executable : 1; + ULONG SystemType : 1; + ULONG Dpl : 2; + ULONG Present : 1; + ULONG Size : 1; ULONG Limit; ULONG Base; } SOFT386_SEG_REG, *PSOFT386_SEG_REG; typedef struct { - ULONG Limit : 16; - ULONG Base : 24; - ULONG Accessed : 1; - ULONG ReadWrite : 1; - ULONG DirConf : 1; - ULONG Executable : 1; - ULONG SystemType : 1; - ULONG Dpl : 2; - ULONG Present : 1; - ULONG LimitHigh : 4; - ULONG Avl : 1; - ULONG Reserved : 1; - ULONG Size : 1; - ULONG Granularity : 1; - ULONG BaseHigh : 8; + ULONG Limit : 16; + ULONG Base : 24; + ULONG Accessed : 1; + ULONG ReadWrite : 1; + ULONG DirConf : 1; + ULONG Executable : 1; + ULONG SystemType : 1; + ULONG Dpl : 2; + ULONG Present : 1; + ULONG LimitHigh : 4; + ULONG Avl : 1; + ULONG Reserved : 1; + ULONG Size : 1; + ULONG Granularity : 1; + ULONG BaseHigh : 8; } SOFT386_GDT_ENTRY, *PSOFT386_GDT_ENTRY; typedef struct { - ULONG Offset : 16; - ULONG Selector : 16; - ULONG Zero : 8; - ULONG Type : 4; - ULONG Storage : 1; - ULONG Dpl : 2; - ULONG Present : 1; - ULONG OffsetHigh : 16; + ULONG Offset : 16; + ULONG Selector : 16; + ULONG Zero : 8; + ULONG Type : 4; + ULONG Storage : 1; + ULONG Dpl : 2; + ULONG Present : 1; + ULONG OffsetHigh : 16; } SOFT386_IDT_ENTRY, *PSOFT386_IDT_ENTRY; typedef struct _SOFT386_TABLE_REG @@ -230,27 +230,27 @@ ULONG Long; struct { - ULONG Cf : 1; + ULONG Cf : 1; ULONG AlwaysSet : 1; - ULONG Pf : 1; + ULONG Pf : 1; ULONG Reserved0 : 1; - ULONG Af : 1; + ULONG Af : 1; ULONG Reserved1 : 1; - ULONG Zf : 1; - ULONG Sf : 1; - ULONG Tf : 1; - ULONG If : 1; - ULONG Df : 1; - ULONG Of : 1; - ULONG Iopl : 2; - ULONG Nt : 1; + ULONG Zf : 1; + ULONG Sf : 1; + ULONG Tf : 1; + ULONG If : 1; + ULONG Df : 1; + ULONG Of : 1; + ULONG Iopl : 2; + ULONG Nt : 1; ULONG Reserved2 : 1; - ULONG Rf : 1; - ULONG Vm : 1; - ULONG Ac : 1; - ULONG Vif : 1; - ULONG Vip : 1; - ULONG Id : 1; + ULONG Rf : 1; + ULONG Vm : 1; + ULONG Ac : 1; + ULONG Vif : 1; + ULONG Vip : 1; + ULONG Id : 1; // ULONG Reserved : 10; }; Modified: branches/ntvdm/lib/soft386/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/CMakeLists.tx…
============================================================================== --- branches/ntvdm/lib/soft386/CMakeLists.txt [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/CMakeLists.txt [iso-8859-1] Tue Sep 17 21:47:38 2013 @@ -1,3 +1,4 @@ + include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs/soft386) list(APPEND SOURCE Modified: branches/ntvdm/lib/soft386/common.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/common.h?rev=…
============================================================================== --- branches/ntvdm/lib/soft386/common.h [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/common.h [iso-8859-1] Tue Sep 17 21:47:38 2013 @@ -15,17 +15,19 @@ #define FASTCALL __fastcall #endif -#define SIGN_FLAG_BYTE 0x80 -#define SIGN_FLAG_WORD 0x8000 -#define SIGN_FLAG_LONG 0x80000000 -#define GET_SEGMENT_RPL(s) ((s) & 3) -#define GET_SEGMENT_INDEX(s) ((s) & 0xFFF8) +#define SIGN_FLAG_BYTE 0x80 +#define SIGN_FLAG_WORD 0x8000 +#define SIGN_FLAG_LONG 0x80000000 + +#define GET_SEGMENT_RPL(s) ((s) & 3) +#define GET_SEGMENT_INDEX(s) ((s) & 0xFFF8) #define EXCEPTION_HAS_ERROR_CODE(x) (((x) == 8) || ((x) >= 10 && (x) <= 14)) -#define PAGE_ALIGN(x) ((x) & 0xFFFFF000) -#define PAGE_OFFSET(x) ((x) & 0x00000FFF) + +#define PAGE_ALIGN(x) ((x) & 0xFFFFF000) +#define PAGE_OFFSET(x) ((x) & 0x00000FFF) #ifndef PAGE_SIZE -#define PAGE_SIZE 4096 +#define PAGE_SIZE 4096 #endif typedef struct _SOFT386_MOD_REG_RM @@ -45,35 +47,35 @@ { struct { - ULONG Present : 1; - ULONG Writeable : 1; - ULONG Usermode : 1; - ULONG WriteThrough : 1; - ULONG NoCache : 1; - ULONG Accessed : 1; - ULONG AlwaysZero : 1; - ULONG Size : 1; - ULONG Unused : 4; - ULONG TableAddress : 20; + ULONG Present : 1; + ULONG Writeable : 1; + ULONG Usermode : 1; + ULONG WriteThrough : 1; + ULONG NoCache : 1; + ULONG Accessed : 1; + ULONG AlwaysZero : 1; + ULONG Size : 1; + ULONG Unused : 4; + ULONG TableAddress : 20; }; ULONG Value; } SOFT386_PAGE_DIR, *PSOFT386_PAGE_DIR; -typedef struct _SOFT386_PAGE_TABLE +typedef union _SOFT386_PAGE_TABLE { - union + struct { - ULONG Present : 1; - ULONG Writeable : 1; - ULONG Usermode : 1; - ULONG WriteThrough : 1; - ULONG NoCache : 1; - ULONG Accessed : 1; - ULONG Dirty : 1; - ULONG AlwaysZero : 1; - ULONG Global : 1; - ULONG Unused : 3; - ULONG Address : 20; + ULONG Present : 1; + ULONG Writeable : 1; + ULONG Usermode : 1; + ULONG WriteThrough : 1; + ULONG NoCache : 1; + ULONG Accessed : 1; + ULONG Dirty : 1; + ULONG AlwaysZero : 1; + ULONG Global : 1; + ULONG Unused : 3; + ULONG Address : 20; }; ULONG Value; } SOFT386_PAGE_TABLE, *PSOFT386_PAGE_TABLE;
11 years, 3 months
1
0
0
0
[hbelusca] 60188: Add a fictitious (commented) field to help the reader to know that indeed, the high bits are indeed reserved.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Sep 17 21:27:29 2013 New Revision: 60188 URL:
http://svn.reactos.org/svn/reactos?rev=60188&view=rev
Log: Add a fictitious (commented) field to help the reader to know that indeed, the high bits are indeed reserved. Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/include/reactos/libs/soft…
============================================================================== --- branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] (original) +++ branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] Tue Sep 17 21:27:29 2013 @@ -168,7 +168,7 @@ }; USHORT LowWord; }; - ULONG Long; + ULONG Long; } SOFT386_REG, *PSOFT386_REG; typedef struct _SOFT386_SEG_REG @@ -251,6 +251,8 @@ ULONG Vif : 1; ULONG Vip : 1; ULONG Id : 1; + + // ULONG Reserved : 10; }; } SOFT386_FLAGS_REG, *PSOFT386_FLAGS_REG;
11 years, 3 months
1
0
0
0
[aandrejevic] 60187: [SOFT386] Fix hypothetical bug.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Tue Sep 17 21:15:52 2013 New Revision: 60187 URL:
http://svn.reactos.org/svn/reactos?rev=60187&view=rev
Log: [SOFT386] Fix hypothetical bug. Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h Modified: branches/ntvdm/include/reactos/libs/soft386/soft386.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/include/reactos/libs/soft…
============================================================================== --- branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] (original) +++ branches/ntvdm/include/reactos/libs/soft386/soft386.h [iso-8859-1] Tue Sep 17 21:15:52 2013 @@ -159,12 +159,15 @@ typedef union _SOFT386_REG { - struct + union { - UCHAR LowByte; - UCHAR HighByte; + struct + { + UCHAR LowByte; + UCHAR HighByte; + }; + USHORT LowWord; }; - USHORT LowWord; ULONG Long; } SOFT386_REG, *PSOFT386_REG;
11 years, 3 months
1
0
0
0
← Newer
1
...
27
28
29
30
31
32
33
...
56
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Results per page:
10
25
50
100
200