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
July 2005
----- 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
21 participants
563 discussions
Start a n
N
ew thread
[greatlrd] 16651: add ConErrMessage to deal with error msg and ConOutMessage for other msg. Copy error msg are always pipe with ConOut and CD error msg with ConErr. Thx harmut that remmid me about it. All error msg need to check if they goes with ConErr or ConOut
by greatlrd@svn.reactos.com
add ConErrMessage to deal with error msg and ConOutMessage for other msg. Copy error msg are always pipe with ConOut and CD error msg with ConErr. Thx harmut that remmid me about it. All error msg need to check if they goes with ConErr or ConOut Modified: trunk/reactos/subsys/system/cmd/cmd.h Modified: trunk/reactos/subsys/system/cmd/console.c Modified: trunk/reactos/subsys/system/cmd/internal.c _____ Modified: trunk/reactos/subsys/system/cmd/cmd.h --- trunk/reactos/subsys/system/cmd/cmd.h 2005-07-19 21:04:19 UTC (rev 16650) +++ trunk/reactos/subsys/system/cmd/cmd.h 2005-07-19 22:48:35 UTC (rev 16651) @@ -152,6 +152,7 @@ VOID ConErrPuts (LPTSTR); VOID ConErrPrintf (LPTSTR, ...); VOID ConOutFormatMessage (DWORD MessageId, ...); +VOID ConErrFormatMessage (DWORD MessageId, ...); SHORT GetCursorX (VOID); SHORT GetCursorY (VOID); _____ Modified: trunk/reactos/subsys/system/cmd/console.c --- trunk/reactos/subsys/system/cmd/console.c 2005-07-19 21:04:19 UTC (rev 16650) +++ trunk/reactos/subsys/system/cmd/console.c 2005-07-19 22:48:35 UTC (rev 16651) @@ -330,6 +330,35 @@ #endif } +VOID ConErrFormatMessage (DWORD MessageId, ...) +{ + TCHAR szMsg[RC_STRING_MAX_SIZE]; + DWORD ret; + LPTSTR text; + va_list arg_ptr; + + va_start (arg_ptr, MessageId); + ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + MessageId, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &text, + 0, + &arg_ptr); + + va_end (arg_ptr); + if(ret > 0) + { + ConErrPuts (text); + LocalFree(text); + } + else + { + LoadString(CMD_ModuleHandle, STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); + } +} + VOID ConOutFormatMessage (DWORD MessageId, ...) { TCHAR szMsg[RC_STRING_MAX_SIZE]; @@ -349,13 +378,13 @@ va_end (arg_ptr); if(ret > 0) { - ConOutPuts (text); + ConErrPuts (text); LocalFree(text); } else { LoadString(CMD_ModuleHandle, STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE); - ConOutPrintf(szMsg); + ConErrPrintf(szMsg); } } _____ Modified: trunk/reactos/subsys/system/cmd/internal.c --- trunk/reactos/subsys/system/cmd/internal.c 2005-07-19 21:04:19 UTC (rev 16650) +++ trunk/reactos/subsys/system/cmd/internal.c 2005-07-19 22:48:35 UTC (rev 16651) @@ -364,7 +364,7 @@ { if(hFile == INVALID_HANDLE_VALUE) { - ConOutFormatMessage (GetLastError(), szFinalPath); + ConErrFormatMessage (GetLastError(), szFinalPath); nErrorLevel = 1; return 1; }
19 years, 6 months
1
0
0
0
[ion] 16650: - 4th out of 5 patch part of ROSRTL removal. This touches fibers:
by ion@svn.reactos.com
- 4th out of 5 patch part of ROSRTL removal. This touches fibers: * Support SxS when available (add new fiber member for this as well). * Support FLS when available. * Added new Fiber Members for new features in XP/2003 (GuaranteedStackBytes and FlsData) * Support FPU State Restore/Save in switch code. * Use new common stack/context initialization routines instead of ROSRTL. * Change Fiber structure to use CONTEXT directly in order to speed up and generalize context creation. * Fix BaseFiberStartup to send right parameters. Note: not yet fully tested with fibertest, I will do this later today and fix any bugs. Modified: trunk/reactos/lib/kernel32/thread/fiber.c Modified: trunk/reactos/lib/kernel32/thread/i386/fiber.S Modified: trunk/reactos/lib/kernel32/thread/thread.c _____ Modified: trunk/reactos/lib/kernel32/thread/fiber.c --- trunk/reactos/lib/kernel32/thread/fiber.c 2005-07-19 20:56:38 UTC (rev 16649) +++ trunk/reactos/lib/kernel32/thread/fiber.c 2005-07-19 21:04:19 UTC (rev 16650) @@ -1,297 +1,251 @@ -/* $Id$ - * - * FILE: lib/kernel32/thread/fiber.c - * - * ReactOS Kernel32.dll - * +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS System Libraries + * FILE: lib/kernel32/thread/fiber.c + * PURPOSE: Fiber Implementation + * PROGRAMMERS: + * Alex Ionescu (alex(a)relsoft.net) + * KJK::Hyperion <noog(a)libero.it> */ #include <k32.h> -/* FIXME */ -#include <rosrtl/thread.h> - #define NDEBUG #include "../include/debug.h" -struct _FIBER /* Field offsets: */ -{ /* 32 bit 64 bit */ - /* this must be the first field */ - LPVOID Parameter; /* 0x00 0x00 */ +typedef struct _FIBER /* Field offsets: */ +{ /* 32 bit 64 bit */ + /* this must be the first field */ + LPVOID Parameter; /* 0x00 0x00 */ + struct _EXCEPTION_REGISTRATION_RECORD * ExceptionList; /* 0x04 0x08 */ + LPVOID StackBase; /* 0x08 0x10 */ + LPVOID StackLimit; /* 0x0C 0x18 */ + LPVOID DeallocationStack; /* 0x10 0x20 */ + CONTEXT Context; /* 0x14 0x28 */ + ULONG GuaranteedStackBytes; /* 0x2E0 */ + PVOID FlsData; /* 0x2E4 */ + PVOID ActivationContextStack; /* 0x2E8 */ +} FIBER, *PFIBER; - struct _EXCEPTION_REGISTRATION_RECORD * ExceptionList; /* 0x04 0x08 */ - LPVOID StackBase; /* 0x08 0x10 */ - LPVOID StackLimit; /* 0x0C 0x18 */ - LPVOID DeallocationStack; /* 0x10 0x20 */ - ULONG_PTR Flags; /* 0x14 0x28 */ -#if defined(_M_IX86) - /* control flow registers */ - DWORD Eip; /* 0x18 ---- */ - DWORD Esp; /* 0x1C ---- */ - DWORD Ebp; /* 0x20 ---- */ - - /* general-purpose registers that must be preserved across calls */ - DWORD Ebx; /* 0x24 ---- */ - DWORD Esi; /* 0x28 ---- */ - DWORD Edi; /* 0x2C ---- */ - - /* floating point save area (optional) */ - FLOATING_SAVE_AREA FloatSave; /* 0x30 ---- */ -#else -#error Unspecified or unsupported architecture. -#endif -}; - -typedef struct _FIBER FIBER, * PFIBER; - -__declspec(noreturn) void WINAPI FiberStartup(PVOID lpStartAddress); - /* * @implemented */ -BOOL WINAPI ConvertFiberToThread(void) +BOOL +WINAPI +ConvertFiberToThread(VOID) { - PTEB pTeb = NtCurrentTeb(); + PTEB pTeb = NtCurrentTeb(); + DPRINT1("Converting Fiber to Thread\n"); - /* the current thread isn't running a fiber: failure */ - if(!pTeb->HasFiberData) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } + /* the current thread isn't running a fiber: failure */ + if(!pTeb->HasFiberData) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } - /* this thread won't run a fiber anymore */ - pTeb->HasFiberData = FALSE; + /* this thread won't run a fiber anymore */ + pTeb->HasFiberData = FALSE; - /* free the fiber */ - if(pTeb->Tib.FiberData != NULL) - RtlFreeHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, pTeb->Tib.FiberData); + /* free the fiber */ + if(pTeb->Tib.FiberData != NULL) + { + RtlFreeHeap(GetProcessHeap(), 0, pTeb->Tib.FiberData); + } - /* success */ - return TRUE; + /* success */ + return TRUE; } - /* * @implemented */ -LPVOID WINAPI ConvertThreadToFiberEx(LPVOID lpParameter, DWORD dwFlags) +LPVOID +WINAPI +ConvertThreadToFiberEx(LPVOID lpParameter, + DWORD dwFlags) { - PTEB pTeb = NtCurrentTeb(); - PFIBER pfCurFiber; + PTEB pTeb = NtCurrentTeb(); + PFIBER pfCurFiber; + DPRINT1("Converting Thread to Fiber\n"); - /* the current thread is already a fiber */ - if(pTeb->HasFiberData && pTeb->Tib.FiberData) return pTeb->Tib.FiberData; + /* the current thread is already a fiber */ + if(pTeb->HasFiberData && pTeb->Tib.FiberData) return pTeb->Tib.FiberData; - /* allocate the fiber */ - pfCurFiber = (PFIBER)RtlAllocateHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, sizeof(FIBER)); + /* allocate the fiber */ + pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(), + 0, + sizeof(FIBER)); - /* failure */ - if(pfCurFiber == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return NULL; - } + /* failure */ + if(pfCurFiber == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } - pfCurFiber->Parameter = lpParameter; - pfCurFiber->Flags = dwFlags; + /* copy some contextual data from the thread to the fiber */ + pfCurFiber->ExceptionList = pTeb->Tib.ExceptionList; + pfCurFiber->StackBase = pTeb->Tib.StackBase; + pfCurFiber->StackLimit = pTeb->Tib.StackLimit; + pfCurFiber->DeallocationStack = pTeb->DeallocationStack; + pfCurFiber->FlsData = pTeb->FlsData; + pfCurFiber->GuaranteedStackBytes = pTeb->GuaranteedStackBytes; + pfCurFiber->ActivationContextStack = pTeb->ActivationContextStackPointer; + pfCurFiber->Context.ContextFlags = CONTEXT_FULL; + + /* Save FPU State if requsted */ + if (dwFlags & FIBER_FLAG_FLOAT_SWITCH) + { + pfCurFiber->Context.ContextFlags |= CONTEXT_FLOATING_POINT; + } - /* copy some contextual data from the thread to the fiber */ - pfCurFiber->ExceptionList = pTeb->Tib.ExceptionList; - pfCurFiber->StackBase = pTeb->Tib.StackBase; - pfCurFiber->StackLimit = pTeb->Tib.StackLimit; - pfCurFiber->DeallocationStack = pTeb->DeallocationStack; + /* associate the fiber to the current thread */ + pTeb->Tib.FiberData = pfCurFiber; + pTeb->HasFiberData = TRUE; - /* associate the fiber to the current thread */ - pTeb->Tib.FiberData = pfCurFiber; - pTeb->HasFiberData = TRUE; - - /* success */ - return (LPVOID)pfCurFiber; + /* success */ + return (LPVOID)pfCurFiber; } - /* * @implemented */ -LPVOID WINAPI ConvertThreadToFiber(LPVOID lpParameter) +LPVOID +WINAPI +ConvertThreadToFiber(LPVOID lpParameter) { - return ConvertThreadToFiberEx(lpParameter, 0); + /* Call the newer function */ + return ConvertThreadToFiberEx(lpParameter, 0); } - /* * @implemented */ -LPVOID WINAPI CreateFiber -( - SIZE_T dwStackSize, - LPFIBER_START_ROUTINE lpStartAddress, - LPVOID lpParameter -) +LPVOID +WINAPI +CreateFiber(SIZE_T dwStackSize, + LPFIBER_START_ROUTINE lpStartAddress, + LPVOID lpParameter) { - return CreateFiberEx(dwStackSize, 0, 0, lpStartAddress, lpParameter); + /* Call the Newer Function */ + return CreateFiberEx(dwStackSize, 0, 0, lpStartAddress, lpParameter); } - /* * @implemented */ -LPVOID WINAPI CreateFiberEx -( - SIZE_T dwStackCommitSize, - SIZE_T dwStackReserveSize, - DWORD dwFlags, - LPFIBER_START_ROUTINE lpStartAddress, - LPVOID lpParameter -) +LPVOID +WINAPI +CreateFiberEx(SIZE_T dwStackCommitSize, + SIZE_T dwStackReserveSize, + DWORD dwFlags, + LPFIBER_START_ROUTINE lpStartAddress, + LPVOID lpParameter) { - PFIBER pfCurFiber; - NTSTATUS nErrCode; - PSIZE_T pnStackReserve = NULL; - PSIZE_T pnStackCommit = NULL; - INITIAL_TEB usFiberInitialTeb; - CONTEXT ctxFiberContext; - PTEB pTeb = NtCurrentTeb(); + PFIBER pfCurFiber; + NTSTATUS nErrCode; + INITIAL_TEB usFiberInitialTeb; + CONTEXT ctxFiberContext; + PVOID ActivationContextStack = NULL; + DPRINT1("Creating Fiber\n"); - /* allocate the fiber */ - pfCurFiber = (PFIBER)RtlAllocateHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, sizeof(FIBER)); + #ifdef SXS_SUPPORT_ENABLED + /* Allocate the Activation Context Stack */ + nErrCode = RtlAllocateActivationContextStack(&ActivationContextStack); + #endif + + /* Allocate the fiber */ + pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(), + 0, + sizeof(FIBER)); + /* Failure */ + if(pfCurFiber == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } - /* failure */ - if(pfCurFiber == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return NULL; - } + /* Create the stack for the fiber */ + nErrCode = BasepCreateStack(NtCurrentProcess(), + dwStackCommitSize, + dwStackReserveSize, + &usFiberInitialTeb); + /* Failure */ + if(!NT_SUCCESS(nErrCode)) + { + /* Free the fiber */ + RtlFreeHeap(GetProcessHeap(), 0, pfCurFiber); - /* if the stack reserve or commit size weren't specified, use defaults */ - if(dwStackReserveSize > 0) pnStackReserve = &dwStackReserveSize; - if(dwStackCommitSize > 0) pnStackCommit = &dwStackCommitSize; - - /* create the stack for the fiber */ - nErrCode = RtlRosCreateStack - ( - NtCurrentProcess(), - &usFiberInitialTeb, - 0, - pnStackReserve, - pnStackCommit - ); - - /* failure */ - if(!NT_SUCCESS(nErrCode)) goto l_CleanupFiber; - - /* initialize the context for the fiber */ - nErrCode = RtlRosInitializeContext - ( - NtCurrentProcess(), - &ctxFiberContext, - FiberStartup, - &usFiberInitialTeb, - 1, - (ULONG_PTR *)&lpStartAddress - ); - - /* failure */ - if(!NT_SUCCESS(nErrCode)) goto l_CleanupStack; - - /* copy the data into the fiber */ - - /* fixed-size stack */ - if(usFiberInitialTeb.PreviousStackBase && usFiberInitialTeb.PreviousStackLimit) - { - pfCurFiber->StackBase = usFiberInitialTeb.PreviousStackBase; - pfCurFiber->StackLimit = usFiberInitialTeb.PreviousStackLimit; - pfCurFiber->DeallocationStack = usFiberInitialTeb.PreviousStackLimit; - } - /* expandable stack */ - else if - ( - usFiberInitialTeb.StackBase && - usFiberInitialTeb.StackLimit && - usFiberInitialTeb.AllocatedStackBase - ) - { - pfCurFiber->StackBase = usFiberInitialTeb.StackBase; - pfCurFiber->StackLimit = usFiberInitialTeb.StackLimit; - pfCurFiber->DeallocationStack = usFiberInitialTeb.AllocatedStackBase; - } - /* bad initial stack */ - else goto l_CleanupStack; - - pfCurFiber->Parameter = lpParameter; - pfCurFiber->Flags = dwFlags; - pfCurFiber->ExceptionList = (struct _EXCEPTION_REGISTRATION_RECORD *)-1; - -#if defined(_M_IX86) - - pfCurFiber->Eip = ctxFiberContext.Eip; - pfCurFiber->Esp = ctxFiberContext.Esp; - pfCurFiber->Ebp = ctxFiberContext.Ebp; - pfCurFiber->Ebx = ctxFiberContext.Ebx; - pfCurFiber->Esi = ctxFiberContext.Esi; - pfCurFiber->Edi = ctxFiberContext.Edi; - - if(dwFlags & FIBER_FLAG_FLOAT_SWITCH) - pfCurFiber->FloatSave = ctxFiberContext.FloatSave; - -#else -#error Unspecified or unsupported architecture. -#endif - - return pfCurFiber; - -l_CleanupStack: - /* free the stack */ - RtlRosDeleteStack(NtCurrentProcess(), &usFiberInitialTeb); - -l_CleanupFiber: - /* free the fiber */ - RtlFreeHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, pfCurFiber); - - /* failure */ - ASSERT(!NT_SUCCESS(nErrCode)); - SetLastErrorByStatus(nErrCode); - return NULL; + /* Failure */ + SetLastErrorByStatus(nErrCode); + return NULL; + } + + /* Clear the context */ + RtlZeroMemory(&pfCurFiber->Context, sizeof(CONTEXT)); + + /* copy the data into the fiber */ + pfCurFiber->StackBase = usFiberInitialTeb.StackBase; + pfCurFiber->StackLimit = usFiberInitialTeb.StackLimit; + pfCurFiber->DeallocationStack = usFiberInitialTeb.AllocatedStackBase; + pfCurFiber->Parameter = lpParameter; + pfCurFiber->ExceptionList = (struct _EXCEPTION_REGISTRATION_RECORD *)-1; + pfCurFiber->GuaranteedStackBytes = 0; + pfCurFiber->FlsData = NULL; + pfCurFiber->ActivationContextStack = ActivationContextStack; + pfCurFiber->Context.ContextFlags = CONTEXT_FULL; + + /* Save FPU State if requsted */ + if (dwFlags & FIBER_FLAG_FLOAT_SWITCH) + { + pfCurFiber->Context.ContextFlags |= CONTEXT_FLOATING_POINT; + } + + /* initialize the context for the fiber */ + BasepInitializeContext(&ctxFiberContext, + lpParameter, + lpStartAddress, + usFiberInitialTeb.StackBase, + 2); + + /* Return the Fiber */ + return pfCurFiber; } - /* * @implemented */ -void WINAPI DeleteFiber(LPVOID lpFiber) +VOID +WINAPI +DeleteFiber(LPVOID lpFiber) { - SIZE_T nSize = 0; - PVOID pStackAllocBase = ((PFIBER)lpFiber)->DeallocationStack; - PTEB pTeb = NtCurrentTeb(); + SIZE_T nSize = 0; + PVOID pStackAllocBase = ((PFIBER)lpFiber)->DeallocationStack; - /* free the fiber */ - RtlFreeHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, lpFiber); + /* free the fiber */ + RtlFreeHeap(GetProcessHeap(), 0, lpFiber); - /* the fiber is deleting itself: let the system deallocate the stack */ - if(pTeb->Tib.FiberData == lpFiber) ExitThread(1); + /* the fiber is deleting itself: let the system deallocate the stack */ + if(NtCurrentTeb()->Tib.FiberData == lpFiber) ExitThread(1); - /* deallocate the stack */ - NtFreeVirtualMemory - ( - NtCurrentProcess(), - &pStackAllocBase, - &nSize, - MEM_RELEASE - ); + /* deallocate the stack */ + NtFreeVirtualMemory(NtCurrentProcess(), + &pStackAllocBase, + &nSize, + MEM_RELEASE); } - -__declspec(noreturn) extern void WINAPI ThreadStartup -( - LPTHREAD_START_ROUTINE lpStartAddress, - LPVOID lpParameter -); - - -__declspec(noreturn) void WINAPI FiberStartup(PVOID lpStartAddress) +__declspec(noreturn) +VOID +WINAPI +BaseFiberStartup(VOID) { - /* FIXME? this should be pretty accurate */ - ThreadStartup(lpStartAddress, GetFiberData()); + PFIBER Fiber = GetFiberData(); + + /* Call the Thread Startup Routine */ + DPRINT1("Starting Fiber\n"); + BaseThreadStartup((LPTHREAD_START_ROUTINE)Fiber->Context.Eax, + (LPVOID)Fiber->Context.Ebx); } /* EOF */ _____ Modified: trunk/reactos/lib/kernel32/thread/i386/fiber.S --- trunk/reactos/lib/kernel32/thread/i386/fiber.S 2005-07-19 20:56:38 UTC (rev 16649) +++ trunk/reactos/lib/kernel32/thread/i386/fiber.S 2005-07-19 21:04:19 UTC (rev 16650) @@ -1,94 +1,128 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/thread/i386/fiber.S - * PURPOSE: Fiber context switch code for the x86 architecture - * PROGRAMMER: KJK::Hyperion <noog(a)libero.it> - * - * UPDATE HISTORY: - * 28/05/2003 - created - * +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/kernel32/thread/i386/fiber.S + * PURPOSE: Fiber context switch code for the x86 architecture + * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) + * KJK::Hyperion <noog(a)libero.it> */ -.extern _DbgPrint +#include <ndk/i386/segment.h> +/* + * FIXME: When ntoskrnl header changes are complete, move asm.h out of ntoskrnl + * so that we can use it here as well + */ +//#include <ndk/asm.h> +#include <../ntoskrnl/include/internal/asm.h> + .globl _SwitchToFiber@4 +.intel_syntax noprefix -ErrStr: - .ascii \ -"(KERNEL32:" __FILE__ ") Saving and restoring the floating point context \ -currently unimplemented\n\0" - _SwitchToFiber@4: + /* Get the TEB */ + mov edx, fs:[TEB_SELECTOR] + + /* Get the Fiber */ + mov eax, [edx+TEB_FIBER_DATA] + + /* Save the non-volatile registers */ + mov [eax+FIBER_CONTEXT_EBX], ebx + mov [eax+FIBER_CONTEXT_ESI], esi + mov [eax+FIBER_CONTEXT_EDI], edi + mov [eax+FIBER_CONTEXT_EBP], ebp + + /* Check if we're to save FPU State */ + cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL + CONTEXT_FLOATING_POINT + jnz NoFpuStateSave + + /* Save the FPU State (Status and Control)*/ + fstsw [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD] + fstcw [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] + + /* Check if the CPU supports SIMD MXCSR State Save */ + cmp byte ptr [PROCESSOR_FEATURE_FXSR], 0 + jnz NoFpuStateSave + stmxcsr [eax+FIBER_CONTEXT_DR6] + +NoFpuStateSave: - movl %fs:0x18, %ecx /* Teb = NtCurrentTeb() */ + /* Save stack since we're not touching it anymore */ + mov [eax+FIBER_CONTEXT_ESP], esp + + /* Transfer some data from the TEB */ + mov ecx, [edx+TEB_FLS_DATA] + mov [eax+FIBER_FLS_DATA], ecx + mov ecx, [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER] + mov [eax+FIBER_ACTIVATION_CONTEXT_STACK], ecx + + /* Transfer some data related to the Stack */ + mov ecx, [edx+TEB_EXCEPTION_LIST] + mov [eax+FIBER_EXCEPTION_LIST], ecx + mov ecx, [edx+TEB_STACK_LIMIT] + mov [eax+FIBER_STACK_LIMIT], ecx + mov ecx, [edx+TEB_GUARANTEED_STACK_BYTES] + mov [eax+FIBER_GUARANTEED_STACK_BYTES], ecx + + /* Switch to the new fiber */ + mov ecx, [esp+4] + mov [edx+TEB_FIBER_DATA], ecx + + /* Switch Fiber Data */ + mov esi, [ecx+FIBER_EXCEPTION_LIST] + mov [edx+TEB_EXCEPTION_LIST], esi + mov esi, [ecx+FIBER_STACK_BASE] + mov [edx+TEB_STACK_BASE], esi + mov esi, [ecx+FIBER_STACK_LIMIT] + mov [edx+TEB_STACK_LIMIT], esi + mov esi, [ecx+FIBER_DEALLOCATION_STACK] + mov [edx+TEB_DEALLOCATION_STACK], esi + mov esi, [ecx+FIBER_GUARANTEED_STACK_BYTES] + mov [edx+TEB_GUARANTEED_STACK_BYTES], esi + mov esi, [ecx+FIBER_ACTIVATION_CONTEXT_STACK] + mov [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER], esi + + /* Restore FPU State */ + cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL + CONTEXT_FLOATING_POINT + jnz NoFpuStateRestore + + /* Check if the Status Word Changed */ + mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD] + cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD] + jnz StatusWordChanged + + /* Check if the Control Word Changed */ + mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] + cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] + jz ControlWordEqual + +StatusWordChanged: - /* get the current fiber */ - movl 0x10(%ecx), %eax /* Fiber = Teb->Tib.FiberData */ + /* Load the new one */ + mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], 0xFFFF + fldenv [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] + +ControlWordEqual: - /* store the volatile context of the current fiber */ - movl 0x0(%ecx), %edx - movl %edx, 0x4(%eax) /* Fiber->ExceptionList = Teb->ExceptionList */ - movl 0x4(%ecx), %edx - movl %edx, 0x8(%eax) /* Fiber->StackBase = Teb->StackBase */ - movl 0x8(%ecx), %edx - movl %edx, 0xC(%eax) /* Fiber->StackLimit = Teb->StackLimit */ - movl 0xE0C(%ecx), %edx - movl %edx, 0x10(%eax) /* Fiber->StackBottom = Teb->DeallocationStack */ - movl 0x0(%esp), %edx - movl %edx, 0x18(%eax) /* Fiber->Eip = [esp + 0] */ - movl %esp, %edx - addl $0x8, %edx - movl %edx, 0x1C(%eax) /* Fiber->Esp = esp + 8 */ - movl %ebp, 0x20(%eax) /* Fiber->Ebp = ebp */ - movl %ebx, 0x24(%eax) /* Fiber->Ebx = ebx */ - movl %esi, 0x28(%eax) /* Fiber->Esi = edi */ - movl %edi, 0x2C(%eax) /* Fiber->Edi = esi */ + /* Load the new one */ + cmp byte ptr [PROCESSOR_FEATURE_FXSR], 0 + jnz NoFpuStateRestore + ldmxcsr [ecx+FIBER_CONTEXT_DR6] + +NoFpuStateRestore: - testl $1, 0x14(%eax) - jz l_NoFloatSave - - /* save the floating point context */ - /* TODO */ - pushl ErrStr - call _DbgPrint - popl %ecx - -l_NoFloatSave: + /* Restore non-volatile registers */ + mov esi, [ecx+FIBER_CONTEXT_ESI] + mov edi, [ecx+FIBER_CONTEXT_EDI] + mov ebx, [ecx+FIBER_CONTEXT_EBX] + mov ebp, [ecx+FIBER_CONTEXT_EBP] + mov esp, [ecx+FIBER_CONTEXT_ESP] + + /* Restore FLS Data */ + mov eax, [ecx+FIBER_FLS_DATA] + mov [edx+TEB_FLS_DATA], eax - /* switch to the specified fiber */ - movl 0x4(%esp), %eax /* Fiber = lpFiber */ - movl %eax, 0x10(%ecx) /* Teb->Tib.FiberData = Fiber */ - - /* restore the volatile context of the specified fiber */ - movl 0x4(%eax), %edx - movl %edx, 0x0(%ecx) /* Teb->ExceptionList = Fiber->ExceptionList */ - movl 0x8(%eax), %edx - movl %edx, 0x4(%ecx) /* Teb->StackBase = Fiber->StackBase */ - movl 0xC(%eax), %edx - movl %edx, 0x8(%ecx) /* Teb->StackLimit = Fiber->StackLimit */ - movl 0x10(%eax), %edx - movl %edx, 0xE0C(%ecx) /* Teb->StackBottom = Fiber->DeallocationStack */ - movl 0x18(%eax), %edx /* edx = Fiber->Eip */ - movl 0x1C(%eax), %esp /* esp = Fiber->Esp */ - movl 0x20(%eax), %ebp /* ebp = Fiber->Ebp */ - movl 0x24(%eax), %ebx /* ebx = Fiber->Ebx */ - movl 0x28(%eax), %esi /* esi = Fiber->Esi */ - movl 0x2C(%eax), %edi /* edi = Fiber->Edi */ - - testb $1, 0x14(%eax) - jz l_NoFloatRestore - - /* restore the floating point context */ - /* TODO */ - pushl ErrStr - call _DbgPrint - popl %ecx - -l_NoFloatRestore: - - /* jump to the saved program counter */ - jmp *%edx - + /* Return */ + ret 4 + /* EOF */ _____ Modified: trunk/reactos/lib/kernel32/thread/thread.c --- trunk/reactos/lib/kernel32/thread/thread.c 2005-07-19 20:56:38 UTC (rev 16649) +++ trunk/reactos/lib/kernel32/thread/thread.c 2005-07-19 21:04:19 UTC (rev 16650) @@ -44,26 +44,28 @@ return ExceptionDisposition; } -__declspec(noreturn) void STDCALL -ThreadStartup -( - LPTHREAD_START_ROUTINE lpStartAddress, - LPVOID lpParameter -) +__declspec(noreturn) +VOID +STDCALL +BaseThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress, + LPVOID lpParameter) { - volatile UINT uExitCode = 0; + volatile UINT uExitCode = 0; - _SEH_TRY - { - uExitCode = (lpStartAddress)((PVOID)lpParameter); - } - _SEH_EXCEPT(BaseThreadExceptionFilter) - { - uExitCode = _SEH_GetExceptionCode(); - } - _SEH_END; + /* Attempt to call the Thread Start Address */ + _SEH_TRY + { + /* Get the exit code from the Thread Start */ + uExitCode = (lpStartAddress)((PVOID)lpParameter); + } + _SEH_EXCEPT(BaseThreadExceptionFilter) + { + /* Get the Exit code from the SEH Handler */ + uExitCode = _SEH_GetExceptionCode(); + } _SEH_END; - ExitThread(uExitCode); + /* Exit the Thread */ + ExitThread(uExitCode); } @@ -209,7 +211,7 @@ 0, nStackReserve, nStackCommit, - ThreadStartup, + BaseThreadStartup, &hThread, &cidClientId, 2, @@ -226,7 +228,7 @@ 0, &nStackReserve, &nStackCommit, - (PTHREAD_START_ROUTINE)ThreadStartup, + (PTHREAD_START_ROUTINE)BaseThreadStartup, &hThread, &cidClientId, 2,
19 years, 6 months
1
0
0
0
[ion] 16649: - Update ASM header file with more offsets.
by ion@svn.reactos.com
- Update ASM header file with more offsets. Modified: trunk/reactos/ntoskrnl/include/internal/asm.h _____ Modified: trunk/reactos/ntoskrnl/include/internal/asm.h --- trunk/reactos/ntoskrnl/include/internal/asm.h 2005-07-19 20:55:13 UTC (rev 16648) +++ trunk/reactos/ntoskrnl/include/internal/asm.h 2005-07-19 20:56:38 UTC (rev 16649) @@ -1,122 +1,182 @@ -/* - * Definitions for the offsets of members in the KV86M_REGISTERS - */ -#define KV86M_REGISTERS_EBP (0x0) -#define KV86M_REGISTERS_EDI (0x4) -#define KV86M_REGISTERS_ESI (0x8) -#define KV86M_REGISTERS_EDX (0xC) -#define KV86M_REGISTERS_ECX (0x10) -#define KV86M_REGISTERS_EBX (0x14) -#define KV86M_REGISTERS_EAX (0x18) -#define KV86M_REGISTERS_DS (0x1C) -#define KV86M_REGISTERS_ES (0x20) -#define KV86M_REGISTERS_FS (0x24) -#define KV86M_REGISTERS_GS (0x28) -#define KV86M_REGISTERS_EIP (0x2C) -#define KV86M_REGISTERS_CS (0x30) -#define KV86M_REGISTERS_EFLAGS (0x34) -#define KV86M_REGISTERS_ESP (0x38) -#define KV86M_REGISTERS_SS (0x3C) - -#define TF_SAVED_EXCEPTION_STACK (0x8C) -#define TF_REGS (0x90) -#define TF_ORIG_EBP (0x94) - - -/* TSS Offsets */ -#define KTSS_ESP0 (0x4) -#define KTSS_CR3 (0x1C) -#define KTSS_EFLAGS (0x24) -#define KTSS_IOMAPBASE (0x66) - -/* - * Defines for accessing KPCR and KTHREAD structure members - */ -#define KTHREAD_INITIAL_STACK 0x18 -#define KTHREAD_STACK_LIMIT 0x1C -#define KTHREAD_TEB 0x20 -#define KTHREAD_KERNEL_STACK 0x28 -#define KTHREAD_NPX_STATE 0x31 -#define KTHREAD_STATE 0x2D -#define KTHREAD_APCSTATE_PROCESS 0x34 + 0x10 -#define KTHREAD_PENDING_USER_APC 0x34 + 0x16 -#define KTHREAD_PENDING_KERNEL_APC 0x34 + 0x15 -#define KTHREAD_CONTEXT_SWITCHES 0x4C -#define KTHREAD_WAIT_IRQL 0x54 -#define KTHREAD_SERVICE_TABLE 0xDC -#define KTHREAD_PREVIOUS_MODE 0x137 -#define KTHREAD_TRAP_FRAME 0x128 -#define KTHREAD_CALLBACK_STACK 0x120 - -#define KPROCESS_DIRECTORY_TABLE_BASE 0x18 -#define KPROCESS_LDT_DESCRIPTOR0 0x20 -#define KPROCESS_LDT_DESCRIPTOR1 0x24 -#define KPROCESS_IOPM_OFFSET 0x30 - -#define KPCR_EXCEPTION_LIST 0x0 -#define KPCR_INITIAL_STACK 0x4 -#define KPCR_STACK_LIMIT 0x8 -#define KPCR_SELF 0x1C -#define KPCR_GDT 0x3C -#define KPCR_TSS 0x40 -#define KPCR_CURRENT_THREAD 0x124 -#define KPCR_NPX_THREAD 0x2F4 - -/* FPU Save Area Offsets */ -#define FN_CONTROL_WORD 0x0 -#define FN_STATUS_WORD 0x4 -#define FN_TAG_WORD 0x8 -#define FN_DATA_SELECTOR 0x18 -#define FN_CR0_NPX_STATE 0x20C -#define SIZEOF_FX_SAVE_AREA 528 - -/* Trap Frame Offsets */ -#define KTRAP_FRAME_DEBUGEBP (0x0) -#define KTRAP_FRAME_DEBUGEIP (0x4) -#define KTRAP_FRAME_DEBUGARGMARK (0x8) -#define KTRAP_FRAME_DEBUGPOINTER (0xC) -#define KTRAP_FRAME_TEMPSS (0x10) -#define KTRAP_FRAME_TEMPESP (0x14) -#define KTRAP_FRAME_DR0 (0x18) -#define KTRAP_FRAME_DR1 (0x1C) -#define KTRAP_FRAME_DR2 (0x20) -#define KTRAP_FRAME_DR3 (0x24) -#define KTRAP_FRAME_DR6 (0x28) -#define KTRAP_FRAME_DR7 (0x2C) -#define KTRAP_FRAME_GS (0x30) -#define KTRAP_FRAME_RESERVED1 (0x32) -#define KTRAP_FRAME_ES (0x34) -#define KTRAP_FRAME_RESERVED2 (0x36) -#define KTRAP_FRAME_DS (0x38) -#define KTRAP_FRAME_RESERVED3 (0x3A) -#define KTRAP_FRAME_EDX (0x3C) -#define KTRAP_FRAME_ECX (0x40) -#define KTRAP_FRAME_EAX (0x44) -#define KTRAP_FRAME_PREVIOUS_MODE (0x48) -#define KTRAP_FRAME_EXCEPTION_LIST (0x4C) -#define KTRAP_FRAME_FS (0x50) -#define KTRAP_FRAME_RESERVED4 (0x52) -#define KTRAP_FRAME_EDI (0x54) -#define KTRAP_FRAME_ESI (0x58) -#define KTRAP_FRAME_EBX (0x5C) -#define KTRAP_FRAME_EBP (0x60) -#define KTRAP_FRAME_ERROR_CODE (0x64) -#define KTRAP_FRAME_EIP (0x68) -#define KTRAP_FRAME_CS (0x6C) -#define KTRAP_FRAME_EFLAGS (0x70) -#define KTRAP_FRAME_ESP (0x74) -#define KTRAP_FRAME_SS (0x78) -#define KTRAP_FRAME_RESERVED5 (0x7A) -#define KTRAP_FRAME_V86_ES (0x7C) -#define KTRAP_FRAME_RESERVED6 (0x7E) -#define KTRAP_FRAME_V86_DS (0x80) -#define KTRAP_FRAME_RESERVED7 (0x82) -#define KTRAP_FRAME_V86_FS (0x84) -#define KTRAP_FRAME_RESERVED8 (0x86) -#define KTRAP_FRAME_V86_GS (0x88) -#define KTRAP_FRAME_RESERVED9 (0x8A) -#define KTRAP_FRAME_SIZE (0x8C) - -/* User Shared Data */ -#define KUSER_SHARED_SYSCALL 0x7FFE0300 -#define KUSER_SHARED_SYSCALL_RET 0x7FFE0304 +/* + * FIXME: Will be moved to main include directory soon + */ + +/* + * Definitions for the offsets of members in the KV86M_REGISTERS + */ +#define KV86M_REGISTERS_EBP (0x0) +#define KV86M_REGISTERS_EDI (0x4) +#define KV86M_REGISTERS_ESI (0x8) +#define KV86M_REGISTERS_EDX (0xC) +#define KV86M_REGISTERS_ECX (0x10) +#define KV86M_REGISTERS_EBX (0x14) +#define KV86M_REGISTERS_EAX (0x18) +#define KV86M_REGISTERS_DS (0x1C) +#define KV86M_REGISTERS_ES (0x20) +#define KV86M_REGISTERS_FS (0x24) +#define KV86M_REGISTERS_GS (0x28) +#define KV86M_REGISTERS_EIP (0x2C) +#define KV86M_REGISTERS_CS (0x30) +#define KV86M_REGISTERS_EFLAGS (0x34) +#define KV86M_REGISTERS_ESP (0x38) +#define KV86M_REGISTERS_SS (0x3C) + +#define TF_SAVED_EXCEPTION_STACK (0x8C) +#define TF_REGS (0x90) +#define TF_ORIG_EBP (0x94) + + +/* TSS Offsets */ +#define KTSS_ESP0 (0x4) +#define KTSS_CR3 (0x1C) +#define KTSS_EFLAGS (0x24) +#define KTSS_IOMAPBASE (0x66) + +/* + * Defines for accessing KPCR and KTHREAD structure members + */ +#define KTHREAD_INITIAL_STACK 0x18 +#define KTHREAD_STACK_LIMIT 0x1C +#define KTHREAD_TEB 0x20 +#define KTHREAD_KERNEL_STACK 0x28 +#define KTHREAD_NPX_STATE 0x31 +#define KTHREAD_STATE 0x2D +#define KTHREAD_APCSTATE_PROCESS 0x34 + 0x10 +#define KTHREAD_PENDING_USER_APC 0x34 + 0x16 +#define KTHREAD_PENDING_KERNEL_APC 0x34 + 0x15 +#define KTHREAD_CONTEXT_SWITCHES 0x4C +#define KTHREAD_WAIT_IRQL 0x54 +#define KTHREAD_SERVICE_TABLE 0xDC +#define KTHREAD_PREVIOUS_MODE 0x137 +#define KTHREAD_TRAP_FRAME 0x128 +#define KTHREAD_CALLBACK_STACK 0x120 + +#define KPROCESS_DIRECTORY_TABLE_BASE 0x18 +#define KPROCESS_LDT_DESCRIPTOR0 0x20 +#define KPROCESS_LDT_DESCRIPTOR1 0x24 +#define KPROCESS_IOPM_OFFSET 0x30 + +#define KPCR_EXCEPTION_LIST 0x0 +#define KPCR_INITIAL_STACK 0x4 +#define KPCR_STACK_LIMIT 0x8 +#define KPCR_SELF 0x1C +#define KPCR_GDT 0x3C +#define KPCR_TSS 0x40 +#define KPCR_CURRENT_THREAD 0x124 +#define KPCR_NPX_THREAD 0x2F4 + +/* FPU Save Area Offsets */ +#define FN_CONTROL_WORD 0x0 +#define FN_STATUS_WORD 0x4 +#define FN_TAG_WORD 0x8 +#define FN_DATA_SELECTOR 0x18 +#define FN_CR0_NPX_STATE 0x20C +#define SIZEOF_FX_SAVE_AREA 528 + +/* Trap Frame Offsets */ +#define KTRAP_FRAME_DEBUGEBP (0x0) +#define KTRAP_FRAME_DEBUGEIP (0x4) +#define KTRAP_FRAME_DEBUGARGMARK (0x8) +#define KTRAP_FRAME_DEBUGPOINTER (0xC) +#define KTRAP_FRAME_TEMPSS (0x10) +#define KTRAP_FRAME_TEMPESP (0x14) +#define KTRAP_FRAME_DR0 (0x18) +#define KTRAP_FRAME_DR1 (0x1C) +#define KTRAP_FRAME_DR2 (0x20) +#define KTRAP_FRAME_DR3 (0x24) +#define KTRAP_FRAME_DR6 (0x28) +#define KTRAP_FRAME_DR7 (0x2C) +#define KTRAP_FRAME_GS (0x30) +#define KTRAP_FRAME_RESERVED1 (0x32) +#define KTRAP_FRAME_ES (0x34) +#define KTRAP_FRAME_RESERVED2 (0x36) +#define KTRAP_FRAME_DS (0x38) +#define KTRAP_FRAME_RESERVED3 (0x3A) +#define KTRAP_FRAME_EDX (0x3C) +#define KTRAP_FRAME_ECX (0x40) +#define KTRAP_FRAME_EAX (0x44) +#define KTRAP_FRAME_PREVIOUS_MODE (0x48) +#define KTRAP_FRAME_EXCEPTION_LIST (0x4C) +#define KTRAP_FRAME_FS (0x50) +#define KTRAP_FRAME_RESERVED4 (0x52) +#define KTRAP_FRAME_EDI (0x54) +#define KTRAP_FRAME_ESI (0x58) +#define KTRAP_FRAME_EBX (0x5C) +#define KTRAP_FRAME_EBP (0x60) +#define KTRAP_FRAME_ERROR_CODE (0x64) +#define KTRAP_FRAME_EIP (0x68) +#define KTRAP_FRAME_CS (0x6C) +#define KTRAP_FRAME_EFLAGS (0x70) +#define KTRAP_FRAME_ESP (0x74) +#define KTRAP_FRAME_SS (0x78) +#define KTRAP_FRAME_RESERVED5 (0x7A) +#define KTRAP_FRAME_V86_ES (0x7C) +#define KTRAP_FRAME_RESERVED6 (0x7E) +#define KTRAP_FRAME_V86_DS (0x80) +#define KTRAP_FRAME_RESERVED7 (0x82) +#define KTRAP_FRAME_V86_FS (0x84) +#define KTRAP_FRAME_RESERVED8 (0x86) +#define KTRAP_FRAME_V86_GS (0x88) +#define KTRAP_FRAME_RESERVED9 (0x8A) +#define KTRAP_FRAME_SIZE (0x8C) + +/* User Shared Data */ +#define KUSER_SHARED_DATA 0x7FFE0000 +#define KUSER_SHARED_PROCESSOR_FEATURES KUSER_SHARED_DATA + 0x274 +#define KUSER_SHARED_SYSCALL KUSER_SHARED_DATA + 0x300 +#define KUSER_SHARED_SYSCALL_RET KUSER_SHARED_DATA + 0x304 +#define PROCESSOR_FEATURE_FXSR KUSER_SHARED_PROCESSOR_FEATURES + 0x4 + +/* CONTEXT CONSTANTS */ +#define CONTEXT_FULL 0x10007 +#define CONTEXT_FLOATING_POINT 0xF +#define CONTEXT_FLAGS 0x0 +#define CONTEXT_DR6 0x14 +#define CONTEXT_FLOAT_SAVE 0x1C +#define CONTEXT_EDI 0x9C +#define CONTEXT_ESI 0xA0 +#define CONTEXT_EBX 0xA4 +#define CONTEXT_EDX 0xA8 +#define CONTEXT_ECX 0xAC +#define CONTEXT_EAX 0xB0 +#define CONTEXT_EBP 0xB4 +#define CONTEXT_EIP 0xB8 +#define CONTEXT_ESP 0xC4 +#define CONTEXT_FLOAT_SAVE_CONTROL_WORD CONTEXT_FLOAT_SAVE + FN_CONTROL_WORD +#define CONTEXT_FLOAT_SAVE_STATUS_WORD CONTEXT_FLOAT_SAVE + FN_STATUS_WORD +#define CONTEXT_FLOAT_SAVE_TAG_WORD CONTEXT_FLOAT_SAVE + FN_TAG_WORD + +/* TEB CONSTANTS */ +#define TEB_EXCEPTION_LIST 0x0 +#define TEB_STACK_BASE 0x4 +#define TEB_STACK_LIMIT 0x8 +#define TEB_FIBER_DATA 0x10 +#define TEB_ACTIVATION_CONTEXT_STACK_POINTER 0x1A8 +#define TEB_DEALLOCATION_STACK 0xE0C +#define TEB_GUARANTEED_STACK_BYTES 0xF78 +#define TEB_FLS_DATA 0xFB4 + +/* FIBER CONSTANTS */ +#define FIBER_PARAMETER 0x0 +#define FIBER_EXCEPTION_LIST 0x4 +#define FIBER_STACK_BASE 0x8 +#define FIBER_STACK_LIMIT 0xC +#define FIBER_DEALLOCATION_STACK 0x10 +#define FIBER_CONTEXT 0x14 +#define FIBER_GUARANTEED_STACK_BYTES 0x2E0 +#define FIBER_FLS_DATA 0x2E4 +#define FIBER_ACTIVATION_CONTEXT_STACK 0x2E8 +#define FIBER_CONTEXT_FLAGS FIBER_CONTEXT + CONTEXT_FLAGS +#define FIBER_CONTEXT_EAX FIBER_CONTEXT + CONTEXT_EAX +#define FIBER_CONTEXT_EBX FIBER_CONTEXT + CONTEXT_EBX +#define FIBER_CONTEXT_ECX FIBER_CONTEXT + CONTEXT_ECX +#define FIBER_CONTEXT_EDX FIBER_CONTEXT + CONTEXT_EDX +#define FIBER_CONTEXT_ESI FIBER_CONTEXT + CONTEXT_ESI +#define FIBER_CONTEXT_EDI FIBER_CONTEXT + CONTEXT_EDI +#define FIBER_CONTEXT_EBP FIBER_CONTEXT + CONTEXT_EBP +#define FIBER_CONTEXT_ESP FIBER_CONTEXT + CONTEXT_ESP +#define FIBER_CONTEXT_DR6 FIBER_CONTEXT + CONTEXT_DR6 +#define FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_STATUS_WORD +#define FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_CONTROL_WORD +#define FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_TAG_WORD
19 years, 6 months
1
0
0
0
[ion] 16648: - Fix LDR_DATA_TABLE_ENTRY definition.
by ion@svn.reactos.com
- Fix LDR_DATA_TABLE_ENTRY definition. Modified: trunk/reactos/include/ndk/ldrtypes.h _____ Modified: trunk/reactos/include/ndk/ldrtypes.h --- trunk/reactos/include/ndk/ldrtypes.h 2005-07-19 18:46:13 UTC (rev 16647) +++ trunk/reactos/include/ndk/ldrtypes.h 2005-07-19 20:55:13 UTC (rev 16648) @@ -61,11 +61,17 @@ ULONG Flags; USHORT LoadCount; USHORT TlsIndex; - LIST_ENTRY HashLinks; - PVOID SectionPointer; + union + { + LIST_ENTRY HashLinks; + PVOID SectionPointer; + }; ULONG CheckSum; - ULONG TimeDateStamp; - PVOID LoadedImports; + union + { + ULONG TimeDateStamp; + PVOID LoadedImports; + }; PVOID EntryPointActivationContext; PVOID PatchInformation; #if defined(DBG) || defined(KDBG)
19 years, 6 months
1
0
0
0
[chorns] 16647: Generate RPC interface headers in intermediate directory
by chorns@svn.reactos.com
Generate RPC interface headers in intermediate directory Modified: trunk/reactos/lib/advapi32/advapi32.xml Modified: trunk/reactos/subsys/system/services/services.xml Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h Modified: trunk/reactos/tools/rbuild/include.cpp Modified: trunk/reactos/tools/rbuild/rbuild.h _____ Modified: trunk/reactos/lib/advapi32/advapi32.xml --- trunk/reactos/lib/advapi32/advapi32.xml 2005-07-19 18:15:32 UTC (rev 16646) +++ trunk/reactos/lib/advapi32/advapi32.xml 2005-07-19 18:46:13 UTC (rev 16647) @@ -1,7 +1,7 @@ <module name="advapi32" type="win32dll" baseaddress="${BASEADDRESS_ADVAPI32}" installbase="system32" installname="advapi32.dll"> <importlibrary definition="advapi32.def" /> <include base="advapi32">.</include> - <include base="ReactOS">include/idl</include> + <include base="scm_client">.</include> <define name="__USE_W32API" /> <define name="WINVER">0x600</define> <define name="_WIN32_IE">0x0500</define> _____ Modified: trunk/reactos/subsys/system/services/services.xml --- trunk/reactos/subsys/system/services/services.xml 2005-07-19 18:15:32 UTC (rev 16646) +++ trunk/reactos/subsys/system/services/services.xml 2005-07-19 18:46:13 UTC (rev 16647) @@ -1,6 +1,6 @@ <module name="services" type="win32cui" installbase="system32" installname="services.exe"> <include base="services">.</include> - <include base="ReactOS">include/idl</include> + <include base="scm_server">.</include> <define name="__USE_W32API" /> <define name="UNICODE" /> <define name="_UNICODE" /> _____ Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp --- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-07-19 18:15:32 UTC (rev 16646) +++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-07-19 18:46:13 UTC (rev 16647) @@ -288,6 +288,20 @@ } string +MingwModuleHandler::GetExtraDependencies ( + const string& filename ) const +{ + string extension = GetExtension ( filename ); + if ( extension == ".idl" || extension == ".IDL" ) + { + string basename = GetBasename ( filename ); + return GetRpcServerHeaderFilename ( basename ) + " " + GetRpcClientHeaderFilename ( basename ); + } + else + return ""; +} + +string MingwModuleHandler::GetModuleArchiveFilename () const { if ( module.type == StaticLibrary ) @@ -701,10 +715,19 @@ for ( i = 0; i < data.includes.size(); i++ ) { + const Include& include = *data.includes[i]; + string includeDirectory; + if ( include.baseModule != NULL && + ( include.baseModule->type == RpcServer || + include.baseModule->type == RpcClient ) ) + includeDirectory = PassThruCacheDirectory ( NormalizeFilename ( include.directory ), + backend->intermediateDirectory ); + else + includeDirectory = include.directory; fprintf ( fMakefile, " -I%s", - data.includes[i]->directory.c_str() ); + includeDirectory.c_str() ); } for ( i = 0; i < data.defines.size(); i++ ) { @@ -905,10 +928,13 @@ void MingwModuleHandler::GenerateGccCommand ( const string& sourceFilename, + const string& extraDependencies, const string& cc, const string& cflagsMacro ) { string dependencies = sourceFilename; + if ( extraDependencies != "" ) + dependencies += " " + extraDependencies; if ( module.pch && use_pch ) dependencies += " " + GetPrecompiledHeaderFilename (); @@ -1079,7 +1105,8 @@ string MingwModuleHandler::GetRpcServerHeaderFilename ( string basename ) const { - return basename + "_s.h"; + return PassThruCacheDirectory ( basename + "_s.h", + backend->intermediateDirectory ); } void @@ -1092,11 +1119,6 @@ string basename = GetBasename ( file.name ); - /*string generatedHeaderFilename = PassThruCacheDirectory ( - basename + ".h", - backend->intermediateDirectory ); - CLEAN_FILE(generatedHeaderFilename); - */ string generatedHeaderFilename = GetRpcServerHeaderFilename ( basename ); CLEAN_FILE(generatedHeaderFilename); @@ -1125,7 +1147,8 @@ string MingwModuleHandler::GetRpcClientHeaderFilename ( string basename ) const { - return basename + "_c.h"; + return PassThruCacheDirectory ( basename + "_c.h", + backend->intermediateDirectory ); } void @@ -1138,11 +1161,6 @@ string basename = GetBasename ( file.name ); - /*string generatedHeaderFilename = PassThruCacheDirectory ( - basename + ".h", - backend->intermediateDirectory ); - CLEAN_FILE(generatedHeaderFilename); - */ string generatedHeaderFilename = GetRpcClientHeaderFilename ( basename ); CLEAN_FILE(generatedHeaderFilename); @@ -1195,6 +1213,7 @@ if ( extension == ".c" || extension == ".C" ) { GenerateGccCommand ( file.name, + "", cc, cflagsMacro ); return; @@ -1204,6 +1223,7 @@ extension == ".cxx" || extension == ".CXX" ) { GenerateGccCommand ( file.name, + "", cppc, cflagsMacro ); return; @@ -1231,6 +1251,7 @@ { GenerateWinebuildCommands ( file.name ); GenerateGccCommand ( GetActualSourceFilename ( file.name ), + "", cc, cflagsMacro ); return; @@ -1240,6 +1261,7 @@ GenerateWidlCommands ( file, widlflagsMacro ); GenerateGccCommand ( GetActualSourceFilename ( file.name ), + GetExtraDependencies ( file.name ), cc, cflagsMacro ); return; @@ -1647,7 +1669,6 @@ if ( library.importedModule->type == RpcServer || library.importedModule->type == RpcClient ) { - for ( size_t j = 0; j < library.importedModule->non_if_data.files.size (); j++ ) { File& file = *library.importedModule->non_if_data.files[j]; @@ -2026,10 +2047,11 @@ const string& filename ) const { string basename = GetBasename ( filename ); - string serverDependency = PassThruCacheDirectory ( + string serverSourceDependency = PassThruCacheDirectory ( NormalizeFilename ( basename + "_s.c" ), backend->intermediateDirectory ); - dependencies.push_back ( serverDependency ); + dependencies.push_back ( serverSourceDependency ); + dependencies.push_back ( GetRpcServerHeaderFilename ( basename ) ); } void _____ Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h --- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h 2005-07-19 18:15:32 UTC (rev 16646) +++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h 2005-07-19 18:46:13 UTC (rev 16647) @@ -85,6 +85,7 @@ std::string GetWorkingDirectory () const; std::string GetBasename ( const std::string& filename ) const; std::string GetActualSourceFilename ( const std::string& filename ) const; + std::string GetExtraDependencies ( const std::string& filename ) const; std::string GetModuleArchiveFilename () const; bool IsGeneratedFile ( const File& file ) const; std::string GetImportLibraryDependency ( const Module& importedModule ); @@ -143,6 +144,7 @@ std::string GenerateNasmParameters () const; std::string MingwModuleHandler::GetPrecompiledHeaderFilename () const; void GenerateGccCommand ( const std::string& sourceFilename, + const std::string& extraDependencies, const std::string& cc, const std::string& cflagsMacro ); void GenerateGccAssemblerCommand ( const std::string& sourceFilename, _____ Modified: trunk/reactos/tools/rbuild/include.cpp --- trunk/reactos/tools/rbuild/include.cpp 2005-07-19 18:15:32 UTC (rev 16646) +++ trunk/reactos/tools/rbuild/include.cpp 2005-07-19 18:46:13 UTC (rev 16647) @@ -27,7 +27,8 @@ const XMLElement* includeNode ) : project ( project ), module ( NULL ), - node ( includeNode ) + node ( includeNode ), + baseModule ( NULL ) { } @@ -36,7 +37,8 @@ const XMLElement* includeNode ) : project ( project ), module ( module ), - node ( includeNode ) + node ( includeNode ), + baseModule ( NULL ) { } @@ -45,7 +47,8 @@ string basePath ) : project ( project ), module ( NULL ), - node ( NULL ) + node ( NULL ), + baseModule ( NULL ) { this->directory = NormalizeFilename ( basePath + SSEP + directory ); this->basePath = NormalizeFilename ( basePath ); @@ -78,6 +81,7 @@ const Module* base = project.LocateModule ( att->value ); if ( base != NULL ) { + baseModule = base; basePath = base->GetBasePath (); referenceResolved = true; } _____ Modified: trunk/reactos/tools/rbuild/rbuild.h --- trunk/reactos/tools/rbuild/rbuild.h 2005-07-19 18:15:32 UTC (rev 16646) +++ trunk/reactos/tools/rbuild/rbuild.h 2005-07-19 18:46:13 UTC (rev 16647) @@ -271,6 +271,7 @@ const Project& project; const Module* module; const XMLElement* node; + const Module* baseModule; std::string directory; std::string basePath;
19 years, 6 months
1
0
0
0
[greatlrd] 16646: Fix all bugs in cmd commands cd, make it rember the last directory for each drive. make c: working, make cd f f working. We can not found any more bugs cd rewriting was done by BrandonTurner and me, Brandon rewrite cmd_chdir and I add two functions that we will use for cd and other commands to get and set current drive path. The /D are also implement in CD
by greatlrd@svn.reactos.com
Fix all bugs in cmd commands cd, make it rember the last directory for each drive. make c: working, make cd f f working. We can not found any more bugs cd rewriting was done by BrandonTurner and me, Brandon rewrite cmd_chdir and I add two functions that we will use for cd and other commands to get and set current drive path. The /D are also implement in CD Modified: trunk/reactos/subsys/system/cmd/En.rc Modified: trunk/reactos/subsys/system/cmd/cmd.h Modified: trunk/reactos/subsys/system/cmd/internal.c _____ Modified: trunk/reactos/subsys/system/cmd/En.rc --- trunk/reactos/subsys/system/cmd/En.rc 2005-07-19 15:57:30 UTC (rev 16645) +++ trunk/reactos/subsys/system/cmd/En.rc 2005-07-19 18:15:32 UTC (rev 16646) @@ -41,12 +41,13 @@ batch program." STRING_CD_HELP, "Changes the current directory or displays it's name\n\n\ -CHDIR [drive:][path]\n\ +CHDIR [/D][drive:][path]\n\ CHDIR[..|.]\n\ -CD [drive:][path]\n\ +CD [/D][drive:][path]\n\ CD[..|.]\n\n\ .. parent directory\n\ - . previous directory\n\n\ + . previous directory\n\ + /D Will change current drive and current directory.\n\n\ Type CD drive: to display the current directory on the specified drive.\n\ Type CD without a parameter to display the current drive and directory.\n" _____ Modified: trunk/reactos/subsys/system/cmd/cmd.h --- trunk/reactos/subsys/system/cmd/cmd.h 2005-07-19 15:57:30 UTC (rev 16645) +++ trunk/reactos/subsys/system/cmd/cmd.h 2005-07-19 18:15:32 UTC (rev 16646) @@ -292,6 +292,7 @@ /* Prototypes for MISC.C */ INT GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size); +BOOL SetRootPath(TCHAR *InPath); TCHAR cgetchar (VOID); BOOL CheckCtrlBreak (INT); LPTSTR *split (LPTSTR, LPINT, BOOL); _____ Modified: trunk/reactos/subsys/system/cmd/internal.c --- trunk/reactos/subsys/system/cmd/internal.c 2005-07-19 15:57:30 UTC (rev 16645) +++ trunk/reactos/subsys/system/cmd/internal.c 2005-07-19 18:15:32 UTC (rev 16646) @@ -126,6 +126,12 @@ * 02-Apr-2004 (Magnus Olsen <magnus(a)greatlord.com>) * Remove all hard code string so they can be * translate to other langues. + * + * 19-jul-2005 (Brandon Turner <turnerb7(a)msu.edu) + * Rewrite the CD, it working as Windows 2000 CMD + * + * 19-jul-2005 (Magnus Olsen <magnus(a)greatlord.com) + * Add SetRootPath and GetRootPath */ #include <precomp.h> @@ -160,8 +166,7 @@ { INT retcode = 1; - - if (_tcslen(InPath)>1) + if (_tcslen(InPath)>1) { if (InPath[1]==_T(':')) { @@ -183,7 +188,7 @@ } if (_tgetdcwd(t,OutPath,size) != NULL) - { + { return 0; } } @@ -205,195 +210,193 @@ } +BOOL SetRootPath(TCHAR *InPath) +{ + TCHAR oldpath[MAX_PATH]; + TCHAR OutPath[MAX_PATH]; + BOOL fail; + + /* Get The current directory path and save it */ + fail = GetCurrentDirectory(MAX_PATH,oldpath); + if (!fail) + return 1; + + /* Get current drive directory path if C: was only pass down*/ + + if (_tcsncicmp(&InPath[1],_T(":\\"),2)!=0) + { + if (!GetRootPath(InPath,OutPath,MAX_PATH)) + _tcscpy(OutPath,InPath); + } + else + { + _tcscpy(OutPath,InPath); + } + + fail = SetCurrentDirectory(OutPath); + if (!fail) + return 1; + + SetCurrentDirectory(OutPath); + GetCurrentDirectory(MAX_PATH,OutPath); + _tchdir(OutPath); + + if (_tcsncicmp(OutPath,oldpath,2)!=0) + SetCurrentDirectory(oldpath); + + return 0; +} + + /* * CD / CHDIR * */ INT cmd_chdir (LPTSTR cmd, LPTSTR param) { - LPTSTR dir; /* pointer to the directory to change to */ - LPTSTR lpOldPath; - size_t size, str_len; - WIN32_FIND_DATA FileData; - HANDLE hSearch; - DWORD dwAttrs; - BOOL fFinished = FALSE; - - /*Should we better declare a variable containing _tsclen(dir) ? It's used a few times, - but on the other hand paths are generally not very long*/ - - if (!_tcsncmp (param, _T("/?"), 2)) + WIN32_FIND_DATA f; + HANDLE hFile; + BOOL bChangeDrive = FALSE; + TCHAR szPath[MAX_PATH]; + TCHAR szFinalPath[MAX_PATH]; + TCHAR * tmpPath; + TCHAR szCurrent[MAX_PATH]; + TCHAR szMsg[RC_STRING_MAX_SIZE]; + INT i; + + + /* Filter out special cases first */ + + /* Print Help */ + if (!_tcsncmp(param, _T("/?"), 2)) { ConOutResPaging(TRUE,STRING_CD_HELP); return 0; } + + /* Set Error Level to Success */ + nErrorLevel = 0; - nErrorLevel = 0; - - - /* The whole param string is our parameter these days. The only thing we do is eliminating every quotation mark */ - /* Is it safe to change the characters param is pointing to? I presume it is, as there doesn't seem to be any - post-processing of it after the function call (what would that accomplish?) */ - - size = _tcscspn(param, _T("\"") ); - str_len = _tcslen(param)-1; - - if ((param[size] == _T('"')) && (str_len >1)) + /* Input String Contains /D Switch */ + if (!_tcsncicmp(param, _T("/D"), 2)) { - - if (size==0) - { - _tcsncpy(param,¶m[size+1],str_len); - param[str_len] = _T('\0'); - } - - size = _tcscspn(param, _T("\"") ); - if (param[size] == _T('"')) - { - param[size] = _T('\0'); - } - + bChangeDrive = TRUE; + tmpPath = _tcsstr(param,_T(" ")); + tmpPath++; + _tcscpy(szPath,tmpPath); + } - - str_len = _tcslen(param); - if (str_len==1) + else { - if (param[0] == _T('*')) - { - param[0] = _T('.'); + _tcscpy(szPath,param); + } + + /* Print Current Directory on a disk */ + if (_tcslen(szPath) == 2 && szPath[1] == _T(':')) + { + if(GetRootPath(szPath,szCurrent,MAX_PATH)) + { + nErrorLevel = 1; + return 1; } + ConOutPuts(szCurrent); + return 0; + } - - dir=param; - - /* if doing a CD and no parameters given, print out current directory */ - if (!dir || !dir[0]) + + /* Get Current Directory */ + GetRootPath(_T("."),szCurrent,MAX_PATH); + + /* Remove " */ + if(szPath[0] == _T('\"')) { - TCHAR szPath[MAX_PATH]; - - GetCurrentDirectory (MAX_PATH, szPath); - ConOutPuts (szPath); - return 0; + tmpPath = _tcsstr(szPath,_T("\"")); + tmpPath++; + _tcscpy(szPath,tmpPath); } - - if (dir && _tcslen (dir) == 1 && *dir == _T('-')) + + if(szPath[_tcslen(szPath) - 1] == _T('\"')) { - if (lpLastPath) - dir = lpLastPath; - else - return 0; + szPath[_tcslen(szPath) - 1] = _T('\0'); } - else if (dir && _tcslen (dir)==2 && dir[1] == _T(':')) + + tmpPath = szPath; + while (_istspace (*tmpPath)) + tmpPath++; + _tcscpy(szPath,tmpPath); + + if (szPath[0] == _T('\0')) { - TCHAR szRoot[3] = _T("A:"); - TCHAR szPath[MAX_PATH]; - - szRoot[0] = _totupper (dir[0]); - GetRootPath (szRoot, szPath,MAX_PATH); - - /* PathRemoveBackslash */ - if (_tcslen (szPath) > 3) + ConOutPuts(szCurrent); + return 0; + } + + + /* change to full path if relative path was given */ + GetFullPathName(szPath,MAX_PATH,szFinalPath,NULL); + + if(szFinalPath[_tcslen(szFinalPath) - 1] == _T('\\') && _tcslen(szFinalPath) > 3) + szFinalPath[_tcslen(szFinalPath) - 1] = _T('\0'); + + /* Handle Root Directory Alone*/ + if (_tcslen(szPath) == 3 && szPath[1] == _T(':')) + { + if(!SetRootPath(szFinalPath)) { - LPTSTR p = _tcsrchr (szPath, _T('\\')); - *p = _T('\0'); + /* Change prompt if it is one the same drive or /D */ + if(bChangeDrive || !_tcsncicmp(szFinalPath,szCurrent,1)) + SetCurrentDirectory(szFinalPath); + return 0; } - - ConOutPuts (szPath); - - - return 0; - } - - /* remove trailing \ if any, but ONLY if dir is not the root dir */ - if (_tcslen (dir) > 3 && dir[_tcslen (dir) - 1] == _T('\\')) - dir[_tcslen(dir) - 1] = _T('\0'); - - - /* store current directory */ - lpOldPath = (LPTSTR)malloc (MAX_PATH * sizeof(TCHAR)); - GetCurrentDirectory (MAX_PATH, lpOldPath); - - chdir(dir); - if (!SetCurrentDirectory (dir)) - { - - hSearch = FindFirstFile(dir, &FileData); - if (hSearch == INVALID_HANDLE_VALUE) - { - ConOutFormatMessage(GetLastError()); - free (lpOldPath); - lpOldPath = NULL; - nErrorLevel = 1; - return 1; - } - - - while (!fFinished) - { - dwAttrs = GetFileAttributes(FileData.cFileName); -#ifdef _DEBUG - DebugPrintf(_T("Search found folder :%s\n"),FileData.cFileName); -#endif - if ((dwAttrs & FILE_ATTRIBUTE_DIRECTORY)) - { - FindClose(hSearch); - // change folder - chdir(dir); - if (!SetCurrentDirectory (FileData.cFileName)) - { - ConOutFormatMessage(GetLastError()); - free (lpOldPath); - lpOldPath = NULL; - nErrorLevel = 1; - return 1; - } - - - return 0; - } - - else if (!FindNextFile(hSearch, &FileData)) - { - FindClose(hSearch); - ConOutFormatMessage(GetLastError()); - nErrorLevel = 1; - free (lpOldPath); - lpOldPath = NULL; - return 1; - } - } - - //ErrorMessage (GetLastError(), _T("CD")); - ConOutFormatMessage(GetLastError()); - nErrorLevel = 1; - - /* throw away current directory */ - free (lpOldPath); - lpOldPath = NULL; - + /* Didnt find an directories */ + LoadString(CMD_ModuleHandle, STRING_ERROR_PATH_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); + nErrorLevel = 1; return 1; + } - else + + /* Get a list of all the files */ + hFile = FindFirstFile (szFinalPath, &f); + + do { - GetCurrentDirectory(MAX_PATH, dir); - if (dir[0]!=lpOldPath[0]) - { - chdir(lpOldPath); - SetCurrentDirectory(lpOldPath); - free(lpOldPath); + if(hFile == INVALID_HANDLE_VALUE) + { + ConOutFormatMessage (GetLastError(), szFinalPath); + nErrorLevel = 1; + return 1; } - else + + /* Strip the paths back to the folder they are in */ + for(i = (_tcslen(szFinalPath) - 1); i > -1; i--) + if(szFinalPath[i] != _T('\\')) + szFinalPath[i] = _T('\0'); + else + break; + + _tcscat(szFinalPath,f.cFileName); + + if(IsExistingDirectory(szFinalPath)) { - if (lpLastPath) - free (lpLastPath); - lpLastPath = lpOldPath; + if(!SetRootPath(szFinalPath)) + { + /* Change for /D */ + if(bChangeDrive) + SetCurrentDirectory(szFinalPath); + return 0; + } } - } + }while(FindNextFile (hFile, &f)); + + /* Didnt find an directories */ + LoadString(CMD_ModuleHandle, STRING_ERROR_PATH_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); + nErrorLevel = 1; + return 1; +} - - return 0; -} #endif
19 years, 6 months
1
0
0
0
[ekohl] 16645: - Implement CM_Get_Depth[_Ex] and CM_Get_DevNode_Status[_Ex].
by ekohl@svn.reactos.com
- Implement CM_Get_Depth[_Ex] and CM_Get_DevNode_Status[_Ex]. - Add dummy code for CM_Get_Child_Ex, CM_Get_Parent_Ex and CM_Get_Sibling_Ex. WIDL doesn't support this yet. Modified: trunk/reactos/include/idl/pnp.idl Modified: trunk/reactos/include/wine/cfgmgr32.h Modified: trunk/reactos/lib/cfgmgr32/cfgmgr32.def Modified: trunk/reactos/lib/setupapi/cfgmgr.c Modified: trunk/reactos/lib/setupapi/setupapi.spec Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c _____ Modified: trunk/reactos/include/idl/pnp.idl --- trunk/reactos/include/idl/pnp.idl 2005-07-19 14:11:53 UTC (rev 16644) +++ trunk/reactos/include/idl/pnp.idl 2005-07-19 15:57:30 UTC (rev 16645) @@ -24,4 +24,29 @@ CONFIGRET PNP_ValidateDeviceInstance(handle_t BindingHandle, [in, string] wchar_t *DeviceInstance, [in] DWORD Flags); + + CONFIGRET PNP_GetRootDeviceInstance(handle_t BindingHandle, + [out, string, size_is(Length)] wchar_t *DeviceInstance, + [in] DWORD Length); + +// cpp_quote("#define PNP_DEVICE_PARENT 1") +// cpp_quote("#define PNP_DEVICE_CHILD 2") +// cpp_quote("#define PNP_DEVICE_SIBLING 3") +// CONFIGRET PNP_GetRelatedDeviceInstance(handle_t BindingHandle, +// [in] DWORD Relationship, +// [in, string] wchar_t *DeviceId, +// [out, string, size_is(Length)] wchar_t *RelatedDeviceId, +// [in] DWORD Length, +// [in] DWORD Flags); + + CONFIGRET PNP_GetDepth(handle_t BindingHandle, + [in, string] wchar_t *DeviceInstance, + [out] unsigned long *Depth, + [in] DWORD Flags); + + CONFIGRET PNP_GetDeviceStatus(handle_t BindingHandle, + [in, string] wchar_t *DeviceInstance, + [out] unsigned long *Status, + [out] unsigned long *Problem, + [in] DWORD Flags); } _____ Modified: trunk/reactos/include/wine/cfgmgr32.h --- trunk/reactos/include/wine/cfgmgr32.h 2005-07-19 14:11:53 UTC (rev 16644) +++ trunk/reactos/include/wine/cfgmgr32.h 2005-07-19 15:57:30 UTC (rev 16645) @@ -81,6 +81,8 @@ CONFIGRET WINAPI CM_Enumerate_Classes_Ex( ULONG, LPGUID, ULONG, HMACHINE ); CONFIGRET WINAPI CM_Get_Child( PDEVINST, DEVINST, ULONG ); CONFIGRET WINAPI CM_Get_Child_Ex( PDEVINST, DEVINST, ULONG, HMACHINE ); +CONFIGRET WINAPI CM_Get_Depth( PULONG, DEVINST, ULONG ); +CONFIGRET WINAPI CM_Get_Depth_Ex( PULONG, DEVINST, ULONG, HMACHINE ); CONFIGRET WINAPI CM_Get_Device_IDA( DEVINST, PCHAR, ULONG, ULONG ); CONFIGRET WINAPI CM_Get_Device_IDW( DEVINST, PWCHAR, ULONG, ULONG ); #define CM_Get_Device_ID WINELIB_NAME_AW(CM_Get_Device_ID) @@ -101,6 +103,8 @@ #define CM_Get_Device_ID_List_Size_Ex WINELIB_NAME_AW(CM_Get_Device_ID_List_Size_Ex) CONFIGRET WINAPI CM_Get_Device_ID_Size( PULONG, DEVINST, ULONG ); CONFIGRET WINAPI CM_Get_Device_ID_Size_Ex( PULONG, DEVINST, ULONG, HMACHINE ); +CONFIGRET WINAPI CM_Get_DevNode_Status( PULONG, PULONG, DEVINST, ULONG ); +CONFIGRET WINAPI CM_Get_DevNode_Status_Ex( PULONG, PULONG, DEVINST, ULONG, HMACHINE ); CONFIGRET WINAPI CM_Get_Global_State( PULONG, ULONG ); CONFIGRET WINAPI CM_Get_Global_State_Ex( PULONG, ULONG, HMACHINE ); CONFIGRET WINAPI CM_Get_Parent( PDEVINST, DEVINST, ULONG ); _____ Modified: trunk/reactos/lib/cfgmgr32/cfgmgr32.def --- trunk/reactos/lib/cfgmgr32/cfgmgr32.def 2005-07-19 14:11:53 UTC (rev 16644) +++ trunk/reactos/lib/cfgmgr32/cfgmgr32.def 2005-07-19 15:57:30 UTC (rev 16645) @@ -79,18 +79,18 @@ ;CM_Get_Class_NameW ;CM_Get_Class_Name_ExA ;CM_Get_Class_Name_ExW -;CM_Get_Depth -;CM_Get_Depth_Ex +CM_Get_Depth(a)12=SETUPAPI.CM_Get_Depth +CM_Get_Depth_Ex(a)16=SETUPAPI.CM_Get_Depth_Ex CM_Get_DevNode_Registry_PropertyA(a)24=SETUPAPI.CM_Get_DevNode_Registry_Pr opertyA CM_Get_DevNode_Registry_PropertyW(a)24=SETUPAPI.CM_Get_DevNode_Registry_Pr opertyW CM_Get_DevNode_Registry_Property_ExA(a)28=SETUPAPI.CM_Get_DevNode_Registry _Property_ExA CM_Get_DevNode_Registry_Property_ExW(a)28=SETUPAPI.CM_Get_DevNode_Registry _Property_ExW -;CM_Get_DevNode_Status -;CM_Get_DevNode_Status_Ex -;CM_Get_Device_IDA -;CM_Get_Device_IDW -;CM_Get_Device_ID_ExA -;CM_Get_Device_ID_ExW +CM_Get_DevNode_Status(a)16=SETUPAPI.CM_Get_DevNode_Status +CM_Get_DevNode_Status_Ex(a)20=SETUPAPI.CM_Get_DevNode_Status_Ex +CM_Get_Device_IDA(a)16=SETUPAPI.CM_Get_Device_IDA +CM_Get_Device_IDW(a)16=SETUPAPI.CM_Get_Device_IDW +CM_Get_Device_ID_ExA(a)20=SETUPAPI.CM_Get_Device_ID_ExA +CM_Get_Device_ID_ExW(a)20=SETUPAPI.CM_Get_Device_ID_ExW CM_Get_Device_ID_ListA(a)16=SETUPAPI.CM_Get_Device_ID_ListA CM_Get_Device_ID_ListW(a)16=SETUPAPI.CM_Get_Device_ID_ListW CM_Get_Device_ID_List_ExA(a)20=SETUPAPI.CM_Get_Device_ID_List_ExA @@ -99,8 +99,8 @@ CM_Get_Device_ID_List_SizeW(a)12=SETUPAPI.CM_Get_Device_ID_List_SizeW CM_Get_Device_ID_List_Size_ExA(a)16=SETUPAPI.CM_Get_Device_ID_List_Size_Ex A CM_Get_Device_ID_List_Size_ExW(a)16=SETUPAPI.CM_Get_Device_ID_List_Size_Ex A -;CM_Get_Device_ID_Size -;CM_Get_Device_ID_Size_Ex +CM_Get_Device_ID_Size(a)12=SETUPAPI.CM_Get_Device_ID_Size +CM_Get_Device_ID_Size_Ex(a)16=SETUPAPI.CM_Get_Device_ID_Size_Ex ;CM_Get_Device_Interface_AliasA ;CM_Get_Device_Interface_AliasW ;CM_Get_Device_Interface_Alias_ExA @@ -115,8 +115,8 @@ ;CM_Get_Device_Interface_List_Size_ExW ;CM_Get_First_Log_Conf ;CM_Get_First_Log_Conf_Ex -;CM_Get_Global_State -;CM_Get_Global_State_Ex +CM_Get_Global_State(a)8=SETUPAPI.CM_Get_Global_State +CM_Get_Global_State_Ex(a)12=SETUPAPI.CM_Get_Global_State_Ex ;CM_Get_HW_Prof_FlagsA ;CM_Get_HW_Prof_FlagsW ;CM_Get_HW_Prof_Flags_ExA @@ -144,6 +144,7 @@ ;CM_Intersect_Range_List ;CM_Invert_Range_List ;CM_Is_Dock_Station_Present +;CM_Is_Dock_Station_Present_Ex CM_Locate_DevNodeA(a)12=SETUPAPI.CM_Locate_DevNodeA CM_Locate_DevNodeW(a)12=SETUPAPI.CM_Locate_DevNodeW CM_Locate_DevNode_ExA(a)16=SETUPAPI.CM_Locate_DevNode_ExA _____ Modified: trunk/reactos/lib/setupapi/cfgmgr.c --- trunk/reactos/lib/setupapi/cfgmgr.c 2005-07-19 14:11:53 UTC (rev 16644) +++ trunk/reactos/lib/setupapi/cfgmgr.c 2005-07-19 15:57:30 UTC (rev 16645) @@ -251,12 +251,124 @@ CONFIGRET WINAPI CM_Get_Child_Ex( PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine) { +#if 0 + WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; + RPC_BINDING_HANDLE BindingHandle = NULL; + HSTRING_TABLE StringTable = NULL; + LPWSTR lpDevInst; + DWORD dwIndex; + CONFIGRET ret; + + TRACE("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); + + if (pdnDevInst == NULL) + return CR_INVALID_POINTER; + + if (dnDevInst == 0) + return CR_INVALID_DEVINST; + + if (ulFlags != 0) + return CR_INVALID_FLAG; + + *pdnDevInst = -1; + + if (hMachine != NULL) + { + BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; + if (BindingHandle == NULL) + return CR_FAILURE; + + StringTable = ((PMACHINE_INFO)hMachine)->StringTable; + if (StringTable == 0) + return CR_FAILURE; + } + else + { + if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) + return CR_FAILURE; + } + + lpDevInst = StringTableStringFromId(StringTable, dnDevInst); + if (lpDevInst == NULL) + return CR_INVALID_DEVNODE; + + ret = PNP_GetRelatedDeviceInstance(BindingHandle, + PNP_DEVICE_CHILD, + lpDevInst, + szRelatedDevInst, + MAX_DEVICE_ID_LEN, + 0); + if (ret != CR_SUCCESS) + return ret; + + TRACE("szRelatedDevInst: %s\n", debugstr_w(szRelatedDevInst)); + + dwIndex = StringTableAddString(StringTable, szRelatedDevInst, 1); + if (dwIndex == -1) + return CR_FAILURE; + + *pdnDevInst = dwIndex; + + return CR_SUCCESS; +#endif FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); return CR_FAILURE; } /*********************************************************************** + * CM_Get_Depth [SETUPAPI.@] + */ +CONFIGRET WINAPI CM_Get_Depth( + PULONG pulDepth, DEVINST dnDevInst, ULONG ulFlags) +{ + TRACE("%p %lx %lx\n", + pulDepth, dnDevInst, ulFlags); + return CM_Get_Depth_Ex(pulDepth, dnDevInst, ulFlags, NULL); +} + + +/********************************************************************** * + * CM_Get_Depth_Ex [SETUPAPI.@] + */ +CONFIGRET WINAPI CM_Get_Depth_Ex( + PULONG pulDepth, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine) +{ + RPC_BINDING_HANDLE BindingHandle = NULL; + HSTRING_TABLE StringTable = NULL; + LPWSTR lpDevInst; + + TRACE("%p %lx %lx %lx\n", + pulDepth, dnDevInst, ulFlags, hMachine); + + if (hMachine != NULL) + { + BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; + if (BindingHandle == NULL) + return CR_FAILURE; + + StringTable = ((PMACHINE_INFO)hMachine)->StringTable; + if (StringTable == 0) + return CR_FAILURE; + } + else + { + if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) + return CR_FAILURE; + } + + lpDevInst = StringTableStringFromId(StringTable, dnDevInst); + if (lpDevInst == NULL) + return CR_INVALID_DEVNODE; + + return PNP_GetDepth(BindingHandle, + lpDevInst, + pulDepth, + ulFlags); +} + + +/********************************************************************** * * CM_Get_Device_IDA [SETUPAPI.@] */ CONFIGRET WINAPI CM_Get_Device_IDA( @@ -322,9 +434,7 @@ dnDevInst, Buffer, &BufferLen)) - { return CR_FAILURE; - } return CR_SUCCESS; } @@ -434,7 +544,7 @@ CONFIGRET WINAPI CM_Get_Device_ID_Size( PULONG pulLen, DEVINST dnDevInst, ULONG ulFlags) { - TRACE("%p %p %lx\n", pulLen, dnDevInst, ulFlags); + TRACE("%p %lx %lx\n", pulLen, dnDevInst, ulFlags); return CM_Get_Device_ID_Size_Ex(pulLen, dnDevInst, ulFlags, NULL); } @@ -448,7 +558,7 @@ HSTRING_TABLE StringTable = NULL; LPWSTR DeviceId; - TRACE("%p %p %lx %lx\n", pulLen, dnDevInst, ulFlags, hMachine); + TRACE("%p %lx %lx %lx\n", pulLen, dnDevInst, ulFlags, hMachine); if (hMachine != NULL) { @@ -476,6 +586,63 @@ /*********************************************************************** + * CM_Get_DevNode_Status [SETUPAPI.@] + */ +CONFIGRET WINAPI CM_Get_DevNode_Status( + PULONG pulStatus, PULONG pulProblemNumber, DEVINST dnDevInst, + ULONG ulFlags) +{ + TRACE("%p %p %lx %lx\n", + pulStatus, pulProblemNumber, dnDevInst, ulFlags); + return CM_Get_DevNode_Status_Ex(pulStatus, pulProblemNumber, dnDevInst, + ulFlags, NULL); +} + + +/********************************************************************** * + * CM_Get_DevNode_Status_Ex [SETUPAPI.@] + */ +CONFIGRET WINAPI +CM_Get_DevNode_Status_Ex( + PULONG pulStatus, PULONG pulProblemNumber, DEVINST dnDevInst, + ULONG ulFlags, HMACHINE hMachine) +{ + RPC_BINDING_HANDLE BindingHandle = NULL; + HSTRING_TABLE StringTable = NULL; + LPWSTR lpDevInst; + + TRACE("%p %p %lx %lx %lx\n", + pulStatus, pulProblemNumber, dnDevInst, ulFlags, hMachine); + + if (hMachine != NULL) + { + BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; + if (BindingHandle == NULL) + return CR_FAILURE; + + StringTable = ((PMACHINE_INFO)hMachine)->StringTable; + if (StringTable == 0) + return CR_FAILURE; + } + else + { + if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) + return CR_FAILURE; + } + + lpDevInst = StringTableStringFromId(StringTable, dnDevInst); + if (lpDevInst == NULL) + return CR_INVALID_DEVNODE; + + return PNP_GetDeviceStatus(BindingHandle, + lpDevInst, + pulStatus, + pulProblemNumber, + ulFlags); +} + + +/********************************************************************** * * CM_Get_Global_State [SETUPAPI.@] */ CONFIGRET WINAPI CM_Get_Global_State( @@ -535,6 +702,66 @@ CONFIGRET WINAPI CM_Get_Parent_Ex( PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine) { +#if 0 + WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; + RPC_BINDING_HANDLE BindingHandle = NULL; + HSTRING_TABLE StringTable = NULL; + LPWSTR lpDevInst; + DWORD dwIndex; + CONFIGRET ret; + + TRACE("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); + + if (pdnDevInst == NULL) + return CR_INVALID_POINTER; + + if (dnDevInst == 0) + return CR_INVALID_DEVINST; + + if (ulFlags != 0) + return CR_INVALID_FLAG; + + *pdnDevInst = -1; + + if (hMachine != NULL) + { + BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; + if (BindingHandle == NULL) + return CR_FAILURE; + + StringTable = ((PMACHINE_INFO)hMachine)->StringTable; + if (StringTable == 0) + return CR_FAILURE; + } + else + { + if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) + return CR_FAILURE; + } + + lpDevInst = StringTableStringFromId(StringTable, dnDevInst); + if (lpDevInst == NULL) + return CR_INVALID_DEVNODE; + + ret = PNP_GetRelatedDeviceInstance(BindingHandle, + PNP_DEVICE_PARENT, + lpDevInst, + szRelatedDevInst, + MAX_DEVICE_ID_LEN, + 0); + if (ret != CR_SUCCESS) + return ret; + + TRACE("szRelatedDevInst: %s\n", debugstr_w(szRelatedDevInst)); + + dwIndex = StringTableAddString(StringTable, szRelatedDevInst, 1); + if (dwIndex == -1) + return CR_FAILURE; + + *pdnDevInst = dwIndex; + + return CR_SUCCESS; +#endif FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); return CR_FAILURE; } @@ -557,6 +784,66 @@ CONFIGRET WINAPI CM_Get_Sibling_Ex( PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine) { +#if 0 + WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; + RPC_BINDING_HANDLE BindingHandle = NULL; + HSTRING_TABLE StringTable = NULL; + LPWSTR lpDevInst; + DWORD dwIndex; + CONFIGRET ret; + + TRACE("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); + + if (pdnDevInst == NULL) + return CR_INVALID_POINTER; + + if (dnDevInst == 0) + return CR_INVALID_DEVINST; + + if (ulFlags != 0) + return CR_INVALID_FLAG; + + *pdnDevInst = -1; + + if (hMachine != NULL) + { + BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; + if (BindingHandle == NULL) + return CR_FAILURE; + + StringTable = ((PMACHINE_INFO)hMachine)->StringTable; + if (StringTable == 0) + return CR_FAILURE; + } + else + { + if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) + return CR_FAILURE; + } + + lpDevInst = StringTableStringFromId(StringTable, dnDevInst); + if (lpDevInst == NULL) + return CR_INVALID_DEVNODE; + + ret = PNP_GetRelatedDeviceInstance(BindingHandle, + PNP_DEVICE_SIBLING, + lpDevInst, + szRelatedDevInst, + MAX_DEVICE_ID_LEN, + 0); + if (ret != CR_SUCCESS) + return ret; + + TRACE("szRelatedDevInst: %s\n", debugstr_w(szRelatedDevInst)); + + dwIndex = StringTableAddString(StringTable, szRelatedDevInst, 1); + if (dwIndex == -1) + return CR_FAILURE; + + *pdnDevInst = dwIndex; + + return CR_SUCCESS; +#endif FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); return CR_FAILURE; } @@ -678,15 +965,20 @@ return CR_FAILURE; } - if (pDeviceID != NULL && wcslen(pDeviceID) != 0) + if (pDeviceID != NULL && lstrlenW(pDeviceID) != 0) { lstrcpyW(DeviceIdBuffer, pDeviceID); } else { /* Get the root device ID */ - lstrcpyW(DeviceIdBuffer, L"HTREE\\ROOT\\0"); + rc = PNP_GetRootDeviceInstance(BindingHandle, + DeviceIdBuffer, + MAX_DEVICE_ID_LEN); + if (rc != CR_SUCCESS) + return CR_FAILURE; } + TRACE("DeviceIdBuffer: %s\n", debugstr_w(DeviceIdBuffer)); /* Validate the device ID */ rc = PNP_ValidateDeviceInstance(BindingHandle, _____ Modified: trunk/reactos/lib/setupapi/setupapi.spec --- trunk/reactos/lib/setupapi/setupapi.spec 2005-07-19 14:11:53 UTC (rev 16644) +++ trunk/reactos/lib/setupapi/setupapi.spec 2005-07-19 15:57:30 UTC (rev 16645) @@ -63,14 +63,14 @@ @ stub CM_Get_Class_NameW @ stub CM_Get_Class_Name_ExA @ stub CM_Get_Class_Name_ExW -@ stub CM_Get_Depth -@ stub CM_Get_Depth_Ex +@ stdcall CM_Get_Depth(ptr long long) +@ stdcall CM_Get_Depth_Ex(ptr long long long) @ stub CM_Get_DevNode_Registry_PropertyA @ stub CM_Get_DevNode_Registry_PropertyW @ stub CM_Get_DevNode_Registry_Property_ExA @ stub CM_Get_DevNode_Registry_Property_ExW -@ stub CM_Get_DevNode_Status -@ stub CM_Get_DevNode_Status_Ex +@ stdcall CM_Get_DevNode_Status(ptr ptr long long) +@ stdcall CM_Get_DevNode_Status_Ex(ptr ptr long long long) @ stdcall CM_Get_Device_IDA(long str long long) @ stdcall CM_Get_Device_IDW(long wstr long long) @ stdcall CM_Get_Device_ID_ExA(long str long long long) _____ Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c --- trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-07-19 14:11:53 UTC (rev 16644) +++ trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-07-19 15:57:30 UTC (rev 16645) @@ -52,6 +52,7 @@ {NULL, NULL} }; +static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0"; /* FUNCTIONS *****************************************************************/ @@ -98,13 +99,13 @@ void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { - return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); } void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { - HeapFree(GetProcessHeap(), 0, ptr); + HeapFree(GetProcessHeap(), 0, ptr); } @@ -176,6 +177,126 @@ } +CONFIGRET +PNP_GetRootDeviceInstance(handle_t BindingHandle, + wchar_t *DeviceInstance, + unsigned long Length) +{ + CONFIGRET ret = CR_SUCCESS; + + DPRINT("PNP_GetRootDeviceInstance() called\n"); + + if (Length < lstrlenW(szRootDeviceId) + 1) + { + ret = CR_BUFFER_SMALL; + goto Done; + } + + lstrcpyW(DeviceInstance, + szRootDeviceId); + +Done: + DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret); + + return ret; +} + + +#if 0 +CONFIGRET +PNP_GetRelatedDeviceInstance(handle_t BindingHandle, + unsigned long Relationship, + wchar_t *DeviceId, + wchar_t *RelatedDeviceId, + unsigned long Length, + unsigned long Flags) +{ + CONFIGRET ret = CR_SUCCESS; + + DPRINT1("PNP_GetRelatedDeviceInstance() called\n"); + DPRINT1(" Relationship %ld\n", Relationship); + DPRINT1(" DeviceId %S\n", DeviceId); + + lstrcpyW(RelatedDeviceId, + szRootDeviceId); + +//Done: + DPRINT1("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret); + + return ret; +} +#endif + + +CONFIGRET +PNP_GetDepth(handle_t BindingHandle, + wchar_t *DeviceInstance, + unsigned long *Depth, + DWORD Flags) +{ + PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData; + CONFIGRET ret = CR_SUCCESS; + NTSTATUS Status; + + DPRINT1("PNP_GetDepth() called\n"); + + RtlInitUnicodeString(&PlugPlayData.DeviceInstance, + DeviceInstance); + + Status = NtPlugPlayControl(PlugPlayControlGetDeviceDepth, + (PVOID)&PlugPlayData, + sizeof(PLUGPLAY_CONTROL_DEPTH_DATA)); + if (NT_SUCCESS(Status)) + { + *Depth = PlugPlayData.Depth; + } + else + { + ret = CR_FAILURE; /* FIXME */ + } + + DPRINT1("PNP_GetDepth() done (returns %lx)\n", ret); + + return ret; +} + + +CONFIGRET +PNP_GetDeviceStatus(handle_t BindingHandle, + wchar_t *DeviceInstance, + unsigned long *pStatus, + unsigned long *pProblem, + DWORD Flags) +{ + PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData; + CONFIGRET ret = CR_SUCCESS; + NTSTATUS Status; + + DPRINT1("PNP_GetDeviceStatus() called\n"); + + RtlInitUnicodeString(&PlugPlayData.DeviceInstance, + DeviceInstance); + PlugPlayData.Operation = 0; /* Get status */ + + Status = NtPlugPlayControl(PlugPlayControlDeviceStatus, + (PVOID)&PlugPlayData, + sizeof(PLUGPLAY_CONTROL_STATUS_DATA)); + if (NT_SUCCESS(Status)) + { + *pStatus = PlugPlayData.DeviceStatus; + *pProblem = PlugPlayData.DeviceProblem; + } + else + { + ret = CR_FAILURE; /* FIXME */ + } + + DPRINT1("PNP_GetDeviceStatus() done (returns %lx)\n", ret); + + return ret; +} + + static DWORD WINAPI PnpEventThread(LPVOID lpParameter) {
19 years, 6 months
1
0
0
0
[fireball] 16644: usb stack "upgrade", fixes issues with timing, host controller reset, new devices discovery, other small things (better to see diff :) ).
by fireball@svn.reactos.com
usb stack "upgrade", fixes issues with timing, host controller reset, new devices discovery, other small things (better to see diff :) ). Modified: trunk/reactos/drivers/usb/cromwell/host/ohci-hcd.c Modified: trunk/reactos/drivers/usb/cromwell/host/ohci_main.c _____ Modified: trunk/reactos/drivers/usb/cromwell/host/ohci-hcd.c --- trunk/reactos/drivers/usb/cromwell/host/ohci-hcd.c 2005-07-19 14:06:19 UTC (rev 16643) +++ trunk/reactos/drivers/usb/cromwell/host/ohci-hcd.c 2005-07-19 14:11:53 UTC (rev 16644) @@ -391,21 +391,35 @@ static int hc_reset (struct ohci_hcd *ohci) { u32 temp; - u32 ints; - u32 control; - - /* Disable HC interrupts */ - writel (OHCI_INTR_MIE, &ohci->regs->intrdisable); - // acknowledge all pending interrupts - ints = readl(&ohci->regs->intrstatus); - writel (ints, &ohci->regs->intrstatus); + /* SMM owns the HC? not for long! + * On PA-RISC, PDC can leave IR set incorrectly; ignore it there. + */ +#ifndef __hppa__ if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { - // takeover without negotiation - there is noone to negotiate with - control = readl (&ohci->regs->control) & ~OHCI_CTRL_IR; - writel (control, &ohci->regs->control); + ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n"); + + /* this timeout is arbitrary. we make it long, so systems + * depending on usb keyboards may be usable even if the + * BIOS/SMM code seems pretty broken. + */ + temp = 500; /* arbitrary: five seconds */ + + writel (OHCI_INTR_OC, &ohci->regs->intrenable); + writel (OHCI_OCR, &ohci->regs->cmdstatus); + while (readl (&ohci->regs->control) & OHCI_CTRL_IR) { + wait_ms (10); + if (--temp == 0) { + ohci_err (ohci, "USB HC TakeOver failed!\n"); + return -1; + } + } } +#endif + /* Disable HC interrupts */ + writel (OHCI_INTR_MIE, &ohci->regs->intrdisable); + ohci_dbg (ohci, "USB HC reset_hc %s: ctrl = 0x%x ;\n", hcd_to_bus (&ohci->hcd)->bus_name, readl (&ohci->regs->control)); @@ -615,27 +629,17 @@ static void ohci_stop (struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); - struct ohci_regs *regs = ohci->regs; - int ints; ohci_dbg (ohci, "stop %s controller%s\n", hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS), ohci->disabled ? " (disabled)" : "" ); - ohci_dump (ohci, 1); + //ohci_dump (ohci, 1); if (!ohci->disabled) hc_reset (ohci); - - // Disable all interrupts - writel (OHCI_INTR_MIE, ®s->intrdisable); - // acknowledge all pending interrupts - ints = readl(®s->intrstatus); - writel (ints, ®s->intrstatus); - // flush register writes - (void) readl (&ohci->regs->control); - remove_debug_files (ohci); + //remove_debug_files (ohci); ohci_mem_cleanup (ohci); if (ohci->hcca) { pci_free_consistent (ohci->hcd.pdev, sizeof *ohci->hcca, _____ Modified: trunk/reactos/drivers/usb/cromwell/host/ohci_main.c --- trunk/reactos/drivers/usb/cromwell/host/ohci_main.c 2005-07-19 14:06:19 UTC (rev 16643) +++ trunk/reactos/drivers/usb/cromwell/host/ohci_main.c 2005-07-19 14:11:53 UTC (rev 16644) @@ -131,14 +131,16 @@ NTSTATUS Status; POHCI_DEVICE_EXTENSION DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - // Fill generic linux structs + // Allocate and fill generic linux structs dev = ExAllocatePoolWithTag(PagedPool, sizeof(struct pci_dev), USB_OHCI_TAG); - - init_wrapper(dev); dev->irq = DeviceExtension->InterruptVector; dev->dev_ext = (PVOID)DeviceExtension; + dev->dev.dev_ext = (PVOID)DeviceExtension; dev->slot_name = ExAllocatePoolWithTag(NonPagedPool, 128, USB_OHCI_TAG); // 128 max len for slot name + // Init wrapper + init_wrapper(dev); + strcpy(dev->dev.name, "OpenHCI PCI-USB Controller"); strcpy(dev->slot_name, "OHCD PCI Slot");
19 years, 6 months
1
0
0
0
[fireball] 16643: usbcore "upgrade", fixes issues with timing, host controller reset, new devices discovery, other small things (better to see diff :) ).
by fireball@svn.reactos.com
usbcore "upgrade", fixes issues with timing, host controller reset, new devices discovery, other small things (better to see diff :) ). Modified: trunk/reactos/drivers/usb/cromwell/core/hub.h _____ Modified: trunk/reactos/drivers/usb/cromwell/core/hub.h --- trunk/reactos/drivers/usb/cromwell/core/hub.h 2005-07-19 13:19:04 UTC (rev 16642) +++ trunk/reactos/drivers/usb/cromwell/core/hub.h 2005-07-19 14:06:19 UTC (rev 16643) @@ -183,7 +183,7 @@ int error; /* last reported error */ int nerrors; /* track consecutive errors */ - + int RestCounter; struct list_head hub_list; /* all hubs */ struct list_head event_list; /* hubs w/data or errs ready */
19 years, 6 months
1
0
0
0
[fireball] 16642: Implemented needed DMA functions (pool alloc/free, create/destroy, map/unmap single), manipulations with timers (schedule_timeout, schedule_wait).
by fireball@svn.reactos.com
Implemented needed DMA functions (pool alloc/free, create/destroy, map/unmap single), manipulations with timers (schedule_timeout, schedule_wait). Modified: trunk/reactos/drivers/usb/cromwell/host/ohci_main.h Modified: trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h Modified: trunk/reactos/drivers/usb/cromwell/linux/usb.h Modified: trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c _____ Modified: trunk/reactos/drivers/usb/cromwell/host/ohci_main.h --- trunk/reactos/drivers/usb/cromwell/host/ohci_main.h 2005-07-19 11:18:40 UTC (rev 16641) +++ trunk/reactos/drivers/usb/cromwell/host/ohci_main.h 2005-07-19 13:19:04 UTC (rev 16642) @@ -38,6 +38,20 @@ ULONG SystemIoBusNumber; ULONG SystemIoSlotNumber; LIST_ENTRY AddressMappingListHead; + + // DMA stuff, and buffers + PDMA_ADAPTER pDmaAdapter; + PVOID MapRegisterBase; + ULONG mapRegisterCount; +#ifdef USB_DMA_SINGLE_SUPPORT + PHYSICAL_ADDRESS Buffer; + PVOID VirtualBuffer; + ULONG BufferSize; + + // Mdl used for single DMA transfers + PMDL Mdl; +#endif + //KDPC DpcObject; OHCI_DRIVER_EXTENSION *DriverExtension; ULONG DeviceOpened; _____ Modified: trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h --- trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h 2005-07-19 11:18:40 UTC (rev 16641) +++ trunk/reactos/drivers/usb/cromwell/linux/linux_wrapper.h 2005-07-19 13:19:04 UTC (rev 16642) @@ -34,7 +34,7 @@ typedef u32 dma_addr_t; -typedef int spinlock_t; +typedef int spinlock_t; typedef int atomic_t; #ifndef STANDALONE #ifndef _MODE_T_ @@ -123,6 +123,8 @@ struct device *parent; struct list_head driver_list; void (*release)(struct device * dev); + + void *dev_ext; // ReactOS-specific: pointer to windows device extension }; struct class_device{int a;}; struct semaphore{int a;}; @@ -165,8 +167,20 @@ int dummy; }; +/* These definitions mirror those in pci.h, so they can be used + * interchangeably with their PCI_ counterparts */ +enum dma_data_direction { + DMA_BIDIRECTIONAL = 0, + DMA_TO_DEVICE = 1, + DMA_FROM_DEVICE = 2, + DMA_NONE = 3, +}; + +/* compatibility */ +#define PCI_DMA_TODEVICE DMA_TO_DEVICE +#define PCI_DMA_FROMDEVICE DMA_FROM_DEVICE + /* from mod_devicetable.h */ - struct usb_device_id { /* which fields to match against? */ __u16 match_flags; @@ -409,43 +423,49 @@ /* PCI */ -#define to_pci_dev(n) container_of(n, struct pci_dev, dev) +#define MAX_POOL_PAGES 2 +#define BITS_PER_LONG 32 -#define pci_pool_create(a,b,c,d,e) (void*)1 +struct pci_page +{ + PHYSICAL_ADDRESS dmaAddress; + PVOID virtualAddress; -#define pci_pool_alloc(a,b,c) my_pci_pool_alloc(a,b,c) + unsigned long bitmap[128]; // 128 == 32bits*4096 blocks +}; -static void __inline__ *my_pci_pool_alloc(void* pool, size_t size, - dma_addr_t *dma_handle) +struct pci_pool { - void* a; - a=kmalloc(size,0); //FIXME -#ifdef MODULE - *dma_handle=((u32)a)&0xfffffff; -#else - *dma_handle=(u32)a; -#endif - return a; -} + char name[32]; + size_t size; + size_t allocation; + size_t blocks_per_page; + struct pci_dev *pdev; + // internal stuff + int pages_allocated; + int blocks_allocated; -#define pci_pool_free(a,b,c) kfree(b) -#define pci_alloc_consistent(a,b,c) my_pci_alloc_consistent(a,b,c) + struct pci_page pages[MAX_POOL_PAGES]; +}; -static void __inline__ *my_pci_alloc_consistent(struct pci_dev *hwdev, size_t size, - dma_addr_t *dma_handle) -{ - void* a; +#define to_pci_dev(n) container_of(n, struct pci_dev, dev) - a=kmalloc(size+256,0); //FIXME - a=(void*)(((int)a+255)&~255); // 256 alignment - *dma_handle=((u32)a)&0xfffffff; +#define pci_pool_create(a,b,c,d,e) my_pci_pool_create(a,b,c,d,e) +struct pci_pool *my_pci_pool_create(const char * name, struct pci_dev * pdev, size_t size, size_t align, size_t allocation); - return a; -} +#define pci_pool_alloc(a,b,c) my_pci_pool_alloc(a,b,c) +void *my_pci_pool_alloc(struct pci_pool * pool, int mem_flags, dma_addr_t *dma_handle); +#define pci_pool_free(a,b,c) my_pci_pool_free(a,b,c) +void my_pci_pool_free(struct pci_pool * pool, void * vaddr, dma_addr_t dma); + +#define pci_alloc_consistent(a,b,c) my_pci_alloc_consistent(a,b,c) +void *my_pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle); + #define pci_free_consistent(a,b,c,d) kfree(c) -#define pci_pool_destroy(a) do {} while(0) +#define pci_pool_destroy(a) my_pci_pool_destroy(a) +void my_pci_pool_destroy (struct pci_pool * pool); #define pci_module_init(x) my_pci_module_init(x) int my_pci_module_init(struct pci_driver *x); @@ -464,17 +484,29 @@ #define dma_pool_free(a,b,c) pci_pool_free(a,b,c) #define dma_pool_destroy(a) pci_pool_destroy(a) -#define dma_alloc_coherent(a,b,c,d) NULL -#define dma_free_coherent(a,b,c,d) do {} while(0) +//#define dma_alloc_coherent(a,b,c,d) NULL +//#define dma_free_coherent(a,b,c,d) do {} while(0) +#define dma_map_single(a,b,c,d) my_dma_map_single(a,b,c,d) +dma_addr_t my_dma_map_single(struct device *hwdev, void *ptr, size_t size, enum dma_data_direction direction); -#define dma_map_single(a,b,c,d) ((u32)(b)&0xfffffff) -#define dma_unmap_single(a,b,c,d) do {} while(0) -#define pci_unmap_single(a,b,c,d) do {} while(0) -#define dma_sync_single(a,b,c,d) do {} while(0) -#define dma_sync_sg(a,b,c,d) do {} while(0) -#define dma_map_sg(a,b,c,d) 0 -#define dma_unmap_sg(a,b,c,d) do {} while(0) +#define dma_unmap_single(a,b,c,d) my_dma_unmap_single(a,b,c,d) +void my_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction); +#define pci_unmap_single(a,b,c,d) my_pci_unmap_single(a,b,c,d) +void my_pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction); + +#define dma_sync_single(a,b,c,d) my_dma_sync_single(a,b,c,d) +void my_dma_sync_single(struct device *hwdev, dma_addr_t dma_handle, size_t size, int direction); + +#define dma_sync_sg(a,b,c,d) my_dma_sync_sg(a,b,c,d) +void my_dma_sync_sg(struct device *hwdev, struct scatterlist *sg, int nelems, int direction); + +#define dma_map_sg(a,b,c,d) my_dma_map_sg(a,b,c,d) +int my_dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, enum dma_data_direction direction); + +#define dma_unmap_sg(a,b,c,d) my_dma_unmap_sg(a,b,c,d) +void my_dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents, enum dma_data_direction direction); + #define usb_create_driverfs_dev_files(a) do {} while(0) #define usb_create_driverfs_intf_files(a) do {} while(0) #define sg_dma_address(x) ((u32)((x)->page*4096 + (x)->offset)) @@ -482,12 +514,6 @@ #define page_address(x) ((void*)(x/4096)) -#define DMA_TO_DEVICE 0 -#define DMA_FROM_DEVICE 0 -#define PCI_DMA_TODEVICE -#define PCI_DMA_FROMDEVICE -#define PCI_DMA_TODEVICE - #define PCI_ROM_RESOURCE 1 #define IORESOURCE_IO CM_RESOURCE_PORT_IO _____ Modified: trunk/reactos/drivers/usb/cromwell/linux/usb.h --- trunk/reactos/drivers/usb/cromwell/linux/usb.h 2005-07-19 11:18:40 UTC (rev 16641) +++ trunk/reactos/drivers/usb/cromwell/linux/usb.h 2005-07-19 13:19:04 UTC (rev 16642) @@ -327,7 +327,7 @@ { int actual; actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, dev->devpath); - return (actual >= (int)size) ? -1 : actual; + return (actual >= size) ? -1 : actual; } /*---------------------------------------------------------------------- ---*/ _____ Modified: trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c --- trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c 2005-07-19 11:18:40 UTC (rev 16641) +++ trunk/reactos/drivers/usb/cromwell/sys/linuxwrapper.c 2005-07-19 13:19:04 UTC (rev 16642) @@ -40,8 +40,11 @@ #define MAX_DRVS 8 static struct device_driver *m_drivers[MAX_DRVS]; -static int drvs_num; +static int drvs_num=0; +unsigned int LAST_USB_EVENT_TICK; +NTSTATUS init_dma(POHCI_DEVICE_EXTENSION pDevExt); + /*---------------------------------------------------------------------- --*/ /* * Helper functions for top-level system @@ -69,6 +72,8 @@ need_wakeup=0; for(n=0;n<MAX_DRVS;n++) m_drivers[n]=NULL; + + init_dma(probe_dev->dev_ext); } /*---------------------------------------------------------------------- --*/ void handle_irqs(int irq) @@ -92,17 +97,20 @@ int n; for(n=0;n<MAX_TIMERS;n++) { - if (main_timer_list[n] && - main_timer_list[n]->function && main_timer_list[n]->expires) + if (main_timer_list[n] && main_timer_list[n]->function) { void (*function)(unsigned long)=main_timer_list[n]->function; unsigned long data=main_timer_list[n]->data; - main_timer_list[n]->expires=0; - - main_timer_list[n]=NULL; // remove timer - //printk("do timer %i fn %p\n",n,function); - - function(data); + + if (main_timer_list[n]->expires>1) { + main_timer_list[n]->expires--; + } else { + + main_timer_list[n]->expires=0; + main_timer_list[n]=0; // remove timer + // Call Timer Function Data + function(data); + } } } } @@ -118,13 +126,13 @@ ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); - /*PsCreateSystemThread(&hThread, + PsCreateSystemThread(&hThread, THREAD_ALL_ACCESS, NULL, NULL, NULL, (PKSTART_ROUTINE)handler, - parm);*/ + parm); DPRINT1("usbcore: Created system thread %d\n", (int)hThread); @@ -229,24 +237,42 @@ } /*---------------------------------------------------------------------- --*/ /* wait until woken up (only one wait allowed!) */ +extern unsigned int LAST_USB_IRQ; + int my_schedule_timeout(int x) { - int wait=1; - x+=10; // safety - printk("schedule_timeout %i\n",x); + LONGLONG HH; + LONGLONG temp; + LONGLONG delay; + extern unsigned int LAST_USB_EVENT_TICK; + printk("schedule_timeout: %d ms\n", x); + + x+=5; // safety + x = x*1000; // to us format + while(x>0) { - do_all_timers(); -#ifndef HAVE_IRQS - handle_irqs(-1); + KeQueryTickCount((LARGE_INTEGER *)&HH);//IoInputDword(0x8008); + temp = HH - LAST_USB_EVENT_TICK; + + //if (temp>(3579)) { //3579 = 1ms! + if (temp>1000) { + do_all_timers(); + LAST_USB_EVENT_TICK = HH; + } -#endif + //if (LAST_USB_IRQ != OHCI_1_INTERRUPT ) { + // LAST_USB_IRQ = OHCI_1_INTERRUPT; + handle_irqs(-1); + //} + if (need_wakeup) break; - wait_ms(wait); - inc_jiffies(wait); - x-=wait; + + delay = 10; + KeDelayExecutionThread(KernelMode, FALSE, (LARGE_INTEGER *)&delay); //wait_us(1); + x-=1; } need_wakeup=0; printk("schedule DONE!!!!!!\n"); @@ -256,17 +282,34 @@ /*---------------------------------------------------------------------- --*/ void my_wait_for_completion(struct completion *x) { - int n=100; + LONGLONG HH; + LONGLONG temp; + LONGLONG delay; + extern unsigned int LAST_USB_EVENT_TICK; + printk("wait for completion\n"); + int n=10; + n = n*1000; // to us format + while(!x->done && (n>0)) { - do_all_timers(); -#ifndef HAVE_IRQS - handle_irqs(-1); + KeQueryTickCount((LARGE_INTEGER *)&HH);//IoInputDword(0x8008); + temp = HH - LAST_USB_EVENT_TICK; -#endif - wait_ms(10); + //if (temp>(3579)) { + if (temp>(1000)) { + do_all_timers(); + LAST_USB_EVENT_TICK = HH; + } + + //if (LAST_USB_IRQ != OHCI_1_INTERRUPT ) { + // LAST_USB_IRQ = OHCI_1_INTERRUPT; + handle_irqs(-1); + //} + + delay = 10; + KeDelayExecutionThread(KernelMode, FALSE, (LARGE_INTEGER *)&delay); //wait_us(1); n--; } printk("wait for completion done %i\n",x->done); @@ -374,11 +417,468 @@ ExFreeToNPagedLookasideList((PNPAGED_LOOKASIDE_LIST)co, ptr); } /*---------------------------------------------------------------------- --*/ -// DMA, not used now +// DMA support routines /*---------------------------------------------------------------------- --*/ +#ifdef USB_DMA_SINGLE_SUPPORT +static IO_ALLOCATION_ACTION NTAPI MapRegisterCallback(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID MapRegisterBase, + PVOID Context); +#endif + +NTSTATUS +init_dma(POHCI_DEVICE_EXTENSION pDevExt) +{ + // Prepare device descriptor structure + DEVICE_DESCRIPTION dd; +#ifdef USB_DMA_SINGLE_SUPPORT + KEVENT DMAEvent; + KIRQL OldIrql; + NTSTATUS Status; +#endif + + RtlZeroMemory( &dd, sizeof(dd) ); + dd.Version = DEVICE_DESCRIPTION_VERSION; + dd.Master = TRUE; + dd.ScatterGather = TRUE; + dd.DemandMode = FALSE; + dd.AutoInitialize = FALSE; + dd.Dma32BitAddresses = TRUE; + dd.InterfaceType = PCIBus; + dd.DmaChannel = 0;//pDevExt->dmaChannel; + dd.MaximumLength = 128;//MAX_DMA_LENGTH; + dd.DmaWidth = Width32Bits; + dd.DmaSpeed = MaximumDmaSpeed; + + // The following taken from Win2k DDB: + // "Compute the maximum number of mapping regs + // this device could possibly need. Since the + // transfer may not be paged aligned, add one + // to allow the max xfer size to span a page." + //pDevExt->mapRegisterCount = (MAX_DMA_LENGTH / PAGE_SIZE) + 1; + + // TODO: Free it somewhere (PutDmaAdapter) + pDevExt->pDmaAdapter = + IoGetDmaAdapter( pDevExt->PhysicalDeviceObject, + &dd, + &pDevExt->mapRegisterCount); + + DPRINT1("IoGetDmaAdapter done 0x%X, mapRegisterCount=%d\n", pDevExt->pDmaAdapter, pDevExt->mapRegisterCount); + + // Fail if failed + if (pDevExt->pDmaAdapter == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + +#ifdef USB_DMA_SINGLE_SUPPORT + /* Allocate buffer now */ + pDevExt->BufferSize = pDevExt->mapRegisterCount * PAGE_SIZE; + DPRINT1("Bufsize = %u\n", pDevExt->BufferSize); + pDevExt->VirtualBuffer = pDevExt->pDmaAdapter->DmaOperations->AllocateCommonBuffer( + pDevExt->pDmaAdapter, pDevExt->BufferSize, &pDevExt->Buffer, FALSE); + DPRINT1("Bufsize = %u, Buffer = 0x%x", pDevExt->BufferSize, pDevExt->Buffer.LowPart); + + if (!pDevExt->VirtualBuffer) + { + DPRINT1("Could not allocate buffer\n"); + // should try again with smaller buffer... + return STATUS_INSUFFICIENT_RESOURCES; + } + + DPRINT1("Calling IoAllocateMdl()\n"); + pDevExt->Mdl = IoAllocateMdl(pDevExt->VirtualBuffer, pDevExt->BufferSize, FALSE, FALSE, NULL); + DPRINT1("Bufsize == %u\n", pDevExt->BufferSize); + + if (!pDevExt->Mdl) + { + DPRINT1("IoAllocateMdl() FAILED\n"); + //TODO: Free the HAL buffer + return STATUS_INSUFFICIENT_RESOURCES; + } + + DPRINT1("VBuffer == 0x%x Mdl == %u Bufsize == %u\n", pDevExt->VirtualBuffer, pDevExt->Mdl, pDevExt->BufferSize); + + DPRINT1("Calling MmBuildMdlForNonPagedPool\n"); + MmBuildMdlForNonPagedPool(pDevExt->Mdl); + + + /* Get map registers for DMA */ + KeInitializeEvent(&DMAEvent, SynchronizationEvent, FALSE); + + KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); + // TODO: Free adapter channel somewhere + Status = pDevExt->pDmaAdapter->DmaOperations->AllocateAdapterChannel(pDevExt->pDm aAdapter, + pDevExt->PhysicalDeviceObject, pDevExt->mapRegisterCount, MapRegisterCallback, &DMAEvent); + KeLowerIrql(OldIrql); + + DPRINT1("VBuffer == 0x%x Bufsize == %u\n", pDevExt->VirtualBuffer, pDevExt->BufferSize); + KeWaitForSingleObject(&DMAEvent, Executive, KernelMode, FALSE, NULL); + + if(Status != STATUS_SUCCESS) + { + DPRINT("init_dma(): unable to allocate adapter channels\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } +#endif + return STATUS_SUCCESS; +} + +/* + * FUNCTION: Acquire map registers in prep for DMA + * ARGUMENTS: + * DeviceObject: unused + * Irp: unused + * MapRegisterBase: returned to blocked thread via a member var + * Context: contains a pointer to the right ControllerInfo + * struct + * RETURNS: + * KeepObject, because that's what the DDK says to do + */ +#ifdef USB_DMA_SINGLE_SUPPORT +static IO_ALLOCATION_ACTION NTAPI MapRegisterCallback(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID MapRegisterBase, + PVOID Context) +{ + POHCI_DEVICE_EXTENSION pDevExt = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + UNREFERENCED_PARAMETER(Irp); + + DPRINT("usb_linuxwrapper: MapRegisterCallback Called, base=0x%08x\n", MapRegisterBase); + + pDevExt->MapRegisterBase = MapRegisterBase; + + // signal that we are finished + KeSetEvent(Context, 0, FALSE); + + return KeepObject;//DeallocateObjectKeepRegisters; +} +#endif + void *my_dma_pool_alloc(struct dma_pool *pool, int gfp_flags, dma_addr_t *dma_handle) { // HalAllocCommonBuffer // But ideally IoGetDmaAdapter + + DPRINT1("dma_pool_alloc() called\n"); return NULL; } + +/* +pci_pool_create -- Creates a pool of pci consistent memory blocks, for dma. + +struct pci_pool * pci_pool_create (const char * name, struct pci_dev * pdev, size_t size, size_t align, size_t allocation, int flags); + +Arguments: +name - name of pool, for diagnostics +pdev - pci device that will be doing the DMA +size - size of the blocks in this pool. +align - alignment requirement for blocks; must be a power of two +allocation - returned blocks won't cross this boundary (or zero) +flags - SLAB_* flags (not all are supported). + +Description: +Returns a pci allocation pool with the requested characteristics, or null if one can't be created. +Given one of these pools, pci_pool_alloc may be used to allocate memory. Such memory will all have +"consistent" DMA mappings, accessible by the device and its driver without using cache flushing +primitives. The actual size of blocks allocated may be larger than requested because of alignment. +If allocation is nonzero, objects returned from pci_pool_alloc won't cross that size boundary. +This is useful for devices which have addressing restrictions on individual DMA transfers, such +as not crossing boundaries of 4KBytes. +*/ +struct pci_pool *my_pci_pool_create(const char * name, struct pci_dev * pdev, size_t size, size_t align, size_t allocation) +{ + struct pci_pool *retval; + + if (align == 0) + align = 1; + if (size == 0) + return 0; + else if (size < align) + size = align; + else if ((size % align) != 0) { + size += align + 1; + size &= ~(align - 1); + } + + if (allocation == 0) { + if (PAGE_SIZE < size) + allocation = size; + else + allocation = PAGE_SIZE; + // FIXME: round up for less fragmentation + } else if (allocation < size) + return 0; + + retval = ExAllocatePool(NonPagedPool, sizeof(retval)); //FIXME: Should it be non-paged? + // pci_pool is rather big struct + + // fill retval structure + strncpy (retval->name, name, sizeof retval->name); + retval->name[sizeof retval->name - 1] = 0; + + retval->allocation = allocation; + retval->size = size; + retval->blocks_per_page = allocation / size; + retval->pdev = pdev; + + retval->pages_allocated = 0; + retval->blocks_allocated = 0; + + DPRINT1("pci_pool_create(): %s/%s size %d, %d/page (%d alloc)\n", + pdev ? pdev->slot_name : NULL, retval->name, size, + retval->blocks_per_page, allocation); + + return retval; +} + +/* +Name: +pci_pool_alloc -- get a block of consistent memory + +Synopsis: +void * pci_pool_alloc (struct pci_pool * pool, int mem_flags, dma_addr_t * handle); + +Arguments: +pool - pci pool that will produce the block + +mem_flags - SLAB_KERNEL or SLAB_ATOMIC + +handle - pointer to dma address of block + +Description: +This returns the kernel virtual address of a currently unused block, and reports its dma +address through the handle. If such a memory block can't be allocated, null is returned. +*/ +void * my_pci_pool_alloc(struct pci_pool * pool, int mem_flags, dma_addr_t *dma_handle) +{ + PVOID result; + POHCI_DEVICE_EXTENSION devExt = (POHCI_DEVICE_EXTENSION)pool->pdev->dev_ext; + //PHYSICAL_ADDRESS logicalAddr; + DPRINT1("pci_pool_alloc() called, blocks already allocated=%d\n", pool->blocks_allocated); + //size_t current_block_in_page; + int page,map,i,block,offset; + + if (pool->pages_allocated == 0) + { + // we need to allocate at least one page + pool->pages[pool->pages_allocated].virtualAddress = + devExt->pDmaAdapter->DmaOperations->AllocateCommonBuffer(devExt->pDmaAda pter, + PAGE_SIZE, &pool->pages[pool->pages_allocated].dmaAddress, FALSE); //FIXME: Cache-enabled? + + // mark all blocks as free (bit=set) + memset(pool->pages[pool->pages_allocated].bitmap, 0xFF, 128*sizeof(long)); + + /* FIXME: the next line replaces physical address by virtual address: + * this change is needed to boot VMWare, but I'm really not sure this + * change is correct! + */ + //pool->pages[pool->pages_allocated].dmaAddress.QuadPart = (ULONG_PTR)pool->pages[pool->pages_allocated].virtualAddress; + pool->pages_allocated++; + } + + // search for a free block in all pages + for (page=0; page<pool->pages_allocated; page++) + { + for (map=0,i=0; i < pool->blocks_per_page; i+= BITS_PER_LONG, map++) + { + if (pool->pages[page].bitmap[map] == 0) + continue; + + block = ffz(~ pool->pages[page].bitmap[map]); + + if ((i + block) < pool->blocks_per_page) + { + clear_bit(block, &pool->pages[page].bitmap[map]); + offset = (BITS_PER_LONG * map) + block; + offset *= pool->size; + goto ready; + } + } + } + + //TODO: alloc page here then + DPRINT1("Panic!! We need one more page to be allocated, and Fireball doesn't want to alloc it!\n"); + offset = 0; + return 0; + +ready: + *dma_handle = pool->pages[page].dmaAddress.QuadPart + offset; + result = (char *)pool->pages[page].virtualAddress + offset; + pool->blocks_allocated++; + +#if 0 + // check do we have enough free blocks on the current page + if (pool->pages_allocated*pool->blocks_per_page < pool->blocks_allocated+1) + { + DPRINT1("Panic!! We need one more page to be allocated, and Fireball doesn't want to alloc it!\n"); + *dma_handle = 0; + return NULL; + } + + // Alloc one block now + pool->blocks_allocated++; + current_block_in_page = pool->blocks_allocated - (pool->blocks_allocated / pool->blocks_per_page) * pool->blocks_per_page; + *dma_handle = pool->pages[pool->pages_allocated-1].dmaAddress.QuadPart + pool->size*(current_block_in_page - 1); + result = pool->pages[pool->pages_allocated-1].virtualAddress + pool->size*(current_block_in_page - 1); +#endif + + return result; +} + +/* +Name +pci_pool_free -- put block back into pci pool +Synopsis + +void pci_pool_free (struct pci_pool * pool, void * vaddr, dma_addr_t dma); + +Arguments + +pool - the pci pool holding the block + +vaddr - virtual address of block + +dma - dma address of block + +Description: +Caller promises neither device nor driver will again touch this block unless it is first re-allocated. +*/ +void my_pci_pool_free (struct pci_pool * pool, void * vaddr, dma_addr_t dma) +{ + int page, block, map; + + // Find page + for (page=0; page<pool->pages_allocated; page++) + { + if (dma < pool->pages[page].dmaAddress.QuadPart) + continue; + if (dma < (pool->pages[page].dmaAddress.QuadPart + pool->allocation)) + break; + } + + block = dma - pool->pages[page].dmaAddress.QuadPart; + block /= pool->size; + map = block / BITS_PER_LONG; + block %= BITS_PER_LONG; + + // mark as free + set_bit (block, &pool->pages[page].bitmap[map]); + + pool->blocks_allocated--; + + DPRINT1("pci_pool_free(): alloc'd: %d\n", pool->blocks_allocated); +} + +/* +pci_pool_destroy -- destroys a pool of pci memory blocks. +Synopsis + +void pci_pool_destroy (struct pci_pool * pool); + + +Arguments: +pool - pci pool that will be destroyed + +Description +Caller guarantees that no more memory from the pool is in use, and that nothing will try to +use the pool after this call. +*/ +void __inline__ my_pci_pool_destroy (struct pci_pool * pool) +{ + DPRINT1("pci_pool_destroy(): alloc'd: %d, UNIMPLEMENTED\n", pool->blocks_allocated); + + ExFreePool(pool); +} + +void *my_pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle) +{ + POHCI_DEVICE_EXTENSION devExt = (POHCI_DEVICE_EXTENSION)hwdev->dev_ext; + DPRINT1("pci_alloc_consistent() size=%d\n", size); + + return devExt->pDmaAdapter->DmaOperations->AllocateCommonBuffer(devExt->pDmaAda pter, size, (PPHYSICAL_ADDRESS)dma_handle, FALSE); //FIXME: Cache-enabled? +} + +dma_addr_t my_dma_map_single(struct device *hwdev, void *ptr, size_t size, enum dma_data_direction direction) +{ + //PHYSICAL_ADDRESS BaseAddress; + //POHCI_DEVICE_EXTENSION pDevExt = (POHCI_DEVICE_EXTENSION)hwdev->dev_ext; + //PUCHAR VirtualAddress = (PUCHAR) MmGetMdlVirtualAddress(pDevExt->Mdl); + //ULONG transferSize = size; + //BOOLEAN WriteToDevice; + + //DPRINT1("dma_map_single() ptr=0x%lx, size=0x%x, dir=%d\n", ptr, size, direction); + /*ASSERT(pDevExt->BufferSize > size); + + // FIXME: It must be an error if DMA_BIDIRECTIONAL trasnfer happens, since MSDN says + // the buffer is locked + if (direction == DMA_BIDIRECTIONAL || direction == DMA_TO_DEVICE) + WriteToDevice = TRUE; + else + WriteToDevice = FALSE; + + DPRINT1("IoMapTransfer\n"); + BaseAddress = pDevExt->pDmaAdapter->DmaOperations->MapTransfer(pDevExt->pDmaAdapter, + pDevExt->Mdl, + pDevExt->MapRegisterBase, + (PUCHAR) MmGetMdlVirtualAddress(pDevExt->Mdl), + &transferSize, + WriteToDevice); + + if (WriteToDevice) + { + DPRINT1("Writing to the device...\n"); + memcpy(VirtualAddress, ptr, size); + } + else + { + DPRINT1("Reading from the device...\n"); + memcpy(ptr, VirtualAddress, size); + }*/ + + //DPRINT1("VBuffer == 0x%x (really 0x%x?) transf_size == %u\n", pDevExt->VirtualBuffer, MmGetPhysicalAddress(pDevExt->VirtualBuffer).LowPart, transferSize); + //DPRINT1("VBuffer == 0x%x (really 0x%x?) transf_size == %u\n", ptr, MmGetPhysicalAddress(ptr).LowPart, transferSize); + + return MmGetPhysicalAddress(ptr).QuadPart;//BaseAddress.QuadPart; /* BIG HACK */ +} + +// 2.6 version of pci_unmap_single +//void my_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction) +void my_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction) +{ + //DPRINT1("dma_unmap_single() called, nothing to do\n"); + /* nothing yet */ +} + +void my_dma_sync_single(struct device *hwdev, + dma_addr_t dma_handle, + size_t size, int direction) +{ + DPRINT1("dma_sync_single() called, UNIMPLEMENTED\n"); + /* nothing yet */ +} + +void my_dma_sync_sg(struct device *hwdev, + struct scatterlist *sg, + int nelems, int direction) +{ + DPRINT1("dma_sync_sg() called, UNIMPLEMENTED\n"); + /* nothing yet */ +} + + +int my_dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, enum dma_data_direction direction) +{ + DPRINT1("dma_map_sg() called, UNIMPLEMENTED\n"); + return 0; +} + +void my_dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents, enum dma_data_direction direction) +{ + DPRINT1("dma_unmap_sg() called, UNIMPLEMENTED\n"); + /* nothing yet */ +} + +/* forwarder ro dma_ equivalent */ +void my_pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction) +{ + my_dma_unmap_single(&hwdev->dev, dma_addr, size, direction); +}
19 years, 6 months
1
0
0
0
← Newer
1
...
25
26
27
28
29
30
31
...
57
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
57
Results per page:
10
25
50
100
200